~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to slirp/ip_icmp.c

  • Committer: ths
  • Date: 2007-10-08 12:45:38 UTC
  • Revision ID: git-v1:450d4ff553af32fc9d83fef20d7106b0151526b8
CRIS disassembler, originally from binutils, by Edgar E. Iglesias.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3356 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "slirp.h"
38
38
#include "ip_icmp.h"
39
39
 
40
 
#ifdef LOG_ENABLED
41
40
struct icmpstat icmpstat;
42
 
#endif
43
41
 
44
42
/* The message sent when emulating PING */
45
 
/* Be nice and tell them it's just a pseudo-ping packet */
46
 
static const char icmp_ping_msg[] = "This is a pseudo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
 
43
/* Be nice and tell them it's just a psuedo-ping packet */
 
44
char icmp_ping_msg[] = "This is a psuedo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
47
45
 
48
46
/* list of actions for icmp_error() on RX of an icmp message */
49
 
static const int icmp_flush[19] = {
 
47
static int icmp_flush[19] = {
50
48
/*  ECHO REPLY (0)  */   0,
51
49
                         1,
52
50
                         1,
85
83
  DEBUG_ARG("m = %lx", (long )m);
86
84
  DEBUG_ARG("m_len = %d", m->m_len);
87
85
 
88
 
  STAT(icmpstat.icps_received++);
 
86
  icmpstat.icps_received++;
89
87
 
90
88
  /*
91
89
   * Locate icmp structure in mbuf, and check
92
90
   * that its not corrupted and of at least minimum length.
93
91
   */
94
92
  if (icmplen < ICMP_MINLEN) {          /* min 8 bytes payload */
95
 
    STAT(icmpstat.icps_tooshort++);
 
93
    icmpstat.icps_tooshort++;
96
94
  freeit:
97
95
    m_freem(m);
98
96
    goto end_error;
102
100
  m->m_data += hlen;
103
101
  icp = mtod(m, struct icmp *);
104
102
  if (cksum(m, icmplen)) {
105
 
    STAT(icmpstat.icps_checksum++);
 
103
    icmpstat.icps_checksum++;
106
104
    goto freeit;
107
105
  }
108
106
  m->m_len += hlen;
172
170
  case ICMP_TSTAMP:
173
171
  case ICMP_MASKREQ:
174
172
  case ICMP_REDIRECT:
175
 
    STAT(icmpstat.icps_notsupp++);
 
173
    icmpstat.icps_notsupp++;
176
174
    m_freem(m);
177
175
    break;
178
176
 
179
177
  default:
180
 
    STAT(icmpstat.icps_badtype++);
 
178
    icmpstat.icps_badtype++;
181
179
    m_freem(m);
182
180
  } /* swith */
183
181
 
207
205
 
208
206
#define ICMP_MAXDATALEN (IP_MSS-28)
209
207
void
210
 
icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
211
 
           const char *message)
 
208
icmp_error(msrc, type, code, minsize, message)
 
209
     struct mbuf *msrc;
 
210
     u_char type;
 
211
     u_char code;
 
212
     int minsize;
 
213
     char *message;
212
214
{
213
215
  unsigned hlen, shlen, s_ip_len;
214
216
  register struct ip *ip;
224
226
  /* check msrc */
225
227
  if(!msrc) goto end_error;
226
228
  ip = mtod(msrc, struct ip *);
227
 
#ifdef DEBUG
 
229
#if DEBUG
228
230
  { char bufa[20], bufb[20];
229
231
    strcpy(bufa, inet_ntoa(ip->ip_src));
230
232
    strcpy(bufb, inet_ntoa(ip->ip_dst));
281
283
  HTONS(icp->icmp_ip.ip_id);
282
284
  HTONS(icp->icmp_ip.ip_off);
283
285
 
284
 
#ifdef DEBUG
 
286
#if DEBUG
285
287
  if(message) {           /* DEBUG : append message to ICMP packet */
286
288
    int message_len;
287
289
    char *cpnt;
312
314
 
313
315
  (void ) ip_output((struct socket *)NULL, m);
314
316
 
315
 
  STAT(icmpstat.icps_reflect++);
 
317
  icmpstat.icps_reflect++;
316
318
 
317
319
end_error:
318
320
  return;
369
371
 
370
372
  (void ) ip_output((struct socket *)NULL, m);
371
373
 
372
 
  STAT(icmpstat.icps_reflect++);
 
374
  icmpstat.icps_reflect++;
373
375
}