socket: add support for selecting interface again
Revert commit e49aececce
("socket: don't set interface for sent
packets") to allow the interface to be selected for outgoing packets,
but don't set it in the callers yet.
This commit is contained in:
parent
c4a2550518
commit
99e3c67a81
3 changed files with 10 additions and 1 deletions
3
cmdmon.c
3
cmdmon.c
|
@ -301,6 +301,9 @@ transmit_reply(int sock_fd, SCK_Message *message)
|
||||||
{
|
{
|
||||||
message->length = PKL_ReplyLength((CMD_Reply *)message->data);
|
message->length = PKL_ReplyLength((CMD_Reply *)message->data);
|
||||||
|
|
||||||
|
/* Don't require the response to use the same interface */
|
||||||
|
message->if_index = INVALID_IF_INDEX;
|
||||||
|
|
||||||
if (!SCK_SendMessage(sock_fd, message, 0))
|
if (!SCK_SendMessage(sock_fd, message, 0))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
4
ntp_io.c
4
ntp_io.c
|
@ -452,9 +452,11 @@ NIO_SendPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr,
|
||||||
message.remote_addr.ip.port = remote_addr->port;
|
message.remote_addr.ip.port = remote_addr->port;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.if_index = local_addr->if_index;
|
|
||||||
message.local_addr.ip = local_addr->ip_addr;
|
message.local_addr.ip = local_addr->ip_addr;
|
||||||
|
|
||||||
|
/* Don't require the response to use the same interface */
|
||||||
|
message.if_index = INVALID_IF_INDEX;
|
||||||
|
|
||||||
#if !defined(HAVE_IN_PKTINFO) && defined(IP_SENDSRCADDR)
|
#if !defined(HAVE_IN_PKTINFO) && defined(IP_SENDSRCADDR)
|
||||||
/* On FreeBSD a local IPv4 address cannot be specified on bound socket */
|
/* On FreeBSD a local IPv4 address cannot be specified on bound socket */
|
||||||
if (message.local_addr.ip.family == IPADDR_INET4 &&
|
if (message.local_addr.ip.family == IPADDR_INET4 &&
|
||||||
|
|
4
socket.c
4
socket.c
|
@ -1049,6 +1049,8 @@ send_message(int sock_fd, SCK_Message *message, int flags)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ipi->ipi_spec_dst.s_addr = htonl(message->local_addr.ip.addr.in4);
|
ipi->ipi_spec_dst.s_addr = htonl(message->local_addr.ip.addr.in4);
|
||||||
|
if (message->if_index != INVALID_IF_INDEX)
|
||||||
|
ipi->ipi_ifindex = message->if_index;
|
||||||
|
|
||||||
#elif defined(IP_SENDSRCADDR)
|
#elif defined(IP_SENDSRCADDR)
|
||||||
struct in_addr *addr;
|
struct in_addr *addr;
|
||||||
|
@ -1073,6 +1075,8 @@ send_message(int sock_fd, SCK_Message *message, int flags)
|
||||||
|
|
||||||
memcpy(&ipi->ipi6_addr.s6_addr, &message->local_addr.ip.addr.in6,
|
memcpy(&ipi->ipi6_addr.s6_addr, &message->local_addr.ip.addr.in6,
|
||||||
sizeof(ipi->ipi6_addr.s6_addr));
|
sizeof(ipi->ipi6_addr.s6_addr));
|
||||||
|
if (message->if_index != INVALID_IF_INDEX)
|
||||||
|
ipi->ipi6_ifindex = message->if_index;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue