From 8e0608d31d988333ff04f3faaa6e851c0ecdbc6e Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Thu, 22 Apr 2010 16:52:29 +0200 Subject: Fourth stage to ipset-5 Add new userspace files: include/, lib/ and plus new files in src/. --- include/libipset/session.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 include/libipset/session.h (limited to 'include/libipset/session.h') diff --git a/include/libipset/session.h b/include/libipset/session.h new file mode 100644 index 0000000..71b8e02 --- /dev/null +++ b/include/libipset/session.h @@ -0,0 +1,81 @@ +/* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef LIBIPSET_SESSION_H +#define LIBIPSET_SESSION_H + +#include /* bool */ +#include /* uintxx_t */ +#include /* printf */ + +#include /* enum ipset_cmd */ +#include /* enum ipset_envopt */ + +/* Report and output buffer sizes */ +#define IPSET_ERRORBUFLEN 1024 +#define IPSET_OUTBUFLEN 8192 + +struct ipset_session; +struct ipset_data; +struct ipset_handle; + +extern struct ipset_data * ipset_session_data(const struct ipset_session *session); +extern struct ipset_handle * ipset_session_handle(const struct ipset_session *session); + +enum ipset_err_type { + IPSET_ERROR, + IPSET_WARNING, +}; + +extern int ipset_session_report(struct ipset_session *session, + enum ipset_err_type type, + const char *fmt, ...); + +#define ipset_err(session, fmt, args...) \ + ipset_session_report(session, IPSET_ERROR, fmt , ## args) + +#define ipset_warn(session, fmt, args...) \ + ipset_session_report(session, IPSET_WARNING, fmt , ## args) + +#define ipset_errptr(session, fmt, args...) ({ \ + ipset_session_report(session, IPSET_ERROR, fmt , ## args); \ + NULL; \ +}) + +extern void ipset_session_report_reset(struct ipset_session *session); +extern const char * ipset_session_error(const struct ipset_session *session); +extern const char * ipset_session_warning(const struct ipset_session *session); + +#define ipset_session_data_set(session, opt, value) \ + ipset_data_set(ipset_session_data(session), opt, value) +#define ipset_session_data_get(session, opt) \ + ipset_data_get(ipset_session_data(session), opt) + +enum ipset_output_mode { + IPSET_LIST_NONE, + IPSET_LIST_PLAIN, + IPSET_LIST_SAVE, + IPSET_LIST_XML, +}; + +extern int ipset_envopt_parse(struct ipset_session *session, + int env, const char *str); +extern bool ipset_envopt_test(struct ipset_session *session, + enum ipset_envopt env); +extern int ipset_session_output(struct ipset_session *session, + enum ipset_output_mode mode); + +extern int ipset_commit(struct ipset_session *session); +extern int ipset_cmd(struct ipset_session *session, enum ipset_cmd cmd, + uint32_t lineno); + +typedef int (*ipset_outfn)(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +extern struct ipset_session * ipset_session_init(ipset_outfn outfn); +extern int ipset_session_fini(struct ipset_session *session); + +#endif /* LIBIPSET_SESSION_H */ -- cgit v1.2.3