Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh index 58e99ac..73e0ae1 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | |||
@@ -1,105 +1,107 @@ | |||
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> | 9 | #include <sys/types.h> |
10 | #include <sys/time.h> | 10 | #include <sys/time.h> |
11 | #include <sys/socket.h> | 11 | #include <sys/socket.h> |
12 | #include <netinet/in.h> | 12 | #include <netinet/in.h> |
13 | #include <arpa/inet.h> | 13 | #include <arpa/inet.h> |
14 | #include <sys/ioctl.h> | 14 | #include <sys/ioctl.h> |
15 | #include <unistd.h> | 15 | #include <unistd.h> |
16 | #include <linux/if.h> | 16 | #include <linux/if.h> |
17 | 17 | ||
18 | /* Following typedefs are needed here, because linux/wireless.h | 18 | /* Following typedefs are needed here, because linux/wireless.h |
19 | includes linux/ethertool.h which is using them */ | 19 | includes linux/ethertool.h which is using them */ |
20 | typedef signed char s8; | 20 | typedef signed char s8; |
21 | typedef unsigned char u8; | 21 | typedef unsigned char u8; |
22 | typedef signed short s16; | 22 | typedef signed short s16; |
23 | typedef unsigned short u16; | 23 | typedef unsigned short u16; |
24 | typedef signed int s32; | 24 | typedef signed int s32; |
25 | typedef unsigned int u32; | 25 | typedef unsigned int u32; |
26 | typedef signed long long s64; | 26 | typedef signed long long s64; |
27 | typedef unsigned long long u64; | 27 | typedef unsigned long long u64; |
28 | 28 | ||
29 | #include <linux/wireless.h> | 29 | #include <linux/wireless.h> |
30 | 30 | ||
31 | #ifndef SIOCIWFIRSTPRIV | 31 | #ifndef SIOCIWFIRSTPRIV |
32 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE | 32 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | extern "C" | 35 | extern "C" |
36 | { | 36 | { |
37 | #include <net/bpf.h> | 37 | #include <net/bpf.h> |
38 | #include <pcap.h> | 38 | #include <pcap.h> |
39 | } | 39 | } |
40 | 40 | ||
41 | extern pcap_t *handletopcap; | ||
42 | |||
41 | /* Defines, used for the card setup */ | 43 | /* Defines, used for the card setup */ |
42 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" | 44 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" |
43 | #define CISCO_STATUS "/proc/driver/aironet/%s/Status" | 45 | #define CISCO_STATUS "/proc/driver/aironet/%s/Status" |
44 | #define CARD_TYPE_CISCO 1 | 46 | #define CARD_TYPE_CISCO 1 |
45 | #define CARD_TYPE_NG 2 | 47 | #define CARD_TYPE_NG 2 |
46 | #define CARD_TYPE_HOSTAP 3 | 48 | #define CARD_TYPE_HOSTAP 3 |
47 | #define CARD_TYPE_ORINOCCO 4 | 49 | #define CARD_TYPE_ORINOCCO 4 |
48 | 50 | ||
49 | /* Some usefull constants for frequencies */ | 51 | /* Some usefull constants for frequencies */ |
50 | #define KILO 1e3 | 52 | #define KILO 1e3 |
51 | #define MEGA 1e6 | 53 | #define MEGA 1e6 |
52 | #define GIGA 1e9 | 54 | #define GIGA 1e9 |
53 | 55 | ||
54 | 56 | ||
55 | /* only for now, until we have the daemon running */ | 57 | /* only for now, until we have the daemon running */ |
56 | /*the config file should provide these information */ | 58 | /*the config file should provide these information */ |
57 | #define CARD_TYPE CARD_TYPE_HOSTAP | 59 | #define CARD_TYPE CARD_TYPE_HOSTAP |
58 | 60 | ||
59 | /* Prototypes */ | 61 | /* Prototypes */ |
60 | int card_check_rfmon_datalink (const char *device); | 62 | int card_check_rfmon_datalink (const char *device); |
61 | int card_into_monitormode (pcap_t **, const char *, int); | 63 | int card_into_monitormode (const char *, int); |
64 | int check_loopback(); | ||
62 | int card_set_promisc_up (const char *device); | 65 | int card_set_promisc_up (const char *device); |
63 | int card_remove_promisc (const char *device); | 66 | int card_remove_promisc (const char *device); |
64 | int card_set_channel (const char *device, int channel,int cardtype); | 67 | int card_set_channel (const char *device, int channel,int cardtype); |
65 | int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); | 68 | int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); |
66 | double iw_freq2float(iw_freq * in); | 69 | double iw_freq2float(iw_freq * in); |
67 | void iw_float2freq(double in, iw_freq *out); | 70 | void iw_float2freq(double in, iw_freq *out); |
68 | int card_detect_channels (char * device); | 71 | int card_detect_channels (char * device); |
69 | 72 | ||
70 | |||
71 | /*------------------------------------------------------------------*/ | 73 | /*------------------------------------------------------------------*/ |
72 | /* | 74 | /* |
73 | * Wrapper to push some Wireless Parameter in the driver | 75 | * Wrapper to push some Wireless Parameter in the driver |
74 | */ | 76 | */ |
75 | static inline int | 77 | static inline int |
76 | iw_set_ext(int skfd, /* Socket to the kernel */ | 78 | iw_set_ext(int skfd, /* Socket to the kernel */ |
77 | char * ifname, /* Device name */ | 79 | char * ifname, /* Device name */ |
78 | int request,/* WE ID */ | 80 | int request,/* WE ID */ |
79 | struct iwreq * pwrq) /* Fixed part of the request */ | 81 | struct iwreq * pwrq) /* Fixed part of the request */ |
80 | { | 82 | { |
81 | /* Set device name */ | 83 | /* Set device name */ |
82 | strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); | 84 | strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); |
83 | /* Do the request */ | 85 | /* Do the request */ |
84 | return(ioctl(skfd, request, pwrq)); | 86 | return(ioctl(skfd, request, pwrq)); |
85 | } | 87 | } |
86 | 88 | ||
87 | /*------------------------------------------------------------------*/ | 89 | /*------------------------------------------------------------------*/ |
88 | /* | 90 | /* |
89 | * Wrapper to extract some Wireless Parameter out of the driver | 91 | * Wrapper to extract some Wireless Parameter out of the driver |
90 | */ | 92 | */ |
91 | static inline int | 93 | static inline int |
92 | iw_get_ext(int skfd, /* Socket to the kernel */ | 94 | iw_get_ext(int skfd, /* Socket to the kernel */ |
93 | char * ifname, /* Device name */ | 95 | char * ifname, /* Device name */ |
94 | int request,/* WE ID */ | 96 | int request,/* WE ID */ |
95 | struct iwreq * pwrq) /* Fixed part of the request */ | 97 | struct iwreq * pwrq) /* Fixed part of the request */ |
96 | { | 98 | { |
97 | /* Set device name */ | 99 | /* Set device name */ |
98 | strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); | 100 | strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); |
99 | /* Do the request */ | 101 | /* Do the request */ |
100 | return(ioctl(skfd, request, pwrq)); | 102 | return(ioctl(skfd, request, pwrq)); |
101 | } | 103 | } |
102 | 104 | ||
103 | 105 | ||
104 | 106 | ||
105 | #endif /* CARDMODE_HH */ | 107 | #endif /* CARDMODE_HH */ |