diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-04-13 22:53:30 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-04-13 22:53:30 +0000 |
commit | dc0d3d1fb6747911830f06804c440b25e0a8f1fb (patch) | |
tree | 941b11e5c4acc9f07cd01fe633d92934b3c2bc1a | |
parent | a8780e080309fc91a1dbcd87f8263df4cc68efd1 (diff) |
parse the BGP Multiprotocol Extensions (RFC 2858) capabilities and store in
the peer struct, claudio ok
-rw-r--r-- | usr.sbin/bgpd/session.c | 26 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.h | 5 |
2 files changed, 28 insertions, 3 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; } diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 1a8becb38a4..943bcd1efa2 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.39 2004/03/11 14:22:23 claudio Exp $ */ +/* $OpenBSD: session.h,v 1.40 2004/04/13 22:53:29 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -142,6 +142,9 @@ struct peer_auth { struct peer_capa { u_int8_t announce; + u_int8_t mp_v4; /* multiprotocol extensions, RFC 2858 */ + u_int8_t mp_v6; + u_int8_t refresh; /* route refresh, RFC 2918 */ }; struct peer { |