ospf.h revision 267654
1228753Smm/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.23 2007-10-08 07:53:21 hannes Exp $ (LBL) */ 2228753Smm/* 3228753Smm * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 4228753Smm * The Regents of the University of California. All rights reserved. 5228753Smm * 6228753Smm * Redistribution and use in source and binary forms, with or without 7228753Smm * modification, are permitted provided that: (1) source code distributions 8228753Smm * retain the above copyright notice and this paragraph in its entirety, (2) 9228753Smm * distributions including binary code include the above copyright notice and 10228753Smm * this paragraph in its entirety in the documentation or other materials 11228753Smm * provided with the distribution, and (3) all advertising materials mentioning 12228753Smm * features or use of this software display the following acknowledgement: 13228753Smm * ``This product includes software developed by the University of California, 14228753Smm * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15228753Smm * the University nor the names of its contributors may be used to endorse 16228753Smm * or promote products derived from this software without specific prior 17228753Smm * written permission. 18228753Smm * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19228753Smm * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20228753Smm * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21228753Smm * 22228753Smm * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) 23228753Smm */ 24228753Smm#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */ 25228753Smm#define OSPF_TYPE_HELLO 1 /* Hello */ 26228763Smm#define OSPF_TYPE_DD 2 /* Database Description */ 27228753Smm#define OSPF_TYPE_LS_REQ 3 /* Link State Request */ 28228753Smm#define OSPF_TYPE_LS_UPDATE 4 /* Link State Update */ 29228753Smm#define OSPF_TYPE_LS_ACK 5 /* Link State Ack */ 30228753Smm 31228753Smm/* Options field 32228753Smm * 33228753Smm * +------------------------------------+ 34228753Smm * | DN | O | DC | L | N/P | MC | E | T | 35228753Smm * +------------------------------------+ 36228753Smm * 37228753Smm */ 38228753Smm 39228753Smm#define OSPF_OPTION_T 0x01 /* T bit: TOS support */ 40228753Smm#define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */ 41228753Smm#define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */ 42228753Smm#define OSPF_OPTION_NP 0x08 /* N/P bit: NSSA capable */ 43228753Smm#define OSPF_OPTION_EA 0x10 /* EA bit: External Attribute capable */ 44228753Smm#define OSPF_OPTION_L 0x10 /* L bit: Packet contains LLS data block */ 45228753Smm#define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuit capable */ 46228753Smm#define OSPF_OPTION_O 0x40 /* O bit: Opaque LSA capable */ 47228753Smm#define OSPF_OPTION_DN 0x80 /* DN bit: Up/Down Bit capable - draft-ietf-ospf-2547-dnbit-04 */ 48228753Smm 49228753Smm/* ospf_authtype */ 50228753Smm#define OSPF_AUTH_NONE 0 /* No auth-data */ 51228753Smm#define OSPF_AUTH_SIMPLE 1 /* Simple password */ 52228753Smm#define OSPF_AUTH_SIMPLE_LEN 8 /* max length of simple authentication */ 53228753Smm#define OSPF_AUTH_MD5 2 /* MD5 authentication */ 54228753Smm#define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */ 55228753Smm 56228753Smm/* db_flags */ 57228753Smm#define OSPF_DB_INIT 0x04 58228753Smm#define OSPF_DB_MORE 0x02 59228753Smm#define OSPF_DB_MASTER 0x01 60228753Smm#define OSPF_DB_RESYNC 0x08 /* RFC4811 */ 61228753Smm 62228753Smm/* ls_type */ 63228753Smm#define LS_TYPE_ROUTER 1 /* router link */ 64228753Smm#define LS_TYPE_NETWORK 2 /* network link */ 65228753Smm#define LS_TYPE_SUM_IP 3 /* summary link */ 66228753Smm#define LS_TYPE_SUM_ABR 4 /* summary area link */ 67228753Smm#define LS_TYPE_ASE 5 /* ASE */ 68228753Smm#define LS_TYPE_GROUP 6 /* Group membership (multicast */ 69228753Smm /* extensions 23 July 1991) */ 70232153Smm#define LS_TYPE_NSSA 7 /* rfc3101 - Not so Stubby Areas */ 71228753Smm#define LS_TYPE_OPAQUE_LL 9 /* rfc2370 - Opaque Link Local */ 72228753Smm#define LS_TYPE_OPAQUE_AL 10 /* rfc2370 - Opaque Link Local */ 73228753Smm#define LS_TYPE_OPAQUE_DW 11 /* rfc2370 - Opaque Domain Wide */ 74228753Smm 75228753Smm#define LS_OPAQUE_TYPE_TE 1 /* rfc3630 */ 76228753Smm#define LS_OPAQUE_TYPE_GRACE 3 /* rfc3623 */ 77228753Smm#define LS_OPAQUE_TYPE_RI 4 /* draft-ietf-ospf-cap-03 */ 78228753Smm 79228753Smm#define LS_OPAQUE_TE_TLV_ROUTER 1 /* rfc3630 */ 80228753Smm#define LS_OPAQUE_TE_TLV_LINK 2 /* rfc3630 */ 81228753Smm 82232153Smm#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE 1 /* rfc3630 */ 83228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_ID 2 /* rfc3630 */ 84228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_LOCAL_IP 3 /* rfc3630 */ 85228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_REMOTE_IP 4 /* rfc3630 */ 86228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_TE_METRIC 5 /* rfc3630 */ 87228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_MAX_BW 6 /* rfc3630 */ 88228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_MAX_RES_BW 7 /* rfc3630 */ 89228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_UNRES_BW 8 /* rfc3630 */ 90228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_ADMIN_GROUP 9 /* rfc3630 */ 91228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_LOCAL_REMOTE_ID 11 /* rfc4203 */ 92228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_PROTECTION_TYPE 14 /* rfc4203 */ 93228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_INTF_SW_CAP_DESCR 15 /* rfc4203 */ 94228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_SHARED_RISK_GROUP 16 /* rfc4203 */ 95228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_BW_CONSTRAINTS 17 /* rfc4124 */ 96228753Smm 97228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP 1 /* rfc3630 */ 98228753Smm#define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA 2 /* rfc3630 */ 99228753Smm 100228753Smm#define LS_OPAQUE_GRACE_TLV_PERIOD 1 /* rfc3623 */ 101228753Smm#define LS_OPAQUE_GRACE_TLV_REASON 2 /* rfc3623 */ 102228753Smm#define LS_OPAQUE_GRACE_TLV_INT_ADDRESS 3 /* rfc3623 */ 103228753Smm 104228753Smm#define LS_OPAQUE_GRACE_TLV_REASON_UNKNOWN 0 /* rfc3623 */ 105232153Smm#define LS_OPAQUE_GRACE_TLV_REASON_SW_RESTART 1 /* rfc3623 */ 106228753Smm#define LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE 2 /* rfc3623 */ 107228753Smm#define LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH 3 /* rfc3623 */ 108228753Smm 109#define LS_OPAQUE_RI_TLV_CAP 1 /* draft-ietf-ospf-cap-03 */ 110 111 112/* rla_link.link_type */ 113#define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ 114#define RLA_TYPE_TRANSIT 2 /* connection to transit network */ 115#define RLA_TYPE_STUB 3 /* connection to stub network */ 116#define RLA_TYPE_VIRTUAL 4 /* virtual link */ 117 118/* rla_flags */ 119#define RLA_FLAG_B 0x01 120#define RLA_FLAG_E 0x02 121#define RLA_FLAG_W1 0x04 122#define RLA_FLAG_W2 0x08 123 124/* sla_tosmetric breakdown */ 125#define SLA_MASK_TOS 0x7f000000 126#define SLA_MASK_METRIC 0x00ffffff 127#define SLA_SHIFT_TOS 24 128 129/* asla_tosmetric breakdown */ 130#define ASLA_FLAG_EXTERNAL 0x80000000 131#define ASLA_MASK_TOS 0x7f000000 132#define ASLA_SHIFT_TOS 24 133#define ASLA_MASK_METRIC 0x00ffffff 134 135/* multicast vertex type */ 136#define MCLA_VERTEX_ROUTER 1 137#define MCLA_VERTEX_NETWORK 2 138 139/* Link-Local-Signaling */ 140#define OSPF_LLS_EO 1 /* RFC4811, RFC4812 */ 141#define OSPF_LLS_MD5 2 /* RFC4813 */ 142 143#define OSPF_LLS_EO_LR 0x00000001 /* RFC4811 */ 144#define OSPF_LLS_EO_RS 0x00000002 /* RFC4812 */ 145 146/* 147 * TOS metric struct (will be 0 or more in router links update) 148 */ 149struct tos_metric { 150 u_int8_t tos_type; 151 u_int8_t reserved; 152 u_int8_t tos_metric[2]; 153}; 154struct tos_link { 155 u_int8_t link_type; 156 u_int8_t link_tos_count; 157 u_int8_t tos_metric[2]; 158}; 159union un_tos { 160 struct tos_link link; 161 struct tos_metric metrics; 162}; 163 164/* link state advertisement header */ 165struct lsa_hdr { 166 u_int16_t ls_age; 167 u_int8_t ls_options; 168 u_int8_t ls_type; 169 union { 170 struct in_addr lsa_id; 171 struct { /* opaque LSAs change the LSA-ID field */ 172 u_int8_t opaque_type; 173 u_int8_t opaque_id[3]; 174 } opaque_field; 175 } un_lsa_id; 176 struct in_addr ls_router; 177 u_int32_t ls_seq; 178 u_int16_t ls_chksum; 179 u_int16_t ls_length; 180}; 181 182/* link state advertisement */ 183struct lsa { 184 struct lsa_hdr ls_hdr; 185 186 /* Link state types */ 187 union { 188 /* Router links advertisements */ 189 struct { 190 u_int8_t rla_flags; 191 u_int8_t rla_zero[1]; 192 u_int16_t rla_count; 193 struct rlalink { 194 struct in_addr link_id; 195 struct in_addr link_data; 196 union un_tos un_tos; 197 } rla_link[1]; /* may repeat */ 198 } un_rla; 199 200 /* Network links advertisements */ 201 struct { 202 struct in_addr nla_mask; 203 struct in_addr nla_router[1]; /* may repeat */ 204 } un_nla; 205 206 /* Summary links advertisements */ 207 struct { 208 struct in_addr sla_mask; 209 u_int32_t sla_tosmetric[1]; /* may repeat */ 210 } un_sla; 211 212 /* AS external links advertisements */ 213 struct { 214 struct in_addr asla_mask; 215 struct aslametric { 216 u_int32_t asla_tosmetric; 217 struct in_addr asla_forward; 218 struct in_addr asla_tag; 219 } asla_metric[1]; /* may repeat */ 220 } un_asla; 221 222 /* Multicast group membership */ 223 struct mcla { 224 u_int32_t mcla_vtype; 225 struct in_addr mcla_vid; 226 } un_mcla[1]; 227 228 /* Opaque TE LSA */ 229 struct { 230 u_int16_t type; 231 u_int16_t length; 232 u_int8_t data[1]; /* may repeat */ 233 } un_te_lsa_tlv; 234 235 /* Opaque Grace LSA */ 236 struct { 237 u_int16_t type; 238 u_int16_t length; 239 u_int8_t data[1]; /* may repeat */ 240 } un_grace_tlv; 241 242 /* Opaque Router information LSA */ 243 struct { 244 u_int16_t type; 245 u_int16_t length; 246 u_int8_t data[1]; /* may repeat */ 247 } un_ri_tlv; 248 249 /* Unknown LSA */ 250 struct unknown { 251 u_int8_t data[1]; /* may repeat */ 252 } un_unknown[1]; 253 254 } lsa_un; 255}; 256 257#define OSPF_AUTH_SIZE 8 258 259/* 260 * the main header 261 */ 262struct ospfhdr { 263 u_int8_t ospf_version; 264 u_int8_t ospf_type; 265 u_int16_t ospf_len; 266 struct in_addr ospf_routerid; 267 struct in_addr ospf_areaid; 268 u_int16_t ospf_chksum; 269 u_int16_t ospf_authtype; 270 u_int8_t ospf_authdata[OSPF_AUTH_SIZE]; 271 union { 272 273 /* Hello packet */ 274 struct { 275 struct in_addr hello_mask; 276 u_int16_t hello_helloint; 277 u_int8_t hello_options; 278 u_int8_t hello_priority; 279 u_int32_t hello_deadint; 280 struct in_addr hello_dr; 281 struct in_addr hello_bdr; 282 struct in_addr hello_neighbor[1]; /* may repeat */ 283 } un_hello; 284 285 /* Database Description packet */ 286 struct { 287 u_int16_t db_ifmtu; 288 u_int8_t db_options; 289 u_int8_t db_flags; 290 u_int32_t db_seq; 291 struct lsa_hdr db_lshdr[1]; /* may repeat */ 292 } un_db; 293 294 /* Link State Request */ 295 struct lsr { 296 u_int8_t ls_type[4]; 297 union { 298 struct in_addr ls_stateid; 299 struct { /* opaque LSAs change the LSA-ID field */ 300 u_int8_t opaque_type; 301 u_int8_t opaque_id[3]; 302 } opaque_field; 303 } un_ls_stateid; 304 struct in_addr ls_router; 305 } un_lsr[1]; /* may repeat */ 306 307 /* Link State Update */ 308 struct { 309 u_int32_t lsu_count; 310 struct lsa lsu_lsa[1]; /* may repeat */ 311 } un_lsu; 312 313 /* Link State Acknowledgement */ 314 struct { 315 struct lsa_hdr lsa_lshdr[1]; /* may repeat */ 316 } un_lsa ; 317 } ospf_un ; 318}; 319 320#define ospf_hello ospf_un.un_hello 321#define ospf_db ospf_un.un_db 322#define ospf_lsr ospf_un.un_lsr 323#define ospf_lsu ospf_un.un_lsu 324#define ospf_lsa ospf_un.un_lsa 325 326/* Functions shared by ospf and ospf6 */ 327extern int ospf_print_te_lsa(const u_int8_t *, u_int); 328extern int ospf_print_grace_lsa(const u_int8_t *, u_int); 329