summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/daemon/source/sniffer.h
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/daemon/source/sniffer.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/sniffer.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/sniffer.h b/noncore/net/wellenreiter/daemon/source/sniffer.h
new file mode 100644
index 0000000..b880b68
--- a/dev/null
+++ b/noncore/net/wellenreiter/daemon/source/sniffer.h
@@ -0,0 +1,102 @@
1// Wellenreiter-sniffer-code header file
2
3#include <string.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <pcap.h>
7#include <errno.h>
8#include <sys/socket.h>
9#include <netinet/in.h>
10#include <arpa/inet.h>
11#include <net/bpf.h>
12#include "ieee802_11.h"
13#include "extract.h"
14
15#define DEFAULT_PATH "/proc/driver/aironet/%s/Config"
16 #define CARD_TYPE_CISCO1
17 #define CARD_TYPE_NG2
18 #define CARD_TYPE_HOSTAP3
19
20#define NONBROADCASTING "non-broadcasting"
21
22/* only for now, until we have the daemon running */
23/*the config file should provide these information */
24 #define SNIFFER_DEVICE "wlan0"
25#define CARD_TYPE CARD_TYPE_CISCO
26 #define SBIN_PATH"/sbin/ifconfig %s promisc up"
27#define WLANCTL_PATH "/sbin/wlanctl-ng"
28
29/* holds all the interresting data */
30struct packetinfo
31{
32 int isvalid;
33 int pktlen;
34 int fctype;
35 int fcsubtype;
36 int fc_wep;
37 int cap_WEP;
38 int cap_IBSS;
39 int cap_ESS;
40 int channel;
41 char bssid[sizeof("00:00:00:00:00:00")];
42 char desthwaddr[sizeof("00:00:00:00:00:00")];
43 char sndhwaddr[sizeof("00:00:00:00:00:00")];
44 char *ssid;
45 int ssid_len;
46};
47
48
49/* Prototypes */
50int card_into_monitormode (char * device, int cardtype);
51
52int card_set_promisc_up (char * device);
53
54int start_sniffing (char * device);
55
56void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char* packet);
57
58int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo);
59
60void etheraddr_string(register const u_char *ep,char * text);
61
62int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo);
63
64static int GetHeaderLength(u_int16_t fc);
65
66static const char *subtype_text[]={
67 "Assoc Request",
68 "Assoc Response",
69 "ReAssoc Request",
70 "ReAssoc Response",
71 "Probe Request",
72 "Probe Response",
73 "RESERVED",
74 "RESERVED",
75 "Beacon",
76 "ATIM",
77 "Disassociation",
78 "Authentication",
79 "DeAuthentication",
80 "RESERVED",
81 "RESERVED"
82};
83
84/*
85 * True if "l" bytes of "var" were captured.
86 *
87 * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large
88 * that "snapend - (l)" underflows.
89 *
90 * The check is for <= rather than < because "l" might be 0.
91 */
92#define TTEST2(var, l) (snapend - (l) <= snapend && \
93 (const u_char *)&(var) <= snapend - (l))
94
95/* True if "var" was captured */
96#define TTEST(var) TTEST2(var, sizeof(var))
97
98/* Bail if "l" bytes of "var" were not captured */
99#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc
100
101/* Bail if "var" was not captured */
102#define TCHECK(var) TCHECK2(var, sizeof(var))