summaryrefslogtreecommitdiffstats
path: root/proto/ospf/lsreq.c
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2004-06-04 19:28:41 +0200
committerOndrej Filip <feela@network.cz>2004-06-04 19:28:41 +0200
commit27f49a2c3c2a86b4822ff1980d751666ed8cee97 (patch)
treeb80e89fc5bdfa4f514c0c2607008f870ca1bebc0 /proto/ospf/lsreq.c
parent77539c4471d4b3f19347d2efc99680f815e1c78a (diff)
downloadbird-27f49a2c3c2a86b4822ff1980d751666ed8cee97.tar
bird-27f49a2c3c2a86b4822ff1980d751666ed8cee97.zip
lsreq.c indented and small 'struct proto' changes.
Diffstat (limited to 'proto/ospf/lsreq.c')
-rw-r--r--proto/ospf/lsreq.c113
1 files changed, 58 insertions, 55 deletions
diff --git a/proto/ospf/lsreq.c b/proto/ospf/lsreq.c
index 3b5ac4b..0c63ed8 100644
--- a/proto/ospf/lsreq.c
+++ b/proto/ospf/lsreq.c
@@ -1,7 +1,7 @@
/*
* BIRD -- OSPF
*
- * (c) 2000 Ondrej Filip <feela@network.cz>
+ * (c) 2000--2004 Ondrej Filip <feela@network.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
@@ -9,7 +9,7 @@
#include "ospf.h"
void
-ospf_lsreq_tx(struct ospf_neighbor *n)
+ospf_lsreq_send(struct ospf_neighbor *n)
{
snode *sn;
struct top_hash_entry *en;
@@ -17,97 +17,101 @@ ospf_lsreq_tx(struct ospf_neighbor *n)
struct ospf_packet *op;
struct ospf_lsreq_header *lsh;
u16 length;
- int i,j;
- struct proto *p=&n->ifa->proto->proto;
+ int i, j;
+ struct proto *p = &n->ifa->proto->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->ip_sk->tbuf;
+ op = (struct ospf_packet *) n->ifa->ip_sk->tbuf;
fill_ospf_pkt_hdr(n->ifa, pk, LSREQ_P);
- sn=SHEAD(n->lsrql);
- if(EMPTY_SLIST(n->lsrql))
+ sn = SHEAD(n->lsrql);
+ if (EMPTY_SLIST(n->lsrql))
{
- if(n->state==NEIGHBOR_LOADING) ospf_neigh_sm(n, INM_LOADDONE);
+ if (n->state == NEIGHBOR_LOADING)
+ ospf_neigh_sm(n, INM_LOADDONE);
return;
}
-
- i=j=(n->ifa->iface->mtu-SIPH-sizeof(struct ospf_lsreq_packet))/
+
+ i = j = (n->ifa->iface->mtu - SIPH - sizeof(struct ospf_lsreq_packet)) /
sizeof(struct ospf_lsreq_header);
- lsh=(struct ospf_lsreq_header *)(pk+1);
-
- for(;i>0;i--)
+ lsh = (struct ospf_lsreq_header *) (pk + 1);
+
+ for (; i > 0; i--)
{
- en=(struct top_hash_entry *)sn;
- lsh->padd1=0; lsh->padd2=0;
- lsh->type=en->lsa.type;
- lsh->rt=htonl(en->lsa.rt);
- lsh->id=htonl(en->lsa.id);
- DBG("Requesting %uth LSA: Type: %u, Id: %I, RT: %I\n",i, en->lsa.type,
- en->lsa.id, en->lsa.rt);
+ en = (struct top_hash_entry *) sn;
+ lsh->padd1 = 0;
+ lsh->padd2 = 0;
+ lsh->type = en->lsa.type;
+ lsh->rt = htonl(en->lsa.rt);
+ lsh->id = htonl(en->lsa.id);
+ DBG("Requesting %uth LSA: Type: %u, Id: %I, RT: %I\n", i, en->lsa.type,
+ en->lsa.id, en->lsa.rt);
lsh++;
- if(sn==STAIL(n->lsrql)) break;
- sn=sn->next;
+ if (sn == STAIL(n->lsrql))
+ break;
+ sn = sn->next;
}
- if(i!=0) i--;
+ if (i != 0)
+ i--;
- length=sizeof(struct ospf_lsreq_packet)+(j-i)*sizeof(struct ospf_lsreq_header);
- op->length=htons(length);
+ length =
+ sizeof(struct ospf_lsreq_packet) + (j -
+ i) * sizeof(struct ospf_lsreq_header);
+ op->length = htons(length);
ospf_pkt_finalize(n->ifa, op);
- sk_send_to(n->ifa->ip_sk,length, n->ip, OSPF_PROTO);
+ sk_send_to(n->ifa->ip_sk, length, n->ip, OSPF_PROTO);
OSPF_TRACE(D_PACKETS, "LS request sent to: %I", n->rid);
}
void
-ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
- struct ospf_iface *ifa, u16 size)
+ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
+ struct ospf_iface *ifa, u16 size)
{
- u32 nrid, myrid;
+ u32 nrid;
struct ospf_neighbor *n;
struct ospf_lsreq_header *lsh;
struct l_lsr_head *llsh;
list uplist;
slab *upslab;
- int length;
- int i,lsano;
-
- nrid=ntohl(ps->ospf_packet.routerid);
+ int length, i, lsano;
+ struct proto *p = (struct proto *) ifa->proto;
- myrid=p->cf->global->router_id;
+ nrid = ntohl(ps->ospf_packet.routerid);
- if((n=find_neigh(ifa, nrid))==NULL)
+ if ((n = find_neigh(ifa, nrid)) == NULL)
{
- OSPF_TRACE(D_PACKETS, "Received lsreq from unknown neighbor! (%I)",
- nrid);
- return ;
+ OSPF_TRACE(D_PACKETS, "Received lsreq from unknown neighbor! (%I)", nrid);
+ return;
}
- if(n->state<NEIGHBOR_EXCHANGE) return;
+ if (n->state < NEIGHBOR_EXCHANGE)
+ return;
OSPF_TRACE(D_EVENTS, "Received LS req from neighbor: %I", n->ip);
ospf_neigh_sm(n, INM_HELLOREC);
- length=ntohs(ps->ospf_packet.length);
- lsh=(void *)(ps+1);
+ length = ntohs(ps->ospf_packet.length);
+ lsh = (void *) (ps + 1);
init_list(&uplist);
- upslab=sl_new(n->pool,sizeof(struct l_lsr_head));
+ upslab = sl_new(n->pool, sizeof(struct l_lsr_head));
- lsano=(length-sizeof(struct ospf_lsreq_packet))/
+ lsano = (length - sizeof(struct ospf_lsreq_packet)) /
sizeof(struct ospf_lsreq_header);
- for(i=0;i<lsano;lsh++,i++)
+ for (i = 0; i < lsano; lsh++, i++)
{
DBG("Processing LSA: ID=%I, Type=%u, Router=%I\n", ntohl(lsh->id),
- lsh->type, ntohl(lsh->rt));
- llsh=sl_alloc(upslab);
- llsh->lsh.id=ntohl(lsh->id);
- llsh->lsh.rt=ntohl(lsh->rt);
- llsh->lsh.type=lsh->type;
+ lsh->type, ntohl(lsh->rt));
+ llsh = sl_alloc(upslab);
+ llsh->lsh.id = ntohl(lsh->id);
+ llsh->lsh.rt = ntohl(lsh->rt);
+ llsh->lsh.type = lsh->type;
add_tail(&uplist, NODE llsh);
- if(ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt,
- llsh->lsh.type)==NULL)
+ if (ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt,
+ llsh->lsh.type) == NULL)
{
log("Received bad LS req from: %I looking: RT: %I, ID: %I, Type: %u",
- n->ip, lsh->rt, lsh->id, lsh->type);
- ospf_neigh_sm(n,INM_BADLSREQ);
+ n->ip, lsh->rt, lsh->id, lsh->type);
+ ospf_neigh_sm(n, INM_BADLSREQ);
rfree(upslab);
return;
}
@@ -115,4 +119,3 @@ ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
ospf_lsupd_tx_list(n, &uplist);
rfree(upslab);
}
-