struct list_head sockopts;
};
+/**
+ * Allocate and initialize a flowopt queue.
+ *
+ * \return A new structure to be passed to \ref flowopt_add(). It is
+ * automatically deallocated in \ref makesock().
+ */
struct flowopts *flowopt_new(void)
{
struct flowopts *new = para_malloc(sizeof(*new));
list_add_tail(&new->node, &fo->sockopts);
}
-void flowopt_add_bool(struct flowopts *fo, int lev, int opt,
- const char *optname, bool on_or_off)
-{
- int on = on_or_off; /* kernel takes 'int' */
-
- flowopt_add(fo, lev, opt, optname, &on, sizeof(on));
-}
-
/** Set the entire bunch of pre-connection options at once. */
static void flowopt_setopts(int sockfd, struct flowopts *fo)
{
/**
* 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;
}
/**