]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/tcpdump/ospf.h
include cdefs.h so as to unbreak the libc build
[FreeBSD/FreeBSD.git] / contrib / tcpdump / ospf.h
1 /* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.3 2000/12/17 23:07:50 guy 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_DB    2       /* Database Description */
27 #define OSPF_TYPE_LSR   3       /* Link State Request */
28 #define OSPF_TYPE_LSU   4       /* Link State Update */
29 #define OSPF_TYPE_LSA   5       /* Link State Ack */
30 #define OSPF_TYPE_MAX   6
31
32 /* Options *_options    */
33 #define OSPF_OPTION_T   0x01    /* T bit: TOS support   */
34 #define OSPF_OPTION_E   0x02    /* E bit: External routes advertised    */
35 #define OSPF_OPTION_MC  0x04    /* MC bit: Multicast capable */
36
37 /* ospf_authtype        */
38 #define OSPF_AUTH_NONE          0       /* No auth-data */
39 #define OSPF_AUTH_SIMPLE        1       /* Simple password */
40 #define OSPF_AUTH_MD5           2       /* MD5 authentication */
41 #define     OSPF_AUTH_MD5_LEN   16      /* length of MD5 authentication */
42
43
44 /* db_flags     */
45 #define OSPF_DB_INIT            0x04        /*  */
46 #define OSPF_DB_MORE            0x02
47 #define OSPF_DB_MASTER          0x01
48
49 /* ls_type      */
50 #define LS_TYPE_ROUTER          1   /* router link */
51 #define LS_TYPE_NETWORK         2   /* network link */
52 #define LS_TYPE_SUM_IP          3   /* summary link */
53 #define LS_TYPE_SUM_ABR         4   /* summary area link */
54 #define LS_TYPE_ASE             5   /* ASE  */
55 #define LS_TYPE_GROUP           6   /* Group membership (multicast */
56                                     /* extensions 23 July 1991) */
57 #define LS_TYPE_MAX             7
58
59 /*************************************************
60  *
61  * is the above a bug in the documentation?
62  *
63  *************************************************/
64
65
66 /* rla_link.link_type   */
67 #define RLA_TYPE_ROUTER         1   /* point-to-point to another router */
68 #define RLA_TYPE_TRANSIT        2   /* connection to transit network    */
69 #define RLA_TYPE_STUB           3   /* connection to stub network       */
70 #define RLA_TYPE_VIRTUAL        4   /* virtual link                     */
71
72 /* rla_flags    */
73 #define RLA_FLAG_B      0x01
74 #define RLA_FLAG_E      0x02
75 #define RLA_FLAG_W1     0x04
76 #define RLA_FLAG_W2     0x08
77
78 /* sla_tosmetric breakdown      */
79 #define SLA_MASK_TOS            0x7f000000
80 #define SLA_MASK_METRIC         0x00ffffff
81 #define SLA_SHIFT_TOS           24
82
83 /* asla_tosmetric breakdown     */
84 #define ASLA_FLAG_EXTERNAL      0x80000000
85 #define ASLA_MASK_TOS           0x7f000000
86 #define ASLA_SHIFT_TOS          24
87 #define ASLA_MASK_METRIC        0x00ffffff
88
89 /* multicast vertex type */
90 #define MCLA_VERTEX_ROUTER      1
91 #define MCLA_VERTEX_NETWORK     2
92
93 /* link state advertisement header */
94 struct lsa_hdr {
95     u_int16_t ls_age;
96     u_int8_t ls_options;
97     u_int8_t ls_type;
98     struct in_addr ls_stateid;
99     struct in_addr ls_router;
100     u_int32_t ls_seq;
101     u_int16_t ls_chksum;
102     u_int16_t ls_length;
103 } ;
104
105 /* link state advertisement */
106 struct lsa {
107     struct lsa_hdr ls_hdr;
108
109     /* Link state types */
110     union {
111         /* Router links advertisements */
112         struct {
113             u_int8_t rla_flags;
114             u_int8_t rla_zero[1];
115             u_int16_t rla_count;
116             struct rlalink {
117                 struct in_addr link_id;
118                 struct in_addr link_data;
119                 u_int8_t link_type;
120                 u_int8_t link_toscount;
121                 u_int16_t link_tos0metric;
122             } rla_link[1];              /* may repeat   */
123         } un_rla;
124
125         /* Network links advertisements */
126         struct {
127             struct in_addr nla_mask;
128             struct in_addr nla_router[1];       /* may repeat   */
129         } un_nla;
130
131         /* Summary links advertisements */
132         struct {
133             struct in_addr sla_mask;
134             u_int32_t sla_tosmetric[1]; /* may repeat   */
135         } un_sla;
136
137         /* AS external links advertisements */
138         struct {
139             struct in_addr asla_mask;
140             struct aslametric {
141                 u_int32_t asla_tosmetric;
142                 struct in_addr asla_forward;
143                 struct in_addr asla_tag;
144             } asla_metric[1];           /* may repeat   */
145         } un_asla;
146
147         /* Multicast group membership */
148         struct mcla {
149             u_int32_t mcla_vtype;
150             struct in_addr mcla_vid;
151         } un_mcla[1];
152     } lsa_un;
153 } ;
154
155
156 /*
157  * TOS metric struct (will be 0 or more in router links update)
158  */
159 struct tos_metric {
160     u_int8_t tos_type;
161     u_int8_t tos_zero;
162     u_int16_t tos_metric;
163 } ;
164
165 #define OSPF_AUTH_SIZE  8
166
167 /*
168  * the main header
169  */
170 struct ospfhdr {
171     u_int8_t ospf_version;
172     u_int8_t ospf_type;
173     u_int16_t ospf_len;
174     struct in_addr ospf_routerid;
175     struct in_addr ospf_areaid;
176     u_int16_t ospf_chksum;
177     u_int16_t ospf_authtype;
178     u_int8_t ospf_authdata[OSPF_AUTH_SIZE];
179     union {
180
181         /* Hello packet */
182         struct {
183             struct in_addr hello_mask;
184             u_int16_t hello_helloint;
185             u_int8_t hello_options;
186             u_int8_t hello_priority;
187             u_int32_t hello_deadint;
188             struct in_addr hello_dr;
189             struct in_addr hello_bdr;
190             struct in_addr hello_neighbor[1]; /* may repeat     */
191         } un_hello;
192
193         /* Database Description packet */
194         struct {
195             u_int8_t db_zero[2];
196             u_int8_t db_options;
197             u_int8_t db_flags;
198             u_int32_t db_seq;
199             struct lsa_hdr db_lshdr[1]; /* may repeat   */
200         } un_db;
201
202         /* Link State Request */
203         struct lsr {
204             u_int32_t ls_type;
205             struct in_addr ls_stateid;
206             struct in_addr ls_router;
207         } un_lsr[1];            /* may repeat   */
208
209         /* Link State Update */
210         struct {
211             u_int32_t lsu_count;
212             struct lsa lsu_lsa[1]; /* may repeat        */
213         } un_lsu;
214
215         /* Link State Acknowledgement */
216         struct {
217             struct lsa_hdr lsa_lshdr[1]; /* may repeat  */
218         } un_lsa ;
219     } ospf_un ;
220 } ;
221
222 #define ospf_hello      ospf_un.un_hello
223 #define ospf_db         ospf_un.un_db
224 #define ospf_lsr        ospf_un.un_lsr
225 #define ospf_lsu        ospf_un.un_lsu
226 #define ospf_lsa        ospf_un.un_lsa
227