mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Added ip_skip_header() and modified OSPF to use it.
This commit is contained in:
parent
11ce4490fa
commit
b23c5e0ff4
2
TODO
2
TODO
@ -30,6 +30,8 @@ Core
|
|||||||
|
|
||||||
- socket: Use IP_RECVERR for BGP TCP sockets?
|
- socket: Use IP_RECVERR for BGP TCP sockets?
|
||||||
|
|
||||||
|
- lib: use better checksum function
|
||||||
|
|
||||||
Cleanup
|
Cleanup
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
- right usage of DBG vs. debug
|
- right usage of DBG vs. debug
|
||||||
|
15
lib/ipv4.c
15
lib/ipv4.c
@ -94,3 +94,18 @@ ip_pton(char *a, ip_addr *o)
|
|||||||
*o = ipa_from_u32(ia);
|
*o = ipa_from_u32(ia);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte *
|
||||||
|
ipv4_skip_header(byte *pkt, int *len)
|
||||||
|
{
|
||||||
|
int l = *len;
|
||||||
|
int q;
|
||||||
|
|
||||||
|
if (l < 20 || (*pkt & 0xf0) != 0x40)
|
||||||
|
return NULL;
|
||||||
|
q = (*pkt & 0x0f) * 4;
|
||||||
|
if (q < l)
|
||||||
|
return NULL;
|
||||||
|
*len -= q;
|
||||||
|
return pkt + q;
|
||||||
|
}
|
||||||
|
@ -58,8 +58,11 @@ typedef u32 ip_addr;
|
|||||||
#define ipa_to_u32(x) _I(x)
|
#define ipa_to_u32(x) _I(x)
|
||||||
#define ipa_compare(x,y) ipv4_compare(_I(x),_I(y))
|
#define ipa_compare(x,y) ipv4_compare(_I(x),_I(y))
|
||||||
|
|
||||||
|
#define ip_skip_header(x, y) ipv4_skip_header(x, y)
|
||||||
|
|
||||||
int ipv4_classify(u32);
|
int ipv4_classify(u32);
|
||||||
u32 ipv4_class_mask(u32);
|
u32 ipv4_class_mask(u32);
|
||||||
|
byte *ipv4_skip_header(byte *, int *);
|
||||||
|
|
||||||
static inline unsigned ipv4_hash(u32 a)
|
static inline unsigned ipv4_hash(u32 a)
|
||||||
{
|
{
|
||||||
|
@ -80,16 +80,15 @@ ospf_rx_hook(sock *sk, int size)
|
|||||||
DBG(sk->iface->name);
|
DBG(sk->iface->name);
|
||||||
DBG(".\n");
|
DBG(".\n");
|
||||||
|
|
||||||
ps=(struct ospf_packet *)(sk->rbuf+5*4);
|
ps = (struct ospf_packet *) ipv4_skip_header(sk->rbuf, &size);
|
||||||
|
if(!ps || size < sizeof(struct ospf_packet))
|
||||||
if(size<=(20+sizeof(struct ospf_packet)))
|
|
||||||
{
|
{
|
||||||
log("%s: Bad packet received: too short", p->name);
|
log("%s: Bad packet received: too short", p->name);
|
||||||
log("%s: Discarding",p->name);
|
log("%s: Discarding",p->name);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ntohs(ps->length))!=(size-20))
|
if(ntohs(ps->length) != size)
|
||||||
{
|
{
|
||||||
log("%s: Bad packet received: size fields does not match", p->name);
|
log("%s: Bad packet received: size fields does not match", p->name);
|
||||||
log("%s: Discarding",p->name);
|
log("%s: Discarding",p->name);
|
||||||
|
Loading…
Reference in New Issue
Block a user