summaryrefslogtreecommitdiff
path: root/source3/librpc/ndr
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-04-03 12:28:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:06 -0500
commit0389cad7c492eda5aee590d0396748c7da9b44ff (patch)
tree13bb3ae9d118d2eb17e374be0a2a675d03f11ff6 /source3/librpc/ndr
parent4432df38eeffa3f9d63b908ce2d0af8d00297078 (diff)
downloadsamba-0389cad7c492eda5aee590d0396748c7da9b44ff.tar.gz
samba-0389cad7c492eda5aee590d0396748c7da9b44ff.tar.bz2
samba-0389cad7c492eda5aee590d0396748c7da9b44ff.zip
r22055: Port the endpoint mapper (and functions it requires) to Samba 3.
(This used to be commit ad981261877e6a2dce0c4f4e71fd9127aa31538a)
Diffstat (limited to 'source3/librpc/ndr')
-rw-r--r--source3/librpc/ndr/ndr_basic.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/source3/librpc/ndr/ndr_basic.c b/source3/librpc/ndr/ndr_basic.c
index 913dfc7e65..c7c6281fea 100644
--- a/source3/librpc/ndr/ndr_basic.c
+++ b/source3/librpc/ndr/ndr_basic.c
@@ -479,12 +479,17 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p)
/*
push a 'simple' full non-zero value if a pointer is non-NULL, otherwise 0
*/
-NTSTATUS ndr_push_sptr_ptr(struct ndr_push *ndr, const void *p)
+NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p)
{
uint32_t ptr = 0;
if (p) {
- ndr->ptr_count++;
- ptr = ndr->ptr_count;
+ /* Check if the pointer already exists and has an id */
+ ptr = ndr_token_peek(&ndr->full_ptr_list, p);
+ if (ptr == 0) {
+ ndr->ptr_count++;
+ ptr = ndr->ptr_count;
+ ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr);
+ }
}
return ndr_push_uint32(ndr, NDR_SCALARS, ptr);
}
@@ -572,6 +577,43 @@ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t)
return NT_STATUS_OK;
}
+/*
+ pull a ipv4address
+*/
+NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address)
+{
+ struct in_addr in;
+ NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.s_addr));
+ in.s_addr = htonl(in.s_addr);
+ *address = talloc_strdup(ndr->current_mem_ctx, inet_ntoa(in));
+ NT_STATUS_HAVE_NO_MEMORY(*address);
+ return NT_STATUS_OK;
+}
+
+/*
+ push a ipv4address
+*/
+NTSTATUS ndr_push_ipv4address(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 IPv4 address: '%s'",
+ address);
+ }
+ addr = inet_addr(address);
+ NDR_CHECK(ndr_push_uint32(ndr, ndr_flags, htonl(addr)));
+ return NT_STATUS_OK;
+}
+
+/*
+ print a ipv4address
+*/
+void ndr_print_ipv4address(struct ndr_print *ndr, const char *name,
+ const char *address)
+{
+ ndr->print(ndr, "%-25s: %s", name, address);
+}
void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type)
{