[lib] Rename types
- Lowercase all defined types. - Prefix with "owl_". - Rename couple_message -> owl_captured_request. - Rename couple_info -> owl_request_info.
This commit is contained in:
parent
a72a76d5a9
commit
91cba33dcd
1
TODO
1
TODO
|
@ -9,7 +9,6 @@
|
|||
|
||||
* libowlps
|
||||
|
||||
- Prefix types with "owl_". Rename some of them (lowercase, at least).
|
||||
- Remove timestamp_to_ms()
|
||||
This function is used only by the aggregator to test if a TIMESTAMP
|
||||
is null. We should create a function to test that, instead of
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define DEBUG
|
||||
|
||||
|
||||
BOOL run = TRUE ;
|
||||
owl_bool run = TRUE ;
|
||||
|
||||
|
||||
|
||||
|
@ -91,10 +91,10 @@ uint_fast8_t owl_frequency_to_channel(uint_fast16_t channel)
|
|||
|
||||
|
||||
/*
|
||||
* Sets the TIMESTAMP 'now' at the current time.
|
||||
* Sets the owl_timestamp 'now' at the current time.
|
||||
* Returns 0 in case of success non-zero otherwise.
|
||||
*/
|
||||
int owl_timestamp_now(TIMESTAMP *now)
|
||||
int owl_timestamp_now(owl_timestamp *now)
|
||||
{
|
||||
int ret ;
|
||||
struct timespec now_ts ;
|
||||
|
@ -112,11 +112,11 @@ int owl_timestamp_now(TIMESTAMP *now)
|
|||
|
||||
|
||||
/*
|
||||
* Returns a TIMESTAMP from a struct timespec.
|
||||
* Returns a owl_timestamp from a struct timespec.
|
||||
*/
|
||||
TIMESTAMP owl_timespec_to_timestamp(const struct timespec d)
|
||||
owl_timestamp owl_timespec_to_timestamp(const struct timespec d)
|
||||
{
|
||||
TIMESTAMP res ;
|
||||
owl_timestamp res ;
|
||||
res.tv_sec = d.tv_sec ;
|
||||
res.tv_nsec = d.tv_nsec ;
|
||||
return res ;
|
||||
|
@ -125,11 +125,11 @@ TIMESTAMP owl_timespec_to_timestamp(const struct timespec d)
|
|||
|
||||
|
||||
/*
|
||||
* Returns a TIMESTAMP from a struct timeval.
|
||||
* Returns a owl_timestamp from a struct timeval.
|
||||
*/
|
||||
TIMESTAMP owl_timeval_to_timestamp(const struct timeval d)
|
||||
owl_timestamp owl_timeval_to_timestamp(const struct timeval d)
|
||||
{
|
||||
TIMESTAMP res ;
|
||||
owl_timestamp res ;
|
||||
res.tv_sec = d.tv_sec ;
|
||||
res.tv_nsec = d.tv_usec * 1000u ;
|
||||
return res ;
|
||||
|
@ -138,23 +138,23 @@ TIMESTAMP owl_timeval_to_timestamp(const struct timeval d)
|
|||
|
||||
|
||||
/*
|
||||
* Converts a TIMESTAMP date value into milliseconds.
|
||||
* Converts a owl_timestamp date value into milliseconds.
|
||||
*/
|
||||
uint64_t owl_timestamp_to_ms(TIMESTAMP d)
|
||||
uint64_t owl_timestamp_to_ms(owl_timestamp d)
|
||||
{
|
||||
return (uint64_t) d.tv_sec * 1000u + (uint64_t) d.tv_nsec / 1000000u ;
|
||||
return (uint64_t) d.tv_sec * 1000u + (uint64_t) d.tv_nsec / 1000000lu ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Converts a TIMESTAMP date value into a printable string.
|
||||
* 'dst' must be an allocated array of at least TIMESTAMP_STR_LEN
|
||||
* Converts a owl_timestamp date value into a printable string.
|
||||
* 'dst' must be an allocated array of at least owl_timestamp_STR_LEN
|
||||
* characters.
|
||||
*/
|
||||
void owl_timestamp_to_string(char *dst, TIMESTAMP src)
|
||||
void owl_timestamp_to_string(char *dst, owl_timestamp src)
|
||||
{
|
||||
snprintf(dst, TIMESTAMP_STR_LEN, "%"PRIu32".%"PRIu32,
|
||||
snprintf(dst, OWL_TIMESTAMP_STR_LEN, "%"PRIu32".%"PRIu32,
|
||||
src.tv_sec, src.tv_nsec) ;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,8 @@ void owl_timestamp_to_string(char *dst, TIMESTAMP src)
|
|||
/*
|
||||
* Returns the time (in milliseconds) between two dates.
|
||||
*/
|
||||
uint_fast32_t owl_time_elapsed_ms(const TIMESTAMP d1, const TIMESTAMP d2)
|
||||
uint_fast32_t owl_time_elapsed_ms(const owl_timestamp d1,
|
||||
const owl_timestamp d2)
|
||||
{
|
||||
return owl_timestamp_to_ms(owl_time_elapsed(d1, d2)) ;
|
||||
}
|
||||
|
@ -171,11 +172,12 @@ uint_fast32_t owl_time_elapsed_ms(const TIMESTAMP d1, const TIMESTAMP d2)
|
|||
|
||||
|
||||
/*
|
||||
* Returns a TIMESTAMP storing the time between two dates.
|
||||
* Returns a owl_timestamp storing the time between two dates.
|
||||
*/
|
||||
TIMESTAMP owl_time_elapsed(const TIMESTAMP d1, const TIMESTAMP d2)
|
||||
owl_timestamp owl_time_elapsed(const owl_timestamp d1,
|
||||
const owl_timestamp d2)
|
||||
{
|
||||
TIMESTAMP elapsed ;
|
||||
owl_timestamp elapsed ;
|
||||
elapsed.tv_sec = abs(d1.tv_sec - d2.tv_sec) ;
|
||||
elapsed.tv_nsec = abs(d1.tv_nsec - d2.tv_nsec) ;
|
||||
#ifdef DEBUG
|
||||
|
@ -188,11 +190,11 @@ TIMESTAMP owl_time_elapsed(const TIMESTAMP d1, const TIMESTAMP d2)
|
|||
|
||||
|
||||
/*
|
||||
* Converts a TIMESTAMP from host endianess to network endianess.
|
||||
* Converts a owl_timestamp from host endianess to network endianess.
|
||||
*/
|
||||
TIMESTAMP owl_hton_timestamp(TIMESTAMP date)
|
||||
owl_timestamp owl_hton_timestamp(owl_timestamp date)
|
||||
{
|
||||
TIMESTAMP d ;
|
||||
owl_timestamp d ;
|
||||
d.tv_sec = htonl(date.tv_sec) ;
|
||||
d.tv_nsec = htonl(date.tv_nsec) ;
|
||||
return d ;
|
||||
|
@ -201,11 +203,11 @@ TIMESTAMP owl_hton_timestamp(TIMESTAMP date)
|
|||
|
||||
|
||||
/*
|
||||
* Converts a TIMESTAMP from network endianess to host endianess.
|
||||
* Converts a owl_timestamp from network endianess to host endianess.
|
||||
*/
|
||||
TIMESTAMP owl_ntoh_timestamp(TIMESTAMP date)
|
||||
owl_timestamp owl_ntoh_timestamp(owl_timestamp date)
|
||||
{
|
||||
TIMESTAMP d ;
|
||||
owl_timestamp d ;
|
||||
d.tv_sec = ntohl(date.tv_sec) ;
|
||||
d.tv_nsec = ntohl(date.tv_nsec) ;
|
||||
return d ;
|
||||
|
@ -217,7 +219,7 @@ TIMESTAMP owl_ntoh_timestamp(TIMESTAMP date)
|
|||
* Compares two MAC addresses.
|
||||
* Returns TRUE if they are identical, FALSE otherwise.
|
||||
*/
|
||||
BOOL owl_mac_equals(uint8_t *mac1, uint8_t *mac2)
|
||||
owl_bool owl_mac_equals(uint8_t *mac1, uint8_t *mac2)
|
||||
{
|
||||
int i ;
|
||||
for(i=0 ; i < 6 ; i++)
|
||||
|
|
|
@ -56,66 +56,76 @@ extern "C" {
|
|||
|
||||
|
||||
/* Boolean type */
|
||||
typedef enum {FALSE, TRUE} BOOL ;
|
||||
#define BOOL_TO_STRING(B) ((B) ? "true" : "false")
|
||||
typedef enum {FALSE, TRUE} owl_bool ;
|
||||
#define OWL_BOOL_TO_STRING(B) ((B) ? "true" : "false")
|
||||
|
||||
|
||||
/* Direction type */
|
||||
enum {NORTH = 1, EAST, SOUTH, WEST} ;
|
||||
typedef uint8_t DIRECTION ;
|
||||
typedef uint8_t owl_direction ;
|
||||
|
||||
|
||||
/* Timestamp type (struct timespec clone with fix-sized fields) */
|
||||
typedef struct _TIMESTAMP
|
||||
typedef struct _owl_timestamp
|
||||
{
|
||||
uint32_t tv_sec ;
|
||||
uint32_t tv_nsec ;
|
||||
} TIMESTAMP ;
|
||||
// Length of a TIMESTAMP when converted to string:
|
||||
#define TIMESTAMP_STR_LEN 22 // 22 = 10 digits, '.', 10 digits, '\0'
|
||||
} owl_timestamp ;
|
||||
// Length of a owl_timestamp when converted to string:
|
||||
#define OWL_TIMESTAMP_STR_LEN 22 // 22 = 10 digits, '.', 10 digits, '\0'
|
||||
|
||||
|
||||
/* Message sent by the listener to the aggregator */
|
||||
typedef struct _couple_message
|
||||
typedef struct _owl_captured_request
|
||||
{
|
||||
uint8_t ap_mac_addr_bytes[6] ; // MAC of the listener
|
||||
uint8_t mobile_mac_addr_bytes[6] ; // MAC of the mobile involved
|
||||
uint8_t mobile_ip_addr_bytes[4] ; // IP of the mobile
|
||||
TIMESTAMP request_time ; // Request ID (timestamp on the mobile)
|
||||
TIMESTAMP start_time ; // Timestamp of arrival on the listener
|
||||
owl_timestamp request_time ; // Request ID (timestamp on the mobile)
|
||||
owl_timestamp start_time ; // Timestamp of arrival on the listener
|
||||
uint8_t antenna_signal_dbm ; // Signal strength measured by the listener
|
||||
/* Calibration data */
|
||||
float x_position ;
|
||||
float y_position ;
|
||||
float z_position ;
|
||||
DIRECTION direction ;
|
||||
} couple_message ;
|
||||
owl_direction direction ;
|
||||
} owl_captured_request ;
|
||||
|
||||
typedef struct _couple_info
|
||||
|
||||
/* Message sent by the aggregator to the positioning server containing
|
||||
* the main data of a request */
|
||||
typedef struct _owl_request
|
||||
{
|
||||
uint8_t mobile_mac_addr_bytes[6] ; // MAC of the mobile
|
||||
owl_timestamp request_time ; // Request ID (timestamp on the mobile)
|
||||
uint16_t nb_info ; // Number of (listener MAC;signal strength) couples
|
||||
} owl_request ;
|
||||
|
||||
|
||||
/* Message sent by the aggregator to the positioning server refering to
|
||||
* a request, indicating that an AP received the request with a given
|
||||
* signal strength */
|
||||
typedef struct _owl_request_info
|
||||
{
|
||||
uint8_t ap_mac_addr_bytes[6] ; // MAC of the listener
|
||||
uint8_t antenna_signal_dbm ; // Signal strength measured by the listener
|
||||
} couple_info ;
|
||||
} owl_request_info ;
|
||||
|
||||
typedef struct _request
|
||||
{
|
||||
uint8_t mobile_mac_addr_bytes[6]; // MAC of the mobile
|
||||
TIMESTAMP request_time ; // Request ID (timestamp on the mobile)
|
||||
uint16_t nb_couples; // Number of (listener MAC;signal strength) couples
|
||||
} request;
|
||||
|
||||
/* Hello message sent by the listener to the aggregator */
|
||||
typedef struct _autocalibration_hello
|
||||
typedef struct _owl_autocalibration_hello
|
||||
{
|
||||
uint8_t ap_mac_addr_bytes[6];
|
||||
} autocalibration_hello ;
|
||||
uint8_t ap_mac_addr_bytes[6] ;
|
||||
} owl_autocalibration_hello ;
|
||||
|
||||
|
||||
/* Message sent to the listener to order an emission */
|
||||
#define AUTOCALIBRATION_ORDER_SEND 1
|
||||
typedef struct _autocalibration_order
|
||||
typedef struct _owl_autocalibration_order
|
||||
{
|
||||
uint8_t order ;
|
||||
} autocalibration_order ;
|
||||
} owl_autocalibration_order ;
|
||||
|
||||
|
||||
/* Positioning request types */
|
||||
#define PACKET_TYPE_NORMAL 0
|
||||
|
@ -217,7 +227,7 @@ typedef struct _autocalibration_order
|
|||
|
||||
|
||||
/* Global variables */
|
||||
BOOL run ;
|
||||
owl_bool run ;
|
||||
|
||||
|
||||
/* Function error codes */
|
||||
|
@ -231,19 +241,21 @@ BOOL run ;
|
|||
/* Function headers */
|
||||
// Misc
|
||||
char* owl_mac_bytes_to_string(uint8_t *mac_binary) ;
|
||||
BOOL owl_mac_equals(uint8_t *mac1, uint8_t *mac2) ;
|
||||
owl_bool owl_mac_equals(uint8_t *mac1, uint8_t *mac2) ;
|
||||
uint_fast8_t owl_frequency_to_channel(uint_fast16_t channel) ;
|
||||
|
||||
// Time
|
||||
int owl_timestamp_now(TIMESTAMP *now) ;
|
||||
TIMESTAMP owl_timespec_to_timestamp(const struct timespec d) ;
|
||||
TIMESTAMP owl_timeval_to_timestamp(const struct timeval d) ;
|
||||
void owl_timestamp_to_string(char *dst, TIMESTAMP src) ;
|
||||
uint64_t owl_timestamp_to_ms(TIMESTAMP date) ;
|
||||
uint_fast32_t owl_time_elapsed_ms(const TIMESTAMP d1, const TIMESTAMP d2) ;
|
||||
TIMESTAMP owl_time_elapsed(const TIMESTAMP d1, const TIMESTAMP d2) ;
|
||||
TIMESTAMP owl_hton_timestamp(TIMESTAMP date) ;
|
||||
TIMESTAMP owl_ntoh_timestamp(TIMESTAMP date) ;
|
||||
int owl_timestamp_now(owl_timestamp *now) ;
|
||||
owl_timestamp owl_timespec_to_timestamp(const struct timespec d) ;
|
||||
owl_timestamp owl_timeval_to_timestamp(const struct timeval d) ;
|
||||
void owl_timestamp_to_string(char *dst, owl_timestamp src) ;
|
||||
uint64_t owl_timestamp_to_ms(owl_timestamp date) ;
|
||||
uint_fast32_t owl_time_elapsed_ms(const owl_timestamp d1,
|
||||
const owl_timestamp d2) ;
|
||||
owl_timestamp owl_time_elapsed(const owl_timestamp d1,
|
||||
const owl_timestamp d2) ;
|
||||
owl_timestamp owl_hton_timestamp(owl_timestamp date) ;
|
||||
owl_timestamp owl_ntoh_timestamp(owl_timestamp date) ;
|
||||
|
||||
// Network
|
||||
int owl_create_udp_trx_socket(char *server_address,
|
||||
|
|
|
@ -50,17 +50,17 @@ typedef struct _couple_list
|
|||
{
|
||||
/* Numéro de séquence de la demande de localisation du mobile */
|
||||
uint8_t mobile_mac_addr_bytes[6] ; // Mobile MAC address (in bytes)
|
||||
TIMESTAMP request_time ; // Request time on the mobile
|
||||
owl_timestamp request_time ; // Request time on the mobile
|
||||
|
||||
/* Calibration data */
|
||||
float x_position ;
|
||||
float y_position ;
|
||||
float z_position ;
|
||||
DIRECTION direction ; // Request orientation
|
||||
owl_direction direction ; // Request orientation
|
||||
|
||||
/* Other data */
|
||||
// Arrival time of the first packet of the couple on the aggregator:
|
||||
TIMESTAMP start_time ;
|
||||
owl_timestamp start_time ;
|
||||
couple_info_list *info ; // Data for this couple
|
||||
|
||||
struct _couple_list *next ;
|
||||
|
@ -73,7 +73,7 @@ typedef struct _ap_list
|
|||
uint8_t mac_addr_bytes[6] ;
|
||||
char ip_addr[16] ;
|
||||
|
||||
TIMESTAMP last_seen ;
|
||||
owl_timestamp last_seen ;
|
||||
|
||||
struct _ap_list *previous ;
|
||||
struct _ap_list *next ;
|
||||
|
@ -87,7 +87,7 @@ void parse_command_line(int argc, char **argv) ;
|
|||
void check_configuration(void) ;
|
||||
|
||||
int read_loop(int sockfd) ;
|
||||
void got_couple_info(couple_message message) ;
|
||||
void got_couple_info(owl_captured_request request) ;
|
||||
|
||||
void* monitor_couples(void) ;
|
||||
void free_couple_list(void) ;
|
||||
|
|
|
@ -326,13 +326,14 @@ int read_loop(int sockfd)
|
|||
int nread ; // recvfrom return value
|
||||
struct sockaddr_in client; // UDP client structure
|
||||
socklen_t client_len = sizeof(client) ; // Size of clients
|
||||
couple_message message ; // Message read on the socket
|
||||
owl_captured_request message ; // Message read on the socket
|
||||
char
|
||||
*ap_mac_str, // Return pointers for owl_mac_bytes_to_string(),
|
||||
*mobile_mac_str,
|
||||
*mobile_ip_str, // ip_bytes_to_string(),
|
||||
request_time_str[TIMESTAMP_STR_LEN], // and owl_timestamp_to_string()
|
||||
start_time_str[TIMESTAMP_STR_LEN] ;
|
||||
// and owl_timestamp_to_string():
|
||||
request_time_str[OWL_TIMESTAMP_STR_LEN],
|
||||
start_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
||||
|
||||
while (run)
|
||||
{
|
||||
|
@ -419,12 +420,12 @@ void* monitor_couples()
|
|||
{
|
||||
couple_list *couple_ptr, *couple_prev ;
|
||||
couple_info_list *couple_info_ptr ;
|
||||
TIMESTAMP current_time ;
|
||||
owl_timestamp current_time ;
|
||||
FILE *fd = NULL ;
|
||||
char *mac_str ;
|
||||
uint_fast32_t sub ; // owl_time_elapsed_ms() result
|
||||
#ifdef USE_TIMESTAMP
|
||||
char request_time_str[TIMESTAMP_STR_LEN] ;
|
||||
char request_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
||||
#endif // USE_TIMESTAMP
|
||||
|
||||
uint_fast32_t aggregate_timeout =
|
||||
|
@ -434,8 +435,8 @@ void* monitor_couples()
|
|||
struct sockaddr_in serv;
|
||||
struct sockaddr_in client ;
|
||||
socklen_t serv_len = sizeof(serv);
|
||||
request demande;
|
||||
couple_info info;
|
||||
owl_request demande ;
|
||||
owl_request_info info;
|
||||
int sockfd;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -505,21 +506,21 @@ void* monitor_couples()
|
|||
memcpy(demande.mobile_mac_addr_bytes,
|
||||
couple_ptr->mobile_mac_addr_bytes, 6) ;
|
||||
demande.request_time = couple_ptr->request_time ;
|
||||
demande.nb_couples = 0 ;
|
||||
demande.nb_info = 0 ;
|
||||
|
||||
// Count the couples:
|
||||
couple_info_ptr = couple_ptr->info ;
|
||||
while (couple_info_ptr != NULL)
|
||||
{
|
||||
demande.nb_couples++;
|
||||
demande.nb_info++;
|
||||
couple_info_ptr = couple_info_ptr->next ;
|
||||
}
|
||||
// Endianess conversions:
|
||||
demande.nb_couples = htons(demande.nb_couples) ;
|
||||
demande.nb_info = htons(demande.nb_info) ;
|
||||
demande.request_time =
|
||||
owl_hton_timestamp(demande.request_time) ;
|
||||
// Send the request:
|
||||
sendto(sockfd, (void *)&demande, sizeof(request), 0,
|
||||
sendto(sockfd, &demande, sizeof(demande), 0,
|
||||
(struct sockaddr *)&serv, serv_len) ;
|
||||
|
||||
// Send couples to the server and empty the list
|
||||
|
@ -531,7 +532,7 @@ void* monitor_couples()
|
|||
couple_info_ptr->ap_mac_addr_bytes, 6) ;
|
||||
info.antenna_signal_dbm =
|
||||
couple_info_ptr->antenna_signal_dbm - 0x100 ;
|
||||
sendto(sockfd, (void *)&info, sizeof(couple_info),
|
||||
sendto(sockfd, &info, sizeof(info),
|
||||
0, (struct sockaddr *)&serv, serv_len) ;
|
||||
|
||||
// Print AP info to the output file
|
||||
|
@ -601,11 +602,11 @@ void* monitor_couples()
|
|||
/*
|
||||
* Treats a received packet.
|
||||
*/
|
||||
void got_couple_info(couple_message message)
|
||||
void got_couple_info(owl_captured_request message)
|
||||
{
|
||||
couple_list *tmp_couple = NULL ;
|
||||
couple_info_list *tmp_info = NULL ;
|
||||
TIMESTAMP start_time ; // Reception time on the aggregator
|
||||
owl_timestamp start_time ; // Reception time on the aggregator
|
||||
|
||||
owl_timestamp_now(&start_time) ;
|
||||
|
||||
|
@ -751,7 +752,7 @@ void listen_for_aps(void)
|
|||
int nread ; // recvfrom return value
|
||||
struct sockaddr_in client; // UDP client structure
|
||||
socklen_t client_len = sizeof(client) ; // Size of clients
|
||||
autocalibration_hello message ;
|
||||
owl_autocalibration_hello message ;
|
||||
char ap_ip_addr[16] ;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -934,7 +935,7 @@ void monitor_aps()
|
|||
*/
|
||||
void delete_old_aps()
|
||||
{
|
||||
TIMESTAMP now ;
|
||||
owl_timestamp now ;
|
||||
|
||||
owl_timestamp_now(&now) ;
|
||||
|
||||
|
@ -1000,7 +1001,7 @@ void unlink_ap(ap_list *ap)
|
|||
*/
|
||||
void order_send(ap_list *ap)
|
||||
{
|
||||
autocalibration_order message ;
|
||||
owl_autocalibration_order message ;
|
||||
struct sockaddr_in serv;
|
||||
struct sockaddr_in client ;
|
||||
socklen_t serv_len = sizeof(serv);
|
||||
|
@ -1065,8 +1066,8 @@ void print_couple_list()
|
|||
couple_info_list *info_ptr = NULL ;
|
||||
char *mobile_mac_str ;
|
||||
char
|
||||
request_time_str[TIMESTAMP_STR_LEN],
|
||||
start_time_str[TIMESTAMP_STR_LEN] ;
|
||||
request_time_str[OWL_TIMESTAMP_STR_LEN],
|
||||
start_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
||||
|
||||
if (couples == NULL) // Empty list
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ struct {
|
|||
uint_fast16_t nb_pkt ; // Number of packets to send
|
||||
uint_fast16_t listening_port ;
|
||||
// Calibration data:
|
||||
DIRECTION direction ;
|
||||
owl_direction direction ;
|
||||
float x ;
|
||||
float y ;
|
||||
float z ;
|
||||
|
@ -64,7 +64,7 @@ char *program_name = NULL ;
|
|||
|
||||
// TRUE if the packet is a calibration request, FALSE if it is a simple
|
||||
// positioning request:
|
||||
BOOL is_calibration_request = FALSE ;
|
||||
owl_bool is_calibration_request = FALSE ;
|
||||
|
||||
int sockfd ; // Sending socket descriptor
|
||||
struct sockaddr_in server ; // Server info
|
||||
|
@ -302,8 +302,8 @@ void create_socket()
|
|||
void make_packet()
|
||||
{
|
||||
uint_fast16_t offset ; // Index used to create the packet
|
||||
TIMESTAMP request_time ;
|
||||
char request_time_str[TIMESTAMP_STR_LEN] ;
|
||||
owl_timestamp request_time ;
|
||||
char request_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
||||
|
||||
// Get the current time and copy it as a string before to switch it to
|
||||
// network endianess:
|
||||
|
@ -317,7 +317,7 @@ void make_packet()
|
|||
|
||||
offset = 0 ;
|
||||
packet_size =
|
||||
sizeof(uint8_t) * 2 + sizeof(TIMESTAMP) + sizeof(float) * 3 ;
|
||||
sizeof(uint8_t) * 2 + sizeof(owl_timestamp) + sizeof(float) * 3 ;
|
||||
packet = malloc(packet_size) ;
|
||||
|
||||
memset(&packet[offset], PACKET_TYPE_CALIBRATION, 1) ; // Packet type
|
||||
|
@ -339,7 +339,7 @@ void make_packet()
|
|||
else // Standard packet
|
||||
{
|
||||
printf("Preparing request packet…\n") ;
|
||||
packet_size = sizeof(uint8_t) + sizeof(TIMESTAMP) ;
|
||||
packet_size = sizeof(uint8_t) + sizeof(owl_timestamp) ;
|
||||
packet = malloc(packet_size) ;
|
||||
memset(&packet[0], PACKET_TYPE_NORMAL, 1) ; // Packet type
|
||||
memcpy(&packet[1], &request_time, sizeof(request_time)) ;
|
||||
|
|
|
@ -29,12 +29,12 @@ struct {
|
|||
uint_fast16_t aggregation_port ;
|
||||
uint_fast16_t listening_port ;
|
||||
#ifdef USE_PTHREAD
|
||||
BOOL keep_monitor ;
|
||||
owl_bool keep_monitor ;
|
||||
#endif // USE_PTHREAD
|
||||
char rtap_iface[IFNAMSIZ + 1] ;
|
||||
char wifi_iface[IFNAMSIZ + 1] ;
|
||||
#ifdef USE_PTHREAD
|
||||
BOOL autocalibration ;
|
||||
owl_bool autocalibration ;
|
||||
char autocalibration_ip[16] ;
|
||||
uint_fast16_t autocalibration_request_port ;
|
||||
uint_fast16_t autocalibration_port ;
|
||||
|
@ -42,8 +42,8 @@ struct {
|
|||
uint_fast32_t autocalibration_delay ;
|
||||
uint_fast16_t autocalibration_nb_packets ;
|
||||
#endif // USE_PTHREAD
|
||||
BOOL verbose ;
|
||||
BOOL display_captured ;
|
||||
owl_bool verbose ;
|
||||
owl_bool display_captured ;
|
||||
} options = { // Initalise default options:
|
||||
MODE_ACTIVE,
|
||||
"127.0.0.1",
|
||||
|
@ -468,8 +468,8 @@ void print_configuration()
|
|||
GET_RTAP_IFACE(),
|
||||
GET_WIFI_IFACE(),
|
||||
#ifdef USE_PTHREAD
|
||||
BOOL_TO_STRING(GET_KEEP_MONITOR()),
|
||||
BOOL_TO_STRING(GET_AUTOCALIBRATION()),
|
||||
OWL_BOOL_TO_STRING(GET_KEEP_MONITOR()),
|
||||
OWL_BOOL_TO_STRING(GET_AUTOCALIBRATION()),
|
||||
GET_AUTOCALIBRATION_IP(),
|
||||
GET_AUTOCALIBRATION_REQUEST_PORT(),
|
||||
GET_AUTOCALIBRATION_PORT(),
|
||||
|
@ -477,8 +477,8 @@ void print_configuration()
|
|||
GET_AUTOCALIBRATION_DELAY(),
|
||||
GET_AUTOCALIBRATION_NBPKT(),
|
||||
#endif // USE_PTHREAD
|
||||
BOOL_TO_STRING(GET_VERBOSE()),
|
||||
BOOL_TO_STRING(GET_DISPLAY_CAPTURED())
|
||||
OWL_BOOL_TO_STRING(GET_VERBOSE()),
|
||||
OWL_BOOL_TO_STRING(GET_DISPLAY_CAPTURED())
|
||||
) ;
|
||||
#endif // USE_CONFIG_FILE
|
||||
}
|
||||
|
@ -551,9 +551,9 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
|||
uint16_t rtap_bytes ; // Received data size
|
||||
uint32_t rtap_presentflags ;
|
||||
uint_fast16_t rtap_position ;
|
||||
couple_message couple ; // Message to send to the aggregator
|
||||
owl_captured_request couple ; // Message to send to the aggregator
|
||||
ssize_t nsent ; // sendto return value
|
||||
BOOL check[15] ; // Present flags
|
||||
owl_bool check[15] ; // Present flags
|
||||
uint8_t raw_packet_fc1 ; // First byte of the received frame's FC
|
||||
uint8_t raw_packet_fc2 ; // Second byte of the received frame's FC
|
||||
uint8_t raw_packet_flags ; // IEEE 802.11 header flags
|
||||
|
@ -566,9 +566,9 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
|||
struct udphdr *packet_udp_header = NULL ;
|
||||
// Localisation request type (request, calibration, autocalibration):
|
||||
uint8_t packet_type ;
|
||||
BOOL is_explicit_packet = TRUE ; // Is the packet an explicit request?
|
||||
owl_bool is_explicit_packet = TRUE ; // Is the packet an explicit request?
|
||||
// Is the packet an autocalibration positioning request?
|
||||
BOOL uses_autocalibration_request_port = FALSE ;
|
||||
owl_bool uses_autocalibration_request_port = FALSE ;
|
||||
int i ; // Iterator
|
||||
|
||||
memset(couple.mobile_ip_addr_bytes, 0, 4) ; // Blank the IP
|
||||
|
@ -667,7 +667,7 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
|||
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)) ;
|
||||
memset(&couple.request_time, 0, sizeof(owl_timestamp)) ;
|
||||
// Blank position data:
|
||||
couple.direction = 0 ;
|
||||
couple.x_position = 0 ;
|
||||
|
@ -743,7 +743,7 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
|||
&packet[rtap_bytes + ieee80211_header_size +
|
||||
LLC_HEADER_SIZE + sizeof(struct iphdr) +
|
||||
sizeof(struct udphdr) + 1],
|
||||
sizeof(TIMESTAMP)) ;
|
||||
sizeof(owl_timestamp)) ;
|
||||
}
|
||||
|
||||
else if (GET_MODE() == MODE_PASSIVE || GET_MODE() == MODE_MIXED)
|
||||
|
@ -854,8 +854,8 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
|||
char *mobile_mac_str =
|
||||
owl_mac_bytes_to_string(couple.mobile_mac_addr_bytes) ;
|
||||
char
|
||||
request_time_str[TIMESTAMP_STR_LEN],
|
||||
start_time_str[TIMESTAMP_STR_LEN] ;
|
||||
request_time_str[OWL_TIMESTAMP_STR_LEN],
|
||||
start_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
||||
owl_timestamp_to_string(request_time_str,
|
||||
owl_ntoh_timestamp(couple.request_time)) ;
|
||||
owl_timestamp_to_string(start_time_str,
|
||||
|
@ -962,7 +962,7 @@ void autocalibrate_hello()
|
|||
{
|
||||
int send_sockfd ;
|
||||
struct sockaddr_in serv;
|
||||
autocalibration_hello message ;
|
||||
owl_autocalibration_hello message ;
|
||||
|
||||
if (GET_VERBOSE())
|
||||
fprintf(stderr, "Autocalibration Hello thread launched.\n") ;
|
||||
|
@ -992,7 +992,7 @@ void autocalibrate()
|
|||
struct sockaddr_in client; // UDP client structure
|
||||
socklen_t client_len = sizeof(client) ; // Size of clients
|
||||
int listen_sockfd ;
|
||||
autocalibration_order message ;
|
||||
owl_autocalibration_order message ;
|
||||
|
||||
if (GET_VERBOSE())
|
||||
fprintf(stderr, "Autocalibration thread launched.\n") ;
|
||||
|
@ -1068,20 +1068,20 @@ uint_fast16_t make_packet(uint8_t **packet)
|
|||
{
|
||||
uint8_t *pkt ;
|
||||
uint_fast16_t size ; // Packet size
|
||||
TIMESTAMP request_time ;
|
||||
owl_timestamp request_time ;
|
||||
|
||||
owl_timestamp_now(&request_time) ;
|
||||
|
||||
if (GET_VERBOSE())
|
||||
{
|
||||
char request_time_str[TIMESTAMP_STR_LEN] ;
|
||||
char request_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
||||
owl_timestamp_to_string(request_time_str, request_time) ;
|
||||
printf("Autocalibration time: %s\n", request_time_str) ;
|
||||
}
|
||||
|
||||
request_time = owl_hton_timestamp(request_time) ;
|
||||
|
||||
size = sizeof(char) + sizeof(TIMESTAMP) ;
|
||||
size = sizeof(char) + sizeof(owl_timestamp) ;
|
||||
pkt = malloc(size) ;
|
||||
|
||||
memset(&pkt[0], PACKET_TYPE_AUTOCALIBRATION, 1) ; // Packet type
|
||||
|
|
Loading…
Reference in New Issue