source: libpacketdump/link_2.cc @ 114b8d6

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 114b8d6 was 1851624, checked in by Perry Lorier <perry@…>, 16 years ago

Make dest/source obvious

  • Property mode set to 100644
File size: 704 bytes
Line 
1#include <netinet/ether.h>
2#include <netinet/in.h>
3#include <stdio.h>
4#include <inttypes.h>
5#include <dlfcn.h>
6#include <map>
7#include "libpacketdump.h"
8
9extern "C"
10void decode(int link_type,char *packet,int len)
11{
12        printf(" Ethernet:");
13        if (len>=6)
14                printf(" Dest: %s",ether_ntoa((struct ether_addr*)packet));
15        else {
16                printf("[|Truncated]\n");
17                return;
18        }
19        if (len>=12) 
20                printf(" Source: %s",ether_ntoa((struct ether_addr*)(packet+6)));
21        else {
22                printf("[|Truncated]\n");
23                return;
24        }
25        if (len>=14) {
26                uint16_t type = htons(*(uint16_t*)(packet+12));
27                printf(" Ethertype: %04x\n",type);
28                decode_next(packet+14,len-14,"eth",type);
29        }
30        else {
31                printf("[|Truncated]\n");
32                return;
33        }
34        return;
35}
Note: See TracBrowser for help on using the repository browser.