diff options
author | Tim Potter <tpot@samba.org> | 2005-05-22 10:23:01 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:16:58 -0500 |
commit | 2b7fe67f4d02f861c9a4bfe823e648f0a995e613 (patch) | |
tree | 969cd8c1c004517303dc25629ecaf0227c45bfbe /source4/libcli | |
parent | ffbeabef646987f02b98cd1f781d3c2a614b3d24 (diff) | |
download | samba-2b7fe67f4d02f861c9a4bfe823e648f0a995e613.tar.gz samba-2b7fe67f4d02f861c9a4bfe823e648f0a995e613.tar.bz2 samba-2b7fe67f4d02f861c9a4bfe823e648f0a995e613.zip |
r6933: Add a couple of helper functions for creating nbt names.
(This used to be commit b896daf11c3efb1b3ca939575da9dab82b395777)
Diffstat (limited to 'source4/libcli')
-rw-r--r-- | source4/libcli/composite/connect.c | 8 | ||||
-rw-r--r-- | source4/libcli/dgram/netlogon.c | 4 | ||||
-rw-r--r-- | source4/libcli/dgram/ntlogon.c | 4 | ||||
-rw-r--r-- | source4/libcli/resolve/resolve.c | 23 | ||||
-rw-r--r-- | source4/libcli/wins/winsrepl.c | 4 |
5 files changed, 28 insertions, 15 deletions
diff --git a/source4/libcli/composite/connect.c b/source4/libcli/composite/connect.c index 0da71df992..526eee8cb8 100644 --- a/source4/libcli/composite/connect.c +++ b/source4/libcli/composite/connect.c @@ -213,9 +213,7 @@ static NTSTATUS connect_socket(struct composite_context *c, state->transport = smbcli_transport_init(state->sock, state, True); NT_STATUS_HAVE_NO_MEMORY(state->transport); - calling.name = cli_credentials_get_workstation(io->in.credentials); - calling.type = NBT_NAME_CLIENT; - calling.scope = NULL; + make_nbt_name_client(&calling, cli_credentials_get_workstation(io->in.credentials)); nbt_choose_called_name(state, &called, io->in.called_name, NBT_NAME_SERVER); @@ -349,9 +347,7 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec c->event_ctx = talloc_reference(c, state->sock->event.ctx); c->private = state; - name.name = io->in.dest_host; - name.type = NBT_NAME_SERVER; - name.scope = NULL; + make_nbt_name_server(&name, io->in.dest_host); state->creq = resolve_name_send(&name, c->event_ctx); if (state->creq == NULL) goto failed; diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c index 6e939725d0..9d3a0dbed9 100644 --- a/source4/libcli/dgram/netlogon.c +++ b/source4/libcli/dgram/netlogon.c @@ -79,9 +79,7 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock, return status; } - myname.name = lp_netbios_name(); - myname.type = NBT_NAME_CLIENT; - myname.scope = NULL; + make_nbt_name_client(&myname, lp_netbios_name()); status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, mailslot_name, diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c index 38651a4085..e4a24b0591 100644 --- a/source4/libcli/dgram/ntlogon.c +++ b/source4/libcli/dgram/ntlogon.c @@ -79,9 +79,7 @@ NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock, return status; } - myname.name = lp_netbios_name(); - myname.type = NBT_NAME_CLIENT; - myname.scope = NULL; + make_nbt_name_client(&myname, lp_netbios_name()); status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE, mailslot_name, diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c index 82268dc953..a3bbd60920 100644 --- a/source4/libcli/resolve/resolve.c +++ b/source4/libcli/resolve/resolve.c @@ -181,3 +181,26 @@ NTSTATUS resolve_name(struct nbt_name *name, TALLOC_CTX *mem_ctx, const char **r struct composite_context *c = resolve_name_send(name, NULL); return resolve_name_recv(c, mem_ctx, reply_addr); } + +/* Initialise a struct nbt_name with a NULL scope */ + +void make_nbt_name(struct nbt_name *nbt, const char *name, int type) +{ + nbt->name = name; + nbt->scope = NULL; + nbt->type = type; +} + +/* Initialise a struct nbt_name with a NBT_NAME_CLIENT (0x00) name */ + +void make_nbt_name_client(struct nbt_name *nbt, const char *name) +{ + make_nbt_name(nbt, name, NBT_NAME_CLIENT); +} + +/* Initialise a struct nbt_name with a NBT_NAME_SERVER (0x20) name */ + +void make_nbt_name_server(struct nbt_name *nbt, const char *name) +{ + make_nbt_name(nbt, name, NBT_NAME_SERVER); +} diff --git a/source4/libcli/wins/winsrepl.c b/source4/libcli/wins/winsrepl.c index 7a3ce72b91..65b713202f 100644 --- a/source4/libcli/wins/winsrepl.c +++ b/source4/libcli/wins/winsrepl.c @@ -602,9 +602,7 @@ static NTSTATUS wrepl_extract_name(struct nbt_name *name, } if (len < 17) { - name->name = talloc_strndup(mem_ctx, namebuf, len); - name->type = NBT_NAME_CLIENT; - name->scope = NULL; + make_nbt_name_client(name, talloc_strndup(mem_ctx, namebuf, len)); return NT_STATUS_OK; } |