1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

r6933: Add a couple of helper functions for creating nbt names.

(This used to be commit b896daf11c)
This commit is contained in:
Tim Potter 2005-05-22 10:23:01 +00:00 committed by Gerald (Jerry) Carter
parent ffbeabef64
commit 2b7fe67f4d
16 changed files with 41 additions and 55 deletions

View File

@ -3274,9 +3274,7 @@ static int do_message_op(void)
struct nbt_name called, calling;
const char *server_name;
calling.name = lp_netbios_name();
calling.type = NBT_NAME_CLIENT;
calling.scope = NULL;
make_nbt_name_client(&calling, lp_netbios_name());
nbt_choose_called_name(NULL, &called, desthost, name_type);

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -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);
}

View File

@ -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;
}

View File

@ -43,9 +43,7 @@ static NTSTATUS libnet_find_pdc_generic(struct libnet_context *ctx, TALLOC_CTX *
return NT_STATUS_OK;
}
name.name = r->generic.in.domain_name;
name.type = NBT_NAME_PDC;
name.scope = NULL;
make_nbt_name(&name, r->generic.in.domain_name, NBT_NAME_PDC);
status = resolve_name(&name, mem_ctx, &address);
if (!NT_STATUS_IS_OK(status)) {

View File

@ -108,9 +108,7 @@ BOOL torture_bench_cldap(void)
NTSTATUS status;
BOOL ret = True;
name.name = lp_parm_string(-1, "torture", "host");
name.type = NBT_NAME_SERVER;
name.scope = NULL;
make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
/* do an initial name resolution to find its IP */
status = resolve_name(&name, mem_ctx, &address);

View File

@ -92,9 +92,7 @@ static BOOL nbt_test_netlogon(TALLOC_CTX *mem_ctx,
logon.req.pdc.lmnt_token = 0xFFFF;
logon.req.pdc.lm20_token = 0xFFFF;
myname.name = TEST_NAME;
myname.type = NBT_NAME_CLIENT;
myname.scope = NULL;
make_nbt_name_client(&myname, TEST_NAME);
status = dgram_mailslot_netlogon_send(dgmsock, &name, address,
0, &myname, &logon);
@ -154,9 +152,7 @@ static BOOL nbt_test_netlogon2(TALLOC_CTX *mem_ctx,
logon.req.pdc2.lmnt_token = 0xFFFF;
logon.req.pdc2.lm20_token = 0xFFFF;
myname.name = TEST_NAME;
myname.type = NBT_NAME_CLIENT;
myname.scope = NULL;
make_nbt_name_client(&myname, TEST_NAME);
status = dgram_mailslot_netlogon_send(dgmsock, &name, address,
0, &myname, &logon);
@ -257,10 +253,7 @@ static BOOL nbt_test_ntlogon(TALLOC_CTX *mem_ctx,
logon.req.logon.lmnt_token = 0xFFFF;
logon.req.logon.lm20_token = 0xFFFF;
myname.name = TEST_NAME;
myname.type = NBT_NAME_CLIENT;
myname.scope = NULL;
make_nbt_name_client(&myname, TEST_NAME);
status = dgram_mailslot_ntlogon_send(dgmsock, &name, address,
0, &myname, &logon);

View File

@ -110,9 +110,7 @@ BOOL torture_bench_nbt(void)
NTSTATUS status;
BOOL ret = True;
name.name = lp_parm_string(-1, "torture", "host");
name.type = NBT_NAME_SERVER;
name.scope = NULL;
make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
/* do an initial name resolution to find its IP */
status = resolve_name(&name, mem_ctx, &address);

View File

@ -160,9 +160,7 @@ BOOL torture_nbt_register(void)
NTSTATUS status;
BOOL ret = True;
name.name = strupper_talloc(mem_ctx, lp_parm_string(-1, "torture", "host"));
name.type = NBT_NAME_SERVER;
name.scope = NULL;
make_nbt_name_server(&name, strupper_talloc(mem_ctx, lp_parm_string(-1, "torture", "host")));
/* do an initial name resolution to find its IP */
status = resolve_name(&name, mem_ctx, &address);

View File

@ -345,9 +345,7 @@ BOOL torture_nbt_wins(void)
NTSTATUS status;
BOOL ret = True;
name.name = lp_parm_string(-1, "torture", "host");
name.type = NBT_NAME_SERVER;
name.scope = NULL;
make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
/* do an initial name resolution to find its IP */
status = resolve_name(&name, mem_ctx, &address);

View File

@ -276,9 +276,7 @@ BOOL torture_bench_wins(void)
NTSTATUS status;
BOOL ret = True;
name.name = lp_parm_string(-1, "torture", "host");
name.type = NBT_NAME_SERVER;
name.scope = NULL;
make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
/* do an initial name resolution to find its IP */
status = resolve_name(&name, mem_ctx, &address);

View File

@ -124,9 +124,7 @@ BOOL torture_nbt_winsreplication(void)
NTSTATUS status;
BOOL ret = True;
name.name = lp_parm_string(-1, "torture", "host");
name.type = NBT_NAME_SERVER;
name.scope = NULL;
make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
/* do an initial name resolution to find its IP */
status = resolve_name(&name, mem_ctx, &address);

View File

@ -56,9 +56,7 @@ static NTSTATUS after_negprot(struct smbcli_transport **dst_transport,
struct nbt_name called;
/* send a NBT session request, if applicable */
calling.name = my_name;
calling.type = NBT_NAME_CLIENT;
calling.scope = NULL;
make_nbt_name_client(&calling, my_name);
nbt_choose_called_name(transport, &called, dest_host, NBT_NAME_SERVER);

View File

@ -49,9 +49,7 @@ static struct smbcli_state *open_nbt_connection(void)
struct smbcli_state *cli;
const char *host = lp_parm_string(-1, "torture", "host");
calling.name = lp_netbios_name();
calling.type = NBT_NAME_CLIENT;
calling.scope = NULL;
make_nbt_name_client(&calling, lp_netbios_name());
nbt_choose_called_name(NULL, &called, host, NBT_NAME_SERVER);