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

Inline net_GetAddress

parent 61696fdb
...@@ -356,9 +356,6 @@ VLC_EXPORT( int, net_Printf, ( vlc_object_t *p_this, int fd, v_socket_t *, const ...@@ -356,9 +356,6 @@ VLC_EXPORT( int, net_Printf, ( vlc_object_t *p_this, int fd, v_socket_t *, const
#define net_vaPrintf(a,b,c,d,e) __net_vaPrintf(VLC_OBJECT(a),b,c,d,e) #define net_vaPrintf(a,b,c,d,e) __net_vaPrintf(VLC_OBJECT(a),b,c,d,e)
VLC_EXPORT( int, __net_vaPrintf, ( vlc_object_t *p_this, int fd, v_socket_t *, const char *psz_fmt, va_list args ) ); VLC_EXPORT( int, __net_vaPrintf, ( vlc_object_t *p_this, int fd, v_socket_t *, const char *psz_fmt, va_list args ) );
#define net_GetSockAddress(a,b,c,d) __net_GetAddress(VLC_OBJECT(a),VLC_FALSE,b,c,d)
#define net_GetPeerAddress(a,b,c,d) __net_GetAddress(VLC_OBJECT(a),VLC_TRUE,b,c,d)
VLC_EXPORT( int, __net_GetAddress, ( vlc_object_t *p_this, vlc_bool_t peer, int fd, char *address, int *port ) );
#if !HAVE_INET_PTON #if !HAVE_INET_PTON
/* only in core, so no need for C++ extern "C" */ /* only in core, so no need for C++ extern "C" */
...@@ -508,4 +505,37 @@ static inline vlc_bool_t net_AddressIsMulticast( vlc_object_t *p_object, char *p ...@@ -508,4 +505,37 @@ static inline vlc_bool_t net_AddressIsMulticast( vlc_object_t *p_object, char *p
return b_multicast; return b_multicast;
} }
#define net_GetSockAddress(a,b,c,d) __net_GetAddress(VLC_OBJECT(a),VLC_FALSE,b,c,d)
#define net_GetPeerAddress(a,b,c,d) __net_GetAddress(VLC_OBJECT(a),VLC_TRUE,b,c,d)
static inline int __net_GetAddress( vlc_object_t *p_this, vlc_bool_t peer, int fd,
char *address, int *port )
{
struct sockaddr_storage addr;
socklen_t addrlen = sizeof( addr );
int val;
val = peer ? getpeername( fd, (struct sockaddr *)&addr, &addrlen )
: getsockname( fd, (struct sockaddr *)&addr, &addrlen );
if (val)
{
#if defined(WIN32) || defined (UNDER_CE)
msg_Err( p_this, "socket address error : %d", WSAGetLastError( ) );
#else
msg_Err( p_this, "socket address error : %s", strerror( errno ) );
#endif
return val;
}
val = vlc_getnameinfo( (struct sockaddr *)&addr, addrlen,
address, NI_MAXNUMERICHOST, port, NI_NUMERICHOST );
if( val )
{
msg_Err( p_this, "socket address error : %s",
vlc_gai_strerror( val ) );
}
return 0;
}
#endif #endif
...@@ -382,7 +382,6 @@ struct module_symbols_t ...@@ -382,7 +382,6 @@ struct module_symbols_t
int (*ACL_LoadFile_inner) (vlc_acl_t *p_acl, const char *path); int (*ACL_LoadFile_inner) (vlc_acl_t *p_acl, const char *path);
int (*ACL_AddNet_inner) (vlc_acl_t *p_acl, const char *psz_ip, int i_len, vlc_bool_t b_allow); int (*ACL_AddNet_inner) (vlc_acl_t *p_acl, const char *psz_ip, int i_len, vlc_bool_t b_allow);
void (*ACL_Destroy_inner) (vlc_acl_t *p_acl); void (*ACL_Destroy_inner) (vlc_acl_t *p_acl);
int (*__net_GetAddress_inner) (vlc_object_t *p_this, vlc_bool_t peer, int fd, char *address, int *port);
}; };
# if defined (__PLUGIN__) # if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...@@ -750,7 +749,6 @@ struct module_symbols_t ...@@ -750,7 +749,6 @@ struct module_symbols_t
# define ACL_LoadFile (p_symbols)->ACL_LoadFile_inner # define ACL_LoadFile (p_symbols)->ACL_LoadFile_inner
# define ACL_AddNet (p_symbols)->ACL_AddNet_inner # define ACL_AddNet (p_symbols)->ACL_AddNet_inner
# define ACL_Destroy (p_symbols)->ACL_Destroy_inner # define ACL_Destroy (p_symbols)->ACL_Destroy_inner
# define __net_GetAddress (p_symbols)->__net_GetAddress_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/****************************************************************** /******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...@@ -1121,7 +1119,6 @@ struct module_symbols_t ...@@ -1121,7 +1119,6 @@ struct module_symbols_t
((p_symbols)->ACL_LoadFile_inner) = ACL_LoadFile; \ ((p_symbols)->ACL_LoadFile_inner) = ACL_LoadFile; \
((p_symbols)->ACL_AddNet_inner) = ACL_AddNet; \ ((p_symbols)->ACL_AddNet_inner) = ACL_AddNet; \
((p_symbols)->ACL_Destroy_inner) = ACL_Destroy; \ ((p_symbols)->ACL_Destroy_inner) = ACL_Destroy; \
((p_symbols)->__net_GetAddress_inner) = __net_GetAddress; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \
# endif /* __PLUGIN__ */ # endif /* __PLUGIN__ */
......
...@@ -1156,36 +1156,6 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj, ...@@ -1156,36 +1156,6 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
int __net_GetAddress( vlc_object_t *p_this, vlc_bool_t peer, int fd,
char *address, int *port )
{
struct sockaddr_storage addr;
socklen_t addrlen = sizeof( addr );
int val;
val = peer ? getpeername( fd, (struct sockaddr *)&addr, &addrlen )
: getsockname( fd, (struct sockaddr *)&addr, &addrlen );
if (val)
{
#if defined(WIN32) || defined (UNDER_CE)
msg_Err( p_this, "socket address error : %d", WSAGetLastError( ) );
#else
msg_Err( p_this, "socket address error : %s", strerror( errno ) );
#endif
return val;
}
val = vlc_getnameinfo( (struct sockaddr *)&addr, addrlen,
address, NI_MAXNUMERICHOST, port, NI_NUMERICHOST );
if( val )
{
msg_Err( p_this, "socket address error : %s",
vlc_gai_strerror( val ) );
}
return 0;
}
/***************************************************************************** /*****************************************************************************
* inet_pton replacement for obsolete and/or crap operating systems * inet_pton replacement for obsolete and/or crap operating systems
*****************************************************************************/ *****************************************************************************/
......
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