1
+ #ifndef TCPINFO_C_ADAPTER_H_
2
+ #define TCPINFO_C_ADAPTER_H_
3
+
1
4
// Copyright 2016 measurement-lab
2
5
//
3
6
// Licensed under the Apache License, Version 2.0 (the "License");
13
16
// limitations under the License.
14
17
15
18
/****************************************************************************
16
- * This file contains declarations that are used by both .c files and .cc
17
- * files. When included in .cc files, it must be enclosed in an extern "C"
18
- * block.
19
- *
20
- * fetch_tcpinfo(...) is implemented in the tcpinfo_c_adapter.c for easy
21
- * access to C libraries.
22
- * update_record(...) is implemented in tcpinfo_lib.cc, because it requires
23
- * access to C++ functions.
19
+ * fetch_tcpinfo() is called from C++, but implemented in C to provide clear
20
+ * linkage to C library functions.
24
21
****************************************************************************/
25
22
26
- #ifndef TCPINFO_C_ADAPTER_H_
27
- #define TCPINFO_C_ADAPTER_H_
28
-
29
- #include <linux/inet_diag.h>
30
- #include <linux/netlink.h>
31
- #include <sys/socket.h>
32
-
33
- #include "libnetlink.h"
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+ #include "libnetlink.h" // For rtnl_filter_t
34
27
35
28
struct inet_diag_arg {
36
29
int protocol ;
@@ -40,9 +33,7 @@ struct inet_diag_arg {
40
33
// `callback` has rtnl_filter_t signature, and is passed to rtnl_dump_filter.
41
34
int fetch_tcpinfo (rtnl_filter_t callback );
42
35
43
- // rtnl_filter_t function to handle each result, passed into fetch_tcpinfo()
44
- // function. Implementation in tcpinfo_lib.cc
45
- int update_record (const struct sockaddr_nl * addr ,
46
- struct nlmsghdr * nlh , void * arg );
47
-
36
+ #ifdef __cplusplus
37
+ }
38
+ #endif
48
39
#endif // TCPINFO_C_ADAPTER_H_
0 commit comments