summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/session.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-04-13 22:53:30 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-04-13 22:53:30 +0000
commitdc0d3d1fb6747911830f06804c440b25e0a8f1fb (patch)
tree941b11e5c4acc9f07cd01fe633d92934b3c2bc1a /usr.sbin/bgpd/session.c
parenta8780e080309fc91a1dbcd87f8263df4cc68efd1 (diff)
parse the BGP Multiprotocol Extensions (RFC 2858) capabilities and store in
the peer struct, claudio ok
Diffstat (limited to 'usr.sbin/bgpd/session.c')
-rw-r--r--usr.sbin/bgpd/session.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index c78f59457a5..0f1d125caa7 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.139 2004/03/20 23:17:35 david Exp $ */
+/* $OpenBSD: session.c,v 1.140 2004/04/13 22:53:29 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1624,7 +1624,9 @@ parse_capabilities(struct peer *peer, u_char *d, u_int16_t dlen)
u_int16_t len;
u_int8_t capa_code;
u_int8_t capa_len;
- void *capa_val;
+ u_char *capa_val;
+ u_int16_t mp_afi;
+ u_int8_t mp_safi;
len = dlen;
while (len > 0) {
@@ -1646,6 +1648,26 @@ parse_capabilities(struct peer *peer, u_char *d, u_int16_t dlen)
capa_val = NULL;
switch (capa_code) {
+ case CAPA_MP: /* RFC 2858 */
+ if (capa_len != 4)
+ return (-1);
+ memcpy(&mp_afi, capa_val, sizeof(mp_afi));
+ memcpy(&mp_safi, capa_val + 3, sizeof(mp_safi));
+ switch (mp_afi) {
+ case AFI_IPv4:
+ if (mp_safi < 1 || mp_safi > 3)
+ return (-1);
+ peer->capa.mp_v4 = mp_safi;
+ break;
+ case AFI_IPv6:
+ if (mp_safi < 1 || mp_safi > 3)
+ return (-1);
+ peer->capa.mp_v6 = mp_safi;
+ break;
+ default: /* ignore */
+ break;
+ }
+ break;
default:
break;
}