source: libpacketdump/link_6.c @ 666b5cf

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 666b5cf was c7062df, checked in by Shane Alcock <salcock@…>, 12 years ago
  • Ensure that the decode functions are exported as global symbols for the various libpacketdump shared libraries
  • Property mode set to 100644
File size: 1.5 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 UNUSED,const char *pkt,unsigned len) 
14{
15        libtrace_sll_header_t *sll = (libtrace_sll_header_t *) pkt;
16        uint16_t type;
17       
18        if (len < sizeof(*sll)) {
19                printf(" Linux SLL: Truncated (len = %u)\n", len);
20                return;
21        }
22
23        printf(" Linux SLL: Packet Type = ");
24        switch(ntohs(sll->pkttype)) {
25                case TRACE_SLL_HOST: printf("HOST\n"); break;
26                case TRACE_SLL_BROADCAST: printf("BROADCAST\n"); break;
27                case TRACE_SLL_MULTICAST: printf("MULTICAST\n"); break;
28                case TRACE_SLL_OTHERHOST: printf("OTHERHOST\n"); break;
29                case TRACE_SLL_OUTGOING: printf("OUTGOING\n"); break;
30                default: printf("Unknown (0x%04x)\n", ntohs(sll->pkttype));
31        }
32       
33        printf(" Linux SLL: Hardware Address Type = 0x%04x\n", ntohs(sll->hatype));
34        printf(" Linux SLL: Hardware Address Length = %u\n", ntohs(sll->halen));
35        printf(" Linux SLL: Hardware Address = %s\n", trace_ether_ntoa( (sll->addr), NULL));
36
37        printf(" Linux SLL: Protocol = 0x%04x\n", ntohs(sll->protocol));
38
39        /* Decide how to continue processing... */
40       
41        /* Do we recognise the hardware address type? */
42        type = arphrd_type_to_libtrace(ntohs(sll->hatype));
43        if (type != 65535) { 
44                decode_next(pkt + sizeof(*sll), len - sizeof(*sll), "link", type);
45                return;
46        }
47
48        /* Meh.. pass it off to eth decoder */
49        decode_next(pkt + sizeof(*sll), len - sizeof(*sll), "eth", ntohs(sll->protocol));
50
51}
52
53
Note: See TracBrowser for help on using the repository browser.