21#ifndef AVFORMAT_NETWORK_H
22#define AVFORMAT_NETWORK_H
42#ifndef EPROTONOSUPPORT
43#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
46#define ETIMEDOUT WSAETIMEDOUT
49#define ECONNREFUSED WSAECONNREFUSED
52#define EINPROGRESS WSAEINPROGRESS
55#define ENOTCONN WSAENOTCONN
58#define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e)
59#define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e)
64#include <sys/socket.h>
65#include <netinet/in.h>
66#include <netinet/tcp.h>
69#define ff_neterrno() AVERROR(errno)
173#if !HAVE_STRUCT_SOCKADDR_STORAGE
175#if HAVE_STRUCT_SOCKADDR_SA_LEN
189 struct sockaddr_in
in;
190#if HAVE_STRUCT_SOCKADDR_IN6
191 struct sockaddr_in6 in6;
196#define MSG_NOSIGNAL 0
199#if !HAVE_STRUCT_ADDRINFO
217#define EAI_BADFLAGS 3
238#define EAI_SOCKTYPE 10
246#define AI_CANONNAME 2
249#ifndef AI_NUMERICHOST
250#define AI_NUMERICHOST 4
257#ifndef NI_NUMERICHOST
258#define NI_NUMERICHOST 2
265#ifndef NI_NUMERICSERV
266#define NI_NUMERICSERV 8
278 char *
host,
int hostlen,
279 char *serv,
int servlen,
int flags);
280#define getaddrinfo ff_getaddrinfo
281#define freeaddrinfo ff_freeaddrinfo
282#define getnameinfo ff_getnameinfo
285#if !HAVE_GETADDRINFO || HAVE_WINSOCK2_H
288#define gai_strerror ff_gai_strerror
291#ifndef INADDR_LOOPBACK
292#define INADDR_LOOPBACK 0x7f000001
295#ifndef INET_ADDRSTRLEN
296#define INET_ADDRSTRLEN 16
299#ifndef INET6_ADDRSTRLEN
300#define INET6_ADDRSTRLEN INET_ADDRSTRLEN
304#define IN_MULTICAST(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000)
306#ifndef IN6_IS_ADDR_MULTICAST
307#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
312#define POLLING_TIME 100
327 socklen_t addrlen,
int timeout,
337int ff_listen(
int fd,
const struct sockaddr *addr, socklen_t addrlen,
367 socklen_t addrlen,
int timeout,
372int ff_socket(
int domain,
int type,
int protocol,
void *logctx);
402 int (*
customize_fd)(
void *,
int,
int),
void *customize_ctx);
static AVFormatContext * ctx
#define flags(name, subs,...)
const AVIOInterruptCB int_cb
int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address, int parallel, URLContext *h, int *fd, int(*customize_fd)(void *, int, int), void *customize_ctx)
Connect to any of the given addrinfo addresses, with multiple attempts running in parallel.
int ff_is_multicast_address(struct sockaddr *addr)
int ff_socket_nonblock(int socket, int enable)
int ff_socket(int domain, int type, int protocol, void *logctx)
int ff_network_wakeup_open(FFNetWakeup *w)
Create a wakeup channel.
int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb)
Waits for up to 'timeout' microseconds.
int ff_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen, void *logctx)
Bind to a file descriptor to an address without accepting connections.
void ff_log_net_error(void *ctx, int level, const char *prefix)
int ff_listen_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h, int will_try_next)
Connect to a file descriptor and poll for result.
int ff_network_wakeup_signal(FFNetWakeup *w)
Wake the thread blocked in ff_network_wait_fd_wakeup() on this channel, or the next one that waits on...
void ff_network_wakeup_close(FFNetWakeup *w)
Close the channel.
void ff_freeaddrinfo(struct addrinfo *res)
int ff_listen_bind(int fd, const struct sockaddr *addr, socklen_t addrlen, int timeout, URLContext *h)
Bind to a file descriptor and poll for a connection.
int ff_getnameinfo(const struct sockaddr *sa, int salen, char *host, int hostlen, char *serv, int servlen, int flags)
int ff_network_wait_fd(int fd, int write)
int ff_network_init(void)
Initialize the network subsystem.
int ff_udp_set_remote_addr(URLContext *h, const struct sockaddr *dest_addr, socklen_t dest_addr_len, int do_connect)
This function is identical to ff_udp_set_remote_url, except that it takes a sockaddr directly.
void ff_udp_get_last_recv_addr(URLContext *h, struct sockaddr_storage *addr, socklen_t *addr_len)
int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb)
This works similarly to ff_network_wait_fd, but waits up to 'timeout' microseconds Uses ff_network_wa...
void ff_network_close(void)
int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
int ff_network_wait_fd_wakeup(int fd, int write, int timeout_ms, const FFNetWakeup *w)
Like ff_network_wait_fd(), but also returns as soon as the wakeup channel is signaled,...
int ff_accept(int fd, int timeout, URLContext *h)
Poll for a single connection on the passed file descriptor.
const char * ff_gai_strerror(int ecode)
miscellaneous OS support macros and functions.
Callback for checking whether to abort blocking functions.
A channel for waking a thread that is blocked in ff_network_wait_fd_wakeup(), from another thread.
struct sockaddr * ai_addr
struct addrinfo * ai_next
static int customize_fd(void *ctx, int fd, int family)
struct sockaddr_storage storage
unbuffered private I/O API