summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/rde_rib.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-08-13 14:03:21 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-08-13 14:03:21 +0000
commite3c8d54a792ae8babd51739f377ebc34a8498a35 (patch)
treeaf3a5f9f65e445023839ef552bdf3d593494426d /usr.sbin/bgpd/rde_rib.c
parentd292483c42a9ff83da5520765dc5ef88c785dba1 (diff)
Fix minor issues with IPv6 dumps and add a function for dumping the RIB table
protocol independent. This new dump format is not (yet) supported by the mrtd route_btoa tool. OK henning@
Diffstat (limited to 'usr.sbin/bgpd/rde_rib.c')
-rw-r--r--usr.sbin/bgpd/rde_rib.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index 77cbc89fbd9..f3f00a7668e 100644
--- a/usr.sbin/bgpd/rde_rib.c
+++ b/usr.sbin/bgpd/rde_rib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_rib.c,v 1.57 2004/08/12 10:24:16 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.58 2004/08/13 14:03:20 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -489,6 +489,24 @@ prefix_remove(struct rde_peer *peer, struct bgpd_addr *prefix, int prefixlen)
path_destroy(asp);
}
+/* dump a prefix into specified buffer */
+int
+prefix_write(u_char *buf, int len, struct bgpd_addr *prefix, u_int8_t plen)
+{
+ int totlen;
+
+ if (prefix->af != AF_INET)
+ return (-1);
+
+ totlen = PREFIX_SIZE(plen);
+
+ if (totlen > len)
+ return (-1);
+ *buf++ = plen;
+ memcpy(buf, &prefix->ba, totlen - 1);
+ return (totlen);
+}
+
/*
* Searches in the prefix list of specified pt_entry for a prefix entry
* belonging to the peer peer. Returns NULL if no match found.