diff options
author | gdt <gdt> | 2004-01-13 15:55:40 +0100 |
---|---|---|
committer | gdt <gdt> | 2004-01-13 15:55:40 +0100 |
commit | 9d24baaa3d4a6688403b34708a1f4696c7d12c5b (patch) | |
tree | 8b4cb6873b4c64c31a1bce6defd032a5201d9f2b /lib/prefix.c | |
parent | 2004-01-10 Paul Jakma <paul@dishone.st> (diff) | |
download | frr-9d24baaa3d4a6688403b34708a1f4696c7d12c5b.tar.xz frr-9d24baaa3d4a6688403b34708a1f4696c7d12c5b.zip |
Explain the dual use of struct prefix for CIDR prefixes and
address/netmask pairs, and clarify the two comparison functions.
Diffstat (limited to 'lib/prefix.c')
-rw-r--r-- | lib/prefix.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 61e0f1955..5a3e71bfe 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -118,7 +118,14 @@ prefix_copy (struct prefix *dest, struct prefix *src) } } -/* If both prefix structure is same then return 1 else return 0. */ +/* + * Return 1 if the address/netmask contained in the prefix structure + * is the same, and else return 0. For this routine, 'same' requires + * that not only the prefix length and the network part be the same, + * but also the host part. Thus, 10.0.0.1/8 and 10.0.0.2/8 are not + * the same. Note that this routine has the same return value sense + * as '==' (which is different from prefix_cmp). + */ int prefix_same (struct prefix *p1, struct prefix *p2) { @@ -136,8 +143,16 @@ prefix_same (struct prefix *p1, struct prefix *p2) return 0; } -/* When both prefix structure is not same, but will be same after - applying mask, return 0. otherwise, return 1 */ +/* + * Return 0 if the network prefixes represented by the struct prefix + * arguments are the same prefix, and 1 otherwise. Network prefixes + * are considered the same if the prefix lengths are equal and the + * network parts are the same. Host bits (which are considered masked + * by the prefix length) are not significant. Thus, 10.0.0.1/8 and + * 10.0.0.2/8 are considered equivalent by this routine. Note that + * this routine has the same return sense as strcmp (which is different + * from prefix_same). + */ int prefix_cmp (struct prefix *p1, struct prefix *p2) { |