summaryrefslogtreecommitdiff
path: root/proto/ospf/lsreq.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-08-21 09:27:52 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2009-08-21 09:27:52 +0200
commitc3226991a061415fa83b757cbff678111c586e58 (patch)
treeecbc7e7a5a2724463e2672bf8a3d1f64956467c0 /proto/ospf/lsreq.c
parent3aab39f589c352e30e9db92346b579dd561482b3 (diff)
Temporary OSPFv3 development commit
Diffstat (limited to 'proto/ospf/lsreq.c')
-rw-r--r--proto/ospf/lsreq.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/proto/ospf/lsreq.c b/proto/ospf/lsreq.c
index 5eeb06f0..cc5afa0f 100644
--- a/proto/ospf/lsreq.c
+++ b/proto/ospf/lsreq.c
@@ -8,6 +8,14 @@
#include "ospf.h"
+
+struct ospf_lsreq_packet
+{
+ struct ospf_packet ospf_packet;
+ struct ospf_lsreq_header lsh[];
+};
+
+
static void ospf_dump_lsreq(struct proto *p, struct ospf_lsreq_packet *pkt)
{
struct ospf_packet *op = &pkt->ospf_packet;
@@ -15,15 +23,13 @@ static void ospf_dump_lsreq(struct proto *p, struct ospf_lsreq_packet *pkt)
ASSERT(op->type == LSREQ_P);
ospf_dump_common(p, op);
- struct ospf_lsreq_header *plsr = (void *) (pkt + 1);
int i, j;
-
- j = (ntohs(op->length) - sizeof(struct ospf_dbdes_packet)) /
+ j = (ntohs(op->length) - sizeof(struct ospf_lsreq_packet)) /
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(plsr[i].id), htonl(plsr[i].rt), plsr[i].type);
+ 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);
}
void
@@ -53,14 +59,12 @@ ospf_lsreq_send(struct ospf_neighbor *n)
i = j = (ospf_pkt_maxsize(n->ifa) - sizeof(struct ospf_lsreq_packet)) /
sizeof(struct ospf_lsreq_header);
- lsh = (struct ospf_lsreq_header *) (pk + 1);
+ lsh = pk->lsh;
for (; i > 0; i--)
{
en = (struct top_hash_entry *) sn;
- lsh->padd1 = 0;
- lsh->padd2 = 0;
- lsh->type = en->lsa.type;
+ lsh->type = htonl(en->lsa.type);
lsh->rt = htonl(en->lsa.rt);
lsh->id = htonl(en->lsa.id);
DBG("Requesting %uth LSA: Type: %u, ID: %R, RT: %R, SN: 0x%x, Age %u\n",
@@ -84,9 +88,10 @@ ospf_lsreq_send(struct ospf_neighbor *n)
}
void
-ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
- struct ospf_iface *ifa, struct ospf_neighbor *n)
+ospf_lsreq_receive(struct ospf_packet *ps_i, struct ospf_iface *ifa,
+ struct ospf_neighbor *n)
{
+ struct ospf_lsreq_packet *ps = (void *) ps_i;
struct ospf_lsreq_header *lsh;
struct l_lsr_head *llsh;
list uplist;
@@ -104,7 +109,7 @@ ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
ospf_neigh_sm(n, INM_HELLOREC);
- lsh = (void *) (ps + 1);
+ lsh = ps->lsh;
init_list(&uplist);
upslab = sl_new(n->pool, sizeof(struct l_lsr_head));
@@ -114,18 +119,19 @@ ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
{
u32 hid = ntohl(lsh->id);
u32 hrt = ntohl(lsh->rt);
+ u32 htype = ntohl(lsh->type);
+ u32 dom = ospf_lsa_domain(htype, ifa);
DBG("Processing requested LSA: Type: %u, ID: %R, RT: %R\n", lsh->type, hid, hrt);
llsh = sl_alloc(upslab);
llsh->lsh.id = hid;
llsh->lsh.rt = hrt;
- llsh->lsh.type = lsh->type;
+ llsh->lsh.type = htype;
add_tail(&uplist, NODE llsh);
- if (ospf_hash_find(po->gr, oa->areaid, llsh->lsh.id, llsh->lsh.rt,
- llsh->lsh.type) == NULL)
+ if (ospfxx_hash_find(po->gr, dom, hid, hrt, htype) == NULL)
{
log(L_WARN
"Received bad LS req from: %I looking: Type: %u, ID: %R, RT: %R",
- n->ip, lsh->type, hid, hrt);
+ n->ip, htype, hid, hrt);
ospf_neigh_sm(n, INM_BADLSREQ);
rfree(upslab);
return;