#include <string.h>
#include <sys/socket.h>
+#include <network/libnetwork.h>
+
typedef struct ip_address {
int family;
struct in6_addr addr;
if (a1->family != a2->family || a1->prefix != a2->prefix)
return -1;
- for (unsigned int i = 0; i < 4; i++) {
- if (a1->addr.s6_addr[i] > a2->addr.s6_addr[i])
- return 0;
- }
+ if (memcmp(&a1->addr.s6_addr, &a2->addr.s6_addr, sizeof(a1->addr.s6_addr)) > 0)
+ return 0;
return 1;
}
if (r)
return;
- if (ip->prefix >= 0) {
+ int address_prefix = default_prefix(ip->family);
+
+ // Only print prefix when it is not the default one
+ if (ip->prefix != address_prefix) {
size_t len = strlen(buffer);
snprintf(buffer + len, sizeof(buffer) - len, "/%d", ip->prefix);
}
int family = AF_UNSPEC;
while (1) {
- int c = getopt_long(argc, argv, "46bcefgnpsv", long_options, &option_index);
+ int c = getopt_long(argc, argv, "46bcefgnpsviV", long_options, &option_index);
if (c == -1)
break;
verbose = 1;
break;
+ case 'V':
+ printf("%s\n", network_version());
+ exit(0);
+ break;
+
case '?':
break;