Mark arguments as const as needed in C programs
This was already done in the libraries, but not in the programs.
This commit is contained in:
parent
ef2b4e9e58
commit
69e8b49300
5
TODO.t2t
5
TODO.t2t
|
@ -47,9 +47,8 @@ Work to do in OwlPS
|
|||
|
||||
- Mark arguments as const in function headers if needed
|
||||
|
||||
Mostly done in the Positioner C++ code (which should nonetheless be
|
||||
checked), but not constantly in C modules.
|
||||
//Done in lib*.//
|
||||
Mostly done in the Positioner C++ code (to be checked).
|
||||
//Done in lib* and other C modules.//
|
||||
|
||||
- Use struct ether_addr to store MAC addresses?
|
||||
|
||||
|
|
|
@ -474,7 +474,7 @@ void owl_algorithm_result_to_csv_simple
|
|||
* Prints an `owl_result` to the given stream, using `fprintf()`.
|
||||
* `src` must not be `NULL`.
|
||||
*/
|
||||
void owl_fprint_result(FILE *stream, const owl_result *const src)
|
||||
void owl_fprint_result(FILE *const stream, const owl_result *const src)
|
||||
{
|
||||
char timestamp_str[OWL_TIMESTAMP_STRLEN] ;
|
||||
|
||||
|
@ -506,7 +506,7 @@ void owl_fprint_result(FILE *stream, const owl_result *const src)
|
|||
* `fprintf()`.
|
||||
* `src` must not be `NULL`.
|
||||
*/
|
||||
void owl_fprint_algorithm_result(FILE *stream,
|
||||
void owl_fprint_algorithm_result(FILE *const stream,
|
||||
const owl_algorithm_result *const src)
|
||||
{
|
||||
assert(src) ;
|
||||
|
|
|
@ -135,9 +135,9 @@ void owl_algorithm_result_to_csv_simple
|
|||
const owl_algorithm_result *const src) ;
|
||||
|
||||
/// Prints an `owl_result` to the given stream
|
||||
void owl_fprint_result(FILE *stream, const owl_result *const src) ;
|
||||
void owl_fprint_result(FILE *const stream, const owl_result *const src) ;
|
||||
/// Prints an `owl_algorithm_result` to the given stream
|
||||
void owl_fprint_algorithm_result(FILE *stream,
|
||||
void owl_fprint_algorithm_result(FILE *const stream,
|
||||
const owl_algorithm_result *const src) ;
|
||||
/// Prints an `owl_result` to the standard output
|
||||
#define owl_print_result(SRC) \
|
||||
|
|
|
@ -102,19 +102,19 @@ typedef struct _cp_list
|
|||
|
||||
|
||||
/* Function headers */
|
||||
int initialise_configuration(int argc, char **argv) ;
|
||||
int parse_config_file(int argc, char **argv) ;
|
||||
int parse_command_line(int argc, char **argv) ;
|
||||
int initialise_configuration(const int argc, char *const *argv) ;
|
||||
int parse_config_file(const int argc, char *const *argv) ;
|
||||
int parse_command_line(const int argc, char *const *argv) ;
|
||||
int check_configuration(void) ;
|
||||
|
||||
int read_loop(int sockfd) ;
|
||||
int read_loop(const int sockfd) ;
|
||||
void print_captured_request(const owl_captured_request *const request) ;
|
||||
void got_request(const owl_captured_request *const request) ;
|
||||
void add_captured_request(const owl_timestamp *const reception_time,
|
||||
const owl_captured_request *const request,
|
||||
request_info_list *const request_info) ;
|
||||
|
||||
void* monitor_requests(void *NULL_value) ;
|
||||
void* monitor_requests(void *const NULL_value) ;
|
||||
void scan_request_list(FILE *const stream,
|
||||
const int sockfd,
|
||||
const struct sockaddr *const serv) ;
|
||||
|
@ -128,23 +128,24 @@ void output_request(request_list *const request_ptr,
|
|||
|
||||
#ifndef NDEBUG
|
||||
void print_request_list(void) ;
|
||||
void print_request_info(request_info_list *info) ;
|
||||
void print_request_info(const request_info_list *const info) ;
|
||||
#endif // NDEBUG
|
||||
|
||||
void* listen_for_cps(void *NULL_value) ;
|
||||
void update_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN],
|
||||
char ip_addr[INET_ADDRSTRLEN]) ;
|
||||
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* listen_for_cps(void *const NULL_value) ;
|
||||
void update_cp(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN],
|
||||
const char ip_addr[INET_ADDRSTRLEN]) ;
|
||||
cp_list* find_cp(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ;
|
||||
cp_list* add_cp_front(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ;
|
||||
void update_cp_ip_addr(cp_list *const cp,
|
||||
const char ip_addr[INET_ADDRSTRLEN]) ;
|
||||
void update_cp_seen(cp_list *const cp) ;
|
||||
void push_cp(cp_list *const cp) ;
|
||||
|
||||
void* monitor_cps(void *NULL_value) ;
|
||||
void* monitor_cps(void *const 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 delete_cp(cp_list *const cp) ;
|
||||
void unlink_cp(const cp_list *const cp) ;
|
||||
void order_send(const cp_list *const cp) ;
|
||||
void free_cp_list(void) ;
|
||||
|
||||
void print_usage(void) ;
|
||||
|
|
|
@ -55,7 +55,7 @@ sem_t lock_cps ; // Semaphore to get access to the CPs' ring
|
|||
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(const int argc, char *const *argv)
|
||||
{
|
||||
int ret = 0 ; // Program return value
|
||||
struct sigaction action ; // Signal handler structure
|
||||
|
@ -199,7 +199,7 @@ int main(int argc, char **argv)
|
|||
* stop (because of a special option or a configuration error), owl_run
|
||||
* is set to false.
|
||||
*/
|
||||
int initialise_configuration(int argc, char **argv)
|
||||
int initialise_configuration(const int argc, char *const *argv)
|
||||
{
|
||||
int ret ;
|
||||
|
||||
|
@ -234,7 +234,7 @@ int initialise_configuration(int argc, char **argv)
|
|||
}
|
||||
|
||||
|
||||
int parse_config_file(int argc, char **argv)
|
||||
int parse_config_file(const int argc, char *const *argv)
|
||||
{
|
||||
// Config file options for confuse
|
||||
cfg_opt_t opts[] =
|
||||
|
@ -360,7 +360,7 @@ int parse_config_file(int argc, char **argv)
|
|||
}
|
||||
|
||||
|
||||
int parse_command_line(int argc, char **argv)
|
||||
int parse_command_line(const int argc, char *const *argv)
|
||||
{
|
||||
int opt ;
|
||||
long arg_long ; // Integer value of optarg
|
||||
|
@ -563,7 +563,7 @@ int check_configuration()
|
|||
/*
|
||||
* Reads packets while the program is not stopped.
|
||||
*/
|
||||
int read_loop(int sockfd)
|
||||
int read_loop(const int sockfd)
|
||||
{
|
||||
int ret = 0 ; // Return value
|
||||
ssize_t nread ; // recvfrom return value
|
||||
|
@ -849,7 +849,7 @@ void add_captured_request(const owl_timestamp *const reception_time,
|
|||
* Thread function. Monitors the list and prints/sends information to the
|
||||
* localisation server when the timeout is reached.
|
||||
*/
|
||||
void* monitor_requests(void *NULL_value)
|
||||
void* monitor_requests(void *const NULL_value)
|
||||
{
|
||||
FILE *stream = NULL ;
|
||||
struct sockaddr serv;
|
||||
|
@ -1180,7 +1180,7 @@ void print_request_list()
|
|||
/*
|
||||
* Prints an element of a request_info_list.
|
||||
*/
|
||||
void print_request_info(request_info_list *info)
|
||||
void print_request_info(const request_info_list *const info)
|
||||
{
|
||||
char cp_mac_str[OWL_ETHER_ADDR_STRLEN] ;
|
||||
if (info == NULL)
|
||||
|
@ -1201,7 +1201,7 @@ void print_request_info(request_info_list *info)
|
|||
/*
|
||||
* Thread function. Listens for hello messages from CPs.
|
||||
*/
|
||||
void* listen_for_cps(void *NULL_value)
|
||||
void* listen_for_cps(void *const NULL_value)
|
||||
{
|
||||
int listen_sockfd ;
|
||||
int nread ; // recvfrom return value
|
||||
|
@ -1258,8 +1258,8 @@ void* listen_for_cps(void *NULL_value)
|
|||
* 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_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN],
|
||||
char ip_addr[INET_ADDRSTRLEN])
|
||||
void update_cp(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN],
|
||||
const char ip_addr[INET_ADDRSTRLEN])
|
||||
{
|
||||
cp_list *found ;
|
||||
|
||||
|
@ -1279,7 +1279,7 @@ void update_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN],
|
|||
* Searches the CP list for a CP with the given MAC address and returns
|
||||
* it.
|
||||
*/
|
||||
cp_list* find_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN])
|
||||
cp_list* find_cp(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN])
|
||||
{
|
||||
cp_list *found ;
|
||||
|
||||
|
@ -1303,7 +1303,7 @@ cp_list* find_cp(uint8_t mac_addr_bytes[ETHER_ADDR_LEN])
|
|||
* Adds a new CP in front of the CP list.
|
||||
* Returns the new list head, or NULL in case of error.
|
||||
*/
|
||||
cp_list* add_cp_front(uint8_t mac_addr_bytes[ETHER_ADDR_LEN])
|
||||
cp_list* add_cp_front(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN])
|
||||
{
|
||||
if (VERBOSE_INFO)
|
||||
{
|
||||
|
@ -1330,7 +1330,8 @@ cp_list* add_cp_front(uint8_t mac_addr_bytes[ETHER_ADDR_LEN])
|
|||
/*
|
||||
* Change the IP address of the CP 'cp' with 'ip_addr'.
|
||||
*/
|
||||
void update_cp_ip_addr(cp_list *cp, char ip_addr[INET_ADDRSTRLEN])
|
||||
void update_cp_ip_addr(cp_list *const cp,
|
||||
const char ip_addr[INET_ADDRSTRLEN])
|
||||
{
|
||||
strncpy(cp->ip_addr, ip_addr, INET_ADDRSTRLEN) ;
|
||||
}
|
||||
|
@ -1339,7 +1340,7 @@ void update_cp_ip_addr(cp_list *cp, char ip_addr[INET_ADDRSTRLEN])
|
|||
/*
|
||||
* Updates the timestamp of the given CP.
|
||||
*/
|
||||
void update_cp_seen(cp_list *cp)
|
||||
void update_cp_seen(cp_list *const cp)
|
||||
{
|
||||
assert(cp) ;
|
||||
owl_timestamp_now(&cp->last_seen) ;
|
||||
|
@ -1350,7 +1351,7 @@ void update_cp_seen(cp_list *cp)
|
|||
* Puts an existing CP in front of the CP list. The CP must not be in
|
||||
* the list yet.
|
||||
*/
|
||||
void push_cp(cp_list *cp)
|
||||
void push_cp(cp_list *const cp)
|
||||
{
|
||||
assert(cp) ;
|
||||
|
||||
|
@ -1377,7 +1378,7 @@ void push_cp(cp_list *cp)
|
|||
* Monitors the CP list: sends orders to CPs following their order in
|
||||
* the list, and deletes old CPs.
|
||||
*/
|
||||
void* monitor_cps(void *NULL_value)
|
||||
void* monitor_cps(void *const NULL_value)
|
||||
{
|
||||
if (VERBOSE_WARNING)
|
||||
fprintf(stderr, "Monitor CP thread launched.\n") ;
|
||||
|
@ -1429,7 +1430,7 @@ void delete_old_cps()
|
|||
/*
|
||||
* Deletes the given CP from the CP list.
|
||||
*/
|
||||
void delete_cp(cp_list *cp)
|
||||
void delete_cp(cp_list *const cp)
|
||||
{
|
||||
if (VERBOSE_INFO)
|
||||
{
|
||||
|
@ -1448,7 +1449,7 @@ void delete_cp(cp_list *cp)
|
|||
* Extracts the given CP from the CP list (it will not be linked to any
|
||||
* other element of the list).
|
||||
*/
|
||||
void unlink_cp(cp_list *cp)
|
||||
void unlink_cp(const cp_list *const cp)
|
||||
{
|
||||
cp_list
|
||||
*cp_previous,
|
||||
|
@ -1478,7 +1479,7 @@ void unlink_cp(cp_list *cp)
|
|||
/*
|
||||
* Sends a 'send' order to the given CP.
|
||||
*/
|
||||
void order_send(cp_list *cp)
|
||||
void order_send(const cp_list *const cp)
|
||||
{
|
||||
owl_autocalibration_order message ;
|
||||
struct sockaddr serv;
|
||||
|
|
|
@ -55,17 +55,17 @@
|
|||
|
||||
|
||||
/* Function headers */
|
||||
void parse_command_line(int argc, char **argv) ;
|
||||
void parse_main_options(int argc, char **argv) ;
|
||||
void parse_command_line(const int argc, char *const *argv) ;
|
||||
void parse_main_options(const int argc, char *const *argv) ;
|
||||
void check_destination_host(void) ;
|
||||
void parse_calibration_data(int argc, char **argv) ;
|
||||
void parse_calibration_data(const int argc, char *const *argv) ;
|
||||
void check_configuration(void) ;
|
||||
void print_configuration(void) ;
|
||||
void create_socket(void) ;
|
||||
void send_request(void) ;
|
||||
void make_packet(void) ;
|
||||
void add_padding(void) ;
|
||||
uint_fast16_t initialise_common_fields(uint_fast8_t packet_type) ;
|
||||
uint_fast16_t initialise_common_fields(const uint_fast8_t packet_type) ;
|
||||
uint_fast16_t initialise_calibration_fields(uint_fast16_t offset) ;
|
||||
#ifdef OWLPS_CLIENT_RECEIVES_POSITION
|
||||
int receive_position(void) ;
|
||||
|
@ -209,7 +209,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
|
||||
|
||||
void parse_command_line(int argc, char **argv)
|
||||
void parse_command_line(const int argc, char *const *argv)
|
||||
{
|
||||
parse_main_options(argc, argv) ;
|
||||
check_destination_host() ;
|
||||
|
@ -222,7 +222,7 @@ void parse_command_line(int argc, char **argv)
|
|||
|
||||
|
||||
|
||||
void parse_main_options(int argc, char **argv)
|
||||
void parse_main_options(const int argc, char *const *argv)
|
||||
{
|
||||
int opt ;
|
||||
long arg_long ; // Integer value of optarg
|
||||
|
@ -390,7 +390,7 @@ void check_destination_host()
|
|||
|
||||
|
||||
/* Parses remaining arguments (possible calibration data) */
|
||||
void parse_calibration_data(int argc, char **argv)
|
||||
void parse_calibration_data(const int argc, char *const *argv)
|
||||
{
|
||||
/* No more arguments to parse */
|
||||
if (argc - optind == 0)
|
||||
|
@ -679,7 +679,7 @@ void add_padding()
|
|||
/*
|
||||
* Initialises the fields of a normal positioning request.
|
||||
*/
|
||||
uint_fast16_t initialise_common_fields(uint_fast8_t packet_type)
|
||||
uint_fast16_t initialise_common_fields(const uint_fast8_t packet_type)
|
||||
{
|
||||
uint_fast16_t offset = 0 ;
|
||||
uint16_t npkt ;
|
||||
|
|
|
@ -171,45 +171,46 @@ enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
|
|||
|
||||
|
||||
/* Function headers */
|
||||
int initialise_configuration(int argc, char **argv) ;
|
||||
int parse_config_file(int argc, char **argv) ;
|
||||
int parse_command_line(int argc, char **argv) ;
|
||||
int parse_main_options(int argc, char **argv) ;
|
||||
int initialise_configuration(const int argc, char *const *argv) ;
|
||||
int parse_config_file(const int argc, char *const *argv) ;
|
||||
int parse_command_line(const int argc, char *const *argv) ;
|
||||
int parse_main_options(const int argc, char *const *argv) ;
|
||||
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
||||
int parse_calibration_data(int argc, char **argv) ;
|
||||
int parse_calibration_data(const int argc, char *const *argv) ;
|
||||
#endif // OWLPS_LISTENER_USES_PTHREAD
|
||||
int check_configuration(void) ;
|
||||
void print_configuration(FILE *stream) ;
|
||||
void print_configuration(FILE *const stream) ;
|
||||
|
||||
#ifdef OWLPS_LISTENER_KEEPS_MONITOR
|
||||
void* keep_mode_monitor(void *iface) ;
|
||||
void* keep_mode_monitor(const void *const iface) ;
|
||||
int iface_mode_monitor(const char *const iface) ;
|
||||
#endif // OWLPS_LISTENER_KEEPS_MONITOR
|
||||
int capture(void) ;
|
||||
void read_packet(const struct pcap_pkthdr *pkt_header,
|
||||
const u_char *pkt_data) ;
|
||||
void extract_calibration_data(const u_char *pkt_data,
|
||||
owl_captured_request *request) ;
|
||||
void extract_packet_numbers(const u_char *pkt_data,
|
||||
owl_captured_request *request) ;
|
||||
bool extract_radiotap_ss(const u_char *pkt_data,
|
||||
owl_captured_request *request) ;
|
||||
uint_fast16_t nat_align(uint_fast16_t offset, uint_fast8_t field_len) ;
|
||||
void display_captured_request(owl_captured_request *request,
|
||||
const struct pcap_pkthdr *pkt_header) ;
|
||||
void read_packet(const struct pcap_pkthdr *const pkt_header,
|
||||
const u_char *const pkt_data) ;
|
||||
void extract_calibration_data(const u_char *const pkt_data,
|
||||
owl_captured_request *const request) ;
|
||||
void extract_packet_numbers(const u_char *const pkt_data,
|
||||
owl_captured_request *const request) ;
|
||||
bool extract_radiotap_ss(const u_char *const pkt_data,
|
||||
owl_captured_request *const request) ;
|
||||
uint_fast16_t nat_align(const uint_fast16_t offset,
|
||||
const uint_fast8_t field_len) ;
|
||||
void display_captured_request(const owl_captured_request *const request,
|
||||
const struct pcap_pkthdr *const pkt_header) ;
|
||||
void get_mac_addr(const char *const iface,
|
||||
uint8_t mac_bytes[ETHER_ADDR_LEN]) ;
|
||||
void get_ip_addr(const char *const iface, char *ip_bytes) ;
|
||||
void get_ip_addr(const char *const iface, char ip[INET_ADDRSTRLEN]) ;
|
||||
|
||||
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
||||
void* autocalibrate(void *NULL_value) ;
|
||||
void* autocalibrate_hello(void *NULL_value) ;
|
||||
void* autocalibrate_hello(void *const NULL_value) ;
|
||||
void* autocalibrate(void *const NULL_value) ;
|
||||
void send_autocalibration_request(void) ;
|
||||
uint_fast16_t make_packet(uint8_t **packet) ;
|
||||
uint_fast16_t make_packet(uint8_t **const packet) ;
|
||||
#endif // OWLPS_LISTENER_USES_PTHREAD
|
||||
|
||||
void sigint_handler(int num) ;
|
||||
void sigterm_handler(int num) ;
|
||||
void sigint_handler(const int num) ;
|
||||
void sigterm_handler(const int num) ;
|
||||
|
||||
void print_usage(void) ;
|
||||
void print_version(void) ;
|
||||
|
|
|
@ -314,7 +314,7 @@ int main(int argc, char *argv[])
|
|||
* stop (because of a special option or a configuration error), owl_run
|
||||
* is set to false.
|
||||
*/
|
||||
int initialise_configuration(int argc, char **argv)
|
||||
int initialise_configuration(const int argc, char *const *argv)
|
||||
{
|
||||
int ret ;
|
||||
|
||||
|
@ -350,7 +350,7 @@ int initialise_configuration(int argc, char **argv)
|
|||
|
||||
|
||||
|
||||
int parse_config_file(int argc, char **argv)
|
||||
int parse_config_file(const int argc, char *const *argv)
|
||||
{
|
||||
#ifdef OWLPS_LISTENER_USES_CONFIG_FILE
|
||||
// If we use libconfuse, we declare options:
|
||||
|
@ -507,7 +507,7 @@ int parse_config_file(int argc, char **argv)
|
|||
|
||||
|
||||
|
||||
int parse_command_line(int argc, char **argv)
|
||||
int parse_command_line(const int argc, char *const *argv)
|
||||
{
|
||||
int ret ;
|
||||
|
||||
|
@ -526,7 +526,7 @@ int parse_command_line(int argc, char **argv)
|
|||
|
||||
|
||||
|
||||
int parse_main_options(int argc, char **argv)
|
||||
int parse_main_options(const int argc, char *const *argv)
|
||||
{
|
||||
int opt ;
|
||||
long arg_long ; // Integer value of optarg
|
||||
|
@ -654,7 +654,7 @@ int parse_main_options(int argc, char **argv)
|
|||
|
||||
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
||||
/* Parses remaining arguments (possible calibration data) */
|
||||
int parse_calibration_data(int argc, char **argv)
|
||||
int parse_calibration_data(const int argc, char *const *argv)
|
||||
{
|
||||
/* No more arguments to parse */
|
||||
if (argc - optind == 0)
|
||||
|
@ -865,7 +865,7 @@ int check_configuration()
|
|||
|
||||
|
||||
|
||||
void print_configuration(FILE *stream)
|
||||
void print_configuration(FILE *const stream)
|
||||
{
|
||||
#ifdef OWLPS_LISTENER_USES_CONFIG_FILE
|
||||
cfg_print(cfg, stream) ;
|
||||
|
@ -931,7 +931,7 @@ void print_configuration(FILE *stream)
|
|||
* Thread function. Switches interface 'iface' to monitor mode every
|
||||
* second. `iface` must be passed as a const char *const.
|
||||
*/
|
||||
void* keep_mode_monitor(void *iface)
|
||||
void* keep_mode_monitor(const void *const iface)
|
||||
{
|
||||
if (VERBOSE_WARNING)
|
||||
fprintf(stderr, "Thread for keeping monitor mode launched.\n") ;
|
||||
|
@ -1056,8 +1056,8 @@ int capture()
|
|||
/*
|
||||
* Treats a packet and sends it to the aggregator.
|
||||
*/
|
||||
void read_packet(const struct pcap_pkthdr *pkt_header,
|
||||
const u_char *pkt_data)
|
||||
void read_packet(const struct pcap_pkthdr *const pkt_header,
|
||||
const u_char *const pkt_data)
|
||||
{
|
||||
owl_captured_request request ; // Message to send to the aggregator
|
||||
uint16_t rtap_bytes ; // Radiotap header size
|
||||
|
@ -1285,8 +1285,8 @@ void read_packet(const struct pcap_pkthdr *pkt_header,
|
|||
* Note: 'pkt_data' is read from its first byte, therefore you must not
|
||||
* pass the whole received packet to this function.
|
||||
*/
|
||||
void extract_calibration_data(const u_char *pkt_data,
|
||||
owl_captured_request *request)
|
||||
void extract_calibration_data(const u_char *const pkt_data,
|
||||
owl_captured_request *const request)
|
||||
{
|
||||
request->direction = pkt_data[0] ;
|
||||
assert(sizeof(float) == 4) ;
|
||||
|
@ -1303,8 +1303,8 @@ void extract_calibration_data(const u_char *pkt_data,
|
|||
* Note: 'pkt_data' is read from its first byte, therefore you must not
|
||||
* pass the whole received packet to this function.
|
||||
*/
|
||||
void extract_packet_numbers(const u_char *pkt_data,
|
||||
owl_captured_request *request)
|
||||
void extract_packet_numbers(const u_char *const pkt_data,
|
||||
owl_captured_request *const request)
|
||||
{
|
||||
// Current packet's ID:
|
||||
memcpy(&request->packet_id, pkt_data,
|
||||
|
@ -1327,8 +1327,8 @@ void extract_packet_numbers(const u_char *pkt_data,
|
|||
* Ideas of improvement:
|
||||
* http://www.unixgarden.com/index.php/gnu-linux-magazine-hs/introduction-a-la-programmation-wifi-en-c-sous-netbsd#8-exemple-n°5-radiotap
|
||||
*/
|
||||
bool extract_radiotap_ss(const u_char *pkt_data,
|
||||
owl_captured_request *request)
|
||||
bool extract_radiotap_ss(const u_char *const pkt_data,
|
||||
owl_captured_request *const request)
|
||||
{
|
||||
uint32_t rtap_presentflags ;
|
||||
uint_fast16_t rtap_position ;
|
||||
|
@ -1395,7 +1395,8 @@ bool extract_radiotap_ss(const u_char *pkt_data,
|
|||
* To advance to the next available position, you can also use the macro
|
||||
* SKIP_FIELD(), which is a simple wrapper around this function.
|
||||
*/
|
||||
uint_fast16_t nat_align(uint_fast16_t offset, uint_fast8_t field_len)
|
||||
uint_fast16_t nat_align(const uint_fast16_t offset,
|
||||
const uint_fast8_t field_len)
|
||||
{
|
||||
uint_fast8_t alignment = offset % field_len ;
|
||||
if (alignment == 0)
|
||||
|
@ -1405,8 +1406,8 @@ uint_fast16_t nat_align(uint_fast16_t offset, uint_fast8_t field_len)
|
|||
|
||||
|
||||
|
||||
void display_captured_request(owl_captured_request *request,
|
||||
const struct pcap_pkthdr *pkt_header)
|
||||
void display_captured_request(const owl_captured_request *const request,
|
||||
const struct pcap_pkthdr *const pkt_header)
|
||||
{
|
||||
owl_timestamp tmp_time ;
|
||||
char
|
||||
|
@ -1588,7 +1589,7 @@ void get_ip_addr(const char *const iface, char ip[INET_ADDRSTRLEN])
|
|||
/* *** Autocalibration functions *** */
|
||||
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
||||
|
||||
void* autocalibrate_hello(void *NULL_value)
|
||||
void* autocalibrate_hello(void *const NULL_value)
|
||||
{
|
||||
int send_sockfd ;
|
||||
struct sockaddr serv;
|
||||
|
@ -1620,7 +1621,7 @@ void* autocalibrate_hello(void *NULL_value)
|
|||
|
||||
|
||||
|
||||
void* autocalibrate(void *NULL_value)
|
||||
void* autocalibrate(void *const NULL_value)
|
||||
{
|
||||
int nread ; // recvfrom return value
|
||||
int listen_sockfd ;
|
||||
|
@ -1703,7 +1704,7 @@ void send_autocalibration_request()
|
|||
* Returns the size of the packet.
|
||||
* In case of error, 0 is returned and *packet is not updated.
|
||||
*/
|
||||
uint_fast16_t make_packet(uint8_t **packet)
|
||||
uint_fast16_t make_packet(uint8_t **const packet)
|
||||
{
|
||||
uint8_t *pkt ;
|
||||
uint_fast16_t size ; // Packet size
|
||||
|
@ -1773,7 +1774,7 @@ uint_fast16_t make_packet(uint8_t **packet)
|
|||
|
||||
|
||||
|
||||
void sigint_handler(int num)
|
||||
void sigint_handler(const int num)
|
||||
{
|
||||
owl_sigint_handler(num) ;
|
||||
pcap_breakloop(capture_handler) ;
|
||||
|
@ -1781,7 +1782,7 @@ void sigint_handler(int num)
|
|||
|
||||
|
||||
|
||||
void sigterm_handler(int num)
|
||||
void sigterm_handler(const int num)
|
||||
{
|
||||
owl_sigterm_handler(num) ;
|
||||
pcap_breakloop(capture_handler) ;
|
||||
|
|
|
@ -126,7 +126,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
|
||||
void parse_command_line(int argc, char **argv)
|
||||
void parse_command_line(const int argc, char *const *argv)
|
||||
{
|
||||
parse_options(argc, argv) ;
|
||||
check_configuration() ;
|
||||
|
@ -136,7 +136,7 @@ void parse_command_line(int argc, char **argv)
|
|||
}
|
||||
|
||||
|
||||
void parse_options(int argc, char **argv)
|
||||
void parse_options(const int argc, char *const *argv)
|
||||
{
|
||||
int opt ;
|
||||
|
||||
|
@ -235,7 +235,7 @@ int receive_udp()
|
|||
/*
|
||||
* Adds a new owl_result to the results' list.
|
||||
*/
|
||||
void store_result(owl_result *new_result)
|
||||
void store_result(owl_result *const new_result)
|
||||
{
|
||||
sem_wait(&lock_results) ;
|
||||
|
||||
|
@ -350,7 +350,7 @@ int init_tcp_socket()
|
|||
/*
|
||||
* Waits for requests from HTTP clients.
|
||||
*/
|
||||
void* tcp_server(void *NULL_value)
|
||||
void* tcp_server(void *const NULL_value)
|
||||
{
|
||||
int newsockfd ;
|
||||
ssize_t nbytes ; // recv/send return value
|
||||
|
@ -417,10 +417,11 @@ void* tcp_server(void *NULL_value)
|
|||
/*
|
||||
* Reads a message and search for a request in it.
|
||||
* Returns the identifier of a request if found, or 0 if not found.
|
||||
* The text of the request is stored in 'client_request'.
|
||||
*/
|
||||
int
|
||||
extract_request_from_message(char client_request[CLIENT_REQUEST_STRLEN],
|
||||
char *client_message)
|
||||
const char *const client_message)
|
||||
{
|
||||
char *token ;
|
||||
|
||||
|
@ -453,7 +454,7 @@ extract_request_from_message(char client_request[CLIENT_REQUEST_STRLEN],
|
|||
/*
|
||||
* Prepare the answer string to send to the TCP client.
|
||||
*/
|
||||
void prepare_answer(int request_id)
|
||||
void prepare_answer(const int request_id)
|
||||
{
|
||||
// Reset the answer's length:
|
||||
answer_strlen = ANSWER_HDR_STRLEN ;
|
||||
|
@ -577,7 +578,7 @@ void prepare_answer(int request_id)
|
|||
* greater than the current size, shrink it if the current size is
|
||||
* greater than the double of new_size.
|
||||
*/
|
||||
void realloc_answer(size_t new_size)
|
||||
void realloc_answer(const size_t new_size)
|
||||
{
|
||||
if (new_size > answer_buflen)
|
||||
answer_buflen = new_size ;
|
||||
|
|
|
@ -55,20 +55,20 @@ typedef struct _results_list
|
|||
} results_list ;
|
||||
|
||||
|
||||
void parse_command_line(int argc, char **argv) ;
|
||||
void parse_options(int argc, char **argv) ;
|
||||
void parse_command_line(const int argc, char *const *argv) ;
|
||||
void parse_options(const int argc, char *const *argv) ;
|
||||
void check_configuration(void) ;
|
||||
void print_configuration(void) ;
|
||||
|
||||
int receive_udp(void) ;
|
||||
void store_result(owl_result *result) ;
|
||||
void store_result(owl_result *const result) ;
|
||||
int init_tcp_socket(void) ;
|
||||
void* tcp_server(void *NULL_value) ;
|
||||
void* tcp_server(void *const NULL_value) ;
|
||||
int
|
||||
extract_request_from_message(char client_request[CLIENT_REQUEST_STRLEN],
|
||||
char *client_message) ;
|
||||
void prepare_answer(int request_id) ;
|
||||
void realloc_answer(size_t new_size) ;
|
||||
const char *const client_message) ;
|
||||
void prepare_answer(const int request_id) ;
|
||||
void realloc_answer(const size_t new_size) ;
|
||||
void free_results_list(void) ;
|
||||
|
||||
void print_usage(void) ;
|
||||
|
|
Loading…
Reference in New Issue