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