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