Commit f9c799a0 authored by Ondřej Zajíček's avatar Ondřej Zajíček

Temporary OSPFv3 development commit (changing multicast support).

parent d2ceaf4e
......@@ -50,7 +50,15 @@ int sk_send_to(sock *, unsigned len, ip_addr to, unsigned port); /* sk_send to g
void sk_reallocate(sock *); /* Free and allocate tbuf & rbuf */
void sk_dump_all(void);
int sk_set_ttl(sock *s, int ttl); /* Set TTL for given socket */
int sk_set_md5_auth(sock *s, ip_addr a, char *passwd); /* Add or remove security associations for given passive socket */
/* Add or remove security associations for given passive socket */
int sk_set_md5_auth(sock *s, ip_addr a, char *passwd);
/* Prepare UDP or IP socket to multicasting. s->iface and s->ttl must be set */
int sk_setup_multicast(sock *s);
int sk_join_group(sock *s, ip_addr maddr);
int sk_leave_group(sock *s, ip_addr maddr);
static inline int
sk_send_buffer_empty(sock *sk)
......@@ -72,9 +80,7 @@ sk_send_buffer_empty(sock *sk)
#define SK_TCP_ACTIVE 1 /* ? ? * * - ? - */
#define SK_TCP 2
#define SK_UDP 3 /* ? ? - - - ? ? */
#define SK_UDP_MC 4 /* ? ? * * * * - */
#define SK_IP 5 /* ? - - * - ? ? */
#define SK_IP_MC 6 /* ? - * * * * - */
#define SK_MAGIC 7 /* Internal use by sysdep code */
#define SK_UNIX_PASSIVE 8
#define SK_UNIX 9
......
......@@ -93,7 +93,7 @@ ospf_dbdes_send(struct ospf_neighbor *n, int next)
{
case NEIGHBOR_EXSTART: /* Send empty packets */
n->myimms.bit.i = 1;
pkt = (struct ospf_dbdes_packet *) (ifa->ip_sk->tbuf);
pkt = (struct ospf_dbdes_packet *) (ifa->sk->tbuf);
op = (struct ospf_packet *) pkt;
ospf_pkt_fill_hdr(ifa, pkt, DBDES_P);
pkt->iface_mtu = htons(ifa->iface->mtu);
......@@ -104,7 +104,7 @@ ospf_dbdes_send(struct ospf_neighbor *n, int next)
op->length = htons(length);
OSPF_PACKET(ospf_dump_dbdes, pkt, "DBDES packet sent to %I via %s", n->ip, ifa->iface->name);
ospf_send_to(ifa->ip_sk, n->ip, ifa);
ospf_send_to(ifa, n->ip);
break;
case NEIGHBOR_EXCHANGE:
......@@ -185,11 +185,11 @@ ospf_dbdes_send(struct ospf_neighbor *n, int next)
}
/* Copy last sent packet again */
memcpy(ifa->ip_sk->tbuf, n->ldbdes, length);
memcpy(ifa->sk->tbuf, n->ldbdes, length);
OSPF_PACKET(ospf_dump_dbdes, (struct ospf_dbdes_packet *) ifa->ip_sk->tbuf,
OSPF_PACKET(ospf_dump_dbdes, (struct ospf_dbdes_packet *) ifa->sk->tbuf,
"DBDES packet sent to %I via %s", n->ip, ifa->iface->name);
ospf_send_to(ifa->ip_sk, n->ip, n->ifa);
ospf_send_to(ifa, n->ip);
if(n->myimms.bit.ms) tm_start(n->rxmt_timer, n->ifa->rxmtint); /* Restart timer */
......
......@@ -56,7 +56,7 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
(ifa->type == OSPF_IT_VLINK ? "vlink-" : ""), ifa->iface->name);
#ifdef OSPFv2
mask = ps->netmask;
ip_addr mask = ps->netmask;
ipa_ntoh(mask);
if (ifa->type != OSPF_IT_VLINK)
{
......@@ -198,7 +198,7 @@ ospf_hello_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
if (n->state >= NEIGHBOR_2WAY)
{
#ifdef OSPFv2
u32 rid = n->ip;
u32 rid = ipa_to_u32(n->ip);
#else /* OSPFv3 */
u32 rid = p->cf->global->router_id;
#endif
......@@ -266,20 +266,12 @@ ospf_hello_send(timer *timer, int poll, struct ospf_neighbor *dirn)
p = (struct proto *) (ifa->oa->po);
DBG("%s: Hello/Poll timer fired on interface %s.\n",
p->name, ifa->iface->name);
/* Now we should send a hello packet */
/* First a common packet header */
if ((ifa->type == OSPF_IT_NBMA) || (ifa->type == OSPF_IT_VLINK))
{
pkt = (struct ospf_hello_packet *) (ifa->ip_sk->tbuf);
}
else
{
pkt = (struct ospf_hello_packet *) (ifa->hello_sk->tbuf);
}
/* Now fill ospf_hello header */
/* Now we should send a hello packet */
pkt = (struct ospf_hello_packet *) (ifa->sk->tbuf);
op = (struct ospf_packet *) pkt;
/* Now fill ospf_hello header */
ospf_pkt_fill_hdr(ifa, pkt, HELLO_P);
#ifdef OSPFv2
......@@ -332,7 +324,7 @@ ospf_hello_send(timer *timer, int poll, struct ospf_neighbor *dirn)
case OSPF_IT_NBMA:
if (timer == NULL) /* Response to received hello */
{
ospf_send_to(ifa->ip_sk, dirn->ip, ifa);
ospf_send_to(ifa, dirn->ip);
}
else
{
......@@ -357,7 +349,7 @@ ospf_hello_send(timer *timer, int poll, struct ospf_neighbor *dirn)
if ((poll == 1) && (send))
{
if (toall || (meeli && nb->eligible))
ospf_send_to(ifa->ip_sk, nb->ip, ifa);
ospf_send_to(ifa, nb->ip);
}
}
if (poll == 0)
......@@ -366,16 +358,16 @@ ospf_hello_send(timer *timer, int poll, struct ospf_neighbor *dirn)
{
if (toall || (n1->rid == ifa->drid) || (n1->rid == ifa->bdrid) ||
(meeli && (n1->priority > 0)))
ospf_send_to(ifa->ip_sk, n1->ip, ifa);
ospf_send_to(ifa, n1->ip);
}
}
}
break;
case OSPF_IT_VLINK:
ospf_send_to(ifa->ip_sk, ifa->vip, ifa);
ospf_send_to(ifa, ifa->vip);
break;
default:
ospf_send_to(ifa->hello_sk, IPA_NONE, ifa);
ospf_send_to(ifa, AllSPFRouters);
}
OSPF_TRACE(D_PACKETS, "HELLO packet sent via %s%s",
......
......@@ -59,7 +59,7 @@ rxbufsize(struct ospf_iface *ifa)
}
static sock *
ospf_open_ip_socket(struct ospf_iface *ifa)
ospf_open_socket(struct ospf_iface *ifa, int mc)
{
sock *ipsk;
struct proto *p = &ifa->oa->po->proto;
......@@ -69,7 +69,8 @@ ospf_open_ip_socket(struct ospf_iface *ifa)
ipsk->dport = OSPF_PROTO;
#ifdef OSPFv2
ipsk->saddr = ifa->iface->addr->ip;
// ipsk->saddr = ifa->iface->addr->ip;
ipsk->saddr = IPA_NONE;
#else /* OSPFv3 */
ipsk->saddr = ifa->lladdr;
#endif
......@@ -86,12 +87,22 @@ ospf_open_ip_socket(struct ospf_iface *ifa)
ipsk->tbsize = ifa->iface->mtu;
ipsk->data = (void *) ifa;
if (sk_open(ipsk) != 0)
goto err;
if (mc)
{
DBG("%s: SK_OPEN: ip open failed.\n", p->name);
return (NULL);
if (sk_setup_multicast(ipsk) < 0)
goto err;
if (sk_join_group(ipsk, AllSPFRouters) < 0)
goto err;
}
DBG("%s: SK_OPEN: ip opened.\n", p->name);
return (ipsk);
return ipsk;
err:
rfree(ipsk);
return NULL;
}
......@@ -122,7 +133,7 @@ ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
ifa->vid, ospf_is[oldstate], ospf_is[state]);
if (state == OSPF_IS_PTP)
{
ifa->ip_sk = ospf_open_ip_socket(ifa);
ifa->sk = ospf_open_socket(ifa, 0);
}
}
else
......@@ -132,43 +143,17 @@ ospf_iface_chstate(struct ospf_iface *ifa, u8 state)
ifa->iface->name, ospf_is[oldstate], ospf_is[state]);
if (ifa->iface->flags & IF_MULTICAST)
{
if ((state == OSPF_IS_BACKUP) || (state == OSPF_IS_DR))
if ((ifa->type != OSPF_IT_NBMA) && (ifa->ioprob == OSPF_I_OK) &&
((state == OSPF_IS_BACKUP) || (state == OSPF_IS_DR)))
{
if ((ifa->dr_sk == NULL) && (ifa->type != OSPF_IT_NBMA))
{
DBG("%s: Adding new multicast socket for (B)DR\n", p->name);
ifa->dr_sk = sk_new(p->pool);
ifa->dr_sk->type = SK_IP_MC;
ifa->dr_sk->sport = 0;
ifa->dr_sk->dport = OSPF_PROTO;
#ifdef OSPFv2
ifa->dr_sk->saddr = AllDRouters;
#else /* OSPFv3 */
// ifa->dr_sk->saddr = AllDRouters;
ifa->dr_sk->saddr = ifa->lladdr;
#endif
ifa->dr_sk->daddr = AllDRouters;
ifa->dr_sk->tos = IP_PREC_INTERNET_CONTROL;
ifa->dr_sk->ttl = 1;
ifa->dr_sk->rx_hook = ospf_rx_hook;
ifa->dr_sk->tx_hook = ospf_tx_hook;
ifa->dr_sk->err_hook = ospf_err_hook;
ifa->dr_sk->iface = ifa->iface;
ifa->dr_sk->rbsize = rxbufsize(ifa);
ifa->dr_sk->tbsize = ifa->iface->mtu;
ifa->dr_sk->data = (void *) ifa;
if (sk_open(ifa->dr_sk) != 0)
{
DBG("%s: SK_OPEN: new? mc open failed.\n", p->name);
}
}
/* FIXME some error handing ? */
sk_join_group(ifa->sk, AllDRouters);
ifa->dr_up = 1;
}
else
else if (ifa->dr_up)
{
rfree(ifa->dr_sk);
ifa->dr_sk = NULL;
sk_leave_group(ifa->sk, AllDRouters);
ifa->dr_up = 0;
}
if ((oldstate == OSPF_IS_DR) && (ifa->net_lsa != NULL))
{
......@@ -209,13 +194,12 @@ ospf_iface_down(struct ospf_iface *ifa)
OSPF_TRACE(D_EVENTS, "Removing neighbor %I", n->ip);
ospf_neigh_remove(n);
}
rfree(ifa->hello_sk);
rfree(ifa->dr_sk);
rfree(ifa->ip_sk);
rfree(ifa->sk);
ifa->sk = NULL;
if (ifa->type == OSPF_IT_VLINK)
{
ifa->ip_sk = NULL;
ifa->iface = NULL;
return;
}
......@@ -311,6 +295,7 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
}
#if 0
static sock *
ospf_open_mc_socket(struct ospf_iface *ifa)
{
......@@ -347,6 +332,7 @@ ospf_open_mc_socket(struct ospf_iface *ifa)
DBG("%s: SK_OPEN: mc opened.\n", p->name);
return (mcsk);
}
#endif
u8
ospf_iface_clasify(struct iface * ifa)
......@@ -383,20 +369,8 @@ ospf_iface_add(struct object_lock *lock)
ifa->ioprob = OSPF_I_OK;
if (ifa->type != OSPF_IT_NBMA)
{
if ((ifa->hello_sk = ospf_open_mc_socket(ifa)) == NULL)
{
log("%s: Huh? could not open mc socket on interface %s?", p->name,
iface->name);
log("%s: Declaring as stub.", p->name);
ifa->stub = 1;
ifa->ioprob += OSPF_I_MC;
}
ifa->dr_sk = NULL;
}
if ((ifa->ip_sk = ospf_open_ip_socket(ifa)) == NULL)
ifa->sk = ospf_open_socket(ifa, ifa->type != OSPF_IT_NBMA);
if (ifa->sk == NULL)
{
log("%s: Huh? could not open ip socket on interface %s?", p->name,
iface->name);
......@@ -546,23 +520,12 @@ ospf_iface_change_mtu(struct proto_ospf *po, struct ospf_iface *ifa)
struct ospf_packet *op;
struct ospf_neighbor *n;
OSPF_TRACE(D_EVENTS, "Changing MTU on interface %s.", ifa->iface->name);
if (ifa->hello_sk)
{
ifa->hello_sk->rbsize = rxbufsize(ifa);
ifa->hello_sk->tbsize = ifa->iface->mtu;
sk_reallocate(ifa->hello_sk);
}
if (ifa->dr_sk)
{
ifa->dr_sk->rbsize = rxbufsize(ifa);
ifa->dr_sk->tbsize = ifa->iface->mtu;
sk_reallocate(ifa->dr_sk);
}
if (ifa->ip_sk)
if (ifa->sk)
{
ifa->ip_sk->rbsize = rxbufsize(ifa);
ifa->ip_sk->tbsize = ifa->iface->mtu;
sk_reallocate(ifa->ip_sk);
ifa->sk->rbsize = rxbufsize(ifa);
ifa->sk->tbsize = ifa->iface->mtu;
sk_reallocate(ifa->sk);
}
WALK_LIST(n, ifa->neigh_list)
......
......@@ -57,7 +57,6 @@ ospf_lsack_send(struct ospf_neighbor *n, int queue)
{
struct ospf_packet *op;
struct ospf_lsack_packet *pk;
sock *sk;
u16 len, i = 0;
struct ospf_lsa_header *h;
struct lsah_n *no;
......@@ -67,13 +66,8 @@ ospf_lsack_send(struct ospf_neighbor *n, int queue)
if (EMPTY_LIST(n->ackl[queue]))
return;
if (ifa->type == OSPF_IT_BCAST)
sk = ifa->hello_sk;
else
sk = ifa->ip_sk;
pk = (struct ospf_lsack_packet *) sk->tbuf;
op = (struct ospf_packet *) sk->tbuf;
pk = (struct ospf_lsack_packet *) ifa->sk->tbuf;
op = (struct ospf_packet *) ifa->sk->tbuf;
ospf_pkt_fill_hdr(n->ifa, pk, LSACK_P);
h = pk->lsh;
......@@ -98,22 +92,22 @@ ospf_lsack_send(struct ospf_neighbor *n, int queue)
op->length = htons(len);
DBG("Sending and continuing! Len=%u\n", len);
OSPF_PACKET(ospf_dump_lsack, (struct ospf_lsack_packet *) sk->tbuf,
OSPF_PACKET(ospf_dump_lsack, (struct ospf_lsack_packet *) ifa->sk->tbuf,
"LSACK packet sent via %s", ifa->iface->name);
if (ifa->type == OSPF_IT_BCAST)
{
if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
ospf_send_to(sk, AllSPFRouters, ifa);
ospf_send_to(ifa, AllSPFRouters);
else
ospf_send_to(sk, AllDRouters, ifa);
ospf_send_to(ifa, AllDRouters);
}
else
{
if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
ospf_send_to_agt(sk, ifa, NEIGHBOR_EXCHANGE);
ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE);
else
ospf_send_to_bdr(sk, ifa);
ospf_send_to_bdr(ifa);
}
ospf_pkt_fill_hdr(n->ifa, pk, LSACK_P);
......@@ -126,24 +120,18 @@ ospf_lsack_send(struct ospf_neighbor *n, int queue)
op->length = htons(len);
DBG("Sending! Len=%u\n", len);
OSPF_PACKET(ospf_dump_lsack, (struct ospf_lsack_packet *) sk->tbuf,
OSPF_PACKET(ospf_dump_lsack, (struct ospf_lsack_packet *) ifa->sk->tbuf,
"LSACK packet sent via %s", ifa->iface->name);
if (ifa->type == OSPF_IT_BCAST)
{
if ((ifa->state == OSPF_IS_DR) || (ifa->state == OSPF_IS_BACKUP))
{
ospf_send_to(sk, AllSPFRouters, ifa);
}
ospf_send_to(ifa, AllSPFRouters);
else
{
ospf_send_to(sk, AllDRouters, ifa);
}
ospf_send_to(ifa, AllDRouters);
}
else
{
ospf_send_to_agt(sk, ifa, NEIGHBOR_EXCHANGE);
}
ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE);
}
void
......
......@@ -126,6 +126,7 @@ void
htonlsab(void *h, void *n, u16 type, u16 len)
{
unsigned int i;
switch (type)
{
case LSA_T_RT:
......@@ -138,10 +139,9 @@ htonlsab(void *h, void *n, u16 type, u16 len)
hrt = h;
#ifdef OSPFv2
nrt->veb.byte = hrt->veb.byte;
nrt->padding = 0;
nrt->links = htons(hrt->links);
links = hrt->links;
nrt->options = htons(hrt->options);
nrt->links = htons(hrt->links);
#else /* OSPFv3 */
nrt->options = htonl(hrt->options);
links = (len - sizeof(struct ospf_lsa_rt)) /
......@@ -211,8 +211,7 @@ ntohlsab(void *n, void *h, u16 type, u16 len)
hrt = h;
#ifdef OSPFv2
hrt->veb.byte = nrt->veb.byte;
hrt->padding = 0;
hrt->options = ntohs(nrt->options);
links = hrt->links = ntohs(nrt->links);
#else /* OSPFv3 */
hrt->options = ntohl(nrt->options);
......@@ -308,19 +307,20 @@ lsasum_calculate(struct ospf_lsa_header *h, void *body)
u16 length = h->length;
u16 type = h->type;
log(L_WARN "Checksum %R %R %d start (len %d)", h->id, h->rt, h->type, length);
// log(L_WARN "Checksum %R %R %d start (len %d)", h->id, h->rt, h->type, length);
htonlsah(h, h);
htonlsab(body, body, type, length - sizeof(struct ospf_lsa_header));
/*
char buf[1024];
memcpy(buf, h, sizeof(struct ospf_lsa_header));
memcpy(buf + sizeof(struct ospf_lsa_header), body, length - sizeof(struct ospf_lsa_header));
buf_dump("CALC", buf, length);
*/
(void) lsasum_check(h, body);
log(L_WARN "Checksum result %4x", h->checksum);
// log(L_WARN "Checksum result %4x", h->checksum);
ntohlsah(h, h);
ntohlsab(body, body, type, length - sizeof(struct ospf_lsa_header));
......
......@@ -28,8 +28,8 @@ static void ospf_dump_lsreq(struct proto *p, struct ospf_lsreq_packet *pkt)
sizeof(struct ospf_lsreq_header);
for (i = 0; i < j; i++)
log(L_TRACE "%s: LSR Id: %R, Rt: %R, Type: %u", p->name,
htonl(pkt->lsh[i].id), htonl(pkt->lsh[i].rt), pkt->lsh[i].type);
log(L_TRACE "%s: LSR Id: %R, Rt: %R, Type: 0x%x", p->name,
htonl(pkt->lsh[i].id), htonl(pkt->lsh[i].rt), htonl(pkt->lsh[i].type));
}
void
......@@ -44,8 +44,8 @@ ospf_lsreq_send(struct ospf_neighbor *n)
int i, j;
struct proto *p = &n->ifa->oa->po->proto;
pk = (struct ospf_lsreq_packet *) n->ifa->ip_sk->tbuf;
op = (struct ospf_packet *) n->ifa->ip_sk->tbuf;
pk = (struct ospf_lsreq_packet *) n->ifa->sk->tbuf;
op = (struct ospf_packet *) n->ifa->sk->tbuf;
ospf_pkt_fill_hdr(n->ifa, pk, LSREQ_P);
......@@ -82,9 +82,9 @@ ospf_lsreq_send(struct ospf_neighbor *n)
i) * sizeof(struct ospf_lsreq_header);
op->length = htons(length);
OSPF_PACKET(ospf_dump_lsreq, (struct ospf_lsreq_packet *) n->ifa->ip_sk->tbuf,
OSPF_PACKET(ospf_dump_lsreq, (struct ospf_lsreq_packet *) n->ifa->sk->tbuf,
"LSREQ packet sent to %I via %s", n->ip, n->ifa->iface->name);
ospf_send_to(n->ifa->ip_sk, n->ip, n->ifa);
ospf_send_to(n->ifa, n->ip);
}
void
......
......@@ -21,7 +21,7 @@ void ospf_dump_lsahdr(struct proto *p, struct ospf_lsa_header *lsa_n)
struct ospf_lsa_header lsa;
ntohlsah(lsa_n, &lsa);
log(L_TRACE "%s: LSA Id: %R, Rt: %R, Type: %u, Age: %u, Seqno: 0x%08x, Sum: %u",
log(L_TRACE "%s: LSA Id: %R, Rt: %R, Type: 0x%04x, Age: %u, Seqno: 0x%08x, Sum: 0x%04x",
p->name, lsa.id, lsa.rt, lsa.type, lsa.age, lsa.sn, lsa.checksum);
}
......@@ -70,7 +70,7 @@ ospf_lsa_flooding_allowed(struct ospf_lsa_header *lsa, u32 domain, struct ospf_i
return 0;
if (ifa->oa->stub)
return 0;
return 1
return 1;
}
else
return ifa->oa->areaid == domain;
......@@ -262,19 +262,13 @@ ospf_lsupd_flood(struct proto_ospf *po,
}
{
sock *sk;
u16 len, age;
struct ospf_lsupd_packet *pk;
struct ospf_packet *op;
struct ospf_lsa_header *lh;
if ((ifa->type == OSPF_IT_NBMA) || (ifa->type == OSPF_IT_VLINK))
sk = ifa->ip_sk;
else
sk = ifa->hello_sk;
pk = (struct ospf_lsupd_packet *) sk->tbuf;
op = (struct ospf_packet *) sk->tbuf;
pk = (struct ospf_lsupd_packet *) ifa->sk->tbuf;
op = (struct ospf_packet *) ifa->sk->tbuf;
ospf_pkt_fill_hdr(ifa, pk, LSUPD_P);
pk->lsano = htonl(1);
......@@ -308,28 +302,28 @@ ospf_lsupd_flood(struct proto_ospf *po,
op->length = htons(len);
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) sk->tbuf,
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) ifa->sk->tbuf,
"LSUPD packet flooded via %s", ifa->iface->name);
switch (ifa->type)
{
case OSPF_IT_NBMA:
if ((ifa->state == OSPF_IS_BACKUP) || (ifa->state == OSPF_IS_DR))
ospf_send_to_agt(sk, ifa, NEIGHBOR_EXCHANGE);
ospf_send_to_agt(ifa, NEIGHBOR_EXCHANGE);
else
ospf_send_to_bdr(sk, ifa);
ospf_send_to_bdr(ifa);
break;
case OSPF_IT_VLINK:
ospf_send_to(sk, ifa->vip, ifa);
ospf_send_to(ifa, ifa->vip);
break;
default:
if ((ifa->state == OSPF_IS_BACKUP) || (ifa->state == OSPF_IS_DR) ||
(ifa->type == OSPF_IT_PTP))
ospf_send_to(sk, AllSPFRouters, ifa);
ospf_send_to(ifa, AllSPFRouters);
else
ospf_send_to(sk, AllDRouters, ifa);
ospf_send_to(ifa, AllDRouters);
}
}
}
......@@ -353,8 +347,8 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
if (EMPTY_LIST(*l))
return;
pk = (struct ospf_lsupd_packet *) n->ifa->ip_sk->tbuf;
op = (struct ospf_packet *) n->ifa->ip_sk->tbuf;
pk = (struct ospf_lsupd_packet *) n->ifa->sk->tbuf;
op = (struct ospf_packet *) n->ifa->sk->tbuf;
DBG("LSupd: 1st packet\n");
......@@ -378,9 +372,9 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
pk->lsano = htonl(lsano);
op->length = htons(len);
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) n->ifa->ip_sk->tbuf,
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) n->ifa->sk->tbuf,
"LSUPD packet sent to %I via %s", n->ip, n->ifa->iface->name);
ospf_send_to(n->ifa->ip_sk, n->ip, n->ifa);
ospf_send_to(n->ifa, n->ip);
DBG("LSupd: next packet\n");
ospf_pkt_fill_hdr(n->ifa, pk, LSUPD_P);
......@@ -401,9 +395,9 @@ ospf_lsupd_send_list(struct ospf_neighbor *n, list * l)
pk->lsano = htonl(lsano);
op->length = htons(len);
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) n->ifa->ip_sk->tbuf,
OSPF_PACKET(ospf_dump_lsupd, (struct ospf_lsupd_packet *) n->ifa->sk->tbuf,
"LSUPD packet sent to %I via %s", n->ip, n->ifa->iface->name);
ospf_send_to(n->ifa->ip_sk, n->ip, n->ifa);
ospf_send_to(n->ifa, n->ip);
}
}
......
......@@ -478,8 +478,8 @@ bdr_election(struct ospf_iface *ifa)
|| ((ifa->bdrid != myid) && (nbdr == &me)))
{
#ifdef OSPFv2
me.dr = ndr ? ipa_to_u32(ndr->ip) : IPA_NONE;
me.bdr = nbdr ? ipa_to_u32(nbdr->ip) : IPA_NONE;
me.dr = ndr ? ipa_to_u32(ndr->ip) : 0;
me.bdr = nbdr ? ipa_to_u32(nbdr->ip) : 0;
#else /* OSPFv3 */
me.dr = ndr ? ndr->rid : 0;
me.bdr = nbdr ? nbdr->rid : 0;
......
......@@ -18,6 +18,7 @@
* normally allocate 2*mtu - (I found one cisco
* sending packets mtu+16)
*/
#define LOCAL_DEBUG 1
#ifdef LOCAL_DEBUG
#define OSPF_FORCE_DEBUG 1
#else
......@@ -161,9 +162,7 @@ struct ospf_iface
struct iface *iface; /* Nest's iface */
struct ospf_area *oa;
struct object_lock *lock;
sock *hello_sk; /* Hello socket */
sock *dr_sk; /* For states DR or BACKUP */
sock *ip_sk; /* IP socket (for DD ...) */
sock *sk; /* IP socket (for DD ...) */
list neigh_list; /* List of neigbours */
u32 cost; /* Cost of iface */
u32 waitint; /* number of sec before changing state from wait */
......@@ -241,6 +240,7 @@ struct ospf_iface
list nbma_list;
u8 priority; /* A router priority for DR election */
u8 ioprob;
u8 dr_up; /* Socket is a member of DRouters group */
u32 rxbuf;
};
......
......@@ -437,26 +437,27 @@ ospf_err_hook(sock * sk, int err)
}
void
ospf_send_to_agt(sock * sk, struct ospf_iface *ifa, u8 state)
ospf_send_to_agt(struct ospf_iface *ifa, u8 state)
{
struct ospf_neighbor *n;
WALK_LIST(n, ifa->neigh_list) if (n->state >= state)
ospf_send_to(sk, n->ip, ifa);
ospf_send_to(ifa, n->ip);
}
void
ospf_send_to_bdr(sock * sk, struct ospf_iface *ifa)
ospf_send_to_bdr(struct ospf_iface *ifa)
{
if (!ipa_equal(ifa->drip, IPA_NONE))
ospf_send_to(sk, ifa->drip, ifa);
ospf_send_to(ifa, ifa->drip);
if (!ipa_equal(ifa->bdrip, IPA_NONE))
ospf_send_to(sk, ifa->bdrip, ifa);
ospf_send_to(ifa, ifa->bdrip);
}
void
ospf_send_to(sock *sk, ip_addr ip, struct ospf_iface *ifa)
ospf_send_to(struct ospf_iface *ifa, ip_addr ip)
{
sock *sk = ifa->sk;
struct ospf_packet *pkt = (struct ospf_packet *) sk->tbuf;
int len = ntohs(pkt->length);
......
......@@ -15,9 +15,9 @@ unsigned ospf_pkt_maxsize(struct ospf_iface *ifa);
int ospf_rx_hook(sock * sk, int size);
void ospf_tx_hook(sock * sk);
void ospf_err_hook(sock * sk, int err);
void ospf_send_to_agt(sock * sk, struct ospf_iface *ifa, u8 state);
void ospf_send_to_bdr(sock * sk, struct ospf_iface *ifa);
void ospf_send_to(sock *sk, ip_addr ip, struct ospf_iface *ifa);
void ospf_send_to_agt(struct ospf_iface *ifa, u8 state);
void ospf_send_to_bdr(struct ospf_iface *ifa);
void ospf_send_to(struct ospf_iface *ifa, ip_addr ip);
#endif /* _BIRD_OSPF_PACKET_H_ */
......@@ -26,6 +26,8 @@ static void rt_sync(struct proto_ospf *po);
#endif
#ifdef OSPFv3
static inline u32 *
get_ipv6_prefix(u32 *buf, ip_addr *addr, int *pxlen, u8 *pxopts, u16 *rest)
{
......@@ -56,6 +58,9 @@ get_ipv6_addr(u32 *buf, ip_addr *addr)
return buf + 4;
}
#endif
static void
fill_ri(orta * orta)
{
......@@ -839,8 +844,8 @@ ospf_ext_spf(struct proto_ospf *po)
if (en->lsa.rt == p->cf->global->router_id)
continue;
DBG("%s: Working on LSA. ID: %R, RT: %R, Type: %u, Mask %I\n",
p->name, en->lsa.id, en->lsa.rt, en->lsa.type, le->netmask);
DBG("%s: Working on LSA. ID: %R, RT: %R, Type: %u\n",
p->name, en->lsa.id, en->lsa.rt, en->lsa.type);
le = en->lsa_body;
......@@ -1056,7 +1061,7 @@ static inline int
match_dr(struct ospf_iface *ifa, struct top_hash_entry *en)
{
#ifdef OSPFv2
return (ifa->drid == en->lsa.rt) && (ifa->drip == ipa_from_u32(en->lsa.id));
return (ifa->drid == en->lsa.rt) && (ipa_to_u32(ifa->drip) == en->lsa.id);
#else /* OSPFv3 */
return (ifa->drid == en->lsa.rt) && (ifa->dr_iface_id == en->lsa.id);