Add trunc and truncf.
[dragonfly.git] / contrib / tcpdump-3.9 / ospf.h
1 /* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.16.2.1 2005/08/23 11:16:30 hannes Exp $ (LBL) */
2 /*
3  * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
4  *      The Regents of the University of California.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that: (1) source code distributions
8  * retain the above copyright notice and this paragraph in its entirety, (2)
9  * distributions including binary code include the above copyright notice and
10  * this paragraph in its entirety in the documentation or other materials
11  * provided with the distribution, and (3) all advertising materials mentioning
12  * features or use of this software display the following acknowledgement:
13  * ``This product includes software developed by the University of California,
14  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15  * the University nor the names of its contributors may be used to endorse
16  * or promote products derived from this software without specific prior
17  * written permission.
18  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu)
23  */
24 #define OSPF_TYPE_UMD           0       /* UMd's special monitoring packets */
25 #define OSPF_TYPE_HELLO         1       /* Hello */
26 #define OSPF_TYPE_DD            2       /* Database Description */
27 #define OSPF_TYPE_LS_REQ        3       /* Link State Request */
28 #define OSPF_TYPE_LS_UPDATE     4       /* Link State Update */
29 #define OSPF_TYPE_LS_ACK        5       /* Link State Ack */
30
31 /* Options field
32  *
33  * +------------------------------------+
34  * | * | O | DC | EA | N/P | MC | E | T |
35  * +------------------------------------+
36  *
37  */
38                 
39 #define OSPF_OPTION_T   0x01    /* T bit: TOS support   */
40 #define OSPF_OPTION_E   0x02    /* E bit: External routes advertised    */
41 #define OSPF_OPTION_MC  0x04    /* MC bit: Multicast capable */
42 #define OSPF_OPTION_NP  0x08    /* N/P bit: NSSA capable */
43 #define OSPF_OPTION_EA  0x10    /* EA bit: External Attribute capable */
44 #define OSPF_OPTION_DC  0x20    /* DC bit: Demand circuit capable */
45 #define OSPF_OPTION_O   0x40    /* O bit: Opaque LSA capable */
46 #define OSPF_OPTION_DN  0x80    /* DN bit: Up/Down Bit capable - draft-ietf-ospf-2547-dnbit-04 */
47
48 /* ospf_authtype        */
49 #define OSPF_AUTH_NONE          0       /* No auth-data */
50 #define OSPF_AUTH_SIMPLE        1       /* Simple password */
51 #define OSPF_AUTH_MD5           2       /* MD5 authentication */
52 #define OSPF_AUTH_MD5_LEN       16      /* length of MD5 authentication */
53
54 /* db_flags     */
55 #define OSPF_DB_INIT            0x04        /*  */
56 #define OSPF_DB_MORE            0x02
57 #define OSPF_DB_MASTER          0x01
58
59 /* ls_type      */
60 #define LS_TYPE_ROUTER          1   /* router link */
61 #define LS_TYPE_NETWORK         2   /* network link */
62 #define LS_TYPE_SUM_IP          3   /* summary link */
63 #define LS_TYPE_SUM_ABR         4   /* summary area link */
64 #define LS_TYPE_ASE             5   /* ASE  */
65 #define LS_TYPE_GROUP           6   /* Group membership (multicast */
66                                     /* extensions 23 July 1991) */
67 #define LS_TYPE_NSSA            7   /* rfc3101 - Not so Stubby Areas */
68 #define LS_TYPE_OPAQUE_LL       9   /* rfc2370 - Opaque Link Local */
69 #define LS_TYPE_OPAQUE_AL      10   /* rfc2370 - Opaque Link Local */
70 #define LS_TYPE_OPAQUE_DW      11   /* rfc2370 - Opaque Domain Wide */
71
72 #define LS_OPAQUE_TYPE_TE       1   /* rfc3630 */
73 #define LS_OPAQUE_TYPE_GRACE    3   /* rfc3623 */
74 #define LS_OPAQUE_TYPE_RI       4   /* draft-ietf-ospf-cap-03 */
75
76 #define LS_OPAQUE_TE_TLV_ROUTER 1   /* rfc3630 */
77 #define LS_OPAQUE_TE_TLV_LINK   2   /* rfc3630 */
78
79 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE             1 /* rfc3630 */
80 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID               2 /* rfc3630 */
81 #define LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP              3 /* rfc3630 */
82 #define LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP             4 /* rfc3630 */
83 #define LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC             5 /* rfc3630 */
84 #define LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW                6 /* rfc3630 */
85 #define LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW            7 /* rfc3630 */
86 #define LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW              8 /* rfc3630 */
87 #define LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP           9 /* rfc3630 */
88 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID 11 /* draft-ietf-ccamp-ospf-gmpls-extensions */
89 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE 14 /* draft-ietf-ccamp-ospf-gmpls-extensions */
90 #define LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR    15 /* draft-ietf-ccamp-ospf-gmpls-extensions */
91 #define LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP    16 /* draft-ietf-ccamp-ospf-gmpls-extensions */
92 #define LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS       17 /* rfc4124 */
93
94 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP        1  /* rfc3630 */
95 #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA         2  /* rfc3630 */
96
97 #define LS_OPAQUE_GRACE_TLV_PERIOD       1 /* rfc3623 */
98 #define LS_OPAQUE_GRACE_TLV_REASON       2 /* rfc3623 */
99 #define LS_OPAQUE_GRACE_TLV_INT_ADDRESS  3 /* rfc3623 */
100
101 #define LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN     0 /* rfc3623 */
102 #define LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART  1 /* rfc3623 */
103 #define LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE  2 /* rfc3623 */
104 #define LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH   3 /* rfc3623 */
105
106 #define LS_OPAQUE_RI_TLV_CAP             1 /* draft-ietf-ospf-cap-03 */
107
108 /*************************************************
109  *
110  * is the above a bug in the documentation?
111  *
112  *************************************************/
113
114
115 /* rla_link.link_type   */
116 #define RLA_TYPE_ROUTER         1   /* point-to-point to another router */
117 #define RLA_TYPE_TRANSIT        2   /* connection to transit network    */
118 #define RLA_TYPE_STUB           3   /* connection to stub network       */
119 #define RLA_TYPE_VIRTUAL        4   /* virtual link                     */
120
121 /* rla_flags    */
122 #define RLA_FLAG_B      0x01
123 #define RLA_FLAG_E      0x02
124 #define RLA_FLAG_W1     0x04
125 #define RLA_FLAG_W2     0x08
126
127 /* sla_tosmetric breakdown      */
128 #define SLA_MASK_TOS            0x7f000000
129 #define SLA_MASK_METRIC         0x00ffffff
130 #define SLA_SHIFT_TOS           24
131
132 /* asla_tosmetric breakdown     */
133 #define ASLA_FLAG_EXTERNAL      0x80000000
134 #define ASLA_MASK_TOS           0x7f000000
135 #define ASLA_SHIFT_TOS          24
136 #define ASLA_MASK_METRIC        0x00ffffff
137
138 /* multicast vertex type */
139 #define MCLA_VERTEX_ROUTER      1
140 #define MCLA_VERTEX_NETWORK     2
141
142 /* link state advertisement header */
143 struct lsa_hdr {
144     u_int16_t ls_age;
145     u_int8_t ls_options;
146     u_int8_t ls_type;
147     union {
148         struct in_addr lsa_id;
149         struct { /* opaque LSAs change the LSA-ID field */
150             u_int8_t opaque_type;
151             u_int8_t opaque_id[3];
152         } opaque_field;
153     } un_lsa_id;
154     struct in_addr ls_router;
155     u_int32_t ls_seq;
156     u_int16_t ls_chksum;
157     u_int16_t ls_length;
158 };
159
160 /* link state advertisement */
161 struct lsa {
162     struct lsa_hdr ls_hdr;
163
164     /* Link state types */
165     union {
166         /* Router links advertisements */
167         struct {
168             u_int8_t rla_flags;
169             u_int8_t rla_zero[1];
170             u_int16_t rla_count;
171             struct rlalink {
172                 struct in_addr link_id;
173                 struct in_addr link_data;
174                 u_int8_t link_type;
175                 u_int8_t link_toscount;
176                 u_int16_t link_tos0metric;
177             } rla_link[1];              /* may repeat   */
178         } un_rla;
179
180         /* Network links advertisements */
181         struct {
182             struct in_addr nla_mask;
183             struct in_addr nla_router[1];       /* may repeat   */
184         } un_nla;
185
186         /* Summary links advertisements */
187         struct {
188             struct in_addr sla_mask;
189             u_int32_t sla_tosmetric[1]; /* may repeat   */
190         } un_sla;
191
192         /* AS external links advertisements */
193         struct {
194             struct in_addr asla_mask;
195             struct aslametric {
196                 u_int32_t asla_tosmetric;
197                 struct in_addr asla_forward;
198                 struct in_addr asla_tag;
199             } asla_metric[1];           /* may repeat   */
200         } un_asla;
201
202         /* Multicast group membership */
203         struct mcla {
204             u_int32_t mcla_vtype;
205             struct in_addr mcla_vid;
206         } un_mcla[1];
207
208         /* Opaque TE LSA */
209         struct {
210             u_int16_t type;
211             u_int16_t length;
212             u_int8_t data[1]; /* may repeat   */
213         } un_te_lsa_tlv;
214
215         /* Opaque Grace LSA */
216         struct {
217             u_int16_t type;
218             u_int16_t length;
219             u_int8_t data[1]; /* may repeat   */
220         } un_grace_tlv;
221
222         /* Opaque Router information LSA */
223         struct {
224             u_int16_t type;
225             u_int16_t length;
226             u_int8_t data[1]; /* may repeat   */
227         } un_ri_tlv;
228
229         /* Unknown LSA */
230         struct unknown {
231             u_int8_t data[1]; /* may repeat   */
232         } un_unknown[1];
233
234     } lsa_un;
235 };
236
237
238 /*
239  * TOS metric struct (will be 0 or more in router links update)
240  */
241 struct tos_metric {
242     u_int8_t tos_type;
243     u_int8_t tos_zero;
244     u_int16_t tos_metric;
245 };
246
247 #define OSPF_AUTH_SIZE  8
248
249 /*
250  * the main header
251  */
252 struct ospfhdr {
253     u_int8_t ospf_version;
254     u_int8_t ospf_type;
255     u_int16_t ospf_len;
256     struct in_addr ospf_routerid;
257     struct in_addr ospf_areaid;
258     u_int16_t ospf_chksum;
259     u_int16_t ospf_authtype;
260     u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
261     union {
262
263         /* Hello packet */
264         struct {
265             struct in_addr hello_mask;
266             u_int16_t hello_helloint;
267             u_int8_t hello_options;
268             u_int8_t hello_priority;
269             u_int32_t hello_deadint;
270             struct in_addr hello_dr;
271             struct in_addr hello_bdr;
272             struct in_addr hello_neighbor[1]; /* may repeat     */
273         } un_hello;
274
275         /* Database Description packet */
276         struct {
277             u_int8_t db_zero[2];
278             u_int8_t db_options;
279             u_int8_t db_flags;
280             u_int32_t db_seq;
281             struct lsa_hdr db_lshdr[1]; /* may repeat   */
282         } un_db;
283
284         /* Link State Request */
285         struct lsr {
286             u_int8_t ls_type[4];
287             union {
288                 struct in_addr ls_stateid;
289                 struct { /* opaque LSAs change the LSA-ID field */
290                     u_int8_t opaque_type;
291                     u_int8_t opaque_id[3];
292                 } opaque_field;
293             } un_ls_stateid;
294             struct in_addr ls_router;
295         } un_lsr[1];            /* may repeat   */
296
297         /* Link State Update */
298         struct {
299             u_int32_t lsu_count;
300             struct lsa lsu_lsa[1]; /* may repeat        */
301         } un_lsu;
302
303         /* Link State Acknowledgement */
304         struct {
305             struct lsa_hdr lsa_lshdr[1]; /* may repeat  */
306         } un_lsa ;
307     } ospf_un ;
308 };
309
310 #define ospf_hello      ospf_un.un_hello
311 #define ospf_db         ospf_un.un_db
312 #define ospf_lsr        ospf_un.un_lsr
313 #define ospf_lsu        ospf_un.un_lsu
314 #define ospf_lsa        ospf_un.un_lsa
315