1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-11 06:22:58 +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,8 +7,6 @@
#include "xiosysincludes.h"
#if _WITH_SOCKET
#include "xioopen.h"
#include "xio-ascii.h"
#include "xio-socket.h"
@ -30,6 +28,8 @@
#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_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);
@ -263,7 +263,12 @@ static int xioopen_socket_connect(
socket_init(0, &us);
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) {
needbind = true;
us.soa.sa_family = pf;
@ -540,7 +545,12 @@ int xioopen_socket_recvfrom(
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
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) {
free(rangename);
return STAT_NORETRY;
@ -626,7 +636,12 @@ int xioopen_socket_recv(
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
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) {
free(rangename);
return STAT_NORETRY;
@ -712,7 +727,12 @@ static int xioopen_socket_datagram(
/* which reply sockets will accept - determine by range option */
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
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) {
free(rangename);
return STAT_NORETRY;
@ -1202,6 +1222,7 @@ int _xioopen_dgram_recvfrom(struct single *sfd, int xioflags,
}
#endif
#if WITH_IP4
/* for generic sockets, this has already been retrieved */
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, pf, &sfd->para.socket.range,
@ -1213,6 +1234,7 @@ int _xioopen_dgram_recvfrom(struct single *sfd, int xioflags,
free(rangename);
sfd->para.socket.dorange = true;
}
#endif /* WITH_IP4 */
#if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP
xio_retropt_tcpwrap(sfd, opts);
@ -1424,6 +1446,7 @@ int _xioopen_dgram_recv(struct single *sfd, int xioflags,
}
#endif
#if WITH_IP4
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
if (xioparserange(rangename, pf, &sfd->para.socket.range,
sfd->para.socket.ip.ai_flags)
@ -1434,6 +1457,7 @@ int _xioopen_dgram_recv(struct single *sfd, int xioflags,
free(rangename);
sfd->para.socket.dorange = true;
}
#endif /* WITH_IP4 */
#if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP
xio_retropt_tcpwrap(sfd, opts);
@ -1449,7 +1473,10 @@ int _xioopen_dgram_recv(struct single *sfd, int xioflags,
return STAT_OK;
}
#endif /* _WITH_SOCKET */
#if _WITH_SOCKET || _WITH_SOCKETPAIR
int retropt_socket_pf(struct opt *opts, int *pf) {
char *pfname;
@ -1478,8 +1505,11 @@ int retropt_socket_pf(struct opt *opts, int *pf) {
}
return -1;
}
#endif /* _WITH_SOCKET || _WITH_SOCKETPAIR */
#if _WITH_SOCKET
/* This function calls recvmsg(..., MSG_PEEK, ...) to obtain information about
the arriving packet, thus it does not "consume" the packet.
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];
int result;
#if WITH_IP4
#if WITH_IP4 || WITH_IP6
if (sfd->para.socket.dorange) {
if (pa == NULL) { return -1; }
if (xiocheckrange(pa, &sfd->para.socket.range) < 0) {
@ -2055,9 +2085,7 @@ int xiosetsockaddrenv(const char *lr,
# 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
ev. generates an appropriate error message.
@ -2080,24 +2108,6 @@ xiosocket(struct opt *opts, int pf, int socktype, int proto, int msglevel) {
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
domain, Linux abstract UNIX domain.
The bind address us may be NULL in which case no bind() happens, except with
@ -2206,8 +2216,12 @@ int xiobind(
if (us) {
sinp = us;
} else {
if (pf == AF_INET) {
if (0) {
;
#if WITH_IP4
} else if (pf == AF_INET) {
socket_in_init(&sin.ip4);
#endif
#if WITH_IP6
} else {
socket_in6_init(&sin.ip6);
@ -2307,10 +2321,12 @@ int xiosock_reuseaddr(int fd, int ipproto, struct opt *opts)
val.u_int = 0;
notnull.u_bool = false;
#if WITH_TCP
if (ipproto == IPPROTO_TCP) {
val.u_int = 1;
notnull.u_bool = true;
}
#endif /* WITH_TCP */
retropt_2integrals(opts, OPT_SO_REUSEADDR, &val, &notnull);
if (notnull.u_bool) {
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;
}
#endif /* _WITH_SOCKET */