summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-01-16 13:21:46 -0800
committerJeremy Allison <jra@samba.org>2008-01-16 13:21:46 -0800
commitbd8abea49fed09e131ab5162821b0ed05c1ab1b0 (patch)
tree9635cc6fa2ff7a0ba82f6858cde0816ab5d79a3f /source3/lib
parent60c3ec3fca08b7d36df760cd6093adb5a807afa0 (diff)
downloadsamba-bd8abea49fed09e131ab5162821b0ed05c1ab1b0.tar.gz
samba-bd8abea49fed09e131ab5162821b0ed05c1ab1b0.tar.bz2
samba-bd8abea49fed09e131ab5162821b0ed05c1ab1b0.zip
Fix IPv6 bug #5204, which caused krb5 DNS lookups
for a name '[<ipv6 addr>'. Jeremy. (This used to be commit f2aa921505e49f894bfed4e5e2f9fc01918b1bb0)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sock.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 945506ea77..10428113ae 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -476,6 +476,29 @@ bool is_address_any(const struct sockaddr_storage *psa)
}
/****************************************************************************
+ Get a port number in host byte order from a sockaddr_storage.
+****************************************************************************/
+
+uint16_t get_sockaddr_port(const struct sockaddr_storage *pss)
+{
+ uint16_t port = 0;
+
+ if (pss->ss_family != AF_INET) {
+#if defined(HAVE_IPV6)
+ /* IPv6 */
+ const struct sockaddr_in6 *sa6 =
+ (const struct sockaddr_in6 *)pss;
+ port = ntohs(sa6->sin6_port);
+#endif
+ } else {
+ const struct sockaddr_in *sa =
+ (const struct sockaddr_in *)pss;
+ port = ntohs(sa->sin_port);
+ }
+ return port;
+}
+
+/****************************************************************************
Print out an IPv4 or IPv6 address from a struct sockaddr_storage.
****************************************************************************/
@@ -518,7 +541,7 @@ char *print_canonical_sockaddr(TALLOC_CTX *ctx,
char *dest = NULL;
int ret;
- ret = getnameinfo((const struct sockaddr *)pss,
+ ret = sys_getnameinfo((const struct sockaddr *)pss,
sizeof(struct sockaddr_storage),
addr, sizeof(addr),
NULL, 0,
@@ -1847,7 +1870,7 @@ const char *get_peer_name(int fd, bool force_lookup)
}
/* Look up the remote host name. */
- ret = getnameinfo((struct sockaddr *)&ss,
+ ret = sys_getnameinfo((struct sockaddr *)&ss,
length,
name_buf,
sizeof(name_buf),