]>
Commit | Line | Data |
---|---|---|
2638249d MM |
1 | /* |
2 | * BIRD -- The Border Gateway Protocol | |
3 | * | |
4 | * (c) 2000 Martin Mares <mj@ucw.cz> | |
5 | * | |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | #ifndef _BIRD_BGP_H_ | |
10 | #define _BIRD_BGP_H_ | |
11 | ||
c00d31be MM |
12 | struct linpool; |
13 | ||
2638249d MM |
14 | struct bgp_config { |
15 | struct proto_config c; | |
16 | unsigned int local_as, remote_as; | |
17 | ip_addr remote_ip; | |
18 | int multihop; /* Number of hops if multihop */ | |
c00d31be | 19 | ip_addr multihop_via; /* Multihop: address to route to */ |
3fdbafb6 MM |
20 | unsigned connect_retry_time; |
21 | unsigned hold_time, initial_hold_time; | |
22 | unsigned keepalive_time; | |
c01e3741 MM |
23 | }; |
24 | ||
25 | struct bgp_conn { | |
26 | struct bgp_proto *bgp; | |
27 | struct birdsock *sk; | |
72a6ef11 | 28 | unsigned int state; /* State of connection state machine */ |
c01e3741 MM |
29 | struct timer *connect_retry_timer; |
30 | struct timer *hold_timer; | |
31 | struct timer *keepalive_timer; | |
3fdbafb6 MM |
32 | int packets_to_send; /* Bitmap of packet types to be sent */ |
33 | int notify_code, notify_subcode, notify_arg, notify_arg_size; | |
34 | int error_flag; /* Error state, ignore all input */ | |
b552ecc4 | 35 | int primary; /* This connection is primary */ |
3fdbafb6 | 36 | unsigned hold_time, keepalive_time; /* Times calculated from my and neighbor's requirements */ |
2638249d MM |
37 | }; |
38 | ||
39 | struct bgp_proto { | |
40 | struct proto p; | |
c01e3741 MM |
41 | struct bgp_config *cf; /* Shortcut to BGP configuration */ |
42 | node bgp_node; /* Node in global BGP protocol list */ | |
3fdbafb6 | 43 | unsigned local_as, remote_as; |
c01e3741 MM |
44 | int is_internal; /* Internal BGP connection (local_as == remote_as) */ |
45 | u32 local_id; /* BGP identifier of this router */ | |
46 | u32 remote_id; /* BGP identifier of the neighbor */ | |
b552ecc4 MM |
47 | struct bgp_conn *conn; /* Connection we have established */ |
48 | struct bgp_conn outgoing_conn; /* Outgoing connection we're working with */ | |
c01e3741 MM |
49 | struct bgp_conn incoming_conn; /* Incoming connection we have neither accepted nor rejected yet */ |
50 | struct object_lock *lock; /* Lock for neighbor connection */ | |
2638249d MM |
51 | }; |
52 | ||
72a6ef11 MM |
53 | #define BGP_PORT 179 |
54 | #define BGP_VERSION 4 | |
55 | #define BGP_HEADER_LENGTH 19 | |
56 | #define BGP_MAX_PACKET_LENGTH 4096 | |
57 | #define BGP_RX_BUFFER_SIZE 4096 | |
58 | #define BGP_TX_BUFFER_SIZE BGP_MAX_PACKET_LENGTH | |
2638249d | 59 | |
973399ae MM |
60 | extern struct linpool *bgp_linpool; |
61 | ||
3fdbafb6 | 62 | void bgp_start_timer(struct timer *t, int value); |
2638249d | 63 | void bgp_check(struct bgp_config *c); |
3fdbafb6 | 64 | void bgp_error(struct bgp_conn *c, unsigned code, unsigned subcode, unsigned data, unsigned len); |
b552ecc4 | 65 | void bgp_close_conn(struct bgp_conn *c); |
2638249d | 66 | |
c01e3741 MM |
67 | /* attrs.c */ |
68 | ||
c00d31be MM |
69 | struct rta *bgp_decode_attrs(struct bgp_conn *conn, byte *a, unsigned int len, struct linpool *pool); |
70 | ||
c01e3741 MM |
71 | /* packets.c */ |
72 | ||
72a6ef11 MM |
73 | void bgp_schedule_packet(struct bgp_conn *conn, int type); |
74 | void bgp_tx(struct birdsock *sk); | |
75 | int bgp_rx(struct birdsock *sk, int size); | |
76 | ||
c01e3741 MM |
77 | /* Packet types */ |
78 | ||
79 | #define PKT_OPEN 0x01 | |
80 | #define PKT_UPDATE 0x02 | |
81 | #define PKT_NOTIFICATION 0x03 | |
82 | #define PKT_KEEPALIVE 0x04 | |
72a6ef11 | 83 | #define PKT_SCHEDULE_CLOSE 0x1f /* Used internally to schedule socket close */ |
c01e3741 MM |
84 | |
85 | /* Attributes */ | |
86 | ||
87 | #define BAF_OPTIONAL 0x80 | |
88 | #define BAF_TRANSITIVE 0x40 | |
89 | #define BAF_PARTIAL 0x20 | |
90 | #define BAF_EXT_LEN 0x10 | |
91 | ||
92 | #define BA_ORIGIN 0x01 /* [RFC1771] */ /* WM */ | |
93 | #define BA_AS_PATH 0x02 /* WM */ | |
94 | #define BA_NEXT_HOP 0x03 /* WM */ | |
95 | #define BA_MULTI_EXIT_DISC 0x04 /* ON */ | |
c00d31be | 96 | #define BA_LOCAL_PREF 0x05 /* WD */ |
c01e3741 MM |
97 | #define BA_ATOMIC_AGGR 0x06 /* WD */ |
98 | #define BA_AGGREGATOR 0x07 /* OT */ | |
99 | #define BA_COMMUNITY 0x08 /* [RFC1997] */ /* OT */ | |
100 | #define BA_ORIGINATOR_ID 0x09 /* [RFC1966] */ /* ON */ | |
101 | #define BA_CLUSTER_LIST 0x0a /* ON */ | |
102 | /* We don't support these: */ | |
103 | #define BA_DPA 0x0b /* ??? */ | |
104 | #define BA_ADVERTISER 0x0c /* [RFC1863] */ | |
105 | #define BA_RCID_PATH 0x0d | |
106 | #define BA_MP_REACH_NLRI 0x0e /* [RFC2283] */ | |
107 | #define BA_MP_UNREACH_NLRI 0x0f | |
108 | #define BA_EXTENDED_COMM 0x10 /* draft-ramachandra-bgp-ext-communities */ | |
109 | ||
c00d31be MM |
110 | #define BGP_PATH_AS_SET 1 /* Types of path segments */ |
111 | #define BGP_PATH_AS_SEQUENCE 2 | |
112 | ||
c01e3741 MM |
113 | /* BGP states */ |
114 | ||
115 | #define BS_IDLE 0 | |
116 | #define BS_CONNECT 1 /* Attempting to connect */ | |
117 | #define BS_ACTIVE 2 /* Waiting for connection retry & listening */ | |
118 | #define BS_OPENSENT 3 | |
119 | #define BS_OPENCONFIRM 4 | |
120 | #define BS_ESTABLISHED 5 | |
121 | ||
2638249d | 122 | #endif |