PARA_ERROR_LOG("Can not determine peer address: %s\n", strerror(errno));
goto no_match;
}
- v4_addr = extract_v4_addr(&ss);
+ extract_v4_addr(&ss, &v4_addr);
if (!v4_addr.s_addr)
goto no_match;
/**
* Extract IPv4 or IPv6-mapped-IPv4 address from sockaddr_storage.
- * \param ss Container of IPv4/6 address
- * \return Extracted IPv4 address (different from 0) or 0 if unsuccessful.
*
- * \sa RFC 3493
+ * \param ss Container of IPv4/6 address.
+ * \param ia Extracted IPv4 address (different from 0) or 0 if unsuccessful.
+ *
+ * \sa RFC 3493.
*/
-struct in_addr extract_v4_addr(const struct sockaddr_storage *ss)
+void extract_v4_addr(const struct sockaddr_storage *ss, struct in_addr *ia)
{
- struct in_addr ia = {.s_addr = 0};
const struct sockaddr *sa = normalize_ip_address(ss);
+ memset(ia, 0, sizeof(*ia));
if (sa->sa_family == AF_INET)
- ia = ((struct sockaddr_in *)sa)->sin_addr;
- return ia;
+ *ia = ((struct sockaddr_in *)sa)->sin_addr;
}
/**
return makesock(l4type, 0, host, port, NULL);
}
-extern struct in_addr extract_v4_addr(const struct sockaddr_storage *ss);
+void extract_v4_addr(const struct sockaddr_storage *ss, struct in_addr *ia);
/**
* Functions to support listening sockets.