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