+ *result = addr;
+ return 1;
+}
+
+/**
+ * Resolve IPv4/IPv6 address and create a ready-to-use active or passive socket.
+ *
+ * \param l4type The layer-4 type (\p IPPROTO_xxx).
+ * \param passive Whether this is a passive or active socket.
+ * \param host Passed to \ref \a lookup_address().
+ * \param port_number Passed to \ref \a lookup_address().
+ * \param fo Socket options to be set before making the connection.
+ *
+ * This creates a ready-made IPv4/v6 socket structure after looking up the
+ * necessary parameters.
+ *
+ * bind(2) is called on passive sockets, and connect(2) on active sockets. The
+ * algorithm tries all possible address combinations until it succeeds. If \a
+ * fo is supplied, options are set and cleanup is performed.
+ *
+ * \return Standard.
+ *
+ * \sa \ref lookup_address(), ipv6(7), getaddrinfo(3), bind(2), connect(2).
+ */
+int makesock(unsigned l4type, bool passive,
+ const char *host, uint16_t port_number,
+ struct flowopts *fo)
+{
+ struct addrinfo *local = NULL, *src = NULL, *remote = NULL, *dst = NULL;
+ int rc, on = 1, sockfd = -1;