-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | 18 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | 1 |
2 files changed, 13 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc index 9e0a772..29dcc75 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | |||
@@ -128,33 +128,36 @@ int card_set_promisc_up (const char *device) | |||
128 | strncpy(ifr.ifr_name, device,10); | 128 | strncpy(ifr.ifr_name, device,10); |
129 | ifr.ifr_flags = IFF_UP + IFF_PROMISC; | 129 | ifr.ifr_flags = IFF_UP + IFF_PROMISC; |
130 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); | 130 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); |
131 | if (err < 0) | 131 | if (err < 0) |
132 | { | 132 | { |
133 | perror("Could not access the interface, "); | 133 | perror("Could not access the interface, "); |
134 | close(fd); | ||
134 | return 0; | 135 | return 0; |
135 | } | 136 | } |
136 | 137 | ||
137 | /* Get the informations back from the interface to check if the flags are correct */ | 138 | /* Get the informations back from the interface to check if the flags are correct */ |
138 | strncpy(ifr.ifr_name, device,10); | 139 | strncpy(ifr.ifr_name, device,10); |
139 | ioctl(fd, SIOCGIFFLAGS, &ifr); | 140 | ioctl(fd, SIOCGIFFLAGS, &ifr); |
140 | if (err < 0) | 141 | if (err < 0) |
141 | { | 142 | { |
142 | perror("Could not access the interface, "); | 143 | perror("Could not access the interface, "); |
144 | close(fd); | ||
143 | return 0; | 145 | return 0; |
144 | } | 146 | } |
145 | 147 | ||
146 | if(ifr.ifr_flags && IFF_UP) | 148 | if(ifr.ifr_flags && IFF_UP) |
147 | { | 149 | { |
148 | printf("%s is ok\n", device); | 150 | close(fd); |
149 | return 1; | 151 | return 1; |
150 | } | 152 | } |
151 | else | 153 | else |
152 | { | 154 | { |
153 | printf("%s flags could not be set", device); | 155 | wl_logerr("Could not set promisc flag on %d", device); |
154 | return 0; | 156 | close(fd); |
157 | return 0; | ||
155 | } | 158 | } |
156 | } | 159 | } |
157 | 160 | ||
158 | /* Set channel (Wireless frequency) of the device */ | 161 | /* Set channel (Wireless frequency) of the device */ |
159 | int card_set_channel (const char *device, int channel, int cardtype) | 162 | int card_set_channel (const char *device, int channel, int cardtype) |
160 | { | 163 | { |
@@ -169,29 +172,32 @@ int card_set_channel (const char *device, int channel, int cardtype) | |||
169 | int fd; | 172 | int fd; |
170 | //Wireless tools structure for the iocalls | 173 | //Wireless tools structure for the iocalls |
171 | struct iwreq ireq; | 174 | struct iwreq ireq; |
172 | int *ptr; | 175 | int *ptr; |
173 | /* Socket needed to use the iocall to */ | 176 | /* Socket needed to use the iocall to */ |
174 | fd = socket(AF_INET, SOCK_STREAM, 0); | 177 | fd = socket(AF_INET, SOCK_STREAM, 0); |
178 | |||
175 | if ( fd == -1 ) { | 179 | if ( fd == -1 ) { |
176 | return -1; | 180 | return -1; |
177 | } | 181 | } |
178 | ptr = (int *) ireq.u.name; | 182 | ptr = (int *) ireq.u.name; |
179 | // This is the monitor mode for 802.11 non-prism header | 183 | // This is the monitor mode for 802.11 non-prism header |
180 | ptr[0] = 2; | 184 | ptr[0] = 2; |
181 | ptr[1] = channel; | 185 | ptr[1] = channel; |
182 | strcpy(ireq.ifr_ifrn.ifrn_name, device); | 186 | strcpy(ireq.ifr_ifrn.ifrn_name, device); |
183 | if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0) | 187 | if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0) |
184 | { | 188 | { |
185 | /* All was fine... */ | 189 | /* All was fine... */ |
186 | // close(fd); | 190 | close(fd); |
187 | wl_loginfo("Set channel %d on interface %s",channel, device); | 191 | wl_loginfo("Set channel %d on interface %s",channel, device); |
188 | return 1; | 192 | return 1; |
189 | } | 193 | } |
190 | else | 194 | else |
191 | { /* iocall does not work */ | 195 | { |
196 | /* iocall does not work */ | ||
197 | close(fd); | ||
192 | wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); | 198 | wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); |
193 | return 0; | 199 | return 0; |
194 | } | 200 | } |
195 | } | 201 | } |
196 | else if (cardtype == CARD_TYPE_NG) | 202 | else if (cardtype == CARD_TYPE_NG) |
197 | { | 203 | { |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh index 242d8c5..4a95956 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | |||
@@ -9,12 +9,13 @@ | |||
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 <linux/if.h> | 16 | #include <linux/if.h> |
16 | #include <linux/wireless.h> | 17 | #include <linux/wireless.h> |
17 | 18 | ||
18 | #ifndef SIOCIWFIRSTPRIV | 19 | #ifndef SIOCIWFIRSTPRIV |
19 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE | 20 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE |
20 | #endif | 21 | #endif |