2 * Copyright (c) 2007 The FFmpeg Project
4 * This file is part of FFmpeg.
6 * FFmpeg 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 * FFmpeg 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 FFmpeg; 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 #ifdef EPROTONOSUPPORT
35 # undef EPROTONOSUPPORT
37 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
41 #define ETIMEDOUT WSAETIMEDOUT
45 #define ECONNREFUSED WSAECONNREFUSED
49 #define EINPROGRESS WSAEINPROGRESS
51 int ff_neterrno(void);
53 #include <sys/types.h>
54 #include <sys/socket.h>
55 #include <netinet/in.h>
58 #define ff_neterrno() AVERROR(errno)
62 #include <arpa/inet.h>
69 int ff_socket_nonblock(int socket, int enable);
71 extern int ff_network_inited_globally;
72 int ff_network_init(void);
73 void ff_network_close(void);
75 void ff_tls_init(void);
76 void ff_tls_deinit(void);
78 int ff_network_wait_fd(int fd, int write);
80 int ff_inet_aton (const char * str, struct in_addr * add);
82 #if !HAVE_STRUCT_SOCKADDR_STORAGE
83 struct sockaddr_storage {
84 #if HAVE_STRUCT_SOCKADDR_SA_LEN
96 #if !HAVE_STRUCT_ADDRINFO
103 struct sockaddr *ai_addr;
105 struct addrinfo *ai_next;
109 /* getaddrinfo constants */
127 #define AI_CANONNAME 2
130 #ifndef AI_NUMERICHOST
131 #define AI_NUMERICHOST 4
138 #ifndef NI_NUMERICHOST
139 #define NI_NUMERICHOST 2
146 #ifndef NI_NUMERICSERV
147 #define NI_NUMERICSERV 8
154 #if !HAVE_GETADDRINFO
155 int ff_getaddrinfo(const char *node, const char *service,
156 const struct addrinfo *hints, struct addrinfo **res);
157 void ff_freeaddrinfo(struct addrinfo *res);
158 int ff_getnameinfo(const struct sockaddr *sa, int salen,
159 char *host, int hostlen,
160 char *serv, int servlen, int flags);
161 const char *ff_gai_strerror(int ecode);
162 #define getaddrinfo ff_getaddrinfo
163 #define freeaddrinfo ff_freeaddrinfo
164 #define getnameinfo ff_getnameinfo
165 #define gai_strerror ff_gai_strerror
168 #ifndef INET6_ADDRSTRLEN
169 #define INET6_ADDRSTRLEN INET_ADDRSTRLEN
173 #define IN_MULTICAST(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000)
175 #ifndef IN6_IS_ADDR_MULTICAST
176 #define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
179 int ff_is_multicast_address(struct sockaddr *addr);
181 #endif /* AVFORMAT_NETWORK_H */