[Aggregator] Get rid of ip_bytes_to_string()
Use inet_ntop() instead of ip_bytes_to_string(). Delete ip_bytes_to_string().
This commit is contained in:
parent
457515faf8
commit
fd4b51aeff
1
TODO
1
TODO
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
* Aggregator
|
* Aggregator
|
||||||
|
|
||||||
- Use inet_ntoa() instead of ip_bytes_to_string().
|
|
||||||
- Use locks to read/write the AP list
|
- Use locks to read/write the AP list
|
||||||
Currently, several threads can access the list simultaneously, and
|
Currently, several threads can access the list simultaneously, and
|
||||||
that's not cool!
|
that's not cool!
|
||||||
|
|
|
@ -112,7 +112,6 @@ void unlink_ap(ap_list *ap) ;
|
||||||
void order_send(ap_list *ap) ;
|
void order_send(ap_list *ap) ;
|
||||||
void free_ap_list(void) ;
|
void free_ap_list(void) ;
|
||||||
|
|
||||||
char* ip_bytes_to_string(uint8_t ip_binary[4]) ;
|
|
||||||
void print_usage(void) ;
|
void print_usage(void) ;
|
||||||
|
|
||||||
#endif // _OWLPS_AGGREGATOR_H_
|
#endif // _OWLPS_AGGREGATOR_H_
|
||||||
|
|
|
@ -384,7 +384,7 @@ int read_loop(int sockfd)
|
||||||
char
|
char
|
||||||
*ap_mac_str, // Return pointers for owl_mac_bytes_to_string(),
|
*ap_mac_str, // Return pointers for owl_mac_bytes_to_string(),
|
||||||
*mobile_mac_str,
|
*mobile_mac_str,
|
||||||
*mobile_ip_str, // ip_bytes_to_string(),
|
mobile_ip_str[INET_ADDRSTRLEN], // inet_ntop()
|
||||||
// and owl_timestamp_to_string():
|
// and owl_timestamp_to_string():
|
||||||
request_time_str[OWL_TIMESTAMP_STR_LEN],
|
request_time_str[OWL_TIMESTAMP_STR_LEN],
|
||||||
start_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
start_time_str[OWL_TIMESTAMP_STR_LEN] ;
|
||||||
|
@ -414,8 +414,8 @@ int read_loop(int sockfd)
|
||||||
owl_mac_bytes_to_string(request.ap_mac_addr_bytes) ;
|
owl_mac_bytes_to_string(request.ap_mac_addr_bytes) ;
|
||||||
mobile_mac_str =
|
mobile_mac_str =
|
||||||
owl_mac_bytes_to_string(request.mobile_mac_addr_bytes) ;
|
owl_mac_bytes_to_string(request.mobile_mac_addr_bytes) ;
|
||||||
mobile_ip_str =
|
inet_ntop(AF_INET, &request.mobile_ip_addr_bytes,
|
||||||
ip_bytes_to_string(request.mobile_ip_addr_bytes) ;
|
mobile_ip_str, INET_ADDRSTRLEN) ;
|
||||||
owl_timestamp_to_string(request_time_str,
|
owl_timestamp_to_string(request_time_str,
|
||||||
request.request_time) ;
|
request.request_time) ;
|
||||||
owl_timestamp_to_string(start_time_str, request.start_time) ;
|
owl_timestamp_to_string(start_time_str, request.start_time) ;
|
||||||
|
@ -445,7 +445,6 @@ int read_loop(int sockfd)
|
||||||
) ;
|
) ;
|
||||||
free(ap_mac_str) ;
|
free(ap_mac_str) ;
|
||||||
free(mobile_mac_str) ;
|
free(mobile_mac_str) ;
|
||||||
free(mobile_ip_str) ;
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
else
|
else
|
||||||
|
@ -1198,36 +1197,6 @@ void print_request_info(request_info_list *info)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Converts an IP address from bytes to string.
|
|
||||||
* /!\ You *must* manually free the returned string /!\
|
|
||||||
*/
|
|
||||||
char* ip_bytes_to_string(uint8_t ip_binary[4])
|
|
||||||
{
|
|
||||||
int_fast8_t
|
|
||||||
size = 16,
|
|
||||||
i = 0 ;
|
|
||||||
|
|
||||||
for (i = 0 ; i < 4 ; ++i)
|
|
||||||
{
|
|
||||||
if (ip_binary[i] < 0x64)
|
|
||||||
size-- ;
|
|
||||||
if (ip_binary[i] < 0x10)
|
|
||||||
size-- ;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *ret = malloc(sizeof(char) * size) ;
|
|
||||||
|
|
||||||
sprintf(ret, "%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8,
|
|
||||||
ip_binary[0], ip_binary[1],
|
|
||||||
ip_binary[2], ip_binary[3]) ;
|
|
||||||
ret[size-1] = '\0' ;
|
|
||||||
|
|
||||||
return ret ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void print_usage()
|
void print_usage()
|
||||||
{
|
{
|
||||||
printf("Usage:\n"
|
printf("Usage:\n"
|
||||||
|
|
Loading…
Reference in New Issue