* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#if !defined( __LIBVLC__ )
- #error You are not libvlc or one of its plugins. You cannot include this file
-#endif
-
#ifndef __VLC_NETWORK_H
# define __VLC_NETWORK_H
# define ENETUNREACH WSAENETUNREACH
# define net_errno (WSAGetLastError())
extern const char *net_strerror( int val );
+
+struct iovec
+{
+ void *iov_base;
+ size_t iov_len;
+};
+
+struct msghdr
+{
+ void *msg_name;
+ size_t msg_namelen;
+ struct iovec *msg_iov;
+ size_t msg_iovlen;
+ void *msg_control;
+ size_t msg_controllen;
+ int msg_flags;
+};
+
+#define sendmsg vlc_sendmsg
+#define recvmsg vlc_recvmsg
+
# ifndef IPV6_V6ONLY
# define IPV6_V6ONLY 27
# endif
#else
# include <sys/socket.h>
-# if HAVE_NETINET_IN_H
+# ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
# endif
-# if HAVE_ARPA_INET_H
+# ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
# elif defined( SYS_BEOS )
# include <net/netdb.h>
# define net_errno errno
#endif
+VLC_EXPORT( ssize_t, vlc_sendmsg, ( int, struct msghdr *, int ) );
+VLC_EXPORT( ssize_t, vlc_recvmsg, ( int, struct msghdr *, int ) );
+
# ifdef __cplusplus
extern "C" {
# endif
};
#define net_Read(a,b,c,d,e,f) __net_Read(VLC_OBJECT(a),b,c,d,e,f)
-VLC_EXPORT( ssize_t, __net_Read, ( vlc_object_t *p_this, int fd, const v_socket_t *, uint8_t *p_data, size_t i_data, vlc_bool_t b_retry ) );
+VLC_EXPORT( ssize_t, __net_Read, ( vlc_object_t *p_this, int fd, const v_socket_t *, uint8_t *p_data, size_t i_data, bool b_retry ) );
#define net_Write(a,b,c,d,e) __net_Write(VLC_OBJECT(a),b,c,d,e)
VLC_EXPORT( ssize_t, __net_Write, ( vlc_object_t *p_this, int fd, const v_socket_t *, const uint8_t *p_data, size_t i_data ) );
#define net_Gets(a,b,c) __net_Gets(VLC_OBJECT(a),b,c)
VLC_EXPORT( char *, __net_Gets, ( vlc_object_t *p_this, int fd, const v_socket_t * ) );
-VLC_EXPORT( ssize_t, net_Printf, ( vlc_object_t *p_this, int fd, const v_socket_t *, const char *psz_fmt, ... ) ATTRIBUTE_FORMAT( 4, 5 ) );
+VLC_EXPORT( ssize_t, net_Printf, ( vlc_object_t *p_this, int fd, const v_socket_t *, const char *psz_fmt, ... ) LIBVLC_FORMAT( 4, 5 ) );
#define net_vaPrintf(a,b,c,d,e) __net_vaPrintf(VLC_OBJECT(a),b,c,d,e)
VLC_EXPORT( ssize_t, __net_vaPrintf, ( vlc_object_t *p_this, int fd, const v_socket_t *, const char *psz_fmt, va_list args ) );
+/* Don't go to an extra call layer if we have the symbol */
#ifndef HAVE_INET_PTON
-/* only in core, so no need for C++ extern "C" */
- VLC_EXPORT (int, inet_pton, (int af, const char *src, void *dst) );
+#define inet_pton vlc_inet_pton
#endif
-
#ifndef HAVE_INET_NTOP
-#ifdef WIN32
-/* only in core, so no need for C++ extern "C" */
- VLC_EXPORT (const char *, inet_ntop, (int af, const void *src,
- char *dst, socklen_t cnt) );
-#endif
+#define inet_ntop vlc_inet_ntop
#endif
+VLC_EXPORT (int, vlc_inet_pton, (int af, const char *src, void *dst) );
+VLC_EXPORT (const char *, vlc_inet_ntop, (int af, const void *src,
+ char *dst, socklen_t cnt) );
+
#ifndef HAVE_POLL
enum
{
# define AI_NUMERICHOST 4
# endif /* if !HAVE_STRUCT_ADDRINFO */
+#ifndef AI_NUMERICSERV
+# define AI_NUMERICSERV 0
+#endif
+
VLC_EXPORT( const char *, vlc_gai_strerror, ( int ) );
VLC_EXPORT( int, vlc_getnameinfo, ( const struct sockaddr *, int, char *, int, int *, int ) );
VLC_EXPORT( int, vlc_getaddrinfo, ( vlc_object_t *, const char *, int, const struct addrinfo *, struct addrinfo ** ) );
VLC_EXPORT( void, vlc_freeaddrinfo, ( struct addrinfo * ) );
-static inline vlc_bool_t
+static inline bool
net_SockAddrIsMulticast (const struct sockaddr *addr, socklen_t len)
{
switch (addr->sa_family)
{
const struct sockaddr_in *v4 = (const struct sockaddr_in *)addr;
if ((size_t)len < sizeof (*v4))
- return VLC_FALSE;
+ return false;
return IN_MULTICAST (ntohl (v4->sin_addr.s_addr)) != 0;
}
#endif
{
const struct sockaddr_in6 *v6 = (const struct sockaddr_in6 *)addr;
if ((size_t)len < sizeof (*v6))
- return VLC_FALSE;
+ return false;
return IN6_IS_ADDR_MULTICAST (&v6->sin6_addr) != 0;
}
#endif
}
- return VLC_FALSE;
+ return false;
}