00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVFORMAT_NETWORK_H
00022 #define AVFORMAT_NETWORK_H
00023
00024 #include <errno.h>
00025
00026 #include "config.h"
00027 #include "libavutil/error.h"
00028 #include "os_support.h"
00029
00030 #if HAVE_WINSOCK2_H
00031 #include <winsock2.h>
00032 #include <ws2tcpip.h>
00033
00034 #ifdef EPROTONOSUPPORT
00035 # undef EPROTONOSUPPORT
00036 #endif
00037 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
00038 #ifdef ETIMEDOUT
00039 # undef ETIMEDOUT
00040 #endif
00041 #define ETIMEDOUT WSAETIMEDOUT
00042 #ifdef ECONNREFUSED
00043 # undef ECONNREFUSED
00044 #endif
00045 #define ECONNREFUSED WSAECONNREFUSED
00046 #ifdef EINPROGRESS
00047 # undef EINPROGRESS
00048 #endif
00049 #define EINPROGRESS WSAEINPROGRESS
00050
00051 int ff_neterrno(void);
00052 #else
00053 #include <sys/types.h>
00054 #include <sys/socket.h>
00055 #include <netinet/in.h>
00056 #include <netdb.h>
00057
00058 #define ff_neterrno() AVERROR(errno)
00059 #endif
00060
00061 #if HAVE_ARPA_INET_H
00062 #include <arpa/inet.h>
00063 #endif
00064
00065 #if HAVE_POLL_H
00066 #include <poll.h>
00067 #endif
00068
00069 int ff_socket_nonblock(int socket, int enable);
00070
00071 extern int ff_network_inited_globally;
00072 int ff_network_init(void);
00073 void ff_network_close(void);
00074
00075 void ff_tls_init(void);
00076 void ff_tls_deinit(void);
00077
00078 int ff_network_wait_fd(int fd, int write);
00079
00080 int ff_inet_aton (const char * str, struct in_addr * add);
00081
00082 #if !HAVE_STRUCT_SOCKADDR_STORAGE
00083 struct sockaddr_storage {
00084 #if HAVE_STRUCT_SOCKADDR_SA_LEN
00085 uint8_t ss_len;
00086 uint8_t ss_family;
00087 #else
00088 uint16_t ss_family;
00089 #endif
00090 char ss_pad1[6];
00091 int64_t ss_align;
00092 char ss_pad2[112];
00093 };
00094 #endif
00095
00096 #if !HAVE_STRUCT_ADDRINFO
00097 struct addrinfo {
00098 int ai_flags;
00099 int ai_family;
00100 int ai_socktype;
00101 int ai_protocol;
00102 int ai_addrlen;
00103 struct sockaddr *ai_addr;
00104 char *ai_canonname;
00105 struct addrinfo *ai_next;
00106 };
00107 #endif
00108
00109
00110 #ifndef EAI_FAIL
00111 #define EAI_FAIL 4
00112 #endif
00113
00114 #ifndef EAI_FAMILY
00115 #define EAI_FAMILY 5
00116 #endif
00117
00118 #ifndef EAI_NONAME
00119 #define EAI_NONAME 8
00120 #endif
00121
00122 #ifndef AI_PASSIVE
00123 #define AI_PASSIVE 1
00124 #endif
00125
00126 #ifndef AI_CANONNAME
00127 #define AI_CANONNAME 2
00128 #endif
00129
00130 #ifndef AI_NUMERICHOST
00131 #define AI_NUMERICHOST 4
00132 #endif
00133
00134 #ifndef NI_NOFQDN
00135 #define NI_NOFQDN 1
00136 #endif
00137
00138 #ifndef NI_NUMERICHOST
00139 #define NI_NUMERICHOST 2
00140 #endif
00141
00142 #ifndef NI_NAMERQD
00143 #define NI_NAMERQD 4
00144 #endif
00145
00146 #ifndef NI_NUMERICSERV
00147 #define NI_NUMERICSERV 8
00148 #endif
00149
00150 #ifndef NI_DGRAM
00151 #define NI_DGRAM 16
00152 #endif
00153
00154 #if !HAVE_GETADDRINFO
00155 int ff_getaddrinfo(const char *node, const char *service,
00156 const struct addrinfo *hints, struct addrinfo **res);
00157 void ff_freeaddrinfo(struct addrinfo *res);
00158 int ff_getnameinfo(const struct sockaddr *sa, int salen,
00159 char *host, int hostlen,
00160 char *serv, int servlen, int flags);
00161 const char *ff_gai_strerror(int ecode);
00162 #define getaddrinfo ff_getaddrinfo
00163 #define freeaddrinfo ff_freeaddrinfo
00164 #define getnameinfo ff_getnameinfo
00165 #define gai_strerror ff_gai_strerror
00166 #endif
00167
00168 #ifndef INET6_ADDRSTRLEN
00169 #define INET6_ADDRSTRLEN INET_ADDRSTRLEN
00170 #endif
00171
00172 #ifndef IN_MULTICAST
00173 #define IN_MULTICAST(a) ((((uint32_t)(a)) & 0xf0000000) == 0xe0000000)
00174 #endif
00175 #ifndef IN6_IS_ADDR_MULTICAST
00176 #define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
00177 #endif
00178
00179 int ff_is_multicast_address(struct sockaddr *addr);
00180
00181 #endif