diff options
author | Olivier Dugeon <olivier.dugeon@orange.com> | 2017-07-20 19:57:43 +0200 |
---|---|---|
committer | Olivier Dugeon <olivier.dugeon@orange.com> | 2017-07-20 19:57:43 +0200 |
commit | ead99d5f26abef2490c1ee89a0126bfd15181182 (patch) | |
tree | 34c4f7918243085317002076699ee14f16ee8e46 /ospfd/ospf_opaque.h | |
parent | Merge pull request #834 from dwalton76/ospf6d-show-crash (diff) | |
download | frr-ead99d5f26abef2490c1ee89a0126bfd15181182.tar.xz frr-ead99d5f26abef2490c1ee89a0126bfd15181182.zip |
OSPF OPAQUE, TE and RI macro refactoring & cleanup
* TLV macros where define itwice in ospf_te.h and in ospf_ri.h
* Merge both definition in ospf_opaque.h and adjust accordingly RI and TE
* Same for typedef status_t which is move in ospfd.h
* Remove also all 'goto' statement in ospf_te.c and ospf_ri.c
* Remove strange function lookup_oi_by_ifp() in ospf_te.c and replace it
by a valid code in initialize_linkparams() function
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
Diffstat (limited to 'ospfd/ospf_opaque.h')
-rw-r--r-- | ospfd/ospf_opaque.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h index 8bad51e65..88a6854b8 100644 --- a/ospfd/ospf_opaque.h +++ b/ospfd/ospf_opaque.h @@ -77,6 +77,47 @@ ((ntohs((lsahdr)->length) >= sizeof(struct lsa_header)) \ && ((ntohs((lsahdr)->length) % sizeof(u_int32_t)) == 0)) +/* + * Following section defines generic TLV (type, length, value) macros, + * used for various LSA opaque usage e.g. Traffic Engineering. + */ +struct tlv_header +{ + u_int16_t type; /* Type of Value */ + u_int16_t length; /* Length of Value portion only, in bytes */ +}; + +#define TLV_HDR_SIZE \ + (sizeof (struct tlv_header)) + +#define TLV_BODY_SIZE(tlvh) \ + (ROUNDUP (ntohs ((tlvh)->length), sizeof (u_int32_t))) + +#define TLV_SIZE(tlvh) \ + (TLV_HDR_SIZE + TLV_BODY_SIZE(tlvh)) + +#define TLV_HDR_TOP(lsah) \ + (struct tlv_header *)((char *)(lsah) + OSPF_LSA_HEADER_SIZE) + +#define TLV_HDR_NEXT(tlvh) \ + (struct tlv_header *)((char *)(tlvh) + TLV_SIZE(tlvh)) + +#define TLV_HDR_SUBTLV(tlvh) \ + (struct tlv_header *)((char *)(tlvh) + TLV_HDR_SIZE) + +#define TLV_DATA(tlvh) (void *)((char *)(tlvh) + TLV_HDR_SIZE) + +#define TLV_TYPE(tlvh) tlvh.header.type +#define TLV_LEN(tlvh) tlvh.header.length +#define TLV_HDR(tlvh) tlvh.header + +/* Following declaration concerns the Opaque LSA management */ +typedef enum _opcode_t { + REORIGINATE_THIS_LSA, + REFRESH_THIS_LSA, + FLUSH_THIS_LSA +} opcode_t; + /* Prototypes. */ extern void ospf_opaque_init(void); |