ospf.h revision 127668
155992Swpaul/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.11 2003/10/22 17:08:46 hannes Exp $ (LBL) */
255992Swpaul/*
355992Swpaul * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
455992Swpaul *	The Regents of the University of California.  All rights reserved.
555992Swpaul *
655992Swpaul * Redistribution and use in source and binary forms, with or without
755992Swpaul * modification, are permitted provided that: (1) source code distributions
855992Swpaul * retain the above copyright notice and this paragraph in its entirety, (2)
955992Swpaul * distributions including binary code include the above copyright notice and
1055992Swpaul * this paragraph in its entirety in the documentation or other materials
1155992Swpaul * provided with the distribution, and (3) all advertising materials mentioning
1255992Swpaul * features or use of this software display the following acknowledgement:
1355992Swpaul * ``This product includes software developed by the University of California,
1455992Swpaul * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
1555992Swpaul * the University nor the names of its contributors may be used to endorse
1655992Swpaul * or promote products derived from this software without specific prior
1755992Swpaul * written permission.
1855992Swpaul * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
1955992Swpaul * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
2055992Swpaul * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2155992Swpaul *
2255992Swpaul * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
2355992Swpaul */
2455992Swpaul#define	OSPF_TYPE_UMD           0	/* UMd's special monitoring packets */
2555992Swpaul#define	OSPF_TYPE_HELLO         1	/* Hello */
2655992Swpaul#define	OSPF_TYPE_DD            2	/* Database Description */
2755992Swpaul#define	OSPF_TYPE_LS_REQ        3	/* Link State Request */
2855992Swpaul#define	OSPF_TYPE_LS_UPDATE     4	/* Link State Update */
2955992Swpaul#define	OSPF_TYPE_LS_ACK        5	/* Link State Ack */
3055992Swpaul
3155992Swpaul/* Options field
3255992Swpaul *
3355992Swpaul * +------------------------------------+
3455992Swpaul * | * | O | DC | EA | N/P | MC | E | T |
3555992Swpaul * +------------------------------------+
3655992Swpaul *
3755992Swpaul */
3855992Swpaul
3955992Swpaul#define OSPF_OPTION_T	0x01	/* T bit: TOS support	*/
40113038Sobrien#define OSPF_OPTION_E	0x02	/* E bit: External routes advertised	*/
41113038Sobrien#define	OSPF_OPTION_MC	0x04	/* MC bit: Multicast capable */
42113038Sobrien#define	OSPF_OPTION_NP	0x08	/* N/P bit: NSSA capable */
4355992Swpaul#define	OSPF_OPTION_EA	0x10	/* EA bit: External Attribute capable */
44113038Sobrien#define	OSPF_OPTION_DC	0x20	/* DC bit: Demand circuit capable */
4555992Swpaul#define	OSPF_OPTION_O	0x40	/* O bit: Opaque LSA capable */
4655992Swpaul
4755992Swpaul/* ospf_authtype	*/
4855992Swpaul#define	OSPF_AUTH_NONE		0	/* No auth-data */
4955992Swpaul#define	OSPF_AUTH_SIMPLE	1	/* Simple password */
5055992Swpaul#define OSPF_AUTH_MD5		2	/* MD5 authentication */
5155992Swpaul#define OSPF_AUTH_MD5_LEN	16	/* length of MD5 authentication */
5255992Swpaul
5355992Swpaul/* db_flags	*/
5455992Swpaul#define	OSPF_DB_INIT		0x04	    /*	*/
5555992Swpaul#define	OSPF_DB_MORE		0x02
5655992Swpaul#define	OSPF_DB_MASTER		0x01
5755992Swpaul
5855992Swpaul/* ls_type	*/
5955992Swpaul#define	LS_TYPE_ROUTER		1   /* router link */
6055992Swpaul#define	LS_TYPE_NETWORK		2   /* network link */
6155992Swpaul#define	LS_TYPE_SUM_IP		3   /* summary link */
6255992Swpaul#define	LS_TYPE_SUM_ABR		4   /* summary area link */
6355992Swpaul#define	LS_TYPE_ASE		5   /* ASE  */
6455992Swpaul#define	LS_TYPE_GROUP		6   /* Group membership (multicast */
6555992Swpaul				    /* extensions 23 July 1991) */
6655992Swpaul#define	LS_TYPE_NSSA            7   /* rfc1587 - Not so Stubby Areas */
6777217Sphk#define	LS_TYPE_OPAQUE_LL       9   /* rfc2370 - Opaque Link Local */
6855992Swpaul#define	LS_TYPE_OPAQUE_AL      10   /* rfc2370 - Opaque Link Local */
6955992Swpaul#define	LS_TYPE_OPAQUE_DW      11   /* rfc2370 - Opaque Domain Wide */
7055992Swpaul
7155992Swpaul#define LS_OPAQUE_TYPE_TE       1   /* rfc3630 */
7255992Swpaul#define LS_OPAQUE_TYPE_GRACE    3   /* draft-ietf-ospf-hitless-restart */
7355992Swpaul
7455992Swpaul#define LS_OPAQUE_TE_TLV_ROUTER 1   /* rfc3630 */
7555992Swpaul#define LS_OPAQUE_TE_TLV_LINK   2   /* rfc3630 */
7655992Swpaul
7755992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE             1 /* rfc3630 */
7855992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID               2 /* rfc3630 */
7955992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP              3 /* rfc3630 */
8092739Salfred#define LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP             4 /* rfc3630 */
8192739Salfred#define LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC             5 /* rfc3630 */
8255992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW                6 /* rfc3630 */
8383270Sbrooks#define LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW            7 /* rfc3630 */
8483270Sbrooks#define LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW              8 /* rfc3630 */
8555992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP           9 /* rfc3630 */
8655992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID 11 /* draft-ietf-ccamp-ospf-gmpls-extensions */
8755992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE 14 /* draft-ietf-ccamp-ospf-gmpls-extensions */
8855992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR    15 /* draft-ietf-ccamp-ospf-gmpls-extensions */
8955992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP    16 /* draft-ietf-ccamp-ospf-gmpls-extensions */
9055992Swpaul
9155992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP        1  /* rfc3630 */
9255992Swpaul#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA         2  /* rfc3630 */
9355992Swpaul
9455992Swpaul/*************************************************
9555992Swpaul *
9655992Swpaul * is the above a bug in the documentation?
9755992Swpaul *
9855992Swpaul *************************************************/
9955992Swpaul
10055992Swpaul
10155992Swpaul/* rla_link.link_type	*/
10283270Sbrooks#define	RLA_TYPE_ROUTER		1   /* point-to-point to another router	*/
10355992Swpaul#define	RLA_TYPE_TRANSIT	2   /* connection to transit network	*/
10455992Swpaul#define	RLA_TYPE_STUB		3   /* connection to stub network	*/
10555992Swpaul#define RLA_TYPE_VIRTUAL	4   /* virtual link			*/
10655992Swpaul
10755992Swpaul/* rla_flags	*/
10855992Swpaul#define	RLA_FLAG_B	0x01
10955992Swpaul#define	RLA_FLAG_E	0x02
11055992Swpaul#define	RLA_FLAG_W1	0x04
11155992Swpaul#define	RLA_FLAG_W2	0x08
11283270Sbrooks
11355992Swpaul/* sla_tosmetric breakdown	*/
11455992Swpaul#define	SLA_MASK_TOS		0x7f000000
11583270Sbrooks#define	SLA_MASK_METRIC		0x00ffffff
116113316Simp#define SLA_SHIFT_TOS		24
117113316Simp
118113316Simp/* asla_tosmetric breakdown	*/
119113316Simp#define	ASLA_FLAG_EXTERNAL	0x80000000
120113316Simp#define	ASLA_MASK_TOS		0x7f000000
121113316Simp#define	ASLA_SHIFT_TOS		24
122113316Simp#define	ASLA_MASK_METRIC	0x00ffffff
123113316Simp
124113316Simp/* multicast vertex type */
125113316Simp#define	MCLA_VERTEX_ROUTER	1
12655992Swpaul#define	MCLA_VERTEX_NETWORK	2
12755992Swpaul
12855992Swpaul/* link state advertisement header */
12955992Swpaulstruct lsa_hdr {
13055992Swpaul    u_int16_t ls_age;
13155992Swpaul    u_int8_t ls_options;
132113316Simp    u_int8_t ls_type;
13383270Sbrooks    union {
13455992Swpaul        struct in_addr lsa_id;
13555992Swpaul        struct { /* opaque LSAs change the LSA-ID field */
13655992Swpaul            u_int8_t opaque_type;
13755992Swpaul            u_int8_t opaque_id[3];
13855992Swpaul	} opaque_field;
139123978Sambrisko    } un_lsa_id;
14055992Swpaul    struct in_addr ls_router;
14155992Swpaul    u_int32_t ls_seq;
14255992Swpaul    u_int16_t ls_chksum;
14355992Swpaul    u_int16_t ls_length;
14455992Swpaul};
14555992Swpaul
14655992Swpaul/* link state advertisement */
14755992Swpaulstruct lsa {
14855992Swpaul    struct lsa_hdr ls_hdr;
14955992Swpaul
15055992Swpaul    /* Link state types */
15155992Swpaul    union {
152113506Smdodd	/* Router links advertisements */
153113506Smdodd	struct {
154113506Smdodd	    u_int8_t rla_flags;
155	    u_int8_t rla_zero[1];
156	    u_int16_t rla_count;
157	    struct rlalink {
158		struct in_addr link_id;
159		struct in_addr link_data;
160		u_int8_t link_type;
161		u_int8_t link_toscount;
162		u_int16_t link_tos0metric;
163	    } rla_link[1];		/* may repeat	*/
164	} un_rla;
165
166	/* Network links advertisements */
167	struct {
168	    struct in_addr nla_mask;
169	    struct in_addr nla_router[1];	/* may repeat	*/
170	} un_nla;
171
172	/* Summary links advertisements */
173	struct {
174	    struct in_addr sla_mask;
175	    u_int32_t sla_tosmetric[1];	/* may repeat	*/
176	} un_sla;
177
178	/* AS external links advertisements */
179	struct {
180	    struct in_addr asla_mask;
181	    struct aslametric {
182		u_int32_t asla_tosmetric;
183		struct in_addr asla_forward;
184		struct in_addr asla_tag;
185	    } asla_metric[1];		/* may repeat	*/
186	} un_asla;
187
188	/* Multicast group membership */
189	struct mcla {
190	    u_int32_t mcla_vtype;
191	    struct in_addr mcla_vid;
192	} un_mcla[1];
193
194        /* Opaque TE LSA */
195        struct {
196	    u_int16_t type;
197	    u_int16_t length;
198	    u_int8_t data[1]; /* may repeat   */
199	} un_te_lsa_tlv;
200
201        /* Unknown LSA */
202        struct unknown {
203	    u_int8_t data[1]; /* may repeat   */
204	} un_unknown[1];
205
206    } lsa_un;
207};
208
209
210/*
211 * TOS metric struct (will be 0 or more in router links update)
212 */
213struct tos_metric {
214    u_int8_t tos_type;
215    u_int8_t tos_zero;
216    u_int16_t tos_metric;
217};
218
219#define	OSPF_AUTH_SIZE	8
220
221/*
222 * the main header
223 */
224struct ospfhdr {
225    u_int8_t ospf_version;
226    u_int8_t ospf_type;
227    u_int16_t ospf_len;
228    struct in_addr ospf_routerid;
229    struct in_addr ospf_areaid;
230    u_int16_t ospf_chksum;
231    u_int16_t ospf_authtype;
232    u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
233    union {
234
235	/* Hello packet */
236	struct {
237	    struct in_addr hello_mask;
238	    u_int16_t hello_helloint;
239	    u_int8_t hello_options;
240	    u_int8_t hello_priority;
241	    u_int32_t hello_deadint;
242	    struct in_addr hello_dr;
243	    struct in_addr hello_bdr;
244	    struct in_addr hello_neighbor[1]; /* may repeat	*/
245	} un_hello;
246
247	/* Database Description packet */
248	struct {
249	    u_int8_t db_zero[2];
250	    u_int8_t db_options;
251	    u_int8_t db_flags;
252	    u_int32_t db_seq;
253	    struct lsa_hdr db_lshdr[1]; /* may repeat	*/
254	} un_db;
255
256	/* Link State Request */
257	struct lsr {
258	    u_int8_t ls_type[4];
259            union {
260                struct in_addr ls_stateid;
261                struct { /* opaque LSAs change the LSA-ID field */
262                    u_int8_t opaque_type;
263                    u_int8_t opaque_id[3];
264                } opaque_field;
265            } un_ls_stateid;
266	    struct in_addr ls_router;
267	} un_lsr[1];		/* may repeat	*/
268
269	/* Link State Update */
270	struct {
271	    u_int32_t lsu_count;
272	    struct lsa lsu_lsa[1]; /* may repeat	*/
273	} un_lsu;
274
275	/* Link State Acknowledgement */
276	struct {
277	    struct lsa_hdr lsa_lshdr[1]; /* may repeat	*/
278	} un_lsa ;
279    } ospf_un ;
280};
281
282#define	ospf_hello	ospf_un.un_hello
283#define	ospf_db		ospf_un.un_db
284#define	ospf_lsr	ospf_un.un_lsr
285#define	ospf_lsu	ospf_un.un_lsu
286#define	ospf_lsa	ospf_un.un_lsa
287
288