2 * Definitions for BGP packet disassembly structures and routine
4 * $Id: packet-bgp.h,v 1.16 2001/11/03 21:25:12 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
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.
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.
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.
25 #ifndef __PACKET_BGP_H__
26 #define __PACKET_BGP_H__
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
38 /* BGP message types */
41 #define BGP_NOTIFICATION 3
42 #define BGP_KEEPALIVE 4
43 #define BGP_ROUTE_REFRESH 5
44 #define BGP_ROUTE_REFRESH_CISCO 0x80
48 guint8 bgp_marker[BGP_MARKER_SIZE];
53 /* BGP OPEN message */
55 guint8 bgpo_marker[BGP_MARKER_SIZE];
60 guint16 bgpo_holdtime;
63 /* options should follow */
66 /* BGP NOTIFICATION message */
67 struct bgp_notification {
68 guint8 bgpn_marker[BGP_MARKER_SIZE];
73 /* data should follow */
76 /* BGP ROUTE-REFRESH message */
77 struct bgp_route_refresh {
78 guint8 bgpr_marker[BGP_MARKER_SIZE];
92 /* attribute flags, from RFC1771 */
93 #define BGP_ATTR_FLAG_OPTIONAL 0x80
94 #define BGP_ATTR_FLAG_TRANSITIVE 0x40
95 #define BGP_ATTR_FLAG_PARTIAL 0x20
96 #define BGP_ATTR_FLAG_EXTENDED_LENGTH 0x10
98 /* AS_PATH segment types */
99 #define AS_SET 1 /* RFC1771 */
100 #define AS_SEQUENCE 2 /* RFC1771 */
101 #define AS_CONFED_SET 4 /* RFC1965 has the wrong values, corrected in */
102 #define AS_CONFED_SEQUENCE 3 /* draft-ietf-idr-bgp-confed-rfc1965bis-01.txt */
104 /* OPEN message Optional Parameter types */
105 #define BGP_OPTION_AUTHENTICATION 1 /* RFC1771 */
106 #define BGP_OPTION_CAPABILITY 2 /* RFC2842 */
108 /* BGP capability code */
109 #define BGP_CAPABILITY_RESERVED 0 /* RFC2434 */
110 #define BGP_CAPABILITY_MULTIPROTOCOL 1 /* RFC2858 */
111 #define BGP_CAPABILITY_ROUTE_REFRESH 2 /* RFC2918 */
112 #define BGP_CAPABILITY_COOPERATIVE_ROUTE_FILTERING 3 /* draft-ietf-idr-route-filter-04.txt */
113 #define BGP_CAPABILITY_ROUTE_REFRESH_CISCO 0x80 /* Cisco */
116 /* well-known communities, from RFC1997 */
117 #define BGP_COMM_NO_EXPORT 0xFFFFFF01
118 #define BGP_COMM_NO_ADVERTISE 0xFFFFFF02
119 #define BGP_COMM_NO_EXPORT_SUBCONFED 0xFFFFFF03
120 #define FOURHEX0 0x0000
121 #define FOURHEXF 0xFFFF
123 /* attribute types */
124 #define BGPTYPE_ORIGIN 1 /* RFC1771 */
125 #define BGPTYPE_AS_PATH 2 /* RFC1771 */
126 #define BGPTYPE_NEXT_HOP 3 /* RFC1771 */
127 #define BGPTYPE_MULTI_EXIT_DISC 4 /* RFC1771 */
128 #define BGPTYPE_LOCAL_PREF 5 /* RFC1771 */
129 #define BGPTYPE_ATOMIC_AGGREGATE 6 /* RFC1771 */
130 #define BGPTYPE_AGGREGATOR 7 /* RFC1771 */
131 #define BGPTYPE_COMMUNITIES 8 /* RFC1997 */
132 #define BGPTYPE_ORIGINATOR_ID 9 /* RFC2796 */
133 #define BGPTYPE_CLUSTER_LIST 10 /* RFC2796 */
134 #define BGPTYPE_DPA 11 /* work in progress */
135 #define BGPTYPE_ADVERTISER 12 /* RFC1863 */
136 #define BGPTYPE_RCID_PATH 13 /* RFC1863 */
137 #define BGPTYPE_MP_REACH_NLRI 14 /* RFC2858 */
138 #define BGPTYPE_MP_UNREACH_NLRI 15 /* RFC2858 */
139 #define BGPTYPE_EXTENDED_COMMUNITY 16 /* Draft Ramachandra */
141 /* Extended community type */
142 /* draft-ramachandra-bgp-ext-communities */
143 #define BGP_EXT_COM_RT_0 0x0002 /* Route Target,Format AS(2bytes):AN(4bytes) */
144 #define BGP_EXT_COM_RT_1 0x0102 /* Route Target,Format IP address:AN(2bytes) */
145 #define BGP_EXT_COM_RO_0 0x0003 /* Route Origin,Format AS(2bytes):AN(4bytes) */
146 #define BGP_EXT_COM_RO_1 0x0103 /* Route Origin,Format IP address:AN(2bytes) */
147 #define BGP_EXT_COM_LINKBAND 0x4004 /* Link Bandwidth,Format AS(2B):Bandwidth(4B) */
148 /* rfc2547 bgp-mpls-vpns */
149 #define BGP_EXT_COM_VPN_ORIGIN 0x0005 /* OSPF Domin ID / VPN of Origin */
150 /* draft-rosen-vpns-ospf-bgp-mpls */
151 #define BGP_EXT_COM_OSPF_RTYPE 0X8000 /* OSPF Route Type,Format Area(4B):RouteType(1B):Options(1B) */
152 #define BGP_EXT_COM_OSPF_RID 0x8001 /* OSPF Router ID,Format RouterID(4B):Unused(2B) */
155 /* OSPF codes for BGP_EXT_COM_OSPF_RTYPE draft-rosen-vpns-ospf-bgp-mpls */
156 #define BGP_OSPF_RTYPE_RTR 1 /* OSPF Router LSA */
157 #define BGP_OSPF_RTYPE_NET 2 /* OSPF Network LSA */
158 #define BGP_OSPF_RTYPE_SUM 3 /* OSPF Summary LSA */
159 #define BGP_OSPF_RTYPE_EXT 5 /* OSPF External LSA, note that ASBR doesn't apply to MPLS-VPN */
160 #define BGP_OSPF_RTYPE_NSSA 7 /* OSPF NSSA External*/
161 #define BGP_OSPF_RTYPE_SHAM 129 /* OSPF-MPLS-VPN Sham link */
162 #define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */
164 /* Extended community & Route dinstinguisher formats */
165 #define FORMAT_AS2_LOC 0x00 /* Format AS(2bytes):AN(4bytes) */
166 #define FORMAT_IP_LOC 0x01 /* Format IP address:AN(2bytes) */
167 #define FORMAT_AS4_LOC 0x02 /* FOrmat AS(4bytes):AN(2bytes) */
169 /* RFC 2858 subsequent address family numbers */
170 #define SAFNUM_UNICAST 1
171 #define SAFNUM_MULCAST 2
172 #define SAFNUM_UNIMULC 3
173 #define SAFNUM_MPLS_LABEL 4 /* rfc3107 */
174 #define SAFNUM_LBVPNIP 128 /* Draft-rosen-rfc2547bis-03 */
177 #define offsetof(type, member) ((size_t)(&((type *)0)->member))