netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Ease usage of libnetfilter_log with C++ applications
@ 2019-07-03  6:46 Stefan Laufmann
  2019-07-03 11:18 ` Florian Westphal
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Laufmann @ 2019-07-03  6:46 UTC (permalink / raw)
  To: netfilter-devel

Hello,

thanks for your work on the netfilter project.

I just recently came across libnetfilter_log and used it inside a C++ 
application. When compiling/linking the project I ran into problems and 
discovered that libnetfilter_log in contrast to e.g. libnetfilter_queue 
and libnetfilter_conntrack lacks `extern "C"` statements in the header 
files.

Are their reasons for that? I would like to suggest to add these 
statements so the library can be easily used from a C++ context.

Kind Regards
Stefan Laufmann

--
emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Goettingen, Amtsgericht Goettingen HR B 3160
Geschaeftsfuehrung: Heike Jordan, Dr. Uwe Kracke
Ust-IdNr.: DE 205 198 055

emlix - smart embedded open source

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ease usage of libnetfilter_log with C++ applications
  2019-07-03  6:46 Ease usage of libnetfilter_log with C++ applications Stefan Laufmann
@ 2019-07-03 11:18 ` Florian Westphal
  2019-07-03 11:25   ` [PATCH] Added extern "C" declarations to header-files Jeremy Sowden
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Westphal @ 2019-07-03 11:18 UTC (permalink / raw)
  To: Stefan Laufmann; +Cc: netfilter-devel

Stefan Laufmann <stefan.laufmann@emlix.com> wrote:
> I just recently came across libnetfilter_log and used it inside a C++
> application. When compiling/linking the project I ran into problems and
> discovered that libnetfilter_log in contrast to e.g. libnetfilter_queue and
> libnetfilter_conntrack lacks `extern "C"` statements in the header files.
> 
> Are their reasons for that?

Noone sent a patch to add them.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Added extern "C" declarations to header-files.
  2019-07-03 11:18 ` Florian Westphal
@ 2019-07-03 11:25   ` Jeremy Sowden
  2019-07-03 11:35     ` Pablo Neira Ayuso
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Sowden @ 2019-07-03 11:25 UTC (permalink / raw)
  To: Netfilter Devel; +Cc: Stefan Laufmann

Declare functions with extern "C" for inclusion in C++.

Reported-by: Stefan Laufmann <stefan.laufmann@emlix.com>
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
 include/libnetfilter_log/libipulog.h        | 8 ++++++++
 include/libnetfilter_log/libnetfilter_log.h | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/include/libnetfilter_log/libipulog.h b/include/libnetfilter_log/libipulog.h
index ee7890a2d93c..deb0dcc72577 100644
--- a/include/libnetfilter_log/libipulog.h
+++ b/include/libnetfilter_log/libipulog.h
@@ -16,6 +16,10 @@
 #define ULOG_PREFIX_LEN	32
 #define ULOG_IFNAMSIZ	16
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Format of the ULOG packets passed through netlink */
 typedef struct ulog_packet_msg {
 	unsigned long mark;
@@ -67,5 +71,9 @@ enum
 };
 #define IPULOG_MAXERR IPULOG_ERR_INVNL
 
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
 
 #endif /* _LIBIPULOG_H */
diff --git a/include/libnetfilter_log/libnetfilter_log.h b/include/libnetfilter_log/libnetfilter_log.h
index 46767eb003c9..6192fa3a5cf1 100644
--- a/include/libnetfilter_log/libnetfilter_log.h
+++ b/include/libnetfilter_log/libnetfilter_log.h
@@ -14,6 +14,10 @@
 #include <linux/netlink.h>
 #include <libnetfilter_log/linux_nfnetlink_log.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct nflog_handle;
 struct nflog_g_handle;
 struct nflog_data;
@@ -97,4 +101,8 @@ int nflog_nlmsg_snprintf(char *buf, size_t bufsiz, const struct nlmsghdr *nlh,
 			 struct nlattr **attr, enum nflog_output_type type,
 			 uint32_t flags);
 
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
 #endif	/* __LIBNETFILTER_LOG_H */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Added extern "C" declarations to header-files.
  2019-07-03 11:25   ` [PATCH] Added extern "C" declarations to header-files Jeremy Sowden
@ 2019-07-03 11:35     ` Pablo Neira Ayuso
  2019-07-03 11:37       ` Jeremy Sowden
  0 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2019-07-03 11:35 UTC (permalink / raw)
  To: Jeremy Sowden; +Cc: Netfilter Devel, Stefan Laufmann

On Wed, Jul 03, 2019 at 12:25:38PM +0100, Jeremy Sowden wrote:
> Declare functions with extern "C" for inclusion in C++.

Applied, thanks.

Please, next time specify [PATCH libnetfilter_log] so we know what
tree this patch is going to :-)

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Added extern "C" declarations to header-files.
  2019-07-03 11:35     ` Pablo Neira Ayuso
@ 2019-07-03 11:37       ` Jeremy Sowden
  0 siblings, 0 replies; 5+ messages in thread
From: Jeremy Sowden @ 2019-07-03 11:37 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: Netfilter Devel, Stefan Laufmann

[-- Attachment #1: Type: text/plain, Size: 336 bytes --]

On 2019-07-03, at 13:35:35 +0200, Pablo Neira Ayuso wrote:
> On Wed, Jul 03, 2019 at 12:25:38PM +0100, Jeremy Sowden wrote:
> > Declare functions with extern "C" for inclusion in C++.
>
> Applied, thanks.
>
> Please, next time specify [PATCH libnetfilter_log] so we know what
> tree this patch is going to :-)

Cheers.  Will do. :)

J.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-03 11:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-03  6:46 Ease usage of libnetfilter_log with C++ applications Stefan Laufmann
2019-07-03 11:18 ` Florian Westphal
2019-07-03 11:25   ` [PATCH] Added extern "C" declarations to header-files Jeremy Sowden
2019-07-03 11:35     ` Pablo Neira Ayuso
2019-07-03 11:37       ` Jeremy Sowden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).