MT#55283 add open_v46_socket()

Opens a generic socket supporting both IPv4 and IPv6, useful for
outgoing connections.

Change-Id: I2502653d481479b9c13a5f66ed5929723e9db9b3
pull/1640/head
Richard Fuchs 3 years ago
parent 83c7336e89
commit 33f19c7941

@ -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;

@ -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

Loading…
Cancel
Save