change the signature that asn2wrs generates for functions to marm all parameters...
[obnox/wireshark/wip.git] / epan / dissectors / packet-bgp.h
1 /* packet-bgp.c
2  * Definitions for BGP packet disassembly structures and routine
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.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      /* size of BGP marker */
31 #define BGP_HEADER_SIZE                 19      /* size of BGP header, including marker */
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 #define BGP_CAPABILITY          6
45 #define BGP_ROUTE_REFRESH_CISCO 0x80
46
47 /* BGP OPEN message */
48 struct bgp_open {
49     guint8 bgpo_marker[BGP_MARKER_SIZE];
50     guint16 bgpo_len;
51     guint8 bgpo_type;
52     guint8 bgpo_version;
53     guint16 bgpo_myas;
54     guint16 bgpo_holdtime;
55     guint32 bgpo_id;
56     guint8 bgpo_optlen;
57     /* options should follow */
58 };
59
60 /* BGP NOTIFICATION message */
61 struct bgp_notification {
62     guint8 bgpn_marker[BGP_MARKER_SIZE];
63     guint16 bgpn_len;
64     guint8 bgpn_type;
65     guint8 bgpn_major;
66     guint8 bgpn_minor;
67     /* data should follow */
68 };
69
70 /* BGP ROUTE-REFRESH message */
71 struct bgp_route_refresh {
72     guint8 bgpr_marker[BGP_MARKER_SIZE];
73     guint16 bgpr_len;
74     guint8 bgpr_type;
75     guint16 bgpr_afi;
76     guint8 bgpr_reserved;
77     guint8 bgpr_safi;
78 };
79
80 /* path attribute */
81 struct bgp_attr {
82     guint8 bgpa_flags;
83     guint8 bgpa_type;
84 };
85
86 /* attribute flags, from RFC1771 */
87 #define BGP_ATTR_FLAG_OPTIONAL        0x80
88 #define BGP_ATTR_FLAG_TRANSITIVE      0x40
89 #define BGP_ATTR_FLAG_PARTIAL         0x20
90 #define BGP_ATTR_FLAG_EXTENDED_LENGTH 0x10
91
92 /* SSA flags */
93 #define BGP_SSA_TRANSITIVE      0x8000
94 #define BGP_SSA_TYPE            0x7FFF
95
96 /* SSA Types */
97 #define BGP_SSA_L2TPv3  1
98 #define BGP_SSA_mGRE    2
99 #define BGP_SSA_IPSec   3
100 #define BGP_SSA_MPLS    4
101
102 /* AS_PATH segment types */
103 #define AS_SET             1   /* RFC1771 */
104 #define AS_SEQUENCE        2   /* RFC1771 */
105 #define AS_CONFED_SET      4   /* RFC1965 has the wrong values, corrected in  */
106 #define AS_CONFED_SEQUENCE 3   /* draft-ietf-idr-bgp-confed-rfc1965bis-01.txt */
107
108 /* OPEN message Optional Parameter types  */
109 #define BGP_OPTION_AUTHENTICATION       1   /* RFC1771 */
110 #define BGP_OPTION_CAPABILITY           2   /* RFC2842 */
111
112 /* BGP capability code */
113 #define BGP_CAPABILITY_RESERVED                    0   /* RFC2434 */
114 #define BGP_CAPABILITY_MULTIPROTOCOL               1   /* RFC2858 */
115 #define BGP_CAPABILITY_ROUTE_REFRESH               2   /* RFC2918 */
116 #define BGP_CAPABILITY_COOPERATIVE_ROUTE_FILTERING 3   /* draft-ietf-idr-route-filter-04.txt */
117 #define BGP_CAPABILITY_GRACEFUL_RESTART         0x40   /* draft-ietf-idr-restart-05  */
118 #define BGP_CAPABILITY_4_OCTET_AS_NUMBER        0x41   /* draft-ietf-idr-as4bytes-06 */
119 #define BGP_CAPABILITY_DYNAMIC_CAPABILITY       0x42   /* draft-ietf-idr-dynamic-cap-03 */
120 #define BGP_CAPABILITY_ORF_CISCO                0x82   /* Cisco */
121 #define BGP_CAPABILITY_ROUTE_REFRESH_CISCO      0x80   /* Cisco */
122
123 #define BGP_ORF_PREFIX_CISCO    0x80 /* Cisco */
124 #define BGP_ORF_COMM_CISCO      0x81 /* Cisco */
125 #define BGP_ORF_EXTCOMM_CISCO   0x82 /* Cisco */
126 #define BGP_ORF_ASPATH_CISCO    0x83 /* Cisco */
127 #define BGP_ORF_COMM            0x02 /* draft-ietf-idr-route-filter-06.txt */
128 #define BGP_ORF_EXTCOMM         0x03 /* draft-ietf-idr-route-filter-06.txt */
129 #define BGP_ORF_ASPATH          0x04 /* draft-ietf-idr-aspath-orf-02.txt */
130 /* draft-ietf-idr-route-filter-06.txt */
131 #define BGP_ORF_ACTION          0xc0
132 #define BGP_ORF_ADD             0x00
133 #define BGP_ORF_REMOVE          0x40
134 #define BGP_ORF_REMOVEALL       0x80
135 #define BGP_ORF_MATCH           0x10
136 #define BGP_ORF_PERMIT          0x00
137 #define BGP_ORF_DENY            0x10
138
139 /* well-known communities, from RFC1997 */
140 #define BGP_COMM_NO_EXPORT           0xFFFFFF01
141 #define BGP_COMM_NO_ADVERTISE        0xFFFFFF02
142 #define BGP_COMM_NO_EXPORT_SUBCONFED 0xFFFFFF03
143 #define FOURHEX0                     0x00000000
144 #define FOURHEXF                     0xFFFF0000
145
146 /* attribute types */
147 #define BGPTYPE_ORIGIN              1 /* RFC1771           */
148 #define BGPTYPE_AS_PATH             2 /* RFC1771           */
149 #define BGPTYPE_NEXT_HOP            3 /* RFC1771           */
150 #define BGPTYPE_MULTI_EXIT_DISC     4 /* RFC1771           */
151 #define BGPTYPE_LOCAL_PREF          5 /* RFC1771           */
152 #define BGPTYPE_ATOMIC_AGGREGATE    6 /* RFC1771           */
153 #define BGPTYPE_AGGREGATOR          7 /* RFC1771           */
154 #define BGPTYPE_COMMUNITIES         8 /* RFC1997           */
155 #define BGPTYPE_ORIGINATOR_ID       9 /* RFC2796           */
156 #define BGPTYPE_CLUSTER_LIST       10 /* RFC2796           */
157 #define BGPTYPE_DPA                11 /* work in progress  */
158 #define BGPTYPE_ADVERTISER         12 /* RFC1863           */
159 #define BGPTYPE_RCID_PATH          13 /* RFC1863           */
160 #define BGPTYPE_MP_REACH_NLRI      14 /* RFC2858           */
161 #define BGPTYPE_MP_UNREACH_NLRI    15 /* RFC2858           */
162 #define BGPTYPE_EXTENDED_COMMUNITY 16 /* Draft Ramachandra */
163 #define BGPTYPE_NEW_AS_PATH        17 /* draft-ietf-idr-as4bytes */
164 #define BGPTYPE_NEW_AGGREGATOR     18 /* draft-ietf-idr-as4bytes */
165 #define BGPTYPE_SAFI_SPECIFIC_ATTR 19 /* draft-kapoor-nalawade-idr-bgp-ssa-00.txt */
166
167 /* Extended community type */
168                                         /* draft-ietf-idr-bgp-ext-communities */
169 #define BGP_EXT_COM_RT_0        0x0002  /* Route Target,Format AS(2bytes):AN(4bytes) */
170 #define BGP_EXT_COM_RT_1        0x0102  /* Route Target,Format IP address:AN(2bytes) */
171 #define BGP_EXT_COM_RT_2        0x0202  /* Route Target,Format AS(2bytes):AN(4bytes) */
172 #define BGP_EXT_COM_RO_0        0x0003  /* Route Origin,Format AS(2bytes):AN(4bytes) */
173 #define BGP_EXT_COM_RO_1        0x0103  /* Route Origin,Format IP address:AN(2bytes) */
174 #define BGP_EXT_COM_RO_2        0x0203  /* Route Origin,Format AS(2bytes):AN(4bytes) */
175 #define BGP_EXT_COM_LINKBAND    0x0004  /* Link Bandwidth,Format AS(2B):Bandwidth(4B) */
176                                         /* -2 version of the draft */
177 #define BGP_EXT_COM_VPN_ORIGIN  0x0005  /* OSPF Domin ID / VPN of Origin  */
178                                         /* draft-rosen-vpns-ospf-bgp-mpls */
179 #define BGP_EXT_COM_OSPF_RTYPE  0X8000  /* OSPF Route Type,Format Area(4B):RouteType(1B):Options(1B) */
180 #define BGP_EXT_COM_OSPF_RID    0x8001  /* OSPF Router ID,Format RouterID(4B):Unused(2B) */
181 #define BGP_EXT_COM_L2INFO      0x800a  /* draft-kompella-ppvpn-l2vpn */
182
183
184 /* OSPF codes for  BGP_EXT_COM_OSPF_RTYPE draft-rosen-vpns-ospf-bgp-mpls  */
185 #define BGP_OSPF_RTYPE_RTR      1 /* OSPF Router LSA */
186 #define BGP_OSPF_RTYPE_NET      2 /* OSPF Network LSA */
187 #define BGP_OSPF_RTYPE_SUM      3 /* OSPF Summary LSA */
188 #define BGP_OSPF_RTYPE_EXT      5 /* OSPF External LSA, note that ASBR doesn't apply to MPLS-VPN */
189 #define BGP_OSPF_RTYPE_NSSA     7 /* OSPF NSSA External*/
190 #define BGP_OSPF_RTYPE_SHAM     129 /* OSPF-MPLS-VPN Sham link */
191 #define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */
192
193 /* Extended community & Route dinstinguisher formats */
194 #define FORMAT_AS2_LOC      0x00    /* Format AS(2bytes):AN(4bytes) */
195 #define FORMAT_IP_LOC       0x01    /* Format IP address:AN(2bytes) */
196 #define FORMAT_AS4_LOC      0x02    /* Format AS(4bytes):AN(2bytes) */
197
198 /* RFC 2858 subsequent address family numbers */
199 #define SAFNUM_UNICAST  1
200 #define SAFNUM_MULCAST  2
201 #define SAFNUM_UNIMULC  3
202 #define SAFNUM_MPLS_LABEL 4     /* rfc3107 */
203 #define SAFNUM_TUNNEL   64      /* draft-nalawade-kapoor-tunnel-safi-02.txt */
204 #define SAFNUM_VPLS     65
205 #define SAFNUM_LAB_VPNUNICAST  128     /* Draft-rosen-rfc2547bis-03 */
206 #define SAFNUM_LAB_VPNMULCAST  129
207 #define SAFNUM_LAB_VPNUNIMULC  130
208
209 #ifndef offsetof
210 #define offsetof(type, member)  ((size_t)(&((type *)0)->member))
211 #endif
212
213 #endif