OSPF_PACKET(ospf_dump_dbdes, n->ldd_buffer,
"DBDES packet sent to nbr %R on %s", n->rid, ifa->ifname);
sk_set_tbuf(ifa->sk, n->ldd_buffer);
- ospf_send_to(ifa, n->ip);
+ ospf_send_to_nbr(ifa, n);
sk_set_tbuf(ifa->sk, NULL);
}
if (queue == ACKL_DIRECT)
{
OSPF_PACKET(ospf_dump_lsack, pkt, "LSACK packet sent to nbr %R on %s", n->rid, ifa->ifname);
- ospf_send_to(ifa, n->ip);
+ ospf_send_to_nbr(ifa, n);
}
else
{
pkt->length = htons(length);
OSPF_PACKET(ospf_dump_lsreq, pkt, "LSREQ packet sent to nbr %R on %s", n->rid, ifa->ifname);
- ospf_send_to(ifa, n->ip);
+ ospf_send_to_nbr(ifa, n);
}
OSPF_PACKET(ospf_dump_lsupd, ospf_tx_buffer(ifa),
"LSUPD packet sent to nbr %R on %s", n->rid, ifa->ifname);
- ospf_send_to(ifa, n->ip);
+ ospf_send_to_nbr(ifa, n);
}
return i;
void ospf_send_to(struct ospf_iface *ifa, ip_addr ip);
void ospf_send_to_iface(struct ospf_iface *ifa);
+static inline void ospf_send_to_nbr(struct ospf_iface *ifa, struct ospf_neighbor *n)
+{ ospf_send_to(ifa, (ifa->type == OSPF_IT_PTP) ? ifa->all_routers : n->ip); }
+
static inline void ospf_send_to_all(struct ospf_iface *ifa)
{ ospf_send_to(ifa, ifa->all_routers); }
void
ospf_send_to_iface(struct ospf_iface *ifa)
{
+ /*
+ * Send packet to (relevant) neighbors on iface
+ *
+ * On broadcast networks, destination is either AllSPFRouters, or AllDRouters.
+ * On PtP networks, destination is always AllSPFRouters. On non-broadcast
+ * networks, packets are sent as unicast to every adjacent neighbor.
+ */
+
if (ifa->type == OSPF_IT_BCAST)
{
if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
else
ospf_send_to_designated(ifa);
}
+ else if (ifa->type == OSPF_IT_PTP)
+ ospf_send_to_all(ifa);
else /* Non-broadcast */
ospf_send_to_adjacent(ifa);
}