[pisa-src] Re: r2518 - in trunk/tools/dhcp: mac2ip.c mac2ip.h

  • From: Christof Mroz <christof.mroz@xxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Tue, 05 Apr 2011 15:07:42 +0200

On Tue, 05 Apr 2011 04:38:45 +0200, Christoph Viethen <christoph.viethen@xxxxxxxxxxxxxx> wrote:


Author: viethen
Date: Tue Apr  5 04:38:45 2011
New Revision: 2518

Log:
change definition of the ip_bounds type to remove two shortcomings:

a) previously, none of the bounds values (being IPv4 addresses, stored
in a binary form) came with any qualification as to their validity; there
is no way to tell whether an IPv4 address, stored in a binary form,
is valid (for instance: has just been read from a config file), since
any four-byte value may look like a valid IPv4 address (even 0.0.0.0 might
be a valid bounds value, depending on definition); --> add a flag to
address this

Good catch! You could probably have used an invalid range to indicated this too, i.e. lower bound = 0xffffffff and upper bound = 0 (and set only if a valid entry was read), but our bit budget is not too tight I think.

+struct ip_bound {
+    mac2ip_ipv4_t bound;
+    _Bool         valid;
+};
+

Could the standard bool type from <stdbool.h> be used here?

 typedef struct ip_bounds {
-    /*
-     * lower client's ip bound  := 0
-     * upper client's ip bound  := 1
-     * lower service's ip bound := 2
-     * upper service's ip bound := 3
-     */
-    mac2ip_ipv4_t bound[4];
+    struct ip_bound lower_client;
+    struct ip_bound upper_client;
+    struct ip_bound lower_service;
+    struct ip_bound upper_service;
 } ip_bounds;
/*

Would it make sense to declare struct ip_range, to reduce clutter even more?
--
This is the pisa developer mailing list. Please also subscribe to the main pisa 
list at:
//www.freelists.org/list/pisa

Other related posts: