4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 * Definitions for parsing OSPF packets (RFC 2328 and RFC 2740)
40 #define OSPF_TYPE_UMD 0 /* UMD's special monitoring packets */
41 #define OSPF_TYPE_HELLO 1 /* Hello */
42 #define OSPF_TYPE_DB 2 /* Database Description */
43 #define OSPF_TYPE_LSR 3 /* Link State Request */
44 #define OSPF_TYPE_LSU 4 /* Link State Update */
45 #define OSPF_TYPE_LSA 5 /* Link State Ack */
46 #define OSPF_TYPE_MAX 6
48 extern char *ospf_types
[];
53 char *ospf_print_bits(const struct bits
*, uchar_t
);
54 char *ospf_print_lsa_age(long);
56 /* Options *_options */
57 #define OSPF_OPTION_T 0x01 /* RFC 2328 T bit: TOS support */
58 #define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */
59 #define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */
60 #define OSPF_OPTION_N 0x08 /* N bit: For type-7 LSA */
61 #define OSPF_OPTION_R 0x10 /* R bit: Router bit */
62 #define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuits */
64 #define OSPF_OPTION_V6 0x01 /* RFC 2740 V6 bit */
67 #define OSPF_AUTH_NONE 0 /* No auth-data */
68 #define OSPF_AUTH_SIMPLE 1 /* Simple password */
69 #define OSPF_AUTH_MD5 2 /* MD5 authentication */
70 #define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */
72 #define OSPF_AUTH_TYPE_MAX 3
75 #define OSPF_DB_INIT 0x04 /* "I" */
76 #define OSPF_DB_MORE 0x02 /* "M" */
77 #define OSPF_DB_MASTER 0x01 /* "MS" */
81 #define LS_TYPE_ROUTER 1 /* router link */
82 #define LS_TYPE_NETWORK 2 /* network link */
83 #define LS_TYPE_SUM_IP 3 /* summary link */
84 #define LS_TYPE_SUM_ABR 4 /* summary area link */
85 #define LS_TYPE_ASE 5 /* ASE */
86 #define LS_TYPE_GROUP 6 /* Group membership (multicast */
87 /* extensions 23 July 1991) */
88 #define LS_TYPE_TYPE7 7 /* Type 7 LSA */
89 #define LS_TYPE_LINK 8 /* Link LSA */
90 #define LS_TYPE_INTRA_AP 9 /* Intra-Area-Prefix */
91 #define LS_TYPE_MAX 10
92 #define LS_TYPE_MASK 0x1fff
94 #define LS_TYPE_INTER_AP 3 /* RFC 2740 Inter-Area-Prefix */
95 #define LS_TYPE_INTER_AR 4 /* RFC 2740 Inter-Area-Router */
97 #define LS6_SCOPE_LINKLOCAL 0x0000
98 #define LS6_SCOPE_AREA 0x2000
99 #define LS6_SCOPE_AS 0x4000
100 #define LS6_SCOPE_MASK 0x6000
102 /* rla_link.link_type */
103 #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */
104 #define RLA_TYPE_TRANSIT 2 /* connection to transit network */
105 #define RLA_TYPE_STUB 3 /* connection to stub network */
106 #define RLA_TYPE_VIRTUAL 4 /* virtual link */
109 #define RLA_FLAG_B 0x01
110 #define RLA_FLAG_E 0x02
111 #define RLA_FLAG_V 0x04
112 #define RLA_FLAG_W 0x08
115 /* sla_tosmetric breakdown */
116 #define SLA_MASK_TOS 0x7f000000
117 #define SLA_MASK_METRIC 0x00ffffff
118 #define SLA_SHIFT_TOS 24
120 /* asla_tosmetric breakdown */
121 #define ASLA_FLAG_EXTERNAL 0x80000000
122 #define ASLA_MASK_TOS 0x7f000000
123 #define ASLA_SHIFT_TOS 24
124 #define ASLA_MASK_METRIC 0x00ffffff
126 /* multicast vertex type */
127 #define MCLA_VERTEX_ROUTER 1
128 #define MCLA_VERTEX_NETWORK 2
130 /* link state advertisement header */
135 struct in_addr ls_stateid
;
136 struct in_addr ls_router
;
142 /* link state advertisement */
144 struct lsa_hdr ls_hdr
;
146 /* Link state types */
148 /* Router links advertisements */
154 struct in_addr link_id
;
155 struct in_addr link_data
;
157 uchar_t link_toscount
;
158 ushort_t link_tos0metric
;
159 } rla_link
[1]; /* may repeat */
162 /* Network links advertisements */
164 struct in_addr nla_mask
;
165 struct in_addr nla_router
[1]; /* may repeat */
168 /* Summary links advertisements */
170 struct in_addr sla_mask
;
171 uint32_t sla_tosmetric
[1]; /* may repeat */
174 /* AS external links advertisements */
176 struct in_addr asla_mask
;
178 uint32_t asla_tosmetric
;
179 struct in_addr asla_forward
;
180 struct in_addr asla_tag
;
181 } asla_metric
[1]; /* may repeat */
184 /* Multicast group membership */
187 struct in_addr mcla_vid
;
193 * TOS metric struct (will be 0 or more in router links update)
202 * OSPF minimum header sizes
204 #define OSPF_AUTH_SIZE 8
205 #define OSPF_MIN_HEADER_SIZE 24
206 #define OSPF6_MIN_HEADER_SIZE 16
207 #define OSPF_MIN_HELLO_HEADER_SIZE 20
208 #define OSPF_MIN_DB_HEADER_SIZE 8
209 #define OSPF6_MIN_DB_HEADER_SIZE 12
210 #define OSPF_MIN_LSR_HEADER_SIZE 12
211 #define OSPF_MIN_LSU_HEADER_SIZE 4
217 uchar_t ospf_version
;
220 struct in_addr ospf_routerid
;
221 struct in_addr ospf_areaid
;
222 ushort_t ospf_chksum
;
223 ushort_t ospf_authtype
;
224 uchar_t ospf_authdata
[OSPF_AUTH_SIZE
];
229 struct in_addr hello_mask
;
230 ushort_t hello_helloint
;
231 uchar_t hello_options
;
232 uchar_t hello_priority
;
233 uint32_t hello_deadint
;
234 struct in_addr hello_dr
;
235 struct in_addr hello_bdr
;
236 struct in_addr hello_neighbor
[1]; /* may repeat */
239 /* Database Description packet */
245 struct lsa_hdr db_lshdr
[1]; /* may repeat */
248 /* Link State Request */
251 struct in_addr ls_stateid
;
252 struct in_addr ls_router
;
253 } un_lsr
[1]; /* may repeat */
255 /* Link State Update */
258 struct lsa lsu_lsa
[1]; /* may repeat */
261 /* Link State Acknowledgement */
263 struct lsa_hdr lsa_lshdr
[1]; /* may repeat */
268 #define ospf_hello ospf_un.un_hello
269 #define ospf_db ospf_un.un_db
270 #define ospf_lsr ospf_un.un_lsr
271 #define ospf_lsu ospf_un.un_lsu
272 #define ospf_lsa ospf_un.un_lsa