author | max <max> | 2003-02-18 09:31:47 (UTC) |
---|---|---|
committer | max <max> | 2003-02-18 09:31:47 (UTC) |
commit | 065f26b161f6df269cfbf9c75751c09453350995 (patch) (unidiff) | |
tree | 0d242028eadc37ecc9afa38af676906998d92329 | |
parent | 3d8495ee454395e95190693af9baa9420f90431f (diff) | |
download | opie-065f26b161f6df269cfbf9c75751c09453350995.zip opie-065f26b161f6df269cfbf9c75751c09453350995.tar.gz opie-065f26b161f6df269cfbf9c75751c09453350995.tar.bz2 |
Remove-promisc-flag
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | 70 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | 3 |
2 files changed, 72 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc index d385df4..7c9fbc4 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc | |||
@@ -195,16 +195,86 @@ int card_set_promisc_up (const char *device) | |||
195 | else | 195 | else |
196 | { | 196 | { |
197 | wl_logerr("Could not set promisc flag on %d", device); | 197 | wl_logerr("Could not set promisc flag on %d", device); |
198 | close(fd); | 198 | close(fd); |
199 | return 0; | 199 | return 0; |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | /* Remove card from promisc mode */ | ||
204 | int card_remove_promisc (const char *device) | ||
205 | { | ||
206 | int err; | ||
207 | /* First generate a socket to use with iocalls */ | ||
208 | int fd = socket(AF_INET, SOCK_DGRAM, 0); | ||
209 | if (fd < 0) | ||
210 | { | ||
211 | /* In case of an error */ | ||
212 | perror("socket"); | ||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | /* Fill an empty an interface structure with the right flags (UP and Promsic) */ | ||
217 | struct ifreq ifr; | ||
218 | /* strncpy(ifr.ifr_name, device,10); | ||
219 | ifr.ifr_flags = IFF_UP + IFF_PROMISC; | ||
220 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); | ||
221 | if (err < 0) | ||
222 | { | ||
223 | perror("Could not access the interface, "); | ||
224 | close(fd); | ||
225 | return 0; | ||
226 | } | ||
227 | */ | ||
228 | /* Get the flags from the interface*/ | ||
229 | strncpy(ifr.ifr_name, device,10); | ||
230 | err = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
231 | if (err < 0) | ||
232 | { | ||
233 | perror("Could not access the interface, "); | ||
234 | close(fd); | ||
235 | return 0; | ||
236 | } | ||
237 | /* Remove the IFF_PROMISC flag */ | ||
238 | ifr.ifr_flags = ifr.ifr_flags - IFF_PROMISC; | ||
239 | /*Set the new flags to the interface*/ | ||
240 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); | ||
241 | if (err < 0) | ||
242 | { | ||
243 | perror("Could not access the interface, "); | ||
244 | close(fd); | ||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | /* Get the flags again to check if IFF_PROMISC is removed */ | ||
249 | err = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
250 | if (err < 0) | ||
251 | { | ||
252 | perror("Could not access the interface, "); | ||
253 | close(fd); | ||
254 | return 0; | ||
255 | } | ||
256 | if(ifr.ifr_flags && IFF_PROMISC) | ||
257 | { | ||
258 | wl_logerr("Could not remove the promisc flag on %d", device); | ||
259 | close(fd); | ||
260 | return 0; | ||
261 | } | ||
262 | else | ||
263 | { | ||
264 | /* Successfully removed the promisc flags */ | ||
265 | close(fd); | ||
266 | return 1; | ||
267 | } | ||
268 | } | ||
269 | |||
270 | |||
271 | |||
272 | |||
203 | /* Set channel (Wireless frequency) of the device */ | 273 | /* Set channel (Wireless frequency) of the device */ |
204 | int card_set_channel (const char *device, int channel, int cardtype) | 274 | int card_set_channel (const char *device, int channel, int cardtype) |
205 | { | 275 | { |
206 | if (cardtype == CARD_TYPE_CISCO || cardtype == CARD_TYPE_NG) | 276 | if (cardtype == CARD_TYPE_CISCO || cardtype == CARD_TYPE_NG) |
207 | { | 277 | { |
208 | /* Cisco and wlan-ng drivers don't need channelswitching */ | 278 | /* Cisco and wlan-ng drivers don't need channelswitching */ |
209 | return 1; | 279 | return 1; |
210 | } | 280 | } |
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh index b35dddd..652b3ed 100644 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh | |||
@@ -43,17 +43,18 @@ extern "C" | |||
43 | 43 | ||
44 | /* only for now, until we have the daemon running */ | 44 | /* only for now, until we have the daemon running */ |
45 | /*the config file should provide these information */ | 45 | /*the config file should provide these information */ |
46 | #define CARD_TYPE CARD_TYPE_HOSTAP | 46 | #define CARD_TYPE CARD_TYPE_HOSTAP |
47 | 47 | ||
48 | /* Prototypes */ | 48 | /* Prototypes */ |
49 | int card_check_rfmon_datalink (const char *device); | 49 | int card_check_rfmon_datalink (const char *device); |
50 | int card_into_monitormode (pcap_t **, const char *, int); | 50 | int card_into_monitormode (pcap_t **, const char *, int); |
51 | int card_set_promisc_up (const char *); | 51 | int card_set_promisc_up (const char *device); |
52 | int card_remove_promisc (const char *device); | ||
52 | int card_set_channel (const char *device, int channel,int cardtype); | 53 | int card_set_channel (const char *device, int channel,int cardtype); |
53 | int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); | 54 | int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); |
54 | double iw_freq2float(iw_freq * in); | 55 | double iw_freq2float(iw_freq * in); |
55 | void iw_float2freq(double in, iw_freq *out); | 56 | void iw_float2freq(double in, iw_freq *out); |
56 | int card_detect_channels (char * device); | 57 | int card_detect_channels (char * device); |
57 | 58 | ||
58 | 59 | ||
59 | /*------------------------------------------------------------------*/ | 60 | /*------------------------------------------------------------------*/ |