summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--librpc/ndr/libndr.h1
-rw-r--r--librpc/ndr/ndr_basic.c52
-rw-r--r--pidl/lib/Parse/Pidl/NDR.pm1
-rw-r--r--pidl/lib/Parse/Pidl/Typelist.pm5
4 files changed, 55 insertions, 4 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index bd39cf4c86..93d95cf398 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -493,6 +493,7 @@ NDR_SCALAR_PROTO(NTTIME_1sec, NTTIME)
NDR_SCALAR_PROTO(NTTIME_hyper, NTTIME)
NDR_SCALAR_PROTO(DATA_BLOB, DATA_BLOB)
NDR_SCALAR_PROTO(ipv4address, const char *)
+NDR_SCALAR_PROTO(ipv6address, const char *)
NDR_SCALAR_PROTO(string, const char *)
NDR_SCALAR_PROTO(double, double)
diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c
index c27faa2398..aa49898dd0 100644
--- a/librpc/ndr/ndr_basic.c
+++ b/librpc/ndr/ndr_basic.c
@@ -831,7 +831,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_ipv4address(struct ndr_push *ndr, int ndr_fl
uint32_t addr;
if (!is_ipaddress(address)) {
return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS,
- "Invalid IPv4 address: '%s'",
+ "Invalid IPv4 address: '%s'",
address);
}
addr = inet_addr(address);
@@ -842,12 +842,60 @@ _PUBLIC_ enum ndr_err_code ndr_push_ipv4address(struct ndr_push *ndr, int ndr_fl
/*
print a ipv4address
*/
-_PUBLIC_ void ndr_print_ipv4address(struct ndr_print *ndr, const char *name,
+_PUBLIC_ void ndr_print_ipv4address(struct ndr_print *ndr, const char *name,
const char *address)
{
ndr->print(ndr, "%-25s: %s", name, address);
}
+/*
+ pull a ipv6address
+*/
+#define IPV6_BYTES 16
+#define IPV6_ADDR_STR_LEN 39
+_PUBLIC_ enum ndr_err_code ndr_pull_ipv6address(struct ndr_pull *ndr, int ndr_flags, const char **address)
+{
+ uint8_t addr[IPV6_BYTES];
+ char *addr_str = talloc_strdup(ndr->current_mem_ctx, "");
+ int i;
+ NDR_CHECK(ndr_pull_array_uint8(ndr, ndr_flags, addr, IPV6_BYTES));
+ for (i = 0; i < IPV6_BYTES; ++i) {
+ addr_str = talloc_asprintf_append(addr_str, "%02x", addr[i]);
+ /* We need a ':' every second byte but the last one */
+ if (i%2 == 1 && i != (IPV6_BYTES - 1)) {
+ addr_str = talloc_strdup_append(addr_str, ":");
+ }
+ }
+ *address = addr_str;
+ NDR_ERR_HAVE_NO_MEMORY(*address);
+ return NDR_ERR_SUCCESS;
+}
+
+/*
+ push a ipv6address
+*/
+_PUBLIC_ enum ndr_err_code ndr_push_ipv6address(struct ndr_push *ndr, int ndr_flags, const char *address)
+{
+ uint32_t addr;
+ if (!is_ipaddress(address)) {
+ return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS,
+ "Invalid IPv6 address: '%s'",
+ address);
+ }
+ addr = inet_addr(address);
+ NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr)));
+ return NDR_ERR_SUCCESS;
+}
+
+/*
+ print a ipv6address
+*/
+_PUBLIC_ void ndr_print_ipv6address(struct ndr_print *ndr, const char *name,
+ const char *address)
+{
+ ndr->print(ndr, "%-25s: %s", name, address);
+}
+#undef IPV6_BYTES
_PUBLIC_ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type)
{
diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm
index f079fbc650..4961cda99e 100644
--- a/pidl/lib/Parse/Pidl/NDR.pm
+++ b/pidl/lib/Parse/Pidl/NDR.pm
@@ -75,6 +75,7 @@ my $scalar_alignment = {
'nbt_string' => 4,
'wrepl_nbt_name' => 4,
'ipv4address' => 4,
+ 'ipv6address' => 4, #16?
'dnsp_name' => 1
};
diff --git a/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm
index 238ad834a4..b841e62209 100644
--- a/pidl/lib/Parse/Pidl/Typelist.pm
+++ b/pidl/lib/Parse/Pidl/Typelist.pm
@@ -20,8 +20,8 @@ use strict;
my %types = ();
my @reference_scalars = (
- "string", "string_array", "nbt_string",
- "wrepl_nbt_name", "ipv4address"
+ "string", "string_array", "nbt_string",
+ "wrepl_nbt_name", "ipv4address", "ipv6address"
);
# a list of known scalar types
@@ -57,6 +57,7 @@ my %scalars = (
"nbt_string" => "const char *",
"wrepl_nbt_name"=> "struct nbt_name *",
"ipv4address" => "const char *",
+ "ipv6address" => "const char *",
"dnsp_name" => "const char *",
);