diff --git a/TODO b/TODO index 74dc29e..f1bdeae 100644 --- a/TODO +++ b/TODO @@ -45,9 +45,6 @@ * Client -- Check the direction - The direction provided by the user should be one of the four - possible values. - Allow to use a string for the direction Could be nice, but probably useless. diff --git a/libowlps/owlps.h b/libowlps/owlps.h index aad0860..170b689 100644 --- a/libowlps/owlps.h +++ b/libowlps/owlps.h @@ -62,6 +62,8 @@ typedef enum {FALSE, TRUE} owl_bool ; /* Direction type */ enum {NORTH = 1, EAST, SOUTH, WEST} ; +#define OWL_DIRECTION_MIN 1 +#define OWL_DIRECTION_MAX 4 typedef uint8_t owl_direction ; diff --git a/owlps-client/owlps-client.c b/owlps-client/owlps-client.c index 8ef709b..89d1e62 100644 --- a/owlps-client/owlps-client.c +++ b/owlps-client/owlps-client.c @@ -227,6 +227,16 @@ void check_configuration() options.nb_pkt = DEFAULT_NBPKT_NORMAL ; } + // Calibration request but bad direction + if (is_calibration_request) + if (options.direction < OWL_DIRECTION_MIN || + options.direction > OWL_DIRECTION_MAX) + { + fprintf(stderr, "Error! « %"PRIu8" » is not a valid" + " direction.\n", options.direction) ; + exit(ERR_BAD_USAGE) ; + } + // Check port numbers if (options.dest_port < 1 || options.dest_port > 65535) {