summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/rde_rib.c
diff options
context:
space:
mode:
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.