diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/ospf/lsack.c | 14 | ||||
-rw-r--r-- | proto/ospf/lsupd.c | 10 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 15 | ||||
-rw-r--r-- | proto/ospf/packet.c | 39 |
4 files changed, 38 insertions, 40 deletions
diff --git a/proto/ospf/lsack.c b/proto/ospf/lsack.c index 5318e50c..1654953f 100644 --- a/proto/ospf/lsack.c +++ b/proto/ospf/lsack.c @@ -111,20 +111,12 @@ ospf_send_lsack_(struct ospf_proto *p, struct ospf_neighbor *n, int queue) { OSPF_PACKET(ospf_dump_lsack, pkt, "LSACK packet sent to nbr %R on %s", n->rid, ifa->ifname); ospf_send_to(ifa, n->ip); - return; } - - OSPF_PACKET(ospf_dump_lsack, pkt, "LSACK packet sent via %s", ifa->ifname); - - if (ifa->type == OSPF_IT_BCAST) + else { - if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP)) - ospf_send_to_all(ifa); - else - ospf_send_to_des(ifa); + OSPF_PACKET(ospf_dump_lsack, pkt, "LSACK packet sent via %s", ifa->ifname); + ospf_send_to_iface(ifa); } - else - ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE); } void diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c index fafe4872..66017a2e 100644 --- a/proto/ospf/lsupd.c +++ b/proto/ospf/lsupd.c @@ -398,15 +398,7 @@ ospf_flood_lsupd(struct ospf_proto *p, struct top_hash_entry **lsa_list, uint ls OSPF_PACKET(ospf_dump_lsupd, ospf_tx_buffer(ifa), "LSUPD packet flooded via %s", ifa->ifname); - 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_des(ifa); - } - else - ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE); + ospf_send_to_iface(ifa); } return i; diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index db55aa6a..aa7d937e 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -1056,22 +1056,13 @@ int ospf_rx_hook(sock * sk, uint size); void ospf_err_hook(sock * sk, int err); void ospf_verr_hook(sock *sk, int err); void ospf_send_to(struct ospf_iface *ifa, ip_addr ip); -void ospf_send_to_agt(struct ospf_iface *ifa, u8 state); -void ospf_send_to_bdr(struct ospf_iface *ifa); - -static inline uint ospf_pkt_maxsize(struct ospf_iface *ifa) -{ return ifa->tx_length - ifa->tx_hdrlen; } +void ospf_send_to_iface(struct ospf_iface *ifa); static inline void ospf_send_to_all(struct ospf_iface *ifa) { ospf_send_to(ifa, ifa->all_routers); } -static inline void ospf_send_to_des(struct ospf_iface *ifa) -{ - if (ipa_nonzero(ifa->des_routers)) - ospf_send_to(ifa, ifa->des_routers); - else - ospf_send_to_bdr(ifa); -} +static inline uint ospf_pkt_maxsize(struct ospf_iface *ifa) +{ return ifa->tx_length - ifa->tx_hdrlen; } #ifndef PARSER #define DROP(DSC,VAL) do { err_dsc = DSC; err_val = VAL; goto drop; } while(0) 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); } |