1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-06-18 06:46:51 +00:00

Fixed build issues on disabled features

This commit is contained in:
Gerhard Rieger 2025-01-29 21:49:16 +01:00
parent af7d44d751
commit 7a90caade5
21 changed files with 182 additions and 95 deletions

View file

@ -7,6 +7,9 @@ Security:
Corrections: Corrections:
Fixed display of option phases in help output. Fixed display of option phases in help output.
Building:
Disabling certain features during configure could break build process.
Testing: Testing:
test.sh produces file results.txt with columns of test numbers, names, test.sh produces file results.txt with columns of test numbers, names,
and results. and results.

View file

@ -226,7 +226,7 @@ int sockname(int fd, FILE *outfile, char style) {
#define FDNAME_OPTLEN 256 #define FDNAME_OPTLEN 256
#define FDNAME_NAMELEN 256 #define FDNAME_NAMELEN 256
socklen_t optlen; socklen_t optlen;
#if HAVE_GETPROTOBYNUMBER || HAVE_GETPROTOBYNUMBER_R #if WITH_IP && ( HAVE_GETPROTOBYNUMBER || HAVE_GETPROTOBYNUMBER_R )
struct protoent protoent, *protoentp; struct protoent protoent, *protoentp;
#endif #endif
#define PROTONAMEMAX 1024 #define PROTONAMEMAX 1024
@ -278,7 +278,7 @@ int sockname(int fd, FILE *outfile, char style) {
Getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &optacceptconn, &optlen); Getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &optacceptconn, &optlen);
#endif #endif
#if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE) #if WITH_IP && ( defined(SO_PROTOCOL) || defined(SO_PROTOTYPE) )
#if HAVE_GETPROTOBYNUMBER_R==1 /* Linux */ #if HAVE_GETPROTOBYNUMBER_R==1 /* Linux */
rc = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname), &protoentp); rc = getprotobynumber_r(proto, &protoent, protoname, sizeof(protoname), &protoentp);
if (protoentp == NULL) { if (protoentp == NULL) {

View file

@ -677,7 +677,7 @@ int xiopoll(struct pollfd fds[], unsigned long nfds, struct timeval *timeout) {
} }
#if WITH_TCP || WITH_UDP #if WITH_TCP || WITH_UDP || WITH_SCTP || WITH_DCCP || WITH_UDPLITE
/* returns port in network byte order; /* returns port in network byte order;
ipproto==IPPROTO_UDP resolves as UDP service, every other value resolves as ipproto==IPPROTO_UDP resolves as UDP service, every other value resolves as
TCP */ TCP */
@ -702,10 +702,10 @@ int parseport(const char *portname, int ipproto) {
return se->s_port; return se->s_port;
} }
#endif /* WITH_TCP || WITH_UDP */ #endif /* WITH_TCP || WITH_UDP || WITH_SCTP || WITH_DCCP || WITH_UDPLITE */
#if WITH_IP4 || WITH_IP6 || WITH_INTERFACE #if WITH_IP4 || WITH_IP6 || _WITH_INTERFACE
/* check the systems interfaces for ifname and return its index /* check the systems interfaces for ifname and return its index
or -1 if no interface with this name was found or -1 if no interface with this name was found
The system calls require an arbitrary socket; the calling program may The system calls require an arbitrary socket; the calling program may
@ -729,8 +729,8 @@ int ifindexbyname(const char *ifname, int anysock) {
} }
if (anysock >= 0) { if (anysock >= 0) {
s = anysock; s = anysock;
} else if ((s = Socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) { } else if ((s = Socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
Error1("socket(PF_INET, SOCK_DGRAM, IPPROTO_IP): %s", strerror(errno)); Error1("socket(PF_INET, SOCK_DGRAM, 0): %s", strerror(errno));
return -1; return -1;
} }
@ -756,10 +756,10 @@ int ifindexbyname(const char *ifname, int anysock) {
return -1; return -1;
#endif /* !defined(HAVE_ STRUCT_IFREQ) && defined(SIOCGIFCONF) && defined(SIOCGIFINDEX) */ #endif /* !defined(HAVE_ STRUCT_IFREQ) && defined(SIOCGIFCONF) && defined(SIOCGIFINDEX) */
} }
#endif /* WITH_IP4 || WITH_IP6 || WITH_INTERFACE */ #endif /* WITH_IP4 || WITH_IP6 || _WITH_INTERFACE */
#if WITH_IP4 || WITH_IP6 || WITH_INTERFACE #if WITH_IP4 || WITH_IP6 || _WITH_INTERFACE
/* like ifindexbyname(), but also allows the index number as input - in this /* like ifindexbyname(), but also allows the index number as input - in this
case it does not lookup the index. case it does not lookup the index.
writes the resulting index to *ifindex and returns 0, writes the resulting index to *ifindex and returns 0,
@ -783,7 +783,7 @@ int ifindex(const char *ifname, unsigned int *ifindex, int anysock) {
*ifindex = val; *ifindex = val;
return 0; return 0;
} }
#endif /* WITH_IP4 || WITH_IP6 || WITH_INTERFACE */ #endif /* WITH_IP4 || WITH_IP6 || _WITH_INTERFACE */
int _xiosetenv(const char *envname, const char *value, int overwrite, const char *sep) { int _xiosetenv(const char *envname, const char *value, int overwrite, const char *sep) {

View file

@ -68,7 +68,7 @@ const struct optdesc opt_ip_multicast_if ={"ip-multicast-if", "multicast-if",
#ifdef IP_PKTOPTIONS #ifdef IP_PKTOPTIONS
const struct optdesc opt_ip_pktoptions = { "ip-pktoptions", "pktopts", OPT_IP_PKTOPTIONS, GROUP_SOCK_IP, PH_PASTSOCKET, TYPE_INT, OFUNC_SOCKOPT, SOL_IP, IP_PKTOPTIONS }; const struct optdesc opt_ip_pktoptions = { "ip-pktoptions", "pktopts", OPT_IP_PKTOPTIONS, GROUP_SOCK_IP, PH_PASTSOCKET, TYPE_INT, OFUNC_SOCKOPT, SOL_IP, IP_PKTOPTIONS };
#endif #endif
#ifdef IP_ADD_MEMBERSHIP #if defined(HAVE_STRUCT_IP_MREQ) || defined(HAVE_STRUCT_IP_MREQN)
const struct optdesc opt_ip_add_membership = { "ip-add-membership", "membership",OPT_IP_ADD_MEMBERSHIP, GROUP_SOCK_IP, PH_PASTSOCKET, TYPE_IP_MREQN, OFUNC_SPEC, SOL_IP, IP_ADD_MEMBERSHIP }; const struct optdesc opt_ip_add_membership = { "ip-add-membership", "membership",OPT_IP_ADD_MEMBERSHIP, GROUP_SOCK_IP, PH_PASTSOCKET, TYPE_IP_MREQN, OFUNC_SPEC, SOL_IP, IP_ADD_MEMBERSHIP };
#endif #endif
#if defined(HAVE_STRUCT_IP_MREQ_SOURCE) && defined(IP_ADD_SOURCE_MEMBERSHIP) #if defined(HAVE_STRUCT_IP_MREQ_SOURCE) && defined(IP_ADD_SOURCE_MEMBERSHIP)
@ -1128,6 +1128,9 @@ int xiotype_ip_add_membership(
} }
#endif /* defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) */ #endif /* defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) */
#if _WITH_IP4
#if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) #if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN)
int xioapply_ip_add_membership( int xioapply_ip_add_membership(
struct single *sfd, struct single *sfd,
@ -1386,6 +1389,8 @@ int xioapply_ip_add_source_membership(struct single *sfd, struct opt *opt) {
#endif /* HAVE_STRUCT_IP_MREQ_SOURCE */ #endif /* HAVE_STRUCT_IP_MREQ_SOURCE */
#endif /* _WITH_IP4 */
#if WITH_RESOLVE #if WITH_RESOLVE
#if HAVE_RESOLV_H #if HAVE_RESOLV_H

View file

@ -23,7 +23,7 @@ static char *inet6addr_info(const struct in6_addr *sa, char *buff, size_t blen);
#ifdef IPV6_V6ONLY #ifdef IPV6_V6ONLY
const struct optdesc opt_ipv6_v6only = { "ipv6-v6only", "ipv6only", OPT_IPV6_V6ONLY, GROUP_SOCK_IP6, PH_PREBIND, TYPE_INT, OFUNC_SOCKOPT, SOL_IPV6, IPV6_V6ONLY }; const struct optdesc opt_ipv6_v6only = { "ipv6-v6only", "ipv6only", OPT_IPV6_V6ONLY, GROUP_SOCK_IP6, PH_PREBIND, TYPE_INT, OFUNC_SOCKOPT, SOL_IPV6, IPV6_V6ONLY };
#endif #endif
#ifdef IPV6_JOIN_GROUP #if defined(HAVE_STRUCT_IP_MREQ) || defined(HAVE_STRUCT_IP_MREQN)
const struct optdesc opt_ipv6_join_group = { "ipv6-join-group", "join-group", OPT_IPV6_JOIN_GROUP, GROUP_SOCK_IP6, PH_PASTSOCKET, TYPE_IP_MREQN, OFUNC_SPEC, SOL_IPV6, IPV6_JOIN_GROUP }; const struct optdesc opt_ipv6_join_group = { "ipv6-join-group", "join-group", OPT_IPV6_JOIN_GROUP, GROUP_SOCK_IP6, PH_PASTSOCKET, TYPE_IP_MREQN, OFUNC_SPEC, SOL_IPV6, IPV6_JOIN_GROUP };
#endif #endif
#ifdef MCAST_JOIN_SOURCE_GROUP #ifdef MCAST_JOIN_SOURCE_GROUP

View file

@ -6,7 +6,7 @@
#include "xiosysincludes.h" #include "xiosysincludes.h"
#if WITH_TCP || WITH_UDP #if WITH_TCP || WITH_UDP || WITH_SCTP || WITH_DCCP || WITH_UDPLITE
#include "xioopen.h" #include "xioopen.h"
#include "xio-socket.h" #include "xio-socket.h"
@ -19,7 +19,7 @@ const struct optdesc opt_sourceport = { "sourceport", "sp", OPT_SOURCEPORT
/*const struct optdesc opt_port = { "port", NULL, OPT_PORT, GROUP_IPAPP, PH_BIND, TYPE_USHORT, OFUNC_SPEC };*/ /*const struct optdesc opt_port = { "port", NULL, OPT_PORT, GROUP_IPAPP, PH_BIND, TYPE_USHORT, OFUNC_SPEC };*/
const struct optdesc opt_lowport = { "lowport", NULL, OPT_LOWPORT, GROUP_IPAPP, PH_LATE, TYPE_BOOL, OFUNC_SPEC }; const struct optdesc opt_lowport = { "lowport", NULL, OPT_LOWPORT, GROUP_IPAPP, PH_LATE, TYPE_BOOL, OFUNC_SPEC };
#if WITH_IP4 #if _WITH_IP4 || _WITH_IP6
/* we expect the form "host:port" */ /* we expect the form "host:port" */
int xioopen_ipapp_connect( int xioopen_ipapp_connect(
int argc, int argc,
@ -276,7 +276,7 @@ int
return STAT_OK; return STAT_OK;
} }
#endif /* WITH_IP4 */ #endif /* _WITH_IP4 || _WITH_IP6 */
#if WITH_TCP && WITH_LISTEN #if WITH_TCP && WITH_LISTEN
@ -382,6 +382,6 @@ int xioopen_ipapp_listen(
return result; return result;
return 0; return 0;
} }
#endif /* WITH_IP4 && WITH_TCP && WITH_LISTEN */ #endif /* WITH_TCP && WITH_LISTEN */
#endif /* WITH_TCP || WITH_UDP */ #endif /* WITH_TCP || WITH_UDP || WITH_SCTP || WITH_DCCP || WITH_UDPLITE */

View file

@ -12,6 +12,7 @@
#include "xio-progcall.h" #include "xio-progcall.h"
#include "xio-socket.h" #include "xio-socket.h"
#include "xio-socketpair.h"
/* these options are used by address pty too */ /* these options are used by address pty too */
@ -23,7 +24,7 @@ const struct optdesc opt_ptmx = { "ptmx", NULL, OPT_PTMX, GROUP_P
#endif #endif
const struct optdesc opt_sitout_eio = { "sitout-eio", NULL, OPT_SITOUT_EIO, GROUP_PTY, PH_OFFSET, TYPE_TIMEVAL, OFUNC_OFFSET, XIO_OFFSETOF(para.exec.sitout_eio), XIO_SIZEOF(para.exec.sitout_eio) }; const struct optdesc opt_sitout_eio = { "sitout-eio", NULL, OPT_SITOUT_EIO, GROUP_PTY, PH_OFFSET, TYPE_TIMEVAL, OFUNC_OFFSET, XIO_OFFSETOF(para.exec.sitout_eio), XIO_SIZEOF(para.exec.sitout_eio) };
#if WITH_EXEC || WITH_SYSTEM #if WITH_EXEC || WITH_SYSTEM || WITH_SHELL
#define MAXPTYNAMELEN 64 #define MAXPTYNAMELEN 64
@ -623,7 +624,7 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
*optsp = popts; *optsp = popts;
return pid; /* indicate parent (main) process */ return pid; /* indicate parent (main) process */
} }
#endif /* WITH_EXEC || WITH_SYSTEM */ #endif /* WITH_EXEC || WITH_SYSTEM || WITH_SHELL */
int setopt_path(struct opt *opts, char **path) { int setopt_path(struct opt *opts, char **path) {

View file

@ -7,8 +7,6 @@
#include "xiosysincludes.h" #include "xiosysincludes.h"
#if _WITH_SOCKET
#include "xioopen.h" #include "xioopen.h"
#include "xio-ascii.h" #include "xio-ascii.h"
#include "xio-socket.h" #include "xio-socket.h"
@ -30,6 +28,8 @@
#include "xio-tcpwrap.h" #include "xio-tcpwrap.h"
#if _WITH_SOCKET
static int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, const struct addrdesc *addrdesc); static int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, const struct addrdesc *addrdesc);
static int xioopen_socket_listen(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, const struct addrdesc *addrdesc); static int xioopen_socket_listen(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, const struct addrdesc *addrdesc);
static int xioopen_socket_sendto(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, const struct addrdesc *addrdesc); static int xioopen_socket_sendto(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, const struct addrdesc *addrdesc);
@ -263,7 +263,12 @@ static int xioopen_socket_connect(
socket_init(0, &us); socket_init(0, &us);
if (retropt_bind(opts, 0 /*pf*/, socktype, proto, (struct sockaddr *)&us, &uslen, 3, if (retropt_bind(opts, 0 /*pf*/, socktype, proto, (struct sockaddr *)&us, &uslen, 3,
sfd->para.socket.ip.ai_flags) #if _WITH_IP4 || _WITH_IP6
sfd->para.socket.ip.ai_flags
#else
NULL
#endif /* _WITH_IP4 || _WITH_IP6 */
)
!= STAT_NOACTION) { != STAT_NOACTION) {
needbind = true; needbind = true;
us.soa.sa_family = pf; us.soa.sa_family = pf;
@ -540,7 +545,12 @@ int xioopen_socket_recvfrom(
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) { if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, 0, &sfd->para.socket.range, if (xioparserange(rangename, 0, &sfd->para.socket.range,
sfd->para.socket.ip.ai_flags) #if _WITH_IP4 || _WITH_IP6
sfd->para.socket.ip.ai_flags
#else
NULL
#endif /* _WITH_IP4 */
)
< 0) { < 0) {
free(rangename); free(rangename);
return STAT_NORETRY; return STAT_NORETRY;
@ -626,7 +636,12 @@ int xioopen_socket_recv(
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) { if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, 0, &sfd->para.socket.range, if (xioparserange(rangename, 0, &sfd->para.socket.range,
sfd->para.socket.ip.ai_flags) #if _WITH_IP4 || _WITH_IP6
sfd->para.socket.ip.ai_flags
#else
NULL
#endif /* _WITH_IP4 */
)
< 0) { < 0) {
free(rangename); free(rangename);
return STAT_NORETRY; return STAT_NORETRY;
@ -712,7 +727,12 @@ static int xioopen_socket_datagram(
/* which reply sockets will accept - determine by range option */ /* which reply sockets will accept - determine by range option */
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) { if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, 0, &sfd->para.socket.range, if (xioparserange(rangename, 0, &sfd->para.socket.range,
sfd->para.socket.ip.ai_flags) #if _WITH_IP4 || _WITH_IP6
sfd->para.socket.ip.ai_flags
#else
NULL
#endif /* _WITH_IP4 */
)
< 0) { < 0) {
free(rangename); free(rangename);
return STAT_NORETRY; return STAT_NORETRY;
@ -1202,6 +1222,7 @@ int _xioopen_dgram_recvfrom(struct single *sfd, int xioflags,
} }
#endif #endif
#if WITH_IP4
/* for generic sockets, this has already been retrieved */ /* for generic sockets, this has already been retrieved */
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) { if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, pf, &sfd->para.socket.range, if (xioparserange(rangename, pf, &sfd->para.socket.range,
@ -1213,6 +1234,7 @@ int _xioopen_dgram_recvfrom(struct single *sfd, int xioflags,
free(rangename); free(rangename);
sfd->para.socket.dorange = true; sfd->para.socket.dorange = true;
} }
#endif /* WITH_IP4 */
#if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP #if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP
xio_retropt_tcpwrap(sfd, opts); xio_retropt_tcpwrap(sfd, opts);
@ -1424,6 +1446,7 @@ int _xioopen_dgram_recv(struct single *sfd, int xioflags,
} }
#endif #endif
#if WITH_IP4
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) { if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, pf, &sfd->para.socket.range, if (xioparserange(rangename, pf, &sfd->para.socket.range,
sfd->para.socket.ip.ai_flags) sfd->para.socket.ip.ai_flags)
@ -1434,6 +1457,7 @@ int _xioopen_dgram_recv(struct single *sfd, int xioflags,
free(rangename); free(rangename);
sfd->para.socket.dorange = true; sfd->para.socket.dorange = true;
} }
#endif /* WITH_IP4 */
#if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP #if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP
xio_retropt_tcpwrap(sfd, opts); xio_retropt_tcpwrap(sfd, opts);
@ -1449,7 +1473,10 @@ int _xioopen_dgram_recv(struct single *sfd, int xioflags,
return STAT_OK; return STAT_OK;
} }
#endif /* _WITH_SOCKET */
#if _WITH_SOCKET || _WITH_SOCKETPAIR
int retropt_socket_pf(struct opt *opts, int *pf) { int retropt_socket_pf(struct opt *opts, int *pf) {
char *pfname; char *pfname;
@ -1478,8 +1505,11 @@ int retropt_socket_pf(struct opt *opts, int *pf) {
} }
return -1; return -1;
} }
#endif /* _WITH_SOCKET || _WITH_SOCKETPAIR */
#if _WITH_SOCKET
/* This function calls recvmsg(..., MSG_PEEK, ...) to obtain information about /* This function calls recvmsg(..., MSG_PEEK, ...) to obtain information about
the arriving packet, thus it does not "consume" the packet. the arriving packet, thus it does not "consume" the packet.
In msgh the msg_name pointer must refer to an (empty) sockaddr storage. In msgh the msg_name pointer must refer to an (empty) sockaddr storage.
@ -1651,7 +1681,7 @@ int xiocheckpeer(xiosingle_t *sfd,
char infobuff[256]; char infobuff[256];
int result; int result;
#if WITH_IP4 #if WITH_IP4 || WITH_IP6
if (sfd->para.socket.dorange) { if (sfd->para.socket.dorange) {
if (pa == NULL) { return -1; } if (pa == NULL) { return -1; }
if (xiocheckrange(pa, &sfd->para.socket.range) < 0) { if (xiocheckrange(pa, &sfd->para.socket.range) < 0) {
@ -2055,9 +2085,7 @@ int xiosetsockaddrenv(const char *lr,
# undef XIOSOCKADDRENVLEN # undef XIOSOCKADDRENVLEN
} }
#endif /* _WITH_SOCKET */ /* These do sockets internally */
/* these do sockets internally */
/* retrieves options so-type and so-prototype from opts, calls socket, and /* retrieves options so-type and so-prototype from opts, calls socket, and
ev. generates an appropriate error message. ev. generates an appropriate error message.
@ -2080,24 +2108,6 @@ xiosocket(struct opt *opts, int pf, int socktype, int proto, int msglevel) {
return result; return result;
} }
/* retrieves options so-type and so-prototype from opts, calls socketpair, and
ev. generates an appropriate error message.
returns 0 on success or -1 if an error occurred. */
int
xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]) {
int result;
retropt_int(opts, OPT_SO_TYPE, &socktype);
retropt_int(opts, OPT_SO_PROTOTYPE, &proto);
result = Socketpair(pf, socktype, proto, sv);
if (result < 0) {
Error5("socketpair(%d, %d, %d, %p): %s",
pf, socktype, proto, sv, strerror(errno));
return -1;
}
return result;
}
/* Binds a socket to a socket address. Handles IP (internet protocol), UNIX /* Binds a socket to a socket address. Handles IP (internet protocol), UNIX
domain, Linux abstract UNIX domain. domain, Linux abstract UNIX domain.
The bind address us may be NULL in which case no bind() happens, except with The bind address us may be NULL in which case no bind() happens, except with
@ -2206,8 +2216,12 @@ int xiobind(
if (us) { if (us) {
sinp = us; sinp = us;
} else { } else {
if (pf == AF_INET) { if (0) {
;
#if WITH_IP4
} else if (pf == AF_INET) {
socket_in_init(&sin.ip4); socket_in_init(&sin.ip4);
#endif
#if WITH_IP6 #if WITH_IP6
} else { } else {
socket_in6_init(&sin.ip6); socket_in6_init(&sin.ip6);
@ -2307,10 +2321,12 @@ int xiosock_reuseaddr(int fd, int ipproto, struct opt *opts)
val.u_int = 0; val.u_int = 0;
notnull.u_bool = false; notnull.u_bool = false;
#if WITH_TCP
if (ipproto == IPPROTO_TCP) { if (ipproto == IPPROTO_TCP) {
val.u_int = 1; val.u_int = 1;
notnull.u_bool = true; notnull.u_bool = true;
} }
#endif /* WITH_TCP */
retropt_2integrals(opts, OPT_SO_REUSEADDR, &val, &notnull); retropt_2integrals(opts, OPT_SO_REUSEADDR, &val, &notnull);
if (notnull.u_bool) { if (notnull.u_bool) {
if (Setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val.u_int, sizeof(int)) if (Setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val.u_int, sizeof(int))
@ -2324,3 +2340,6 @@ int xiosock_reuseaddr(int fd, int ipproto, struct opt *opts)
} }
return 0; return 0;
} }
#endif /* _WITH_SOCKET */

View file

@ -135,8 +135,6 @@ extern int xioparserange(const char *rangename, int pf, struct xiorange *range,
extern int extern int
xiosocket(struct opt *opts, int pf, int socktype, int proto, int level); xiosocket(struct opt *opts, int pf, int socktype, int proto, int level);
extern int
xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]);
extern int xiosock_reuseaddr(int fd, int ipproto, struct opt *opts); extern int xiosock_reuseaddr(int fd, int ipproto, struct opt *opts);
#endif /* !defined(__xio_socket_h_included) */ #endif /* !defined(__xio_socket_h_included) */

View file

@ -95,3 +95,26 @@ static int xioopen_socketpair(
} }
#endif /* WITH_SOCKETPAIR */ #endif /* WITH_SOCKETPAIR */
#if _WITH_SOCKETPAIR
/* retrieves options so-type and so-prototype from opts, calls socketpair, and
ev. generates an appropriate error message.
returns 0 on success or -1 if an error occurred. */
int
xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]) {
int result;
retropt_int(opts, OPT_SO_TYPE, &socktype);
retropt_int(opts, OPT_SO_PROTOTYPE, &proto);
result = Socketpair(pf, socktype, proto, sv);
if (result < 0) {
Error5("socketpair(%d, %d, %d, %p): %s",
pf, socktype, proto, sv, strerror(errno));
return -1;
}
return result;
}
#endif /* _WITH_SOCKETPAIR */

View file

@ -7,4 +7,6 @@
const extern struct addrdesc xioaddr_socketpair; const extern struct addrdesc xioaddr_socketpair;
extern int xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]);
#endif /* !defined(__xio_socketpair_h_included) */ #endif /* !defined(__xio_socketpair_h_included) */

View file

@ -6,14 +6,16 @@
#include "xiosysincludes.h" #include "xiosysincludes.h"
#if WITH_SOCKS4 || WITH_SOCKS4A
#include "xioopen.h" #include "xioopen.h"
#include "xio-ascii.h" #include "xio-ascii.h"
#include "xio-socket.h" #include "xio-socket.h"
#include "xio-ip.h" #include "xio-ip.h"
#include "xio-ipapp.h" #include "xio-ipapp.h"
#define SOCKSPORT "1080"
#if WITH_SOCKS4 || WITH_SOCKS4A
#include "xio-socks.h" #include "xio-socks.h"
@ -24,7 +26,6 @@ enum {
SOCKS_CD_IDENTFAILED SOCKS_CD_IDENTFAILED
} ; } ;
#define SOCKSPORT "1080"
#define BUFF_LEN (SIZEOF_STRUCT_SOCKS4+512) #define BUFF_LEN (SIZEOF_STRUCT_SOCKS4+512)
static int xioopen_socks4_connect(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *fd, const struct addrdesc *addrdesc); static int xioopen_socks4_connect(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *fd, const struct addrdesc *addrdesc);
@ -229,6 +230,8 @@ static int xioopen_socks4_connect(
return 0; return 0;
} }
#endif /* WITH_SOCKS4 || WITH_SOCKS4A */
#if WITH_SOCKS4 || WITH_SOCKS4A || WITH_SOCKS5
int _xioopen_opt_socksport( int _xioopen_opt_socksport(
struct opt *opts, struct opt *opts,
@ -253,6 +256,8 @@ int _xioopen_opt_socksport(
return 0; return 0;
} }
#endif /* WITH_SOCKS4 || WITH_SOCKS4A || WITH_SOCKS5 */
#if WITH_SOCKS4 || WITH_SOCKS4A
int _xioopen_socks4_prepare(const char *targetport, struct opt *opts, char **socksport, struct socks4 *sockhead, size_t *headlen) { int _xioopen_socks4_prepare(const char *targetport, struct opt *opts, char **socksport, struct socks4 *sockhead, size_t *headlen) {
char *userid; char *userid;

View file

@ -85,7 +85,7 @@ int _xioopen_ipdgram_listen(struct single *sfd,
return STAT_NORETRY; return STAT_NORETRY;
} }
#if WITH_IP4 /*|| WITH_IP6*/ #if WITH_IP4 || WITH_IP6
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) { if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, pf, &sfd->para.socket.range, if (xioparserange(rangename, pf, &sfd->para.socket.range,
sfd->para.socket.ip.ai_flags) sfd->para.socket.ip.ai_flags)
@ -646,7 +646,7 @@ int xioopen_udp_recv(
} }
#endif #endif
#if WITH_IP4 /*|| WITH_IP6*/ #if WITH_IP4 || WITH_IP6
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) { if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, pf, &xfd->stream.para.socket.range, if (xioparserange(rangename, pf, &xfd->stream.para.socket.range,
xfd->stream.para.socket.ip.ai_flags) xfd->stream.para.socket.ip.ai_flags)

View file

@ -257,7 +257,12 @@ static int xioopen_unix_connect(
if (retropt_bind(opts, pf, socktype, protocol, (struct sockaddr *)&us, &uslen, if (retropt_bind(opts, pf, socktype, protocol, (struct sockaddr *)&us, &uslen,
(addrdesc->arg1/*abstract*/<<1)|sfd->para.socket.un.tight, (addrdesc->arg1/*abstract*/<<1)|sfd->para.socket.un.tight,
sfd->para.socket.ip.ai_flags) #if WITH_TCP
sfd->para.socket.ip.ai_flags
#else
0
#endif /* WITH_TCP */
)
== STAT_OK) { == STAT_OK) {
needbind = true; needbind = true;
} }
@ -426,7 +431,12 @@ static int xioopen_unix_sendto(
if (retropt_bind(opts, pf, socktype, protocol, (struct sockaddr *)&us, &uslen, if (retropt_bind(opts, pf, socktype, protocol, (struct sockaddr *)&us, &uslen,
(addrdesc->arg1/*abstract*/<<1)| sfd->para.socket.un.tight, (addrdesc->arg1/*abstract*/<<1)| sfd->para.socket.un.tight,
sfd->para.socket.ip.ai_flags) #if WITH_TCP
sfd->para.socket.ip.ai_flags
#else
0
#endif /* WITH_TCP */
)
== STAT_OK) { == STAT_OK) {
needbind = true; needbind = true;
} }
@ -709,7 +719,12 @@ _xioopen_unix_client(
if (retropt_bind(opts, pf, socktype, protocol, &us.soa, &uslen, if (retropt_bind(opts, pf, socktype, protocol, &us.soa, &uslen,
(abstract<<1)|sfd->para.socket.un.tight, (abstract<<1)|sfd->para.socket.un.tight,
sfd->para.socket.ip.ai_flags) #if WITH_TCP
sfd->para.socket.ip.ai_flags
#else
0
#endif /* WITH_TCP */
)
!= STAT_NOACTION) { != STAT_NOACTION) {
needbind = true; needbind = true;
} }

View file

@ -98,7 +98,7 @@ static int xioopen_vsock_connect(
ret = retropt_bind(opts, pf, socktype, protocol, ret = retropt_bind(opts, pf, socktype, protocol,
(struct sockaddr *)&sa_local, &sa_len, 3, (struct sockaddr *)&sa_local, &sa_len, 3,
sfd->para.socket.ip.ai_flags); NULL);
if (ret == STAT_NORETRY) if (ret == STAT_NORETRY)
return ret; return ret;
if (ret == STAT_OK) if (ret == STAT_OK)

View file

@ -16,7 +16,13 @@
# define WITH_OPEN 1 # define WITH_OPEN 1
#endif #endif
#if WITH_OPEN || WITH_PIPE || WITH_UNIX || WITH_PTY #if WITH_INTERFACE || WITH_TUN
# define _WITH_INTERFACE 1
#else
# define _WITH_INTERFACE 0
#endif
#if WITH_OPEN || WITH_PIPE || WITH_UNIX || WITH_PTY || _WITH_INTERFACE
# define WITH_NAMED 1 # define WITH_NAMED 1
#endif #endif
@ -34,7 +40,7 @@
with IP6 */ with IP6 */
#endif #endif
#if WITH_OPENSSL #if WITH_OPENSSL || WITH_SOCKS5
# define WITH_TCP 1 # define WITH_TCP 1
# define WITH_IP4 1 # define WITH_IP4 1
#endif #endif
@ -57,7 +63,7 @@
# define _WITH_UDP 1 # define _WITH_UDP 1
#endif #endif
#if WITH_UNIX || WITH_IP4 || WITH_IP6 || WITH_SOCKS4 || WITH_RAWIP || WITH_GENERICSOCKET #if WITH_UNIX || WITH_IP4 || WITH_IP6 || WITH_SOCKS4 || WITH_SOCKS5 || WITH_RAWIP || WITH_GENERICSOCKET || WITH_SOCKETPAIR || WITH_VSOCK
# define _WITH_SOCKET 1 # define _WITH_SOCKET 1
#else #else
# undef _WITH_SOCKET # undef _WITH_SOCKET
@ -71,10 +77,8 @@
# undef WITH_LIBWRAP # undef WITH_LIBWRAP
#endif #endif
#if WITH_INTERFACE || WITH_TUN #if WITH_SOCKETPAIR || WITH_EXEC || WITH_SYSTEM || WITH_SHELL
# define _WITH_INTERFACE 1 # define _WITH_SOCKETPAIR 1
#else
# define _WITH_INTERFACE 0
#endif #endif
#if WITH_GENERICSOCKET || _WITH_INTERFACE #if WITH_GENERICSOCKET || _WITH_INTERFACE

View file

@ -471,14 +471,14 @@ static xiofile_t *xioallocfd(void) {
fd->stream.escape = -1; fd->stream.escape = -1;
/* fd->stream.para.exec.pid = 0; */ /* fd->stream.para.exec.pid = 0; */
fd->stream.lineterm = LINETERM_RAW; fd->stream.lineterm = LINETERM_RAW;
#if WITH_RESOLVE #if ( _WITH_IP4 || _WITH_IP6 ) && WITH_RESOLVE
#if HAVE_RES_RETRANS #if HAVE_RES_RETRANS
fd->stream.para.socket.ip.res.retrans = -1; fd->stream.para.socket.ip.res.retrans = -1;
#endif #endif
#if HAVE_RES_RETRY #if HAVE_RES_RETRY
fd->stream.para.socket.ip.res.retry = -1; fd->stream.para.socket.ip.res.retry = -1;
#endif #endif
#endif /* WITH_RESOLVE */ #endif /* ( _WITH_IP4 || _WITH_IP6 ) && WITH_RESOLVE */
return fd; return fd;
} }
@ -701,10 +701,10 @@ int xioopen_single(xiofile_t *xfd, int xioflags) {
mode_t orig_umask, tmp_umask; mode_t orig_umask, tmp_umask;
int result; int result;
/* Values to be saved until xioopen() is finished */ /* Values to be saved until xioopen() is finished */
#if WITH_RESOLVE && HAVE_RESOLV_H #if ( _WITH_IP4 || _WITH_IP6 ) && WITH_RESOLVE && HAVE_RESOLV_H
int do_res; int do_res;
struct __res_state save_res; struct __res_state save_res;
#endif /* WITH_RESOLVE && HAVE_RESOLV_H */ #endif
#if WITH_NAMESPACES #if WITH_NAMESPACES
int save_netfd = -1; int save_netfd = -1;
#endif #endif
@ -735,10 +735,10 @@ int xioopen_single(xiofile_t *xfd, int xioflags) {
return -1; return -1;
#endif /* WITH_NAMESPACES */ #endif /* WITH_NAMESPACES */
#if WITH_RESOLVE && HAVE_RESOLV_H #if ( _WITH_IP4 || _WITH_IP6 ) && WITH_RESOLVE && HAVE_RESOLV_H
if ((do_res = xio_res_init(sfd, &save_res)) < 0) if ((do_res = xio_res_init(sfd, &save_res)) < 0)
return STAT_NORETRY; return STAT_NORETRY;
#endif /* WITH_RESOLVE && HAVE_RESOLV_H */ #endif
if (xio_chdir(sfd->opts, &orig_dir) < 0) if (xio_chdir(sfd->opts, &orig_dir) < 0)
return STAT_NORETRY; return STAT_NORETRY;
@ -769,10 +769,10 @@ int xioopen_single(xiofile_t *xfd, int xioflags) {
free(orig_dir); free(orig_dir);
} }
#if WITH_RESOLVE && HAVE_RESOLV_H #if ( _WITH_IP4 || _WITH_IP6 ) && WITH_RESOLVE && HAVE_RESOLV_H
if (do_res) if (do_res)
xio_res_restore(&save_res); xio_res_restore(&save_res);
#endif /* WITH_RESOLVE && HAVE_RESOLV_H */ #endif
#if WITH_NAMESPACES #if WITH_NAMESPACES
if (save_netfd > 0) { if (save_netfd > 0) {

View file

@ -177,7 +177,7 @@ static int applyopt(struct single *sfd, int fd, struct opt *opt);
binary search! */ binary search! */
/* NULL terminated */ /* NULL terminated */
const struct optname optionnames[] = { const struct optname optionnames[] = {
#if HAVE_RESOLV_H && WITH_RES_AAONLY #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H && WITH_RES_AAONLY
IF_RESOLVE("aaonly", &opt_res_aaonly) IF_RESOLVE("aaonly", &opt_res_aaonly)
#endif #endif
#ifdef TCP_ABORT_THRESHOLD /* HP_UX */ #ifdef TCP_ABORT_THRESHOLD /* HP_UX */
@ -421,7 +421,7 @@ const struct optname optionnames[] = {
#ifdef TCP_DEFER_ACCEPT /* Linux 2.4.0 */ #ifdef TCP_DEFER_ACCEPT /* Linux 2.4.0 */
IF_TCP ("defer-accept", &opt_tcp_defer_accept) IF_TCP ("defer-accept", &opt_tcp_defer_accept)
#endif #endif
#if HAVE_RESOLV_H #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H
IF_RESOLVE("defnames", &opt_res_defnames) IF_RESOLVE("defnames", &opt_res_defnames)
#endif /* HAVE_RESOLV_H */ #endif /* HAVE_RESOLV_H */
#ifdef O_DELAY #ifdef O_DELAY
@ -454,10 +454,10 @@ const struct optname optionnames[] = {
#ifdef VDISCARD #ifdef VDISCARD
IF_TERMIOS("discard", &opt_vdiscard) IF_TERMIOS("discard", &opt_vdiscard)
#endif #endif
#if WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST #if (WITH_IP4 || WITH_IP6) && WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST
IF_IP ("dns", &opt_res_nsaddr) IF_IP ("dns", &opt_res_nsaddr)
#endif #endif
#if HAVE_RESOLV_H #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H
IF_RESOLVE("dnsrch", &opt_res_dnsrch) IF_RESOLVE("dnsrch", &opt_res_dnsrch)
#endif /* HAVE_RESOLV_H */ #endif /* HAVE_RESOLV_H */
#ifdef SO_DONTLINGER #ifdef SO_DONTLINGER
@ -721,7 +721,7 @@ const struct optname optionnames[] = {
IF_ANY ("ignoreeof", &opt_ignoreeof) IF_ANY ("ignoreeof", &opt_ignoreeof)
IF_ANY ("ignoreof", &opt_ignoreeof) IF_ANY ("ignoreof", &opt_ignoreeof)
IF_TERMIOS("ignpar", &opt_ignpar) IF_TERMIOS("ignpar", &opt_ignpar)
#if HAVE_RESOLV_H #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H
IF_RESOLVE("igntc", &opt_res_igntc) IF_RESOLVE("igntc", &opt_res_igntc)
#endif /* HAVE_RESOLV_H */ #endif /* HAVE_RESOLV_H */
IF_TERMIOS("imaxbel", &opt_imaxbel) IF_TERMIOS("imaxbel", &opt_imaxbel)
@ -1050,7 +1050,7 @@ const struct optname optionnames[] = {
IF_IP ("multicast-ttl", &opt_ip_multicast_ttl) IF_IP ("multicast-ttl", &opt_ip_multicast_ttl)
IF_IP ("multicastloop", &opt_ip_multicast_loop) IF_IP ("multicastloop", &opt_ip_multicast_loop)
IF_IP ("multicastttl", &opt_ip_multicast_ttl) IF_IP ("multicastttl", &opt_ip_multicast_ttl)
#if WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST #if (WITH_IP4 || WITH_IP6) && WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST
IF_IP ("nameserver", &opt_res_nsaddr) IF_IP ("nameserver", &opt_res_nsaddr)
#endif #endif
#if defined(O_NDELAY) && (!defined(O_NONBLOCK) || O_NDELAY != O_NONBLOCK) #if defined(O_NDELAY) && (!defined(O_NONBLOCK) || O_NDELAY != O_NONBLOCK)
@ -1118,7 +1118,7 @@ const struct optname optionnames[] = {
IF_OPENSSL("nosni", &opt_openssl_no_sni) IF_OPENSSL("nosni", &opt_openssl_no_sni)
#endif #endif
IF_INTERFACE("notrailers", &opt_iff_notrailers) IF_INTERFACE("notrailers", &opt_iff_notrailers)
#if WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST #if (WITH_IP4 || WITH_IP6) && WITH_RESOLVE && HAVE_RESOLV_H && HAVE_RES_NSADDR_LIST
IF_IP ("nsaddr", &opt_res_nsaddr) IF_IP ("nsaddr", &opt_res_nsaddr)
#endif #endif
#ifdef O_NSHARE #ifdef O_NSHARE
@ -1350,7 +1350,7 @@ const struct optname optionnames[] = {
#if WITH_POSIXMQ #if WITH_POSIXMQ
IF_ANY ("posixmq-priority", &opt_posixmq_priority) IF_ANY ("posixmq-priority", &opt_posixmq_priority)
#endif #endif
#if HAVE_RESOLV_H && WITH_RES_PRIMARY #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H && WITH_RES_PRIMARY
IF_RESOLVE("primary", &opt_res_primary) IF_RESOLVE("primary", &opt_res_primary)
#endif #endif
#ifdef SO_PRIORITY #ifdef SO_PRIORITY
@ -1411,7 +1411,7 @@ const struct optname optionnames[] = {
IF_OPEN ("rdonly", &opt_o_rdonly) IF_OPEN ("rdonly", &opt_o_rdonly)
IF_OPEN ("rdwr", &opt_o_rdwr) IF_OPEN ("rdwr", &opt_o_rdwr)
IF_ANY ("readbytes", &opt_readbytes) IF_ANY ("readbytes", &opt_readbytes)
#if HAVE_RESOLV_H #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H
IF_RESOLVE("recurse", &opt_res_recurse) IF_RESOLVE("recurse", &opt_res_recurse)
#endif /* HAVE_RESOLV_H */ #endif /* HAVE_RESOLV_H */
#ifdef IP_RECVDSTADDR #ifdef IP_RECVDSTADDR
@ -1451,7 +1451,7 @@ const struct optname optionnames[] = {
#ifdef VREPRINT #ifdef VREPRINT
IF_TERMIOS("reprint", &opt_vreprint) IF_TERMIOS("reprint", &opt_vreprint)
#endif #endif
#if HAVE_RESOLV_H #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H
# if WITH_AA_ONLY # if WITH_AA_ONLY
IF_RESOLVE("res-aaonly", &opt_res_aaonly) IF_RESOLVE("res-aaonly", &opt_res_aaonly)
# endif # endif
@ -1480,13 +1480,13 @@ const struct optname optionnames[] = {
# endif # endif
IF_RESOLVE("res-stayopen", &opt_res_stayopen) IF_RESOLVE("res-stayopen", &opt_res_stayopen)
IF_RESOLVE("res-usevc", &opt_res_usevc) IF_RESOLVE("res-usevc", &opt_res_usevc)
#endif /* HAVE_RESOLV_H */ #endif /* (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H */
IF_PROXY ("resolv", &opt_proxy_resolve) IF_PROXY ("resolv", &opt_proxy_resolve)
IF_PROXY ("resolve", &opt_proxy_resolve) IF_PROXY ("resolve", &opt_proxy_resolve)
#ifdef IP_RETOPTS #ifdef IP_RETOPTS
IF_IP ("retopts", &opt_ip_retopts) IF_IP ("retopts", &opt_ip_retopts)
#endif #endif
# if HAVE_RES_RETRANS #if (WITH_IP4 || WITH_IP6) && HAVE_RES_RETRANS
IF_RESOLVE("retrans", &opt_res_retrans) IF_RESOLVE("retrans", &opt_res_retrans)
#endif #endif
#if WITH_INTERFACE && defined(PACKET_AUXDATA) #if WITH_INTERFACE && defined(PACKET_AUXDATA)
@ -1724,7 +1724,7 @@ const struct optname optionnames[] = {
IF_IPAPP ("sourceport", &opt_sourceport) IF_IPAPP ("sourceport", &opt_sourceport)
IF_IPAPP ("sp", &opt_sourceport) IF_IPAPP ("sp", &opt_sourceport)
IF_TERMIOS("start", &opt_vstart) IF_TERMIOS("start", &opt_vstart)
#if HAVE_RESOLV_H #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H
IF_RESOLVE("stayopen", &opt_res_stayopen) IF_RESOLVE("stayopen", &opt_res_stayopen)
#endif /* HAVE_RESOLV_H */ #endif /* HAVE_RESOLV_H */
IF_EXEC ("stderr", &opt_stderr) IF_EXEC ("stderr", &opt_stderr)
@ -1930,7 +1930,7 @@ const struct optname optionnames[] = {
IF_ANY ("user", &opt_user) IF_ANY ("user", &opt_user)
IF_NAMED ("user-early", &opt_user_early) IF_NAMED ("user-early", &opt_user_early)
IF_ANY ("user-late", &opt_user_late) IF_ANY ("user-late", &opt_user_late)
#if HAVE_RESOLV_H #if (WITH_IP4 || WITH_IP6) && HAVE_RESOLV_H
IF_RESOLVE("usevc", &opt_res_usevc) IF_RESOLVE("usevc", &opt_res_usevc)
#endif /* HAVE_RESOLV_H */ #endif /* HAVE_RESOLV_H */
#if defined(AI_V4MAPPED) #if defined(AI_V4MAPPED)
@ -2654,13 +2654,13 @@ int parseopts_table(const char **a, groups_t groups, struct opt **opts,
(*opts)[i].value3.u_string); (*opts)[i].value3.u_string);
break; break;
#if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) #if (WITH_IP4 || WITH_IP6) && ( defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) )
case TYPE_IP_MREQN: case TYPE_IP_MREQN:
xiotype_ip_add_membership(token, ent, opt); xiotype_ip_add_membership(token, ent, opt);
break; break;
#endif /* defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) */ #endif /* WITH_IP && defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) ) */
#if defined(HAVE_STRUCT_IP_MREQ_SOURCE) && defined(IP_ADD_SOURCE_MEMBERSHIP) #if _WITH_IP4 && defined(HAVE_STRUCT_IP_MREQ_SOURCE)
case TYPE_IP_MREQ_SOURCE: case TYPE_IP_MREQ_SOURCE:
xiotype_ip_add_source_membership(token, ent, opt); xiotype_ip_add_source_membership(token, ent, opt);
break; break;
@ -3323,6 +3323,7 @@ int retropt_bind(struct opt *opts,
} }
} }
# if WITH_IP4 || WITH_IP6
/* Set AI_PASSIVE, except when it is explicitely disabled */ /* Set AI_PASSIVE, except when it is explicitely disabled */
ai_flags2[0] = ai_flags[0]; ai_flags2[0] = ai_flags[0];
ai_flags2[1] = ai_flags[1]; ai_flags2[1] = ai_flags[1];
@ -3337,6 +3338,8 @@ int retropt_bind(struct opt *opts,
Error("error resolving bind option"); Error("error resolving bind option");
return STAT_NORETRY; return STAT_NORETRY;
} }
/*# else */
# endif /* WITH_IP4 || WITH_IP6 */
break; break;
#endif /* WITH_IP4 || WITH_IP6 || WITH_VSOCK */ #endif /* WITH_IP4 || WITH_IP6 || WITH_VSOCK */
@ -3567,6 +3570,8 @@ int applyopt_ioctl_generic(
return 0; return 0;
} }
#if _WITH_SOCKET
int applyopt_sockopt( int applyopt_sockopt(
int fd, int fd,
struct opt *opt) struct opt *opt)
@ -3695,7 +3700,7 @@ int applyopt_sockopt(
} }
break; break;
#endif /* HAVE_STRUCT_LINGER */ #endif /* HAVE_STRUCT_LINGER */
#if defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) #if (WITH_IP4 || WITH_IP6) && ( defined(HAVE_STRUCT_IP_MREQ) || defined (HAVE_STRUCT_IP_MREQN) )
case TYPE_IP_MREQN: case TYPE_IP_MREQN:
/* handled in applyopts_single */ /* handled in applyopts_single */
break; break;
@ -3815,6 +3820,8 @@ int applyopt_sockopt_generic(
return 0; return 0;
} }
#endif /* _WITH_SOCKET */
int applyopt_flock( int applyopt_flock(
int fd, int fd,
struct opt *opt) struct opt *opt)
@ -4272,6 +4279,7 @@ static int applyopt_offset(struct single *sfd, struct opt *opt) {
case TYPE_CONST: case TYPE_CONST:
*(int *)ptr = opt->desc->minor; *(int *)ptr = opt->desc->minor;
break; break;
#if WITH_IP4
case TYPE_IP4NAME: case TYPE_IP4NAME:
memset(ptr, 0, sizeof(struct sockaddr_in)); memset(ptr, 0, sizeof(struct sockaddr_in));
((struct sockaddr_in *)ptr)->sin_addr = opt->value.u_ip4addr; ((struct sockaddr_in *)ptr)->sin_addr = opt->value.u_ip4addr;
@ -4281,6 +4289,7 @@ static int applyopt_offset(struct single *sfd, struct opt *opt) {
memset(ptr, 0, sizeof(struct sockaddr_in)); memset(ptr, 0, sizeof(struct sockaddr_in));
*(struct sockaddr_in *)ptr = opt->value.u_ip4sock; *(struct sockaddr_in *)ptr = opt->value.u_ip4sock;
break; break;
#endif /* WITH_IP4 */
default: default:
Error2("applyopt_offset(opt:%s): type %s not implemented", Error2("applyopt_offset(opt:%s): type %s not implemented",
opt->desc->defname, xiohelp_opttypename(opt->desc->type)); opt->desc->defname, xiohelp_opttypename(opt->desc->type));

View file

@ -72,7 +72,7 @@ enum e_types {
#if HAVE_STRUCT_LINGER #if HAVE_STRUCT_LINGER
TYPE_LINGER, /* struct linger */ TYPE_LINGER, /* struct linger */
#endif /* HAVE_STRUCT_LINGER */ #endif /* HAVE_STRUCT_LINGER */
#if HAVE_STRUCT_IP_MREQ || HAVE_STRUCT_IP_MREQN #if (WITH_IP4 || WITH_IP6) && ( defined(HAVE_STRUCT_IP_MREQ) || defined(HAVE_STRUCT_IP_MREQN) )
TYPE_IP_MREQN, /* for struct ip_mreq or struct ip_mreqn */ TYPE_IP_MREQN, /* for struct ip_mreq or struct ip_mreqn */
#endif #endif
#if HAVE_STRUCT_IP_MREQ_SOURCE #if HAVE_STRUCT_IP_MREQ_SOURCE

View file

@ -10,6 +10,7 @@
#include "xio-openssl.h" #include "xio-openssl.h"
static pid_t socat_kill_pid; /* here we pass the pid to be killed in sighandler */ static pid_t socat_kill_pid; /* here we pass the pid to be killed in sighandler */
static void signal_kill_pid(int dummy) { static void signal_kill_pid(int dummy) {
@ -51,6 +52,7 @@ int xioshutdown(xiofile_t *sock, int how) {
sock->stream.fd, strerror(errno)); sock->stream.fd, strerror(errno));
} }
return 0; return 0;
#if _WITH_SOCKET
case XIOSHUT_DOWN: case XIOSHUT_DOWN:
result = Shutdown(sock->stream.fd, how); result = Shutdown(sock->stream.fd, how);
if (result < 0) { if (result < 0) {
@ -70,7 +72,6 @@ int xioshutdown(xiofile_t *sock, int how) {
return -1; return -1;
} }
return 0; return 0;
#if _WITH_SOCKET
case XIOSHUT_NULL: case XIOSHUT_NULL:
writenull = '\0'; /* assign something to make gcc happy */ writenull = '\0'; /* assign something to make gcc happy */
/* send an empty packet; only useful on datagram sockets? */ /* send an empty packet; only useful on datagram sockets? */

View file

@ -116,8 +116,10 @@ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) {
case XIOWRITE_PIPE: case XIOWRITE_PIPE:
if (pipe->para.bipipe.socktype == SOCK_STREAM) { if (pipe->para.bipipe.socktype == SOCK_STREAM) {
writt = Write(pipe->para.bipipe.fdout, buff, bytes); writt = Write(pipe->para.bipipe.fdout, buff, bytes);
#if _WITH_SOCKET
} else { } else {
writt = Send(pipe->para.bipipe.fdout, buff, bytes, 0); writt = Send(pipe->para.bipipe.fdout, buff, bytes, 0);
#endif /* _WITH_SOCKET */
} }
_errno = errno; _errno = errno;
if (writt < 0) { if (writt < 0) {