diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2021-05-09 14:51:39 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2021-05-09 14:51:39 +0200 |
commit | 1647923bd8d2f8e53337365abc5be7e343aa570c (patch) | |
tree | 72f34e15257ca9a9fbe2d4041bf2bb210076e32c /proto/ospf/packet.c | |
parent | 255722e0fcf251c101ff5bec92f1867edf841daa (diff) |
OSPF: Minor refactoring of packet sending code
Common behavior for LSupd and delayed LSack moved to ospf_send_to_iface()
and other minor changes.
Diffstat (limited to 'proto/ospf/packet.c')
-rw-r--r-- | proto/ospf/packet.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c index 85cbbdf0..1f471d79 100644 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@ -664,21 +664,44 @@ ospf_send_to(struct ospf_iface *ifa, ip_addr dst) log(L_WARN "OSPF: TX queue full on %s", ifa->ifname); } -void -ospf_send_to_agt(struct ospf_iface *ifa, u8 state) +static void +ospf_send_to_designated(struct ospf_iface *ifa) +{ + /* In case of real-broadcast mode */ + if (ipa_zero(ifa->des_routers)) + { + if (ipa_nonzero2(ifa->drip)) + ospf_send_to(ifa, ifa->drip); + + if (ipa_nonzero2(ifa->bdrip)) + ospf_send_to(ifa, ifa->bdrip); + + return; + } + + ospf_send_to(ifa, ifa->des_routers); +} + +static void +ospf_send_to_adjacent(struct ospf_iface *ifa) { struct ospf_neighbor *n; WALK_LIST(n, ifa->neigh_list) - if (n->state >= state) + if (n->state >= NEIGHBOR_EXCHANGE) ospf_send_to(ifa, n->ip); } void -ospf_send_to_bdr(struct ospf_iface *ifa) +ospf_send_to_iface(struct ospf_iface *ifa) { - if (ipa_nonzero2(ifa->drip)) - ospf_send_to(ifa, ifa->drip); - if (ipa_nonzero2(ifa->bdrip)) - ospf_send_to(ifa, ifa->bdrip); + if (ifa->type == OSPF_IT_BCAST) + { + if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP)) + ospf_send_to_all(ifa); + else + ospf_send_to_designated(ifa); + } + else /* Non-broadcast */ + ospf_send_to_adjacent(ifa); } |