Skip to content

Commit ef7fa13

Browse files
authored
Merge pull request #26 from MERAprojects/meraswitch/devel/issue_ops_build#8
MERAprojects/ops-build#8 IPv6 static routes aren't configured
2 parents 1917f73 + ce7f4f6 commit ef7fa13

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

lib/prefix.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,4 +903,26 @@ inet6_ntoa (struct in6_addr addr)
903903
inet_ntop (AF_INET6, &addr, buf, INET6_ADDRSTRLEN);
904904
return buf;
905905
}
906+
907+
int
908+
ip_addr_is_equal (const char *addr_str1, const char *addr_str2) {
909+
int af;
910+
911+
af = ((strstr(addr_str1, ":") != NULL) ? AF_INET6 : AF_INET);
912+
return ip_addr_is_equal_af(af, addr_str1, addr_str2);
913+
}
914+
915+
int
916+
ip_addr_is_equal_af (int af, const char *addr_str1, const char *addr_str2) {
917+
struct in6_addr addr1, addr2;
918+
919+
if (af == AF_INET) {
920+
return !strcmp(addr_str1, addr_str2);
921+
}
922+
else if (inet_pton(AF_INET6, addr_str1, &addr1) && inet_pton(AF_INET6, addr_str2, &addr2)) {
923+
return !IPV6_ADDR_CMP(&addr1, &addr2);
924+
}
925+
return 0;
926+
}
927+
906928
#endif /* HAVE_IPV6 */

lib/prefix.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ extern void masklen2ip6 (const int, struct in6_addr *);
219219

220220
extern void str2in6_addr (const char *, struct in6_addr *);
221221
extern const char *inet6_ntoa (struct in6_addr);
222+
extern int ip_addr_is_equal (const char *, const char *);
223+
extern int ip_addr_is_equal_af (int, const char *, const char *);
222224

223225
#endif /* HAVE_IPV6 */
224226

0 commit comments

Comments
 (0)