diff options
Diffstat (limited to 'sbin/routed/input.c')
-rw-r--r-- | sbin/routed/input.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/sbin/routed/input.c b/sbin/routed/input.c index 55162fcd87be..08872a7b4b02 100644 --- a/sbin/routed/input.c +++ b/sbin/routed/input.c @@ -33,13 +33,14 @@ #include "defs.h" -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)input.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) -#include <sys/cdefs.h> +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.26 $"); +#ident "$Revision: 2.26 $" #endif -#ident "$Revision: 2.17 $" static void input(struct sockaddr_in *, struct interface *, struct interface *, struct rip *, int); @@ -326,9 +327,14 @@ input(struct sockaddr_in *from, /* received from this IP address */ v12buf.n->n_family = RIP_AF_INET; v12buf.n->n_dst = RIP_DEFAULT; i = aifp->int_d_metric; - if (0 != (rt = rtget(RIP_DEFAULT, 0))) - i = MIN(i, (rt->rt_metric - +aifp->int_metric+1)); + if (0 != (rt = rtget(RIP_DEFAULT, 0))) { + j = (rt->rt_metric + +aifp->int_metric + +aifp->int_adj_outmetric + +1); + if (i > j) + i = j; + } v12buf.n->n_metric = htonl(i); v12buf.n++; break; @@ -394,11 +400,15 @@ input(struct sockaddr_in *from, /* received from this IP address */ */ v12buf.n->n_family = RIP_AF_INET; v12buf.n->n_dst = dst; - v12buf.n->n_metric = (rt->rt_metric+1 - + ((aifp!=0) - ? aifp->int_metric - : 1)); - if (v12buf.n->n_metric > HOPCNT_INFINITY) + j = rt->rt_metric+1; + if (!aifp) + ++j; + else + j += (aifp->int_metric + + aifp->int_adj_outmetric); + if (j < HOPCNT_INFINITY) + v12buf.n->n_metric = j; + else v12buf.n->n_metric = HOPCNT_INFINITY; if (v12buf.buf->rip_vers != RIPv1) { v12buf.n->n_tag = rt->rt_tag; @@ -482,7 +492,8 @@ input(struct sockaddr_in *from, /* received from this IP address */ if (from->sin_port != ntohs(RIP_PORT)) { msglim(&bad_router, FROM_NADDR, " discard RIP response from unknown port" - " %d", from->sin_port); + " %d on %s", + ntohs(from->sin_port), naddr_ntoa(FROM_NADDR)); return; } @@ -651,7 +662,8 @@ input(struct sockaddr_in *from, /* received from this IP address */ /* Adjust metric according to incoming interface.. */ - n->n_metric += aifp->int_metric; + n->n_metric += (aifp->int_metric + + aifp->int_adj_inmetric); if (n->n_metric > HOPCNT_INFINITY) n->n_metric = HOPCNT_INFINITY; @@ -964,12 +976,12 @@ ck_passwd(struct interface *aifp, */ if (TRACEPACKETS) { if (NA->au.a_md5.md5_auth_len - != RIP_AUTH_MD5_LEN) + != RIP_AUTH_MD5_HASH_LEN) msglim(use_authp, from, "unknown MD5 RIPv2 auth len %#x" " instead of %#x from %s", NA->au.a_md5.md5_auth_len, - RIP_AUTH_MD5_LEN, + RIP_AUTH_MD5_HASH_LEN, naddr_ntoa(from)); if (na2->a_family != RIP_AF_AUTH) msglim(use_authp, from, @@ -986,8 +998,9 @@ ck_passwd(struct interface *aifp, } MD5Init(&md5_ctx); - MD5Update(&md5_ctx, (u_char *)rip, len); - MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_LEN); + MD5Update(&md5_ctx, (u_char *)rip, + len + RIP_AUTH_MD5_HASH_XTRA); + MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_KEY_LEN); MD5Final(hash, &md5_ctx); if (!memcmp(hash, na2->au.au_pw, sizeof(hash))) return 1; |