[lib-client] Change function prefix (owlclient_)

Change the function prefix from "owlps_" to "owlclient_".
This commit is contained in:
Matteo Cypriani 2011-03-11 10:24:33 +01:00
parent 7c80f17b0b
commit 0045ba8a14
4 changed files with 46 additions and 44 deletions

View File

@ -12,10 +12,10 @@
* 'iface' if specified (if you want the interface to be selected, * 'iface' if specified (if you want the interface to be selected,
* automatically, this parameter should be NULL or an empty string). * automatically, this parameter should be NULL or an empty string).
*/ */
int owlps_create_socket_to_aggregator(char *dest_ip, int owlclient_create_socket_to_aggregator(char *dest_ip,
uint_fast16_t dest_port, uint_fast16_t dest_port,
struct sockaddr_in *server, struct sockaddr_in *server,
char *iface) char *iface)
{ {
struct sockaddr_in client ; struct sockaddr_in client ;
@ -28,9 +28,9 @@ int owlps_create_socket_to_aggregator(char *dest_ip,
exit(ERR_CREATING_SOCKET) ; exit(ERR_CREATING_SOCKET) ;
} }
// If we specified an interface name // If we specified an interface name
if (iface != NULL && iface[0] != '\0') if (iface != NULL && iface[0] != '\0')
owlps_use_iface(sockfd, iface) ; owlclient_use_iface(sockfd, iface) ;
return sockfd ; return sockfd ;
} }
@ -38,7 +38,7 @@ int owlps_create_socket_to_aggregator(char *dest_ip,
/* Selects 'iface' as sending interface for the socket 'sockfd'. */ /* Selects 'iface' as sending interface for the socket 'sockfd'. */
void owlps_use_iface(int sockfd, char *iface) void owlclient_use_iface(int sockfd, char *iface)
{ {
if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, iface, if (setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE, iface,
strlen(iface) + 1) == -1) strlen(iface) + 1) == -1)
@ -52,9 +52,9 @@ void owlps_use_iface(int sockfd, char *iface)
void owlps_send_request(int sockfd, struct sockaddr_in *server, void owlclient_send_request(int sockfd, struct sockaddr_in *server,
void *packet, uint_fast16_t packet_size, void *packet, uint_fast16_t packet_size,
uint_fast16_t nb_pkt, uint_fast32_t delay) uint_fast16_t nb_pkt, uint_fast32_t delay)
{ {
uint_fast16_t i ; uint_fast16_t i ;
@ -63,13 +63,13 @@ void owlps_send_request(int sockfd, struct sockaddr_in *server,
#endif // DEBUG #endif // DEBUG
// Transmit first packet: // Transmit first packet:
owlps_send_packet(sockfd, server, packet, packet_size) ; owlclient_send_packet(sockfd, server, packet, packet_size) ;
// Transmit remaining packets (if any): // Transmit remaining packets (if any):
for (i = 0 ; i < nb_pkt - 1 ; ++i) for (i = 0 ; i < nb_pkt - 1 ; ++i)
{ {
usleep(delay) ; // Wait during the wanted delay usleep(delay) ; // Wait during the wanted delay
owlps_send_packet(sockfd, server, packet, packet_size) ; owlclient_send_packet(sockfd, server, packet, packet_size) ;
} }
#ifdef DEBUG #ifdef DEBUG
@ -79,8 +79,8 @@ void owlps_send_request(int sockfd, struct sockaddr_in *server,
void owlps_send_packet(int sockfd, struct sockaddr_in *server, void owlclient_send_packet(int sockfd, struct sockaddr_in *server,
void *packet, uint_fast16_t packet_size) void *packet, uint_fast16_t packet_size)
{ {
ssize_t nsent = sendto(sockfd, packet, packet_size, 0, ssize_t nsent = sendto(sockfd, packet, packet_size, 0,
(struct sockaddr *) server, (struct sockaddr *) server,

View File

@ -14,16 +14,16 @@
/* Function headers */ /* Function headers */
int owlps_create_socket_to_aggregator(char *dest_ip, int owlclient_create_socket_to_aggregator(char *dest_ip,
uint_fast16_t dest_port, uint_fast16_t dest_port,
struct sockaddr_in *server, struct sockaddr_in *server,
char *iface) ; char *iface) ;
void owlps_use_iface(int sockfd, char *iface) ; void owlclient_use_iface(int sockfd, char *iface) ;
void owlps_send_request(int sockfd, struct sockaddr_in *server, void owlclient_send_request(int sockfd, struct sockaddr_in *server,
void *packet, uint_fast16_t packet_size, void *packet, uint_fast16_t packet_size,
uint_fast16_t nb_pkt, uint_fast32_t delay) ; uint_fast16_t nb_pkt, uint_fast32_t delay) ;
void owlps_send_packet(int sockfd, struct sockaddr_in *server, void owlclient_send_packet(int sockfd, struct sockaddr_in *server,
void *packet, uint_fast16_t packet_size) ; void *packet, uint_fast16_t packet_size) ;
#endif // _LIBOWLPS_CLIENT_ #endif // _LIBOWLPS_CLIENT_

View File

@ -275,8 +275,9 @@ void print_configuration()
void create_socket() void create_socket()
{ {
sockfd = sockfd =
owlps_create_socket_to_aggregator(options.dest_ip, options.dest_port, owlclient_create_socket_to_aggregator(options.dest_ip,
&server, options.iface) ; options.dest_port,
&server, options.iface) ;
} }
@ -330,8 +331,8 @@ void make_packet()
void send_request() void send_request()
{ {
owlps_send_request(sockfd, &server, packet, packet_size, owlclient_send_request(sockfd, &server, packet, packet_size,
options.nb_pkt, options.delay) ; options.nb_pkt, options.delay) ;
} }

View File

@ -492,9 +492,9 @@ int capture()
/* Open UDP socket to the aggregator */ /* Open UDP socket to the aggregator */
aggregation_sockfd = aggregation_sockfd =
owlps_create_socket_to_aggregator(GET_AGGREGATION_IP(), owlclient_create_socket_to_aggregator(GET_AGGREGATION_IP(),
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:
@ -922,15 +922,16 @@ void autocalibrate_hello()
fprintf(stderr, "Autocalibration Hello thread launched.\n") ; fprintf(stderr, "Autocalibration Hello thread launched.\n") ;
send_sockfd = send_sockfd =
owlps_create_socket_to_aggregator(GET_AGGREGATION_IP(), owlclient_create_socket_to_aggregator(GET_AGGREGATION_IP(),
GET_AUTOCALIBRATION_PORT(), GET_AUTOCALIBRATION_PORT(),
&serv, NULL) ; &serv, NULL) ;
memcpy(&message.ap_mac_addr_bytes, my_mac_bytes, 6) ; memcpy(&message.ap_mac_addr_bytes, my_mac_bytes, 6) ;
while (run) while (run)
{ {
owlps_send_packet(send_sockfd, &serv, &message, sizeof(message)) ; owlclient_send_packet(send_sockfd, &serv,
&message, sizeof(message)) ;
sleep(GET_AUTOCALIBRATION_HELLO_DELAY()) ; sleep(GET_AUTOCALIBRATION_HELLO_DELAY()) ;
} }
@ -952,10 +953,10 @@ void autocalibrate()
// Socket to send autocalibration positioning requests // Socket to send autocalibration positioning requests
autocalibration_send_sockfd = autocalibration_send_sockfd =
owlps_create_socket_to_aggregator(GET_AUTOCALIBRATION_IP(), owlclient_create_socket_to_aggregator(GET_AUTOCALIBRATION_IP(),
GET_AUTOCALIBRATION_REQUEST_PORT(), GET_AUTOCALIBRATION_REQUEST_PORT(),
&autocalibration_send_server, &autocalibration_send_server,
GET_WIFI_IFACE()) ; GET_WIFI_IFACE()) ;
// Socket to receive orders from the aggregator // Socket to receive orders from the aggregator
listen_sockfd = listen_sockfd =
@ -1001,11 +1002,11 @@ void send_autocalibration_request()
uint8_t *packet ; uint8_t *packet ;
uint_fast16_t packet_size = make_packet(&packet) ; uint_fast16_t packet_size = make_packet(&packet) ;
owlps_send_request(autocalibration_send_sockfd, owlclient_send_request(autocalibration_send_sockfd,
&autocalibration_send_server, &autocalibration_send_server,
packet, packet_size, packet, packet_size,
GET_AUTOCALIBRATION_NBPKT(), GET_AUTOCALIBRATION_NBPKT(),
GET_AUTOCALIBRATION_DELAY()) ; GET_AUTOCALIBRATION_DELAY()) ;
free(packet) ; free(packet) ;
} }