source: libpacketdump/link_6.c @ e4e94c38

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