43# define _NO_OLDNAMES 1
46# define net_errno (WSAGetLastError())
47# define net_Close(fd) ((void)closesocket((SOCKET)fd))
49# define IPV6_V6ONLY 27
51# if !defined(SHUT_RDWR)
52# define SHUT_RDWR (SD_BOTH)
53# define SHUT_WR (SD_SEND)
54# define SHUT_RD (SD_RECEIVE)
57# include <sys/socket.h>
58# include <netinet/in.h>
60# define net_errno errno
61# define net_Close(fd) ((void)vlc_close(fd))
132VLC_API ssize_t
vlc_send(
int fd,
const void *buf,
size_t buflen,
int flags);
155 const struct sockaddr *dst, socklen_t dstlen);
179#define net_Connect(a, b, c, d, e) net_Connect(VLC_OBJECT(a), b, c, d, e)
183#define net_ListenTCP(a, b, c) net_Listen(VLC_OBJECT(a), b, c, \
184 SOCK_STREAM, IPPROTO_TCP)
187#define net_ConnectTCP(a, b, c) net_ConnectTCP(VLC_OBJECT(a), b, c)
206#define net_Accept(a, b) \
207 net_Accept(VLC_OBJECT(a), b)
210#define net_ConnectDgram(a, b, c, d, e ) \
211 net_ConnectDgram(VLC_OBJECT(a), b, c, d, e)
219#define net_OpenDgram( a, b, c, d, e, g ) \
220 net_OpenDgram(VLC_OBJECT(a), b, c, d, e, g)
224 return net_OpenDgram (obj, host, port, NULL, 0, IPPROTO_UDP);
241#define net_Read(a,b,c,d) net_Read(VLC_OBJECT(a),b,c,d)
254#define net_Write(a,b,c,d) net_Write(VLC_OBJECT(a),b,c,d)
261static inline int vlc_getsockopt(
int s,
int level,
int name,
262 void *val, socklen_t *len)
264 return getsockopt(s, level,
name, (
char *)val, len);
266#define getsockopt vlc_getsockopt
268static inline int vlc_setsockopt(
int s,
int level,
int name,
269 const void *val, socklen_t len)
271 return setsockopt(s, level,
name, (
const char *)val, len);
273#define setsockopt vlc_setsockopt
278#define NI_MAXNUMERICHOST 64
280#ifndef AI_NUMERICSERV
281# define AI_NUMERICSERV 0
288# if !defined(WINAPI_FAMILY) || WINAPI_FAMILY != WINAPI_FAMILY_APP
290# define gai_strerror gai_strerrorA
296 const struct addrinfo *,
struct addrinfo **);
298 const struct addrinfo *,
struct addrinfo **);
303 switch (addr->sa_family)
308 const struct sockaddr_in *v4 = (
const struct sockaddr_in *)addr;
309 if ((
size_t)len <
sizeof (*v4))
311 return IN_MULTICAST (ntohl (v4->sin_addr.s_addr)) != 0;
315#ifdef IN6_IS_ADDR_MULTICAST
318 const struct sockaddr_in6 *v6 = (
const struct sockaddr_in6 *)addr;
319 if ((
size_t)len <
sizeof (*v6))
321 return IN6_IS_ADDR_MULTICAST (&v6->sin6_addr) != 0;
332 struct sockaddr_storage addr;
333 socklen_t addrlen =
sizeof( addr );
335 return getsockname( fd, (
struct sockaddr *)&addr, &addrlen )
343 struct sockaddr_storage addr;
344 socklen_t addrlen =
sizeof( addr );
346 return getpeername( fd, (
struct sockaddr *)&addr, &addrlen )
#define VLC_USED
Definition: fourcc_gen.c:32
#define VLC_API
Definition: fourcc_gen.c:31
#define VLC_EGENERIC
Unspecified error.
Definition: vlc_common.h:505
static bool net_SockAddrIsMulticast(const struct sockaddr *addr, socklen_t len)
Definition: vlc_network.h:302
static int net_GetPeerAddress(int fd, char *address, int *port)
Definition: vlc_network.h:342
int vlc_getaddrinfo(const char *, unsigned, const struct addrinfo *, struct addrinfo **)
Resolves a host name to a list of socket addresses (like getaddrinfo()).
Definition: getaddrinfo.c:77
char * vlc_getProxyUrl(const char *)
Determines the network proxy server to use (if any).
Definition: specific.c:342
#define NI_MAXNUMERICHOST
Definition: vlc_network.h:279
int vlc_getaddrinfo_i11e(const char *, unsigned, const struct addrinfo *, struct addrinfo **)
Definition: getaddrinfo.c:39
static int net_GetSockAddress(int fd, char *address, int *port)
Definition: vlc_network.h:331
int vlc_getnameinfo(const struct sockaddr *, int, char *, int, int *, int)
Definition: getaddrinfo.c:39
#define net_OpenDgram(a, b, c, d, e, g)
Definition: vlc_network.h:220
static int net_ListenUDP1(vlc_object_t *obj, const char *host, unsigned port)
Definition: vlc_network.h:223
#define net_Write(a, b, c, d)
Definition: vlc_network.h:255
ssize_t vlc_sendmsg(int fd, const struct msghdr *msg, int flags)
Sends a socket message.
Definition: filesystem.c:384
#define net_Accept(a, b)
Definition: vlc_network.h:207
ssize_t vlc_sendto(int fd, const void *buf, size_t buflen, int flags, const struct sockaddr *dst, socklen_t dstlen)
Sends data to a peer.
Definition: filesystem.c:378
ssize_t vlc_send(int fd, const void *buf, size_t buflen, int flags)
Sends data.
Definition: filesystem.c:373
static int net_ConnectUDP(vlc_object_t *obj, const char *host, unsigned port, int hlim)
Definition: vlc_network.h:214
int vlc_socket(int pf, int type, int proto, bool nonblock)
Creates a socket file descriptor.
Definition: filesystem.c:337
#define net_Read(a, b, c, d)
Definition: vlc_network.h:242
int * net_Listen(vlc_object_t *p_this, const char *psz_host, unsigned i_port, int socktype, int protocol)
Definition: io.c:213
int vlc_accept(int lfd, struct sockaddr *addr, socklen_t *alen, bool nonblock)
Accepts an inbound connection request on a listening socket.
Definition: filesystem.c:355
int vlc_close(int)
Closes a file descriptor.
Definition: filesystem.c:91
#define net_Connect(a, b, c, d, e)
Definition: vlc_network.h:180
void net_ListenClose(int *fd)
Definition: io.c:295
int net_SetCSCov(int fd, int sendcov, int recvcov)
net_SetCSCov: Sets the send and receive checksum coverage of a socket:
Definition: udp.c:720
int vlc_socketpair(int pf, int type, int proto, int fds[2], bool nonblock)
Creates a pair of socket file descriptors.
Definition: filesystem.c:345
#define net_ConnectDgram(a, b, c, d, e)
Definition: vlc_network.h:211
#define net_ConnectTCP(a, b, c)
Definition: vlc_network.h:188
int net_Socket(vlc_object_t *obj, int family, int socktype, int proto)
Definition: io.c:65
const char name[16]
Definition: httpd.c:1281
uint16_t i_port
Definition: keystore.c:217
VLC object common members.
Definition: vlc_objects.h:45
This file is a collection of common definitions and types.