{
FILE *fd = fopen("/proc/net/if_inet6", "r");
int len;
+ bool ret = false;
char buf[256];
if (fd == NULL)
len = strlen(buf);
if ((len <= 0) || buf[len - 1] != '\n')
- return false;
+ break;
buf[--len] = '\0';
if (sscanf(buf, "%s %x %x %x %x %s",
addr_buf, &dummy, &dummy, &dummy, &flags, name) != 6)
- return false;
+ break;
if (strcmp(name, ifname) ||
(flags & (IFA_F_DADFAILED | IFA_F_TENTATIVE | IFA_F_DEPRECATED)))
for (i = 0; i < strlen(addr_buf); i++) {
if (!isxdigit(addr_buf[i]) || isupper(addr_buf[i]))
- return false;
+ break;
}
memset(&inet6_addr, 0, sizeof(inet6_addr));
}
if ((IN6_IS_ADDR_LINKLOCAL(&inet6_addr) == IN6_IS_ADDR_LINKLOCAL(addr)) &&
- (IN6_IS_ADDR_UNIQUELOCAL(&inet6_addr) == IN6_IS_ADDR_UNIQUELOCAL(addr)))
- return true;
+ (IN6_IS_ADDR_UNIQUELOCAL(&inet6_addr) == IN6_IS_ADDR_UNIQUELOCAL(addr))) {
+ ret = true;
+ break;
+ }
}
- return false;
+ fclose(fd);
+ return ret;
}
static void sighandler(int signal)