summaryrefslogtreecommitdiff
path: root/net/openbgpd/files/patch-bgpd_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/openbgpd/files/patch-bgpd_util.c')
-rw-r--r--net/openbgpd/files/patch-bgpd_util.c56
1 files changed, 46 insertions, 10 deletions
diff --git a/net/openbgpd/files/patch-bgpd_util.c b/net/openbgpd/files/patch-bgpd_util.c
index 4503f07a196b..88c95a8423d8 100644
--- a/net/openbgpd/files/patch-bgpd_util.c
+++ b/net/openbgpd/files/patch-bgpd_util.c
@@ -2,13 +2,13 @@ Index: bgpd/util.c
===================================================================
RCS file: /home/cvs/private/hrs/openbgpd/bgpd/util.c,v
retrieving revision 1.1.1.6
-retrieving revision 1.4
-diff -u -p -r1.1.1.6 -r1.4
+retrieving revision 1.5
+diff -u -p -r1.1.1.6 -r1.5
--- bgpd/util.c 14 Feb 2010 20:19:57 -0000 1.1.1.6
-+++ bgpd/util.c 4 Feb 2010 16:22:23 -0000 1.4
++++ bgpd/util.c 10 Apr 2010 12:16:23 -0000 1.5
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.6 2009/06/12 16:42:53 claudio Exp $ */
-+/* $OpenBSD: util.c,v 1.10 2010/01/13 06:02:37 claudio Exp $ */
++/* $OpenBSD: util.c,v 1.11 2010/03/29 09:04:43 claudio Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -22,9 +22,11 @@ diff -u -p -r1.1.1.6 -r1.4
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
-@@ -33,10 +36,20 @@ log_addr(const struct bgpd_addr *addr)
+@@ -32,11 +35,24 @@ const char *
+ log_addr(const struct bgpd_addr *addr)
{
static char buf[48];
++ char tbuf[16];
- if (inet_ntop(addr->af, &addr->ba, buf, sizeof(buf)) == NULL)
- return ("?");
@@ -37,20 +39,54 @@ diff -u -p -r1.1.1.6 -r1.4
+ return ("?");
+ return (buf);
+ case AID_VPN_IPv4:
-+ if (inet_ntop(AF_INET, &addr->vpn4.addr, buf,
-+ sizeof(buf)) == NULL)
++ if (inet_ntop(AF_INET, &addr->vpn4.addr, tbuf,
++ sizeof(tbuf)) == NULL)
+ return ("?");
++ snprintf(buf, sizeof(buf), "%s %s", log_rd(addr->vpn4.rd),
++ tbuf);
return (buf);
+ }
+ return ("???");
}
const char *
-@@ -90,6 +103,32 @@ log_as(u_int32_t as)
+@@ -90,6 +106,64 @@ log_as(u_int32_t as)
return (buf);
}
-+/* XXX this function does not check if the type/subtype combo is
++const char *
++log_rd(u_int64_t rd)
++{
++ static char buf[32];
++ struct in_addr addr;
++ u_int32_t u32;
++ u_int16_t u16;
++
++ rd = betoh64(rd);
++ switch (rd >> 48) {
++ case EXT_COMMUNITY_TWO_AS:
++ u32 = rd & 0xffffffff;
++ u16 = (rd >> 32) & 0xffff;
++ snprintf(buf, sizeof(buf), "rd %i:%i", u16, u32);
++ break;
++ case EXT_COMMUNITY_FOUR_AS:
++ u32 = (rd >> 16) & 0xffffffff;
++ u16 = rd & 0xffff;
++ snprintf(buf, sizeof(buf), "rd %s:%i", log_as(u32), u16);
++ break;
++ case EXT_COMMUNITY_IPV4:
++ u32 = (rd >> 16) & 0xffffffff;
++ u16 = rd & 0xffff;
++ addr.s_addr = htonl(u32);
++ snprintf(buf, sizeof(buf), "rd %s:%i", inet_ntoa(addr), u16);
++ break;
++ default:
++ return ("rd ?");
++ }
++ return (buf);
++}
++
++/* NOTE: this function does not check if the type/subtype combo is
+ * actually valid. */
+const char *
+log_ext_subtype(u_int8_t subtype)
@@ -79,7 +115,7 @@ diff -u -p -r1.1.1.6 -r1.4
int
aspath_snprint(char *buf, size_t size, void *data, u_int16_t len)
{
-@@ -276,3 +315,115 @@ inet6applymask(struct in6_addr *dest, co
+@@ -276,3 +350,115 @@ inet6applymask(struct in6_addr *dest, co
for (i = 0; i < 16; i++)
dest->s6_addr[i] = src->s6_addr[i] & mask.s6_addr[i];
}