mirror of
https://repo.or.cz/socat.git
synced 2025-07-13 23:13:24 +00:00
Fixed UDP-LISTEN with bind to IPv4 address on option -0
This commit is contained in:
parent
c4844692f3
commit
0f1c5dd85a
5 changed files with 131 additions and 26 deletions
21
xioopts.c
21
xioopts.c
|
@ -3258,7 +3258,8 @@ int retropt_bind(struct opt *opts,
|
|||
int ipproto,
|
||||
struct sockaddr *sa,
|
||||
socklen_t *salen,
|
||||
int feats, /* TCP etc: 1..address allowed,
|
||||
int feats, /* -1..generic addr spec
|
||||
TCP etc: 1..address allowed,
|
||||
3..address and port allowed
|
||||
UNIX (or'd): 1..tight
|
||||
2..abstract
|
||||
|
@ -3282,10 +3283,13 @@ int retropt_bind(struct opt *opts,
|
|||
}
|
||||
bindp = bindname;
|
||||
|
||||
switch (af) {
|
||||
#if WITH_IP4 && WITH_IP6
|
||||
/* Try to derive address family from string */
|
||||
if (af == AF_UNSPEC && bindname[0] == '[')
|
||||
af = AF_INET6;
|
||||
#endif /* WITH_IP4 && WITH_IP6 */
|
||||
|
||||
case AF_UNSPEC:
|
||||
{
|
||||
if (feats == -1) {
|
||||
size_t p = 0;
|
||||
dalan(bindname, (uint8_t *)sa->sa_data, &p, *salen-sizeof(sa->sa_family), 'i');
|
||||
*salen = p + sizeof(sa->sa_family);
|
||||
|
@ -3297,10 +3301,13 @@ int retropt_bind(struct opt *opts,
|
|||
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||
sa->sa_len = *salen;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
return STAT_OK;
|
||||
}
|
||||
|
||||
switch (af) {
|
||||
|
||||
#if WITH_IP4 || WITH_IP6 || WITH_VSOCK
|
||||
case AF_UNSPEC:
|
||||
#if WITH_VSOCK
|
||||
case AF_VSOCK:
|
||||
#endif
|
||||
|
@ -3336,7 +3343,7 @@ int retropt_bind(struct opt *opts,
|
|||
ai_flags2[0] = ai_flags[0];
|
||||
ai_flags2[1] = ai_flags[1];
|
||||
if (!(ai_flags2[1] & AI_PASSIVE))
|
||||
ai_flags2[0] |= AI_PASSIVE;
|
||||
ai_flags2[0] |= AI_PASSIVE;
|
||||
|
||||
if ((result =
|
||||
xioresolve(hostname[0]!='\0'?hostname:NULL, portp,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue