mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
lsreq.c indented and small 'struct proto' changes.
This commit is contained in:
parent
77539c4471
commit
27f49a2c3c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* 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.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#include "ospf.h"
|
#include "ospf.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
ospf_lsreq_tx(struct ospf_neighbor *n)
|
ospf_lsreq_send(struct ospf_neighbor *n)
|
||||||
{
|
{
|
||||||
snode *sn;
|
snode *sn;
|
||||||
struct top_hash_entry *en;
|
struct top_hash_entry *en;
|
||||||
@ -17,97 +17,101 @@ ospf_lsreq_tx(struct ospf_neighbor *n)
|
|||||||
struct ospf_packet *op;
|
struct ospf_packet *op;
|
||||||
struct ospf_lsreq_header *lsh;
|
struct ospf_lsreq_header *lsh;
|
||||||
u16 length;
|
u16 length;
|
||||||
int i,j;
|
int i, j;
|
||||||
struct proto *p=&n->ifa->proto->proto;
|
struct proto *p = &n->ifa->proto->proto;
|
||||||
|
|
||||||
pk=(struct ospf_lsreq_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;
|
op = (struct ospf_packet *) n->ifa->ip_sk->tbuf;
|
||||||
|
|
||||||
fill_ospf_pkt_hdr(n->ifa, pk, LSREQ_P);
|
fill_ospf_pkt_hdr(n->ifa, pk, LSREQ_P);
|
||||||
|
|
||||||
sn=SHEAD(n->lsrql);
|
sn = SHEAD(n->lsrql);
|
||||||
if(EMPTY_SLIST(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;
|
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);
|
sizeof(struct ospf_lsreq_header);
|
||||||
lsh=(struct ospf_lsreq_header *)(pk+1);
|
lsh = (struct ospf_lsreq_header *) (pk + 1);
|
||||||
|
|
||||||
for(;i>0;i--)
|
for (; i > 0; i--)
|
||||||
{
|
{
|
||||||
en=(struct top_hash_entry *)sn;
|
en = (struct top_hash_entry *) sn;
|
||||||
lsh->padd1=0; lsh->padd2=0;
|
lsh->padd1 = 0;
|
||||||
lsh->type=en->lsa.type;
|
lsh->padd2 = 0;
|
||||||
lsh->rt=htonl(en->lsa.rt);
|
lsh->type = en->lsa.type;
|
||||||
lsh->id=htonl(en->lsa.id);
|
lsh->rt = htonl(en->lsa.rt);
|
||||||
DBG("Requesting %uth LSA: Type: %u, Id: %I, RT: %I\n",i, en->lsa.type,
|
lsh->id = htonl(en->lsa.id);
|
||||||
en->lsa.id, en->lsa.rt);
|
DBG("Requesting %uth LSA: Type: %u, Id: %I, RT: %I\n", i, en->lsa.type,
|
||||||
|
en->lsa.id, en->lsa.rt);
|
||||||
lsh++;
|
lsh++;
|
||||||
if(sn==STAIL(n->lsrql)) break;
|
if (sn == STAIL(n->lsrql))
|
||||||
sn=sn->next;
|
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);
|
length =
|
||||||
op->length=htons(length);
|
sizeof(struct ospf_lsreq_packet) + (j -
|
||||||
|
i) * sizeof(struct ospf_lsreq_header);
|
||||||
|
op->length = htons(length);
|
||||||
ospf_pkt_finalize(n->ifa, op);
|
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);
|
OSPF_TRACE(D_PACKETS, "LS request sent to: %I", n->rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
|
ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
|
||||||
struct ospf_iface *ifa, u16 size)
|
struct ospf_iface *ifa, u16 size)
|
||||||
{
|
{
|
||||||
u32 nrid, myrid;
|
u32 nrid;
|
||||||
struct ospf_neighbor *n;
|
struct ospf_neighbor *n;
|
||||||
struct ospf_lsreq_header *lsh;
|
struct ospf_lsreq_header *lsh;
|
||||||
struct l_lsr_head *llsh;
|
struct l_lsr_head *llsh;
|
||||||
list uplist;
|
list uplist;
|
||||||
slab *upslab;
|
slab *upslab;
|
||||||
int length;
|
int length, i, lsano;
|
||||||
int i,lsano;
|
struct proto *p = (struct proto *) ifa->proto;
|
||||||
|
|
||||||
nrid=ntohl(ps->ospf_packet.routerid);
|
nrid = ntohl(ps->ospf_packet.routerid);
|
||||||
|
|
||||||
myrid=p->cf->global->router_id;
|
if ((n = find_neigh(ifa, nrid)) == NULL)
|
||||||
|
|
||||||
if((n=find_neigh(ifa, nrid))==NULL)
|
|
||||||
{
|
{
|
||||||
OSPF_TRACE(D_PACKETS, "Received lsreq from unknown neighbor! (%I)",
|
OSPF_TRACE(D_PACKETS, "Received lsreq from unknown neighbor! (%I)", nrid);
|
||||||
nrid);
|
return;
|
||||||
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_TRACE(D_EVENTS, "Received LS req from neighbor: %I", n->ip);
|
||||||
ospf_neigh_sm(n, INM_HELLOREC);
|
ospf_neigh_sm(n, INM_HELLOREC);
|
||||||
|
|
||||||
length=ntohs(ps->ospf_packet.length);
|
length = ntohs(ps->ospf_packet.length);
|
||||||
lsh=(void *)(ps+1);
|
lsh = (void *) (ps + 1);
|
||||||
init_list(&uplist);
|
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);
|
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),
|
DBG("Processing LSA: ID=%I, Type=%u, Router=%I\n", ntohl(lsh->id),
|
||||||
lsh->type, ntohl(lsh->rt));
|
lsh->type, ntohl(lsh->rt));
|
||||||
llsh=sl_alloc(upslab);
|
llsh = sl_alloc(upslab);
|
||||||
llsh->lsh.id=ntohl(lsh->id);
|
llsh->lsh.id = ntohl(lsh->id);
|
||||||
llsh->lsh.rt=ntohl(lsh->rt);
|
llsh->lsh.rt = ntohl(lsh->rt);
|
||||||
llsh->lsh.type=lsh->type;
|
llsh->lsh.type = lsh->type;
|
||||||
add_tail(&uplist, NODE llsh);
|
add_tail(&uplist, NODE llsh);
|
||||||
if(ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt,
|
if (ospf_hash_find(n->ifa->oa->gr, llsh->lsh.id, llsh->lsh.rt,
|
||||||
llsh->lsh.type)==NULL)
|
llsh->lsh.type) == NULL)
|
||||||
{
|
{
|
||||||
log("Received bad LS req from: %I looking: RT: %I, ID: %I, Type: %u",
|
log("Received bad LS req from: %I looking: RT: %I, ID: %I, Type: %u",
|
||||||
n->ip, lsh->rt, lsh->id, lsh->type);
|
n->ip, lsh->rt, lsh->id, lsh->type);
|
||||||
ospf_neigh_sm(n,INM_BADLSREQ);
|
ospf_neigh_sm(n, INM_BADLSREQ);
|
||||||
rfree(upslab);
|
rfree(upslab);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -115,4 +119,3 @@ ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
|
|||||||
ospf_lsupd_tx_list(n, &uplist);
|
ospf_lsupd_tx_list(n, &uplist);
|
||||||
rfree(upslab);
|
rfree(upslab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* 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.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*
|
*
|
||||||
@ -10,8 +10,8 @@
|
|||||||
#ifndef _BIRD_OSPF_LSREQ_H_
|
#ifndef _BIRD_OSPF_LSREQ_H_
|
||||||
#define _BIRD_OSPF_LSREQ_H_
|
#define _BIRD_OSPF_LSREQ_H_
|
||||||
|
|
||||||
void ospf_lsreq_tx(struct ospf_neighbor *n);
|
void ospf_lsreq_send(struct ospf_neighbor *n);
|
||||||
void ospf_lsreq_rx(struct ospf_lsreq_packet *ps, struct proto *p,
|
void ospf_lsreq_receive(struct ospf_lsreq_packet *ps,
|
||||||
struct ospf_iface *ifa, u16 size);
|
struct ospf_iface *ifa, u16 size);
|
||||||
|
|
||||||
#endif /* _BIRD_OSPF_LSREQ_H_ */
|
#endif /* _BIRD_OSPF_LSREQ_H_ */
|
||||||
|
@ -522,7 +522,7 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
|
|||||||
|
|
||||||
if(n->state==NEIGHBOR_LOADING)
|
if(n->state==NEIGHBOR_LOADING)
|
||||||
{
|
{
|
||||||
ospf_lsreq_tx(n); /* Send me another part of database */
|
ospf_lsreq_send(n); /* Send me another part of database */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ rxmt_timer_hook(timer *timer)
|
|||||||
p->name, ifa->iface->name, n->ip);
|
p->name, ifa->iface->name, n->ip);
|
||||||
if (n->state < NEIGHBOR_LOADING) ospf_dbdes_tx(n);
|
if (n->state < NEIGHBOR_LOADING) ospf_dbdes_tx(n);
|
||||||
|
|
||||||
if(n->state < NEIGHBOR_FULL) ospf_lsreq_tx(n);
|
if(n->state < NEIGHBOR_FULL) ospf_lsreq_send(n);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!EMPTY_SLIST(n->lsrtl))
|
if(!EMPTY_SLIST(n->lsrtl))
|
||||||
|
@ -184,7 +184,7 @@ ospf_rx_hook (sock * sk, int size)
|
|||||||
break;
|
break;
|
||||||
case LSREQ_P:
|
case LSREQ_P:
|
||||||
DBG ("%s: Link state request received.\n", p->name);
|
DBG ("%s: Link state request received.\n", p->name);
|
||||||
ospf_lsreq_rx ((struct ospf_lsreq_packet *) ps, p, ifa, size);
|
ospf_lsreq_receive((struct ospf_lsreq_packet *) ps, ifa, size);
|
||||||
break;
|
break;
|
||||||
case LSUPD_P:
|
case LSUPD_P:
|
||||||
DBG ("%s: Link state update received.\n", p->name);
|
DBG ("%s: Link state update received.\n", p->name);
|
||||||
|
Loading…
Reference in New Issue
Block a user