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