summaryrefslogtreecommitdiff
path: root/lib/prefix.h
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-02-13 12:47:23 -0500
committerGitHub <noreply@github.com>2019-02-13 12:47:23 -0500
commitcfef27e56ef3246a261ee0bf2810a46c08eebf8f (patch)
treeac66ba3d1f7a037ad51f21bd54a236d5388f5916 /lib/prefix.h
parent01490ba25da576ec0a72c896559ebc6fa71484be (diff)
parent8ed561e1f13d0afb019a7963238bdd43ad017bec (diff)
Merge pull request #3622 from mjstapp/fix_cpp_compile
libs, daemons: changes to permit c++ compilation
Diffstat (limited to 'lib/prefix.h')
-rw-r--r--lib/prefix.h38
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/prefix.h b/lib/prefix.h
index aaffb1e0c5..ae931288c0 100644
--- a/lib/prefix.h
+++ b/lib/prefix.h
@@ -35,6 +35,10 @@
#include "ipaddr.h"
#include "compiler.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifndef ETH_ALEN
#define ETH_ALEN 6
#endif
@@ -276,20 +280,29 @@ struct prefix_sg {
* side, which strips type safety since the cast will accept any pointer
* type.)
*/
+#ifndef __cplusplus
+#define prefixtype(uname, typename, fieldname) \
+ typename *fieldname;
+#else
+#define prefixtype(uname, typename, fieldname) \
+ typename *fieldname; \
+ uname(typename *x) { this->fieldname = x; }
+#endif
+
union prefixptr {
- struct prefix *p;
- struct prefix_ipv4 *p4;
- struct prefix_ipv6 *p6;
- struct prefix_evpn *evp;
- const struct prefix_fs *fs;
+ prefixtype(prefixptr, struct prefix, p)
+ prefixtype(prefixptr, struct prefix_ipv4, p4)
+ prefixtype(prefixptr, struct prefix_ipv6, p6)
+ prefixtype(prefixptr, struct prefix_evpn, evp)
+ prefixtype(prefixptr, struct prefix_fs, fs)
} __attribute__((transparent_union));
union prefixconstptr {
- const struct prefix *p;
- const struct prefix_ipv4 *p4;
- const struct prefix_ipv6 *p6;
- const struct prefix_evpn *evp;
- const struct prefix_fs *fs;
+ prefixtype(prefixconstptr, const struct prefix, p)
+ prefixtype(prefixconstptr, const struct prefix_ipv4, p4)
+ prefixtype(prefixconstptr, const struct prefix_ipv6, p6)
+ prefixtype(prefixconstptr, const struct prefix_evpn, evp)
+ prefixtype(prefixconstptr, const struct prefix_fs, fs)
} __attribute__((transparent_union));
#ifndef INET_ADDRSTRLEN
@@ -497,4 +510,9 @@ static inline int is_host_route(struct prefix *p)
return (p->prefixlen == IPV6_MAX_BITLEN);
return 0;
}
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _ZEBRA_PREFIX_H */