diff --git a/CHANGES b/CHANGES index 80ac1f2..7ddfcbe 100644 --- a/CHANGES +++ b/CHANGES @@ -100,6 +100,10 @@ Features: confirm option ipv6-v6only). Added option ai-passive to control this flag explicitely. + New option ai-v4mapped (v4mapped) sets or unsets the AI_V4MAPPED flag + of the resolver. For Socat addresses requiring IPv6 addresses, this + resolves IPv4 addresses to the approriate IPv6 address [::ffff:*:*]. + Corrections: When a sub process (EXEC, SYSTEM) terminated with exit code other than 0, its last sent data might have been lost depending on timing of read/ diff --git a/VERSION b/VERSION index 576e205..ceaf471 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -"1.7.4.5+conn-over" +"1.7.4.5+" diff --git a/doc/socat.yo b/doc/socat.yo index 909fd77..cae5c97 100644 --- a/doc/socat.yo +++ b/doc/socat.yo @@ -2243,12 +2243,20 @@ dit(bf(tt(ip-transparent))) label(OPTION_AI_ADDRCONFIG) dit(bf(tt(ai-addrconfig[=0|1]))), dit(bf(tt(addrconfig[=0|1]))) Sets or unsets the AI_ADDRCONFIG flag to prevent name resolution to address - families that are not configured (e.g. IPv6). Default value is 1 in case the - resolver does not get an address family hint from Socat address or defaults. + families that are not available on the computer (e.g. IPv6). Default value + is 1 in case the resolver does not get an address family hint from Socat + address or defaults. +label(OPTION_AI_PASSIVE) dit(bf(tt(ai-passive[=0|1]))), dit(bf(tt(passive[=0|1]))) - Sets of unsets the AI_ADDRCONFIG flag for code(getaddrinfo)) calls. Default - is 1 for LISTEN, RECV, and RECVFROM type addresses, and with + Sets of unsets the AI_ADDRCONFIG flag for code(getaddrinfo()) calls. + Default is 1 for LISTEN, RECV, and RECVFROM type addresses, and with link(bind)(OPTION_BIND) option. +label(OPTION_AI_V4MAPPED) +dit(bf(tt(ai-v4mapped[=0|1]))), dit(bf(tt(v4mapped[=0|1]))) + Sets or unsets the AI_V4MAPPED flag for code(getaddrinfo()). With socat() + addresses requiring IPv6 addresses, this resolves IPv4 addresses to the + approriate IPv6 address [::ffff:*:*]. For IPv6 Socat addresses, the default + is 1. label(OPTION_RES_DEBUG)dit(bf(tt(res-debug))) label(OPTION_RES_AAONLY)dit(bf(tt(res-aaonly))) label(OPTION_RES_USEVC)dit(bf(tt(res-usevc))) diff --git a/xio-ip.c b/xio-ip.c index fb6c1bc..b42ee56 100644 --- a/xio-ip.c +++ b/xio-ip.c @@ -83,6 +83,7 @@ const struct optdesc opt_ip_recvif = { "ip-recvif", "recvdstaddrif",OPT_IP_RECVI #ifdef AI_ADDRCONFIG const struct optdesc opt_ai_addrconfig = { "ai-addrconfig", "addrconfig", OPT_AI_ADDRCONFIG, GROUP_SOCK_IP, PH_INIT, TYPE_BOOL, OFUNC_OFFSET_MASKS, XIO_OFFSETOF(para.socket.ip.ai_flags), XIO_SIZEOF(para.socket.ip.ai_flags), AI_ADDRCONFIG }; +const struct optdesc opt_ai_v4mapped = { "ai-v4mapped", "v4mapped", OPT_AI_V4MAPPED, GROUP_SOCK_IP, PH_INIT, TYPE_BOOL, OFUNC_OFFSET_MASKS, XIO_OFFSETOF(para.socket.ip.ai_flags), XIO_SIZEOF(para.socket.ip.ai_flags), AI_V4MAPPED }; #endif #ifdef AI_PASSIVE const struct optdesc opt_ai_passive = { "ai-passive", "passive", OPT_AI_PASSIVE, GROUP_SOCK_IP, PH_INIT, TYPE_BOOL, OFUNC_OFFSET_MASKS, XIO_OFFSETOF(para.socket.ip.ai_flags), XIO_SIZEOF(para.socket.ip.ai_flags), AI_PASSIVE }; @@ -227,7 +228,6 @@ int xiogetaddrinfo(const char *node, const char *service, } if (family == 0) hints.ai_flags |= AI_ADDRCONFIG; - hints.ai_flags |= AI_PASSIVE /* important for IPv4+IPv6 listen */; #if HAVE_GETADDRINFO if (node != NULL || service != NULL) { struct addrinfo *record; @@ -461,7 +461,6 @@ int xioresolve(const char *node, const char *service, if (ai_flags[0] & AI_PASSIVE && family == PF_UNSPEC) { /* We select the first IPv6 address, if available, because this might accept IPv4 connections too */ - struct addrinfo *aip = res; while (aip != NULL) { if (aip->ai_family == PF_INET6) break; diff --git a/xio-ip.h b/xio-ip.h index 4c63f7a..9695ba9 100644 --- a/xio-ip.h +++ b/xio-ip.h @@ -31,6 +31,7 @@ extern const struct optdesc opt_ip_transparent; extern const struct optdesc opt_ai_addrconfig; extern const struct optdesc opt_ai_passive; +extern const struct optdesc opt_ai_v4mapped; extern const struct optdesc opt_res_debug; extern const struct optdesc opt_res_aaonly; diff --git a/xio-ipapp.c b/xio-ipapp.c index 3c671da..ac71f2e 100644 --- a/xio-ipapp.c +++ b/xio-ipapp.c @@ -36,10 +36,9 @@ int xioopen_ipapp_connect(int argc, const char *argv[], struct opt *opts, bool needbind = false; bool lowport = false; int level; - int result; - struct addrinfo **ai_sorted; int i; + int result; if (argc != 3) { Error2("%s: wrong number of parameters (%d instead of 2)", argv[0], argc-1); diff --git a/xio-udp.c b/xio-udp.c index a6e31b2..73f0dc8 100644 --- a/xio-udp.c +++ b/xio-udp.c @@ -354,7 +354,6 @@ int xioopen_udp_sendto(int argc, const char *argv[], struct opt *opts, return STAT_NORETRY; } - //xioinit_ip(&pf, xioparms.preferred_ip); retropt_socket_pf(opts, &pf); if ((result = _xioopen_udp_sendto(argv[1], argv[2], opts, xioflags, xfd, groups, pf, socktype, ipproto)) @@ -451,7 +450,6 @@ int xioopen_udp_datagram(int argc, const char *argv[], struct opt *opts, return STAT_NORETRY; } - //xioinit_ip(&pf, xioparms.preferred_ip); if ((hostname = strdup(argv[1])) == NULL) { Error1("strdup(\"%s\"): out of memory", argv[1]); return STAT_RETRYLATER; @@ -601,7 +599,6 @@ int xioopen_udp_recv(int argc, const char *argv[], struct opt *opts, return STAT_NORETRY; } - //xioinit_ip(&pf, xioparms.default_ip); retropt_socket_pf(opts, &pf); if (pf == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 diff --git a/xioinitialize.c b/xioinitialize.c index 6b7161a..813a4d9 100644 --- a/xioinitialize.c +++ b/xioinitialize.c @@ -72,7 +72,6 @@ int xioinitialize(void) { { const char *default_ip; - // xioparms.default_ip = WITH_DEFAULT_IPV; default_ip = getenv("SOCAT_DEFAULT_LISTEN_IP"); if (default_ip != NULL) { switch (default_ip[0]) { @@ -89,7 +88,6 @@ int xioinitialize(void) { { const char *preferred_ip; - // xioparms.preferred_ip = WITH_DEFAULT_IPV; preferred_ip = getenv("SOCAT_PREFERRED_RESOLVE_IP"); if (preferred_ip != NULL) { switch (preferred_ip[0]) { diff --git a/xioopen.c b/xioopen.c index fa214af..e55baec 100644 --- a/xioopen.c +++ b/xioopen.c @@ -386,10 +386,6 @@ xiofile_t *xioopen(const char *addr, /* address specification */ int xioflags) { xiofile_t *xfd; - //if (xioinitialize() < 0) { - // return NULL; - //} - Debug1("xioopen(\"%s\")", addr); if ((xfd = xioparse_dual(&addr)) == NULL) { diff --git a/xioopts.c b/xioopts.c index 5a84ad5..3d1cc34 100644 --- a/xioopts.c +++ b/xioopts.c @@ -181,6 +181,9 @@ const struct optname optionnames[] = { #endif #if defined(AI_PASSIVE ) IF_IP ("ai-passive", &opt_ai_passive) +#endif +#if defined(AI_V4MAPPED) + IF_IP ("ai-v4mapped", &opt_ai_v4mapped) #endif IF_INTERFACE("allmulti", &opt_iff_allmulti) #if WITH_LIBWRAP && defined(HAVE_HOSTS_ALLOW_TABLE) @@ -1848,6 +1851,9 @@ const struct optname optionnames[] = { #if HAVE_RESOLV_H IF_IP ("usevc", &opt_res_usevc) #endif /* HAVE_RESOLV_H */ +#if defined(AI_V4MAPPED) + IF_IP ("v4mapped", &opt_ai_v4mapped) +#endif #ifdef IPV6_V6ONLY IF_IP6 ("v6only", &opt_ipv6_v6only) #endif diff --git a/xioopts.h b/xioopts.h index 4a79218..b253ac5 100644 --- a/xioopts.h +++ b/xioopts.h @@ -204,6 +204,7 @@ enum e_optcode { OPT_ADDRESS_FAMILY = 1, OPT_AI_ADDRCONFIG, /* getaddrinfo() */ OPT_AI_PASSIVE, /* getaddrinfo() */ + OPT_AI_V4MAPPED, /* getaddrinfo() */ /* these are not alphabetically, I know... */ OPT_B0, /* termios.c_cflag */ OPT_B50, /* termios.c_cflag */