mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-09 20:58:44 +00:00
Initial multicast support (can not work, but skeleton is there)
This commit is contained in:
parent
8e66a0ebb9
commit
06fa1453cd
@ -313,6 +313,7 @@ rip_process_packet( struct proto *p, struct rip_packet *packet, int num, ip_addr
|
|||||||
|
|
||||||
switch( packet->heading.command ) {
|
switch( packet->heading.command ) {
|
||||||
case RIPCMD_REQUEST: debug( "Asked to send my routing table\n" );
|
case RIPCMD_REQUEST: debug( "Asked to send my routing table\n" );
|
||||||
|
/* FIXME: should have configurable: ignore always, honour to neighbours, honour always. FIXME: use one global socket for these. FIXME: synchronization - if two ask me at same time */
|
||||||
rip_sendto( p, whotoldme, port, NULL ); /* no broadcast */
|
rip_sendto( p, whotoldme, port, NULL ); /* no broadcast */
|
||||||
break;
|
break;
|
||||||
case RIPCMD_RESPONSE: debug( "*** Rtable from %I\n", whotoldme );
|
case RIPCMD_RESPONSE: debug( "*** Rtable from %I\n", whotoldme );
|
||||||
@ -473,7 +474,7 @@ rip_dump(struct proto *p)
|
|||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
WALK_LIST( rif, P->interfaces ) {
|
WALK_LIST( rif, P->interfaces ) {
|
||||||
debug( "RIP: interface #%d: %s, %I, busy = %x\n", i++, rif->iface->name, rif->sock->daddr, rif->busy );
|
debug( "RIP: interface #%d: %s, %I, busy = %x\n", i++, rif->iface?rif->iface->name:"(dummy)", rif->sock->daddr, rif->busy );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,40 +492,50 @@ kill_iface(struct proto *p, struct rip_interface *i)
|
|||||||
mb_free(i);
|
mb_free(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* new maybe null if we are creating initial send socket
|
||||||
|
*/
|
||||||
struct rip_interface *
|
struct rip_interface *
|
||||||
new_iface(struct proto *p, struct iface *new)
|
new_iface(struct proto *p, struct iface *new, unsigned long flags)
|
||||||
{
|
{
|
||||||
struct rip_interface *i;
|
struct rip_interface *rif;
|
||||||
debug( "RIP: New interface %s here\n", new->name);
|
int want_multicast;
|
||||||
i = mb_alloc(p->pool, sizeof( struct rip_interface ));
|
|
||||||
i->iface = new;
|
|
||||||
i->proto = p;
|
|
||||||
|
|
||||||
i->sock = sk_new( p->pool );
|
rif = mb_alloc(p->pool, sizeof( struct rip_interface ));
|
||||||
i->sock->type = SK_UDP;
|
rif->iface = new;
|
||||||
i->sock->sport = P->port;
|
rif->proto = p;
|
||||||
i->sock->rx_hook = rip_rx;
|
|
||||||
i->sock->data = i;
|
|
||||||
i->sock->rbsize = 10240;
|
|
||||||
i->sock->iface = new;
|
|
||||||
i->sock->tbuf = mb_alloc( p->pool, sizeof( struct rip_packet ));
|
|
||||||
i->sock->tx_hook = rip_tx;
|
|
||||||
i->sock->err_hook = rip_tx_err;
|
|
||||||
i->sock->daddr = IPA_NONE;
|
|
||||||
i->sock->dport = P->port;
|
|
||||||
|
|
||||||
if (new->flags & IF_BROADCAST)
|
want_multicast = 0 && (flags & IF_MULTICAST);
|
||||||
i->sock->daddr = new->brd;
|
/* FIXME: should have config option to disable this one */
|
||||||
if (new->flags & IF_UNNUMBERED)
|
|
||||||
i->sock->daddr = new->opposite;
|
|
||||||
|
|
||||||
if (!ipa_nonzero(i->sock->daddr))
|
rif->sock = sk_new( p->pool );
|
||||||
log( L_WARN "RIP: interface %s is too strange for me", i->iface->name );
|
rif->sock->type = want_multicast?SK_UDP_MC:SK_UDP;
|
||||||
|
rif->sock->sport = P->port;
|
||||||
|
rif->sock->rx_hook = rip_rx;
|
||||||
|
rif->sock->data = rif;
|
||||||
|
rif->sock->rbsize = 10240;
|
||||||
|
rif->sock->iface = new;
|
||||||
|
rif->sock->tbuf = mb_alloc( p->pool, sizeof( struct rip_packet ));
|
||||||
|
rif->sock->tx_hook = rip_tx;
|
||||||
|
rif->sock->err_hook = rip_tx_err;
|
||||||
|
rif->sock->daddr = IPA_NONE;
|
||||||
|
rif->sock->dport = P->port;
|
||||||
|
rif->sock->ttl = 1; /* FIXME: care must be taken not to send requested responses from this socket */
|
||||||
|
|
||||||
if (sk_open(i->sock)<0)
|
if (want_multicast)
|
||||||
die( "RIP/%s: could not listen on %s\n", p->name, i->iface->name );
|
rif->sock->daddr = ipa_from_u32(0x7f000001); /* FIXME: must lookup address in rfc's */
|
||||||
|
if (flags & IF_BROADCAST)
|
||||||
|
rif->sock->daddr = new->brd;
|
||||||
|
if (flags & IF_UNNUMBERED)
|
||||||
|
rif->sock->daddr = new->opposite;
|
||||||
|
|
||||||
return i;
|
if (!ipa_nonzero(rif->sock->daddr))
|
||||||
|
log( L_WARN "RIP: interface %s is too strange for me", rif->iface->name );
|
||||||
|
|
||||||
|
if (sk_open(rif->sock)<0)
|
||||||
|
die( "RIP/%s: could not listen on %s\n", p->name, rif->iface->name );
|
||||||
|
|
||||||
|
return rif;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -540,13 +551,14 @@ rip_if_notify(struct proto *p, unsigned c, struct iface *old, struct iface *new)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (new) {
|
if (new) {
|
||||||
struct rip_interface *i;
|
struct rip_interface *rif;
|
||||||
struct iface_patt *k = iface_patt_match(&P->iface_list, new);
|
struct iface_patt *k = iface_patt_match(&P->iface_list, new);
|
||||||
|
|
||||||
if (!k) return; /* We are not interested in this interface */
|
if (!k) return; /* We are not interested in this interface */
|
||||||
i = new_iface(p, new);
|
DBG("adding interface %s\n", new->name );
|
||||||
i->metric = k->u.rip.metric;
|
rif = new_iface(p, new, new->flags);
|
||||||
add_head( &P->interfaces, NODE i );
|
rif->metric = k->u.rip.metric;
|
||||||
|
add_head( &P->interfaces, NODE rif );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,6 +659,7 @@ rip_preconfig(struct protocol *x)
|
|||||||
static void
|
static void
|
||||||
rip_postconfig(struct protocol *p)
|
rip_postconfig(struct protocol *p)
|
||||||
{
|
{
|
||||||
|
new_iface(p, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct protocol proto_rip = {
|
struct protocol proto_rip = {
|
||||||
|
Loading…
Reference in New Issue
Block a user