1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

added tests for epm_Map endpointer map calls

This commit is contained in:
Andrew Tridgell 0001-01-01 00:00:00 +00:00
parent 4203019698
commit 570ad78525
3 changed files with 62 additions and 27 deletions

View File

@ -30,7 +30,7 @@ interface epmapper
typedef [nodiscriminant] union {
[case(13)] epm_prot_uuid uuid;
[default] ;
[default] [flag(NDR_REMAINING)] DATA_BLOB lhs_data;
} epm_protocol_info;
typedef struct {
@ -39,7 +39,7 @@ interface epmapper
} epm_lhs;
typedef struct {
[flag(NDR_REMAINING)] DATA_BLOB data;
[flag(NDR_REMAINING)] DATA_BLOB rhs_data;
} epm_rhs;
typedef struct {
@ -47,10 +47,10 @@ interface epmapper
[subcontext(2)] epm_rhs rhs;
} epm_floor;
/* not that the NDR_NOALIGN flag is inherited by all nested
/* note that the NDR_NOALIGN flag is inherited by all nested
structures. All of the towers/floors stuff is
non-aligned. I wonder what sort of wicked substance these
guys were smoking?
guys were smoking?
*/
typedef [flag(NDR_NOALIGN)] struct {
uint16 num_floors;

View File

@ -782,6 +782,9 @@ void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *
void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r)
{
ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length);
if (r.length) {
dump_data(10, r.data, r.length);
}
}

View File

@ -48,47 +48,40 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr)
case 0x9:
printf(" IP:");
if (rhs->data.length == 4) {
if (rhs->rhs_data.length == 4) {
struct in_addr in;
in.s_addr = RIVAL(rhs->data.data, 0);
in.s_addr = RIVAL(rhs->rhs_data.data, 0);
printf("%s", inet_ntoa(in));
}
break;
case 0x10:
printf(" PIPE:%.*s", rhs->data.length, rhs->data.data);
printf(" PIPE:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
break;
case 0x0f:
printf(" SMBNP:%.*s", rhs->data.length, rhs->data.data);
printf(" SMB:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
break;
case 0x11:
printf(" SMB:%.*s", rhs->data.length, rhs->data.data);
printf(" NetBIOS:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
break;
case 0x01:
printf(" UNK(1):%.*s", rhs->data.length, rhs->data.data);
printf(" UNK(1):%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
break;
case 0x1f:
printf(" TCP:");
if (rhs->data.length == 2) {
printf("%d", SVAL(rhs->data.data, 0));
}
break;
case 0x07:
printf(" XXX:");
if (rhs->data.length == 2) {
printf("%d", SVAL(rhs->data.data, 0));
if (rhs->rhs_data.length == 2) {
printf("%d", SVAL(rhs->rhs_data.data, 0));
}
break;
default:
printf(" UNK(%02x):", lhs->protocol);
if (rhs->data.length == 2) {
printf("%d", SVAL(rhs->data.data, 0));
if (rhs->rhs_data.length == 2) {
printf("%d", SVAL(rhs->rhs_data.data, 0));
}
break;
}
@ -96,6 +89,43 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr)
printf("\n");
}
static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct epm_twr_t *twr)
{
NTSTATUS status;
struct epm_Map r;
GUID uuid;
struct policy_handle handle;
int i;
ZERO_STRUCT(uuid);
ZERO_STRUCT(handle);
r.in.object = &uuid;
r.in.map_tower = twr;
r.in.entry_handle = &handle;
r.out.entry_handle = &handle;
r.in.max_towers = 100;
status = dcerpc_epm_Map(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status) || r.out.status != 0) {
printf("epm_Map failed - %s/0x%x\n",
nt_errstr(status), r.out.status);
return False;
}
printf("epm_Map results:\n");
for (i=0;i<r.out.num_towers;i++) {
if (r.out.towers[i].twr) {
display_tower(mem_ctx, &r.out.towers[i].twr->towers);
}
}
return True;
}
static BOOL test_Lookup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
@ -117,13 +147,15 @@ static BOOL test_Lookup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
r.in.max_ents = 10;
do {
int i;
status = dcerpc_epm_Lookup(p, mem_ctx, &r);
if (NT_STATUS_IS_OK(status) && r.out.status == 0) {
int i;
for (i=0;i<r.out.num_ents;i++) {
printf("Found '%s'\n", r.out.entries[i].annotation);
display_tower(mem_ctx, &r.out.entries[i].tower->towers);
}
if (!NT_STATUS_IS_OK(status) || r.out.status != 0) {
break;
}
for (i=0;i<r.out.num_ents;i++) {
printf("\nFound '%s'\n", r.out.entries[i].annotation);
display_tower(mem_ctx, &r.out.entries[i].tower->towers);
test_Map(p, mem_ctx, r.out.entries[i].tower);
}
} while (NT_STATUS_IS_OK(status) &&
r.out.status == 0 &&