mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
ndr: Implement push function for IPv6 addresses
Thanks to Julien Kerihuel for providing the patch that pushed me to finish my own IPv6 patches.
This commit is contained in:
parent
013780b1e1
commit
ee7ee2c4c2
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)";
|
||||
|
Loading…
Reference in New Issue
Block a user