[Client] Check the direction

This commit is contained in:
Matteo Cypriani 2011-03-25 11:33:05 +01:00
parent 15f4436628
commit 7c6d09d859
3 changed files with 12 additions and 3 deletions

3
TODO
View File

@ -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.

View File

@ -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 ;

View File

@ -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)
{