summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc59
1 files changed, 47 insertions, 12 deletions
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
index 7c9fbc4..4f187c0 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc
@@ -8,5 +8,5 @@
8#include "wl_log.hh" 8#include "wl_log.hh"
9 9pcap_t *handletopcap;
10/* main card into monitor function */ 10/* main card into monitor function */
11int card_into_monitormode (pcap_t **orighandle, const char *device, int cardtype) 11int card_into_monitormode (const char *device, int cardtype)
12{ 12{
@@ -154,2 +154,47 @@ int card_check_rfmon_datalink (const char *device)
154 154
155/* Ipaq running familiar does not have a loopback device, we need one */
156int check_loopback()
157{
158 /* Checking for a loopback interface with 127.0.0.1, otherwise the other stuff seems to fail on
159 familiar linux on ipaq's */
160 int err;
161 /* First generate a socket to use with iocalls */
162 int fd = socket(AF_INET, SOCK_DGRAM, 0);
163 if (fd < 0)
164 {
165 /* In case of an error */
166 wl_logerr("check_loopback, generation of a socket failed, cannot continue");
167 return 0;
168 }
169 /* Fill an empty an interface structure with the right flags (UP and Promsic) */
170 struct ifreq ifr;
171 strncpy(ifr.ifr_name, "lo",3);
172
173 /* Get the interface flags, loopback interfaces can be detected that way */
174 err = ioctl(fd, SIOCGIFFLAGS, &ifr);
175 if (err < 0)
176 {
177 wl_logerr("check_loopback, could not get the flags of lo, check if you got a lo loopback interface, cannot continue");
178 close(fd);
179 return 0;
180 }
181 /* Checking the flags for IFF_LOOPBACK flags */
182 if(ifr.ifr_flags && IFF_LOOPBACK)
183 {
184 /* Yes, we do have a loopback interface....sup! */
185 close(fd);
186 wl_loginfo ("check_loopback, check for loopback interface lo successful");
187 return 1;
188 }
189 else
190 {
191 wl_logerr("check_loopback, did not found an interface lo with the IFF_LOOPBACK flag set, cannot continue");
192 close(fd);
193 return 0;
194 }
195 /* Should never be reached */
196 return 0;
197} /*check_loopback */
198
199
155/* Set card into promisc mode */ 200/* Set card into promisc mode */
@@ -217,12 +262,2 @@ int card_remove_promisc (const char *device)
217 struct ifreq ifr; 262 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*/ 263 /* Get the flags from the interface*/