* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: client.c,v 1.176.2.14 2004/03/09 06:09:17 marka Exp $ */
+/* $Id: client.c,v 1.176.2.15 2004/04/28 14:17:03 marka Exp $ */
#include <config.h>
}
/*
- * Determine the destination address. For IPv6, we get this from the
- * pktinfo structure (if supported). For IPv4, we have to make do with
+ * Determine the destination address. For TCP/IPv6, we get this from
+ * the receiving socket. For UDP/IPv6, we get it from the pktinfo
+ * structure (if supported). For IPv4, we have to do with
* the address of the interface where the request was received.
*/
if (client->interface->addr.type.sa.sa_family == AF_INET6) {
- if ((client->attributes & NS_CLIENTATTR_PKTINFO) != 0)
+ result = ISC_R_FAILURE;
+
+ if (TCP_CLIENT(client)) {
+ isc_sockaddr_t destsockaddr;
+
+ result = isc_socket_getsockname(client->tcpsocket,
+ &destsockaddr);
+ if (result == ISC_R_SUCCESS)
+ isc_netaddr_fromsockaddr(&destaddr,
+ &destsockaddr);
+ }
+ if (result != ISC_R_SUCCESS &&
+ (client->attributes & NS_CLIENTATTR_PKTINFO) != 0) {
isc_netaddr_fromin6(&destaddr, &client->pktinfo.ipi6_addr);
- else
- isc_netaddr_any6(&destaddr);
+ result = ISC_R_SUCCESS;
+ }
+ if (result != ISC_R_SUCCESS) {
+ UNEXPECTED_ERROR(__FILE__, __LINE__,
+ "failed to get request's "
+ "destination: %s",
+ isc_result_totext(result));
+ goto cleanup;
+ }
} else {
isc_netaddr_fromsockaddr(&destaddr, &client->interface->addr);
}