mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Work better with platforms that do not have ipv6 structures, or that do not have sin_len fields, etc.
svn:r986
This commit is contained in:
parent
135591aeab
commit
980bcd68f7
@ -86,7 +86,7 @@ CORE_SRC = event.c buffer.c evbuffer-internal.h bufferevent.c \
|
||||
log.c evutil.c $(SYS_SRC)
|
||||
EXTRA_SRC = event_tagging.c http.c evhttp.h http-internal.h evdns.c \
|
||||
evdns.h evrpc.c evrpc.h evrpc-internal.h mm-internal.h \
|
||||
strlcpy.c strlcpy-internal.h strlcpy-internal.h
|
||||
strlcpy.c strlcpy-internal.h strlcpy-internal.h ipv6-internal.h
|
||||
|
||||
libevent_la_SOURCES = $(CORE_SRC) $(EXTRA_SRC)
|
||||
libevent_la_LIBADD = @LTLIBOBJS@ $(SYS_LIBS)
|
||||
|
51
configure.in
51
configure.in
@ -53,7 +53,7 @@ AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" != "no"])
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h stdarg.h inttypes.h stdint.h stddef.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/param.h sys/ioctl.h sys/select.h sys/devpoll.h port.h netinet/in6.h sys/socket.h sys/uio.h arpa/inet.h)
|
||||
AC_CHECK_HEADERS(fcntl.h stdarg.h inttypes.h stdint.h stddef.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/param.h sys/ioctl.h sys/select.h sys/devpoll.h port.h netinet/in.h netinet/in6.h sys/socket.h sys/uio.h arpa/inet.h)
|
||||
if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
|
||||
AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
|
||||
AC_EGREP_CPP(yes,
|
||||
@ -326,17 +326,52 @@ AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(int)
|
||||
AC_CHECK_SIZEOF(short)
|
||||
|
||||
AC_CHECK_TYPES([struct in6_addr], , ,
|
||||
[#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t], , ,
|
||||
[#include <sys/types.h>
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN6_H
|
||||
#include <netinet/in6.h>
|
||||
#endif])
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#define WIN32_WINNT 0x400
|
||||
#define _WIN32_WINNT 0x400
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1300)
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
#endif
|
||||
])
|
||||
AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len], , ,
|
||||
[#include <sys/types.h>
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN6_H
|
||||
#include <netinet/in6.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#define WIN32_WINNT 0x400
|
||||
#define _WIN32_WINNT 0x400
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1300)
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
#endif
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([for socklen_t])
|
||||
AC_TRY_COMPILE([
|
||||
|
7
evdns.c
7
evdns.c
@ -104,6 +104,7 @@
|
||||
#include "log.h"
|
||||
#include "mm-internal.h"
|
||||
#include "strlcpy-internal.h"
|
||||
#include "ipv6-internal.h"
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
@ -187,12 +188,6 @@ struct evdns_request {
|
||||
struct evdns_base *base;
|
||||
};
|
||||
|
||||
#ifndef HAVE_STRUCT_IN6_ADDR
|
||||
struct in6_addr {
|
||||
u8 s6_addr[16];
|
||||
};
|
||||
#endif
|
||||
|
||||
struct reply {
|
||||
unsigned int type;
|
||||
unsigned int have_answer;
|
||||
|
5
evutil.c
5
evutil.c
@ -68,6 +68,7 @@
|
||||
#include "log.h"
|
||||
|
||||
#include "strlcpy-internal.h"
|
||||
#include "ipv6-internal.h"
|
||||
|
||||
int
|
||||
evutil_socketpair(int family, int type, int protocol, evutil_socket_t fd[2])
|
||||
@ -634,7 +635,9 @@ evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int o
|
||||
if (is_ipv6) {
|
||||
struct sockaddr_in6 sin6;
|
||||
memset(&sin6, 0, sizeof(sin6));
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
|
||||
sin6.sin6_len = sizeof(sin6);
|
||||
#endif
|
||||
sin6.sin6_family = AF_INET6;
|
||||
sin6.sin6_port = htons(port);
|
||||
if (1 != evutil_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr))
|
||||
@ -647,7 +650,9 @@ evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int o
|
||||
} else {
|
||||
struct sockaddr_in sin;
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
|
||||
sin.sin_len = sizeof(sin);
|
||||
#endif
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(port);
|
||||
if (1 != evutil_inet_pton(AF_INET, addr_part, &sin.sin_addr))
|
||||
|
37
ipv6-internal.h
Normal file
37
ipv6-internal.h
Normal file
@ -0,0 +1,37 @@
|
||||
/* Internal use only: Fake IPv6 structures and values on platforms that
|
||||
* do not have them */
|
||||
|
||||
#ifndef _EVENT_IPV6_INTERNAL_H
|
||||
#define _EVENT_IPV6_INTERNAL_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "event-config.h"
|
||||
#include <event2/util.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _EVENT_HAVE_STRUCT_IN6_ADDR
|
||||
struct in6_addr {
|
||||
ev_uint8_t s6_addr[16];
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef _EVENT_HAVE_SA_FAMILY_T
|
||||
typedef int sa_family_t
|
||||
#endif
|
||||
|
||||
#ifndef _EVENT_HAVE_STRUCT_SOCKADDR_IN6
|
||||
struct sockaddr_in6 {
|
||||
sa_family_t sin6_family;
|
||||
ev_uint16_t sin6_port;
|
||||
struct in6_addr sin6_addr;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -47,6 +47,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "event2/util.h"
|
||||
#include "../ipv6-internal.h"
|
||||
|
||||
void util_suite(void);
|
||||
|
||||
@ -259,7 +260,9 @@ regress_sockaddr_port_parse(void)
|
||||
if (ent->sa_family == AF_INET) {
|
||||
struct sockaddr_in sin;
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
|
||||
sin.sin_len = sizeof(sin);
|
||||
#endif
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(ent->port);
|
||||
r = evutil_inet_pton(AF_INET, ent->addr, &sin.sin_addr);
|
||||
@ -273,7 +276,9 @@ regress_sockaddr_port_parse(void)
|
||||
} else {
|
||||
struct sockaddr_in6 sin6;
|
||||
memset(&sin6, 0, sizeof(sin6));
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
|
||||
sin6.sin6_len = sizeof(sin6);
|
||||
#endif
|
||||
sin6.sin6_family = AF_INET6;
|
||||
sin6.sin6_port = htons(ent->port);
|
||||
r = evutil_inet_pton(AF_INET6, ent->addr, &sin6.sin6_addr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user