#endif
VLC_API int vlc_getnameinfo( const struct sockaddr *, int, char *, int, int *, int );
-VLC_API int vlc_getaddrinfo (vlc_object_t *, const char *, unsigned,
+VLC_API int vlc_getaddrinfo (const char *, unsigned,
const struct addrinfo *, struct addrinfo **);
socklen_t srclen = 0, dstlen = 0;
struct addrinfo *res;
- if (!vlc_getaddrinfo ( VLC_OBJECT(p_stream), dhost, dport, &hints, &res))
+ if (!vlc_getaddrinfo (dhost, dport, &hints, &res))
{
memcpy (&dst, res->ai_addr, dstlen = res->ai_addrlen);
freeaddrinfo (res);
}
- if (!vlc_getaddrinfo ( VLC_OBJECT(p_stream), shost, sport, &hints, &res))
+ if (!vlc_getaddrinfo (shost, sport, &hints, &res))
{
memcpy (&src, res->ai_addr, srclen = res->ai_addrlen);
freeaddrinfo (res);
/**
* Resolves a host name to a list of socket addresses (like getaddrinfo()).
*
- * @param p_this a VLC object
* @param node host name to resolve (encoded as UTF-8), or NULL
* @param i_port port number for the socket addresses
* @param p_hints parameters (see getaddrinfo() manual page)
* On failure, *res is undefined. On success, it must be freed with
* freeaddrinfo().
*/
-int vlc_getaddrinfo (vlc_object_t *p_this, const char *node,
- unsigned port, const struct addrinfo *p_hints,
- struct addrinfo **res)
+int vlc_getaddrinfo (const char *node, unsigned port,
+ const struct addrinfo *p_hints, struct addrinfo **res)
{
struct addrinfo hints;
char psz_buf[NI_MAXHOST], portbuf[6], *servname;
if (port != 0)
{
if (port > 65535)
- {
- msg_Err (p_this, "invalid port number %u specified", port);
return EAI_SERVICE;
- }
/* cannot overflow */
snprintf (portbuf, sizeof (portbuf), "%u", port);
servname = portbuf;
msg_Dbg (p_this, "net: listening to %s port %d",
(psz_host != NULL) ? psz_host : "*", i_port);
- int i_val = vlc_getaddrinfo (p_this, psz_host, i_port, &hints, &res);
+ int i_val = vlc_getaddrinfo (psz_host, i_port, &hints, &res);
if (i_val)
{
msg_Err (p_this, "Cannot resolve %s port %d : %s",
struct addrinfo hints, *res, *ptr;
const char *psz_realhost;
char *psz_socks;
- int i_realport, i_val, i_handle = -1;
+ int i_realport, i_handle = -1;
int evfd = vlc_object_waitpipe (p_this);
if (evfd == -1)
i_realport );
}
- i_val = vlc_getaddrinfo( p_this, psz_realhost, i_realport, &hints, &res );
+ int val = vlc_getaddrinfo (psz_realhost, i_realport, &hints, &res);
free( psz_socks );
- if( i_val )
+ if (val)
{
- msg_Err( p_this, "cannot resolve %s port %d : %s", psz_realhost,
- i_realport, gai_strerror( i_val ) );
+ msg_Err (p_this, "cannot resolve %s port %d : %s", psz_realhost,
+ i_realport, gai_strerror (val));
return -1;
}
if( i_socks_version == 4 )
{
- struct addrinfo hints, *p_res;
+ struct addrinfo hints, *res;
/* 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 ) )
+ if (vlc_getaddrinfo (psz_host, 0, &hints, &res))
return VLC_EGENERIC;
buffer[0] = i_socks_version;
buffer[1] = 0x01; /* CONNECT */
SetWBE( &buffer[2], i_port ); /* Port */
- memcpy( &buffer[4], /* Address */
- &((struct sockaddr_in *)(p_res->ai_addr))->sin_addr, 4 );
- freeaddrinfo( p_res );
+ memcpy (&buffer[4], /* Address */
+ &((struct sockaddr_in *)(res->ai_addr))->sin_addr, 4);
+ freeaddrinfo (res);
buffer[8] = 0; /* Empty user id */
msg_Dbg (obj, "net: opening %s datagram port %d",
host ? host : "any", port);
- int val = vlc_getaddrinfo (obj, host, port, &hints, &res);
+ int val = vlc_getaddrinfo (host, port, &hints, &res);
if (val)
{
msg_Err (obj, "Cannot resolve %s port %d : %s", host, port,
int i_hlim, int proto )
{
struct addrinfo hints, *res, *ptr;
- int i_val, i_handle = -1;
+ int i_handle = -1;
bool b_unreach = false;
if( i_hlim < 0 )
msg_Dbg( p_this, "net: connecting to [%s]:%d", psz_host, i_port );
- i_val = vlc_getaddrinfo( p_this, psz_host, i_port, &hints, &res );
- if( i_val )
+ int val = vlc_getaddrinfo (psz_host, i_port, &hints, &res);
+ if (val)
{
- msg_Err( p_this, "cannot resolve [%s]:%d : %s", psz_host, i_port,
- gai_strerror( i_val ) );
+ msg_Err (p_this, "cannot resolve [%s]:%d : %s", psz_host, i_port,
+ gai_strerror (val));
return -1;
}
psz_server, i_server, psz_bind, i_bind);
struct addrinfo hints, *loc, *rem;
- int val;
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = protocol;
- val = vlc_getaddrinfo (obj, psz_server, i_server, &hints, &rem);
+ int val = vlc_getaddrinfo (psz_server, i_server, &hints, &rem);
if (val)
{
msg_Err (obj, "cannot resolve %s port %d : %s", psz_bind, i_bind,
}
hints.ai_flags = AI_PASSIVE;
- val = vlc_getaddrinfo (obj, psz_bind, i_bind, &hints, &loc);
+ val = vlc_getaddrinfo (psz_bind, i_bind, &hints, &loc);
if (val)
{
msg_Err (obj, "cannot resolve %s port %d : %s", psz_bind, i_bind,
/* GRUIK. We should not convert back-and-forth from string to numbers */
struct addrinfo *res;
- if (vlc_getaddrinfo (obj, psz_dst, 0, NULL, &res) == 0)
+ if (vlc_getaddrinfo (psz_dst, 0, NULL, &res) == 0)
{
if (res->ai_addrlen <= sizeof (p_session->addr))
memcpy (&p_session->addr, res->ai_addr,