summaryrefslogtreecommitdiffstats
path: root/sbin/routed/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/routed/input.c')
-rw-r--r--sbin/routed/input.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/sbin/routed/input.c b/sbin/routed/input.c
index bc03028..bdf0a8b 100644
--- a/sbin/routed/input.c
+++ b/sbin/routed/input.c
@@ -100,9 +100,9 @@ read_rip(int sock,
if (aifp->int_addr == from.sin_addr.s_addr)
break;
}
- if (aifp == 0) {
+ if (aifp == NULL) {
aifp = ifwithname(inbuf.ifname, 0);
- if (aifp == 0) {
+ if (aifp == NULL) {
msglim(&bad_name, from.sin_addr.s_addr,
"impossible interface name %.*s",
IFNAMSIZ, inbuf.ifname);
@@ -115,13 +115,13 @@ read_rip(int sock,
/* If it came via the wrong interface, do not
* trust it.
*/
- aifp = 0;
+ aifp = NULL;
}
}
#else
aifp = iflookup(from.sin_addr.s_addr);
#endif
- if (sifp == 0)
+ if (sifp == NULL)
sifp = aifp;
input(&from, sifp, aifp, &inbuf.pbuf.rip, cc);
@@ -148,19 +148,19 @@ input(struct sockaddr_in *from, /* received from this IP address */
struct interface *ifp1;
naddr gate, mask, v1_mask, dst, ddst_h = 0;
struct auth *ap;
- struct tgate *tg = 0;
+ struct tgate *tg = NULL;
struct tgate_net *tn;
int i, j;
/* Notice when we hear from a remote gateway
*/
- if (aifp != 0
+ if (aifp != NULL
&& (aifp->int_state & IS_REMOTE))
aifp->int_act_time = now.tv_sec;
trace_rip("Recv", "from", from, sifp, rip, cc);
- if (sifp == 0) {
+ if (sifp == NULL) {
trace_pkt(" discard a request from an indirect router"
" (possibly an attack)");
return;
@@ -206,7 +206,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
case RIPCMD_REQUEST:
/* For mere requests, be a little sloppy about the source
*/
- if (aifp == 0)
+ if (aifp == NULL)
aifp = sifp;
/* Are we talking to ourself or a remote gateway?
@@ -233,7 +233,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
* the router does not depend on us.
*/
if (rip_sock < 0
- || (aifp != 0
+ || (aifp != NULL
&& IS_RIP_OUT_OFF(aifp->int_state))) {
trace_pkt(" discard request while RIP off");
return;
@@ -263,20 +263,20 @@ input(struct sockaddr_in *from, /* received from this IP address */
}
if (rip->rip_vers == RIPv2
- && (aifp == 0 || (aifp->int_state & IS_NO_RIPV1_OUT))) {
+ && (aifp == NULL || (aifp->int_state & IS_NO_RIPV1_OUT))) {
v12buf.buf->rip_vers = RIPv2;
/* If we have a secret but it is a cleartext secret,
* do not disclose our secret unless the other guy
* already knows it.
*/
ap = find_auth(aifp);
- if (ap != 0 && ap->type == RIP_AUTH_PW
+ if (ap != NULL && ap->type == RIP_AUTH_PW
&& n->n_family == RIP_AF_AUTH
&& !ck_passwd(aifp,rip,lim,FROM_NADDR,&use_auth))
- ap = 0;
+ ap = NULL;
} else {
v12buf.buf->rip_vers = RIPv1;
- ap = 0;
+ ap = NULL;
}
clr_ws_buf(&v12buf, ap);
@@ -308,7 +308,8 @@ input(struct sockaddr_in *from, /* received from this IP address */
if ((aifp != NULL && insecure > 0) ||
(aifp == NULL && insecure > 1))
supply(from, aifp, OUT_QUERY, 0,
- rip->rip_vers, ap != 0);
+ rip->rip_vers,
+ ap != NULL);
else
trace_pkt("Warning: "
"possible attack detected");
@@ -323,7 +324,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
* to keep an unwary host that is just starting
* from picking us as a router.
*/
- if (aifp == 0) {
+ if (aifp == NULL) {
trace_pkt("ignore distant router");
return;
}
@@ -347,7 +348,7 @@ 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))) {
+ if (NULL != (rt = rtget(RIP_DEFAULT, 0))) {
j = (rt->rt_metric
+aifp->int_metric
+aifp->int_adj_outmetric
@@ -369,7 +370,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
supply(from, aifp, OUT_UNICAST, 0,
(aifp->int_state & IS_NO_RIPV1_OUT)
? RIPv2 : RIPv1,
- ap != 0);
+ ap != NULL);
return;
}
@@ -411,7 +412,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
if (v12buf.buf->rip_vers != RIPv1)
v12buf.n->n_mask = mask;
- if (rt == 0) {
+ if (rt == NULL) {
/* we do not have the answer */
v12buf.n->n_metric = HOPCNT_INFINITY;
} else {
@@ -433,7 +434,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
if (v12buf.buf->rip_vers != RIPv1) {
v12buf.n->n_tag = rt->rt_tag;
v12buf.n->n_mask = mask;
- if (aifp != 0
+ if (aifp != NULL
&& on_net(rt->rt_gate,
aifp->int_net,
aifp->int_mask)
@@ -451,7 +452,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
/* Send the answer about specific routes.
*/
- if (ap != 0 && ap->type == RIP_AUTH_MD5)
+ if (ap != NULL && ap->type == RIP_AUTH_MD5)
end_md5_auth(&v12buf, ap);
if (from->sin_port != htons(RIP_PORT)) {
@@ -486,7 +487,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
naddr_ntoa(FROM_NADDR));
return;
}
- if (aifp == 0) {
+ if (aifp == NULL) {
msglog("trace command from unknown router %s",
naddr_ntoa(FROM_NADDR));
return;
@@ -543,7 +544,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
* via broadcast or point-to-point networks, and from
* those listed in /etc/gateways.
*/
- if (aifp == 0) {
+ if (aifp == NULL) {
msglim(&unk_router, FROM_NADDR,
" discard response from %s"
" via unexpected interface",
@@ -588,7 +589,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
tg = tgates;
while (tg->tgate_addr != FROM_NADDR) {
tg = tg->tgate_next;
- if (tg == 0) {
+ if (tg == NULL) {
trace_pkt(" discard RIP response"
" from untrusted router %s",
naddr_ntoa(FROM_NADDR));
@@ -733,7 +734,7 @@ input(struct sockaddr_in *from, /* received from this IP address */
* of the defense against RS_NET_SYN.
*/
if (have_ripv1_out
- && (((rt = rtget(dst,mask)) == 0
+ && (((rt = rtget(dst,mask)) == NULL
|| !(rt->rt_state & RS_NET_SYN)))
&& (v1_mask = ripv1_mask_net(dst,0)) > mask) {
ddst_h = v1_mask & -v1_mask;
@@ -798,7 +799,7 @@ input_route(naddr dst, /* network order */
* If our interface is broken, switch to using the other guy.
*/
ifp1 = ifwithaddr(dst, 1, 1);
- if (ifp1 != 0
+ if (ifp1 != NULL
&& (!(ifp1->int_state & IS_BROKE)
|| (ifp1->int_state & IS_PASSIVE)))
return;
@@ -809,7 +810,7 @@ input_route(naddr dst, /* network order */
/* Consider adding the route if we do not already have it.
*/
- if (rt == 0) {
+ if (rt == NULL) {
/* Ignore unknown routes being poisoned.
*/
if (new->rts_metric == HOPCNT_INFINITY)
@@ -817,7 +818,7 @@ input_route(naddr dst, /* network order */
/* Ignore the route if it points to us */
if (n->n_nhop != 0
- && 0 != ifwithaddr(n->n_nhop, 1, 0))
+ && ifwithaddr(n->n_nhop, 1, 0) != NULL)
return;
/* If something has not gone crazy and tried to fill
@@ -915,7 +916,7 @@ input_route(naddr dst, /* network order */
* Ignore the route if it points to us.
*/
if (n->n_nhop != 0
- && 0 != ifwithaddr(n->n_nhop, 1, 0))
+ && NULL != ifwithaddr(n->n_nhop, 1, 0))
return;
/* the loop above set rts0=worst spare */
OpenPOWER on IntegriCloud