From e34e07e640989bff120acc2954536e3471134f88 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 19 Aug 2021 11:36:16 +0200 Subject: [PATCH] pimd: de-circularize includes pimd's include files are very interdependent. Let's chop that down a bit to gain some flexibility. Signed-off-by: David Lamparter --- pimd/pim_assert.h | 18 ++++++++++++++++-- pimd/pim_bfd.c | 1 + pimd/pim_bsm.c | 1 + pimd/pim_iface.h | 1 + pimd/pim_ifchannel.h | 16 ++-------------- pimd/pim_igmpv3.h | 2 ++ pimd/pim_instance.h | 2 ++ pimd/pim_mroute.h | 2 ++ pimd/pim_nb_config.c | 1 + pimd/pim_neighbor.h | 1 + pimd/pim_oil.h | 3 ++- pimd/pim_rp.c | 2 +- pimd/pim_rp.h | 3 ++- pimd/pim_rpf.c | 1 + pimd/pim_rpf.h | 3 --- pimd/pim_upstream.h | 2 +- pimd/pim_zlookup.c | 1 + pimd/pimd.h | 1 - 18 files changed, 37 insertions(+), 24 deletions(-) diff --git a/pimd/pim_assert.h b/pimd/pim_assert.h index 63fda3fe34..c07cbeb013 100644 --- a/pimd/pim_assert.h +++ b/pimd/pim_assert.h @@ -24,8 +24,22 @@ #include "if.h" -#include "pim_neighbor.h" -#include "pim_ifchannel.h" +struct pim_ifchannel; +struct pim_neighbor; + +enum pim_ifassert_state { + PIM_IFASSERT_NOINFO, + PIM_IFASSERT_I_AM_WINNER, + PIM_IFASSERT_I_AM_LOSER +}; + +struct pim_assert_metric { + uint32_t rpt_bit_flag; + uint32_t metric_preference; + uint32_t route_metric; + struct in_addr ip_address; /* neighbor router that sourced the Assert + message */ +}; /* RFC 4601: 4.11. Timer Values diff --git a/pimd/pim_bfd.c b/pimd/pim_bfd.c index dfe2d5f2fa..c7fcbba71e 100644 --- a/pimd/pim_bfd.c +++ b/pimd/pim_bfd.c @@ -28,6 +28,7 @@ #include "zclient.h" #include "pim_instance.h" +#include "pim_neighbor.h" #include "pim_cmd.h" #include "pim_vty.h" #include "pim_iface.h" diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c index f2845ee6e1..a3a3426f39 100644 --- a/pimd/pim_bsm.c +++ b/pimd/pim_bsm.c @@ -28,6 +28,7 @@ #include "pimd.h" #include "pim_iface.h" #include "pim_instance.h" +#include "pim_neighbor.h" #include "pim_rpf.h" #include "pim_hello.h" #include "pim_pim.h" diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h index 92784103fe..dc70b4134f 100644 --- a/pimd/pim_iface.h +++ b/pimd/pim_iface.h @@ -30,6 +30,7 @@ #include "pim_igmp.h" #include "pim_upstream.h" +#include "pim_instance.h" #include "bfd.h" #define PIM_IF_MASK_PIM (1 << 0) diff --git a/pimd/pim_ifchannel.h b/pimd/pim_ifchannel.h index 7ec8191e56..52f02a660b 100644 --- a/pimd/pim_ifchannel.h +++ b/pimd/pim_ifchannel.h @@ -25,6 +25,8 @@ #include "if.h" #include "prefix.h" +#include "pim_assert.h" + struct pim_ifchannel; #include "pim_upstream.h" @@ -39,20 +41,6 @@ enum pim_ifjoin_state { PIM_IFJOIN_PRUNE_PENDING_TMP, }; -enum pim_ifassert_state { - PIM_IFASSERT_NOINFO, - PIM_IFASSERT_I_AM_WINNER, - PIM_IFASSERT_I_AM_LOSER -}; - -struct pim_assert_metric { - uint32_t rpt_bit_flag; - uint32_t metric_preference; - uint32_t route_metric; - struct in_addr ip_address; /* neighbor router that sourced the Assert - message */ -}; - /* Flag to detect change in CouldAssert(S,G,I) */ diff --git a/pimd/pim_igmpv3.h b/pimd/pim_igmpv3.h index 6abaef6e26..5adf22a6fa 100644 --- a/pimd/pim_igmpv3.h +++ b/pimd/pim_igmpv3.h @@ -23,6 +23,8 @@ #include #include "if.h" +#include "pim_igmp.h" + #define IGMP_V3_CHECKSUM_OFFSET (2) #define IGMP_V3_REPORT_NUMGROUPS_OFFSET (6) #define IGMP_V3_REPORT_GROUPPRECORD_OFFSET (8) diff --git a/pimd/pim_instance.h b/pimd/pim_instance.h index 52ded08ae3..68c5b9167b 100644 --- a/pimd/pim_instance.h +++ b/pimd/pim_instance.h @@ -210,6 +210,8 @@ struct pim_instance { void pim_vrf_init(void); void pim_vrf_terminate(void); +extern struct pim_router *router; + struct pim_instance *pim_get_pim_instance(vrf_id_t vrf_id); #endif diff --git a/pimd/pim_mroute.h b/pimd/pim_mroute.h index 2d8e1b01fb..4cd6b9f0ac 100644 --- a/pimd/pim_mroute.h +++ b/pimd/pim_mroute.h @@ -167,6 +167,8 @@ struct igmpmsg { Above: from */ +struct channel_oil; + int pim_mroute_socket_enable(struct pim_instance *pim); int pim_mroute_socket_disable(struct pim_instance *pim); diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index 4b4c1ec7db..20fc4eaef6 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -23,6 +23,7 @@ #include "pim_nb.h" #include "lib/northbound_cli.h" #include "pim_igmpv3.h" +#include "pim_neighbor.h" #include "pim_pim.h" #include "pim_mlag.h" #include "pim_bfd.h" diff --git a/pimd/pim_neighbor.h b/pimd/pim_neighbor.h index b461098a60..d71b2b87c3 100644 --- a/pimd/pim_neighbor.h +++ b/pimd/pim_neighbor.h @@ -27,6 +27,7 @@ #include "prefix.h" #include "pim_tlv.h" +#include "pim_iface.h" struct pim_neighbor { int64_t creation; /* timestamp of creation */ diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h index b0aa2b17c5..af8ac84594 100644 --- a/pimd/pim_oil.h +++ b/pimd/pim_oil.h @@ -20,8 +20,9 @@ #ifndef PIM_OIL_H #define PIM_OIL_H +struct pim_interface; + #include "pim_mroute.h" -#include "pim_iface.h" /* * Where did we get this (S,G) from? diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 3e3b6dddb5..f2a969e04a 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -42,7 +42,7 @@ #include "pim_rpf.h" #include "pim_sock.h" #include "pim_memory.h" -#include "pim_iface.h" +#include "pim_neighbor.h" #include "pim_msdp.h" #include "pim_nht.h" #include "pim_mroute.h" diff --git a/pimd/pim_rp.h b/pimd/pim_rp.h index dd7cd5d75e..595025e5c9 100644 --- a/pimd/pim_rp.h +++ b/pimd/pim_rp.h @@ -24,9 +24,10 @@ #include "prefix.h" #include "vty.h" #include "plist.h" -#include "pim_iface.h" #include "pim_rpf.h" +struct pim_interface; + enum rp_source { RP_SRC_NONE = 0, RP_SRC_STATIC, diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index 98944e8fed..10e157e9c4 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -31,6 +31,7 @@ #include "pim_pim.h" #include "pim_str.h" #include "pim_iface.h" +#include "pim_neighbor.h" #include "pim_zlookup.h" #include "pim_ifchannel.h" #include "pim_time.h" diff --git a/pimd/pim_rpf.h b/pimd/pim_rpf.h index f006519b71..006aa1b636 100644 --- a/pimd/pim_rpf.h +++ b/pimd/pim_rpf.h @@ -22,9 +22,6 @@ #include -#include "pim_upstream.h" -#include "pim_neighbor.h" - /* RFC 4601: diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h index 56039d5605..ea3b564f8a 100644 --- a/pimd/pim_upstream.h +++ b/pimd/pim_upstream.h @@ -24,7 +24,7 @@ #include #include "plist.h" -#include +#include "pim_rpf.h" #include "pim_str.h" #include "pim_ifchannel.h" diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index dce936b8a9..abf9577bd5 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -31,6 +31,7 @@ #include "pimd.h" #include "pim_iface.h" +#include "pim_neighbor.h" #include "pim_pim.h" #include "pim_str.h" #include "pim_oil.h" diff --git a/pimd/pimd.h b/pimd/pimd.h index 88e692b50d..4cb860a6b7 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -136,7 +136,6 @@ extern const char *const PIM_ALL_ROUTERS; extern const char *const PIM_ALL_PIM_ROUTERS; extern const char *const PIM_ALL_IGMP_ROUTERS; -extern struct pim_router *router; extern struct zebra_privs_t pimd_privs; extern struct in_addr qpim_all_pim_routers_addr; extern uint8_t qpim_ecmp_enable; -- 2.39.5