Merge branch 'master' of git://repo.or.cz/unleashed into uadmin
[unleashed.git] / contrib / tcpdump / ospf.h
blobb47aaf69319deb1ca9ad49a12fade6fd62b30cde
1 /*
2 * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
23 #define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */
24 #define OSPF_TYPE_HELLO 1 /* Hello */
25 #define OSPF_TYPE_DD 2 /* Database Description */
26 #define OSPF_TYPE_LS_REQ 3 /* Link State Request */
27 #define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */
28 #define OSPF_TYPE_LS_ACK 5 /* Link State Ack */
30 /* Options field
32 * +------------------------------------+
33 * | DN | O | DC | L | N/P | MC | E | T |
34 * +------------------------------------+
38 #define OSPF_OPTION_T 0x01 /* T bit: TOS support */
39 #define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */
40 #define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */
41 #define OSPF_OPTION_NP 0x08 /* N/P bit: NSSA capable */
42 #define OSPF_OPTION_EA 0x10 /* EA bit: External Attribute capable */
43 #define OSPF_OPTION_L 0x10 /* L bit: Packet contains LLS data block */
44 #define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuit capable */
45 #define OSPF_OPTION_O 0x40 /* O bit: Opaque LSA capable */
46 #define OSPF_OPTION_DN 0x80 /* DN bit: Up/Down Bit capable - draft-ietf-ospf-2547-dnbit-04 */
48 /* ospf_authtype */
49 #define OSPF_AUTH_NONE 0 /* No auth-data */
50 #define OSPF_AUTH_SIMPLE 1 /* Simple password */
51 #define OSPF_AUTH_SIMPLE_LEN 8 /* max length of simple authentication */
52 #define OSPF_AUTH_MD5 2 /* MD5 authentication */
53 #define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */
55 /* db_flags */
56 #define OSPF_DB_INIT 0x04
57 #define OSPF_DB_MORE 0x02
58 #define OSPF_DB_MASTER 0x01
59 #define OSPF_DB_RESYNC 0x08 /* RFC4811 */
61 /* ls_type */
62 #define LS_TYPE_ROUTER 1 /* router link */
63 #define LS_TYPE_NETWORK 2 /* network link */
64 #define LS_TYPE_SUM_IP 3 /* summary link */
65 #define LS_TYPE_SUM_ABR 4 /* summary area link */
66 #define LS_TYPE_ASE 5 /* ASE */
67 #define LS_TYPE_GROUP 6 /* Group membership (multicast */
68 /* extensions 23 July 1991) */
69 #define LS_TYPE_NSSA 7 /* rfc3101 - Not so Stubby Areas */
70 #define LS_TYPE_OPAQUE_LL 9 /* rfc2370 - Opaque Link Local */
71 #define LS_TYPE_OPAQUE_AL 10 /* rfc2370 - Opaque Link Local */
72 #define LS_TYPE_OPAQUE_DW 11 /* rfc2370 - Opaque Domain Wide */
74 #define LS_OPAQUE_TYPE_TE 1 /* rfc3630 */
75 #define LS_OPAQUE_TYPE_GRACE 3 /* rfc3623 */
76 #define LS_OPAQUE_TYPE_RI 4 /* draft-ietf-ospf-cap-03 */
78 #define LS_OPAQUE_TE_TLV_ROUTER 1 /* rfc3630 */
79 #define LS_OPAQUE_TE_TLV_LINK 2 /* rfc3630 */
81 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE 1 /* rfc3630 */
82 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID 2 /* rfc3630 */
83 #define LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP 3 /* rfc3630 */
84 #define LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP 4 /* rfc3630 */
85 #define LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC 5 /* rfc3630 */
86 #define LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW 6 /* rfc3630 */
87 #define LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW 7 /* rfc3630 */
88 #define LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW 8 /* rfc3630 */
89 #define LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP 9 /* rfc3630 */
90 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID 11 /* rfc4203 */
91 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE 14 /* rfc4203 */
92 #define LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR 15 /* rfc4203 */
93 #define LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP 16 /* rfc4203 */
94 #define LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS 17 /* rfc4124 */
96 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP 1 /* rfc3630 */
97 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA 2 /* rfc3630 */
99 #define LS_OPAQUE_GRACE_TLV_PERIOD 1 /* rfc3623 */
100 #define LS_OPAQUE_GRACE_TLV_REASON 2 /* rfc3623 */
101 #define LS_OPAQUE_GRACE_TLV_INT_ADDRESS 3 /* rfc3623 */
103 #define LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN 0 /* rfc3623 */
104 #define LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART 1 /* rfc3623 */
105 #define LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE 2 /* rfc3623 */
106 #define LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH 3 /* rfc3623 */
108 #define LS_OPAQUE_RI_TLV_CAP 1 /* draft-ietf-ospf-cap-03 */
111 /* rla_link.link_type */
112 #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
113 #define RLA_TYPE_TRANSIT 2 /* connection to transit network */
114 #define RLA_TYPE_STUB 3 /* connection to stub network */
115 #define RLA_TYPE_VIRTUAL 4 /* virtual link */
117 /* rla_flags */
118 #define RLA_FLAG_B 0x01
119 #define RLA_FLAG_E 0x02
120 #define RLA_FLAG_W1 0x04
121 #define RLA_FLAG_W2 0x08
123 /* sla_tosmetric breakdown */
124 #define SLA_MASK_TOS 0x7f000000
125 #define SLA_MASK_METRIC 0x00ffffff
126 #define SLA_SHIFT_TOS 24
128 /* asla_tosmetric breakdown */
129 #define ASLA_FLAG_EXTERNAL 0x80000000
130 #define ASLA_MASK_TOS 0x7f000000
131 #define ASLA_SHIFT_TOS 24
132 #define ASLA_MASK_METRIC 0x00ffffff
134 /* multicast vertex type */
135 #define MCLA_VERTEX_ROUTER 1
136 #define MCLA_VERTEX_NETWORK 2
138 /* Link-Local-Signaling */
139 #define OSPF_LLS_HDRLEN 4U /* RFC5613 Section 2.2 */
141 #define OSPF_LLS_EO 1 /* RFC4811, RFC4812 */
142 #define OSPF_LLS_MD5 2 /* RFC4813 */
144 #define OSPF_LLS_EO_LR 0x00000001 /* RFC4811 */
145 #define OSPF_LLS_EO_RS 0x00000002 /* RFC4812 */
148 * TOS metric struct (will be 0 or more in router links update)
150 struct tos_metric {
151 uint8_t tos_type;
152 uint8_t reserved;
153 uint8_t tos_metric[2];
155 struct tos_link {
156 uint8_t link_type;
157 uint8_t link_tos_count;
158 uint8_t tos_metric[2];
160 union un_tos {
161 struct tos_link link;
162 struct tos_metric metrics;
165 /* link state advertisement header */
166 struct lsa_hdr {
167 uint16_t ls_age;
168 uint8_t ls_options;
169 uint8_t ls_type;
170 union {
171 struct in_addr lsa_id;
172 struct { /* opaque LSAs change the LSA-ID field */
173 uint8_t opaque_type;
174 uint8_t opaque_id[3];
175 } opaque_field;
176 } un_lsa_id;
177 struct in_addr ls_router;
178 uint32_t ls_seq;
179 uint16_t ls_chksum;
180 uint16_t ls_length;
183 /* link state advertisement */
184 struct lsa {
185 struct lsa_hdr ls_hdr;
187 /* Link state types */
188 union {
189 /* Router links advertisements */
190 struct {
191 uint8_t rla_flags;
192 uint8_t rla_zero[1];
193 uint16_t rla_count;
194 struct rlalink {
195 struct in_addr link_id;
196 struct in_addr link_data;
197 union un_tos un_tos;
198 } rla_link[1]; /* may repeat */
199 } un_rla;
201 /* Network links advertisements */
202 struct {
203 struct in_addr nla_mask;
204 struct in_addr nla_router[1]; /* may repeat */
205 } un_nla;
207 /* Summary links advertisements */
208 struct {
209 struct in_addr sla_mask;
210 uint32_t sla_tosmetric[1]; /* may repeat */
211 } un_sla;
213 /* AS external links advertisements */
214 struct {
215 struct in_addr asla_mask;
216 struct aslametric {
217 uint32_t asla_tosmetric;
218 struct in_addr asla_forward;
219 struct in_addr asla_tag;
220 } asla_metric[1]; /* may repeat */
221 } un_asla;
223 /* Multicast group membership */
224 struct mcla {
225 uint32_t mcla_vtype;
226 struct in_addr mcla_vid;
227 } un_mcla[1];
229 /* Opaque TE LSA */
230 struct {
231 uint16_t type;
232 uint16_t length;
233 uint8_t data[1]; /* may repeat */
234 } un_te_lsa_tlv;
236 /* Opaque Grace LSA */
237 struct {
238 uint16_t type;
239 uint16_t length;
240 uint8_t data[1]; /* may repeat */
241 } un_grace_tlv;
243 /* Opaque Router information LSA */
244 struct {
245 uint16_t type;
246 uint16_t length;
247 uint8_t data[1]; /* may repeat */
248 } un_ri_tlv;
250 /* Unknown LSA */
251 struct unknown {
252 uint8_t data[1]; /* may repeat */
253 } un_unknown[1];
255 } lsa_un;
258 #define OSPF_AUTH_SIZE 8
261 * the main header
263 struct ospfhdr {
264 uint8_t ospf_version;
265 uint8_t ospf_type;
266 uint16_t ospf_len;
267 struct in_addr ospf_routerid;
268 struct in_addr ospf_areaid;
269 uint16_t ospf_chksum;
270 uint16_t ospf_authtype;
271 uint8_t ospf_authdata[OSPF_AUTH_SIZE];
272 union {
274 /* Hello packet */
275 struct {
276 struct in_addr hello_mask;
277 uint16_t hello_helloint;
278 uint8_t hello_options;
279 uint8_t hello_priority;
280 uint32_t hello_deadint;
281 struct in_addr hello_dr;
282 struct in_addr hello_bdr;
283 struct in_addr hello_neighbor[1]; /* may repeat */
284 } un_hello;
286 /* Database Description packet */
287 struct {
288 uint16_t db_ifmtu;
289 uint8_t db_options;
290 uint8_t db_flags;
291 uint32_t db_seq;
292 struct lsa_hdr db_lshdr[1]; /* may repeat */
293 } un_db;
295 /* Link State Request */
296 struct lsr {
297 uint8_t ls_type[4];
298 union {
299 struct in_addr ls_stateid;
300 struct { /* opaque LSAs change the LSA-ID field */
301 uint8_t opaque_type;
302 uint8_t opaque_id[3];
303 } opaque_field;
304 } un_ls_stateid;
305 struct in_addr ls_router;
306 } un_lsr[1]; /* may repeat */
308 /* Link State Update */
309 struct {
310 uint32_t lsu_count;
311 struct lsa lsu_lsa[1]; /* may repeat */
312 } un_lsu;
314 /* Link State Acknowledgement */
315 struct {
316 struct lsa_hdr lsa_lshdr[1]; /* may repeat */
317 } un_lsa ;
318 } ospf_un ;
321 #define ospf_hello ospf_un.un_hello
322 #define ospf_db ospf_un.un_db
323 #define ospf_lsr ospf_un.un_lsr
324 #define ospf_lsu ospf_un.un_lsu
325 #define ospf_lsa ospf_un.un_lsa