From 89e18bfad1cb0e01af904d539da1d4a6aeb2ae5b Mon Sep 17 00:00:00 2001 From: Andrew Cooks Date: Wed, 15 May 2024 16:42:43 +1000 Subject: [PATCH] ospf6d: move lsa structs to ospf6_lsa.h It will be cleaner to have the LSAs in a single header and the future TLVs in a single header. Signed-off-by: Andrew Cooks --- ospf6d/ospf6_abr.h | 16 -------- ospf6d/ospf6_asbr.h | 11 ----- ospf6d/ospf6_gr.c | 1 + ospf6d/ospf6_interface.c | 2 +- ospf6d/ospf6_intra.h | 60 --------------------------- ospf6d/ospf6_lsa.h | 89 ++++++++++++++++++++++++++++++++++++++++ ospf6d/ospf6_spf.c | 2 +- tests/ospf6d/test_lsdb.c | 1 + 8 files changed, 93 insertions(+), 89 deletions(-) diff --git a/ospf6d/ospf6_abr.h b/ospf6d/ospf6_abr.h index 52686ed49f..ab9e000d43 100644 --- a/ospf6d/ospf6_abr.h +++ b/ospf6d/ospf6_abr.h @@ -17,22 +17,6 @@ extern unsigned char conf_debug_ospf6_abr; #define OSPF6_DEBUG_ABR_OFF() (conf_debug_ospf6_abr = 0) #define IS_OSPF6_DEBUG_ABR (conf_debug_ospf6_abr) -/* Inter-Area-Prefix-LSA */ -#define OSPF6_INTER_PREFIX_LSA_MIN_SIZE 4U /* w/o IPv6 prefix */ -struct ospf6_inter_prefix_lsa { - uint32_t metric; - struct ospf6_prefix prefix; -}; - -/* Inter-Area-Router-LSA */ -#define OSPF6_INTER_ROUTER_LSA_FIX_SIZE 12U -struct ospf6_inter_router_lsa { - uint8_t mbz; - uint8_t options[3]; - uint32_t metric; - uint32_t router_id; -}; - #define OSPF6_ABR_SUMMARY_METRIC(E) \ (ntohl((E)->metric & htonl(OSPF6_EXT_PATH_METRIC_MAX))) #define OSPF6_ABR_SUMMARY_METRIC_SET(E, C) \ diff --git a/ospf6d/ospf6_asbr.h b/ospf6d/ospf6_asbr.h index 21e6d898e8..ace3ba8488 100644 --- a/ospf6d/ospf6_asbr.h +++ b/ospf6d/ospf6_asbr.h @@ -79,17 +79,6 @@ struct ospf6_external_aggr_rt { struct hash *match_extnl_hash; }; -/* AS-External-LSA */ -#define OSPF6_AS_EXTERNAL_LSA_MIN_SIZE 4U /* w/o IPv6 prefix */ -struct ospf6_as_external_lsa { - uint32_t bits_metric; - - struct ospf6_prefix prefix; - /* followed by none or one forwarding address */ - /* followed by none or one external route tag */ - /* followed by none or one referenced LS-ID */ -}; - #define OSPF6_ASBR_BIT_T ntohl (0x01000000) #define OSPF6_ASBR_BIT_F ntohl (0x02000000) #define OSPF6_ASBR_BIT_E ntohl (0x04000000) diff --git a/ospf6d/ospf6_gr.c b/ospf6d/ospf6_gr.c index 7295dee0f0..543de1c9e3 100644 --- a/ospf6d/ospf6_gr.c +++ b/ospf6d/ospf6_gr.c @@ -16,6 +16,7 @@ #include "printfrr.h" #include "lib_errors.h" +#include "ospf6_proto.h" #include "ospf6d/ospf6_lsa.h" #include "ospf6d/ospf6_lsdb.h" #include "ospf6d/ospf6_route.h" diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 25c0392d99..60f92385dd 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -14,6 +14,7 @@ #include "plist.h" #include "zclient.h" +#include "ospf6_proto.h" #include "ospf6_lsa.h" #include "ospf6_lsdb.h" #include "ospf6_top.h" @@ -33,7 +34,6 @@ #include "ospf6_tlv.h" #include "ospf6_gr.h" #include "lib/json.h" -#include "ospf6_proto.h" #include "lib/keychain.h" #include "ospf6_auth_trailer.h" #include "ospf6d/ospf6_interface_clippy.c" diff --git a/ospf6d/ospf6_intra.h b/ospf6d/ospf6_intra.h index 7d154cb4c6..f77089fc05 100644 --- a/ospf6d/ospf6_intra.h +++ b/ospf6d/ospf6_intra.h @@ -55,30 +55,6 @@ extern in_addr_t conf_debug_ospf6_brouter_specific_area_id; (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \ && conf_debug_ospf6_brouter_specific_area_id == (area_id)) -/* Router-LSA */ -#define OSPF6_ROUTER_LSA_MIN_SIZE 4U -struct ospf6_router_lsa { - uint8_t bits; - uint8_t options[3]; - /* followed by ospf6_router_lsdesc(s) */ -}; - -/* Link State Description in Router-LSA */ -#define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U -struct ospf6_router_lsdesc { - uint8_t type; - uint8_t reserved; - uint16_t metric; /* output cost */ - uint32_t interface_id; - uint32_t neighbor_interface_id; - in_addr_t neighbor_router_id; -}; - -#define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1 -#define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2 -#define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3 -#define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4 - enum stub_router_mode { OSPF6_NOT_STUB_ROUTER, OSPF6_IS_STUB_ROUTER, @@ -99,42 +75,6 @@ enum stub_router_mode { #define ROUTER_LSDESC_GET_NBR_ROUTERID(x) \ (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id) -/* Network-LSA */ -#define OSPF6_NETWORK_LSA_MIN_SIZE 4U -struct ospf6_network_lsa { - uint8_t reserved; - uint8_t options[3]; - /* followed by ospf6_netowrk_lsd(s) */ -}; - -/* Link State Description in Router-LSA */ -#define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U -struct ospf6_network_lsdesc { - in_addr_t router_id; -}; -#define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \ - (((struct ospf6_network_lsdesc *)(x))->router_id) - -/* Link-LSA */ -#define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */ -struct ospf6_link_lsa { - uint8_t priority; - uint8_t options[3]; - struct in6_addr linklocal_addr; - uint32_t prefix_num; - /* followed by ospf6 prefix(es) */ -}; - -/* Intra-Area-Prefix-LSA */ -#define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */ -struct ospf6_intra_prefix_lsa { - uint16_t prefix_num; - uint16_t ref_type; - uint32_t ref_id; - in_addr_t ref_adv_router; - /* followed by ospf6 prefix(es) */ -}; - #define OSPF6_ROUTER_LSA_SCHEDULE(oa) \ do { \ diff --git a/ospf6d/ospf6_lsa.h b/ospf6d/ospf6_lsa.h index 4fc2f0dd18..d2501c42ce 100644 --- a/ospf6d/ospf6_lsa.h +++ b/ospf6d/ospf6_lsa.h @@ -117,6 +117,95 @@ static inline uint16_t ospf6_lsa_size(struct ospf6_lsa_header *header) #define OSPF6_LSA_IS_SEQWRAP(L) ((L)->header->seqnum == htonl(OSPF_MAX_SEQUENCE_NUMBER + 1)) +/* Router-LSA */ +#define OSPF6_ROUTER_LSA_MIN_SIZE 4U +struct ospf6_router_lsa { + uint8_t bits; + uint8_t options[3]; + /* followed by ospf6_router_lsdesc(s) */ +}; + +/* Link State Description in Router-LSA */ +#define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U +struct ospf6_router_lsdesc { + uint8_t type; + uint8_t reserved; + uint16_t metric; /* output cost */ + uint32_t interface_id; + uint32_t neighbor_interface_id; + in_addr_t neighbor_router_id; +}; + +#define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1 +#define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2 +#define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3 +#define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4 + +/* Network-LSA */ +#define OSPF6_NETWORK_LSA_MIN_SIZE 4U +struct ospf6_network_lsa { + uint8_t reserved; + uint8_t options[3]; + /* followed by ospf6_network_lsdesc(s) */ +}; + +/* Link State Description in Network-LSA */ +#define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U +struct ospf6_network_lsdesc { + in_addr_t router_id; +}; +#define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \ + (((struct ospf6_network_lsdesc *)(x))->router_id) + +/* Inter-Area-Prefix-LSA */ +#define OSPF6_INTER_PREFIX_LSA_MIN_SIZE 4U /* w/o IPv6 prefix */ +struct ospf6_inter_prefix_lsa { + uint32_t metric; + struct ospf6_prefix prefix; +}; + +/* Inter-Area-Router-LSA */ +#define OSPF6_INTER_ROUTER_LSA_FIX_SIZE 12U +struct ospf6_inter_router_lsa { + uint8_t mbz; + uint8_t options[3]; + uint32_t metric; + uint32_t router_id; +}; + +/* AS-External-LSA */ +#define OSPF6_AS_EXTERNAL_LSA_MIN_SIZE 4U /* w/o IPv6 prefix */ +struct ospf6_as_external_lsa { + uint32_t bits_metric; + + struct ospf6_prefix prefix; + /* followed by none or one forwarding address */ + /* followed by none or one external route tag */ + /* followed by none or one referenced LS-ID */ +}; + +/* FIXME: move nssa lsa here. */ + +/* Link-LSA */ +#define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */ +struct ospf6_link_lsa { + uint8_t priority; + uint8_t options[3]; + struct in6_addr linklocal_addr; + uint32_t prefix_num; + /* followed by ospf6 prefix(es) */ +}; + +/* Intra-Area-Prefix-LSA */ +#define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */ +struct ospf6_intra_prefix_lsa { + uint16_t prefix_num; + uint16_t ref_type; + uint32_t ref_id; + in_addr_t ref_adv_router; + /* followed by ospf6 prefix(es) */ +}; + struct ospf6_lsa { char name[64]; /* dump string */ diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 7879dae8d7..5c6c1f0f26 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -16,11 +16,11 @@ #include "frrevent.h" #include "lib_errors.h" +#include "ospf6_proto.h" #include "ospf6_lsa.h" #include "ospf6_lsdb.h" #include "ospf6_route.h" #include "ospf6_area.h" -#include "ospf6_proto.h" #include "ospf6_abr.h" #include "ospf6_asbr.h" #include "ospf6_spf.h" diff --git a/tests/ospf6d/test_lsdb.c b/tests/ospf6d/test_lsdb.c index f9df73538a..9cec4a3182 100644 --- a/tests/ospf6d/test_lsdb.c +++ b/tests/ospf6d/test_lsdb.c @@ -12,6 +12,7 @@ #include "vector.h" #include "vty.h" +#include "ospf6d/ospf6_proto.h" /* for struct ospf6_prefix */ #include "ospf6d/ospf6_lsa.h" #include "ospf6d/ospf6_lsdb.h"