Make RIP nolisten mode actually work. The socket is required for

sending, the received data has to be discarded instead.

(patch by Andreas Steinmetz modified by me)
This commit is contained in:
Martin Mares 2004-05-31 17:42:38 +00:00
parent 1bd897dd33
commit 4a02013767

View file

@ -457,6 +457,10 @@ rip_rx(sock *s, int size)
struct proto *p = i->proto; struct proto *p = i->proto;
int num; int num;
/* In non-listening mode, just ignore packet */
if (i->mode & IM_NOLISTEN)
return 1;
CHK_MAGIC; CHK_MAGIC;
DBG( "RIP: message came: %d bytes from %I via %s\n", size, s->faddr, i->iface ? i->iface->name : "(dummy)" ); DBG( "RIP: message came: %d bytes from %I via %s\n", size, s->faddr, i->iface ? i->iface->name : "(dummy)" );
size -= sizeof( struct rip_packet_heading ); size -= sizeof( struct rip_packet_heading );
@ -716,10 +720,8 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_
if (!ipa_nonzero(rif->sock->daddr)) { if (!ipa_nonzero(rif->sock->daddr)) {
if (rif->iface) if (rif->iface)
log( L_WARN "%s: interface %s is too strange for me", P_NAME, rif->iface->name ); log( L_WARN "%s: interface %s is too strange for me", P_NAME, rif->iface->name );
} else } else if (sk_open(rif->sock)<0) {
if (!(rif->mode & IM_NOLISTEN)) log( L_ERR "%s: could not create socket for %s", P_NAME, rif->iface ? rif->iface->name : "(dummy)" );
if (sk_open(rif->sock)<0) {
log( L_ERR "%s: could not listen on %s", P_NAME, rif->iface ? rif->iface->name : "(dummy)" );
if (rif->iface) { if (rif->iface) {
rfree(rif->sock); rfree(rif->sock);
mb_free(rif); mb_free(rif);