32 #if CONFIG_TLS_OPENSSL_PROTOCOL
37 #if CONFIG_TLS_GNUTLS_PROTOCOL
45 #if CONFIG_TLS_OPENSSL_PROTOCOL
48 #if CONFIG_TLS_GNUTLS_PROTOCOL
63 "network initialization. Please use "
64 "avformat_network_init(), this will "
65 "become mandatory later.\n");
67 if (WSAStartup(
MAKEWORD(1,1), &wsaData))
75 int ev = write ? POLLOUT : POLLIN;
76 struct pollfd p = { .fd = fd, .events = ev, .revents = 0 };
78 ret = poll(&p, 1, 100);
79 return ret < 0 ?
ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 :
AVERROR(EAGAIN);
85 int64_t wait_start = 0;
112 int err = WSAGetLastError();
118 case WSAEPROTONOSUPPORT:
119 return AVERROR(EPROTONOSUPPORT);
122 case WSAECONNREFUSED:
133 if (addr->sa_family == AF_INET) {
134 return IN_MULTICAST(ntohl(((
struct sockaddr_in *)addr)->sin_addr.s_addr));
136 #if HAVE_STRUCT_SOCKADDR_IN6
137 if (addr->sa_family == AF_INET6) {
157 }
while (timeout <= 0 || runs-- > 0);
171 fd = socket(af, type | SOCK_CLOEXEC, proto);
172 if (fd == -1 && errno == EINVAL)
175 fd = socket(af, type, proto);
178 if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
185 setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(
int){1},
sizeof(int));
195 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse,
sizeof(reuse))) {
198 ret = bind(fd, addr, addrlen);
211 struct pollfd lp = { fd, POLLIN, 0 };
230 if ((ret =
ff_listen(fd, addr, addrlen)) < 0)
232 if ((ret =
ff_accept(fd, timeout, h)) < 0)
242 struct pollfd p = {fd, POLLOUT, 0};
249 while ((ret = connect(fd, addr, addrlen))) {
261 optlen =
sizeof(ret);
262 if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))
270 "Connection to %s failed (%s), trying next address\n",
286 if (!strcmp(pattern,
"*"))
289 if (pattern[0] ==
'*')
291 if (pattern[0] ==
'.')
293 len_p = strlen(pattern);
294 len_h = strlen(hostname);
298 if (!strcmp(pattern, &hostname[len_h - len_p])) {
301 if (hostname[len_h - len_p - 1] ==
'.')
320 char *sep, *next =
NULL;
321 start += strspn(start,
" ,");
322 sep = start + strcspn(start,
" ,");
#define AV_LOG_WARNING
Something somehow does not look correct.
memory handling functions
static int match_host_pattern(const char *pattern, const char *hostname)
AVIOInterruptCB interrupt_callback
void ff_network_close(void)
static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout, AVIOInterruptCB *cb)
int ff_socket(int af, int type, int proto)
int ff_network_inited_globally
#define IN6_IS_ADDR_MULTICAST(a)
static double cb(void *priv, double x, double y)
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_network_init(void)
int ff_openssl_init(void)
int ff_listen(int fd, const struct sockaddr *addr, socklen_t addrlen)
Bind to a file descriptor to an address without accepting connections.
void ff_gnutls_init(void)
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.
Callback for checking whether to abort blocking functions.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_accept(int fd, int timeout, URLContext *h)
Poll for a single connection on the passed file descriptor.
const AVIOInterruptCB int_cb
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_is_multicast_address(struct sockaddr *addr)
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...
int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
int ff_socket_nonblock(int socket, int enable)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrup a blocking function associated with cb.
char * av_strdup(const char *s)
Duplicate the string s.
void ff_gnutls_deinit(void)
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
common internal api header.
char * filename
specified URL
int ff_network_wait_fd(int fd, int write)
void ff_openssl_deinit(void)
unbuffered private I/O API