summaryrefslogtreecommitdiffstats
path: root/bgpd/rfapi/rfapi_nve_addr.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/rfapi/rfapi_nve_addr.c')
-rw-r--r--bgpd/rfapi/rfapi_nve_addr.c169
1 files changed, 76 insertions, 93 deletions
diff --git a/bgpd/rfapi/rfapi_nve_addr.c b/bgpd/rfapi/rfapi_nve_addr.c
index f80455bbe..0fb887912 100644
--- a/bgpd/rfapi/rfapi_nve_addr.c
+++ b/bgpd/rfapi/rfapi_nve_addr.c
@@ -1,4 +1,4 @@
-/*
+/*
*
* Copyright 2009-2016, LabN Consulting, L.L.C.
*
@@ -41,135 +41,118 @@
#define DEBUG_NVE_ADDR 0
-void rfapiNveAddr2Str (struct rfapi_nve_addr *, char *, int);
+void rfapiNveAddr2Str(struct rfapi_nve_addr *, char *, int);
#if DEBUG_NVE_ADDR
-static void
-logdifferent (const char *tag,
- struct rfapi_nve_addr *a, struct rfapi_nve_addr *b)
+static void logdifferent(const char *tag, struct rfapi_nve_addr *a,
+ struct rfapi_nve_addr *b)
{
- char a_str[BUFSIZ];
- char b_str[BUFSIZ];
+ char a_str[BUFSIZ];
+ char b_str[BUFSIZ];
- rfapiNveAddr2Str (a, a_str, BUFSIZ);
- rfapiNveAddr2Str (b, b_str, BUFSIZ);
- vnc_zlog_debug_verbose ("%s: [%s] [%s]", tag, a_str, b_str);
+ rfapiNveAddr2Str(a, a_str, BUFSIZ);
+ rfapiNveAddr2Str(b, b_str, BUFSIZ);
+ vnc_zlog_debug_verbose("%s: [%s] [%s]", tag, a_str, b_str);
}
#endif
-int
-rfapi_nve_addr_cmp (void *k1, void *k2)
+int rfapi_nve_addr_cmp(void *k1, void *k2)
{
- struct rfapi_nve_addr *a = (struct rfapi_nve_addr *) k1;
- struct rfapi_nve_addr *b = (struct rfapi_nve_addr *) k2;
- int ret = 0;
+ struct rfapi_nve_addr *a = (struct rfapi_nve_addr *)k1;
+ struct rfapi_nve_addr *b = (struct rfapi_nve_addr *)k2;
+ int ret = 0;
- if (!a || !b)
- {
+ if (!a || !b) {
#if DEBUG_NVE_ADDR
- vnc_zlog_debug_verbose ("%s: missing address a=%p b=%p", __func__, a, b);
+ vnc_zlog_debug_verbose("%s: missing address a=%p b=%p",
+ __func__, a, b);
#endif
- return (a - b);
- }
- if (a->un.addr_family != b->un.addr_family)
- {
+ return (a - b);
+ }
+ if (a->un.addr_family != b->un.addr_family) {
#if DEBUG_NVE_ADDR
- vnc_zlog_debug_verbose ("diff: UN addr fam a->un.af=%d, b->un.af=%d",
- a->un.addr_family, b->un.addr_family);
+ vnc_zlog_debug_verbose(
+ "diff: UN addr fam a->un.af=%d, b->un.af=%d",
+ a->un.addr_family, b->un.addr_family);
#endif
- return (a->un.addr_family - b->un.addr_family);
- }
- if (a->un.addr_family == AF_INET)
- {
- ret = IPV4_ADDR_CMP (&a->un.addr.v4, &b->un.addr.v4);
- if (ret != 0)
- {
+ return (a->un.addr_family - b->un.addr_family);
+ }
+ if (a->un.addr_family == AF_INET) {
+ ret = IPV4_ADDR_CMP(&a->un.addr.v4, &b->un.addr.v4);
+ if (ret != 0) {
#if DEBUG_NVE_ADDR
- logdifferent ("diff: UN addr", a, b);
+ logdifferent("diff: UN addr", a, b);
#endif
- return ret;
- }
- }
- else if (a->un.addr_family == AF_INET6)
- {
- ret = IPV6_ADDR_CMP (&a->un.addr.v6, &b->un.addr.v6);
- if (ret == 0)
- {
+ return ret;
+ }
+ } else if (a->un.addr_family == AF_INET6) {
+ ret = IPV6_ADDR_CMP(&a->un.addr.v6, &b->un.addr.v6);
+ if (ret == 0) {
#if DEBUG_NVE_ADDR
- logdifferent ("diff: UN addr", a, b);
+ logdifferent("diff: UN addr", a, b);
#endif
- return ret;
- }
- }
- else
- {
- assert (0);
- }
- if (a->vn.addr_family != b->vn.addr_family)
- {
+ return ret;
+ }
+ } else {
+ assert(0);
+ }
+ if (a->vn.addr_family != b->vn.addr_family) {
#if DEBUG_NVE_ADDR
- vnc_zlog_debug_verbose ("diff: pT addr fam a->vn.af=%d, b->vn.af=%d",
- a->vn.addr_family, b->vn.addr_family);
+ vnc_zlog_debug_verbose(
+ "diff: pT addr fam a->vn.af=%d, b->vn.af=%d",
+ a->vn.addr_family, b->vn.addr_family);
#endif
- return (a->vn.addr_family - b->vn.addr_family);
- }
- if (a->vn.addr_family == AF_INET)
- {
- ret = IPV4_ADDR_CMP (&a->vn.addr.v4, &b->vn.addr.v4);
- if (ret != 0)
- {
+ return (a->vn.addr_family - b->vn.addr_family);
+ }
+ if (a->vn.addr_family == AF_INET) {
+ ret = IPV4_ADDR_CMP(&a->vn.addr.v4, &b->vn.addr.v4);
+ if (ret != 0) {
#if DEBUG_NVE_ADDR
- logdifferent ("diff: VN addr", a, b);
+ logdifferent("diff: VN addr", a, b);
#endif
- return ret;
- }
- }
- else if (a->vn.addr_family == AF_INET6)
- {
- ret = IPV6_ADDR_CMP (&a->vn.addr.v6, &b->vn.addr.v6);
- if (ret == 0)
- {
+ return ret;
+ }
+ } else if (a->vn.addr_family == AF_INET6) {
+ ret = IPV6_ADDR_CMP(&a->vn.addr.v6, &b->vn.addr.v6);
+ if (ret == 0) {
#if DEBUG_NVE_ADDR
- logdifferent ("diff: VN addr", a, b);
+ logdifferent("diff: VN addr", a, b);
#endif
- return ret;
- }
- }
- else
- {
- assert (0);
- }
- return 0;
+ return ret;
+ }
+ } else {
+ assert(0);
+ }
+ return 0;
}
-void
-rfapiNveAddr2Str (struct rfapi_nve_addr *na, char *buf, int bufsize)
+void rfapiNveAddr2Str(struct rfapi_nve_addr *na, char *buf, int bufsize)
{
- char *p = buf;
- int r;
+ char *p = buf;
+ int r;
#define REMAIN (bufsize - (p-buf))
#define INCP {p += (r > REMAIN)? REMAIN: r;}
- if (bufsize < 1)
- return;
+ if (bufsize < 1)
+ return;
- r = snprintf (p, REMAIN, "VN=");
- INCP;
+ r = snprintf(p, REMAIN, "VN=");
+ INCP;
- if (!rfapiRfapiIpAddr2Str (&na->vn, p, REMAIN))
- goto done;
+ if (!rfapiRfapiIpAddr2Str(&na->vn, p, REMAIN))
+ goto done;
- buf[bufsize - 1] = 0;
- p = buf + strlen (buf);
+ buf[bufsize - 1] = 0;
+ p = buf + strlen(buf);
- r = snprintf (p, REMAIN, ", UN=");
- INCP;
+ r = snprintf(p, REMAIN, ", UN=");
+ INCP;
- rfapiRfapiIpAddr2Str (&na->un, p, REMAIN);
+ rfapiRfapiIpAddr2Str(&na->un, p, REMAIN);
done:
- buf[bufsize - 1] = 0;
+ buf[bufsize - 1] = 0;
}