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;
/**
* 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,
const struct addrinfo *);
vlc_tls_t *vlc_tls_SocketOpenAddrInfo(const struct addrinfo *);
/**
* 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,
* This function resolves a hostname, and attempts to establish a TCP/IP
* 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
*/
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,
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);
if (tls == NULL)
vlc_tls_t *sock = vlc_tls_SocketAddrInfo(info);
if (sock == NULL)
return NULL;
if (vlc_tls_Connect(tls))
{
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)
if (vlc_tls_Connect(sock))
{
vlc_tls_t *tls = vlc_tls_ConnectAddrInfo(p);
if (tls != NULL)
return tls;
msg_Err(obj, "connection error: %s", vlc_strerror_c(errno));
vlc_tls_SessionDelete(sock);
sock = NULL;
}
return NULL;
return sock;
}
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);
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);
return tls;
}
freeaddrinfo(res);
return tls;
return NULL;
}
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