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

Remove the getaddrinfo transport protocol and socket type hacks

That was meant for DCCP and UDP-Lite but it shouldn't be needed.
parent e71a4f98
...@@ -158,27 +158,9 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, ...@@ -158,27 +158,9 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
int i_port, int protocol) int i_port, int protocol)
{ {
struct addrinfo hints, *res; struct addrinfo hints, *res;
int socktype = SOCK_DGRAM;
switch( protocol )
{
case IPPROTO_TCP:
socktype = SOCK_STREAM;
break;
case 33: /* DCCP */
#ifdef __linux__
# ifndef SOCK_DCCP
# define SOCK_DCCP 6
# endif
socktype = SOCK_DCCP;
#endif
break;
}
memset (&hints, 0, sizeof( hints )); memset (&hints, 0, sizeof( hints ));
/* Since we use port numbers rather than service names, the socket type hints.ai_protocol = protocol;
* does not really matter. */
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE; hints.ai_flags = AI_PASSIVE;
msg_Dbg (p_this, "net: listening to %s port %d", psz_host, i_port); msg_Dbg (p_this, "net: listening to %s port %d", psz_host, i_port);
...@@ -196,7 +178,8 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, ...@@ -196,7 +178,8 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
for (struct addrinfo *ptr = res; ptr != NULL; ptr = ptr->ai_next) for (struct addrinfo *ptr = res; ptr != NULL; ptr = ptr->ai_next)
{ {
int fd = net_Socket (p_this, ptr->ai_family, socktype, protocol); int fd = net_Socket (p_this, ptr->ai_family, ptr->ai_socktype,
ptr->ai_protocol);
if (fd == -1) if (fd == -1)
{ {
msg_Dbg (p_this, "socket error: %m"); msg_Dbg (p_this, "socket error: %m");
...@@ -229,8 +212,8 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, ...@@ -229,8 +212,8 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
{ {
net_Close (fd); net_Close (fd);
#if !defined(WIN32) && !defined(UNDER_CE) #if !defined(WIN32) && !defined(UNDER_CE)
fd = rootwrap_bind (ptr->ai_family, socktype, fd = rootwrap_bind (ptr->ai_family, ptr->ai_socktype,
protocol ? protocol : ptr->ai_protocol, ptr->ai_protocol,
ptr->ai_addr, ptr->ai_addrlen); ptr->ai_addr, ptr->ai_addrlen);
if (fd != -1) if (fd != -1)
{ {
...@@ -254,7 +237,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, ...@@ -254,7 +237,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
} }
/* Listen */ /* Listen */
switch (socktype) switch (ptr->ai_socktype)
{ {
case SOCK_STREAM: case SOCK_STREAM:
case SOCK_RDM: case SOCK_RDM:
......
...@@ -84,7 +84,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -84,7 +84,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
return -1; return -1;
memset( &hints, 0, sizeof( hints ) ); memset( &hints, 0, sizeof( hints ) );
hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = proto;
psz_socks = var_CreateGetNonEmptyString( p_this, "socks" ); psz_socks = var_CreateGetNonEmptyString( p_this, "socks" );
if( psz_socks != NULL ) if( psz_socks != NULL )
...@@ -148,8 +148,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -148,8 +148,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
for( ptr = res; ptr != NULL; ptr = ptr->ai_next ) for( ptr = res; ptr != NULL; ptr = ptr->ai_next )
{ {
int fd = net_Socket( p_this, ptr->ai_family, int fd = net_Socket( p_this, ptr->ai_family,
type ? type : ptr->ai_socktype, ptr->ai_socktype, ptr->ai_protocol );
proto ? proto : ptr->ai_protocol );
if( fd == -1 ) if( fd == -1 )
{ {
msg_Dbg( p_this, "socket error: %m" ); msg_Dbg( p_this, "socket error: %m" );
...@@ -464,6 +463,8 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj, ...@@ -464,6 +463,8 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
/* v4 only support ipv4 */ /* v4 only support ipv4 */
memset (&hints, 0, sizeof (hints)); memset (&hints, 0, sizeof (hints));
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
if( vlc_getaddrinfo( p_obj, psz_host, 0, &hints, &p_res ) ) if( vlc_getaddrinfo( p_obj, psz_host, 0, &hints, &p_res ) )
return VLC_EGENERIC; return VLC_EGENERIC;
......
...@@ -142,6 +142,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port, ...@@ -142,6 +142,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
memset (&hints, 0, sizeof( hints )); memset (&hints, 0, sizeof( hints ));
hints.ai_family = family; hints.ai_family = family;
hints.ai_socktype = SOCK_DGRAM; hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = protocol;
hints.ai_flags = AI_PASSIVE; hints.ai_flags = AI_PASSIVE;
if (host && !*host) if (host && !*host)
...@@ -163,7 +164,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port, ...@@ -163,7 +164,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
for (const struct addrinfo *ptr = res; ptr != NULL; ptr = ptr->ai_next) for (const struct addrinfo *ptr = res; ptr != NULL; ptr = ptr->ai_next)
{ {
int fd = net_Socket (obj, ptr->ai_family, ptr->ai_socktype, int fd = net_Socket (obj, ptr->ai_family, ptr->ai_socktype,
protocol ? protocol : ptr->ai_protocol); ptr->ai_protocol);
if (fd == -1) if (fd == -1)
{ {
msg_Dbg (obj, "socket error: %m"); msg_Dbg (obj, "socket error: %m");
...@@ -660,6 +661,7 @@ int __net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -660,6 +661,7 @@ int __net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
memset( &hints, 0, sizeof( hints ) ); memset( &hints, 0, sizeof( hints ) );
hints.ai_socktype = SOCK_DGRAM; hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = proto;
msg_Dbg( p_this, "net: connecting to [%s]:%d", psz_host, i_port ); msg_Dbg( p_this, "net: connecting to [%s]:%d", psz_host, i_port );
...@@ -675,7 +677,7 @@ int __net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -675,7 +677,7 @@ int __net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
{ {
char *str; char *str;
int fd = net_Socket (p_this, ptr->ai_family, ptr->ai_socktype, int fd = net_Socket (p_this, ptr->ai_family, ptr->ai_socktype,
proto ? proto : ptr->ai_protocol); ptr->ai_protocol);
if (fd == -1) if (fd == -1)
continue; continue;
...@@ -764,6 +766,7 @@ int __net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind, ...@@ -764,6 +766,7 @@ int __net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
memset (&hints, 0, sizeof (hints)); memset (&hints, 0, sizeof (hints));
hints.ai_family = family; hints.ai_family = family;
hints.ai_socktype = SOCK_DGRAM; hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = protocol;
val = vlc_getaddrinfo (obj, psz_server, i_server, &hints, &rem); val = vlc_getaddrinfo (obj, psz_server, i_server, &hints, &rem);
if (val) if (val)
...@@ -786,7 +789,7 @@ int __net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind, ...@@ -786,7 +789,7 @@ int __net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
for (struct addrinfo *ptr = loc; ptr != NULL; ptr = ptr->ai_next) for (struct addrinfo *ptr = loc; ptr != NULL; ptr = ptr->ai_next)
{ {
int fd = net_Socket (obj, ptr->ai_family, ptr->ai_socktype, int fd = net_Socket (obj, ptr->ai_family, ptr->ai_socktype,
protocol ? protocol : ptr->ai_protocol); ptr->ai_protocol);
if (fd == -1) if (fd == -1)
continue; // usually, address family not supported continue; // usually, address family not supported
......
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