Make Slirp statistics gathering and output conditional to LOG_ENABLED

Add 'info slirp' command to monitor to display statistics
Disable Slirp debugging code by default


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3451 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1 2007-10-26 18:42:59 +00:00
parent 7d294b61ed
commit 31a60e2275
22 changed files with 203 additions and 125 deletions

View file

@ -46,7 +46,11 @@
#include "ip_icmp.h"
int ip_defttl;
#ifdef LOG_ENABLED
struct ipstat ipstat;
#endif
struct ipq ipq;
/*
@ -78,23 +82,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 +107,7 @@ ip_input(m)
* if (ip->ip_sum) {
*/
if(cksum(m,hlen)) {
ipstat.ips_badsum++;
STAT(ipstat.ips_badsum++);
goto bad;
}
@ -112,7 +116,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 +129,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 +196,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 +212,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 +224,7 @@ ip_input(m)
icmp_input(m, hlen);
break;
default:
ipstat.ips_noproto++;
STAT(ipstat.ips_noproto++);
m_free(m);
}
return;
@ -385,7 +389,7 @@ insert:
return ((struct ip *)ip);
dropfrag:
ipstat.ips_fragdropped++;
STAT(ipstat.ips_fragdropped++);
m_freem(m);
return (0);
}
@ -457,7 +461,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 +668,7 @@ bad:
/* Not yet */
icmp_error(m, type, code, 0, 0);
ipstat.ips_badoptions++;
STAT(ipstat.ips_badoptions++);
return (1);
}