]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: use some more transparent unions for prefixes
authorDavid Lamparter <equinox@diac24.net>
Sun, 28 Jul 2019 07:26:21 +0000 (09:26 +0200)
committerDavid Lamparter <equinox@diac24.net>
Sun, 28 Jul 2019 07:26:21 +0000 (09:26 +0200)
... so we can pass prefix_ipv4/prefix_ipv6 in.

Signed-off-by: David Lamparter <equinox@diac24.net>
lib/prefix.c
lib/prefix.h

index 1008e16a5d0093fc37865bf330b458b08c2cc8c2..78a97fd1480ea50281a631ffb54f3971e7267ca4 100644 (file)
@@ -628,8 +628,11 @@ int prefix_match_network_statement(const struct prefix *n,
        return 1;
 }
 
-void prefix_copy(struct prefix *dest, const struct prefix *src)
+void prefix_copy(union prefixptr udest, union prefixconstptr usrc)
 {
+       struct prefix *dest = udest.p;
+       const struct prefix *src = usrc.p;
+
        dest->family = src->family;
        dest->prefixlen = src->prefixlen;
 
@@ -674,8 +677,11 @@ void prefix_copy(struct prefix *dest, const struct prefix *src)
  * the same.  Note that this routine has the same return value sense
  * as '==' (which is different from prefix_cmp).
  */
-int prefix_same(const struct prefix *p1, const struct prefix *p2)
+int prefix_same(union prefixconstptr up1, union prefixconstptr up2)
 {
+       const struct prefix *p1 = up1.p;
+       const struct prefix *p2 = up2.p;
+
        if ((p1 && !p2) || (!p1 && p2))
                return 0;
 
@@ -722,8 +728,10 @@ int prefix_same(const struct prefix *p1, const struct prefix *p2)
  * this routine has the same return sense as strcmp (which is different
  * from prefix_same).
  */
-int prefix_cmp(const struct prefix *p1, const struct prefix *p2)
+int prefix_cmp(union prefixconstptr up1, union prefixconstptr up2)
 {
+       const struct prefix *p1 = up1.p;
+       const struct prefix *p2 = up2.p;
        int offset;
        int shift;
        int i;
index d57b43dac689e10d377a7afbef3510daf230b0ee..5f88eaae052c7b73a597c3b39d535003dbcaeada 100644 (file)
@@ -410,10 +410,10 @@ extern const char *prefix2str(union prefixconstptr, char *, int);
 extern int prefix_match(const struct prefix *, const struct prefix *);
 extern int prefix_match_network_statement(const struct prefix *,
                                          const struct prefix *);
-extern int prefix_same(const struct prefix *, const struct prefix *);
-extern int prefix_cmp(const struct prefix *, const struct prefix *);
+extern int prefix_same(union prefixconstptr, union prefixconstptr);
+extern int prefix_cmp(union prefixconstptr, union prefixconstptr);
 extern int prefix_common_bits(const struct prefix *, const struct prefix *);
-extern void prefix_copy(struct prefix *dest, const struct prefix *src);
+extern void prefix_copy(union prefixptr, union prefixconstptr);
 extern void apply_mask(struct prefix *);
 
 extern struct prefix *sockunion2prefix(const union sockunion *dest,