Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/sniff.hh') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/sniff.hh | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh index c7108ac..a4cf4b7 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh | |||
@@ -1,70 +1,73 @@ | |||
1 | /* $Id$ */ | 1 | /* $Id$ */ |
2 | 2 | ||
3 | #ifndef SNIFF_HH | 3 | #ifndef SNIFF_HH |
4 | #define SNIFF_HH | 4 | #define SNIFF_HH |
5 | 5 | ||
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <errno.h> | 9 | #include <errno.h> |
10 | #include <sys/types.h> | 10 | #include <sys/types.h> |
11 | #include <sys/time.h> | 11 | #include <sys/time.h> |
12 | #include <sys/socket.h> | 12 | #include <sys/socket.h> |
13 | #include <netinet/in.h> | 13 | #include <netinet/in.h> |
14 | #include <arpa/inet.h> | 14 | #include <arpa/inet.h> |
15 | 15 | ||
16 | extern "C" | 16 | extern "C" |
17 | { | 17 | { |
18 | #include <net/bpf.h> | 18 | #include <net/bpf.h> |
19 | #include <pcap.h> | 19 | #include <pcap.h> |
20 | } | 20 | } |
21 | 21 | ||
22 | #define NONBROADCASTING "non-broadcasting" | 22 | #define NONBROADCASTING "non-broadcasting" |
23 | 23 | ||
24 | /* holds all the interresting data */ | 24 | /* holds all the interresting data */ |
25 | struct packetinfo | 25 | struct packetinfo |
26 | { | 26 | { |
27 | int isvalid; | 27 | int isvalid; |
28 | int pktlen; | 28 | int pktlen; |
29 | int fctype; | 29 | int fctype; |
30 | int fcsubtype; | 30 | int fcsubtype; |
31 | int fc_wep; | 31 | int fc_wep; |
32 | int cap_WEP; | 32 | int cap_WEP; |
33 | int cap_IBSS; | 33 | int cap_IBSS; |
34 | int cap_ESS; | 34 | int cap_ESS; |
35 | int channel; | 35 | int channel; |
36 | char bssid[sizeof("00:00:00:00:00:00") + 1]; | 36 | char bssid[sizeof("00:00:00:00:00:00") + 1]; |
37 | char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; | 37 | char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; |
38 | char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; | 38 | char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; |
39 | char ssid[128]; | 39 | char ssid[128]; |
40 | int ssid_len; | 40 | int ssid_len; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | /* Function definitions */ | ||
44 | /* Used for stoping and starting the sniffer process */ | ||
45 | int start_sniffer(const char *device, int cardtype); | ||
46 | int stop_sniffer(const char *device, int cardtype); | ||
43 | void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); | 47 | void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); |
44 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); | 48 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); |
45 | void etheraddr_string(register const u_char *ep,char * text); | 49 | void etheraddr_string(register const u_char *ep,char * text); |
46 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); | 50 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); |
47 | |||
48 | int GetHeaderLength(u_int16_t fc); | 51 | int GetHeaderLength(u_int16_t fc); |
49 | 52 | ||
50 | /* | 53 | /* |
51 | * True if "l" bytes of "var" were captured. | 54 | * True if "l" bytes of "var" were captured. |
52 | * | 55 | * |
53 | * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large | 56 | * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large |
54 | * that "snapend - (l)" underflows. | 57 | * that "snapend - (l)" underflows. |
55 | * | 58 | * |
56 | * The check is for <= rather than < because "l" might be 0. | 59 | * The check is for <= rather than < because "l" might be 0. |
57 | */ | 60 | */ |
58 | #define TTEST2(var, l) (snapend - (l) <= snapend && \ | 61 | #define TTEST2(var, l) (snapend - (l) <= snapend && \ |
59 | (const u_char *)&(var) <= snapend - (l)) | 62 | (const u_char *)&(var) <= snapend - (l)) |
60 | 63 | ||
61 | /* True if "var" was captured */ | 64 | /* True if "var" was captured */ |
62 | #define TTEST(var) TTEST2(var, sizeof(var)) | 65 | #define TTEST(var) TTEST2(var, sizeof(var)) |
63 | 66 | ||
64 | /* Bail if "l" bytes of "var" were not captured */ | 67 | /* Bail if "l" bytes of "var" were not captured */ |
65 | #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc | 68 | #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc |
66 | 69 | ||
67 | /* Bail if "var" was not captured */ | 70 | /* Bail if "var" was not captured */ |
68 | #define TCHECK(var) TCHECK2(var, sizeof(var)) | 71 | #define TCHECK(var) TCHECK2(var, sizeof(var)) |
69 | 72 | ||
70 | #endif /* SNIFF_HH */ | 73 | #endif /* SNIFF_HH */ |