diff options
Diffstat (limited to 'slirp/ip_input.c')
-rw-r--r-- | slirp/ip_input.c | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/slirp/ip_input.c b/slirp/ip_input.c index a7d6e3181..b04684027 100644 --- a/slirp/ip_input.c +++ b/slirp/ip_input.c @@ -45,10 +45,19 @@ #include <slirp.h> #include "ip_icmp.h" -int ip_defttl; +#ifdef LOG_ENABLED struct ipstat ipstat; +#endif + struct ipq ipq; +static struct ip *ip_reass(register struct ipasfrag *ip, + register struct ipq *fp); +static void ip_freef(struct ipq *fp); +static void ip_enq(register struct ipasfrag *p, + register struct ipasfrag *prev); +static void ip_deq(register struct ipasfrag *p); + /* * IP initialization: fill in IP protocol switch table. * All protocols not implemented in kernel go to raw IP protocol handler. @@ -60,7 +69,6 @@ ip_init() ip_id = tt.tv_sec & 0xffff; udp_init(); tcp_init(); - ip_defttl = IPDEFTTL; } /* @@ -78,23 +86,23 @@ ip_input(m) DEBUG_ARG("m = %lx", (long)m); DEBUG_ARG("m_len = %d", m->m_len); - ipstat.ips_total++; + STAT(ipstat.ips_total++); if (m->m_len < sizeof (struct ip)) { - ipstat.ips_toosmall++; + STAT(ipstat.ips_toosmall++); return; } ip = mtod(m, struct ip *); if (ip->ip_v != IPVERSION) { - ipstat.ips_badvers++; + STAT(ipstat.ips_badvers++); goto bad; } hlen = ip->ip_hl << 2; if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */ - ipstat.ips_badhlen++; /* or packet too short */ + STAT(ipstat.ips_badhlen++); /* or packet too short */ goto bad; } @@ -103,7 +111,7 @@ ip_input(m) * if (ip->ip_sum) { */ if(cksum(m,hlen)) { - ipstat.ips_badsum++; + STAT(ipstat.ips_badsum++); goto bad; } @@ -112,7 +120,7 @@ ip_input(m) */ NTOHS(ip->ip_len); if (ip->ip_len < hlen) { - ipstat.ips_badlen++; + STAT(ipstat.ips_badlen++); goto bad; } NTOHS(ip->ip_id); @@ -125,7 +133,7 @@ ip_input(m) * Drop packet if shorter than we expect. */ if (m->m_len < ip->ip_len) { - ipstat.ips_tooshort++; + STAT(ipstat.ips_tooshort++); goto bad; } /* Should drop packet if mbuf too long? hmmm... */ @@ -192,11 +200,11 @@ ip_input(m) * attempt reassembly; if it succeeds, proceed. */ if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) { - ipstat.ips_fragments++; + STAT(ipstat.ips_fragments++); ip = ip_reass((struct ipasfrag *)ip, fp); if (ip == 0) return; - ipstat.ips_reassembled++; + STAT(ipstat.ips_reassembled++); m = dtom(ip); } else if (fp) @@ -208,7 +216,7 @@ ip_input(m) /* * Switch out to protocol's input routine. */ - ipstat.ips_delivered++; + STAT(ipstat.ips_delivered++); switch (ip->ip_p) { case IPPROTO_TCP: tcp_input(m, hlen, (struct socket *)NULL); @@ -220,7 +228,7 @@ ip_input(m) icmp_input(m, hlen); break; default: - ipstat.ips_noproto++; + STAT(ipstat.ips_noproto++); m_free(m); } return; @@ -235,10 +243,8 @@ bad: * reassembly of this datagram already exists, then it * is given as fp; otherwise have to make a chain. */ -struct ip * -ip_reass(ip, fp) - register struct ipasfrag *ip; - register struct ipq *fp; +static struct ip * +ip_reass(register struct ipasfrag *ip, register struct ipq *fp) { register struct mbuf *m = dtom(ip); register struct ipasfrag *q; @@ -385,7 +391,7 @@ insert: return ((struct ip *)ip); dropfrag: - ipstat.ips_fragdropped++; + STAT(ipstat.ips_fragdropped++); m_freem(m); return (0); } @@ -394,9 +400,8 @@ dropfrag: * Free a fragment reassembly header and all * associated datagrams. */ -void -ip_freef(fp) - struct ipq *fp; +static void +ip_freef(struct ipq *fp) { register struct ipasfrag *q, *p; @@ -414,9 +419,8 @@ ip_freef(fp) * Put an ip fragment on a reassembly chain. * Like insque, but pointers in middle of structure. */ -void -ip_enq(p, prev) - register struct ipasfrag *p, *prev; +static void +ip_enq(register struct ipasfrag *p, register struct ipasfrag *prev) { DEBUG_CALL("ip_enq"); DEBUG_ARG("prev = %lx", (long)prev); @@ -429,9 +433,8 @@ ip_enq(p, prev) /* * To ip_enq as remque is to insque. */ -void -ip_deq(p) - register struct ipasfrag *p; +static void +ip_deq(register struct ipasfrag *p) { ((struct ipasfrag *)(p->ipf_prev))->ipf_next = p->ipf_next; ((struct ipasfrag *)(p->ipf_next))->ipf_prev = p->ipf_prev; @@ -457,7 +460,7 @@ ip_slowtimo() --fp->ipq_ttl; fp = (struct ipq *) fp->next; if (((struct ipq *)(fp->prev))->ipq_ttl == 0) { - ipstat.ips_fragtimeout++; + STAT(ipstat.ips_fragtimeout++); ip_freef((struct ipq *) fp->prev); } } @@ -664,7 +667,7 @@ bad: /* Not yet */ icmp_error(m, type, code, 0, 0); - ipstat.ips_badoptions++; + STAT(ipstat.ips_badoptions++); return (1); } |