Move all error #defines in owlps.h
This commit is contained in:
parent
7432716a3c
commit
3fec57b1ae
|
@ -29,7 +29,7 @@ int owl_create_trx_socket(const char *const dest_ip,
|
|||
{
|
||||
perror("Error! Cannot create UDP sending socket to the aggregation"
|
||||
" server") ;
|
||||
exit(ERR_CREATING_SOCKET) ;
|
||||
exit(OWL_ERR_SOCKET_CREATE) ;
|
||||
}
|
||||
|
||||
// If we specified an interface name
|
||||
|
@ -110,7 +110,7 @@ void owl_send_packet(const int sockfd,
|
|||
if (nsent != (ssize_t) packet_size)
|
||||
{
|
||||
perror("Error sending data to the aggregation server") ;
|
||||
exit(ERR_SENDING_INFO) ;
|
||||
exit(OWL_ERR_SOCKET_SEND) ;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
|
||||
#include <owlps.h>
|
||||
|
||||
/* Error codes */
|
||||
#define ERR_CREATING_SOCKET 151 // Error when creating output socket
|
||||
#define ERR_SENDING_INFO 152 // Error sending a localisation request
|
||||
|
||||
|
||||
/* Function headers */
|
||||
int owl_create_trx_socket(const char *const dest_ip,
|
||||
|
|
|
@ -173,8 +173,31 @@ typedef struct _owl_autocalibration_order
|
|||
extern owl_bool owl_run ;
|
||||
|
||||
|
||||
/* Function error codes */
|
||||
/* Error codes */
|
||||
/* User interface */
|
||||
// Wrong program invokation (command-line arguments):
|
||||
#define OWL_ERR_BAD_USAGE 100
|
||||
// Error when reading/parsing the configuration file:
|
||||
#define OWL_ERR_CONFIG_FILE 101
|
||||
/* System */
|
||||
// Error when creating a thread:
|
||||
#define OWL_ERR_THREAD_CREATE 110
|
||||
// Wrong signal received:
|
||||
#define OWL_ERR_BAD_SIGNAL 111
|
||||
/* Network communication */
|
||||
// Error when creating a socket:
|
||||
#define OWL_ERR_SOCKET_CREATE 120
|
||||
// Error when sending a message on a socket:
|
||||
#define OWL_ERR_SOCKET_SEND 121
|
||||
// Error when reading from a socket:
|
||||
#define OWL_ERR_SOCKET_RECV 122
|
||||
/* Network interface / capture */
|
||||
// Error when opening the capture interface:
|
||||
#define OWL_ERR_IFACE_PCAP_OPEN 130
|
||||
// Error when reading the interface Wi-Fi mode:
|
||||
#define OWL_ERR_IFACE_MODE_GET 131
|
||||
// Error when setting the interface Wi-Fi mode:
|
||||
#define OWL_ERR_IFACE_MODE_SET 132
|
||||
|
||||
|
||||
/* Function headers */
|
||||
|
|
|
@ -27,15 +27,6 @@
|
|||
#define VERBOSE_REQUESTS cfg_getint(cfg, "verbose") >= 4
|
||||
|
||||
|
||||
/* Error codes */
|
||||
#define ERR_NO_MESSAGE_RECEIVED 1 // Error when reading the socket
|
||||
#define ERR_CREATING_SOCKET 2 // Erreur when creating listening socket
|
||||
#define ERR_BAD_USAGE 3 // Bad program call
|
||||
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file
|
||||
#define ERR_SENDING_INFO 5 // Error sending a message on a socket
|
||||
#define ERR_CREATING_THREAD 6 // Error creating a thread
|
||||
|
||||
|
||||
/* Linked list storing data of each request */
|
||||
typedef struct _request_info_list
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr,
|
||||
"Error! Cannot listen on port %"PRIuFAST16".\n",
|
||||
listening_port) ;
|
||||
ret = ERR_CREATING_SOCKET ;
|
||||
ret = OWL_ERR_SOCKET_CREATE ;
|
||||
goto exit ;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ int main(int argc, char **argv)
|
|||
if (ret != 0)
|
||||
{
|
||||
perror("Cannot create monitor thread") ;
|
||||
ret = ERR_CREATING_THREAD ;
|
||||
ret = OWL_ERR_THREAD_CREATE ;
|
||||
goto exit ;
|
||||
}
|
||||
if (cfg_getbool(cfg, "autocalibration"))
|
||||
|
@ -89,7 +89,7 @@ int main(int argc, char **argv)
|
|||
if (ret != 0)
|
||||
{
|
||||
perror("Cannot create autocalibration hello thread") ;
|
||||
ret = ERR_CREATING_THREAD ;
|
||||
ret = OWL_ERR_THREAD_CREATE ;
|
||||
goto exit ;
|
||||
}
|
||||
ret = pthread_create(&monitor_aps_thread, NULL,
|
||||
|
@ -97,7 +97,7 @@ int main(int argc, char **argv)
|
|||
if (ret != 0)
|
||||
{
|
||||
perror("Cannot create monitor APs thread") ;
|
||||
ret = ERR_CREATING_THREAD ;
|
||||
ret = OWL_ERR_THREAD_CREATE ;
|
||||
goto exit ;
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ int parse_config_file(int argc, char **argv)
|
|||
config_file) ;
|
||||
free(config_file) ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_PARSING_CONFIG_FILE ;
|
||||
return OWL_ERR_CONFIG_FILE ;
|
||||
}
|
||||
free(config_file) ;
|
||||
|
||||
|
@ -342,7 +342,7 @@ int parse_command_line(int argc, char **argv)
|
|||
default :
|
||||
print_usage() ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_BAD_USAGE ;
|
||||
return OWL_ERR_BAD_USAGE ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ int check_configuration()
|
|||
fprintf(stderr, "Error! You must specify an output file.\n") ;
|
||||
print_usage() ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_BAD_USAGE ;
|
||||
return OWL_ERR_BAD_USAGE ;
|
||||
}
|
||||
|
||||
// listening_port //
|
||||
|
@ -388,7 +388,7 @@ int check_configuration()
|
|||
" localisation server.\n") ;
|
||||
print_usage() ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_BAD_USAGE ;
|
||||
return OWL_ERR_BAD_USAGE ;
|
||||
}
|
||||
|
||||
// aggregate_timeout //
|
||||
|
@ -467,7 +467,7 @@ int read_loop(int sockfd)
|
|||
if (owl_run)
|
||||
{
|
||||
perror("No request received from listener") ;
|
||||
ret = ERR_NO_MESSAGE_RECEIVED ;
|
||||
ret = OWL_ERR_SOCKET_RECV ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
|
@ -904,7 +904,7 @@ void* listen_for_aps(void *NULL_value)
|
|||
{
|
||||
perror("Error! Cannot create UDP listening socket from the"
|
||||
" listeners") ;
|
||||
exit(ERR_CREATING_SOCKET) ;
|
||||
exit(OWL_ERR_SOCKET_CREATE) ;
|
||||
}
|
||||
pthread_cleanup_push(&owl_close_fd, &listen_sockfd) ;
|
||||
|
||||
|
@ -1178,7 +1178,7 @@ void order_send(ap_list *ap)
|
|||
if (nsent != (ssize_t) sizeof(message))
|
||||
{
|
||||
perror("Error sending order to the listener") ;
|
||||
exit(ERR_SENDING_INFO) ;
|
||||
exit(OWL_ERR_SOCKET_SEND) ;
|
||||
}
|
||||
|
||||
close(sockfd) ;
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
#include <net/if.h>
|
||||
|
||||
|
||||
/* Error codes */
|
||||
#define ERR_BAD_USAGE 1 // Bad program call (bad number of arguments)
|
||||
|
||||
/* Number of packets to send */
|
||||
#define DEFAULT_NBPKT_CALIB 20 // 20 packets when calibrating
|
||||
#define DEFAULT_NBPKT_NORMAL 10 // 10 packets when requesting the position
|
||||
|
@ -210,7 +207,7 @@ void parse_main_options(int argc, char **argv)
|
|||
exit(0) ;
|
||||
default :
|
||||
print_usage() ;
|
||||
exit(ERR_BAD_USAGE) ;
|
||||
exit(OWL_ERR_BAD_USAGE) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,7 +222,7 @@ void check_destination_ip()
|
|||
fprintf(stderr, "Error! You must specify a destination IP address"
|
||||
" (-d).\n") ;
|
||||
print_usage() ;
|
||||
exit(ERR_BAD_USAGE) ;
|
||||
exit(OWL_ERR_BAD_USAGE) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +244,7 @@ void parse_calibration_data(int argc, char **argv)
|
|||
else // Bad number of arguments
|
||||
{
|
||||
print_usage() ;
|
||||
exit(ERR_BAD_USAGE) ;
|
||||
exit(OWL_ERR_BAD_USAGE) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +286,7 @@ void check_configuration()
|
|||
{
|
||||
fprintf(stderr, "Error! « %"PRIu8" » is not a valid"
|
||||
" direction.\n", options.direction) ;
|
||||
exit(ERR_BAD_USAGE) ;
|
||||
exit(OWL_ERR_BAD_USAGE) ;
|
||||
}
|
||||
|
||||
// Check port numbers
|
||||
|
|
|
@ -154,15 +154,6 @@ enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
|
|||
//#define RTAP_EXT 31
|
||||
|
||||
|
||||
/* Error codes */
|
||||
#define ERR_OPENING_IFACE 2 // Error when opening capture interface
|
||||
#define ERR_BAD_USAGE 3 // Bad program call
|
||||
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file
|
||||
#define ERR_CREATING_THREAD 6 // Error creating a thread
|
||||
#define ERR_SETTING_MODE 101
|
||||
#define ERR_READING_MODE 104
|
||||
|
||||
|
||||
/* Function headers */
|
||||
int initialise_configuration(int argc, char **argv) ;
|
||||
int parse_config_file(int argc, char **argv) ;
|
||||
|
|
|
@ -152,7 +152,7 @@ int main(int argc, char *argv[])
|
|||
if (ret != 0)
|
||||
{
|
||||
perror("Cannot create keep monitor thread") ;
|
||||
ret = ERR_CREATING_THREAD ;
|
||||
ret = OWL_ERR_THREAD_CREATE ;
|
||||
goto exit ;
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ int main(int argc, char *argv[])
|
|||
if (ret != 0)
|
||||
{
|
||||
perror("Cannot create autocalibration thread") ;
|
||||
ret = ERR_CREATING_THREAD ;
|
||||
ret = OWL_ERR_THREAD_CREATE ;
|
||||
goto exit ;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ int main(int argc, char *argv[])
|
|||
if (ret != 0)
|
||||
{
|
||||
perror("Cannot create autocalibration hello thread") ;
|
||||
ret = ERR_CREATING_THREAD ;
|
||||
ret = OWL_ERR_THREAD_CREATE ;
|
||||
goto exit ;
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ int parse_config_file(int argc, char **argv)
|
|||
config_file) ;
|
||||
free(config_file) ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_PARSING_CONFIG_FILE ;
|
||||
return OWL_ERR_CONFIG_FILE ;
|
||||
}
|
||||
free(config_file) ;
|
||||
#endif // USE_CONFIG_FILE
|
||||
|
@ -522,7 +522,7 @@ int parse_main_options(int argc, char **argv)
|
|||
default :
|
||||
print_usage() ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_BAD_USAGE ;
|
||||
return OWL_ERR_BAD_USAGE ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -549,7 +549,7 @@ int parse_calibration_data(int argc, char **argv)
|
|||
{
|
||||
print_usage() ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_BAD_USAGE ;
|
||||
return OWL_ERR_BAD_USAGE ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -571,7 +571,7 @@ int check_configuration()
|
|||
fprintf(stderr, "Error! Unknown mode « %c ».\n", (char) GET_MODE()) ;
|
||||
print_usage() ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_BAD_USAGE ;
|
||||
return OWL_ERR_BAD_USAGE ;
|
||||
}
|
||||
|
||||
if (GET_RTAP_IFACE()[0] == '\0')
|
||||
|
@ -580,7 +580,7 @@ int check_configuration()
|
|||
" for the capture.\n") ;
|
||||
print_usage() ;
|
||||
owl_run = owl_false ;
|
||||
return ERR_BAD_USAGE ;
|
||||
return OWL_ERR_BAD_USAGE ;
|
||||
}
|
||||
|
||||
if (GET_WIFI_IFACE()[0] == '\0')
|
||||
|
@ -749,7 +749,7 @@ int iface_mode_monitor(const char *const iface)
|
|||
if (ioctl(sockfd, SIOCGIWMODE, &wrq) == -1) // Get current mode
|
||||
{
|
||||
perror("Error reading interface mode") ;
|
||||
return ERR_READING_MODE ;
|
||||
return OWL_ERR_IFACE_MODE_GET ;
|
||||
}
|
||||
|
||||
// If interface is not yet in Monitor mode
|
||||
|
@ -759,7 +759,7 @@ int iface_mode_monitor(const char *const iface)
|
|||
if (ioctl(sockfd, SIOCSIWMODE, &wrq) == -1) // Set up Monitor mode
|
||||
{
|
||||
perror("Error setting up Monitor mode") ;
|
||||
return ERR_SETTING_MODE ;
|
||||
return OWL_ERR_IFACE_MODE_SET ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -785,7 +785,7 @@ int capture()
|
|||
if (capture_handler == NULL) // Capture starting failed
|
||||
{
|
||||
fprintf(stderr, "Cannot open capture interface %s\n", errbuf) ;
|
||||
return ERR_OPENING_IFACE ;
|
||||
return OWL_ERR_IFACE_PCAP_OPEN ;
|
||||
}
|
||||
|
||||
/* Open UDP socket to the aggregator */
|
||||
|
@ -1302,7 +1302,7 @@ void* autocalibrate(void *NULL_value)
|
|||
{
|
||||
perror("Error! Cannot create UDP listening socket from the"
|
||||
" aggregation server") ;
|
||||
exit(ERR_CREATING_SOCKET) ;
|
||||
exit(OWL_ERR_SOCKET_CREATE) ;
|
||||
}
|
||||
pthread_cleanup_push(&owl_close_fd, &listen_sockfd) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue