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: 1.4 KB
[950d54a]1#include <netinet/in.h>
2#include <stdio.h>
3#include <inttypes.h>
4#include <dlfcn.h>
5#include "libpacketdump.h"
[4e65f42]6#include "libtrace.h"
8struct ieee_802_11_header {
9        uint8_t      protocol:2;
10        uint8_t      type:2;
11        uint8_t      subtype:4;
12        uint8_t      to_ds:1;
13        uint8_t      from_ds:1;
14        uint8_t      more_frag:1;
15        uint8_t      retry:1;
16        uint8_t      power:1;
17        uint8_t      more_data:1;
18        uint8_t      wep:1;
19        uint8_t      order:1;
20        uint16_t     duration;
21        uint8_t      mac1[6];
22        uint8_t      mac2[6];
23        uint8_t      mac3[6];
24        uint16_t     SeqCtl;
25        uint8_t      mac4[6];
26        uint8_t      data[1];
29struct ieee_802_11_payload {
30        uint16_t     type;
31        uint8_t      data[1];
34extern "C"
35void decode(int link_type,char *packet,int len)
[4e65f42]37        char ether_buf[18] = {0, };
[950d54a]38        printf(" 802.11:");
39        struct ieee_802_11_header *hdr = (struct ieee_802_11_header *)packet;
[4e65f42]41        printf(" %s",trace_ether_ntoa((uint8_t*)(hdr->mac1), ether_buf));
42        printf(" %s",trace_ether_ntoa((uint8_t*)(hdr->mac2), ether_buf));
43        printf(" %s",trace_ether_ntoa((uint8_t*)(hdr->mac3), ether_buf));
45        struct ieee_802_11_payload *pld = (struct ieee_802_11_payload *) ((int)packet + sizeof(struct ieee_802_11_header) - 2);
46        uint16_t type = htons(pld->type);
47        printf(" %04x\n",type);
48        decode_next((char *)pld->data,len-(sizeof(struct ieee_802_11_header)),"eth",type);
49        return;
Note: See TracBrowser for help on using the repository browser.