xref: /freebsd/contrib/tcpdump/ospf.h (revision 8e537d168674d6b65869f73c20813001af875738)
1 /*
2  * Copyright (c) 1991, 1993, 1994, 1995, 1996
3  *	The Regents of the University of California.  All rights reserved.
4  *
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.
20  *
21  * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
22  */
23 #define	OSPF_TYPE_UMD	0	/* UMd's special monitoring packets */
24 #define	OSPF_TYPE_HELLO	1	/* Hello */
25 #define	OSPF_TYPE_DB	2	/* Database Description */
26 #define	OSPF_TYPE_LSR	3	/* Link State Request */
27 #define	OSPF_TYPE_LSU	4	/* Link State Update */
28 #define	OSPF_TYPE_LSA	5	/* Link State Ack */
29 #define	OSPF_TYPE_MAX	6
30 
31 /* Options *_options	*/
32 #define OSPF_OPTION_T	0x01	/* T bit: TOS support	*/
33 #define OSPF_OPTION_E	0x02	/* E bit: External routes advertised	*/
34 #define	OSPF_OPTION_MC	0x04	/* MC bit: Multicast capable */
35 
36 /* ospf_authtype	*/
37 #define	OSPF_AUTH_NONE		0	/* No auth-data */
38 #define	OSPF_AUTH_SIMPLE	1	/* Simple password */
39 
40 /* db_flags	*/
41 #define	OSPF_DB_INIT		0x04	    /*	*/
42 #define	OSPF_DB_MORE		0x02
43 #define	OSPF_DB_MASTER		0x01
44 
45 /* ls_type	*/
46 #define	LS_TYPE_ROUTER		1   /* router link */
47 #define	LS_TYPE_NETWORK		2   /* network link */
48 #define	LS_TYPE_SUM_IP		3   /* summary link */
49 #define	LS_TYPE_SUM_ABR		4   /* summary area link */
50 #define	LS_TYPE_ASE		5   /* ASE  */
51 #define	LS_TYPE_GROUP		6   /* Group membership (multicast */
52 				    /* extensions 23 July 1991) */
53 #define	LS_TYPE_MAX		7
54 
55 /*************************************************
56  *
57  * is the above a bug in the documentation?
58  *
59  *************************************************/
60 
61 
62 /* rla_link.link_type	*/
63 #define	RLA_TYPE_ROUTER		1   /* point-to-point to another router	*/
64 #define	RLA_TYPE_TRANSIT	2   /* connection to transit network	*/
65 #define	RLA_TYPE_STUB		3   /* connection to stub network	*/
66 #define RLA_TYPE_VIRTUAL	4   /* virtual link			*/
67 
68 /* rla_flags	*/
69 #define	RLA_FLAG_B	0x01
70 #define	RLA_FLAG_E	0x02
71 #define	RLA_FLAG_W1	0x04
72 #define	RLA_FLAG_W2	0x08
73 
74 /* sla_tosmetric breakdown	*/
75 #define	SLA_MASK_TOS		0x7f000000
76 #define	SLA_MASK_METRIC		0x00ffffff
77 #define SLA_SHIFT_TOS		24
78 
79 /* asla_tosmetric breakdown	*/
80 #define	ASLA_FLAG_EXTERNAL	0x80000000
81 #define	ASLA_MASK_TOS		0x7f000000
82 #define	ASLA_SHIFT_TOS		24
83 #define	ASLA_MASK_METRIC	0x00ffffff
84 
85 /* multicast vertex type */
86 #define	MCLA_VERTEX_ROUTER	1
87 #define	MCLA_VERTEX_NETWORK	2
88 
89 /* link state advertisement header */
90 struct lsa_hdr {
91     u_short ls_age;
92     u_char ls_options;
93     u_char ls_type;
94     struct in_addr ls_stateid;
95     struct in_addr ls_router;
96     u_int32_t ls_seq;
97     u_short ls_chksum;
98     u_short ls_length;
99 } ;
100 
101 /* link state advertisement */
102 struct lsa {
103     struct lsa_hdr ls_hdr;
104 
105     /* Link state types */
106     union {
107 	/* Router links advertisements */
108 	struct {
109 	    u_char rla_flags;
110 	    u_char rla_zero[1];
111 	    u_short rla_count;
112 	    struct rlalink {
113 		struct in_addr link_id;
114 		struct in_addr link_data;
115 		u_char link_type;
116 		u_char link_toscount;
117 		u_short link_tos0metric;
118 	    } rla_link[1];		/* may repeat	*/
119 	} un_rla;
120 
121 	/* Network links advertisements */
122 	struct {
123 	    struct in_addr nla_mask;
124 	    struct in_addr nla_router[1];	/* may repeat	*/
125 	} un_nla;
126 
127 	/* Summary links advertisements */
128 	struct {
129 	    struct in_addr sla_mask;
130 	    u_int32_t sla_tosmetric[1];	/* may repeat	*/
131 	} un_sla;
132 
133 	/* AS external links advertisements */
134 	struct {
135 	    struct in_addr asla_mask;
136 	    struct aslametric {
137 		u_int32_t asla_tosmetric;
138 		struct in_addr asla_forward;
139 		struct in_addr asla_tag;
140 	    } asla_metric[1];		/* may repeat	*/
141 	} un_asla;
142 
143 	/* Multicast group membership */
144 	struct mcla {
145 	    u_int32_t mcla_vtype;
146 	    struct in_addr mcla_vid;
147 	} un_mcla[1];
148     } lsa_un;
149 } ;
150 
151 
152 /*
153  * TOS metric struct (will be 0 or more in router links update)
154  */
155 struct tos_metric {
156     u_char tos_type;
157     u_char tos_zero;
158     u_short tos_metric;
159 } ;
160 
161 #define	OSPF_AUTH_SIZE	8
162 
163 /*
164  * the main header
165  */
166 struct ospfhdr {
167     u_char ospf_version;
168     u_char ospf_type;
169     u_short ospf_len;
170     struct in_addr ospf_routerid;
171     struct in_addr ospf_areaid;
172     u_short ospf_chksum;
173     u_short ospf_authtype;
174     u_char ospf_authdata[OSPF_AUTH_SIZE];
175     union {
176 
177 	/* Hello packet */
178 	struct {
179 	    struct in_addr hello_mask;
180 	    u_short hello_helloint;
181 	    u_char hello_options;
182 	    u_char hello_priority;
183 	    u_int32_t hello_deadint;
184 	    struct in_addr hello_dr;
185 	    struct in_addr hello_bdr;
186 	    struct in_addr hello_neighbor[1]; /* may repeat	*/
187 	} un_hello;
188 
189 	/* Database Description packet */
190 	struct {
191 	    u_char db_zero[2];
192 	    u_char db_options;
193 	    u_char db_flags;
194 	    u_int32_t db_seq;
195 	    struct lsa_hdr db_lshdr[1]; /* may repeat	*/
196 	} un_db;
197 
198 	/* Link State Request */
199 	struct lsr {
200 	    u_int32_t ls_type;
201 	    struct in_addr ls_stateid;
202 	    struct in_addr ls_router;
203 	} un_lsr[1];		/* may repeat	*/
204 
205 	/* Link State Update */
206 	struct {
207 	    u_int32_t lsu_count;
208 	    struct lsa lsu_lsa[1]; /* may repeat	*/
209 	} un_lsu;
210 
211 	/* Link State Acknowledgement */
212 	struct {
213 	    struct lsa_hdr lsa_lshdr[1]; /* may repeat	*/
214 	} un_lsa ;
215     } ospf_un ;
216 } ;
217 
218 #define	ospf_hello	ospf_un.un_hello
219 #define	ospf_db		ospf_un.un_db
220 #define	ospf_lsr	ospf_un.un_lsr
221 #define	ospf_lsu	ospf_un.un_lsu
222 #define	ospf_lsa	ospf_un.un_lsa
223 
224