Commit e877f5a6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

tls: inline one function, revector

parent 20150f3d
...@@ -288,12 +288,8 @@ struct addrinfo; ...@@ -288,12 +288,8 @@ struct addrinfo;
/** /**
* Creates a transport-layer stream from a struct addrinfo. * Creates a transport-layer stream from a struct addrinfo.
*
* \note The function currently iterates through the addrinfo linked list.
* Future versions may implement different behaviour (e.g. RFC6555).
*/ */
vlc_tls_t *vlc_tls_SocketOpenAddrInfo(vlc_object_t *obj, vlc_tls_t *vlc_tls_SocketOpenAddrInfo(const struct addrinfo *);
const struct addrinfo *);
/** /**
* Creates a transport-layer TCP stream from a name and port. * Creates a transport-layer TCP stream from a name and port.
...@@ -301,6 +297,9 @@ vlc_tls_t *vlc_tls_SocketOpenAddrInfo(vlc_object_t *obj, ...@@ -301,6 +297,9 @@ vlc_tls_t *vlc_tls_SocketOpenAddrInfo(vlc_object_t *obj,
* This function resolves a hostname, and attempts to establish a TCP/IP * This function resolves a hostname, and attempts to establish a TCP/IP
* connection to the specified host and port number. * connection to the specified host and port number.
* *
* @note The function currently iterates through the addrinfo linked list.
* Future versions may implement different behaviour (e.g. RFC6555).
*
* @return a transport layer socket on success or NULL on error * @return a transport layer socket on success or NULL on error
*/ */
VLC_API vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj, VLC_API vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj,
......
...@@ -537,33 +537,18 @@ static ssize_t vlc_tls_ConnectWrite(vlc_tls_t *tls, ...@@ -537,33 +537,18 @@ static ssize_t vlc_tls_ConnectWrite(vlc_tls_t *tls,
return vlc_tls_SocketWrite(tls, iov, count); return vlc_tls_SocketWrite(tls, iov, count);
} }
static vlc_tls_t *vlc_tls_ConnectAddrInfo(const struct addrinfo *info) vlc_tls_t *vlc_tls_SocketOpenAddrInfo(const struct addrinfo *restrict info)
{ {
vlc_tls_t *tls = vlc_tls_SocketAddrInfo(info); vlc_tls_t *sock = vlc_tls_SocketAddrInfo(info);
if (tls == NULL) if (sock == NULL)
return NULL; return NULL;
if (vlc_tls_Connect(tls)) if (vlc_tls_Connect(sock))
{
vlc_tls_SessionDelete(tls);
tls = NULL;
}
return tls;
}
vlc_tls_t *vlc_tls_SocketOpenAddrInfo(vlc_object_t *obj,
const struct addrinfo *restrict info)
{
/* TODO: implement RFC6555 */
for (const struct addrinfo *p = info; p != NULL; p = p->ai_next)
{ {
vlc_tls_t *tls = vlc_tls_ConnectAddrInfo(p); vlc_tls_SessionDelete(sock);
if (tls != NULL) sock = NULL;
return tls;
msg_Err(obj, "connection error: %s", vlc_strerror_c(errno));
} }
return NULL; return sock;
} }
vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj, const char *name, vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj, const char *name,
...@@ -588,9 +573,22 @@ vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj, const char *name, ...@@ -588,9 +573,22 @@ vlc_tls_t *vlc_tls_SocketOpenTCP(vlc_object_t *obj, const char *name,
msg_Dbg(obj, "connecting to %s port %u ...", name, port); msg_Dbg(obj, "connecting to %s port %u ...", name, port);
vlc_tls_t *tls = vlc_tls_SocketOpenAddrInfo(obj, res); /* TODO: implement RFC6555 */
for (const struct addrinfo *p = res; p != NULL; p = p->ai_next)
{
vlc_tls_t *tls = vlc_tls_SocketOpenAddrInfo(p);
if (tls == NULL)
{
msg_Err(obj, "connection error: %s", vlc_strerror_c(errno));
continue;
}
freeaddrinfo(res); freeaddrinfo(res);
return tls; return tls;
}
freeaddrinfo(res);
return NULL;
} }
vlc_tls_t *vlc_tls_SocketOpenTLS(vlc_tls_creds_t *creds, const char *name, vlc_tls_t *vlc_tls_SocketOpenTLS(vlc_tls_creds_t *creds, const char *name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment