3 files changed, 5 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh index 7c6a21d..b85b7b7 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | |||
@@ -1,35 +1,36 @@ | |||
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 <errno.h> | 8 | #include <errno.h> |
9 | #include <sys/types.h> | ||
10 | #include <sys/time.h> | ||
9 | #include <sys/socket.h> | 11 | #include <sys/socket.h> |
10 | #include <netinet/in.h> | 12 | #include <netinet/in.h> |
11 | #include <arpa/inet.h> | ||
12 | 13 | ||
13 | extern "C" | 14 | extern "C" |
14 | { | 15 | { |
15 | #include <net/bpf.h> | 16 | #include <net/bpf.h> |
16 | #include <pcap.h> | 17 | #include <pcap.h> |
17 | } | 18 | } |
18 | 19 | ||
19 | /* Defines, used for the card setup */ | 20 | /* Defines, used for the card setup */ |
20 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" | 21 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" |
21 | #define CARD_TYPE_CISCO1 | 22 | #define CARD_TYPE_CISCO1 |
22 | #define CARD_TYPE_NG 2 | 23 | #define CARD_TYPE_NG 2 |
23 | #define CARD_TYPE_HOSTAP3 | 24 | #define CARD_TYPE_HOSTAP3 |
24 | 25 | ||
25 | /* only for now, until we have the daemon running */ | 26 | /* only for now, until we have the daemon running */ |
26 | /*the config file should provide these information */ | 27 | /*the config file should provide these information */ |
27 | #define CARD_TYPE CARD_TYPE_HOSTAP | 28 | #define CARD_TYPE CARD_TYPE_HOSTAP |
28 | #define SBIN_PATH "/sbin/ifconfig %s promisc up" | 29 | #define SBIN_PATH "/sbin/ifconfig %s promisc up" |
29 | #define WLANCTL_PATH "/sbin/wlanctl-ng" | 30 | #define WLANCTL_PATH "/sbin/wlanctl-ng" |
30 | 31 | ||
31 | /* Prototypes */ | 32 | /* Prototypes */ |
32 | int card_into_monitormode (pcap_t **, char *, int); | 33 | int card_into_monitormode (pcap_t **, char *, int); |
33 | int card_set_promisc_up (const char *); | 34 | int card_set_promisc_up (const char *); |
34 | 35 | ||
35 | #endif /* CARDMODE_HH */ | 36 | #endif /* CARDMODE_HH */ |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/proto.cc index 2ec23f4..a1228e4 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/proto.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/proto.cc | |||
@@ -1,72 +1,73 @@ | |||
1 | /* | 1 | /* |
2 | * Communication protocol | 2 | * Communication protocol |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include "proto.hh" | 7 | #include "proto.hh" |
8 | #include "sock.hh" | 8 | #include "sock.hh" |
9 | #include "log.hh" | ||
9 | 10 | ||
10 | /* Send found network to GUI */ | 11 | /* Send found network to GUI */ |
11 | int send_network_found (const char *guihost, int guiport, void *structure) | 12 | int send_network_found (const char *guihost, int guiport, void *structure) |
12 | { | 13 | { |
13 | wl_network_t *ptr; | 14 | wl_network_t *ptr; |
14 | char buffer[2048]; | 15 | char buffer[2048]; |
15 | char temp[5]; | 16 | char temp[5]; |
16 | 17 | ||
17 | ptr = (wl_network_t *)structure; | 18 | ptr = (wl_network_t *)structure; |
18 | 19 | ||
19 | memset(buffer, 0, 2048); | 20 | memset(buffer, 0, 2048); |
20 | 21 | ||
21 | /* Type = Found new net */ | 22 | /* Type = Found new net */ |
22 | memcpy(buffer, "01", 2); | 23 | memcpy(buffer, "01", 2); |
23 | 24 | ||
24 | /* Set Net-type */ | 25 | /* Set Net-type */ |
25 | memset(temp, 0, sizeof(temp)); | 26 | memset(temp, 0, sizeof(temp)); |
26 | snprintf(temp, 2, "%d", ptr->net_type); | 27 | snprintf(temp, 2, "%d", ptr->net_type); |
27 | memcpy(buffer + 2, temp, 1); | 28 | memcpy(buffer + 2, temp, 1); |
28 | 29 | ||
29 | /* Set channel */ | 30 | /* Set channel */ |
30 | memset(temp, 0, sizeof(temp)); | 31 | memset(temp, 0, sizeof(temp)); |
31 | 32 | ||
32 | if(ptr->channel < 10) | 33 | if(ptr->channel < 10) |
33 | snprintf(temp, 3, "0%d", ptr->channel); | 34 | snprintf(temp, 3, "0%d", ptr->channel); |
34 | else | 35 | else |
35 | snprintf(temp, 3, "%d", ptr->channel); | 36 | snprintf(temp, 3, "%d", ptr->channel); |
36 | 37 | ||
37 | memcpy(buffer + 3, temp, 2); | 38 | memcpy(buffer + 3, temp, 2); |
38 | 39 | ||
39 | /* Set WEP y/n */ | 40 | /* Set WEP y/n */ |
40 | memset(temp, 0, sizeof(temp)); | 41 | memset(temp, 0, sizeof(temp)); |
41 | snprintf(temp, 2, "%d", ptr->wep); | 42 | snprintf(temp, 2, "%d", ptr->wep); |
42 | memcpy(buffer + 5, temp, 1); | 43 | memcpy(buffer + 5, temp, 1); |
43 | 44 | ||
44 | /* Set MAC address */ | 45 | /* Set MAC address */ |
45 | memcpy(buffer + 6, ptr->mac, 17); | 46 | memcpy(buffer + 6, ptr->mac, 17); |
46 | 47 | ||
47 | /* Set lenght of ssid */ | 48 | /* Set lenght of ssid */ |
48 | memset(temp, 0, sizeof(temp)); | 49 | memset(temp, 0, sizeof(temp)); |
49 | 50 | ||
50 | if(ptr->ssid_len > 99) | 51 | if(ptr->ssid_len > 99) |
51 | snprintf(temp, 4, "%d", ptr->ssid_len); | 52 | snprintf(temp, 4, "%d", ptr->ssid_len); |
52 | else if(ptr->ssid_len < 10) | 53 | else if(ptr->ssid_len < 10) |
53 | snprintf(temp, 4, "00%d", ptr->ssid_len); | 54 | snprintf(temp, 4, "00%d", ptr->ssid_len); |
54 | else | 55 | else |
55 | snprintf(temp, 4, "0%d", ptr->ssid_len); | 56 | snprintf(temp, 4, "0%d", ptr->ssid_len); |
56 | 57 | ||
57 | memcpy(buffer + 23, temp, 3); | 58 | memcpy(buffer + 23, temp, 3); |
58 | 59 | ||
59 | /* Set ssid */ | 60 | /* Set ssid */ |
60 | memcpy(buffer + 26, ptr->bssid, ptr->ssid_len); | 61 | memcpy(buffer + 26, ptr->bssid, ptr->ssid_len); |
61 | 62 | ||
62 | /* Send prepared buffer to GUI */ | 63 | /* Send prepared buffer to GUI */ |
63 | #ifdef DEBUG | 64 | #ifdef DEBUG |
64 | wl_loginfo("Sending network to GUI: '%s'", buffer); | 65 | wl_loginfo("Sending network to GUI: '%s'", buffer); |
65 | #endif | 66 | #endif |
66 | 67 | ||
67 | sendcomm(guihost, guiport, buffer); | 68 | sendcomm(guihost, guiport, buffer); |
68 | 69 | ||
69 | return 1; | 70 | return 1; |
70 | } | 71 | } |
71 | 72 | ||
72 | /* Fill buffer into structur */ | 73 | /* Fill buffer into structur */ |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh index c13461a..c7108ac 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh | |||
@@ -1,68 +1,70 @@ | |||
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> | ||
11 | #include <sys/time.h> | ||
10 | #include <sys/socket.h> | 12 | #include <sys/socket.h> |
11 | #include <netinet/in.h> | 13 | #include <netinet/in.h> |
12 | #include <arpa/inet.h> | 14 | #include <arpa/inet.h> |
13 | 15 | ||
14 | extern "C" | 16 | extern "C" |
15 | { | 17 | { |
16 | #include <net/bpf.h> | 18 | #include <net/bpf.h> |
17 | #include <pcap.h> | 19 | #include <pcap.h> |
18 | } | 20 | } |
19 | 21 | ||
20 | #define NONBROADCASTING "non-broadcasting" | 22 | #define NONBROADCASTING "non-broadcasting" |
21 | 23 | ||
22 | /* holds all the interresting data */ | 24 | /* holds all the interresting data */ |
23 | struct packetinfo | 25 | struct packetinfo |
24 | { | 26 | { |
25 | int isvalid; | 27 | int isvalid; |
26 | int pktlen; | 28 | int pktlen; |
27 | int fctype; | 29 | int fctype; |
28 | int fcsubtype; | 30 | int fcsubtype; |
29 | int fc_wep; | 31 | int fc_wep; |
30 | int cap_WEP; | 32 | int cap_WEP; |
31 | int cap_IBSS; | 33 | int cap_IBSS; |
32 | int cap_ESS; | 34 | int cap_ESS; |
33 | int channel; | 35 | int channel; |
34 | char bssid[sizeof("00:00:00:00:00:00") + 1]; | 36 | char bssid[sizeof("00:00:00:00:00:00") + 1]; |
35 | char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; | 37 | char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; |
36 | char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; | 38 | char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; |
37 | char ssid[128]; | 39 | char ssid[128]; |
38 | int ssid_len; | 40 | int ssid_len; |
39 | }; | 41 | }; |
40 | 42 | ||
41 | void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); | 43 | void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); |
42 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); | 44 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); |
43 | void etheraddr_string(register const u_char *ep,char * text); | 45 | void etheraddr_string(register const u_char *ep,char * text); |
44 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); | 46 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); |
45 | 47 | ||
46 | int GetHeaderLength(u_int16_t fc); | 48 | int GetHeaderLength(u_int16_t fc); |
47 | 49 | ||
48 | /* | 50 | /* |
49 | * True if "l" bytes of "var" were captured. | 51 | * True if "l" bytes of "var" were captured. |
50 | * | 52 | * |
51 | * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large | 53 | * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large |
52 | * that "snapend - (l)" underflows. | 54 | * that "snapend - (l)" underflows. |
53 | * | 55 | * |
54 | * The check is for <= rather than < because "l" might be 0. | 56 | * The check is for <= rather than < because "l" might be 0. |
55 | */ | 57 | */ |
56 | #define TTEST2(var, l) (snapend - (l) <= snapend && \ | 58 | #define TTEST2(var, l) (snapend - (l) <= snapend && \ |
57 | (const u_char *)&(var) <= snapend - (l)) | 59 | (const u_char *)&(var) <= snapend - (l)) |
58 | 60 | ||
59 | /* True if "var" was captured */ | 61 | /* True if "var" was captured */ |
60 | #define TTEST(var) TTEST2(var, sizeof(var)) | 62 | #define TTEST(var) TTEST2(var, sizeof(var)) |
61 | 63 | ||
62 | /* Bail if "l" bytes of "var" were not captured */ | 64 | /* Bail if "l" bytes of "var" were not captured */ |
63 | #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc | 65 | #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc |
64 | 66 | ||
65 | /* Bail if "var" was not captured */ | 67 | /* Bail if "var" was not captured */ |
66 | #define TCHECK(var) TCHECK2(var, sizeof(var)) | 68 | #define TCHECK(var) TCHECK2(var, sizeof(var)) |
67 | 69 | ||
68 | #endif /* SNIFF_HH */ | 70 | #endif /* SNIFF_HH */ |