summaryrefslogtreecommitdiff
path: root/librpc/ndr
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2010-09-28 20:33:54 -0700
committerKai Blin <kai@samba.org>2010-10-04 20:59:59 +0200
commitee7ee2c4c2f4c75c355cc06ce29d1ef59b2ae581 (patch)
treef1b10c7426fc47d9aa7dbd8777c2b84ef04a39a5 /librpc/ndr
parent013780b1e1942522dfee59d973a341b5f18ace67 (diff)
downloadsamba-ee7ee2c4c2f4c75c355cc06ce29d1ef59b2ae581.tar.gz
samba-ee7ee2c4c2f4c75c355cc06ce29d1ef59b2ae581.tar.bz2
samba-ee7ee2c4c2f4c75c355cc06ce29d1ef59b2ae581.zip
ndr: Implement push function for IPv6 addresses
Thanks to Julien Kerihuel for providing the patch that pushed me to finish my own IPv6 patches.
Diffstat (limited to 'librpc/ndr')
-rw-r--r--librpc/ndr/libndr.h1
-rw-r--r--librpc/ndr/ndr_basic.c15
2 files changed, 12 insertions, 4 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 93d95cf398..c110b76ae5 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -189,6 +189,7 @@ enum ndr_err_code {
NDR_ERR_RANGE,
NDR_ERR_TOKEN,
NDR_ERR_IPV4ADDRESS,
+ NDR_ERR_IPV6ADDRESS,
NDR_ERR_INVALID_POINTER,
NDR_ERR_UNREAD_BYTES,
NDR_ERR_NDR64
diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c
index aa49898dd0..31a8b9de6d 100644
--- a/librpc/ndr/ndr_basic.c
+++ b/librpc/ndr/ndr_basic.c
@@ -876,14 +876,21 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ipv6address(struct ndr_pull *ndr, int ndr_fl
*/
_PUBLIC_ enum ndr_err_code ndr_push_ipv6address(struct ndr_push *ndr, int ndr_flags, const char *address)
{
- uint32_t addr;
+ uint8_t addr[IPV6_BYTES];
+ int ret;
+
if (!is_ipaddress(address)) {
- return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS,
+ return ndr_push_error(ndr, NDR_ERR_IPV6ADDRESS,
"Invalid IPv6 address: '%s'",
address);
}
- addr = inet_addr(address);
- NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr)));
+ ret = inet_pton(AF_INET6, address, addr);
+ if (ret <= 0) {
+ return NDR_ERR_IPV6ADDRESS;
+ }
+
+ NDR_CHECK(ndr_push_array_uint8(ndr, ndr_flags, addr, IPV6_BYTES));
+
return NDR_ERR_SUCCESS;
}