Statistics
| Branch: | Revision:

iof-bird-daemon / proto / bgp / bgp.h @ 72a6ef11

History | View | Annotate | Download (3.17 KB)

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

    
12
struct bgp_config {
13
  struct proto_config c;
14
  unsigned int local_as, remote_as;
15
  ip_addr remote_ip;
16
  int multihop;                                /* Number of hops if multihop */
17
  int connect_retry_time;
18
  int hold_time;
19
  int keepalive_time;
20
};
21

    
22
struct bgp_conn {
23
  struct bgp_proto *bgp;
24
  struct birdsock *sk;
25
  unsigned int state;                        /* State of connection state machine */
26
  struct timer *connect_retry_timer;
27
  struct timer *hold_timer;
28
  struct timer *keepalive_timer;
29
  unsigned int packets_to_send;                /* Bitmap of packet types to be sent */
30
  unsigned int notify_code, notify_subcode, notify_arg, notify_arg_size;
31
  unsigned int error_flag;                /* Error state, ignore all input */
32
};
33

    
34
struct bgp_proto {
35
  struct proto p;
36
  struct bgp_config *cf;                /* Shortcut to BGP configuration */
37
  node bgp_node;                        /* Node in global BGP protocol list */
38
  int local_as, remote_as;
39
  int is_internal;                        /* Internal BGP connection (local_as == remote_as) */
40
  u32 local_id;                                /* BGP identifier of this router */
41
  u32 remote_id;                        /* BGP identifier of the neighbor */
42
  int hold_time;                        /* Hold time calculated from my and neighbor's requirements */
43
  struct bgp_conn conn;                        /* Our primary connection */
44
  struct bgp_conn incoming_conn;        /* Incoming connection we have neither accepted nor rejected yet */
45
  struct object_lock *lock;                /* Lock for neighbor connection */
46
};
47

    
48
#define BGP_PORT                179
49
#define BGP_VERSION                4
50
#define BGP_HEADER_LENGTH        19
51
#define BGP_MAX_PACKET_LENGTH        4096
52
#define BGP_RX_BUFFER_SIZE        4096
53
#define BGP_TX_BUFFER_SIZE        BGP_MAX_PACKET_LENGTH
54

    
55
void bgp_check(struct bgp_config *c);
56

    
57
/* attrs.c */
58

    
59
/* packets.c */
60

    
61
void bgp_schedule_packet(struct bgp_conn *conn, int type);
62
void bgp_tx(struct birdsock *sk);
63
int bgp_rx(struct birdsock *sk, int size);
64

    
65
/* Packet types */
66

    
67
#define PKT_OPEN                0x01
68
#define PKT_UPDATE                0x02
69
#define PKT_NOTIFICATION        0x03
70
#define PKT_KEEPALIVE                0x04
71
#define PKT_SCHEDULE_CLOSE        0x1f        /* Used internally to schedule socket close */
72

    
73
/* Attributes */
74

    
75
#define BAF_OPTIONAL                0x80
76
#define BAF_TRANSITIVE                0x40
77
#define BAF_PARTIAL                0x20
78
#define BAF_EXT_LEN                0x10
79

    
80
#define BA_ORIGIN                0x01        /* [RFC1771] */                /* WM */
81
#define BA_AS_PATH                0x02                                /* WM */
82
#define BA_NEXT_HOP                0x03                                /* WM */
83
#define BA_MULTI_EXIT_DISC        0x04                                /* ON */
84
#define BA_LOCAL_PREF                0x05                                /* WM */
85
#define BA_ATOMIC_AGGR                0x06                                /* WD */
86
#define BA_AGGREGATOR                0x07                                /* OT */
87
#define BA_COMMUNITY                0x08        /* [RFC1997] */                /* OT */
88
#define BA_ORIGINATOR_ID        0x09        /* [RFC1966] */                /* ON */
89
#define BA_CLUSTER_LIST                0x0a                                /* ON */
90
/* We don't support these: */
91
#define BA_DPA                        0x0b        /* ??? */
92
#define BA_ADVERTISER                0x0c        /* [RFC1863] */
93
#define BA_RCID_PATH                0x0d
94
#define BA_MP_REACH_NLRI        0x0e        /* [RFC2283] */
95
#define BA_MP_UNREACH_NLRI        0x0f
96
#define BA_EXTENDED_COMM        0x10        /* draft-ramachandra-bgp-ext-communities */
97

    
98
/* BGP states */
99

    
100
#define BS_IDLE                        0
101
#define BS_CONNECT                1        /* Attempting to connect */
102
#define BS_ACTIVE                2        /* Waiting for connection retry & listening */
103
#define BS_OPENSENT                3
104
#define BS_OPENCONFIRM                4
105
#define BS_ESTABLISHED                5
106

    
107
#endif