summaryrefslogtreecommitdiff
path: root/source4/libcli/wrepl
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-09-29 14:00:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:12 -0500
commit08f16292a0cfab57c484661c1f05e1a49ec06942 (patch)
treee018b47bf00b965bd6222893256d853707b6f572 /source4/libcli/wrepl
parent9cbafc42ee5cbaae9dfb9d147eefd0e59ff953d0 (diff)
downloadsamba-08f16292a0cfab57c484661c1f05e1a49ec06942.tar.gz
samba-08f16292a0cfab57c484661c1f05e1a49ec06942.tar.bz2
samba-08f16292a0cfab57c484661c1f05e1a49ec06942.zip
r10608: - fix hierachical memory handling in ndr_pull_nbt_name
- add wrepl_nbt_name scalar type and do the pull/push in the ndr layer instead of the caller - give the flags and group_flag in the wrepl_name a meaning metze (This used to be commit b98efc2905e1147eb97111b46a877bdb9d8dd154)
Diffstat (limited to 'source4/libcli/wrepl')
-rw-r--r--source4/libcli/wrepl/winsrepl.c47
-rw-r--r--source4/libcli/wrepl/winsrepl.h16
2 files changed, 22 insertions, 41 deletions
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index 069ee29407..feeea321b1 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -671,40 +671,6 @@ struct wrepl_request *wrepl_pull_names_send(struct wrepl_socket *wrepl_socket,
return req;
}
-
-/*
- extract a nbt_name from a WINS name buffer
-*/
-static NTSTATUS wrepl_extract_name(struct nbt_name *name,
- TALLOC_CTX *mem_ctx,
- uint8_t *namebuf, uint32_t len)
-{
- char *s;
-
- /* oh wow, what a nasty bug in windows ... */
- if (namebuf[0] == 0x1b && len >= 16) {
- namebuf[0] = namebuf[15];
- namebuf[15] = 0x1b;
- }
-
- if (len < 17) {
- make_nbt_name_client(name, talloc_strndup(mem_ctx, (char *)namebuf, len));
- return NT_STATUS_OK;
- }
-
- s = talloc_strndup(mem_ctx, (char *)namebuf, 15);
- trim_string(s, NULL, " ");
- name->name = s;
- name->type = namebuf[15];
- if (len > 18) {
- name->scope = talloc_strndup(mem_ctx, (char *)(namebuf+17), len-17);
- } else {
- name->scope = NULL;
- }
-
- return NT_STATUS_OK;
-}
-
/*
fetch the names for a WINS partner - recv
*/
@@ -735,12 +701,15 @@ NTSTATUS wrepl_pull_names_recv(struct wrepl_request *req,
for (i=0;i<io->out.num_names;i++) {
struct wrepl_wins_name *wname = &packet->message.replication.info.reply.names[i];
struct wrepl_name *name = &io->out.names[i];
- status = wrepl_extract_name(&name->name, io->out.names,
- wname->name, wname->name_len);
- if (!NT_STATUS_IS_OK(status)) goto failed;
- name->flags = wname->flags;
- name->group_flag= wname->group_flag;
+ name->name = wname->name;
+ talloc_steal(io->out.names, wname->name.name);
+ talloc_steal(io->out.names, wname->name.scope);
+ name->type = WREPL_NAME_TYPE(wname->flags);
+ name->state = WREPL_NAME_STATE(wname->flags);
+ name->node = WREPL_NBT_NODE(wname->flags);
+ name->is_static = WREPL_NAME_IS_STATIC(wname->flags);
+ name->raw_flags = wname->flags;
name->version_id= wname->id;
name->owner = talloc_strdup(io->out.names, io->in.partner.address);
if (name->owner == NULL) goto nomem;
diff --git a/source4/libcli/wrepl/winsrepl.h b/source4/libcli/wrepl/winsrepl.h
index 2253fe181e..9b9362e4b3 100644
--- a/source4/libcli/wrepl/winsrepl.h
+++ b/source4/libcli/wrepl/winsrepl.h
@@ -104,6 +104,15 @@ struct wrepl_pull_table {
} out;
};
+#define WREPL_NAME_TYPE(flags) (flags & WREPL_FLAGS_RECORD_TYPE)
+#define WREPL_NAME_STATE(flags) ((flags & WREPL_FLAGS_RECORD_STATE)>>2)
+#define WREPL_NBT_NODE(flags) ((flags & WREPL_FLAGS_NODE_TYPE)<<8)
+#define WREPL_NAME_IS_STATIC(flags) ((flags & WREPL_FLAGS_IS_STATIC)?True:False)
+
+#define WREPL_NAME_FLAGS(type, state, node, is_static) \
+ (type | (state << 2) | (node>>8) | \
+ (is_static ? WREPL_FLAGS_IS_STATIC : 0))
+
/*
a full pull replication
*/
@@ -116,8 +125,11 @@ struct wrepl_pull_names {
uint32_t num_names;
struct wrepl_name {
struct nbt_name name;
- uint32_t flags;
- uint32_t group_flag;
+ enum wrepl_name_type type;
+ enum wrepl_name_state state;
+ enum nbt_node_type node;
+ BOOL is_static;
+ uint32_t raw_flags;
uint64_t version_id;
const char *owner;
uint32_t num_addresses;