From 940c5f74dfebca407d77d0c347f488625d726e4c Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 11 Mar 2011 11:19:44 +0100 Subject: [PATCH] [lib] Prefix all functions with owl_ --- TODO | 2 +- .../libowlps-client/libowlps-client.c | 4 +- .../owlps-aggregator/owlps-aggregatord.c | 103 ++++++++++-------- .../owlps-client/owlps-client.c | 8 +- .../owlps-listener/owlps-listenerd.c | 27 ++--- libowlps/libowlps.c | 57 +++++----- libowlps/owlps.h | 38 +++---- 7 files changed, 124 insertions(+), 115 deletions(-) diff --git a/TODO b/TODO index 5ba4e3e..7113069 100644 --- a/TODO +++ b/TODO @@ -11,7 +11,7 @@ * libowlps -- Prefix all function with "owlps_". +- Rename types? Prefix them? * Aggregator diff --git a/infrastructure-centred/libowlps-client/libowlps-client.c b/infrastructure-centred/libowlps-client/libowlps-client.c index bab14ca..b248930 100644 --- a/infrastructure-centred/libowlps-client/libowlps-client.c +++ b/infrastructure-centred/libowlps-client/libowlps-client.c @@ -18,8 +18,8 @@ int owlclient_create_trx_socket(char *dest_ip, uint_fast16_t dest_port, { struct sockaddr_in client ; - int sockfd = create_udp_sending_socket(dest_ip, dest_port, - server, &client) ; + int sockfd = owl_create_udp_sending_socket(dest_ip, dest_port, + server, &client) ; if (sockfd < 0) { perror("Error! Cannot create UDP sending socket to the aggregation" diff --git a/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c b/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c index dc98810..91d00cd 100644 --- a/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c +++ b/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c @@ -33,14 +33,14 @@ int main(int argc, char **argv) /* Set up signal handlers */ sigemptyset(&action.sa_mask) ; - action.sa_handler = sigint_handler ; + action.sa_handler = owl_sigint_handler ; sigaction(SIGINT, &action, NULL) ; - action.sa_handler = sigterm_handler ; + action.sa_handler = owl_sigterm_handler ; sigaction(SIGTERM, &action, NULL) ; /* Create UDP socket */ listening_port = cfg_getint(cfg, "listening_port") ; - if ((sockfd = create_udp_listening_socket(listening_port)) < 0) + if ((sockfd = owl_create_udp_listening_socket(listening_port)) < 0) { fprintf(stderr, "Error! Cannot listen on port %"PRIuFAST16".\n", @@ -328,9 +328,9 @@ int read_loop(int sockfd) if (cfg_getbool(cfg, "verbose")) { ap_mac_string = - mac_bytes_to_string(message.ap_mac_addr_bytes) ; + owl_mac_bytes_to_string(message.ap_mac_addr_bytes) ; mobile_mac_string = - mac_bytes_to_string(message.mobile_mac_addr_bytes) ; + owl_mac_bytes_to_string(message.mobile_mac_addr_bytes) ; mobile_ip_string = ip_bytes_to_string(message.mobile_ip_addr_bytes) ; printf("\n" @@ -349,8 +349,8 @@ int read_loop(int sockfd) ap_mac_string, mobile_mac_string, mobile_ip_string, - timestamp_to_ms(message.request_time), - timestamp_to_ms(message.start_time), + owl_timestamp_to_ms(message.request_time), + owl_timestamp_to_ms(message.start_time), message.antenna_signal_dbm - 0x100, message.x_position, message.y_position, @@ -365,7 +365,7 @@ int read_loop(int sockfd) else { ap_mac_string = - mac_bytes_to_string(message.ap_mac_addr_bytes) ; + owl_mac_bytes_to_string(message.ap_mac_addr_bytes) ; fprintf(stderr, "Request received from AP « %s ».\n", ap_mac_string) ; free(ap_mac_string) ; @@ -408,9 +408,10 @@ void* monitor_couples() fprintf(stderr, "Monitor couples thread launched.\n") ; #endif // DEBUG - sockfd = create_udp_sending_socket(cfg_getstr(cfg, "positioner_ip"), - cfg_getint(cfg, "positioner_port"), - &serv, &client) ; + sockfd = + owl_create_udp_sending_socket(cfg_getstr(cfg, "positioner_ip"), + cfg_getint(cfg, "positioner_port"), + &serv, &client) ; /* Open output file */ fd = fopen(cfg_getstr(cfg, "output_file"), "a") ; // We use add mode @@ -426,11 +427,11 @@ void* monitor_couples() couple_ptr = couples ; couple_prev = NULL ; couple_info_ptr = NULL ; - timestamp_now(¤t_time) ; + owl_timestamp_now(¤t_time) ; while (couple_ptr != NULL) // Parsing list { - sub = time_elapsed(couple_ptr->start_time, current_time) ; + sub = owl_time_elapsed(couple_ptr->start_time, current_time) ; // If the couple was not treated already if (couple_ptr->info != NULL) @@ -450,13 +451,13 @@ void* monitor_couples() #ifdef USE_TIMESTAMP // Print request mobile timestamp to the output file fprintf(fd, "%"PRIu64";", - timestamp_to_ms(couple_ptr->request_time)) ; + owl_timestamp_to_ms(couple_ptr->request_time)) ; #endif // USE_TIMESTAMP // Print mobile MAC address to the output file mac_string = - mac_bytes_to_string(couple_ptr - ->mobile_mac_addr_bytes) ; + owl_mac_bytes_to_string(couple_ptr + ->mobile_mac_addr_bytes) ; fprintf(fd, "%s;", mac_string) ; free(mac_string) ; @@ -493,8 +494,8 @@ void* monitor_couples() // Print AP info to the output file mac_string = - mac_bytes_to_string(couple_info_ptr - ->ap_mac_addr_bytes) ; + owl_mac_bytes_to_string(couple_info_ptr + ->ap_mac_addr_bytes) ; fprintf(fd, ";%s;%d", mac_string, couple_info_ptr->antenna_signal_dbm - 0x100) ; free(mac_string) ; @@ -564,7 +565,7 @@ void got_couple_info(couple_message message) couple_info_list *tmp_info = NULL ; TIMESTAMP start_time ; // Reception time on the aggregator - timestamp_now(&start_time) ; + owl_timestamp_now(&start_time) ; /* Create a new couple */ tmp_info = malloc(sizeof(couple_info_list)) ; @@ -580,10 +581,12 @@ void got_couple_info(couple_message message) tmp_couple = malloc(sizeof(couple_list)) ; // create it. memcpy(tmp_couple->mobile_mac_addr_bytes, message.mobile_mac_addr_bytes, 6) ; - if (timestamp_to_ms(message.request_time) != 0) // Explicit packet + // Explicit packet: + if (owl_timestamp_to_ms(message.request_time) != 0) // Transmission time on the mobile: tmp_couple->request_time = message.request_time ; - else // Implicit packet + // Implicit packet: + else // Reception time on the AP: tmp_couple->request_time = message.start_time ; // Save locale time on the aggregator (not the reception time @@ -600,28 +603,30 @@ void got_couple_info(couple_message message) else // If the couple list exists already { // we search the list for the couple - if (timestamp_to_ms(message.request_time) != 0) // Explicit packet + // Explicit packet: + if (owl_timestamp_to_ms(message.request_time) != 0) { while (tmp_couple != NULL) { // Research criterion: MAC and transmission time - if (mac_equals(message.mobile_mac_addr_bytes, - tmp_couple->mobile_mac_addr_bytes) == 1 - && time_elapsed(message.request_time, - tmp_couple->request_time) == 0) + if (owl_mac_equals(message.mobile_mac_addr_bytes, + tmp_couple->mobile_mac_addr_bytes) == 1 + && owl_time_elapsed(message.request_time, + tmp_couple->request_time) == 0) break ; // If the couple exists, we stop on it tmp_couple = tmp_couple->next ; } } - else // Implicit packet + // Implicit packet: + else { while (tmp_couple != NULL) { // Research criterion: MAC addresses equals and reception // times on the APs less than 10 ms // TODO : define an option for the maximal difference time. - if (mac_equals(message.mobile_mac_addr_bytes, - tmp_couple->mobile_mac_addr_bytes) == 1 - && time_elapsed(message.start_time, - tmp_couple->request_time) <= 10) + if (owl_mac_equals(message.mobile_mac_addr_bytes, + tmp_couple->mobile_mac_addr_bytes) == 1 + && owl_time_elapsed(message.start_time, + tmp_couple->request_time) <= 10) break ; // If the couple exists, we stop on it tmp_couple = tmp_couple->next ; } @@ -633,10 +638,12 @@ void got_couple_info(couple_message message) tmp_couple = malloc(sizeof(couple_list)) ; // create it. memcpy(tmp_couple->mobile_mac_addr_bytes, message.mobile_mac_addr_bytes, 6) ; - if (timestamp_to_ms(message.request_time) != 0) // Explicit packet + // Explicit packet: + if (owl_timestamp_to_ms(message.request_time) != 0) // Transmission time on the mobile: tmp_couple->request_time = message.request_time ; - else // Implicit packet + // Implicit packet: + else // Reception time on the AP: tmp_couple->request_time = message.start_time ; // Save locale time on the aggregator (not the reception time @@ -710,8 +717,8 @@ void listen_for_aps(void) #endif // DEBUG listen_sockfd = - create_udp_listening_socket(cfg_getint(cfg, - "autocalibration_port")) ; + owl_create_udp_listening_socket(cfg_getint(cfg, + "autocalibration_port")) ; if (listen_sockfd < 0) { perror("Error! Cannot create UDP listening socket from the" @@ -779,7 +786,7 @@ ap_list* find_ap(uint8_t mac_addr_bytes[6]) found = token_aps ; do { - if (mac_equals(found->mac_addr_bytes, mac_addr_bytes)) + if (owl_mac_equals(found->mac_addr_bytes, mac_addr_bytes)) return found ; found = found->next ; } @@ -795,7 +802,7 @@ ap_list* find_ap(uint8_t mac_addr_bytes[6]) ap_list* add_ap_front(uint8_t mac_addr_bytes[6]) { #ifdef DEBUG - char *mac = mac_bytes_to_string(mac_addr_bytes) ; + char *mac = owl_mac_bytes_to_string(mac_addr_bytes) ; fprintf(stderr, "Creating AP with MAC address « %s »...\n", mac) ; free(mac) ; #endif // DEBUG @@ -823,7 +830,7 @@ void update_ap_ip_addr(ap_list *ap, char ip_addr[16]) void update_ap_seen(ap_list *ap) { assert(ap) ; - timestamp_now(&ap->last_seen) ; + owl_timestamp_now(&ap->last_seen) ; } @@ -887,10 +894,10 @@ void delete_old_aps() { TIMESTAMP now ; - timestamp_now(&now) ; + owl_timestamp_now(&now) ; while (token_aps != NULL) - if (time_elapsed(token_aps->last_seen, now) > + if (owl_time_elapsed(token_aps->last_seen, now) > (uint_fast32_t) cfg_getint(cfg, "ap_keep_timeout") * 1000) delete_ap(token_aps) ; else @@ -905,7 +912,7 @@ void delete_ap(ap_list *ap) { #ifdef DEBUG assert(ap) ; - char *mac = mac_bytes_to_string(token_aps->mac_addr_bytes) ; + char *mac = owl_mac_bytes_to_string(token_aps->mac_addr_bytes) ; fprintf(stderr, "Deleting AP « %s »...\n", mac) ; free(mac) ; #endif // DEBUG @@ -963,9 +970,9 @@ void order_send(ap_list *ap) #endif // DEBUG sockfd = - create_udp_sending_socket(ap->ip_addr, - cfg_getint(cfg, "autocalibration_port"), - &serv, &client) ; + owl_create_udp_sending_socket(ap->ip_addr, + cfg_getint(cfg, "autocalibration_port"), + &serv, &client) ; message.order = htonl(AUTOCALIBRATION_ORDER_SEND) ; nsent = sendto(sockfd, (void *)&message, sizeof(message), 0, @@ -1027,14 +1034,14 @@ void print_couple_list() info_ptr = couple_ptr->info ; // Get the sub-list pointer mobile_mac_string = - mac_bytes_to_string(couple_ptr->mobile_mac_addr_bytes) ; + owl_mac_bytes_to_string(couple_ptr->mobile_mac_addr_bytes) ; printf("Mobile MAC: %s\n" "Sequence number: %"PRIu64"\n" "Reception timestamp: %"PRIu64"\n" "\n", mobile_mac_string, - timestamp_to_ms(couple_ptr->request_time), - timestamp_to_ms(couple_ptr->start_time) + owl_timestamp_to_ms(couple_ptr->request_time), + owl_timestamp_to_ms(couple_ptr->start_time) ) ; free(mobile_mac_string) ; @@ -1063,7 +1070,7 @@ void print_couple_info(couple_info_list *info) if (info == NULL) return ; - ap_mac_string = mac_bytes_to_string(info->ap_mac_addr_bytes) ; + ap_mac_string = owl_mac_bytes_to_string(info->ap_mac_addr_bytes) ; printf("\tAP MAC: %s\n" "\tSignal strength: %d dBm\n", ap_mac_string, diff --git a/infrastructure-centred/owlps-client/owlps-client.c b/infrastructure-centred/owlps-client/owlps-client.c index f2456b5..7bdc7de 100644 --- a/infrastructure-centred/owlps-client/owlps-client.c +++ b/infrastructure-centred/owlps-client/owlps-client.c @@ -287,12 +287,12 @@ void make_packet() uint_fast16_t offset ; // Index used to create the packet TIMESTAMP request_time ; - timestamp_now(&request_time) ; + owl_timestamp_now(&request_time) ; if (is_calibration_request) // Calibration packet { printf("Calibration time: %"PRIu64"\n", - timestamp_to_ms(request_time)) ; + owl_timestamp_to_ms(request_time)) ; offset = 0 ; packet_size = @@ -318,7 +318,7 @@ void make_packet() else // Standard packet { printf("Request time: %"PRIu64"\n", - timestamp_to_ms(request_time)) ; + owl_timestamp_to_ms(request_time)) ; packet_size = sizeof(uint8_t) + sizeof(TIMESTAMP) ; packet = malloc(packet_size) ; memset(&packet[0], PACKET_TYPE_NORMAL, 1) ; // Packet type @@ -341,7 +341,7 @@ void receive_position() // Position of the mobile as computed by the infrastructure: float x, y, z ; - sockfd = create_udp_listening_socket(options.listening_port) ; + sockfd = owl_create_udp_listening_socket(options.listening_port) ; recvfrom(sockfd, &x, sizeof(float), 0, NULL, NULL) ; recvfrom(sockfd, &y, sizeof(float), 0, NULL, NULL) ; recvfrom(sockfd, &z, sizeof(float), 0, NULL, NULL) ; diff --git a/infrastructure-centred/owlps-listener/owlps-listenerd.c b/infrastructure-centred/owlps-listener/owlps-listenerd.c index a91c0e9..b9c2d67 100644 --- a/infrastructure-centred/owlps-listener/owlps-listenerd.c +++ b/infrastructure-centred/owlps-listener/owlps-listenerd.c @@ -89,13 +89,13 @@ int main(int argc, char *argv[]) /* Set up signal handlers */ sigemptyset(&action.sa_mask) ; - action.sa_handler = sigint_handler ; + action.sa_handler = owl_sigint_handler ; sigaction(SIGINT, &action, NULL) ; - action.sa_handler = sigterm_handler ; + action.sa_handler = owl_sigterm_handler ; sigaction(SIGTERM, &action, NULL) ; get_mac_addr(GET_WIFI_IFACE(), my_mac_bytes) ; - mac_string = mac_bytes_to_string(my_mac_bytes) ; + mac_string = owl_mac_bytes_to_string(my_mac_bytes) ; printf("My MAC address is: %s\n", mac_string) ; free(mac_string) ; get_ip_addr(GET_WIFI_IFACE(), my_ip) ; @@ -465,7 +465,8 @@ void keep_mode_monitor(char *iface) while (run) { - iface_mode_monitor(iface) ; // Switch the interface to monitor mode + // Switch the interface to monitor mode: + owl_iface_mode_monitor(iface) ; sleep(1) ; // Wait for 1 second } } @@ -622,12 +623,12 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, memcpy(couple.mobile_mac_addr_bytes, &packet[rtap_bytes+10], 6) ; // Drop the packet if it comes from the AP itself: - if (mac_equals(my_mac_bytes, couple.mobile_mac_addr_bytes)) + if (owl_mac_equals(my_mac_bytes, couple.mobile_mac_addr_bytes)) return ; memcpy(couple.ap_mac_addr_bytes, my_mac_bytes, 6) ; // Copy AP MAC // Capture time is in the pcap header: - couple.start_time = timeval_to_timestamp(header->ts) ; + couple.start_time = owl_timeval_to_timestamp(header->ts) ; // Transmission time on the mobile is unknown (unless the packet is // an explicit request): memset(&couple.request_time, 0, sizeof(TIMESTAMP)) ; @@ -811,9 +812,9 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, if (GET_DISPLAY_CAPTURED()) { char *ap_mac_string = - mac_bytes_to_string(couple.ap_mac_addr_bytes) ; + owl_mac_bytes_to_string(couple.ap_mac_addr_bytes) ; char *mobile_mac_string = - mac_bytes_to_string(couple.mobile_mac_addr_bytes) ; + owl_mac_bytes_to_string(couple.mobile_mac_addr_bytes) ; printf("*** Couple to send ***\n" "\tMAC AP: %s\n" "\tMobile MAC: %s\n" @@ -827,8 +828,8 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, , ap_mac_string, mobile_mac_string, - timestamp_to_ms(couple.request_time), - timestamp_to_ms(couple.start_time), + owl_timestamp_to_ms(couple.request_time), + owl_timestamp_to_ms(couple.start_time), couple.antenna_signal_dbm - 0x100, couple.x_position, couple.y_position, @@ -960,7 +961,7 @@ void autocalibrate() // Socket to receive orders from the aggregator listen_sockfd = - create_udp_listening_socket(GET_AUTOCALIBRATION_PORT()) ; + owl_create_udp_listening_socket(GET_AUTOCALIBRATION_PORT()) ; if (listen_sockfd < 0) { perror("Error! Cannot create UDP listening socket from the" @@ -1024,11 +1025,11 @@ uint_fast16_t make_packet(uint8_t **packet) uint_fast16_t size ; // Packet size TIMESTAMP request_time ; - timestamp_now(&request_time) ; + owl_timestamp_now(&request_time) ; if (GET_VERBOSE()) printf("Autocalibration time: %"PRIu64"\n", - timestamp_to_ms(request_time)) ; + owl_timestamp_to_ms(request_time)) ; size = sizeof(char) + sizeof(TIMESTAMP) ; pkt = malloc(size) ; diff --git a/libowlps/libowlps.c b/libowlps/libowlps.c index 2886fc5..427b56b 100644 --- a/libowlps/libowlps.c +++ b/libowlps/libowlps.c @@ -17,7 +17,7 @@ BOOL run = TRUE ; * Converts a MAC address from bytes to string. * /!\ You *must* manually free the returned string /!\ */ -char* mac_bytes_to_string(uint8_t *mac_binary) +char* owl_mac_bytes_to_string(uint8_t *mac_binary) { char *ret = malloc(sizeof(char) * 18) ; @@ -35,7 +35,7 @@ char* mac_bytes_to_string(uint8_t *mac_binary) * Converts a IEEE 802.11 frequency into a channel number. * Returns 0 if the frequency does not correspond to an official channel. */ -uint_fast8_t frequency_to_channel(uint_fast16_t channel) +uint_fast8_t owl_frequency_to_channel(uint_fast16_t channel) { uint_fast8_t c = 0 ; // Result @@ -93,10 +93,10 @@ uint_fast8_t frequency_to_channel(uint_fast16_t channel) /* * Set the TIMESTAMP 'now' at the current time (millisecond-precision). */ -void timestamp_now(TIMESTAMP *now) +void owl_timestamp_now(TIMESTAMP *now) { - if (! timestamp_now_ns(now)) - timestamp_round_to_ms(now) ; + if (! owl_timestamp_now_ns(now)) + owl_timestamp_round_to_ms(now) ; } @@ -104,7 +104,7 @@ void timestamp_now(TIMESTAMP *now) /* * Set the TIMESTAMP 'now' at the current time (nanosecond-precision). */ -int timestamp_now_ns(TIMESTAMP *now) +int owl_timestamp_now_ns(TIMESTAMP *now) { int ret ; if ((ret = clock_gettime(CLOCK_REALTIME, now))) @@ -120,7 +120,7 @@ int timestamp_now_ns(TIMESTAMP *now) /* * Lower the precision of 'now' to milliseconds. */ -void timestamp_round_to_ms(TIMESTAMP *now) +void owl_timestamp_round_to_ms(TIMESTAMP *now) { now->tv_nsec = now->tv_nsec / 1000000 * 1000000 ; } @@ -130,7 +130,7 @@ void timestamp_round_to_ms(TIMESTAMP *now) /* * Returns a TIMESTAMP from a struct timeval. */ -TIMESTAMP timeval_to_timestamp(const struct timeval d) +TIMESTAMP owl_timeval_to_timestamp(const struct timeval d) { TIMESTAMP res ; res.tv_sec = d.tv_sec ; @@ -143,7 +143,7 @@ TIMESTAMP timeval_to_timestamp(const struct timeval d) /* * Converts a TIMESTAMP date value into milliseconds. */ -uint64_t timestamp_to_ms(TIMESTAMP d) +uint64_t owl_timestamp_to_ms(TIMESTAMP d) { return d.tv_sec * 1000 + d.tv_nsec / 1000000 ; } @@ -153,13 +153,14 @@ uint64_t timestamp_to_ms(TIMESTAMP d) /* * Returns the time (in milliseconds) between two dates. */ -uint_fast32_t time_elapsed(TIMESTAMP sup, TIMESTAMP inf) +uint_fast32_t owl_time_elapsed(TIMESTAMP sup, TIMESTAMP inf) { - uint_fast32_t sub = abs(timestamp_to_ms(sup) - timestamp_to_ms(inf)) ; + uint_fast32_t elapsed_ms = + abs(owl_timestamp_to_ms(sup) - owl_timestamp_to_ms(inf)) ; #ifdef DEBUG - printf("time_elapsed(): %"PRIuFAST32"\n", sub) ; + printf("time_elapsed(): %"PRIuFAST32"ms\n", elapsed_ms) ; #endif - return sub ; + return elapsed_ms ; } @@ -168,7 +169,7 @@ uint_fast32_t time_elapsed(TIMESTAMP sup, TIMESTAMP inf) * Compares two MAC addresses. * Returns TRUE if they are identical, FALSE otherwise. */ -BOOL mac_equals(uint8_t *mac1, uint8_t *mac2) +BOOL owl_mac_equals(uint8_t *mac1, uint8_t *mac2) { int i ; for(i=0 ; i < 6 ; i++) @@ -189,10 +190,10 @@ BOOL mac_equals(uint8_t *mac1, uint8_t *mac2) * - client_description (in/out): the structure in which the client * description will be saved. */ -int create_udp_sending_socket(char *server_address, - uint_fast16_t server_port, - struct sockaddr_in *server_description, - struct sockaddr_in * client_description) +int owl_create_udp_sending_socket(char *server_address, + uint_fast16_t server_port, + struct sockaddr_in *server_description, + struct sockaddr_in *client_description) { int sockfd ; // Socket descriptor @@ -227,7 +228,7 @@ int create_udp_sending_socket(char *server_address, * Parameters: * - port: port on which the socket listens. */ -int create_udp_listening_socket(uint_fast16_t port) +int owl_create_udp_listening_socket(uint_fast16_t port) { int sockfd ; // Socket descriptor struct sockaddr_in server_description ; // Server structure @@ -266,7 +267,7 @@ int create_udp_listening_socket(uint_fast16_t port) /* * Switches the IEEE 802.11 interface 'iface' to Monitor mode. */ -int iface_mode_monitor(char *iface) +int owl_iface_mode_monitor(char *iface) { struct iwreq wrq ; int sockfd = iw_sockets_open() ; @@ -301,7 +302,7 @@ int iface_mode_monitor(char *iface) * Sets the IEEE 802.11 channel of the interface 'iface'. * 'channel' must be an integer between 1 and 14. */ -int iface_set_channel(char *iface, uint_fast8_t channel) +int owl_iface_set_channel(char *iface, uint_fast8_t channel) { struct iwreq wrq ; int sockfd = iw_sockets_open() ; @@ -327,7 +328,7 @@ int iface_set_channel(char *iface, uint_fast8_t channel) * Switches alternatively the Wi-Fi channel of the IEEE 802.11 interface * 'iface' to 4 or 11. */ -int iface_channel_hop(char *iface) +int owl_iface_channel_hop(char *iface) { uint_fast16_t channel ; struct iwreq wrq ; @@ -345,16 +346,16 @@ int iface_channel_hop(char *iface) channel = wrq.u.freq.m / 100000 ; if (channel > 1000) // If the value is in Hz, we convert it to a - channel = frequency_to_channel(channel) ; // channel number + channel = owl_frequency_to_channel(channel) ; // channel number // (with our own function, still not very clean). close(sockfd) ; /* Switch the canal */ if (channel == 4) // If channel is 4 - return iface_set_channel(iface, 11) ; // switch to 11 ; + return owl_iface_set_channel(iface, 11) ; // switch to 11 ; else - return iface_set_channel(iface, 4) ; // else, set it to 4. + return owl_iface_set_channel(iface, 4) ; // else, set it to 4. } @@ -362,7 +363,7 @@ int iface_channel_hop(char *iface) /* * Generic signal handler for SIGINT. */ -void sigint_handler(int num) +void owl_sigint_handler(int num) { if (num != SIGINT) { @@ -382,7 +383,7 @@ void sigint_handler(int num) /* Gestionnaire de signal générique pour SIGTERM */ -void sigterm_handler(int num) +void owl_sigterm_handler(int num) { if (num != SIGTERM) { @@ -391,5 +392,5 @@ void sigterm_handler(int num) exit(ERR_BAD_SIGNAL) ; } - sigint_handler(SIGINT) ; + owl_sigint_handler(SIGINT) ; } diff --git a/libowlps/owlps.h b/libowlps/owlps.h index 85c6d18..7d2cc2b 100644 --- a/libowlps/owlps.h +++ b/libowlps/owlps.h @@ -218,31 +218,31 @@ BOOL run ; /* Function headers */ // Misc -char* mac_bytes_to_string(uint8_t *mac_binary) ; -BOOL mac_equals(uint8_t *mac1, uint8_t *mac2) ; -uint_fast8_t frequency_to_channel(uint_fast16_t channel) ; +char* owl_mac_bytes_to_string(uint8_t *mac_binary) ; +BOOL owl_mac_equals(uint8_t *mac1, uint8_t *mac2) ; +uint_fast8_t owl_frequency_to_channel(uint_fast16_t channel) ; // Time -void timestamp_now(TIMESTAMP *now) ; -int timestamp_now_ns(TIMESTAMP *now) ; -void timestamp_round_to_ms(TIMESTAMP *now) ; -TIMESTAMP timeval_to_timestamp(const struct timeval d) ; -uint64_t timestamp_to_ms(TIMESTAMP date) ; -uint_fast32_t time_elapsed(TIMESTAMP sup, TIMESTAMP inf) ; +void owl_timestamp_now(TIMESTAMP *now) ; +int owl_timestamp_now_ns(TIMESTAMP *now) ; +void owl_timestamp_round_to_ms(TIMESTAMP *now) ; +TIMESTAMP owl_timeval_to_timestamp(const struct timeval d) ; +uint64_t owl_timestamp_to_ms(TIMESTAMP date) ; +uint_fast32_t owl_time_elapsed(TIMESTAMP sup, TIMESTAMP inf) ; // Network -int create_udp_sending_socket(char *server_address, - uint_fast16_t server_port, - struct sockaddr_in *server_description, - struct sockaddr_in * client_description) ; -int create_udp_listening_socket(uint_fast16_t port) ; -int iface_mode_monitor(char *iface) ; -int iface_set_channel(char *iface, uint_fast8_t channel) ; -int iface_channel_hop(char *iface) ; +int owl_create_udp_sending_socket(char *server_address, + uint_fast16_t server_port, + struct sockaddr_in *server_description, + struct sockaddr_in *client_description) ; +int owl_create_udp_listening_socket(uint_fast16_t port) ; +int owl_iface_mode_monitor(char *iface) ; +int owl_iface_set_channel(char *iface, uint_fast8_t channel) ; +int owl_iface_channel_hop(char *iface) ; // Signals -void sigint_handler(int num) ; -void sigterm_handler(int num) ; +void owl_sigint_handler(int num) ; +void owl_sigterm_handler(int num) ; /* Macros */