Untested IPv6 support added. I do not know if it compiles in IPV6 mode.
This commit is contained in:
parent
720d911d77
commit
c79ec2ec19
2 changed files with 34 additions and 8 deletions
|
@ -4,6 +4,8 @@
|
||||||
* Copyright (c) 1998, 1999 Pavel Machek <pavel@ucw.cz>
|
* Copyright (c) 1998, 1999 Pavel Machek <pavel@ucw.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.
|
||||||
|
*
|
||||||
|
FIXME: IpV6 support
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LOCAL_DEBUG
|
#define LOCAL_DEBUG
|
||||||
|
@ -85,8 +87,14 @@ rip_tx( sock *s )
|
||||||
packet->block[i].family = htons( 2 ); /* AF_INET */
|
packet->block[i].family = htons( 2 ); /* AF_INET */
|
||||||
packet->block[i].tag = htons( e->tag );
|
packet->block[i].tag = htons( e->tag );
|
||||||
packet->block[i].network = e->n.prefix;
|
packet->block[i].network = e->n.prefix;
|
||||||
|
#ifndef IPV6
|
||||||
packet->block[i].netmask = ipa_mkmask( e->n.pxlen );
|
packet->block[i].netmask = ipa_mkmask( e->n.pxlen );
|
||||||
packet->block[i].nexthop = IPA_NONE; /* FIXME: How should I set it? My own IP address? */
|
ipa_hton( packet->block[i].netmask );
|
||||||
|
packet->block[i].nexthop = IPA_NONE; /* FIXME: does it make sense to set this to not-me in some cases? */
|
||||||
|
ipa_hton( packet->block[i].nexthop );
|
||||||
|
#else
|
||||||
|
packet->block[i].pxlen = e->n.pxlen;
|
||||||
|
#endif
|
||||||
packet->block[i].metric = htonl( e->metric );
|
packet->block[i].metric = htonl( e->metric );
|
||||||
if (ipa_equal(e->whotoldme, s->daddr)) {
|
if (ipa_equal(e->whotoldme, s->daddr)) {
|
||||||
DBG( "(split horizont)" );
|
DBG( "(split horizont)" );
|
||||||
|
@ -94,8 +102,6 @@ rip_tx( sock *s )
|
||||||
packet->block[i].metric = P_CF->infinity;
|
packet->block[i].metric = P_CF->infinity;
|
||||||
}
|
}
|
||||||
ipa_hton( packet->block[i].network );
|
ipa_hton( packet->block[i].network );
|
||||||
ipa_hton( packet->block[i].netmask );
|
|
||||||
ipa_hton( packet->block[i].nexthop );
|
|
||||||
|
|
||||||
if (i++ == ((P_CF->authtype == AT_MD5) ? PACKET_MD5_MAX : PACKET_MAX)) {
|
if (i++ == ((P_CF->authtype == AT_MD5) ? PACKET_MD5_MAX : PACKET_MAX)) {
|
||||||
FIB_ITERATE_PUT(&c->iter, z);
|
FIB_ITERATE_PUT(&c->iter, z);
|
||||||
|
@ -185,6 +191,7 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme )
|
||||||
net *n;
|
net *n;
|
||||||
neighbor *neighbor;
|
neighbor *neighbor;
|
||||||
struct rip_interface *rif;
|
struct rip_interface *rif;
|
||||||
|
int pxlen;
|
||||||
|
|
||||||
bzero(&A, sizeof(A));
|
bzero(&A, sizeof(A));
|
||||||
A.proto = p;
|
A.proto = p;
|
||||||
|
@ -193,14 +200,20 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme )
|
||||||
A.cast = RTC_UNICAST;
|
A.cast = RTC_UNICAST;
|
||||||
A.dest = RTD_ROUTER;
|
A.dest = RTD_ROUTER;
|
||||||
A.flags = 0;
|
A.flags = 0;
|
||||||
|
#ifndef IPV6
|
||||||
A.gw = ipa_nonzero(b->nexthop) ? b->nexthop : whotoldme;
|
A.gw = ipa_nonzero(b->nexthop) ? b->nexthop : whotoldme;
|
||||||
|
pxlen = ipa_mklen(b->netmask);
|
||||||
|
#else
|
||||||
|
A.gw = whotoldme; /* FIXME: next hop is in other packet for v6 */
|
||||||
|
pxlen = b->pxlen;
|
||||||
|
#endif
|
||||||
A.from = whotoldme;
|
A.from = whotoldme;
|
||||||
|
|
||||||
/* FIXME: Check if destination looks valid - ie not net 0 or 127 */
|
/* FIXME: Check if destination looks valid - ie not net 0 or 127 */
|
||||||
|
|
||||||
neighbor = neigh_find( p, &A.gw, 0 );
|
neighbor = neigh_find( p, &A.gw, 0 );
|
||||||
if (!neighbor) {
|
if (!neighbor) {
|
||||||
log( L_ERR "%I asked me to route %I/%I using not-neighbor %I.", A.from, b->network, b->netmask, A.gw );
|
log( L_ERR "%I asked me to route %I/%d using not-neighbor %I.", A.from, b->network, pxlen, A.gw );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,11 +228,11 @@ advertise_entry( struct proto *p, struct rip_block *b, ip_addr whotoldme )
|
||||||
|
|
||||||
/* set to: interface of nexthop */
|
/* set to: interface of nexthop */
|
||||||
a = rta_lookup(&A);
|
a = rta_lookup(&A);
|
||||||
if (ipa_mklen(b->netmask)==-1) {
|
if (pxlen==-1) {
|
||||||
log( L_ERR "%I asked me to route %I/%I, but that is not valid netmask.", A.from, b->network, b->netmask );
|
log( L_ERR "%I gave me invalid pxlen/netmask for %I.", A.from, b->network );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n = net_get( p->table, b->network, ipa_mklen( b->netmask ));
|
n = net_get( p->table, b->network, pxlen );
|
||||||
r = rte_get_temp(a);
|
r = rte_get_temp(a);
|
||||||
r->u.rip.metric = ntohl(b->metric) + rif->patt->metric;
|
r->u.rip.metric = ntohl(b->metric) + rif->patt->metric;
|
||||||
if (r->u.rip.metric > P_CF->infinity) r->u.rip.metric = P_CF->infinity;
|
if (r->u.rip.metric > P_CF->infinity) r->u.rip.metric = P_CF->infinity;
|
||||||
|
@ -243,7 +256,7 @@ process_block( struct proto *p, struct rip_block *block, ip_addr whotoldme )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug( "block: %I tells me: %I/%I available, metric %d... ", whotoldme, network, block->netmask, metric );
|
debug( "block: %I tells me: %I/??? available, metric %d... ", whotoldme, network, metric );
|
||||||
|
|
||||||
advertise_entry( p, block, whotoldme );
|
advertise_entry( p, block, whotoldme );
|
||||||
}
|
}
|
||||||
|
@ -302,12 +315,14 @@ rip_process_packet( struct proto *p, struct rip_packet *packet, int num, ip_addr
|
||||||
}
|
}
|
||||||
/* FIXME: Need to reject packets which have no authentication */
|
/* FIXME: Need to reject packets which have no authentication */
|
||||||
ipa_ntoh( block->network );
|
ipa_ntoh( block->network );
|
||||||
|
#ifndef IPV6
|
||||||
ipa_ntoh( block->netmask );
|
ipa_ntoh( block->netmask );
|
||||||
ipa_ntoh( block->nexthop );
|
ipa_ntoh( block->nexthop );
|
||||||
if (packet->heading.version == RIP_V1) {
|
if (packet->heading.version == RIP_V1) {
|
||||||
block->netmask = block->network; /* MJ: why are macros like this?! */
|
block->netmask = block->network; /* MJ: why are macros like this?! */
|
||||||
ipa_class_mask( block->netmask );
|
ipa_class_mask( block->netmask );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
process_block( p, block, whotoldme );
|
process_block( p, block, whotoldme );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Structures for RIP protocol
|
* Structures for RIP protocol
|
||||||
|
*
|
||||||
|
FIXME: in V6, they insert additional entry whenever next hop differs. Such entry is identified by 0xff in metric.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nest/route.h"
|
#include "nest/route.h"
|
||||||
|
@ -39,6 +41,7 @@ struct rip_packet_heading {
|
||||||
u16 unused;
|
u16 unused;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef IPV6
|
||||||
struct rip_block {
|
struct rip_block {
|
||||||
u16 family; /* 0xffff on first message means this is authentication */
|
u16 family; /* 0xffff on first message means this is authentication */
|
||||||
u16 tag;
|
u16 tag;
|
||||||
|
@ -47,6 +50,14 @@ struct rip_block {
|
||||||
ip_addr nexthop;
|
ip_addr nexthop;
|
||||||
u32 metric;
|
u32 metric;
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
struct rip_block {
|
||||||
|
ip_addr network;
|
||||||
|
u16 tag;
|
||||||
|
u8 pxlen;
|
||||||
|
u8 metric
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct rip_block_auth {
|
struct rip_block_auth {
|
||||||
u16 mustbeFFFF;
|
u16 mustbeFFFF;
|
||||||
|
|
Loading…
Reference in a new issue