1999-11-17 15:50:41 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- OSPF
|
|
|
|
*
|
2004-07-01 15:01:04 +00:00
|
|
|
* (c) 1999--2004 Ondrej Filip <feela@network.cz>
|
1999-11-17 15:50:41 +00:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ospf.h"
|
|
|
|
|
2009-08-21 07:27:52 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_hello2_packet
|
2009-08-21 07:27:52 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_packet hdr;
|
|
|
|
union ospf_auth auth;
|
|
|
|
|
|
|
|
u32 netmask;
|
2009-08-21 07:27:52 +00:00
|
|
|
u16 helloint;
|
|
|
|
u8 options;
|
|
|
|
u8 priority;
|
|
|
|
u32 deadint;
|
|
|
|
u32 dr;
|
|
|
|
u32 bdr;
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
u32 neighbors[];
|
|
|
|
};
|
2009-08-21 07:27:52 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_hello3_packet
|
2009-08-21 07:27:52 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_packet hdr;
|
|
|
|
|
2009-08-21 07:27:52 +00:00
|
|
|
u32 iface_id;
|
|
|
|
u8 priority;
|
|
|
|
u8 options3;
|
|
|
|
u8 options2;
|
|
|
|
u8 options;
|
|
|
|
u16 helloint;
|
|
|
|
u16 deadint;
|
|
|
|
u32 dr;
|
|
|
|
u32 bdr;
|
2012-08-05 20:32:06 +00:00
|
|
|
|
|
|
|
u32 neighbors[];
|
2009-08-21 07:27:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-11-17 15:50:41 +00:00
|
|
|
void
|
2012-08-05 20:32:06 +00:00
|
|
|
ospf_hello_receive(struct ospf_packet *pkt, struct ospf_iface *ifa,
|
2009-08-21 07:27:52 +00:00
|
|
|
struct ospf_neighbor *n, ip_addr faddr)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2009-12-11 00:20:53 +00:00
|
|
|
struct proto_ospf *po = ifa->oa->po;
|
2010-02-11 09:23:35 +00:00
|
|
|
char *beg = "OSPF: Bad HELLO packet from ";
|
2012-08-05 20:32:06 +00:00
|
|
|
unsigned int size, i, two_way;
|
2009-10-29 22:57:42 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
u32 rcv_iface_id, rcv_helloint, rcv_deadint, rcv_dr, rcv_bdr;
|
|
|
|
u8 rcv_options, rcv_priority;
|
|
|
|
|
|
|
|
u32 *neighbors;
|
|
|
|
u32 neigh_count;
|
2009-10-29 22:57:42 +00:00
|
|
|
|
1999-11-17 15:50:41 +00:00
|
|
|
|
2014-04-29 08:22:25 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "HELLO packet received from %I via %s", faddr, ifa->ifname);
|
2012-08-05 20:32:06 +00:00
|
|
|
|
|
|
|
size = ntohs(pkt->length);
|
|
|
|
|
|
|
|
if (ospf_is_v2(po))
|
2010-02-11 09:23:35 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
struct ospf_hello2_packet *ps = (void *) pkt;
|
|
|
|
|
|
|
|
if (size < sizeof(struct ospf_hello2_packet))
|
|
|
|
{
|
|
|
|
log(L_ERR "%s%I - too short (%u B)", beg, faddr, size);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rcv_iface_id = 0;
|
|
|
|
rcv_helloint = ntohs(ps->helloint);
|
|
|
|
rcv_deadint = ntohl(ps->deadint);
|
|
|
|
rcv_dr = ntohl(ps->dr);
|
|
|
|
rcv_bdr = ntohl(ps->bdr);
|
|
|
|
rcv_options = ps->options;
|
|
|
|
rcv_priority = ps->priority;
|
|
|
|
|
|
|
|
int pxlen = u32_masklen(ntohl(ps->netmask));
|
|
|
|
if ((ifa->type != OSPF_IT_VLINK) &&
|
|
|
|
(ifa->type != OSPF_IT_PTP) &&
|
|
|
|
(pxlen != ifa->addr->pxlen))
|
|
|
|
{
|
|
|
|
log(L_ERR "%s%I - prefix length mismatch (%d)", beg, faddr, pxlen);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
neighbors = ps->neighbors;
|
|
|
|
neigh_count = (size - sizeof(struct ospf_hello2_packet)) / sizeof(u32);
|
2010-02-11 09:23:35 +00:00
|
|
|
}
|
2012-08-05 20:32:06 +00:00
|
|
|
else /* OSPFv3 */
|
|
|
|
{
|
|
|
|
struct ospf_hello3_packet *ps = (void *) pkt;
|
|
|
|
|
|
|
|
if (size < sizeof(struct ospf_hello3_packet))
|
|
|
|
{
|
|
|
|
log(L_ERR "%s%I - too short (%u B)", beg, faddr, size);
|
|
|
|
return;
|
|
|
|
}
|
2004-06-04 17:12:27 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
rcv_iface_id = ntohl(ps->iface_id);
|
|
|
|
rcv_helloint = ntohs(ps->helloint);
|
|
|
|
rcv_deadint = ntohs(ps->deadint);
|
|
|
|
rcv_dr = ntohl(ps->dr);
|
|
|
|
rcv_bdr = ntohl(ps->bdr);
|
|
|
|
rcv_options = ps->options;
|
|
|
|
rcv_priority = ps->priority;
|
|
|
|
|
|
|
|
neighbors = ps->neighbors;
|
|
|
|
neigh_count = (size - sizeof(struct ospf_hello3_packet)) / sizeof(u32);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rcv_helloint != ifa->helloint)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
log(L_ERR "%s%I - hello interval mismatch (%d)", beg, faddr, rcv_helloint);
|
1999-11-17 15:50:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (rcv_deadint != ifa->deadint)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
log(L_ERR "%s%I - dead interval mismatch (%d)", beg, faddr, rcv_deadint);
|
1999-11-17 15:50:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-07-20 21:40:20 +00:00
|
|
|
/* Check whether bits E, N match */
|
2012-08-05 20:32:06 +00:00
|
|
|
if ((rcv_options ^ ifa->oa->options) & (OPT_E | OPT_N))
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
log(L_ERR "%s%I - area type mismatch (%x)", beg, faddr, rcv_options);
|
1999-11-17 15:50:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-04-29 08:22:25 +00:00
|
|
|
/* XXXX */
|
|
|
|
#ifdef OSPFv2
|
|
|
|
if (n && (n->rid != ntohl(pkt->routerid)))
|
|
|
|
{
|
|
|
|
OSPF_TRACE(D_EVENTS, "Neighbor %I has changed router id from %R to %R",
|
|
|
|
n->ip, n->rid, ntohl(pkt->routerid));
|
|
|
|
ospf_neigh_remove(n);
|
|
|
|
n = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-06-06 19:53:52 +00:00
|
|
|
if (!n)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2010-12-24 17:08:07 +00:00
|
|
|
if ((ifa->type == OSPF_IT_NBMA) || (ifa->type == OSPF_IT_PTMP))
|
2000-09-02 00:03:36 +00:00
|
|
|
{
|
2010-12-24 17:08:07 +00:00
|
|
|
struct nbma_node *nn = find_nbma_node(ifa, faddr);
|
2000-09-02 00:03:36 +00:00
|
|
|
|
2010-12-24 17:08:07 +00:00
|
|
|
if (!nn && ifa->strictnbma)
|
2000-09-02 00:03:36 +00:00
|
|
|
{
|
2014-04-29 08:22:25 +00:00
|
|
|
log(L_WARN "Ignoring new neighbor: %I on %s", faddr, ifa->ifname);
|
2000-09-02 00:03:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-12-24 17:08:07 +00:00
|
|
|
|
|
|
|
if (nn && (ifa->type == OSPF_IT_NBMA) &&
|
2012-08-05 20:32:06 +00:00
|
|
|
(((rcv_priority == 0) && nn->eligible) ||
|
|
|
|
((rcv_priority > 0) && !nn->eligible)))
|
2000-09-02 00:03:36 +00:00
|
|
|
{
|
2014-04-29 08:22:25 +00:00
|
|
|
log(L_ERR "Eligibility mismatch for neighbor: %I on %s", faddr, ifa->ifname);
|
2010-12-24 17:08:07 +00:00
|
|
|
return;
|
2000-09-02 00:03:36 +00:00
|
|
|
}
|
2010-12-24 17:08:07 +00:00
|
|
|
|
|
|
|
if (nn)
|
|
|
|
nn->found = 1;
|
2000-09-02 00:03:36 +00:00
|
|
|
}
|
2010-12-24 17:08:07 +00:00
|
|
|
|
2014-04-29 08:22:25 +00:00
|
|
|
OSPF_TRACE(D_EVENTS, "New neighbor found: %I on %s", faddr, ifa->ifname);
|
2004-06-04 12:53:10 +00:00
|
|
|
|
|
|
|
n = ospf_neighbor_new(ifa);
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
n->rid = ntohl(pkt->routerid);
|
2004-06-04 17:12:27 +00:00
|
|
|
n->ip = faddr;
|
2012-08-05 20:32:06 +00:00
|
|
|
n->dr = rcv_dr;
|
|
|
|
n->bdr = rcv_bdr;
|
|
|
|
n->priority = rcv_priority;
|
|
|
|
n->iface_id = rcv_iface_id;
|
2014-04-29 08:22:25 +00:00
|
|
|
|
|
|
|
if (n->ifa->cf->bfd)
|
|
|
|
ospf_neigh_update_bfd(n, n->ifa->bfd);
|
1999-11-17 15:50:41 +00:00
|
|
|
}
|
2014-04-29 08:22:25 +00:00
|
|
|
|
|
|
|
/* XXXX */
|
|
|
|
#ifdef OSPFv3 /* NOTE: this could also be relevant for OSPFv2 on PtP ifaces */
|
|
|
|
else if (!ipa_equal(faddr, n->ip))
|
|
|
|
{
|
|
|
|
OSPF_TRACE(D_EVENTS, "Neighbor address changed from %I to %I", n->ip, faddr);
|
|
|
|
n->ip = faddr;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-11-17 15:50:41 +00:00
|
|
|
ospf_neigh_sm(n, INM_HELLOREC);
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
two_way = 0;
|
|
|
|
for (i = 0; i < neigh_count; i++)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
if (ntohl(neighbors[i]) == po->router_id)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2000-05-10 23:42:13 +00:00
|
|
|
DBG("%s: Twoway received from %I\n", p->name, faddr);
|
1999-11-17 15:50:41 +00:00
|
|
|
ospf_neigh_sm(n, INM_2WAYREC);
|
2012-08-05 20:32:06 +00:00
|
|
|
two_way = 1;
|
1999-11-17 15:50:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-08-05 20:32:06 +00:00
|
|
|
if (!two_way)
|
2004-06-04 17:12:27 +00:00
|
|
|
ospf_neigh_sm(n, INM_1WAYREC);
|
1999-11-17 15:50:41 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
u32 old_dr = n->dr;
|
|
|
|
u32 old_bdr = n->bdr;
|
|
|
|
u32 old_priority = n->priority;
|
|
|
|
u32 old_iface_id = n->iface_id;
|
2009-08-21 07:27:52 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
n->dr = rcv_dr;
|
|
|
|
n->bdr = rcv_bdr;
|
|
|
|
n->priority = rcv_priority;
|
|
|
|
n->iface_id = rcv_iface_id;
|
2000-05-09 11:27:31 +00:00
|
|
|
|
1999-11-17 15:50:41 +00:00
|
|
|
/* Check priority change */
|
2004-06-04 17:12:27 +00:00
|
|
|
if (n->state >= NEIGHBOR_2WAY)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
u32 n_id = ospf_is_v2(po) ? ipa_to_u32(n->ip) : n->rid;
|
2009-08-21 07:27:52 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (n->priority != old_priority)
|
2004-06-06 08:12:42 +00:00
|
|
|
ospf_iface_sm(ifa, ISM_NEICH);
|
1999-11-17 15:50:41 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (n->iface_id != old_iface_id)
|
2009-08-21 07:27:52 +00:00
|
|
|
ospf_iface_sm(ifa, ISM_NEICH);
|
|
|
|
|
2009-12-11 00:20:53 +00:00
|
|
|
/* Neighbor is declaring itself ad DR and there is no BDR */
|
2012-08-05 20:32:06 +00:00
|
|
|
if ((n->dr == n_id) && (n->bdr == 0)
|
2004-06-04 17:12:27 +00:00
|
|
|
&& (n->state != NEIGHBOR_FULL))
|
2004-06-06 08:12:42 +00:00
|
|
|
ospf_iface_sm(ifa, ISM_BACKS);
|
1999-11-17 15:50:41 +00:00
|
|
|
|
2000-05-09 11:27:31 +00:00
|
|
|
/* Neighbor is declaring itself as BDR */
|
2012-08-05 20:32:06 +00:00
|
|
|
if ((n->bdr == n_id) && (n->state != NEIGHBOR_FULL))
|
2004-06-06 08:12:42 +00:00
|
|
|
ospf_iface_sm(ifa, ISM_BACKS);
|
2000-05-09 11:27:31 +00:00
|
|
|
|
|
|
|
/* Neighbor is newly declaring itself as DR or BDR */
|
2012-08-05 20:32:06 +00:00
|
|
|
if (((n->dr == n_id) && (n->dr != old_dr))
|
|
|
|
|| ((n->bdr == n_id) && (n->bdr != old_bdr)))
|
2004-06-06 08:12:42 +00:00
|
|
|
ospf_iface_sm(ifa, ISM_NEICH);
|
2000-05-09 11:27:31 +00:00
|
|
|
|
|
|
|
/* Neighbor is no more declaring itself as DR or BDR */
|
2012-08-05 20:32:06 +00:00
|
|
|
if (((old_dr == n_id) && (n->dr != old_dr))
|
|
|
|
|| ((old_bdr == n_id) && (n->bdr != old_bdr)))
|
2004-06-06 08:12:42 +00:00
|
|
|
ospf_iface_sm(ifa, ISM_NEICH);
|
1999-11-17 15:50:41 +00:00
|
|
|
}
|
|
|
|
|
2004-07-14 21:46:20 +00:00
|
|
|
if (ifa->type == OSPF_IT_NBMA)
|
2000-09-02 00:03:36 +00:00
|
|
|
{
|
2004-06-04 17:12:27 +00:00
|
|
|
if ((ifa->priority == 0) && (n->priority > 0))
|
2011-07-07 15:43:39 +00:00
|
|
|
ospf_hello_send(n->ifa, OHS_HELLO, n);
|
2000-09-02 00:03:36 +00:00
|
|
|
}
|
1999-11-17 15:50:41 +00:00
|
|
|
ospf_neigh_sm(n, INM_HELLOREC);
|
|
|
|
}
|
|
|
|
|
2000-09-02 00:03:36 +00:00
|
|
|
void
|
2011-07-07 15:43:39 +00:00
|
|
|
ospf_hello_send(struct ospf_iface *ifa, int kind, struct ospf_neighbor *dirn)
|
1999-11-17 15:50:41 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
struct proto_ospf *po = ifa->oa->po;
|
|
|
|
struct proto *p = &po->proto;
|
|
|
|
struct ospf_packet *pkt;
|
2004-06-25 16:39:53 +00:00
|
|
|
struct ospf_neighbor *neigh, *n1;
|
|
|
|
struct nbma_node *nb;
|
2012-08-05 20:32:06 +00:00
|
|
|
u32 *neighbors;
|
|
|
|
u16 length;
|
|
|
|
int i, max;
|
2004-07-15 16:37:52 +00:00
|
|
|
|
2010-11-19 12:46:21 +00:00
|
|
|
if (ifa->state <= OSPF_IS_LOOP)
|
2004-06-25 16:39:53 +00:00
|
|
|
return;
|
|
|
|
|
2004-06-04 17:12:27 +00:00
|
|
|
if (ifa->stub)
|
|
|
|
return; /* Don't send any packet on stub iface */
|
2000-09-02 08:54:40 +00:00
|
|
|
|
2010-03-14 15:36:59 +00:00
|
|
|
DBG("%s: Hello/Poll timer fired on interface %s with IP %I\n",
|
2014-04-29 08:22:25 +00:00
|
|
|
p->name, ifa->ifname, ifa->addr->ip);
|
1999-11-17 15:50:41 +00:00
|
|
|
|
2010-03-11 17:07:24 +00:00
|
|
|
pkt = ospf_tx_buffer(ifa);
|
2004-06-26 20:15:34 +00:00
|
|
|
ospf_pkt_fill_hdr(ifa, pkt, HELLO_P);
|
2000-06-05 23:44:26 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
if (ospf_is_v2(po))
|
|
|
|
{
|
|
|
|
struct ospf_hello2_packet *ps = (void *) pkt;
|
|
|
|
|
|
|
|
ps->netmask = htonl(u32_mkmask(ifa->addr->pxlen));
|
|
|
|
|
2013-05-22 22:16:19 +00:00
|
|
|
if ((ifa->type == OSPF_IT_VLINK) ||
|
|
|
|
((ifa->type == OSPF_IT_PTP) && !ifa->ptp_netmask))
|
2012-08-05 20:32:06 +00:00
|
|
|
ps->netmask = 0;
|
|
|
|
|
|
|
|
ps->helloint = ntohs(ifa->helloint);
|
|
|
|
ps->options = ifa->oa->options;
|
|
|
|
ps->priority = ifa->priority;
|
|
|
|
ps->deadint = htonl(ifa->deadint);
|
|
|
|
ps->dr = htonl(ipa_to_u32(ifa->drip));
|
|
|
|
ps->bdr = htonl(ipa_to_u32(ifa->bdrip));
|
|
|
|
|
|
|
|
length = sizeof(struct ospf_hello2_packet);
|
|
|
|
neighbors = ps->neighbors;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct ospf_hello3_packet *ps = (void *) pkt;
|
|
|
|
|
2013-01-12 23:17:49 +00:00
|
|
|
ps->iface_id = htonl(ifa->iface_id);
|
2012-08-05 20:32:06 +00:00
|
|
|
ps->priority = ifa->priority;
|
|
|
|
ps->options3 = ifa->oa->options >> 16;
|
|
|
|
ps->options2 = ifa->oa->options >> 8;
|
|
|
|
ps->options = ifa->oa->options;
|
|
|
|
ps->helloint = ntohs(ifa->helloint);
|
|
|
|
ps->deadint = htons(ifa->deadint);
|
|
|
|
ps->dr = htonl(ifa->drid);
|
|
|
|
ps->bdr = htonl(ifa->bdrid);
|
|
|
|
|
|
|
|
length = sizeof(struct ospf_hello3_packet);
|
|
|
|
neighbors = ps->neighbors;
|
|
|
|
}
|
2000-06-05 23:44:26 +00:00
|
|
|
|
2004-06-04 17:12:27 +00:00
|
|
|
i = 0;
|
2014-04-29 08:22:25 +00:00
|
|
|
max = (ospf_pkt_maxsize(ifa) - length) / sizeof(u32);
|
2011-03-17 14:53:36 +00:00
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
/* Fill all neighbors */
|
2011-03-17 14:53:36 +00:00
|
|
|
if (kind != OHS_SHUTDOWN)
|
2000-06-05 23:44:26 +00:00
|
|
|
{
|
2011-03-17 14:53:36 +00:00
|
|
|
WALK_LIST(neigh, ifa->neigh_list)
|
2004-06-26 20:15:34 +00:00
|
|
|
{
|
2012-08-05 20:32:06 +00:00
|
|
|
if (i == max)
|
2011-03-17 14:53:36 +00:00
|
|
|
{
|
2014-04-29 08:22:25 +00:00
|
|
|
log(L_WARN "%s: Too many neighbors on interface %s", p->name, ifa->ifname);
|
2011-03-17 14:53:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-08-05 20:32:06 +00:00
|
|
|
neighbors[i] = htonl(neigh->rid);
|
2011-03-17 14:53:36 +00:00
|
|
|
i++;
|
2004-06-26 20:15:34 +00:00
|
|
|
}
|
2000-06-05 23:44:26 +00:00
|
|
|
}
|
|
|
|
|
2012-08-05 20:32:06 +00:00
|
|
|
length += i * sizeof(u32);
|
|
|
|
pkt->length = htons(length);
|
2000-06-05 23:44:26 +00:00
|
|
|
|
2004-06-25 16:39:53 +00:00
|
|
|
switch(ifa->type)
|
2000-06-05 23:44:26 +00:00
|
|
|
{
|
2010-12-24 17:08:07 +00:00
|
|
|
case OSPF_IT_BCAST:
|
|
|
|
case OSPF_IT_PTP:
|
2012-05-14 09:47:41 +00:00
|
|
|
ospf_send_to_all(ifa);
|
2010-12-24 17:08:07 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OSPF_IT_NBMA:
|
2011-07-07 15:43:39 +00:00
|
|
|
if (dirn) /* Response to received hello */
|
2010-12-24 17:08:07 +00:00
|
|
|
{
|
|
|
|
ospf_send_to(ifa, dirn->ip);
|
2004-06-25 16:39:53 +00:00
|
|
|
break;
|
2010-12-24 17:08:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int to_all = ifa->state > OSPF_IS_DROTHER;
|
|
|
|
int me_elig = ifa->priority > 0;
|
|
|
|
|
2011-03-17 14:53:36 +00:00
|
|
|
if (kind == OHS_POLL) /* Poll timer */
|
2010-12-24 17:08:07 +00:00
|
|
|
{
|
|
|
|
WALK_LIST(nb, ifa->nbma_list)
|
|
|
|
if (!nb->found && (to_all || (me_elig && nb->eligible)))
|
|
|
|
ospf_send_to(ifa, nb->ip);
|
|
|
|
}
|
|
|
|
else /* Hello timer */
|
|
|
|
{
|
|
|
|
WALK_LIST(n1, ifa->neigh_list)
|
|
|
|
if (to_all || (me_elig && (n1->priority > 0)) ||
|
|
|
|
(n1->rid == ifa->drid) || (n1->rid == ifa->bdrid))
|
|
|
|
ospf_send_to(ifa, n1->ip);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSPF_IT_PTMP:
|
|
|
|
WALK_LIST(n1, ifa->neigh_list)
|
|
|
|
ospf_send_to(ifa, n1->ip);
|
|
|
|
|
|
|
|
WALK_LIST(nb, ifa->nbma_list)
|
|
|
|
if (!nb->found)
|
|
|
|
ospf_send_to(ifa, nb->ip);
|
|
|
|
|
|
|
|
/* If there is no other target, we also send HELLO packet to the other end */
|
|
|
|
if (ipa_nonzero(ifa->addr->opposite) && !ifa->strictnbma &&
|
|
|
|
EMPTY_LIST(ifa->neigh_list) && EMPTY_LIST(ifa->nbma_list))
|
|
|
|
ospf_send_to(ifa, ifa->addr->opposite);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OSPF_IT_VLINK:
|
|
|
|
ospf_send_to(ifa, ifa->vip);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bug("Bug in ospf_hello_send()");
|
2000-06-05 23:44:26 +00:00
|
|
|
}
|
2009-04-06 14:17:47 +00:00
|
|
|
|
2014-04-29 08:22:25 +00:00
|
|
|
OSPF_TRACE(D_PACKETS, "HELLO packet sent via %s", ifa->ifname);
|
1999-11-17 15:50:41 +00:00
|
|
|
}
|