2 * Copyright (c) 2007 The Libav Project
4 * This file is part of Libav.
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVFORMAT_NETWORK_H
22 #define AVFORMAT_NETWORK_H
27 #include "libavutil/error.h"
28 #include "os_support.h"
34 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
35 #define ETIMEDOUT WSAETIMEDOUT
36 #define ECONNREFUSED WSAECONNREFUSED
37 #define EINPROGRESS WSAEINPROGRESS
39 int ff_neterrno(void);
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 #include <netinet/in.h>
46 #define ff_neterrno() AVERROR(errno)
50 #include <arpa/inet.h>
57 int ff_socket_nonblock(int socket, int enable);
59 extern int ff_network_inited_globally;
60 int ff_network_init(void);
61 void ff_network_close(void);
63 void ff_tls_init(void);
64 void ff_tls_deinit(void);
66 int ff_network_wait_fd(int fd, int write);
68 int ff_inet_aton (const char * str, struct in_addr * add);
70 #if !HAVE_STRUCT_SOCKADDR_STORAGE
71 struct sockaddr_storage {
72 #if HAVE_STRUCT_SOCKADDR_SA_LEN
84 #if !HAVE_STRUCT_ADDRINFO
91 struct sockaddr *ai_addr;
93 struct addrinfo *ai_next;
97 /* getaddrinfo constants */
115 #define AI_CANONNAME 2
118 #ifndef AI_NUMERICHOST
119 #define AI_NUMERICHOST 4
126 #ifndef NI_NUMERICHOST
127 #define NI_NUMERICHOST 2
134 #ifndef NI_NUMERICSERV
135 #define NI_NUMERICSERV 8
142 #if !HAVE_GETADDRINFO
143 int ff_getaddrinfo(const char *node, const char *service,
144 const struct addrinfo *hints, struct addrinfo **res);
145 void ff_freeaddrinfo(struct addrinfo *res);
146 int ff_getnameinfo(const struct sockaddr *sa, int salen,
147 char *host, int hostlen,
148 char *serv, int servlen, int flags);
149 const char *ff_gai_strerror(int ecode);
150 #define getaddrinfo ff_getaddrinfo
151 #define freeaddrinfo ff_freeaddrinfo
152 #define getnameinfo ff_getnameinfo
153 #define gai_strerror ff_gai_strerror
156 #ifndef INET6_ADDRSTRLEN
157 #define INET6_ADDRSTRLEN INET_ADDRSTRLEN
161 #define IN_MULTICAST(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000)
163 #ifndef IN6_IS_ADDR_MULTICAST
164 #define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
167 int ff_is_multicast_address(struct sockaddr *addr);
169 #endif /* AVFORMAT_NETWORK_H */