diff options
author | Alexander Bokovoy <ab@samba.org> | 2008-01-17 07:26:12 +0300 |
---|---|---|
committer | Alexander Bokovoy <ab@samba.org> | 2008-01-17 07:26:12 +0300 |
commit | 3fffb04990f1af191a2a8b5ebe0e301d7f483102 (patch) | |
tree | 01171a1c6acf905082af9a38d4a1ff8e7caa3f70 /source3/lib/util_sock.c | |
parent | fd03ea4a903b79a0a7894315b3b43fb08108f938 (diff) | |
parent | f44713df4d636203354c55d9a9bc2538073cf0af (diff) | |
download | samba-3fffb04990f1af191a2a8b5ebe0e301d7f483102.tar.gz samba-3fffb04990f1af191a2a8b5ebe0e301d7f483102.tar.bz2 samba-3fffb04990f1af191a2a8b5ebe0e301d7f483102.zip |
Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test
(This used to be commit 4256f8e093e81fbc2c1afd8f823725ae286945ce)
Diffstat (limited to 'source3/lib/util_sock.c')
-rw-r--r-- | source3/lib/util_sock.c | 27 |
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), |