X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/f4fb6922fee52973e2f568f18411594c88b40aa2..1e722029bc405a555e81840c00708084128c5cdd:/bgp.h diff --git a/bgp.h b/bgp.h index db8b1ae..8e636ab 100644 --- a/bgp.h +++ b/bgp.h @@ -1,5 +1,5 @@ /* BGPv4 (RFC1771) */ -/* $Id: bgp.h,v 1.5 2005/06/04 15:42:35 bodea Exp $ */ +/* $Id: bgp.h,v 1.5 2005-06-04 15:42:35 bodea Exp $ */ #ifndef __BGP_H__ #define __BGP_H__ @@ -67,6 +67,10 @@ struct bgp_mp_cap_param { uint8_t safi; } __attribute__ ((packed)); +/* bgp_mp_cap_param.afi */ +#define BGP_MP_AFI_RESERVED 0 +#define BGP_MP_AFI_IPv4 1 +#define BGP_MP_AFI_IPv6 2 /* bgp_mp_cap_param.safi */ #define BGP_MP_SAFI_UNICAST 1 #define BGP_MP_SAFI_MULTICAST 2 @@ -101,6 +105,22 @@ struct bgp_path_attr { } data; /* variable */ } __attribute__ ((packed)); +struct bgp_attr_mp_reach_nlri_partial { + uint16_t afi; /* sa_family_t */ + uint8_t safi; + uint8_t next_hop_len; + uint8_t next_hop[16]; + uint8_t reserved; +} __attribute__ ((packed)); +#define BGP_PATH_ATTR_MP_REACH_NLRI_PARTIAL_SIZE (3 + sizeof(struct bgp_attr_mp_reach_nlri_partial)) + +struct bgp_attr_mp_unreach_nlri_partial { + uint16_t afi; /* sa_family_t */ + uint8_t safi; +} __attribute__ ((packed)); +/* we use it as an extended attribute */ +#define BGP_PATH_ATTR_MP_UNREACH_NLRI_PARTIAL_SIZE (4 + sizeof(struct bgp_attr_mp_unreach_nlri_partial)) + /* bgp_path_attr.flags (bitfields) */ #define BGP_PATH_ATTR_FLAG_OPTIONAL (1 << 7) #define BGP_PATH_ATTR_FLAG_TRANS (1 << 6) @@ -121,9 +141,11 @@ struct bgp_path_attr { #define BGP_PATH_ATTR_CODE_ATOMIC_AGGREGATE 6 /* well-known, discretionary */ #define BGP_PATH_ATTR_CODE_AGGREGATOR 7 /* optional, transitive */ #define BGP_PATH_ATTR_CODE_COMMUNITIES 8 /* optional, transitive (RFC1997) */ +#define BGP_PATH_ATTR_CODE_MP_REACH_NLRI 14 /* optional, non-transitive (RFC4760) */ +#define BGP_PATH_ATTR_CODE_MP_UNREACH_NLRI 15 /* optional, non-transitive (RFC4760) */ #define BGP_PATH_ATTR_SIZE(p) ((((p).flags & BGP_PATH_ATTR_FLAG_EXTLEN) \ - ? ((p).data.e.len + 1) : (p).data.s.len) + 3) + ? ((p).data.e.len + 4) : (p).data.s.len) + 3) /* well known COMMUNITIES */ #define BGP_COMMUNITY_NO_EXPORT 0xffffff01 /* don't advertise outside confederation */ @@ -191,10 +213,17 @@ struct bgp_buf { size_t done; /* bytes sent/recvd */ }; +enum bgp_mp_handling { + HandleIPv6Routes, + DoesntHandleIPv6Routes, + HandlingUnknown, +}; + /* state */ struct bgp_peer { char name[32]; /* peer name */ in_addr_t addr; /* peer address */ + in_addr_t source_addr; /* our source address */ int as; /* AS number */ int sock; enum bgp_state state; /* FSM state */ @@ -219,9 +248,11 @@ struct bgp_peer { int path_attr_len_without_nexthop; /* length of path attrs without NEXT_HOP */ uint32_t events; /* events to poll */ struct event_data edata; /* poll data */ - int handle_ipv6_routes; /* can handle IPv6 routes advertisements */ + enum bgp_mp_handling mp_handling; /* how it handles IPv6 routes advertisements */ int update_routes6; /* UPDATE required for IPv6 routes */ struct bgp_route6_list *routes6; /* IPv6 routes known by this peer */ + char mp_reach_nlri_partial[BGP_PATH_ATTR_MP_REACH_NLRI_PARTIAL_SIZE]; + char mp_unreach_nlri_partial[BGP_PATH_ATTR_MP_UNREACH_NLRI_PARTIAL_SIZE]; }; /* bgp_peer.cli_flag */ @@ -235,20 +266,19 @@ extern int bgp_configured; /* actions */ int bgp_setup(int as); int bgp_start(struct bgp_peer *peer, char *name, int as, int keepalive, - int hold, int enable); + int hold, struct in_addr update_source, int enable); void bgp_stop(struct bgp_peer *peer); void bgp_halt(struct bgp_peer *peer); int bgp_restart(struct bgp_peer *peer); -int bgp_add_route(in_addr_t ip, in_addr_t mask); +int bgp_add_route(in_addr_t ip, int prefixlen); int bgp_add_route6(struct in6_addr ip, int prefixlen); -int bgp_del_route(in_addr_t ip, in_addr_t mask); +int bgp_del_route(in_addr_t ip, int prefixlen); int bgp_del_route6(struct in6_addr ip, int prefixlen); void bgp_enable_routing(int enable); int bgp_set_poll(void); int bgp_process(uint32_t events[]); +void bgp_process_peers_timers(); char const *bgp_state_str(enum bgp_state state); -extern char const *cvs_id_bgp; - #endif /* __BGP_H__ */