Remove TODO comments about NSAP and ISIS decodings since
[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.9 2000/04/11 14:21:37 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
37 /* BGP message types */
38 #define BGP_OPEN                1
39 #define BGP_UPDATE              2
40 #define BGP_NOTIFICATION        3
41 #define BGP_KEEPALIVE           4
42
43 /* BGP header */
44 struct bgp {
45     guint8 bgp_marker[BGP_MARKER_SIZE];
46     guint16 bgp_len;
47     guint8 bgp_type;
48 };
49
50 /* BGP OPEN message */
51 struct bgp_open {
52     guint8 bgpo_marker[BGP_MARKER_SIZE];
53     guint16 bgpo_len;
54     guint8 bgpo_type;
55     guint8 bgpo_version;
56     guint16 bgpo_myas;
57     guint16 bgpo_holdtime;
58     guint32 bgpo_id;
59     guint8 bgpo_optlen;
60     /* options should follow */
61 };
62
63 /* BGP NOTIFICATION message */
64 struct bgp_notification {
65     guint8 bgpn_marker[BGP_MARKER_SIZE];
66     guint16 bgpn_len;
67     guint8 bgpn_type;
68     guint8 bgpn_major;
69     guint8 bgpn_minor;
70     /* data should follow */
71 };
72
73 /* path attribute */
74 struct bgp_attr {
75     guint8 bgpa_flags;
76     guint8 bgpa_type;
77 };
78
79 /* attribute flags, from RFC1771 */
80 #define BGP_ATTR_FLAG_OPTIONAL        0x80
81 #define BGP_ATTR_FLAG_TRANSITIVE      0x40
82 #define BGP_ATTR_FLAG_PARTIAL         0x20
83 #define BGP_ATTR_FLAG_EXTENDED_LENGTH 0x10
84
85 /* AS_PATH segment types */
86 #define AS_SET             1   /* RFC1771 */
87 #define AS_SEQUENCE        2   /* RFC1771 */
88 /* This is wrong according to the RFC... in the Zebra code they say that
89    cisco reversed it.  Packet traces seem to agree.                      */
90 #define AS_CONFED_SET      4   /* RFC1965 */
91 #define AS_CONFED_SEQUENCE 3   /* RFC1965 */
92
93 /* well-known communities, from RFC1997 */
94 #define BGP_COMM_NO_EXPORT           0xFFFFFF01
95 #define BGP_COMM_NO_ADVERTISE        0xFFFFFF02
96 #define BGP_COMM_NO_EXPORT_SUBCONFED 0xFFFFFF03
97 #define FOURHEX0                     0x0000
98 #define FOURHEXF                     0xFFFF
99
100 /* attribute types */
101 #define BGPTYPE_ORIGIN            1   /* RFC1771          */
102 #define BGPTYPE_AS_PATH           2   /* RFC1771          */
103 #define BGPTYPE_NEXT_HOP          3   /* RFC1771          */
104 #define BGPTYPE_MULTI_EXIT_DISC   4   /* RFC1771          */
105 #define BGPTYPE_LOCAL_PREF        5   /* RFC1771          */
106 #define BGPTYPE_ATOMIC_AGGREGATE  6   /* RFC1771          */
107 #define BGPTYPE_AGGREGATOR        7   /* RFC1771          */
108 #define BGPTYPE_COMMUNITIES       8   /* RFC1997          */
109 #define BGPTYPE_ORIGINATOR_ID     9   /* RFC1966          */
110 #define BGPTYPE_CLUSTER_LIST     10   /* RFC1966          */
111 #define BGPTYPE_DPA              11   /* work in progress */
112 #define BGPTYPE_ADVERTISER       12   /* RFC1863          */
113 #define BGPTYPE_RCID_PATH        13   /* RFC1863          */
114 #define BGPTYPE_MP_REACH_NLRI    14   /* RFC2283          */
115 #define BGPTYPE_MP_UNREACH_NLRI  15   /* RFC2283          */
116
117 /* RFC1700 address family numbers */
118 #define AFNUM_INET      1
119 #define AFNUM_INET6     2
120 #define AFNUM_NSAP      3
121 #define AFNUM_HDLC      4
122 #define AFNUM_BBN1822   5
123 #define AFNUM_802       6
124 #define AFNUM_E163      7
125 #define AFNUM_E164      8
126 #define AFNUM_F69       9
127 #define AFNUM_X121      10
128 #define AFNUM_IPX       11
129 #define AFNUM_ATALK     12
130 #define AFNUM_DECNET    13
131 #define AFNUM_BANYAN    14
132 #define AFNUM_E164NSAP  15
133
134 #define CHECK_SIZE(x, s, l) \
135 do {                            \
136     if ((x) + (s) > (l))        \
137         return;                 \
138 } while (0)
139
140 #ifndef offsetof
141 #define offsetof(type, member)  ((size_t)(&((type *)0)->member))
142 #endif
143
144 #endif