mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 15:32:35 +00:00
Fixed option sourceport with UDP6-DATAGRAM
This commit is contained in:
parent
f61a95585b
commit
c00262b42d
2 changed files with 15 additions and 1 deletions
2
CHANGES
2
CHANGES
|
@ -204,6 +204,8 @@ Corrections:
|
|||
Thanks to Hiroshi Sakurai for reporting the problem and suggesting this
|
||||
solution.
|
||||
|
||||
Fixed option sourceport with UDP6-DATAGRAM.
|
||||
|
||||
Coding:
|
||||
Introduced groups_t instead of uint32_t, for more flexibility.
|
||||
|
||||
|
|
14
xio-udp.c
14
xio-udp.c
|
@ -465,10 +465,10 @@ static int xioopen_udp_datagram(
|
|||
if (retropt_ushort(opts, OPT_SOURCEPORT, &sfd->para.socket.ip.sourceport)
|
||||
>= 0) {
|
||||
sfd->para.socket.ip.dosourceport = true;
|
||||
sfd->para.socket.ip.sourceport = ntohs(sfd->peersa.ip4.sin_port);
|
||||
}
|
||||
|
||||
retropt_socket_pf(opts, &pf);
|
||||
|
||||
result =
|
||||
_xioopen_udp_sendto(hostname, argv[2], opts, xioflags, xxfd,
|
||||
addrdesc->groups, pf, socktype, ipproto);
|
||||
|
@ -477,6 +477,18 @@ static int xioopen_udp_datagram(
|
|||
return result;
|
||||
}
|
||||
|
||||
if (sfd->para.socket.ip.dosourceport) {
|
||||
switch (sfd->peersa.soa.sa_family) {
|
||||
case PF_INET:
|
||||
default:
|
||||
sfd->para.socket.ip.sourceport = ntohs(sfd->peersa.ip4.sin_port);
|
||||
break;
|
||||
case PF_INET6:
|
||||
sfd->para.socket.ip.sourceport = ntohs(sfd->peersa.ip6.sin6_port);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sfd->dtype = XIOREAD_RECV|XIOWRITE_SENDTO;
|
||||
|
||||
sfd->para.socket.la.soa.sa_family = sfd->peersa.soa.sa_family;
|
||||
|
|
Loading…
Reference in a new issue