source: libpacketdump/link_2.c @ 176646e

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 176646e 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: 782 bytes
RevLine 
[ace188a]1#include <sys/types.h>
[09d3bef]2#include <netinet/in.h>
3#include <stdio.h>
4#include <inttypes.h>
5#include <dlfcn.h>
6#include "libtrace.h"
7#include "libpacketdump.h"
8
[c7062df]9DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
[09d3bef]10{
11        char ether_buf[18] = {0, };
12        printf(" Ethernet:");
13        if (len>=6)
14                printf(" Dest: %s",trace_ether_ntoa((uint8_t *)packet, 
15                                        ether_buf));
16        else {
17                printf("[|Truncated]\n");
18                return;
19        }
20        if (len>=12) 
21                printf(" Source: %s",trace_ether_ntoa((uint8_t*)(packet+6), 
22                                        ether_buf));
23        else {
24                printf("[|Truncated]\n");
25                return;
26        }
27        if (len>=14) {
28                uint16_t type = htons(*(uint16_t*)(packet+12));
[f2f3327]29                printf(" Ethertype: 0x%04x\n",type);
[09d3bef]30                decode_next(packet+14,len-14,"eth",type);
31        }
32        else {
33                printf("[|Truncated]\n");
34                return;
35        }
36        return;
37}
Note: See TracBrowser for help on using the repository browser.