~ubuntu-branches/ubuntu/intrepid/tcpdump/intrepid

« back to all changes in this revision

Viewing changes to print-ether.c

  • Committer: Bazaar Package Importer
  • Author(s): Romain Francoise
  • Date: 2005-12-10 14:26:20 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051210142620-t4ju0367w6j2x06i
Tags: 3.9.4-2
debian/patches/20_man_fixes.dpatch: Merge patch from A Costa
<agcosta@gis.net> fixing a few typos (closes: #342310).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
#ifndef lint
22
22
static const char rcsid[] _U_ =
23
 
    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.82.2.3 2003/12/29 22:42:21 hannes Exp $ (LBL)";
 
23
    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95.2.4 2005/07/10 14:47:57 hannes Exp $ (LBL)";
24
24
#endif
25
25
 
26
26
#ifdef HAVE_CONFIG_H
38
38
 
39
39
#include "ether.h"
40
40
 
41
 
const u_char *snapend;
42
 
 
43
41
const struct tok ethertype_values[] = { 
44
42
    { ETHERTYPE_IP,             "IPv4" },
45
43
    { ETHERTYPE_MPLS,           "MPLS unicast" },
67
65
    { ETHERTYPE_AARP,           "Appletalk ARP" },
68
66
    { ETHERTYPE_IPX,            "IPX" },
69
67
    { ETHERTYPE_PPP,            "PPP" },
 
68
    { ETHERTYPE_SLOW,           "Slow Protocols" },
70
69
    { ETHERTYPE_PPPOED,         "PPPoE D" },
71
70
    { ETHERTYPE_PPPOES,         "PPPoE S" },
 
71
    { ETHERTYPE_EAPOL,          "EAPOL" },
 
72
    { ETHERTYPE_JUMBO,          "Jumbo" },
72
73
    { ETHERTYPE_LOOPBACK,       "Loopback" },
 
74
    { ETHERTYPE_ISO,            "OSI" },
 
75
    { ETHERTYPE_GRE_ISO,        "GRE-OSI" },
73
76
    { 0, NULL}
74
77
};
75
78
 
134
137
                        if (!eflag)
135
138
                                ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN);
136
139
 
137
 
                        if (!xflag && !qflag)
 
140
                        if (!suppress_default_print)
138
141
                                default_print(p, caplen);
139
142
                }
140
143
        } else if (ether_encap_print(ether_type, p, length, caplen,
143
146
                if (!eflag)
144
147
                        ether_hdr_print((u_char *)ep, length + ETHER_HDRLEN);
145
148
 
146
 
                if (!xflag && !qflag)
 
149
                if (!suppress_default_print)
147
150
                        default_print(p, caplen);
148
151
        } 
149
152
}
151
154
/*
152
155
 * This is the top level routine of the printer.  'p' points
153
156
 * to the ether header of the packet, 'h->ts' is the timestamp,
154
 
 * 'h->length' is the length of the packet off the wire, and 'h->caplen'
 
157
 * 'h->len' is the length of the packet off the wire, and 'h->caplen'
155
158
 * is the number of bytes actually captured.
156
159
 */
157
160
u_int
184
187
        switch (ether_type) {
185
188
 
186
189
        case ETHERTYPE_IP:
187
 
                ip_print(p, length);
 
190
                ip_print(gndo, p, length);
188
191
                return (1);
189
192
 
190
193
#ifdef INET6
195
198
 
196
199
        case ETHERTYPE_ARP:
197
200
        case ETHERTYPE_REVARP:
198
 
                arp_print(p, length, caplen);
 
201
                arp_print(gndo, p, length, caplen);
199
202
                return (1);
200
203
 
201
204
        case ETHERTYPE_DN:
243
246
                                ether_hdr_print(p - 18, length + 4);
244
247
                }
245
248
 
246
 
                if (!xflag && !qflag)
 
249
                if (!suppress_default_print)
247
250
                        default_print(p - 18, caplen + 4);
248
251
 
249
252
                return (1);
250
253
 
 
254
        case ETHERTYPE_JUMBO:
 
255
                ether_type = ntohs(*(u_int16_t *)(p));
 
256
                p += 2;
 
257
                length -= 2;      
 
258
                caplen -= 2;
 
259
 
 
260
                if (ether_type > ETHERMTU) {
 
261
                    if (eflag)
 
262
                        printf("ethertype %s, ",
 
263
                               tok2str(ethertype_values,"0x%04x", ether_type));
 
264
                    goto recurse;
 
265
                }
 
266
 
 
267
                *extracted_ether_type = 0;
 
268
 
 
269
                if (llc_print(p, length, caplen, p - 16, p - 10,
 
270
                              extracted_ether_type) == 0) {
 
271
                    ether_hdr_print(p - 16, length + 2);
 
272
                }
 
273
 
 
274
                if (!suppress_default_print)
 
275
                    default_print(p - 16, caplen + 2);
 
276
 
 
277
                return (1);
 
278
 
 
279
        case ETHERTYPE_ISO:
 
280
                isoclns_print(p+1, length-1, length-1);
 
281
                return(1);
 
282
 
251
283
        case ETHERTYPE_PPPOED:
252
284
        case ETHERTYPE_PPPOES:
253
285
                pppoe_print(p, length);
254
286
                return (1);
255
287
 
 
288
        case ETHERTYPE_EAPOL:
 
289
                eap_print(gndo, p, length);
 
290
                return (1);
 
291
 
256
292
        case ETHERTYPE_PPP:
257
293
                if (length) {
258
294
                        printf(": ");
260
296
                }
261
297
                return (1);
262
298
 
 
299
        case ETHERTYPE_SLOW:
 
300
                slow_print(p, length);
 
301
                return (1);
 
302
 
263
303
        case ETHERTYPE_LOOPBACK:
264
 
                return (0);
 
304
                return (1);
265
305
 
266
306
        case ETHERTYPE_MPLS:
267
307
        case ETHERTYPE_MPLS_MULTI:
277
317
                return (0);
278
318
        }
279
319
}
 
320
 
 
321
 
 
322
/*
 
323
 * Local Variables:
 
324
 * c-style: whitesmith
 
325
 * c-basic-offset: 8
 
326
 * End:
 
327
 */
 
328