summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/daemon/source/sniffer.hh
authormjm <mjm>2002-11-12 22:12:33 (UTC)
committer mjm <mjm>2002-11-12 22:12:33 (UTC)
commiteaecbed44924ece119c5b41db2828b4554f263d2 (patch) (unidiff)
treeb87dd3d049ea1768b20192f6c674f8684a41282c /noncore/net/wellenreiter/daemon/source/sniffer.hh
parent15bc80dffd7a4c52985a742cb3a439da42692478 (diff)
downloadopie-eaecbed44924ece119c5b41db2828b4554f263d2.zip
opie-eaecbed44924ece119c5b41db2828b4554f263d2.tar.gz
opie-eaecbed44924ece119c5b41db2828b4554f263d2.tar.bz2
pre-alpha version, most things does not work yet.
todo: communication protocol with GUI and implementation of sniffer
Diffstat (limited to 'noncore/net/wellenreiter/daemon/source/sniffer.hh') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/daemon/source/sniffer.hh83
1 files changed, 83 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/daemon/source/sniffer.hh b/noncore/net/wellenreiter/daemon/source/sniffer.hh
new file mode 100644
index 0000000..7f45be6
--- a/dev/null
+++ b/noncore/net/wellenreiter/daemon/source/sniffer.hh
@@ -0,0 +1,83 @@
1/* $Id$ */
2
3#ifndef SNIFFER_HH
4#define SNIFFER_HH
5
6#include <string.h>
7#include <stdio.h>
8#include <stdlib.h>
9#include <pcap.h>
10#include <errno.h>
11#include <sys/socket.h>
12#include <netinet/in.h>
13#include <arpa/inet.h>
14#include <net/bpf.h>
15
16#define DEFAULT_PATH "/proc/driver/aironet/%s/Config"
17 #define CARD_TYPE_CISCO1
18 #define CARD_TYPE_NG2
19 #define CARD_TYPE_HOSTAP3
20
21#define NONBROADCASTING "non-broadcasting"
22
23/* only for now, until we have the daemon running */
24/*the config file should provide these information */
25 #define SNIFFER_DEVICE "wlan0"
26#define CARD_TYPE CARD_TYPE_CISCO
27 #define SBIN_PATH"/sbin/ifconfig %s promisc up"
28#define WLANCTL_PATH "/sbin/wlanctl-ng"
29
30/* holds all the interresting data */
31struct packetinfo
32{
33 int isvalid;
34 int pktlen;
35 int fctype;
36 int fcsubtype;
37 int fc_wep;
38 int cap_WEP;
39 int cap_IBSS;
40 int cap_ESS;
41 int channel;
42 char bssid[sizeof("00:00:00:00:00:00")];
43 char desthwaddr[sizeof("00:00:00:00:00:00")];
44 char sndhwaddr[sizeof("00:00:00:00:00:00")];
45 char *ssid;
46 int ssid_len;
47};
48
49
50/* Prototypes */
51
52int sniffer(void);
53int card_into_monitormode (char * device, int cardtype);
54int card_set_promisc_up (char * device);
55int start_sniffing (char * device);
56void process_packets(u_char *useless,const struct pcap_pkthdr* pkthdr,const u_char* packet);
57int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo);
58void etheraddr_string(register const u_char *ep,char * text);
59int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo);
60
61static int GetHeaderLength(u_int16_t fc);
62
63/*
64 * True if "l" bytes of "var" were captured.
65 *
66 * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large
67 * that "snapend - (l)" underflows.
68 *
69 * The check is for <= rather than < because "l" might be 0.
70 */
71#define TTEST2(var, l) (snapend - (l) <= snapend && \
72 (const u_char *)&(var) <= snapend - (l))
73
74/* True if "var" was captured */
75#define TTEST(var) TTEST2(var, sizeof(var))
76
77/* Bail if "l" bytes of "var" were not captured */
78#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc
79
80/* Bail if "var" was not captured */
81#define TCHECK(var) TCHECK2(var, sizeof(var))
82
83#endif /* SNIFFER_HH */