diff --git a/lib/socket.c b/lib/socket.c index e1c9a707c..54e8fc7a9 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -725,6 +725,20 @@ fail: return -1; } +int open_v46_socket(socket_t *r, int type) { + sockfamily_t *fam = &__socket_families[SF_IP6]; + + if (__socket(r, type, fam)) { + __C_DBG("open socket fail, fd=%d", r->fd); + return -1; + } + + nonblock(r->fd); + ipv6only(r->fd, 0); + + return 0; +} + void dummy_socket(socket_t *r, const sockaddr_t *sa) { ZERO(*r); r->fd = -1; diff --git a/lib/socket.h b/lib/socket.h index 2548179fe..4ea315eaa 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -214,6 +214,7 @@ INLINE int socket_cpu_affinity(socket_t *s, int cpu) { void socket_init(void); int open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *); +int open_v46_socket(socket_t *r, int type); int connect_socket(socket_t *r, int type, const endpoint_t *ep); int connect_socket_nb(socket_t *r, int type, const endpoint_t *ep); // 1 == in progress int connect_socket_retry(socket_t *r); // retries connect() while in progress