From 1759d7ec38637e1eaf009619f463d6b121e23502 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Wed, 18 Mar 2015 20:58:25 +0100 Subject: Support linking libipset to C++ programs Issue reported by Pavel Odintsov. --- include/libipset/data.h | 8 ++++++++ include/libipset/errcode.h | 8 ++++++++ include/libipset/icmp.h | 8 ++++++++ include/libipset/icmpv6.h | 8 ++++++++ include/libipset/mnl.h | 9 ++++++++- include/libipset/parse.h | 8 ++++++++ include/libipset/print.h | 8 ++++++++ include/libipset/session.h | 8 ++++++++ include/libipset/types.h | 8 ++++++++ include/libipset/ui.h | 8 ++++++++ 10 files changed, 80 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libipset/data.h b/include/libipset/data.h index 945df54..ca21890 100644 --- a/include/libipset/data.h +++ b/include/libipset/data.h @@ -131,6 +131,10 @@ enum ipset_opt { struct ipset_data; +#ifdef __cplusplus +extern "C" { +#endif + extern void ipset_strlcpy(char *dst, const char *src, size_t len); extern void ipset_strlcat(char *dst, const char *src, size_t len); extern bool ipset_data_flags_test(const struct ipset_data *data, @@ -164,4 +168,8 @@ extern void ipset_data_fini(struct ipset_data *data); extern size_t ipset_data_sizeof(enum ipset_opt opt, uint8_t family); +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_DATA_H */ diff --git a/include/libipset/errcode.h b/include/libipset/errcode.h index 1593d89..6b9dfe0 100644 --- a/include/libipset/errcode.h +++ b/include/libipset/errcode.h @@ -18,7 +18,15 @@ struct ipset_errcode_table { const char *message; /* error message the code translated to */ }; +#ifdef __cplusplus +extern "C" { +#endif + extern int ipset_errcode(struct ipset_session *session, enum ipset_cmd cmd, int errcode); +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_ERRCODE_H */ diff --git a/include/libipset/icmp.h b/include/libipset/icmp.h index e27fd4a..914b5e8 100644 --- a/include/libipset/icmp.h +++ b/include/libipset/icmp.h @@ -9,8 +9,16 @@ #include /* uintxx_t */ +#ifdef __cplusplus +extern "C" { +#endif + extern const char *id_to_icmp(uint8_t id); extern const char *icmp_to_name(uint8_t type, uint8_t code); extern int name_to_icmp(const char *str, uint16_t *typecode); +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_ICMP_H */ diff --git a/include/libipset/icmpv6.h b/include/libipset/icmpv6.h index 8295445..69c1119 100644 --- a/include/libipset/icmpv6.h +++ b/include/libipset/icmpv6.h @@ -9,8 +9,16 @@ #include /* uintxx_t */ +#ifdef __cplusplus +extern "C" { +#endif + extern const char *id_to_icmpv6(uint8_t id); extern const char *icmpv6_to_name(uint8_t type, uint8_t code); extern int name_to_icmpv6(const char *str, uint16_t *typecode); +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_ICMPV6_H */ diff --git a/include/libipset/mnl.h b/include/libipset/mnl.h index 0516ec7..7aaf44e 100644 --- a/include/libipset/mnl.h +++ b/include/libipset/mnl.h @@ -22,8 +22,15 @@ struct nfgenmsg { }; #endif -extern int ipset_get_nlmsg_type(const struct nlmsghdr *nlh); +#ifdef __cplusplus +extern "C" { +#endif +extern int ipset_get_nlmsg_type(const struct nlmsghdr *nlh); extern const struct ipset_transport ipset_mnl_transport; +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_MNL_H */ diff --git a/include/libipset/parse.h b/include/libipset/parse.h index 810ea28..9223eeb 100644 --- a/include/libipset/parse.h +++ b/include/libipset/parse.h @@ -24,6 +24,10 @@ struct ipset_arg; typedef int (*ipset_parsefn)(struct ipset_session *s, enum ipset_opt opt, const char *str); +#ifdef __cplusplus +extern "C" { +#endif + extern int ipset_parse_ether(struct ipset_session *session, enum ipset_opt opt, const char *str); extern int ipset_parse_port(struct ipset_session *session, @@ -116,4 +120,8 @@ extern int ipset_parse_iptimeout(struct ipset_session *session, extern int ipset_parse_name_compat(struct ipset_session *session, enum ipset_opt opt, const char *str); +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_PARSE_H */ diff --git a/include/libipset/print.h b/include/libipset/print.h index 8f672c3..2103ce1 100644 --- a/include/libipset/print.h +++ b/include/libipset/print.h @@ -13,6 +13,10 @@ typedef int (*ipset_printfn)(char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env); +#ifdef __cplusplus +extern "C" { +#endif + extern int ipset_print_ether(char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env); @@ -77,4 +81,8 @@ extern int ipset_print_data(char *buf, unsigned int len, const struct ipset_data *data, enum ipset_opt opt, uint8_t env); +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_PRINT_H */ diff --git a/include/libipset/session.h b/include/libipset/session.h index 988233e..833f763 100644 --- a/include/libipset/session.h +++ b/include/libipset/session.h @@ -21,6 +21,10 @@ struct ipset_session; struct ipset_data; struct ipset_handle; +#ifdef __cplusplus +extern "C" { +#endif + extern struct ipset_data * ipset_session_data(const struct ipset_session *session); extern struct ipset_handle * @@ -104,4 +108,8 @@ extern int ipset_session_fini(struct ipset_session *session); extern void ipset_debug_msg(const char *dir, void *buffer, int len); +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_SESSION_H */ diff --git a/include/libipset/types.h b/include/libipset/types.h index c98855e..7f41afc 100644 --- a/include/libipset/types.h +++ b/include/libipset/types.h @@ -86,6 +86,10 @@ struct ipset_type { const char *alias[]; /* name alias(es) */ }; +#ifdef __cplusplus +extern "C" { +#endif + extern int ipset_cache_add(const char *name, const struct ipset_type *type, uint8_t family); extern int ipset_cache_del(const char *name); @@ -107,6 +111,10 @@ extern bool ipset_match_typename(const char *str, const struct ipset_type *t); extern void ipset_load_types(void); +#ifdef __cplusplus +} +#endif + #ifdef TYPE_INCLUSIVE # ifdef _INIT # undef _init diff --git a/include/libipset/ui.h b/include/libipset/ui.h index 2b7119e..4846dc1 100644 --- a/include/libipset/ui.h +++ b/include/libipset/ui.h @@ -20,6 +20,10 @@ struct ipset_commands { const char *help; }; +#ifdef __cplusplus +extern "C" { +#endif + extern const struct ipset_commands ipset_commands[]; struct ipset_session; @@ -45,4 +49,8 @@ extern void ipset_shift_argv(int *argc, char *argv[], int from); extern void ipset_port_usage(void); extern int ipset_parse_file(struct ipset_session *s, int opt, const char *str); +#ifdef __cplusplus +} +#endif + #endif /* LIBIPSET_UI_H */ -- cgit v1.2.3