source: libpacketdump/ @ 11c4044

Last change on this file since 11c4044 was 4e65f42, checked in by Shane Alcock <salcock@…>, 16 years ago

Fixed segmentation faults when trace_destroy is called on a trace that wasn't successfully created
libdl is now checked for and only linked against if available (BSD's don't have a libdl)
Fixed the libpacketdump .so's to use libtrace's generic protocol headers as well as trace_ether_ntoa
Added missing check for strlcpy
Added a couple of #defines to various tools that needed them under FreeBSD
Removed some needless #includes from the libpacketdump .so's

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