[lib] Move owl_iface_mode_monitor() in Listener
Only owlps-listener uses owl_iface_mode_monitor(), so we don't need to keep it in libowlps.
This commit is contained in:
parent
7dade1c36b
commit
00d89efd40
1
TODO
1
TODO
|
@ -24,7 +24,6 @@
|
||||||
° owl_timestamp_is_null()
|
° owl_timestamp_is_null()
|
||||||
° owl_iface_channel_hop()
|
° owl_iface_channel_hop()
|
||||||
° owl_iface_set_channel() (except by owl_iface_channel_hop())
|
° owl_iface_set_channel() (except by owl_iface_channel_hop())
|
||||||
- Move owl_iface_mode_monitor() in owlps-listenerd.c.
|
|
||||||
|
|
||||||
|
|
||||||
* Aggregator
|
* Aggregator
|
||||||
|
|
|
@ -376,39 +376,6 @@ int owl_create_udp_listening_socket(const uint_fast16_t port)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Switches the IEEE 802.11 interface 'iface' to Monitor mode.
|
|
||||||
*/
|
|
||||||
int owl_iface_mode_monitor(const char *const iface)
|
|
||||||
{
|
|
||||||
struct iwreq wrq ;
|
|
||||||
int sockfd = iw_sockets_open() ;
|
|
||||||
|
|
||||||
strncpy((&wrq)->ifr_name, iface, IFNAMSIZ) ;
|
|
||||||
|
|
||||||
if (ioctl(sockfd, SIOCGIWMODE, &wrq) == -1) // Get current mode
|
|
||||||
{
|
|
||||||
perror("Error reading interface mode") ;
|
|
||||||
return ERR_READING_MODE ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If interface is not yet in Monitor mode
|
|
||||||
if (wrq.u.mode != IW_MODE_MONITOR)
|
|
||||||
{
|
|
||||||
wrq.u.mode = IW_MODE_MONITOR ;
|
|
||||||
if (ioctl(sockfd, SIOCSIWMODE, &wrq) == -1) // Set up Monitor mode
|
|
||||||
{
|
|
||||||
perror("Error setting up Monitor mode") ;
|
|
||||||
return ERR_SETTING_MODE ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
close(sockfd) ;
|
|
||||||
|
|
||||||
return 0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets the IEEE 802.11 channel of the interface 'iface'.
|
* Sets the IEEE 802.11 channel of the interface 'iface'.
|
||||||
* 'channel' must be an integer between 1 and 14.
|
* 'channel' must be an integer between 1 and 14.
|
||||||
|
|
|
@ -290,7 +290,6 @@ int owl_create_udp_trx_socket(const char *const server_address,
|
||||||
struct sockaddr_in *const server_description,
|
struct sockaddr_in *const server_description,
|
||||||
struct sockaddr_in *const client_description) ;
|
struct sockaddr_in *const client_description) ;
|
||||||
int owl_create_udp_listening_socket(const uint_fast16_t port) ;
|
int owl_create_udp_listening_socket(const uint_fast16_t port) ;
|
||||||
int owl_iface_mode_monitor(const char *const iface) ;
|
|
||||||
int owl_iface_set_channel(const char *const iface,
|
int owl_iface_set_channel(const char *const iface,
|
||||||
const uint_fast8_t channel) ;
|
const uint_fast8_t channel) ;
|
||||||
int owl_iface_channel_hop(const char *const iface) ;
|
int owl_iface_channel_hop(const char *const iface) ;
|
||||||
|
|
|
@ -36,7 +36,7 @@ OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" \
|
||||||
-D USE_CONFIG_FILE -lconfuse -D USE_PTHREAD -pthread
|
-D USE_CONFIG_FILE -lconfuse -D USE_PTHREAD -pthread
|
||||||
LIBS = -L$(LIBOWLPS_DIR) -lowlps \
|
LIBS = -L$(LIBOWLPS_DIR) -lowlps \
|
||||||
-L$(LIBOWLPSCLIENT_DIR) -lowlps-client \
|
-L$(LIBOWLPSCLIENT_DIR) -lowlps-client \
|
||||||
-lpcap
|
-lpcap -liw
|
||||||
LDFLAGS = $(LIBS) $(OWLPSFLAGS)
|
LDFLAGS = $(LIBS) $(OWLPSFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ void print_configuration(void) ;
|
||||||
|
|
||||||
#ifdef USE_PTHREAD
|
#ifdef USE_PTHREAD
|
||||||
void* keep_mode_monitor(void *iface) ;
|
void* keep_mode_monitor(void *iface) ;
|
||||||
|
int iface_mode_monitor(const char *const iface) ;
|
||||||
#endif // USE_PTHREAD
|
#endif // USE_PTHREAD
|
||||||
int capture(void) ;
|
int capture(void) ;
|
||||||
void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#ifdef USE_PTHREAD
|
#ifdef USE_PTHREAD
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
|
# include <iwlib.h>
|
||||||
#endif // USE_PTHREAD
|
#endif // USE_PTHREAD
|
||||||
|
|
||||||
// Used by get_mac_addr():
|
// Used by get_mac_addr():
|
||||||
|
@ -668,12 +669,46 @@ void* keep_mode_monitor(void *iface)
|
||||||
while (owl_run)
|
while (owl_run)
|
||||||
{
|
{
|
||||||
// Switch the interface to monitor mode:
|
// Switch the interface to monitor mode:
|
||||||
owl_iface_mode_monitor((char*) iface) ;
|
iface_mode_monitor((char*) iface) ;
|
||||||
sleep(1) ; // Wait for 1 second
|
sleep(1) ; // Wait for 1 second
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_exit(NULL) ;
|
pthread_exit(NULL) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Switches the IEEE 802.11 interface 'iface' to Monitor mode.
|
||||||
|
*/
|
||||||
|
int iface_mode_monitor(const char *const iface)
|
||||||
|
{
|
||||||
|
struct iwreq wrq ;
|
||||||
|
int sockfd = iw_sockets_open() ;
|
||||||
|
|
||||||
|
strncpy((&wrq)->ifr_name, iface, IFNAMSIZ) ;
|
||||||
|
|
||||||
|
if (ioctl(sockfd, SIOCGIWMODE, &wrq) == -1) // Get current mode
|
||||||
|
{
|
||||||
|
perror("Error reading interface mode") ;
|
||||||
|
return ERR_READING_MODE ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If interface is not yet in Monitor mode
|
||||||
|
if (wrq.u.mode != IW_MODE_MONITOR)
|
||||||
|
{
|
||||||
|
wrq.u.mode = IW_MODE_MONITOR ;
|
||||||
|
if (ioctl(sockfd, SIOCSIWMODE, &wrq) == -1) // Set up Monitor mode
|
||||||
|
{
|
||||||
|
perror("Error setting up Monitor mode") ;
|
||||||
|
return ERR_SETTING_MODE ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(sockfd) ;
|
||||||
|
|
||||||
|
return 0 ;
|
||||||
|
}
|
||||||
#endif // USE_PTHREAD
|
#endif // USE_PTHREAD
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue