From: RĂ©mi Denis-Courmont Date: Mon, 1 Feb 2010 21:13:26 +0000 (+0200) Subject: Remove the getaddrinfo transport protocol and socket type hacks X-Git-Tag: 1.1.0-ff~566 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=3adb049b4bba9e6537940a907cd50ebb52e1a278;p=vlc Remove the getaddrinfo transport protocol and socket type hacks That was meant for DCCP and UDP-Lite but it shouldn't be needed. --- diff --git a/src/network/io.c b/src/network/io.c index 554b23456c..a1923c17d8 100644 --- a/src/network/io.c +++ b/src/network/io.c @@ -158,27 +158,9 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, int i_port, int protocol) { 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 )); - /* Since we use port numbers rather than service names, the socket type - * does not really matter. */ - hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = protocol; hints.ai_flags = AI_PASSIVE; 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, 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) { msg_Dbg (p_this, "socket error: %m"); @@ -229,8 +212,8 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, { net_Close (fd); #if !defined(WIN32) && !defined(UNDER_CE) - fd = rootwrap_bind (ptr->ai_family, socktype, - protocol ? protocol : ptr->ai_protocol, + fd = rootwrap_bind (ptr->ai_family, ptr->ai_socktype, + ptr->ai_protocol, ptr->ai_addr, ptr->ai_addrlen); if (fd != -1) { @@ -254,7 +237,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, } /* Listen */ - switch (socktype) + switch (ptr->ai_socktype) { case SOCK_STREAM: case SOCK_RDM: diff --git a/src/network/tcp.c b/src/network/tcp.c index cd5fa021a5..cc4eb0aefd 100644 --- a/src/network/tcp.c +++ b/src/network/tcp.c @@ -84,7 +84,7 @@ int __net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, return -1; memset( &hints, 0, sizeof( hints ) ); - hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = proto; psz_socks = var_CreateGetNonEmptyString( p_this, "socks" ); if( psz_socks != NULL ) @@ -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 ) { int fd = net_Socket( p_this, ptr->ai_family, - type ? type : ptr->ai_socktype, - proto ? proto : ptr->ai_protocol ); + ptr->ai_socktype, ptr->ai_protocol ); if( fd == -1 ) { msg_Dbg( p_this, "socket error: %m" ); @@ -464,6 +463,8 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj, /* v4 only support ipv4 */ memset (&hints, 0, sizeof (hints)); 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 ) ) return VLC_EGENERIC; diff --git a/src/network/udp.c b/src/network/udp.c index d00b09e704..4366df23fb 100644 --- a/src/network/udp.c +++ b/src/network/udp.c @@ -142,6 +142,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port, memset (&hints, 0, sizeof( hints )); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = protocol; hints.ai_flags = AI_PASSIVE; if (host && !*host) @@ -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) { int fd = net_Socket (obj, ptr->ai_family, ptr->ai_socktype, - protocol ? protocol : ptr->ai_protocol); + ptr->ai_protocol); if (fd == -1) { 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, memset( &hints, 0, sizeof( hints ) ); hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = proto; 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, { char *str; int fd = net_Socket (p_this, ptr->ai_family, ptr->ai_socktype, - proto ? proto : ptr->ai_protocol); + ptr->ai_protocol); if (fd == -1) continue; @@ -764,6 +766,7 @@ int __net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind, memset (&hints, 0, sizeof (hints)); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = protocol; val = vlc_getaddrinfo (obj, psz_server, i_server, &hints, &rem); if (val) @@ -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) { int fd = net_Socket (obj, ptr->ai_family, ptr->ai_socktype, - protocol ? protocol : ptr->ai_protocol); + ptr->ai_protocol); if (fd == -1) continue; // usually, address family not supported