summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-01 04:12:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:28 -0500
commit9b9c23b19be5a90821e1075a76f8b94fdb2424e2 (patch)
treef968db44bf97befaa4d19136e83c508cd3932b35 /source4/librpc
parentc4f115aa1b0029f716d495fa8fa3052d1a833439 (diff)
downloadsamba-9b9c23b19be5a90821e1075a76f8b94fdb2424e2.tar.gz
samba-9b9c23b19be5a90821e1075a76f8b94fdb2424e2.tar.bz2
samba-9b9c23b19be5a90821e1075a76f8b94fdb2424e2.zip
r5155: define ipv4address as a based IDL type, mapped to a "const char *" in
the header, and defined on the wire as a 4 byte network byte order IP. This means the calling code doesn't have to worry about network byte order conversions. (This used to be commit 72048e37179dd5b9ada0c5280d2f0d8c23d1a17d)
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/idl/epmapper.idl2
-rw-r--r--source4/librpc/idl/misc.idl4
-rw-r--r--source4/librpc/idl/nbt.idl2
-rw-r--r--source4/librpc/ndr/ndr_basic.c34
-rw-r--r--source4/librpc/rpc/dcerpc_util.c37
5 files changed, 44 insertions, 35 deletions
diff --git a/source4/librpc/idl/epmapper.idl b/source4/librpc/idl/epmapper.idl
index ba5770b305..89c4e246f9 100644
--- a/source4/librpc/idl/epmapper.idl
+++ b/source4/librpc/idl/epmapper.idl
@@ -99,7 +99,7 @@ interface epmapper
} epm_rhs_tcp;
typedef struct {
- ipv4_addr ipaddr;
+ ipv4address ipaddr;
} epm_rhs_ip;
typedef struct {
diff --git a/source4/librpc/idl/misc.idl b/source4/librpc/idl/misc.idl
index 4b69d1089b..13306b6876 100644
--- a/source4/librpc/idl/misc.idl
+++ b/source4/librpc/idl/misc.idl
@@ -6,10 +6,6 @@
interface misc
{
- typedef [public,noprint] struct {
- uint32 addr;
- } ipv4_addr;
-
typedef [public,noprint,gensize] struct {
uint32 time_low;
uint16 time_mid;
diff --git a/source4/librpc/idl/nbt.idl b/source4/librpc/idl/nbt.idl
index 9dc42fccba..08dde1f018 100644
--- a/source4/librpc/idl/nbt.idl
+++ b/source4/librpc/idl/nbt.idl
@@ -102,7 +102,7 @@ interface nbt
typedef struct {
nb_flags nb_flags;
- ipv4_addr ipaddr;
+ ipv4address ipaddr;
} nbt_rdata_address;
typedef struct {
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index 9601421044..507ee1594b 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -21,6 +21,7 @@
*/
#include "includes.h"
+#include "system/network.h"
#define NDR_BE(ndr) (((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN)
#define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs))
@@ -1017,6 +1018,39 @@ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, time_t *t)
}
+/*
+ pull a ipv4address
+*/
+NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, const char **address)
+{
+ struct ipv4_addr in;
+ NDR_CHECK(ndr_pull_uint32(ndr, &in.addr));
+ in.addr = htonl(in.addr);
+ *address = talloc_strdup(ndr, sys_inet_ntoa(in));
+ NT_STATUS_HAVE_NO_MEMORY(*address);
+ return NT_STATUS_OK;
+}
+
+/*
+ push a ipv4address
+*/
+NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, const char *address)
+{
+ uint32_t addr = interpret_addr(address);
+ NDR_CHECK(ndr_push_uint32(ndr, 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)
{
ndr->print(ndr, "%s: struct %s", name, type);
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 7639ca3fdd..ddc9386c02 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -386,15 +386,7 @@ const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *flo
return talloc_asprintf(mem_ctx, "%d", floor->rhs.http.port);
case EPM_PROTOCOL_IP:
- if (floor->rhs.ip.ipaddr.addr == 0) {
- return NULL;
- }
-
- {
- struct ipv4_addr in;
- in.addr = htonl(floor->rhs.ip.ipaddr.addr);
- return talloc_strdup(mem_ctx, sys_inet_ntoa(in));
- }
+ return talloc_strdup(mem_ctx, floor->rhs.ip.ipaddr);
case EPM_PROTOCOL_NCACN:
return NULL;
@@ -457,11 +449,8 @@ static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor
return NT_STATUS_OK;
case EPM_PROTOCOL_IP:
- if (strlen(data) > 0) {
- floor->rhs.ip.ipaddr.addr = ntohl(interpret_addr(data));
- } else {
- floor->rhs.ip.ipaddr.addr = 0;
- }
+ floor->rhs.ip.ipaddr = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(floor->rhs.ip.ipaddr);
return NT_STATUS_OK;
case EPM_PROTOCOL_NCACN:
@@ -474,23 +463,17 @@ static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor
case EPM_PROTOCOL_SMB:
floor->rhs.smb.unc = talloc_strdup(mem_ctx, data);
- if (!floor->rhs.smb.unc) {
- return NT_STATUS_NO_MEMORY;
- }
+ NT_STATUS_HAVE_NO_MEMORY(floor->rhs.smb.unc);
return NT_STATUS_OK;
case EPM_PROTOCOL_PIPE:
floor->rhs.pipe.path = talloc_strdup(mem_ctx, data);
- if (!floor->rhs.pipe.path) {
- return NT_STATUS_NO_MEMORY;
- }
+ NT_STATUS_HAVE_NO_MEMORY(floor->rhs.pipe.path);
return NT_STATUS_OK;
case EPM_PROTOCOL_NETBIOS:
floor->rhs.netbios.name = talloc_strdup(mem_ctx, data);
- if (!floor->rhs.netbios.name) {
- return NT_STATUS_NO_MEMORY;
- }
+ NT_STATUS_HAVE_NO_MEMORY(floor->rhs.netbios.name);
return NT_STATUS_OK;
case EPM_PROTOCOL_NCALRPC:
@@ -506,16 +489,12 @@ static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor
case EPM_PROTOCOL_STREETTALK:
floor->rhs.streettalk.streettalk = talloc_strdup(mem_ctx, data);
- if (!floor->rhs.streettalk.streettalk) {
- return NT_STATUS_NO_MEMORY;
- }
+ NT_STATUS_HAVE_NO_MEMORY(floor->rhs.streettalk.streettalk);
return NT_STATUS_OK;
case EPM_PROTOCOL_UNIX_DS:
floor->rhs.unix_ds.path = talloc_strdup(mem_ctx, data);
- if (!floor->rhs.unix_ds.path) {
- return NT_STATUS_NO_MEMORY;
- }
+ NT_STATUS_HAVE_NO_MEMORY(floor->rhs.unix_ds.path);
return NT_STATUS_OK;
case EPM_PROTOCOL_NULL: