summaryrefslogtreecommitdiff
path: root/lib/prefix.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prefix.c')
-rw-r--r--lib/prefix.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/prefix.c b/lib/prefix.c
index 1a4a914e05..ad8dea273e 100644
--- a/lib/prefix.c
+++ b/lib/prefix.c
@@ -853,7 +853,7 @@ void prefix_ipv4_free(struct prefix_ipv4 *p)
prefix_free((struct prefix *)p);
}
-/* When string format is invalid return 0. */
+/* If given string is valid return 1 else return 0 */
int str2prefix_ipv4(const char *str, struct prefix_ipv4 *p)
{
int ret;
@@ -881,8 +881,10 @@ int str2prefix_ipv4(const char *str, struct prefix_ipv4 *p)
cp = XMALLOC(MTYPE_TMP, (pnt - str) + 1);
memcpy(cp, str, pnt - str);
*(cp + (pnt - str)) = '\0';
- ret = inet_aton(cp, &p->prefix);
+ ret = inet_pton(AF_INET, cp, &p->prefix);
XFREE(MTYPE_TMP, cp);
+ if (ret == 0)
+ return 0;
/* Get prefix length. */
plen = (uint8_t)atoi(++pnt);
@@ -1023,7 +1025,7 @@ void prefix_ipv6_free(struct prefix_ipv6 *p)
prefix_free((struct prefix *)p);
}
-/* If given string is valid return pin6 else return NULL */
+/* If given string is valid return 1 else return 0 */
int str2prefix_ipv6(const char *str, struct prefix_ipv6 *p)
{
char *pnt;