summaryrefslogtreecommitdiff
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
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.
-rw-r--r--librpc/ndr/libndr.h1
-rw-r--r--librpc/ndr/ndr_basic.c15
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm6
3 files changed, 18 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;
}
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index b494ec9b98..3318229f0e 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -921,6 +921,11 @@ sub ConvertObjectFromPythonData($$$$$$;$)
return;
}
+ if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "ipv6address") {
+ $self->pidl("$target = PyString_AsString($cvar);");
+ return;
+ }
+
if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "dnsp_name") {
$self->pidl("$target = PyString_AS_STRING($cvar);");
return;
@@ -1088,6 +1093,7 @@ sub ConvertScalarToPython($$$)
# Not yet supported
if ($ctypename eq "string_array") { return "PyCObject_FromTallocPtr($cvar)"; }
if ($ctypename eq "ipv4address") { return "PyString_FromString_check_null($cvar)"; }
+ if ($ctypename eq "ipv6address") { return "PyString_FromString_check_null($cvar)"; }
if ($ctypename eq "dnsp_name") { return "PyString_FromString_check_null($cvar)"; }
if ($ctypename eq "pointer") {
return "PyCObject_FromTallocPtr($cvar)";