diff --git a/owlps-aggregator/owlps-aggregator.h b/owlps-aggregator/owlps-aggregator.h index f18e16b..2267e05 100644 --- a/owlps-aggregator/owlps-aggregator.h +++ b/owlps-aggregator/owlps-aggregator.h @@ -32,7 +32,7 @@ #define DEFAULT_AGGREGATE_TIMEOUT 600 // milliseconds #define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds #define DEFAULT_CHECK_INTERVAL 300 // milliseconds -#define DEFAULT_AP_KEEP_TIMEOUT 35 // seconds +#define DEFAULT_CP_KEEP_TIMEOUT 35 // seconds #define DEFAULT_AC_ORDER_INTERVAL 1000 // milliseconds #define POSITIONER_DEFAULT_IP "127.0.0.1" @@ -50,11 +50,11 @@ typedef struct _request_info_list { // Number of the current packet: uint16_t packet_id ; - // MAC address of the transmitter AP (in bytes): - uint8_t ap_mac_addr_bytes[ETHER_ADDR_LEN] ; + // MAC address of the transmitter CP (in bytes): + uint8_t cp_mac_addr_bytes[ETHER_ADDR_LEN] ; // Timestamp of arrival on the listener: owl_timestamp capture_time ; - // Signal strength received by the AP from the mobile: + // Signal strength received by the CP from the mobile: int8_t ss_dbm ; struct _request_info_list *next ; } request_info_list ; @@ -88,17 +88,17 @@ typedef struct _request_list } request_list ; -/* Linked list of the known APs */ -typedef struct _ap_list +/* Linked list of the known CPs */ +typedef struct _cp_list { uint8_t mac_addr_bytes[ETHER_ADDR_LEN] ; char ip_addr[INET_ADDRSTRLEN] ; owl_timestamp last_seen ; - struct _ap_list *previous ; - struct _ap_list *next ; -} ap_list ; + struct _cp_list *previous ; + struct _cp_list *next ; +} cp_list ; /* Function headers */ @@ -131,21 +131,21 @@ void print_request_list(void) ; void print_request_info(request_info_list *info) ; #endif // NDEBUG -void* listen_for_aps(void *NULL_value) ; -void update_ap(uint8_t mac_addr_bytes[ETHER_ADDR_LEN], +void* listen_for_cps(void *NULL_value) ; +void update_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN], char ip_addr[INET_ADDRSTRLEN]) ; -ap_list* find_ap(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ; -ap_list* add_ap_front(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ; -void update_ap_ip_addr(ap_list *ap, char ip_addr[INET_ADDRSTRLEN]) ; -void update_ap_seen(ap_list *ap) ; -void push_ap(ap_list *ap) ; +cp_list* find_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ; +cp_list* add_cp_front(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ; +void update_cp_ip_addr(cp_list *cp, char ip_addr[INET_ADDRSTRLEN]) ; +void update_cp_seen(cp_list *cp) ; +void push_cp(cp_list *cp) ; -void* monitor_aps(void *NULL_value) ; -void delete_old_aps(void) ; -void delete_ap(ap_list *ap) ; -void unlink_ap(ap_list *ap) ; -void order_send(ap_list *ap) ; -void free_ap_list(void) ; +void* monitor_cps(void *NULL_value) ; +void delete_old_cps(void) ; +void delete_cp(cp_list *cp) ; +void unlink_cp(cp_list *cp) ; +void order_send(cp_list *cp) ; +void free_cp_list(void) ; void print_usage(void) ; void print_version(void) ; diff --git a/owlps-aggregator/owlps-aggregatord.c b/owlps-aggregator/owlps-aggregatord.c index fc77c6c..590bee7 100644 --- a/owlps-aggregator/owlps-aggregatord.c +++ b/owlps-aggregator/owlps-aggregatord.c @@ -49,9 +49,9 @@ bool dump_configuration = false ; request_list *requests = NULL ; // Computed data list sem_t lock_requests ; // Semaphore to get access to the requests -ap_list *token_aps = NULL ; // Token ring of the APs -uint_fast16_t nb_aps = 0 ; // Number of APs in the APs' ring -sem_t lock_aps ; // Semaphore to get access to the APs' ring +cp_list *token_cps = NULL ; // Token ring of the CPs +uint_fast16_t nb_cps = 0 ; // Number of CPs in the CPs' ring +sem_t lock_cps ; // Semaphore to get access to the CPs' ring @@ -61,7 +61,7 @@ int main(int argc, char **argv) struct sigaction action ; // Signal handler structure pthread_t monitor_thread, // Aggregated data monitoring thread - monitor_aps_thread, // APs monitoring thread + monitor_cps_thread, // CPs monitoring thread autocalibration_hello_thread ; // Hello messages reception thread uint_fast16_t listening_port ; int sockfd = -1 ; // UDP listening socket @@ -91,7 +91,7 @@ int main(int argc, char **argv) /* Set up semaphores */ sem_init(&lock_requests, 0, 1) ; - sem_init(&lock_aps, 0, 1) ; + sem_init(&lock_cps, 0, 1) ; /* Create UDP socket */ listening_port = cfg_getint(cfg, "listening_port") ; @@ -115,18 +115,18 @@ int main(int argc, char **argv) if (cfg_getbool(cfg, "autocalibration")) { ret = pthread_create(&autocalibration_hello_thread, NULL, - &listen_for_aps, NULL) ; + &listen_for_cps, NULL) ; if (ret != 0) { perror("Cannot create autocalibration hello thread") ; ret = OWL_ERR_THREAD_CREATE ; goto exit ; } - ret = pthread_create(&monitor_aps_thread, NULL, - &monitor_aps, NULL) ; + ret = pthread_create(&monitor_cps_thread, NULL, + &monitor_cps, NULL) ; if (ret != 0) { - perror("Cannot create monitor APs thread") ; + perror("Cannot create monitor CPs thread") ; ret = OWL_ERR_THREAD_CREATE ; goto exit ; } @@ -164,11 +164,11 @@ int main(int argc, char **argv) fprintf(stderr, "Autocalibration hello thread done.\n") ; if (VERBOSE_WARNING) - fprintf(stderr, "Waiting for the monitor APs thread...\n") ; - if (pthread_join(monitor_aps_thread, NULL) != 0) - perror("Cannot join monitor APs thread") ; + fprintf(stderr, "Waiting for the monitor CPs thread...\n") ; + if (pthread_join(monitor_cps_thread, NULL) != 0) + perror("Cannot join monitor CPs thread") ; else if (VERBOSE_WARNING) - fprintf(stderr, "Monitor APs thread done.\n") ; + fprintf(stderr, "Monitor CPs thread done.\n") ; } /* Last cleaning tasks */ @@ -181,11 +181,11 @@ int main(int argc, char **argv) if (sockfd >= 0) close(sockfd) ; // Close socket assert(requests == NULL) ; - free_ap_list() ; + free_cp_list() ; cfg_free(cfg) ; // Clean configuration // Destroy semaphores: sem_destroy(&lock_requests) ; - sem_destroy(&lock_aps) ; + sem_destroy(&lock_cps) ; return ret ; } @@ -274,8 +274,8 @@ int parse_config_file(int argc, char **argv) // listeners: CFG_INT("autocalibration_hello_port", OWL_DEFAULT_AUTOCALIBRATION_HELLO_PORT, CFGF_NONE), - // Time we keep APs in the list (in seconds): - CFG_INT("ap_keep_timeout", DEFAULT_AP_KEEP_TIMEOUT, CFGF_NONE), + // Time we keep CPs in the list (in seconds): + CFG_INT("cp_keep_timeout", DEFAULT_CP_KEEP_TIMEOUT, CFGF_NONE), // Time between two checks of the CP list (in milliseconds): CFG_INT("ac_order_interval", DEFAULT_AC_ORDER_INTERVAL, CFGF_NONE), @@ -392,7 +392,7 @@ int parse_command_line(int argc, char **argv) cfg_setint(cfg, "keep_timeout", strtol(optarg, NULL, 0)) ; break ; case 'K' : - cfg_setint(cfg, "ap_keep_timeout", strtol(optarg, NULL, 0)) ; + cfg_setint(cfg, "cp_keep_timeout", strtol(optarg, NULL, 0)) ; break ; case 'l' : cfg_setint(cfg, "listening_port", strtol(optarg, NULL, 0)) ; @@ -499,13 +499,13 @@ int check_configuration() cfg_setint(cfg, "check_interval", DEFAULT_CHECK_INTERVAL) ; } - // ap_keep_timeout // - if (cfg_getint(cfg, "ap_keep_timeout") < 0) + // cp_keep_timeout // + if (cfg_getint(cfg, "cp_keep_timeout") < 0) { if (VERBOSE_WARNING) - fprintf(stderr, "Warning! ap_keep_timeout cannot be negative:" + fprintf(stderr, "Warning! cp_keep_timeout cannot be negative:" " failing back to the default value.\n") ; - cfg_setint(cfg, "ap_keep_timeout", DEFAULT_AP_KEEP_TIMEOUT) ; + cfg_setint(cfg, "cp_keep_timeout", DEFAULT_CP_KEEP_TIMEOUT) ; } // ac_order_interval // @@ -560,7 +560,7 @@ int read_loop(int sockfd) if (VERBOSE_REQUESTS) print_captured_request(&request) ; else if (VERBOSE_CHATTERBOX) - fprintf(stderr, "Request received from AP \"%s\".\n", + fprintf(stderr, "Request received from CP \"%s\".\n", owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ; got_request(&request) ; @@ -578,7 +578,7 @@ void print_captured_request(const owl_captured_request *const request) char request_time_str[OWL_TIMESTAMP_STRLEN], capture_time_str[OWL_TIMESTAMP_STRLEN], - ap_mac_addr_str[OWL_ETHER_ADDR_STRLEN], + cp_mac_addr_str[OWL_ETHER_ADDR_STRLEN], mobile_mac_addr_str[OWL_ETHER_ADDR_STRLEN], mobile_ip_str[INET_ADDRSTRLEN] ; @@ -587,7 +587,7 @@ void print_captured_request(const owl_captured_request *const request) owl_timestamp_to_string(&request->request_time, request_time_str) ; owl_timestamp_to_string(&request->capture_time, capture_time_str) ; owl_mac_bytes_to_string_r(request->ap_mac_addr_bytes, - ap_mac_addr_str) ; + cp_mac_addr_str) ; owl_mac_bytes_to_string_r(request->mobile_mac_addr_bytes, mobile_mac_addr_str) ; inet_ntop(AF_INET, &request->mobile_ip_addr_bytes, @@ -595,13 +595,13 @@ void print_captured_request(const owl_captured_request *const request) fprintf(stderr, "\n" - "*** Request received from AP ***\n" + "*** Request received from CP ***\n" "\tType: %"PRIu8"\n" - "\tAP MAC: %s\n" + "\tCP MAC: %s\n" "\tMobile MAC: %s\n" "\tMobile IP: %s\n" "\tRequest timestamp: %s\n" - "\tRequest arrival time on the AP: %s\n" + "\tRequest arrival time on the CP: %s\n" "\tSignal: %"PRId8" dBm\n" "\tPosition X: %f\n" "\tPosition Y: %f\n" @@ -610,7 +610,7 @@ void print_captured_request(const owl_captured_request *const request) "\tPacket number: %"PRIu16"/%"PRIu16"\n" , request->type, - ap_mac_addr_str, + cp_mac_addr_str, mobile_mac_addr_str, mobile_ip_str, request_time_str, @@ -648,7 +648,7 @@ void got_request(const owl_captured_request *const request) } tmp_info->packet_id = request->packet_id ; - memcpy(tmp_info->ap_mac_addr_bytes, request->ap_mac_addr_bytes, + memcpy(tmp_info->cp_mac_addr_bytes, request->ap_mac_addr_bytes, ETHER_ADDR_LEN) ; tmp_info->capture_time = request->capture_time ; tmp_info->ss_dbm = request->ss_dbm ; @@ -687,7 +687,7 @@ void add_captured_request(const owl_timestamp *const reception_time, if (requests == NULL) // If the request list does not exist, { if (VERBOSE_INFO) - fprintf(stderr, "Creating request list with AP \"%s\".\n", + fprintf(stderr, "Creating request list with CP \"%s\".\n", owl_mac_bytes_to_string(request->ap_mac_addr_bytes)) ; tmp_request = malloc(sizeof(request_list)) ; // create it. if (! tmp_request) @@ -708,10 +708,10 @@ void add_captured_request(const owl_timestamp *const reception_time, tmp_request->request_time = request->request_time ; // Implicit packet: else - // Reception time on the AP: + // Reception time on the CP: tmp_request->request_time = request->capture_time ; // Save locale time on the aggregator (not the reception time - // on the AP): + // on the CP): tmp_request->start_time = *reception_time ; tmp_request->x_position = request->x_position ; tmp_request->y_position = request->y_position ; @@ -742,7 +742,7 @@ void add_captured_request(const owl_timestamp *const reception_time, { while (tmp_request != NULL) { // Research criterion: MAC addresses equals and reception - // times on the APs less than 10 ms + // times on the CPs less than 10 ms // TODO : define an option for the maximal difference time. if (owl_mac_equals(request->mobile_mac_addr_bytes, tmp_request->mobile_mac_addr_bytes) && @@ -756,7 +756,7 @@ void add_captured_request(const owl_timestamp *const reception_time, if (tmp_request == NULL) // The request does not exist in the list { if (VERBOSE_INFO) - fprintf(stderr, "Create new request from AP \"%s\".\n", + fprintf(stderr, "Create new request from CP \"%s\".\n", owl_mac_bytes_to_string(request->ap_mac_addr_bytes)) ; tmp_request = malloc(sizeof(request_list)) ; // create it if (! tmp_request) @@ -777,10 +777,10 @@ void add_captured_request(const owl_timestamp *const reception_time, tmp_request->request_time = request->request_time ; // Implicit packet: else - // Reception time on the AP: + // Reception time on the CP: tmp_request->request_time = request->capture_time ; // Save the local time on the aggregator (not the reception - // time on the AP): + // time on the CP): tmp_request->start_time = *reception_time ; tmp_request->x_position = request->x_position ; tmp_request->y_position = request->y_position ; @@ -1058,7 +1058,7 @@ void output_request(request_list *const request_ptr, // Send CP info to the localisation server info.packet_id = htons(request_info_ptr->packet_id) ; memcpy(info.ap_mac_addr_bytes, - request_info_ptr->ap_mac_addr_bytes, ETHER_ADDR_LEN) ; + request_info_ptr->cp_mac_addr_bytes, ETHER_ADDR_LEN) ; info.capture_time = request_info_ptr->capture_time ; owl_hton_timestamp(&info.capture_time) ; info.ss_dbm = request_info_ptr->ss_dbm ; @@ -1066,7 +1066,7 @@ void output_request(request_list *const request_ptr, 0, (const struct sockaddr *const)serv, serv_len) ; // Print CP info to the output file - owl_mac_bytes_to_string_r(request_info_ptr->ap_mac_addr_bytes, + owl_mac_bytes_to_string_r(request_info_ptr->cp_mac_addr_bytes, mac_str) ; fprintf(stream, ";%s;%"PRIu16";%"PRId8, mac_str, @@ -1151,15 +1151,15 @@ void print_request_list() */ void print_request_info(request_info_list *info) { - char ap_mac_str[OWL_ETHER_ADDR_STRLEN] ; + char cp_mac_str[OWL_ETHER_ADDR_STRLEN] ; if (info == NULL) return ; - owl_mac_bytes_to_string_r(info->ap_mac_addr_bytes, ap_mac_str) ; + owl_mac_bytes_to_string_r(info->ap_mac_addr_bytes, cp_mac_str) ; fprintf(stderr, - "\tAP MAC: %s\n" + "\tCP MAC: %s\n" "\tSignal strength: %"PRId8" dBm\n", - ap_mac_str, + cp_mac_str, info->ss_dbm ) ; } @@ -1168,16 +1168,16 @@ void print_request_info(request_info_list *info) /* - * Thread function. Listens for hello messages from APs. + * Thread function. Listens for hello messages from CPs. */ -void* listen_for_aps(void *NULL_value) +void* listen_for_cps(void *NULL_value) { int listen_sockfd ; int nread ; // recvfrom return value struct sockaddr_in client; // UDP client structure socklen_t client_len = sizeof(client) ; // Size of clients owl_autocalibration_hello message ; - char ap_ip_addr[INET_ADDRSTRLEN] ; + char cp_ip_addr[INET_ADDRSTRLEN] ; if (VERBOSE_WARNING) fprintf(stderr, "Autocalibration Hello thread launched.\n") ; @@ -1205,15 +1205,15 @@ void* listen_for_aps(void *NULL_value) continue ; } - inet_ntop(AF_INET, &client.sin_addr, ap_ip_addr, INET_ADDRSTRLEN) ; + inet_ntop(AF_INET, &client.sin_addr, cp_ip_addr, INET_ADDRSTRLEN) ; if (VERBOSE_INFO) fprintf(stderr, - "Got a Hello message from \"%s\"\n", ap_ip_addr) ; + "Got a Hello message from \"%s\"\n", cp_ip_addr) ; - sem_wait(&lock_aps) ; - update_ap(message.ap_mac_addr_bytes, ap_ip_addr) ; - sem_post(&lock_aps) ; + sem_wait(&lock_cps) ; + update_cp(message.ap_mac_addr_bytes, cp_ip_addr) ; + sem_post(&lock_cps) ; } /* Close the socket */ @@ -1224,150 +1224,150 @@ void* listen_for_aps(void *NULL_value) /* - * Updates the timestamp of the AP with the given MAC address if it is in - * the AP list, or add a new AP with this MAC address to the AP list. + * Updates the timestamp of the CP with the given MAC address if it is in + * the CP list, or add a new CP with this MAC address to the CP list. */ -void update_ap(uint8_t mac_addr_bytes[ETHER_ADDR_LEN], +void update_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN], char ip_addr[INET_ADDRSTRLEN]) { - ap_list *found ; + cp_list *found ; - if ((found = find_ap(mac_addr_bytes)) == NULL) + if ((found = find_cp(mac_addr_bytes)) == NULL) { - ap_list *new_ap = add_ap_front(mac_addr_bytes) ; - if (new_ap) - update_ap_ip_addr(new_ap, ip_addr) ; + cp_list *new_cp = add_cp_front(mac_addr_bytes) ; + if (new_cp) + update_cp_ip_addr(new_cp, ip_addr) ; } else - update_ap_seen(found) ; + update_cp_seen(found) ; } /* - * Searches the AP list for an AP with the given MAC address and returns + * Searches the CP list for a CP with the given MAC address and returns * it. */ -ap_list* find_ap(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) +cp_list* find_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) { - ap_list *found ; + cp_list *found ; - if (token_aps == NULL) + if (token_cps == NULL) return NULL ; - found = token_aps ; + found = token_cps ; do { if (owl_mac_equals(found->mac_addr_bytes, mac_addr_bytes)) return found ; found = found->next ; } - while (found != token_aps) ; + while (found != token_cps) ; return NULL ; } /* - * Adds a new AP in front of the AP list. + * Adds a new CP in front of the CP list. * Returns the new list head, or NULL in case of error. */ -ap_list* add_ap_front(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) +cp_list* add_cp_front(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) { if (VERBOSE_INFO) { char mac_str[OWL_ETHER_ADDR_STRLEN] ; owl_mac_bytes_to_string_r(mac_addr_bytes, mac_str) ; fprintf(stderr, - "Creating AP with MAC address \"%s\"...\n", mac_str) ; + "Creating CP with MAC address \"%s\"...\n", mac_str) ; } - ap_list *ap = malloc(sizeof(ap_list)) ; - if (! ap) + cp_list *cp = malloc(sizeof(cp_list)) ; + if (! cp) { perror("Cannot allocate memory") ; owl_run = false ; return NULL ; } - memcpy(ap->mac_addr_bytes, mac_addr_bytes, ETHER_ADDR_LEN) ; - update_ap_seen(ap) ; - push_ap(ap) ; - return ap ; + memcpy(cp->mac_addr_bytes, mac_addr_bytes, ETHER_ADDR_LEN) ; + update_cp_seen(cp) ; + push_cp(cp) ; + return cp ; } /* - * Change the IP address of the AP 'ap' with 'ip_addr'. + * Change the IP address of the CP 'cp' with 'ip_addr'. */ -void update_ap_ip_addr(ap_list *ap, char ip_addr[INET_ADDRSTRLEN]) +void update_cp_ip_addr(cp_list *cp, char ip_addr[INET_ADDRSTRLEN]) { - strncpy(ap->ip_addr, ip_addr, INET_ADDRSTRLEN) ; + strncpy(cp->ip_addr, ip_addr, INET_ADDRSTRLEN) ; } /* - * Updates the timestamp of the given AP. + * Updates the timestamp of the given CP. */ -void update_ap_seen(ap_list *ap) +void update_cp_seen(cp_list *cp) { - assert(ap) ; - owl_timestamp_now(&ap->last_seen) ; + assert(cp) ; + owl_timestamp_now(&cp->last_seen) ; } /* - * Puts an existing AP in front of the AP list. The AP must not be in + * Puts an existing CP in front of the CP list. The CP must not be in * the list yet. */ -void push_ap(ap_list *ap) +void push_cp(cp_list *cp) { - assert(ap) ; + assert(cp) ; - ++nb_aps ; + ++nb_cps ; - if (token_aps == NULL) // List does not exist yet + if (token_cps == NULL) // List does not exist yet { - token_aps = ap ; - ap->next = ap ; - ap->previous = ap ; + token_cps = cp ; + cp->next = cp ; + cp->previous = cp ; return ; } - ap->previous = token_aps->previous ; - ap->previous->next = ap ; - ap->next = token_aps ; - token_aps->previous = ap ; - token_aps = ap ; + cp->previous = token_cps->previous ; + cp->previous->next = cp ; + cp->next = token_cps ; + token_cps->previous = cp ; + token_cps = cp ; } /* - * Monitors the AP list: sends orders to APs following their order in - * the list, and deletes old APs. + * Monitors the CP list: sends orders to CPs following their order in + * the list, and deletes old CPs. */ -void* monitor_aps(void *NULL_value) +void* monitor_cps(void *NULL_value) { if (VERBOSE_WARNING) - fprintf(stderr, "Monitor AP thread launched.\n") ; + fprintf(stderr, "Monitor CP thread launched.\n") ; while (owl_run) { - sem_wait(&lock_aps) ; - delete_old_aps() ; - sem_post(&lock_aps) ; + sem_wait(&lock_cps) ; + delete_old_cps() ; + sem_post(&lock_cps) ; // Here we're not in a hurry, so we released the semaphore to - // allow listen_for_aps() to process a received hello packet, + // allow listen_for_cps() to process a received hello packet, // if needed. - sem_wait(&lock_aps) ; - if (nb_aps > 1) + sem_wait(&lock_cps) ; + if (nb_cps > 1) { - order_send(token_aps) ; - token_aps = token_aps->next ; + order_send(token_cps) ; + token_cps = token_cps->next ; } - sem_post(&lock_aps) ; + sem_post(&lock_cps) ; owl_msleep(cfg_getint(cfg, "ac_order_interval")) ; } @@ -1377,77 +1377,77 @@ void* monitor_aps(void *NULL_value) /* - * Deletes APs that did not send any Hello packet for a while, following - * the list order. Stops on the first not-to-be-deleted AP. + * Deletes CPs that did not send any Hello packet for a while, following + * the list order. Stops on the first not-to-be-deleted CP. */ -void delete_old_aps() +void delete_old_cps() { owl_timestamp now ; owl_timestamp_now(&now) ; - while (token_aps != NULL) - if (owl_time_elapsed_ms(&token_aps->last_seen, &now) > - (uint_fast32_t) cfg_getint(cfg, "ap_keep_timeout") * 1000) - delete_ap(token_aps) ; + while (token_cps != NULL) + if (owl_time_elapsed_ms(&token_cps->last_seen, &now) > + (uint_fast32_t) cfg_getint(cfg, "cp_keep_timeout") * 1000) + delete_cp(token_cps) ; else return ; } /* - * Deletes the given AP from the AP list. + * Deletes the given CP from the CP list. */ -void delete_ap(ap_list *ap) +void delete_cp(cp_list *cp) { if (VERBOSE_INFO) { char mac_str[OWL_ETHER_ADDR_STRLEN] ; - assert(ap) ; - owl_mac_bytes_to_string_r(ap->mac_addr_bytes, mac_str) ; - fprintf(stderr, "Deleting AP \"%s\"...\n", mac_str) ; + assert(cp) ; + owl_mac_bytes_to_string_r(cp->mac_addr_bytes, mac_str) ; + fprintf(stderr, "Deleting CP \"%s\"...\n", mac_str) ; } - unlink_ap(ap) ; - free(ap) ; + unlink_cp(cp) ; + free(cp) ; } /* - * Extracts the given AP from the AP list (it will not be linked to any + * Extracts the given CP from the CP list (it will not be linked to any * other element of the list). */ -void unlink_ap(ap_list *ap) +void unlink_cp(cp_list *cp) { - ap_list - *ap_previous, - *ap_next ; + cp_list + *cp_previous, + *cp_next ; - assert(ap) ; - ap_previous = ap->previous ; - ap_next = ap->next ; - assert(ap_previous) ; - assert(ap_next) ; + assert(cp) ; + cp_previous = cp->previous ; + cp_next = cp->next ; + assert(cp_previous) ; + assert(cp_next) ; - ap_previous->next = ap_next ; - ap_next->previous = ap_previous ; + cp_previous->next = cp_next ; + cp_next->previous = cp_previous ; - if (ap == token_aps) + if (cp == token_cps) { - if (ap->next == ap) // It was the last AP in the ring - token_aps = NULL ; + if (cp->next == cp) // It was the last CP in the ring + token_cps = NULL ; else - token_aps = ap_next ; + token_cps = cp_next ; } - --nb_aps ; + --nb_cps ; } /* - * Sends a 'send' order to the given AP. + * Sends a 'send' order to the given CP. */ -void order_send(ap_list *ap) +void order_send(cp_list *cp) { owl_autocalibration_order message ; struct sockaddr_in serv; @@ -1457,10 +1457,10 @@ void order_send(ap_list *ap) ssize_t nsent ; if (VERBOSE_INFO) - fprintf(stderr, "Sending an order to %s...\n", ap->ip_addr) ; + fprintf(stderr, "Sending an order to %s...\n", cp->ip_addr) ; sockfd = - owl_create_udp_trx_socket(ap->ip_addr, + owl_create_udp_trx_socket(cp->ip_addr, cfg_getint(cfg, "autocalibration_order_port"), &serv, &client) ; @@ -1479,29 +1479,29 @@ void order_send(ap_list *ap) /* - * Empties the AP list. - * Note that this function does not use lock_aps, so it should not + * Empties the CP list. + * Note that this function does not use lock_cps, so it should not * be called in a concurrent context. */ -void free_ap_list() +void free_cp_list() { - ap_list *ap_ptr ; + cp_list *cp_ptr ; - if (token_aps == NULL) + if (token_cps == NULL) return ; - ap_ptr = token_aps->next ; - assert(ap_ptr) ; + cp_ptr = token_cps->next ; + assert(cp_ptr) ; - while (ap_ptr != token_aps) + while (cp_ptr != token_cps) { - ap_list *ap_tmp = ap_ptr ; - ap_ptr = ap_ptr->next ; - free(ap_tmp) ; + cp_list *cp_tmp = cp_ptr ; + cp_ptr = cp_ptr->next ; + free(cp_tmp) ; } - free(token_aps) ; - token_aps = NULL ; + free(token_cps) ; + token_cps = NULL ; } @@ -1528,7 +1528,7 @@ void print_usage() " [-A]" " [-a autocalibration_port]" "\n\t" - " [-K ap_keep_timeout]" + " [-K cp_keep_timeout]" " [-C ac_order_interval]" "\n" "\t%s -h\n" @@ -1579,8 +1579,8 @@ void print_usage() " sent to\n\t\t\t\tthe listeners (default: %d).\n" "\t-H port\t\t\tPort on which autocalibration hello are" " received\n\t\t\t\tfrom the listeners (default: %d).\n" - "\t-K ap_keep_timeout\tInactive APs are kept during" - " 'ap_keep_timeout'\n\t\t\t\tseconds (default: %d s).\n" + "\t-K cp_keep_timeout\tInactive CPs are kept during" + " 'cp_keep_timeout'\n\t\t\t\tseconds (default: %d s).\n" "\t-C ac_order_interval\tTime (in milliseconds) between two" " transmissions\n\t\t\t\tof autocalibration orders to the" " stored CPs\n\t\t\t\t(default: %d ms).\n" @@ -1597,7 +1597,7 @@ void print_usage() DEFAULT_CHECK_INTERVAL, OWL_DEFAULT_AUTOCALIBRATION_ORDER_PORT, OWL_DEFAULT_AUTOCALIBRATION_HELLO_PORT, - DEFAULT_AP_KEEP_TIMEOUT, + DEFAULT_CP_KEEP_TIMEOUT, DEFAULT_AC_ORDER_INTERVAL ) ; }