source: libpacketdump/link_1.c @ fade02b

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since fade02b was ac7037b, checked in by Shane Alcock <salcock@…>, 11 years ago
  • Added libpacketdump decoders for CHDLC and PPP/HDLC
  • Property mode set to 100644
File size: 993 bytes
Line 
1/* Decoder for CHDLC frames */
2
3#include <sys/types.h>
4#include <netinet/in.h>
5#include <stdio.h>
6#include <inttypes.h>
7#include <dlfcn.h>
8#include "libtrace.h"
9#include "libpacketdump.h"
10
11typedef struct libtrace_chdlc_t {
12        uint8_t address;        /** 0xF0 for unicast, 0xF8 for multicast */
13        uint8_t control;        /** Always 0x00 */
14        uint16_t ethertype;
15} libtrace_chdlc_t;
16
17
18DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
19{
20        libtrace_chdlc_t *frame = (libtrace_chdlc_t *)packet;
21
22        printf(" CHDLC:");
23        if (len >= 1)
24                printf(" Address: 0x%02x", frame->address);
25        else {
26                printf("[|Truncated]\n");
27                return;
28        }
29       
30        if (len >= 2)
31                printf(" Control: 0x%02x", frame->control);
32        else {
33                printf("[|Truncated]\n");
34                return;
35        }
36       
37        if (len >= 4) {
38                printf(" Ethertype: 0x%04x\n", ntohs(frame->ethertype));
39                decode_next(packet + 4, len - 4, "eth", 
40                                ntohs(frame->ethertype));
41        }
42        else {
43                printf("[|Truncated]\n");
44                return;
45        }
46       
47
48        return;
49}
Note: See TracBrowser for help on using the repository browser.