"hf_sna_rh_csi" is now an FT_UINT8 field, so add it with
[obnox/wireshark/wip.git] / packet-bgp.h
1 /* packet-bgp.c
2  * Definitions for BGP packet disassembly structures and routine
3  *
4  * $Id: packet-bgp.h,v 1.10 2000/12/25 05:28:40 itojun Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  * 
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef __PACKET_BGP_H__
26 #define __PACKET_BGP_H__
27
28 /* some handy things to know */
29 #define BGP_MAX_PACKET_SIZE             4096
30 #define BGP_MARKER_SIZE                 16
31 #define BGP_HEADER_SIZE                 19
32 #define BGP_MIN_OPEN_MSG_SIZE           29
33 #define BGP_MIN_UPDATE_MSG_SIZE         23
34 #define BGP_MIN_NOTIFICATION_MSG_SIZE   21
35 #define BGP_MIN_KEEPALVE_MSG_SIZE       BGP_HEADER_SIZE
36 #define BGP_TCP_PORT                    179
37
38 /* BGP message types */
39 #define BGP_OPEN                1
40 #define BGP_UPDATE              2
41 #define BGP_NOTIFICATION        3
42 #define BGP_KEEPALIVE           4
43 #define BGP_ROUTE_REFRESH       5
44
45 /* BGP header */
46 struct bgp {
47     guint8 bgp_marker[BGP_MARKER_SIZE];
48     guint16 bgp_len;
49     guint8 bgp_type;
50 };
51
52 /* BGP OPEN message */
53 struct bgp_open {
54     guint8 bgpo_marker[BGP_MARKER_SIZE];
55     guint16 bgpo_len;
56     guint8 bgpo_type;
57     guint8 bgpo_version;
58     guint16 bgpo_myas;
59     guint16 bgpo_holdtime;
60     guint32 bgpo_id;
61     guint8 bgpo_optlen;
62     /* options should follow */
63 };
64
65 /* BGP NOTIFICATION message */
66 struct bgp_notification {
67     guint8 bgpn_marker[BGP_MARKER_SIZE];
68     guint16 bgpn_len;
69     guint8 bgpn_type;
70     guint8 bgpn_major;
71     guint8 bgpn_minor;
72     /* data should follow */
73 };
74
75 /* BGP ROUTE-REFRESH message */
76 struct bgp_route_refresh {
77     guint8 bgpr_marker[BGP_MARKER_SIZE];
78     guint16 bgpr_len;
79     guint8 bgpr_type;
80     guint16 bgpr_afi;
81     guint8 bgpr_reserved;
82     guint8 bgpr_safi;
83 };
84
85 /* path attribute */
86 struct bgp_attr {
87     guint8 bgpa_flags;
88     guint8 bgpa_type;
89 };
90
91 /* attribute flags, from RFC1771 */
92 #define BGP_ATTR_FLAG_OPTIONAL        0x80
93 #define BGP_ATTR_FLAG_TRANSITIVE      0x40
94 #define BGP_ATTR_FLAG_PARTIAL         0x20
95 #define BGP_ATTR_FLAG_EXTENDED_LENGTH 0x10
96
97 /* AS_PATH segment types */
98 #define AS_SET             1   /* RFC1771 */
99 #define AS_SEQUENCE        2   /* RFC1771 */
100 #define AS_CONFED_SET      4   /* RFC1965 has the wrong values, corrected in  */
101 #define AS_CONFED_SEQUENCE 3   /* draft-ietf-idr-bgp-confed-rfc1965bis-01.txt */
102
103 /* OPEN message Optional Parameter types  */
104 #define BGP_OPTION_AUTHENTICATION       1   /* RFC1771 */
105 #define BGP_OPTION_CAPABILITY           2   /* RFC2842 */
106
107 /* BGP capability code */
108 #define BGP_CAPABILITY_RESERVED         0   /* RFC2434 */
109 #define BGP_CAPABILITY_MULTIPROTOCOL    1   /* RFC2858 */
110 #define BGP_CAPABILITY_ROUTE_REFRESH    2   /* RFC2918 */
111
112 /* well-known communities, from RFC1997 */
113 #define BGP_COMM_NO_EXPORT           0xFFFFFF01
114 #define BGP_COMM_NO_ADVERTISE        0xFFFFFF02
115 #define BGP_COMM_NO_EXPORT_SUBCONFED 0xFFFFFF03
116 #define FOURHEX0                     0x0000
117 #define FOURHEXF                     0xFFFF
118
119 /* attribute types */
120 #define BGPTYPE_ORIGIN            1   /* RFC1771          */
121 #define BGPTYPE_AS_PATH           2   /* RFC1771          */
122 #define BGPTYPE_NEXT_HOP          3   /* RFC1771          */
123 #define BGPTYPE_MULTI_EXIT_DISC   4   /* RFC1771          */
124 #define BGPTYPE_LOCAL_PREF        5   /* RFC1771          */
125 #define BGPTYPE_ATOMIC_AGGREGATE  6   /* RFC1771          */
126 #define BGPTYPE_AGGREGATOR        7   /* RFC1771          */
127 #define BGPTYPE_COMMUNITIES       8   /* RFC1997          */
128 #define BGPTYPE_ORIGINATOR_ID     9   /* RFC2796          */
129 #define BGPTYPE_CLUSTER_LIST     10   /* RFC2796          */
130 #define BGPTYPE_DPA              11   /* work in progress */
131 #define BGPTYPE_ADVERTISER       12   /* RFC1863          */
132 #define BGPTYPE_RCID_PATH        13   /* RFC1863          */
133 #define BGPTYPE_MP_REACH_NLRI    14   /* RFC2858          */
134 #define BGPTYPE_MP_UNREACH_NLRI  15   /* RFC2858          */
135
136 /* RFC1700 address family numbers */
137 #define AFNUM_INET      1
138 #define AFNUM_INET6     2
139 #define AFNUM_NSAP      3
140 #define AFNUM_HDLC      4
141 #define AFNUM_BBN1822   5
142 #define AFNUM_802       6
143 #define AFNUM_E163      7
144 #define AFNUM_E164      8
145 #define AFNUM_F69       9
146 #define AFNUM_X121      10
147 #define AFNUM_IPX       11
148 #define AFNUM_ATALK     12
149 #define AFNUM_DECNET    13
150 #define AFNUM_BANYAN    14
151 #define AFNUM_E164NSAP  15
152
153 #define CHECK_SIZE(x, s, l) \
154 do {                            \
155     if ((x) + (s) > (l))        \
156         return;                 \
157 } while (0)
158
159 #ifndef offsetof
160 #define offsetof(type, member)  ((size_t)(&((type *)0)->member))
161 #endif
162
163 #endif