libnetfilter_conntrack: add extern C's to public headers
PATCH 1/1 libnetfilter_conntrack: add extern C's to public headers
The attached patch adds:
extern "C" {...}
to all of the public headers in libnetfilter_conntrack's public headers. It is, of course, #ifdef __cplusplus'd.
This will make it more straight forward for C++ developers to use libnetfilter_conntrack in their applications.
Signature · 9 lines
Phil Dibowitz [email protected] Open Source software and tech docs Insanity Palace of Metallica http://www.phildev.net/ http://www.ipom.com/ "Never write it in C if you can do it in 'awk'; Never do it in 'awk' if 'sed' can handle it; Never use 'sed' when 'tr' can do the job; Never invoke 'tr' when 'cat' is sufficient; Avoid using 'cat' whenever possible" -- Taylor's Laws of Programming
include/libnetfilter_conntrack/libnetfilter_conntrack.h renamed from include/libnetfilter_conntrack/libnetfilter_conntrack.h.orig +8 -0
@@ -13,6 +13,10 @@#include <libnfnetlink/libnfnetlink.h> #include <libnetfilter_conntrack/linux_nfnetlink_conntrack.h> +#ifdef __cplusplus +extern "C" { +#endif +enum {CONNTRACK =NFNL_SUBSYS_CTNETLINK ,EXPECT =NFNL_SUBSYS_CTNETLINK_EXP
@@ -549,4 +553,8 @@void *req, unsigned int size); +#ifdef __cplusplus +} +#endif +#endif /* _LIBNETFILTER_CONNTRACK_H_ */
include/libnetfilter_conntrack/libnetfilter_conntrack_icmp.h renamed from include/libnetfilter_conntrack/libnetfilter_conntrack_icmp.h.orig +8 -0
@@ -8,6 +8,10 @@ #ifndef _LIBNETFILTER_CONNTRACK_ICMP_H_ #define _LIBNETFILTER_CONNTRACK_ICMP_H_ +#ifdef __cplusplus +extern "C" { +#endif + enum icmp_flags { ICMP_TYPE_BIT = 0, ICMP_TYPE = (1 << ICMP_TYPE_BIT),
@@ -19,4 +23,8 @@ICMP_ID = (1 <<ICMP_ID_BIT ) }; +#ifdef __cplusplus +} +#endif +#endif
include/libnetfilter_conntrack/libnetfilter_conntrack_ipv4.h renamed from include/libnetfilter_conntrack/libnetfilter_conntrack_ipv4.h.orig +8 -0
@@ -8,6 +8,10 @@ #ifndef _LIBNETFILTER_CONNTRACK_IPV4_H_ #define _LIBNETFILTER_CONNTRACK_IPV4_H_ +#ifdef __cplusplus +extern "C" { +#endif + enum ipv4_flags { IPV4_ORIG_SRC_BIT = 0, IPV4_ORIG_SRC = (1 << IPV4_ORIG_SRC_BIT),
@@ -26,4 +30,8 @@IPV4_REPL = (IPV4_REPL_SRC |IPV4_REPL_DST ) }; +#ifdef __cplusplus +} +#endif +#endif
include/libnetfilter_conntrack/libnetfilter_conntrack_ipv6.h renamed from include/libnetfilter_conntrack/libnetfilter_conntrack_ipv6.h.orig +8 -0
@@ -8,6 +8,10 @@ #ifndef _LIBNETFILTER_CONNTRACK_IPV6_H_ #define _LIBNETFILTER_CONNTRACK_IPV6_H_ +#ifdef __cplusplus +extern "C" { +#endif + enum ipv6_flags { IPV6_ORIG_SRC_BIT = 0, IPV6_ORIG_SRC = (1 << IPV6_ORIG_SRC_BIT),
@@ -26,4 +30,8 @@IPV6_REPL = (IPV6_REPL_SRC |IPV6_REPL_DST ) }; +#ifdef __cplusplus +} +#endif +#endif
include/libnetfilter_conntrack/libnetfilter_conntrack_sctp.h renamed from include/libnetfilter_conntrack/libnetfilter_conntrack_sctp.h.orig +8 -0
@@ -8,6 +8,10 @@ #ifndef _LIBNETFILTER_CONNTRACK_SCTP_H_ #define _LIBNETFILTER_CONNTRACK_SCTP_H_ +#ifdef __cplusplus +extern "C" { +#endif + enum sctp_flags { SCTP_ORIG_SPORT_BIT = 0, SCTP_ORIG_SPORT = (1 << SCTP_ORIG_SPORT_BIT),
@@ -37,4 +41,8 @@SCTP_EXPTUPLE_DPORT = (1 <<SCTP_EXPTUPLE_DPORT_BIT ) }; +#ifdef __cplusplus +} +#endif +#endif
include/libnetfilter_conntrack/libnetfilter_conntrack_tcp.h renamed from include/libnetfilter_conntrack/libnetfilter_conntrack_tcp.h.orig +8 -0
@@ -8,6 +8,10 @@ #ifndef _LIBNETFILTER_CONNTRACK_TCP_H_ #define _LIBNETFILTER_CONNTRACK_TCP_H_ +#ifdef __cplusplus +extern "C" { +#endif + enum tcp_state { TCP_CONNTRACK_NONE, TCP_CONNTRACK_SYN_SENT,
@@ -52,4 +56,8 @@TCP_EXPTUPLE_DPORT = (1 <<TCP_EXPTUPLE_DPORT_BIT ) }; +#ifdef __cplusplus +} +#endif +#endif
include/libnetfilter_conntrack/libnetfilter_conntrack_udp.h renamed from include/libnetfilter_conntrack/libnetfilter_conntrack_udp.h.orig +8 -0
@@ -8,6 +8,10 @@ #ifndef _LIBNETFILTER_CONNTRACK_UDP_H_ #define _LIBNETFILTER_CONNTRACK_UDP_H_ +#ifdef __cplusplus +extern "C" { +#endif + enum udp_flags { UDP_ORIG_SPORT_BIT = 0, UDP_ORIG_SPORT = (1 << UDP_ORIG_SPORT_BIT),
@@ -34,4 +38,8 @@UDP_EXPTUPLE_DPORT = (1 <<UDP_EXPTUPLE_DPORT_BIT ) }; +#ifdef __cplusplus +} +#endif +#endif
include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h renamed from include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h.orig +8 -0
@@ -2,6 +2,10 @@#define _IPCONNTRACK_NETLINK_H#include <libnfnetlink/linux_nfnetlink.h> +#ifdef __cplusplus +extern "C" { +#endif +enum cntl_msg_types {IPCTNL_MSG_CT_NEW ,IPCTNL_MSG_CT_GET ,
@@ -134,4 +138,8 @@ };#define CTA_HELP_MAX (__CTA_HELP_MAX - 1) +#ifdef __cplusplus +} +#endif +#endif /* _IPCONNTRACK_NETLINK_H */
Quoted 9 lines · Phil Dibowitz
The attached patch adds:
extern "C" {...}
to all of the public headers in libnetfilter_conntrack's public headers. It is, of course, #ifdef __cplusplus'd.
This will make it more straight forward for C++ developers to use
libnetfilter_conntrackin their applications.
I never saw a response to this patch... I was wondering if there was an objection to it, or if it got accepted, or forgotten, or...?
Signature · 9 lines
Phil Dibowitz [email protected] Open Source software and tech docs Insanity Palace of Metallica http://www.phildev.net/ http://www.ipom.com/ "Never write it in C if you can do it in 'awk'; Never do it in 'awk' if 'sed' can handle it; Never use 'sed' when 'tr' can do the job; Never invoke 'tr' when 'cat' is sufficient; Avoid using 'cat' whenever possible" -- Taylor's Laws of Programming
Pablo Neira Ayuso
maintainerSorry for the late reply.
include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h line 8
Quoted 10 lines · Phil Dibowitz
include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h renamed from include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h.orig +4
-0@@ -2,6 +2,10 @@#define _IPCONNTRACK_NETLINK_H#include <libnfnetlink/linux_nfnetlink.h> +#ifdef __cplusplus +extern "C" { +#endif +
Do you really need to include the extern "C" in linux_nfnetlink_conntrack.h?
Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
Quoted 9 lines · Pablo Neira Ayuso
Sorry for the late reply.
Quoted 6 lines · Phil Dibowitz
include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h renamed from include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h.orig +0
-0@@ -2,6 +2,10 @@#define _IPCONNTRACK_NETLINK_H#include <libnfnetlink/linux_nfnetlink.h>
Quoted 6 lines
include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h line 8
Quoted 4 lines
include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h renamed from include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h.orig +4
-0+#ifdef __cplusplus +extern "C" { +#endif +Do you really need to include the extern "C" in
linux_nfnetlink_conntrack.h?
I believe so, yes. The alternative is to put it around the #include of linux_nfnetlink_conntrack.h inside of libnetfilter_conntrack.h, but that isn't as clean and prevents anyone from using it directly. Anything in /usr/include is fair game for using in an #include, and thus should be extern-C-safe.
Signature · 9 lines
Phil Dibowitz [email protected] Open Source software and tech docs Insanity Palace of Metallica http://www.phildev.net/ http://www.ipom.com/ "Never write it in C if you can do it in 'awk'; Never do it in 'awk' if 'sed' can handle it; Never use 'sed' when 'tr' can do the job; Never invoke 'tr' when 'cat' is sufficient; Avoid using 'cat' whenever possible" -- Taylor's Laws of Programming
Quoted 7 lines · Phil Dibowitz
Quoted 1 line · Pablo Neira Ayuso
Do you really need to include the extern "C" in
linux_nfnetlink_conntrack.h?I believe so, yes. The alternative is to put it around the #include of
linux_nfnetlink_conntrack.hinside oflibnetfilter_conntrack.h, but that isn't as clean and prevents anyone from using it directly. Anything in/usr/includeis fair game for using in an #include, and thus should be extern-C-safe.
Applied. Thanks Phil.
BTW, got no reply on my suggestion about your project name. Thoughts?
Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
Quoted 4 lines · Pablo Neira Ayuso
Quoted 3 lines · Phil Dibowitz
Quoted 1 line · Pablo Neira Ayuso
Do you really need to include the extern "C" in
linux_nfnetlink_conntrack.h?
Quoted 8 lines
Quoted 4 lines
I believe so, yes. The alternative is to put it around the #include of
linux_nfnetlink_conntrack.hinside oflibnetfilter_conntrack.h, but that isn't as clean and prevents anyone from using it directly. Anything in/usr/includeis fair game for using in an #include, and thus should be extern-C-safe.Applied. Thanks Phil.
BTW, got no reply on my suggestion about your project name. Thoughts?
While I understand the point you were making, my project has been around for years - I'm not renaming it. That'll cause more confusion than anything else, IMO. It's in all major distros and many people are well acquanted with what the software is and is not...
Signature · 9 lines
Phil Dibowitz [email protected] Open Source software and tech docs Insanity Palace of Metallica http://www.phildev.net/ http://www.ipom.com/ "Never write it in C if you can do it in 'awk'; Never do it in 'awk' if 'sed' can handle it; Never use 'sed' when 'tr' can do the job; Never invoke 'tr' when 'cat' is sufficient; Avoid using 'cat' whenever possible" -- Taylor's Laws of Programming