]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/prefix.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / lib / prefix.c
index ed0774e77495b03415aef24c2f5d524d3e0fe1dd..858f860ee8e1f8e99e169bc5fe75eae00a056739 100644 (file)
@@ -27,6 +27,7 @@
 #include "memory.h"
 #include "log.h"
 #include "jhash.h"
+#include "lib_errors.h"
 
 DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix")
 
@@ -656,7 +657,8 @@ void prefix_copy(struct prefix *dest, const struct prefix *src)
                memcpy((void *)dest->u.prefix_flowspec.ptr,
                       (void *)src->u.prefix_flowspec.ptr, len);
        } else {
-               zlog_err("prefix_copy(): Unknown address family %d",
+               flog_err(EC_LIB_DEVELOPMENT,
+                        "prefix_copy(): Unknown address family %d",
                         src->family);
                assert(0);
        }
@@ -851,7 +853,7 @@ int str2prefix_ipv4(const char *str, struct prefix_ipv4 *p)
        /* String doesn't contail slash. */
        if (pnt == NULL) {
                /* Convert string to prefix. */
-               ret = inet_aton(str, &p->prefix);
+               ret = inet_pton(AF_INET, str, &p->prefix);
                if (ret == 0)
                        return 0;
 
@@ -1197,6 +1199,9 @@ int str2prefix(const char *str, struct prefix *p)
 {
        int ret;
 
+       if (!str || !p)
+               return 0;
+
        /* First we try to convert string to struct prefix_ipv4. */
        ret = str2prefix_ipv4(str, (struct prefix_ipv4 *)p);
        if (ret)
@@ -1370,17 +1375,6 @@ void prefix_free(struct prefix *p)
        XFREE(MTYPE_PREFIX, p);
 }
 
-/* Utility function.  Check the string only contains digit
- * character.
- * FIXME str.[c|h] would be better place for this function. */
-int all_digit(const char *str)
-{
-       for (; *str != '\0'; str++)
-               if (!isdigit((int)*str))
-                       return 0;
-       return 1;
-}
-
 /* Utility function to convert ipv4 prefixes to Classful prefixes */
 void apply_classful_mask_ipv4(struct prefix_ipv4 *p)
 {