xref: /titanic_50/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ospf6.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _OSPF6_H
28*7c478bd9Sstevel@tonic-gate #define	_OSPF6_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Definitions for parsing OSPF packets (RFC 2328)
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
37*7c478bd9Sstevel@tonic-gate extern "C" {
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate struct lsa6_hdr {
41*7c478bd9Sstevel@tonic-gate 	uint16_t ls6_age;
42*7c478bd9Sstevel@tonic-gate 	uint16_t ls6_type;
43*7c478bd9Sstevel@tonic-gate 	uint32_t ls6_stateid;
44*7c478bd9Sstevel@tonic-gate 	uint32_t ls6_router;
45*7c478bd9Sstevel@tonic-gate 	uint32_t ls6_seq;
46*7c478bd9Sstevel@tonic-gate 	uint16_t ls6_chksum;
47*7c478bd9Sstevel@tonic-gate 	uint16_t ls6_length;
48*7c478bd9Sstevel@tonic-gate };
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate struct lsa6_prefix {
51*7c478bd9Sstevel@tonic-gate 	uint8_t  lsa6_plen;
52*7c478bd9Sstevel@tonic-gate 	uint8_t  lsa6_popt;
53*7c478bd9Sstevel@tonic-gate 	uint16_t lsa6_pmbz;
54*7c478bd9Sstevel@tonic-gate 	uint8_t  lsa6_pfx[4];
55*7c478bd9Sstevel@tonic-gate };
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate /* link state advertisement */
58*7c478bd9Sstevel@tonic-gate struct lsa6 {
59*7c478bd9Sstevel@tonic-gate 	struct lsa6_hdr ls6_hdr;
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate 	/* Link state types */
62*7c478bd9Sstevel@tonic-gate 	union {
63*7c478bd9Sstevel@tonic-gate 		/* Router links advertisements */
64*7c478bd9Sstevel@tonic-gate 		struct {
65*7c478bd9Sstevel@tonic-gate 			union {
66*7c478bd9Sstevel@tonic-gate 				uint8_t  rla_flg;
67*7c478bd9Sstevel@tonic-gate 				uint32_t rla_opt;
68*7c478bd9Sstevel@tonic-gate 			} un_rla_flgopt;
69*7c478bd9Sstevel@tonic-gate #define	rla6_flags	un_rla_flgopt.rla_flg
70*7c478bd9Sstevel@tonic-gate #define	rla6_options	un_rla_flgopt.rla_opt
71*7c478bd9Sstevel@tonic-gate 			struct rla6link {
72*7c478bd9Sstevel@tonic-gate 				uint8_t link_type;
73*7c478bd9Sstevel@tonic-gate 				uint8_t link_zero[1];
74*7c478bd9Sstevel@tonic-gate 				uint16_t link_metric;
75*7c478bd9Sstevel@tonic-gate 				uint32_t link_ifid;
76*7c478bd9Sstevel@tonic-gate 				uint32_t link_nifid;
77*7c478bd9Sstevel@tonic-gate 				uint32_t link_nrtid;
78*7c478bd9Sstevel@tonic-gate 			} rla_link[1];		/* may repeat	*/
79*7c478bd9Sstevel@tonic-gate 		} un_rla;
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate 		/* Network links advertisements */
82*7c478bd9Sstevel@tonic-gate 		struct {
83*7c478bd9Sstevel@tonic-gate 			uint32_t nla_options;
84*7c478bd9Sstevel@tonic-gate 			uint32_t nla_router[1];	/* may repeat	*/
85*7c478bd9Sstevel@tonic-gate 		} un_nla;
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate 		/* Inter Area Prefix LSA */
88*7c478bd9Sstevel@tonic-gate 		struct {
89*7c478bd9Sstevel@tonic-gate 			uint32_t inter_ap_metric;
90*7c478bd9Sstevel@tonic-gate 			struct lsa6_prefix inter_ap_prefix[1];
91*7c478bd9Sstevel@tonic-gate 		} un_inter_ap;
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate 		/* Link LSA */
94*7c478bd9Sstevel@tonic-gate 		struct llsa {
95*7c478bd9Sstevel@tonic-gate 			union {
96*7c478bd9Sstevel@tonic-gate 				uint8_t pri;
97*7c478bd9Sstevel@tonic-gate 				uint32_t opt;
98*7c478bd9Sstevel@tonic-gate 			} llsa_priandopt;
99*7c478bd9Sstevel@tonic-gate #define	llsa_priority	llsa_priandopt.pri
100*7c478bd9Sstevel@tonic-gate #define	llsa_options	llsa_priandopt.opt
101*7c478bd9Sstevel@tonic-gate 			struct in6_addr llsa_lladdr;
102*7c478bd9Sstevel@tonic-gate 			uint32_t llsa_nprefix;
103*7c478bd9Sstevel@tonic-gate 			struct lsa6_prefix llsa_prefix[1];
104*7c478bd9Sstevel@tonic-gate 		} un_llsa;
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate 		/* Intra-Area-Prefix */
107*7c478bd9Sstevel@tonic-gate 		struct {
108*7c478bd9Sstevel@tonic-gate 			uint16_t intra_ap_nprefix;
109*7c478bd9Sstevel@tonic-gate 			uint16_t intra_ap_lstype;
110*7c478bd9Sstevel@tonic-gate 			uint32_t intra_ap_lsid;
111*7c478bd9Sstevel@tonic-gate 			uint32_t intra_ap_rtid;
112*7c478bd9Sstevel@tonic-gate 			struct lsa6_prefix intra_ap_prefix[1];
113*7c478bd9Sstevel@tonic-gate 		} un_intra_ap;
114*7c478bd9Sstevel@tonic-gate 	} lsa_un;
115*7c478bd9Sstevel@tonic-gate };
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate struct ospf6hdr {
118*7c478bd9Sstevel@tonic-gate 	uint8_t ospf6_version;
119*7c478bd9Sstevel@tonic-gate 	uint8_t ospf6_type;
120*7c478bd9Sstevel@tonic-gate 	uint16_t ospf6_len;
121*7c478bd9Sstevel@tonic-gate 	uint32_t ospf6_routerid;
122*7c478bd9Sstevel@tonic-gate 	uint32_t ospf6_areaid;
123*7c478bd9Sstevel@tonic-gate 	uint16_t ospf6_chksum;
124*7c478bd9Sstevel@tonic-gate 	uint8_t ospf6_instanceid;
125*7c478bd9Sstevel@tonic-gate 	uint8_t ospf6_rsvd;
126*7c478bd9Sstevel@tonic-gate 	union {
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate 		/* Hello packet */
129*7c478bd9Sstevel@tonic-gate 		struct {
130*7c478bd9Sstevel@tonic-gate 			uint32_t hello_ifid;
131*7c478bd9Sstevel@tonic-gate 			union {
132*7c478bd9Sstevel@tonic-gate 				uint8_t pri;
133*7c478bd9Sstevel@tonic-gate 				uint32_t opt;
134*7c478bd9Sstevel@tonic-gate 			} hello_priandopt;
135*7c478bd9Sstevel@tonic-gate #define	hello6_priority	hello_priandopt.pri
136*7c478bd9Sstevel@tonic-gate #define	hello6_options	hello_priandopt.opt
137*7c478bd9Sstevel@tonic-gate 			uint16_t hello_helloint;
138*7c478bd9Sstevel@tonic-gate 			uint16_t hello_deadint;
139*7c478bd9Sstevel@tonic-gate 			uint32_t hello_dr;
140*7c478bd9Sstevel@tonic-gate 			uint32_t hello_bdr;
141*7c478bd9Sstevel@tonic-gate 			uint32_t hello_neighbor[1];	/* may repeat	*/
142*7c478bd9Sstevel@tonic-gate 		} un_hello;
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate 		/* Database Description packet */
145*7c478bd9Sstevel@tonic-gate 		struct {
146*7c478bd9Sstevel@tonic-gate 			uint32_t db_options;
147*7c478bd9Sstevel@tonic-gate 			uint16_t db_mtu;
148*7c478bd9Sstevel@tonic-gate 			uint8_t db_mbz;
149*7c478bd9Sstevel@tonic-gate 			uint8_t db_flags;
150*7c478bd9Sstevel@tonic-gate 			uint32_t db_seq;
151*7c478bd9Sstevel@tonic-gate 			struct lsa6_hdr db_lshdr[1];	/* may repeat	*/
152*7c478bd9Sstevel@tonic-gate 		} un_db;
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate 		/* Link State Request */
155*7c478bd9Sstevel@tonic-gate 		struct lsr6 {
156*7c478bd9Sstevel@tonic-gate 			uint16_t ls_mbz;
157*7c478bd9Sstevel@tonic-gate 			uint16_t ls_type;
158*7c478bd9Sstevel@tonic-gate 			uint32_t ls_stateid;
159*7c478bd9Sstevel@tonic-gate 			uint32_t ls_router;
160*7c478bd9Sstevel@tonic-gate 		} un_lsr[1];				/* may repeat	*/
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate 		/* Link State Update */
163*7c478bd9Sstevel@tonic-gate 		struct {
164*7c478bd9Sstevel@tonic-gate 			uint32_t lsu_count;
165*7c478bd9Sstevel@tonic-gate 			struct lsa6 lsu_lsa[1]; 	/* may repeat	*/
166*7c478bd9Sstevel@tonic-gate 		} un_lsu;
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate 		/* Link State Acknowledgement */
169*7c478bd9Sstevel@tonic-gate 		struct {
170*7c478bd9Sstevel@tonic-gate 			struct lsa6_hdr lsa_lshdr[1]; 	/* may repeat	*/
171*7c478bd9Sstevel@tonic-gate 		} un_lsa;
172*7c478bd9Sstevel@tonic-gate 	} ospf6_un;
173*7c478bd9Sstevel@tonic-gate };
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate #define	ospf6_hello	ospf6_un.un_hello
176*7c478bd9Sstevel@tonic-gate #define	ospf6_db	ospf6_un.un_db
177*7c478bd9Sstevel@tonic-gate #define	ospf6_lsr	ospf6_un.un_lsr
178*7c478bd9Sstevel@tonic-gate #define	ospf6_lsu	ospf6_un.un_lsu
179*7c478bd9Sstevel@tonic-gate #define	ospf6_lsa	ospf6_un.un_lsa
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
182*7c478bd9Sstevel@tonic-gate }
183*7c478bd9Sstevel@tonic-gate #endif
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate #endif /* _OSPF6_H */
186