source: libpacketdump/link_6.c @ 1326d5f

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 1326d5f was 8e580c5, checked in by Perry Lorier <perry@…>, 11 years ago

use trace_get_payload_from_meta() as it's exported.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 * Linux SLL Decoder
3 *
4 */
5
6#include <sys/types.h>
7#include <netinet/in.h>
8#include <stdio.h>
9#include "libpacketdump.h"
10#include "libtrace.h"
11#include "libtrace_int.h"
12
13DLLEXPORT void decode(int link_type ,const char *pkt,unsigned len) 
14{
15        libtrace_sll_header_t *sll = (libtrace_sll_header_t *) pkt;
16        libtrace_linktype_t linktype = link_type;
17        void *ret;     
18
19        if (len < sizeof(*sll)) {
20                printf(" Linux SLL: Truncated (len = %u)\n", len);
21                return;
22        }
23
24        printf(" Linux SLL: Packet Type = ");
25        switch(ntohs(sll->pkttype)) {
26                case TRACE_SLL_HOST: printf("HOST\n"); break;
27                case TRACE_SLL_BROADCAST: printf("BROADCAST\n"); break;
28                case TRACE_SLL_MULTICAST: printf("MULTICAST\n"); break;
29                case TRACE_SLL_OTHERHOST: printf("OTHERHOST\n"); break;
30                case TRACE_SLL_OUTGOING: printf("OUTGOING\n"); break;
31                default: printf("Unknown (0x%04x)\n", ntohs(sll->pkttype));
32        }
33       
34        printf(" Linux SLL: Hardware Address Type = 0x%04x\n", ntohs(sll->hatype));
35        printf(" Linux SLL: Hardware Address Length = %u\n", ntohs(sll->halen));
36        printf(" Linux SLL: Hardware Address = %s\n", trace_ether_ntoa( (sll->addr), NULL));
37
38        printf(" Linux SLL: Protocol = 0x%04x\n", ntohs(sll->protocol));
39
40        /* Decide how to continue processing... */
41       
42        /* Do we recognise the hardware address type? */
43        ret=trace_get_payload_from_meta(pkt, &linktype, &len);
44        /*type = arphrd_type_to_libtrace(ntohs(sll->hatype)); */
45        if (linktype != 65535) { 
46                decode_next(ret, len, "link", linktype);
47                /*decode_next(pkt + sizeof(*sll), len - sizeof(*sll), "link", type);*/
48                return;
49        }
50
51        /* Meh.. pass it off to eth decoder */
52        decode_next(pkt + sizeof(*sll), len - sizeof(*sll), "eth", ntohs(sll->protocol));
53
54}
55
56
Note: See TracBrowser for help on using the repository browser.