X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/c202a9fa8922a7b5f7677232d6a232150e6686d0..HEAD:/ospf.h diff --git a/ospf.h b/ospf.h index 7d9bef2f..9b274faf 100644 --- a/ospf.h +++ b/ospf.h @@ -1,4 +1,3 @@ -/* @(#) $Header: /tcpdump/master/tcpdump/ospf.h,v 1.20 2007-09-23 23:01:33 guy Exp $ (LBL) */ /* * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997 * The Regents of the University of California. All rights reserved. @@ -21,7 +20,6 @@ * * OSPF support contributed by Jeffrey Honig (jch@mitchell.cit.cornell.edu) */ -#define OSPF_TYPE_UMD 0 /* UMd's special monitoring packets */ #define OSPF_TYPE_HELLO 1 /* Hello */ #define OSPF_TYPE_DD 2 /* Database Description */ #define OSPF_TYPE_LS_REQ 3 /* Link State Request */ @@ -29,22 +27,17 @@ #define OSPF_TYPE_LS_ACK 5 /* Link State Ack */ /* Options field - * - * +-------------------------------------+ - * | DN | O | DC | EA | N/P | MC | E | T | - * +-------------------------------------+ * * +------------------------------------+ * | DN | O | DC | L | N/P | MC | E | T | * +------------------------------------+ * */ - -#define OSPF_OPTION_T 0x01 /* T bit: TOS support */ -#define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */ + +#define OSPF_OPTION_MT 0x01 /* MT bit: multi-topology */ +#define OSPF_OPTION_E 0x02 /* E bit: External routes advertised */ #define OSPF_OPTION_MC 0x04 /* MC bit: Multicast capable */ #define OSPF_OPTION_NP 0x08 /* N/P bit: NSSA capable */ -#define OSPF_OPTION_EA 0x10 /* EA bit: External Attribute capable */ #define OSPF_OPTION_L 0x10 /* L bit: Packet contains LLS data block */ #define OSPF_OPTION_DC 0x20 /* DC bit: Demand circuit capable */ #define OSPF_OPTION_O 0x40 /* O bit: Opaque LSA capable */ @@ -58,10 +51,10 @@ #define OSPF_AUTH_MD5_LEN 16 /* length of MD5 authentication */ /* db_flags */ -#define OSPF_DB_INIT 0x04 /* */ +#define OSPF_DB_INIT 0x04 #define OSPF_DB_MORE 0x02 -#define OSPF_DB_MASTER 0x01 -#define OSPF_DB_RESYNC 0x08 /* RFC4811 */ +#define OSPF_DB_MASTER 0x01 +#define OSPF_DB_RESYNC 0x08 /* RFC4811 */ /* ls_type */ #define LS_TYPE_ROUTER 1 /* router link */ @@ -78,7 +71,9 @@ #define LS_OPAQUE_TYPE_TE 1 /* rfc3630 */ #define LS_OPAQUE_TYPE_GRACE 3 /* rfc3623 */ -#define LS_OPAQUE_TYPE_RI 4 /* draft-ietf-ospf-cap-03 */ +#define LS_OPAQUE_TYPE_RI 4 /* rfc7770 */ +#define LS_OPAQUE_TYPE_EP 7 /* rfc7684 */ +#define LS_OPAQUE_TYPE_EL 8 /* rfc7684 */ #define LS_OPAQUE_TE_TLV_ROUTER 1 /* rfc3630 */ #define LS_OPAQUE_TE_TLV_LINK 2 /* rfc3630 */ @@ -101,6 +96,12 @@ #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_PTP 1 /* rfc3630 */ #define LS_OPAQUE_TE_LINK_SUBTLV_LINK_TYPE_MA 2 /* rfc3630 */ +#define LS_OPAQUE_RI_SUBTLV_SID_LABEL 1 /* rfc8665 */ + +#define LS_OPAQUE_EP_EXTD_PREFIX_TLV 1 /* rfc7684 */ +#define LS_OPAQUE_EP_EXTD_PREFIX_RANGE_TLV 2 /* rfc8665 */ +#define LS_OPAQUE_EP_SUBTLV_PREFIX_SID 2 /* rfc8665 */ + #define LS_OPAQUE_GRACE_TLV_PERIOD 1 /* rfc3623 */ #define LS_OPAQUE_GRACE_TLV_REASON 2 /* rfc3623 */ #define LS_OPAQUE_GRACE_TLV_INT_ADDRESS 3 /* rfc3623 */ @@ -110,8 +111,12 @@ #define LS_OPAQUE_GRACE_TLV_REASON_SW_UPGRADE 2 /* rfc3623 */ #define LS_OPAQUE_GRACE_TLV_REASON_CP_SWITCH 3 /* rfc3623 */ -#define LS_OPAQUE_RI_TLV_CAP 1 /* draft-ietf-ospf-cap-03 */ - +#define LS_OPAQUE_RI_TLV_CAP 1 /* rfc7770 */ +#define LS_OPAQUE_RI_TLV_HOSTNAME 7 /* rfc5642 */ +#define LS_OPAQUE_RI_TLV_SR_ALGO 8 /* rfc8865 */ +#define LS_OPAQUE_RI_TLV_SID_LABEL_RANGE 9 /* rfc8865 */ +#define LS_OPAQUE_RI_TLV_SR_LOCAL_BLOCK 14 /* rfc8865 */ +#define LS_OPAQUE_RI_TLV_SRMS_PREFERENCE 15 /* rfc8865 */ /* rla_link.link_type */ #define RLA_TYPE_ROUTER 1 /* point-to-point to another router */ @@ -122,8 +127,10 @@ /* rla_flags */ #define RLA_FLAG_B 0x01 #define RLA_FLAG_E 0x02 -#define RLA_FLAG_W1 0x04 -#define RLA_FLAG_W2 0x08 +#define RLA_FLAG_V 0x04 +#define RLA_FLAG_W 0x08 +#define RLA_FLAG_NT 0x10 /* RFC3101 Appendix B */ +#define RLA_FLAG_H 0x80 /* sla_tosmetric breakdown */ #define SLA_MASK_TOS 0x7f000000 @@ -141,29 +148,48 @@ #define MCLA_VERTEX_NETWORK 2 /* Link-Local-Signaling */ -#define OSPF_LLS_EO 1 /* RFC4811, RFC4812 */ -#define OSPF_LLS_MD5 2 /* RFC4813 */ +#define OSPF_LLS_HDRLEN 4U /* RFC5613 Section 2.2 */ + +#define OSPF_LLS_EO 1 /* RFC4811, RFC4812 */ +#define OSPF_LLS_MD5 2 /* RFC4813 */ #define OSPF_LLS_EO_LR 0x00000001 /* RFC4811 */ #define OSPF_LLS_EO_RS 0x00000002 /* RFC4812 */ +/* + * TOS metric struct (will be 0 or more in router links update) + */ +struct tos_metric { + nd_uint8_t tos_type; + nd_uint8_t reserved; + nd_uint16_t tos_metric; +}; +struct tos_link { + nd_uint8_t link_type; + nd_uint8_t link_tos_count; + nd_uint16_t tos_metric; +}; +union un_tos { + struct tos_link link; + struct tos_metric metrics; +}; /* link state advertisement header */ struct lsa_hdr { - u_int16_t ls_age; - u_int8_t ls_options; - u_int8_t ls_type; + nd_uint16_t ls_age; + nd_uint8_t ls_options; + nd_uint8_t ls_type; union { - struct in_addr lsa_id; + nd_ipv4 lsa_id; struct { /* opaque LSAs change the LSA-ID field */ - u_int8_t opaque_type; - u_int8_t opaque_id[3]; + nd_uint8_t opaque_type; + nd_uint24_t opaque_id; } opaque_field; } un_lsa_id; - struct in_addr ls_router; - u_int32_t ls_seq; - u_int16_t ls_chksum; - u_int16_t ls_length; + nd_ipv4 ls_router; + nd_uint32_t ls_seq; + nd_uint16_t ls_chksum; + nd_uint16_t ls_length; }; /* link state advertisement */ @@ -174,139 +200,134 @@ struct lsa { union { /* Router links advertisements */ struct { - u_int8_t rla_flags; - u_int8_t rla_zero[1]; - u_int16_t rla_count; + nd_uint8_t rla_flags; + nd_byte rla_zero; + nd_uint16_t rla_count; struct rlalink { - struct in_addr link_id; - struct in_addr link_data; - u_int8_t link_type; - u_int8_t link_toscount; - u_int16_t link_tos0metric; + nd_ipv4 link_id; + nd_ipv4 link_data; + union un_tos un_tos; } rla_link[1]; /* may repeat */ } un_rla; /* Network links advertisements */ struct { - struct in_addr nla_mask; - struct in_addr nla_router[1]; /* may repeat */ + nd_ipv4 nla_mask; + nd_ipv4 nla_router[1]; /* may repeat */ } un_nla; /* Summary links advertisements */ struct { - struct in_addr sla_mask; - u_int32_t sla_tosmetric[1]; /* may repeat */ + nd_ipv4 sla_mask; + nd_uint32_t sla_tosmetric[1]; /* may repeat */ } un_sla; /* AS external links advertisements */ struct { - struct in_addr asla_mask; + nd_ipv4 asla_mask; struct aslametric { - u_int32_t asla_tosmetric; - struct in_addr asla_forward; - struct in_addr asla_tag; + nd_uint32_t asla_tosmetric; + nd_ipv4 asla_forward; + nd_ipv4 asla_tag; } asla_metric[1]; /* may repeat */ } un_asla; /* Multicast group membership */ struct mcla { - u_int32_t mcla_vtype; - struct in_addr mcla_vid; + nd_uint32_t mcla_vtype; + nd_ipv4 mcla_vid; } un_mcla[1]; /* Opaque TE LSA */ struct { - u_int16_t type; - u_int16_t length; - u_int8_t data[1]; /* may repeat */ - } un_te_lsa_tlv; + nd_uint16_t type; + nd_uint16_t length; + nd_byte data[1]; /* may repeat */ + } un_te_lsa_tlv[1]; /* may repeat */ /* Opaque Grace LSA */ struct { - u_int16_t type; - u_int16_t length; - u_int8_t data[1]; /* may repeat */ - } un_grace_tlv; + nd_uint16_t type; + nd_uint16_t length; + nd_byte data[1]; /* may repeat */ + } un_grace_tlv[1]; /* may repeat */ /* Opaque Router information LSA */ struct { - u_int16_t type; - u_int16_t length; - u_int8_t data[1]; /* may repeat */ - } un_ri_tlv; + nd_uint16_t type; + nd_uint16_t length; + nd_byte data[1]; /* may repeat */ + } un_ri_tlv[1]; /* may repeat */ + + /* Extended Prefix LSA */ + struct { + nd_uint16_t type; + nd_uint16_t length; + nd_byte data[1]; /* may repeat */ + } un_ep_tlv[1]; /* may repeat */ /* Unknown LSA */ struct unknown { - u_int8_t data[1]; /* may repeat */ + nd_byte data[1]; /* may repeat */ } un_unknown[1]; } lsa_un; }; - -/* - * TOS metric struct (will be 0 or more in router links update) - */ -struct tos_metric { - u_int8_t tos_type; - u_int8_t tos_zero; - u_int16_t tos_metric; -}; - #define OSPF_AUTH_SIZE 8 /* * the main header */ struct ospfhdr { - u_int8_t ospf_version; - u_int8_t ospf_type; - u_int16_t ospf_len; - struct in_addr ospf_routerid; - struct in_addr ospf_areaid; - u_int16_t ospf_chksum; - u_int16_t ospf_authtype; - u_int8_t ospf_authdata[OSPF_AUTH_SIZE]; + nd_uint8_t ospf_version; + nd_uint8_t ospf_type; + nd_uint16_t ospf_len; + nd_ipv4 ospf_routerid; + nd_ipv4 ospf_areaid; + nd_uint16_t ospf_chksum; + nd_uint16_t ospf_authtype; + nd_byte ospf_authdata[OSPF_AUTH_SIZE]; union { /* Hello packet */ struct { - struct in_addr hello_mask; - u_int16_t hello_helloint; - u_int8_t hello_options; - u_int8_t hello_priority; - u_int32_t hello_deadint; - struct in_addr hello_dr; - struct in_addr hello_bdr; - struct in_addr hello_neighbor[1]; /* may repeat */ + nd_ipv4 hello_mask; + nd_uint16_t hello_helloint; + nd_uint8_t hello_options; + nd_uint8_t hello_priority; + nd_uint32_t hello_deadint; + nd_ipv4 hello_dr; + nd_ipv4 hello_bdr; + nd_ipv4 hello_neighbor[1]; /* may repeat */ } un_hello; /* Database Description packet */ struct { - u_int16_t db_ifmtu; - u_int8_t db_options; - u_int8_t db_flags; - u_int32_t db_seq; + nd_uint16_t db_ifmtu; + nd_uint8_t db_options; + nd_uint8_t db_flags; + nd_uint32_t db_seq; struct lsa_hdr db_lshdr[1]; /* may repeat */ } un_db; /* Link State Request */ struct lsr { - u_int8_t ls_type[4]; + nd_uint32_t ls_type; union { - struct in_addr ls_stateid; + nd_ipv4 ls_stateid; struct { /* opaque LSAs change the LSA-ID field */ - u_int8_t opaque_type; - u_int8_t opaque_id[3]; + nd_uint8_t opaque_type; + nd_uint24_t opaque_id; } opaque_field; } un_ls_stateid; - struct in_addr ls_router; + nd_ipv4 ls_router; } un_lsr[1]; /* may repeat */ /* Link State Update */ struct { - u_int32_t lsu_count; - struct lsa lsu_lsa[1]; /* may repeat */ + nd_uint32_t lsu_count; + struct lsa lsu_lsa[1]; /* may repeat */ } un_lsu; /* Link State Acknowledgement */ @@ -321,7 +342,3 @@ struct ospfhdr { #define ospf_lsr ospf_un.un_lsr #define ospf_lsu ospf_un.un_lsu #define ospf_lsa ospf_un.un_lsa - -/* Functions shared by ospf and ospf6 */ -extern int ospf_print_te_lsa(u_int8_t *, u_int); -extern int ospf_print_grace_lsa(u_int8_t *, u_int);