Revision 31a60e22 slirp/ip_input.c

b/slirp/ip_input.c
46 46
#include "ip_icmp.h"
47 47

  
48 48
int ip_defttl;
49

  
50
#ifdef LOG_ENABLED
49 51
struct ipstat ipstat;
52
#endif
53

  
50 54
struct ipq ipq;
51 55

  
52 56
/*
......
78 82
	DEBUG_ARG("m = %lx", (long)m);
79 83
	DEBUG_ARG("m_len = %d", m->m_len);
80 84

  
81
	ipstat.ips_total++;
85
	STAT(ipstat.ips_total++);
82 86

  
83 87
	if (m->m_len < sizeof (struct ip)) {
84
		ipstat.ips_toosmall++;
88
		STAT(ipstat.ips_toosmall++);
85 89
		return;
86 90
	}
87 91

  
88 92
	ip = mtod(m, struct ip *);
89 93

  
90 94
	if (ip->ip_v != IPVERSION) {
91
		ipstat.ips_badvers++;
95
		STAT(ipstat.ips_badvers++);
92 96
		goto bad;
93 97
	}
94 98

  
95 99
	hlen = ip->ip_hl << 2;
96 100
	if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */
97
	  ipstat.ips_badhlen++;                     /* or packet too short */
101
	  STAT(ipstat.ips_badhlen++);                     /* or packet too short */
98 102
	  goto bad;
99 103
	}
100 104

  
......
103 107
	 * if (ip->ip_sum) {
104 108
	 */
105 109
	if(cksum(m,hlen)) {
106
	  ipstat.ips_badsum++;
110
	  STAT(ipstat.ips_badsum++);
107 111
	  goto bad;
108 112
	}
109 113

  
......
112 116
	 */
113 117
	NTOHS(ip->ip_len);
114 118
	if (ip->ip_len < hlen) {
115
		ipstat.ips_badlen++;
119
		STAT(ipstat.ips_badlen++);
116 120
		goto bad;
117 121
	}
118 122
	NTOHS(ip->ip_id);
......
125 129
	 * Drop packet if shorter than we expect.
126 130
	 */
127 131
	if (m->m_len < ip->ip_len) {
128
		ipstat.ips_tooshort++;
132
		STAT(ipstat.ips_tooshort++);
129 133
		goto bad;
130 134
	}
131 135
	/* Should drop packet if mbuf too long? hmmm... */
......
192 196
		 * attempt reassembly; if it succeeds, proceed.
193 197
		 */
194 198
		if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) {
195
			ipstat.ips_fragments++;
199
			STAT(ipstat.ips_fragments++);
196 200
			ip = ip_reass((struct ipasfrag *)ip, fp);
197 201
			if (ip == 0)
198 202
				return;
199
			ipstat.ips_reassembled++;
203
			STAT(ipstat.ips_reassembled++);
200 204
			m = dtom(ip);
201 205
		} else
202 206
			if (fp)
......
208 212
	/*
209 213
	 * Switch out to protocol's input routine.
210 214
	 */
211
	ipstat.ips_delivered++;
215
	STAT(ipstat.ips_delivered++);
212 216
	switch (ip->ip_p) {
213 217
	 case IPPROTO_TCP:
214 218
		tcp_input(m, hlen, (struct socket *)NULL);
......
220 224
		icmp_input(m, hlen);
221 225
		break;
222 226
	 default:
223
		ipstat.ips_noproto++;
227
		STAT(ipstat.ips_noproto++);
224 228
		m_free(m);
225 229
	}
226 230
	return;
......
385 389
	return ((struct ip *)ip);
386 390

  
387 391
dropfrag:
388
	ipstat.ips_fragdropped++;
392
	STAT(ipstat.ips_fragdropped++);
389 393
	m_freem(m);
390 394
	return (0);
391 395
}
......
457 461
		--fp->ipq_ttl;
458 462
		fp = (struct ipq *) fp->next;
459 463
		if (((struct ipq *)(fp->prev))->ipq_ttl == 0) {
460
			ipstat.ips_fragtimeout++;
464
			STAT(ipstat.ips_fragtimeout++);
461 465
			ip_freef((struct ipq *) fp->prev);
462 466
		}
463 467
	}
......
664 668
/* Not yet */
665 669
 	icmp_error(m, type, code, 0, 0);
666 670

  
667
	ipstat.ips_badoptions++;
671
	STAT(ipstat.ips_badoptions++);
668 672
	return (1);
669 673
}
670 674

  

Also available in: Unified diff