[Listener] Fix the "don't want to quit" bug
In capture(), the pcap_loop() call was blocking, so the program did not quit if no packet came on rtap_iface. This is now fixed by a call to pcap_breakloop() in the signal handlers.
This commit is contained in:
parent
ccb963cea8
commit
5f9de6e1dc
5
TODO
5
TODO
|
@ -35,11 +35,6 @@
|
||||||
|
|
||||||
- read_packet(): use ieee80211_header_size for all implicit packets
|
- read_packet(): use ieee80211_header_size for all implicit packets
|
||||||
Currently the size is corrected only for data packets.
|
Currently the size is corrected only for data packets.
|
||||||
- Fix the "don't want to quit" bug
|
|
||||||
Sometimes owlps-listener refuses to quit on SIGTERM. This is
|
|
||||||
because of the blocking call of pcap_loop() in capture(): something
|
|
||||||
has to be read on rtap_iface before to quit. Maybe we should thread
|
|
||||||
capture(), to be able to pthread_cancel() it.
|
|
||||||
- Fix segfault when rtap_iface is not in monitor mode (?) on Foneras.
|
- Fix segfault when rtap_iface is not in monitor mode (?) on Foneras.
|
||||||
- Merge Makefile and Makefile_atheros?
|
- Merge Makefile and Makefile_atheros?
|
||||||
Use autohell?
|
Use autohell?
|
||||||
|
|
|
@ -97,6 +97,9 @@ void send_autocalibration_request(void) ;
|
||||||
uint_fast16_t make_packet(uint8_t **packet) ;
|
uint_fast16_t make_packet(uint8_t **packet) ;
|
||||||
#endif // USE_PTHREAD
|
#endif // USE_PTHREAD
|
||||||
|
|
||||||
|
void sigint_handler(int num) ;
|
||||||
|
void sigterm_handler(int num) ;
|
||||||
|
|
||||||
void print_usage(void) ;
|
void print_usage(void) ;
|
||||||
void print_version(void) ;
|
void print_version(void) ;
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ char *program_name = NULL ;
|
||||||
uint8_t my_mac_bytes[6] ; // AP MAC address
|
uint8_t my_mac_bytes[6] ; // AP MAC address
|
||||||
char my_ip[INET_ADDRSTRLEN] ; // AP IP address
|
char my_ip[INET_ADDRSTRLEN] ; // AP IP address
|
||||||
|
|
||||||
|
pcap_t *capture_handler = NULL ; // Packet capture descriptor
|
||||||
int aggregation_sockfd ;
|
int aggregation_sockfd ;
|
||||||
struct sockaddr_in aggregation_server ;
|
struct sockaddr_in aggregation_server ;
|
||||||
int autocalibration_send_sockfd ;
|
int autocalibration_send_sockfd ;
|
||||||
|
@ -89,9 +90,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Set up signal handlers */
|
/* Set up signal handlers */
|
||||||
sigemptyset(&action.sa_mask) ;
|
sigemptyset(&action.sa_mask) ;
|
||||||
action.sa_handler = owl_sigint_handler ;
|
action.sa_handler = sigint_handler ;
|
||||||
sigaction(SIGINT, &action, NULL) ;
|
sigaction(SIGINT, &action, NULL) ;
|
||||||
action.sa_handler = owl_sigterm_handler ;
|
action.sa_handler = sigterm_handler ;
|
||||||
sigaction(SIGTERM, &action, NULL) ;
|
sigaction(SIGTERM, &action, NULL) ;
|
||||||
|
|
||||||
get_mac_addr(GET_WIFI_IFACE(), my_mac_bytes) ;
|
get_mac_addr(GET_WIFI_IFACE(), my_mac_bytes) ;
|
||||||
|
@ -585,12 +586,12 @@ void* keep_mode_monitor(void *iface)
|
||||||
*/
|
*/
|
||||||
int capture()
|
int capture()
|
||||||
{
|
{
|
||||||
pcap_t *handle ; // Packet capture descriptor
|
|
||||||
char errbuf[PCAP_ERRBUF_SIZE] ; // Error message
|
char errbuf[PCAP_ERRBUF_SIZE] ; // Error message
|
||||||
|
|
||||||
// Start capture:
|
// Start capture:
|
||||||
handle = pcap_open_live(GET_RTAP_IFACE(), BUFSIZ, 1, 1000, errbuf) ;
|
capture_handler =
|
||||||
if (handle == NULL) // Capture starting failed
|
pcap_open_live(GET_RTAP_IFACE(), BUFSIZ, 1, 1000, errbuf) ;
|
||||||
|
if (capture_handler == NULL) // Capture starting failed
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Cannot open capture interface %s\n", errbuf) ;
|
fprintf(stderr, "Cannot open capture interface %s\n", errbuf) ;
|
||||||
return ERR_OPENING_IFACE ;
|
return ERR_OPENING_IFACE ;
|
||||||
|
@ -602,11 +603,11 @@ int capture()
|
||||||
GET_AGGREGATION_PORT(),
|
GET_AGGREGATION_PORT(),
|
||||||
&aggregation_server, NULL) ;
|
&aggregation_server, NULL) ;
|
||||||
|
|
||||||
while(run)
|
while (run)
|
||||||
// Capture one packet at time, and call read_packet() on it:
|
// Capture one packet at time, and call read_packet() on it:
|
||||||
pcap_loop(handle, 1, read_packet, NULL) ;
|
pcap_loop(capture_handler, 1, read_packet, NULL) ;
|
||||||
|
|
||||||
pcap_close(handle) ; // Stop capture
|
pcap_close(capture_handler) ; // Stop capture
|
||||||
close(aggregation_sockfd) ; // Close socket
|
close(aggregation_sockfd) ; // Close socket
|
||||||
|
|
||||||
return 0 ;
|
return 0 ;
|
||||||
|
@ -1176,6 +1177,22 @@ uint_fast16_t make_packet(uint8_t **packet)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void sigint_handler(int num)
|
||||||
|
{
|
||||||
|
owl_sigint_handler(num) ;
|
||||||
|
pcap_breakloop(capture_handler) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void sigterm_handler(int num)
|
||||||
|
{
|
||||||
|
owl_sigterm_handler(num) ;
|
||||||
|
pcap_breakloop(capture_handler) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void print_usage()
|
void print_usage()
|
||||||
{
|
{
|
||||||
printf("Usage :\n"
|
printf("Usage :\n"
|
||||||
|
|
Loading…
Reference in New Issue