-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/sniff.hh | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh index 976ceeb..a3f8280 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | |||
@@ -1,33 +1,37 @@ | |||
1 | /* $Id$ */ | 1 | /* $Id$ */ |
2 | 2 | ||
3 | #ifndef CARDMODE_HH | 3 | #ifndef CARDMODE_HH |
4 | #define CARDMODE_HH | 4 | #define CARDMODE_HH |
5 | 5 | ||
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <pcap.h> | ||
9 | #include <errno.h> | 8 | #include <errno.h> |
10 | #include <sys/socket.h> | 9 | #include <sys/socket.h> |
11 | #include <netinet/in.h> | 10 | #include <netinet/in.h> |
12 | #include <arpa/inet.h> | 11 | #include <arpa/inet.h> |
12 | |||
13 | extern "C" | ||
14 | { | ||
13 | #include <net/bpf.h> | 15 | #include <net/bpf.h> |
16 | #include <pcap.h> | ||
17 | } | ||
14 | 18 | ||
15 | #include "../../libwellenreiter/source/log.hh" | 19 | #include "../../libwellenreiter/source/log.hh" |
16 | 20 | ||
17 | /* Defines, used for the card setup */ | 21 | /* Defines, used for the card setup */ |
18 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" | 22 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" |
19 | #define CARD_TYPE_CISCO1 | 23 | #define CARD_TYPE_CISCO1 |
20 | #define CARD_TYPE_NG 2 | 24 | #define CARD_TYPE_NG 2 |
21 | #define CARD_TYPE_HOSTAP3 | 25 | #define CARD_TYPE_HOSTAP3 |
22 | 26 | ||
23 | /* only for now, until we have the daemon running */ | 27 | /* only for now, until we have the daemon running */ |
24 | /*the config file should provide these information */ | 28 | /*the config file should provide these information */ |
25 | #define CARD_TYPE CARD_TYPE_CISCO | 29 | #define CARD_TYPE CARD_TYPE_CISCO |
26 | #define SBIN_PATH "/sbin/ifconfig %s promisc up" | 30 | #define SBIN_PATH "/sbin/ifconfig %s promisc up" |
27 | #define WLANCTL_PATH "/sbin/wlanctl-ng" | 31 | #define WLANCTL_PATH "/sbin/wlanctl-ng" |
28 | 32 | ||
29 | /* Prototypes */ | 33 | /* Prototypes */ |
30 | int card_into_monitormode (pcap_t **, char *, int); | 34 | int card_into_monitormode (pcap_t **, char *, int); |
31 | int card_set_promisc_up (const char *); | 35 | int card_set_promisc_up (const char *); |
32 | 36 | ||
33 | #endif /* CARDMODE_HH */ | 37 | #endif /* CARDMODE_HH */ |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh index 60cdc43..c13461a 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh | |||
@@ -1,62 +1,66 @@ | |||
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 <pcap.h> | ||
10 | #include <errno.h> | 9 | #include <errno.h> |
11 | #include <sys/socket.h> | 10 | #include <sys/socket.h> |
12 | #include <netinet/in.h> | 11 | #include <netinet/in.h> |
13 | #include <arpa/inet.h> | 12 | #include <arpa/inet.h> |
13 | |||
14 | extern "C" | ||
15 | { | ||
14 | #include <net/bpf.h> | 16 | #include <net/bpf.h> |
17 | #include <pcap.h> | ||
18 | } | ||
15 | 19 | ||
16 | #define NONBROADCASTING "non-broadcasting" | 20 | #define NONBROADCASTING "non-broadcasting" |
17 | 21 | ||
18 | /* holds all the interresting data */ | 22 | /* holds all the interresting data */ |
19 | struct packetinfo | 23 | struct packetinfo |
20 | { | 24 | { |
21 | int isvalid; | 25 | int isvalid; |
22 | int pktlen; | 26 | int pktlen; |
23 | int fctype; | 27 | int fctype; |
24 | int fcsubtype; | 28 | int fcsubtype; |
25 | int fc_wep; | 29 | int fc_wep; |
26 | int cap_WEP; | 30 | int cap_WEP; |
27 | int cap_IBSS; | 31 | int cap_IBSS; |
28 | int cap_ESS; | 32 | int cap_ESS; |
29 | int channel; | 33 | int channel; |
30 | char bssid[sizeof("00:00:00:00:00:00") + 1]; | 34 | char bssid[sizeof("00:00:00:00:00:00") + 1]; |
31 | char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; | 35 | char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; |
32 | char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; | 36 | char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; |
33 | char ssid[128]; | 37 | char ssid[128]; |
34 | int ssid_len; | 38 | int ssid_len; |
35 | }; | 39 | }; |
36 | 40 | ||
37 | void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); | 41 | void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); |
38 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); | 42 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); |
39 | void etheraddr_string(register const u_char *ep,char * text); | 43 | void etheraddr_string(register const u_char *ep,char * text); |
40 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); | 44 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); |
41 | 45 | ||
42 | int GetHeaderLength(u_int16_t fc); | 46 | int GetHeaderLength(u_int16_t fc); |
43 | 47 | ||
44 | /* | 48 | /* |
45 | * True if "l" bytes of "var" were captured. | 49 | * True if "l" bytes of "var" were captured. |
46 | * | 50 | * |
47 | * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large | 51 | * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large |
48 | * that "snapend - (l)" underflows. | 52 | * that "snapend - (l)" underflows. |
49 | * | 53 | * |
50 | * The check is for <= rather than < because "l" might be 0. | 54 | * The check is for <= rather than < because "l" might be 0. |
51 | */ | 55 | */ |
52 | #define TTEST2(var, l) (snapend - (l) <= snapend && \ | 56 | #define TTEST2(var, l) (snapend - (l) <= snapend && \ |
53 | (const u_char *)&(var) <= snapend - (l)) | 57 | (const u_char *)&(var) <= snapend - (l)) |
54 | 58 | ||
55 | /* True if "var" was captured */ | 59 | /* True if "var" was captured */ |
56 | #define TTEST(var) TTEST2(var, sizeof(var)) | 60 | #define TTEST(var) TTEST2(var, sizeof(var)) |
57 | 61 | ||
58 | /* Bail if "l" bytes of "var" were not captured */ | 62 | /* Bail if "l" bytes of "var" were not captured */ |
59 | #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc | 63 | #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc |
60 | 64 | ||
61 | /* Bail if "var" was not captured */ | 65 | /* Bail if "var" was not captured */ |
62 | #define TCHECK(var) TCHECK2(var, sizeof(var)) | 66 | #define TCHECK(var) TCHECK2(var, sizeof(var)) |