summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2004-05-31 17:42:38 +0000
committerMartin Mares <mj@ucw.cz>2004-05-31 17:42:38 +0000
commit4a02013767ab05b9cf7567c09e5fad59c9bd1c10 (patch)
tree586e85a1572eceabb6a321b4cc84574bfe8cbc7e /proto
parent1bd897dd33a49bd03f661e84687f8bba25af2983 (diff)
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)
Diffstat (limited to 'proto')
-rw-r--r--proto/rip/rip.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index 392a687f..c3a49510 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -457,6 +457,10 @@ rip_rx(sock *s, int size)
struct proto *p = i->proto;
int num;
+ /* In non-listening mode, just ignore packet */
+ if (i->mode & IM_NOLISTEN)
+ return 1;
+
CHK_MAGIC;
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 );
@@ -716,17 +720,15 @@ new_iface(struct proto *p, struct iface *new, unsigned long flags, struct iface_
if (!ipa_nonzero(rif->sock->daddr)) {
if (rif->iface)
log( L_WARN "%s: interface %s is too strange for me", P_NAME, rif->iface->name );
- } else
- if (!(rif->mode & IM_NOLISTEN))
- 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) {
- rfree(rif->sock);
- mb_free(rif);
- return NULL;
- }
- /* On dummy, we just return non-working socket, so that user gets error every time anyone requests table */
- }
+ } else if (sk_open(rif->sock)<0) {
+ log( L_ERR "%s: could not create socket for %s", P_NAME, rif->iface ? rif->iface->name : "(dummy)" );
+ if (rif->iface) {
+ rfree(rif->sock);
+ mb_free(rif);
+ return NULL;
+ }
+ /* On dummy, we just return non-working socket, so that user gets error every time anyone requests table */
+ }
TRACE(D_EVENTS, "Listening on %s, port %d, mode %s (%I)", rif->iface ? rif->iface->name : "(dummy)", P_CF->port, rif->multicast ? "multicast" : "broadcast", rif->sock->daddr );