mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
A structure for receiving DD seq packets added.
This commit is contained in:
parent
e3121112ab
commit
1af664158d
@ -366,10 +366,7 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
|
|||||||
die("%s: Iface %s in down state?", p->name, ifa->iface->name);
|
die("%s: Iface %s in down state?", p->name, ifa->iface->name);
|
||||||
break;
|
break;
|
||||||
case OSPF_IS_WAITING:
|
case OSPF_IS_WAITING:
|
||||||
DBG(p->name);
|
DBG("%s: Neighbor? on iface %s\n",p->name, ifa->iface->name);
|
||||||
DBG(": Neighbor? on iface ");
|
|
||||||
DBG(ifa->iface->name);
|
|
||||||
DBG("\n");
|
|
||||||
break;
|
break;
|
||||||
case OSPF_IS_DROTHER:
|
case OSPF_IS_DROTHER:
|
||||||
if(((n->rid==ifa->drid) || (n->rid==ifa->bdrid))
|
if(((n->rid==ifa->drid) || (n->rid==ifa->bdrid))
|
||||||
@ -400,10 +397,7 @@ ospf_rx_hook(sock *sk, int size)
|
|||||||
ifa=(struct ospf_iface *)(sk->data);
|
ifa=(struct ospf_iface *)(sk->data);
|
||||||
|
|
||||||
p=(struct proto *)(ifa->proto);
|
p=(struct proto *)(ifa->proto);
|
||||||
DBG(p->name);
|
DBG("%s: RX_Hook called on interface %s.\n",p->name, sk->iface->name);
|
||||||
DBG(": RX_Hook called on interface ");
|
|
||||||
DBG(sk->iface->name);
|
|
||||||
DBG(".\n");
|
|
||||||
|
|
||||||
ps = (struct ospf_packet *) ipv4_skip_header(sk->rbuf, &size);
|
ps = (struct ospf_packet *) ipv4_skip_header(sk->rbuf, &size);
|
||||||
if(ps==NULL)
|
if(ps==NULL)
|
||||||
@ -465,28 +459,30 @@ ospf_rx_hook(sock *sk, int size)
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Dump packet */
|
/* Dump packet */
|
||||||
pu8=(u8 *)(sk->rbuf+5*4);
|
pu8=(u8 *)(sk->rbuf+5*4);
|
||||||
for(i=0;i<ntohs(ps->length);i+=4)
|
for(i=0;i<ntohs(ps->length);i+=4)
|
||||||
debug("%s: received %u,%u,%u,%u\n",p->name, pu8[i+0], pu8[i+1], pu8[i+2],
|
DBG("%s: received %u,%u,%u,%u\n",p->name, pu8[i+0], pu8[i+1], pu8[i+2],
|
||||||
pu8[i+3]);
|
pu8[i+3]);
|
||||||
debug("%s: received size: %u\n",p->name,size);
|
debug("%s: received size: %u\n",p->name,size);
|
||||||
|
|
||||||
switch(ps->type)
|
switch(ps->type)
|
||||||
{
|
{
|
||||||
case HELLO:
|
case HELLO:
|
||||||
DBG(p->name);
|
DBG("%s: Hello received.\n", p->name);
|
||||||
DBG(": Hello received.\n");
|
|
||||||
ospf_hello_rx((struct ospf_hello_packet *)ps, p, ifa, size);
|
ospf_hello_rx((struct ospf_hello_packet *)ps, p, ifa, size);
|
||||||
break;
|
break;
|
||||||
case DBDES:
|
case DBDES:
|
||||||
|
DBG("%s: Database description received.\n", p->name);
|
||||||
break;
|
break;
|
||||||
case LSREQ:
|
case LSREQ:
|
||||||
|
DBG("%s: Link state request received.\n", p->name);
|
||||||
break;
|
break;
|
||||||
case LSUPD:
|
case LSUPD:
|
||||||
|
DBG("%s: Link state update received.\n", p->name);
|
||||||
break;
|
break;
|
||||||
case LSACK:
|
case LSACK:
|
||||||
|
DBG("%s: Link state ack received.\n", p->name);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log("%s: Bad packet received: wrong type %u", p->name, ps->type);
|
log("%s: Bad packet received: wrong type %u", p->name, ps->type);
|
||||||
@ -524,11 +520,14 @@ ospf_err_hook(sock *sk, int err)
|
|||||||
DBG("%s: Err_Hook called on interface %s\n", p->name,sk->iface->name);
|
DBG("%s: Err_Hook called on interface %s\n", p->name,sk->iface->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This will change ! */
|
|
||||||
sock *
|
sock *
|
||||||
ospf_open_socket(struct proto *p, struct ospf_iface *ifa)
|
ospf_open_mc_socket(struct ospf_iface *ifa)
|
||||||
{
|
{
|
||||||
sock *mcsk;
|
sock *mcsk;
|
||||||
|
struct proto *p;
|
||||||
|
|
||||||
|
p=(struct proto *)(ifa->proto);
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: No NBMA networks now */
|
/* FIXME: No NBMA networks now */
|
||||||
|
|
||||||
@ -550,17 +549,45 @@ ospf_open_socket(struct proto *p, struct ospf_iface *ifa)
|
|||||||
mcsk->data=(void *)ifa;
|
mcsk->data=(void *)ifa;
|
||||||
if(sk_open(mcsk)!=0)
|
if(sk_open(mcsk)!=0)
|
||||||
{
|
{
|
||||||
DBG(p->name);
|
DBG("%s: SK_OPEN: mc open failed.\n",p->name);
|
||||||
DBG(": SK_OPEN: failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
DBG(p->name);
|
DBG("%s: SK_OPEN: mc opened.\n",p->name);
|
||||||
DBG(": SK_OPEN: open\n");
|
|
||||||
return(mcsk);
|
return(mcsk);
|
||||||
}
|
}
|
||||||
else return(NULL);
|
else return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sock *
|
||||||
|
ospf_open_ip_socket(struct ospf_iface *ifa)
|
||||||
|
{
|
||||||
|
sock *ipsk;
|
||||||
|
struct proto *p;
|
||||||
|
|
||||||
|
p=(struct proto *)(ifa->proto);
|
||||||
|
|
||||||
|
ipsk=sk_new(p->pool);
|
||||||
|
ipsk->type=SK_IP;
|
||||||
|
ipsk->dport=OSPF_PROTO;
|
||||||
|
ipsk->saddr=ifa->iface->addr->ip;
|
||||||
|
ipsk->tos=IP_PREC_INTERNET_CONTROL;
|
||||||
|
ipsk->ttl=1;
|
||||||
|
ipsk->rx_hook=ospf_rx_hook;
|
||||||
|
ipsk->tx_hook=ospf_tx_hook;
|
||||||
|
ipsk->err_hook=ospf_err_hook;
|
||||||
|
ipsk->iface=ifa->iface;
|
||||||
|
ipsk->rbsize=ifa->iface->mtu;
|
||||||
|
ipsk->tbsize=ifa->iface->mtu;
|
||||||
|
ipsk->data=(void *)ifa;
|
||||||
|
if(sk_open(ipsk)!=0)
|
||||||
|
{
|
||||||
|
DBG("%s: SK_OPEN: ip open failed.\n",p->name);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
DBG("%s: SK_OPEN: ip opened.\n",p->name);
|
||||||
|
return(ipsk);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This will later decide, wheter use iface for OSPF or not
|
* This will later decide, wheter use iface for OSPF or not
|
||||||
* depending on config
|
* depending on config
|
||||||
@ -775,19 +802,24 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
|
|||||||
ospf_iface_default(ifa);
|
ospf_iface_default(ifa);
|
||||||
if(ifa->type!=OSPF_IT_NBMA)
|
if(ifa->type!=OSPF_IT_NBMA)
|
||||||
{
|
{
|
||||||
if((mcsk=ospf_open_socket(p, ifa))!=NULL)
|
if((ifa->hello_sk=ospf_open_mc_socket(ifa))==NULL)
|
||||||
{
|
{
|
||||||
ifa->hello_sk=mcsk;
|
log("%s: Huh? could not open mc socket on interface %s?", p->name,
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log("%s: Huh? could not open socket on interface %s?", p->name,
|
|
||||||
iface->name);
|
iface->name);
|
||||||
mb_free(ifa);
|
mb_free(ifa);
|
||||||
log("%s: Ignoring this interface\n", p->name);
|
log("%s: Ignoring this interface\n", p->name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* FIXME: In fail case??? */
|
|
||||||
|
if((ifa->ip_sk=ospf_open_ip_socket(ifa))==NULL)
|
||||||
|
{
|
||||||
|
log("%s: Huh? could not open ip socket on interface %s?", p->name,
|
||||||
|
iface->name);
|
||||||
|
mb_free(ifa);
|
||||||
|
log("%s: Ignoring this interface\n", p->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
init_list(&(ifa->neigh_list));
|
init_list(&(ifa->neigh_list));
|
||||||
}
|
}
|
||||||
/* FIXME: NBMA? */
|
/* FIXME: NBMA? */
|
||||||
@ -820,8 +852,7 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
|
|||||||
static int
|
static int
|
||||||
ospf_start(struct proto *p)
|
ospf_start(struct proto *p)
|
||||||
{
|
{
|
||||||
DBG(p->name);
|
DBG("%s: Start\n",p->name);
|
||||||
DBG(": Start\n");
|
|
||||||
|
|
||||||
p->if_notify=ospf_if_notify;
|
p->if_notify=ospf_if_notify;
|
||||||
|
|
||||||
|
@ -33,7 +33,8 @@ struct ospf_iface {
|
|||||||
node n;
|
node n;
|
||||||
struct proto_ospf *proto;
|
struct proto_ospf *proto;
|
||||||
struct iface *iface; /* Nest's iface */
|
struct iface *iface; /* Nest's iface */
|
||||||
sock *hello_sk; /* List of active sockets */
|
sock *hello_sk; /* Hello socket */
|
||||||
|
sock *ip_sk; /* IP socket (for DD ...) */
|
||||||
list neigh_list; /* List of neigbours */
|
list neigh_list; /* List of neigbours */
|
||||||
u32 area; /* OSPF Area */
|
u32 area; /* OSPF Area */
|
||||||
u16 cost; /* Cost of iface */
|
u16 cost; /* Cost of iface */
|
||||||
@ -71,7 +72,9 @@ struct ospf_iface {
|
|||||||
#define PRIORITY_D 1
|
#define PRIORITY_D 1
|
||||||
#define HELLOINT_D 10
|
#define HELLOINT_D 10
|
||||||
#define DEADC_D 4
|
#define DEADC_D 4
|
||||||
#define WAIT_DMH 2 /* Value of Wait timer - not found it in RFC - using 2*HELLO */
|
#define WAIT_DMH 2 /* Value of Wait timer - not found it in RFC
|
||||||
|
* - using 2*HELLO
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ospf_patt {
|
struct ospf_patt {
|
||||||
@ -108,6 +111,13 @@ struct ospf_hello_packet {
|
|||||||
u32 bdr;
|
u32 bdr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ospf_ddseq_packet {
|
||||||
|
struct ospf_packet ospf_packet;
|
||||||
|
u16 iface_mtu;
|
||||||
|
u16 options;
|
||||||
|
u32 ddseq_no;
|
||||||
|
};
|
||||||
|
|
||||||
struct ospf_neighbor
|
struct ospf_neighbor
|
||||||
{
|
{
|
||||||
node n;
|
node n;
|
||||||
|
Loading…
Reference in New Issue
Block a user