diff --git a/libowlps/libowlps.c b/libowlps/libowlps.c index 3cc946c..ad77de0 100644 --- a/libowlps/libowlps.c +++ b/libowlps/libowlps.c @@ -24,6 +24,9 @@ owl_bool owl_run = TRUE ; +/* *** Miscellaneous functions *** */ + + /* * Converts a MAC address from bytes to string. * The string is allocated in a static buffer, and will be overwritten @@ -38,7 +41,6 @@ const char* owl_mac_bytes_to_string(const uint8_t *const mac_binary) } - /* * Converts a MAC address from bytes to string. * 'mac_str' must be allocated by the caller. @@ -53,7 +55,6 @@ void owl_mac_bytes_to_string_r(const uint8_t *const mac_binary, } - /* * Compares two MAC addresses. * Returns TRUE if they are identical, FALSE otherwise. @@ -69,7 +70,6 @@ owl_bool owl_mac_equals(const uint8_t *const mac1, } - /* * Converts a IEEE 802.11 frequency into a channel number. * Returns 0 if the frequency does not correspond to an official channel. @@ -129,6 +129,9 @@ uint_fast8_t owl_frequency_to_channel(const uint_fast16_t channel) +/* *** Time *** */ + + /* * Sets the owl_timestamp 'now' at the current time. * Returns 0 in case of success non-zero otherwise. @@ -149,7 +152,6 @@ int owl_timestamp_now(owl_timestamp *const now) } - /* * Returns a owl_timestamp from a struct timespec. */ @@ -162,7 +164,6 @@ owl_timestamp owl_timespec_to_timestamp(const struct timespec d) } - /* * Returns a owl_timestamp from a struct timeval. */ @@ -175,7 +176,6 @@ owl_timestamp owl_timeval_to_timestamp(const struct timeval d) } - owl_bool owl_timestamp_equals(const owl_timestamp d1, const owl_timestamp d2) { @@ -183,14 +183,12 @@ owl_bool owl_timestamp_equals(const owl_timestamp d1, } - owl_bool owl_timestamp_is_null(const owl_timestamp d) { return d.tv_sec == 0 && d.tv_nsec == 0 ; } - /* * Converts a owl_timestamp date value into milliseconds. */ @@ -200,7 +198,6 @@ uint64_t owl_timestamp_to_ms(const owl_timestamp d) } - /* * Converts a owl_timestamp date value into a printable string. * 'dst' must be an allocated array of at least owl_timestamp_STR_LEN @@ -213,7 +210,6 @@ void owl_timestamp_to_string(char *const dst, const owl_timestamp src) } - /* * Returns the time (in milliseconds) between two dates. */ @@ -224,7 +220,6 @@ uint_fast32_t owl_time_elapsed_ms(const owl_timestamp d1, } - /* * Returns a owl_timestamp storing the time between two dates. */ @@ -242,7 +237,6 @@ owl_timestamp owl_time_elapsed(const owl_timestamp d1, } - /* * Converts a owl_timestamp from host endianess to network endianess. */ @@ -255,7 +249,6 @@ owl_timestamp owl_hton_timestamp(const owl_timestamp d) } - /* * Converts a owl_timestamp from network endianess to host endianess. */ @@ -269,6 +262,9 @@ owl_timestamp owl_ntoh_timestamp(const owl_timestamp d) +/* *** Network *** */ + + /* * Creates a UDP transmission socket and returns its descriptor. * Parameters: @@ -286,7 +282,7 @@ int owl_create_udp_trx_socket(const char *const server_address, { int sockfd ; // Socket descriptor - /* Ceate the UDP socket */ + /* Create the UDP socket */ sockfd = socket(AF_INET, SOCK_DGRAM, 0) ; if (sockfd < 0) { @@ -311,7 +307,6 @@ int owl_create_udp_trx_socket(const char *const server_address, } - /* * Creates a UDP reception socket and returns its descriptor. * Parameters: @@ -352,7 +347,6 @@ int owl_create_udp_listening_socket(const uint_fast16_t port) } - /* * Switches the IEEE 802.11 interface 'iface' to Monitor mode. */ @@ -386,7 +380,6 @@ int owl_iface_mode_monitor(const char *const iface) } - /* * Sets the IEEE 802.11 channel of the interface 'iface'. * 'channel' must be an integer between 1 and 14. @@ -413,7 +406,6 @@ int owl_iface_set_channel(const char *const iface, } - /* * Switches alternatively the Wi-Fi channel of the IEEE 802.11 interface * 'iface' to 4 or 11. @@ -428,7 +420,7 @@ int owl_iface_channel_hop(const char *const iface) if (ioctl(sockfd, SIOCGIWFREQ, &wrq) == -1) { - perror("Erreur lors de la lecture de la fréquence ") ; + perror("Error reading the frequency") ; return ERR_READING_CHANNEL ; } // The following is not very clean: we should use iw_freq2float(), @@ -450,6 +442,9 @@ int owl_iface_channel_hop(const char *const iface) +/* *** Signals *** */ + + /* * Generic signal handler for SIGINT. */ @@ -471,8 +466,9 @@ void owl_sigint_handler(const int num) } - -/* Gestionnaire de signal générique pour SIGTERM */ +/* + * Generic signal handler for SIGTERM. + */ void owl_sigterm_handler(const int num) { if (num != SIGTERM) @@ -487,6 +483,9 @@ void owl_sigterm_handler(const int num) +/* *** Thread-related functions *** */ + + /* * Closes the file descriptor 'fd'. * 'fd' must be passed as an int pointer (int*). @@ -507,7 +506,6 @@ void owl_close_fd(void *const fd) } - /* * Closes the stream 'file'. * 'file' must be passed as a pointer on a pointer of FILE (FILE**).