mirror of
https://github.com/samba-team/samba.git
synced 2025-02-25 17:57:42 +03:00
r2938: Use IDL to dissect the RHS of floors in protocol towers
(This used to be commit 273d0049b5339e3288b264e5a4393bfab1d4e239)
This commit is contained in:
parent
f2657b2cb1
commit
ae0aa86039
@ -74,18 +74,113 @@ interface epmapper
|
||||
[default] [flag(NDR_REMAINING)] DATA_BLOB lhs_data;
|
||||
} epm_protocol_info;
|
||||
|
||||
typedef struct {
|
||||
//FIXME
|
||||
} epm_rhs_dnet_nsp;
|
||||
|
||||
typedef struct {
|
||||
//FIXME
|
||||
} epm_rhs_osi_tp4;
|
||||
|
||||
typedef struct {
|
||||
//FIXME
|
||||
} epm_rhs_osi_clns;
|
||||
|
||||
typedef struct {
|
||||
uint16 port;
|
||||
} epm_rhs_udp;
|
||||
|
||||
typedef struct {
|
||||
uint16 port;
|
||||
} epm_rhs_tcp;
|
||||
|
||||
typedef struct {
|
||||
uint32 address;
|
||||
} epm_rhs_ip;
|
||||
|
||||
typedef struct {
|
||||
uint16 minor_version;
|
||||
} epm_rhs_ncadg;
|
||||
|
||||
typedef struct {
|
||||
uint16 minor_version;
|
||||
} epm_rhs_ncacn;
|
||||
|
||||
typedef struct {
|
||||
uint16 unknown;
|
||||
} epm_rhs_uuid;
|
||||
|
||||
typedef struct {
|
||||
//FIXME
|
||||
} epm_rhs_ipx;
|
||||
|
||||
typedef struct {
|
||||
astring unc;
|
||||
} epm_rhs_smb;
|
||||
|
||||
typedef struct {
|
||||
astring path;
|
||||
} epm_rhs_pipe;
|
||||
|
||||
typedef struct {
|
||||
astring name;
|
||||
} epm_rhs_netbios;
|
||||
|
||||
typedef struct {
|
||||
} epm_rhs_nb_nb;
|
||||
|
||||
typedef struct {
|
||||
} epm_rhs_spx;
|
||||
|
||||
typedef struct {
|
||||
} epm_rhs_nb_ipx;
|
||||
|
||||
typedef struct {
|
||||
uint16 port;
|
||||
} epm_rhs_http;
|
||||
|
||||
typedef struct {
|
||||
astring path;
|
||||
} epm_rhs_unix_ds;
|
||||
|
||||
typedef struct {
|
||||
} epm_rhs_null;
|
||||
|
||||
typedef struct {
|
||||
} epm_rhs_ncalrpc;
|
||||
|
||||
typedef [nodiscriminant] union {
|
||||
[case(EPM_PROTOCOL_DNET_NSP)] epm_rhs_dnet_nsp dnet_nsp;
|
||||
[case(EPM_PROTOCOL_OSI_TP4)] epm_rhs_osi_tp4 osi_tp4;
|
||||
[case(EPM_PROTOCOL_OSI_CLNS)] epm_rhs_osi_clns osi_clns;
|
||||
[case(EPM_PROTOCOL_TCP)] epm_rhs_tcp tcp;
|
||||
[case(EPM_PROTOCOL_UDP)] epm_rhs_udp udp;
|
||||
[case(EPM_PROTOCOL_IP)] epm_rhs_ip ip;
|
||||
[case(EPM_PROTOCOL_NCADG)] epm_rhs_ncadg ncadg;
|
||||
[case(EPM_PROTOCOL_NCACN)] epm_rhs_ncacn ncacn;
|
||||
[case(EPM_PROTOCOL_NCALRPC)] epm_rhs_ncalrpc ncalrpc;
|
||||
[case(EPM_PROTOCOL_UUID)] epm_rhs_uuid uuid;
|
||||
[case(EPM_PROTOCOL_IPX)] epm_rhs_ipx ipx;
|
||||
[case(EPM_PROTOCOL_SMB)] epm_rhs_smb smb;
|
||||
[case(EPM_PROTOCOL_PIPE)] epm_rhs_pipe pipe;
|
||||
[case(EPM_PROTOCOL_NETBIOS)] epm_rhs_netbios netbios;
|
||||
[case(EPM_PROTOCOL_NB_NB)] epm_rhs_nb_nb nb_nb;
|
||||
[case(EPM_PROTOCOL_SPX)] epm_rhs_spx spx;
|
||||
[case(EPM_PROTOCOL_NB_IPX)] epm_rhs_nb_ipx nb_ipx;
|
||||
[case(EPM_PROTOCOL_HTTP)] epm_rhs_http http;
|
||||
[case(EPM_PROTOCOL_UNIX_DS)] epm_rhs_unix_ds unix_ds;
|
||||
[case(EPM_PROTOCOL_NULL)] epm_rhs_null null;
|
||||
[default] [flag(NDR_REMAINING)] DATA_BLOB unknown;
|
||||
} epm_rhs;
|
||||
|
||||
typedef struct {
|
||||
uint8 protocol;
|
||||
[switch_is(protocol)] epm_protocol_info info;
|
||||
} epm_lhs;
|
||||
|
||||
typedef struct {
|
||||
[flag(NDR_REMAINING)] DATA_BLOB rhs_data;
|
||||
} epm_rhs;
|
||||
|
||||
typedef struct {
|
||||
[subcontext(2)] epm_lhs lhs;
|
||||
[subcontext(2)] epm_rhs rhs;
|
||||
[subcontext(2),switch_is(lhs.protocol)] epm_rhs rhs;
|
||||
} epm_floor;
|
||||
|
||||
/* note that the NDR_NOALIGN flag is inherited by all nested
|
||||
@ -99,7 +194,7 @@ interface epmapper
|
||||
} epm_towers;
|
||||
|
||||
typedef struct {
|
||||
[value(ndr_size_epm_towers(&r->towers))] uint32 tower_length;
|
||||
uint32 tower_length;
|
||||
[subcontext(4)] epm_towers towers;
|
||||
} epm_twr_t;
|
||||
|
||||
|
@ -22,32 +22,6 @@
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
/*
|
||||
this ndr_size_* stuff should really be auto-generated ....
|
||||
*/
|
||||
|
||||
static size_t ndr_size_epm_floor(struct epm_floor *fl)
|
||||
{
|
||||
size_t ret = 5;
|
||||
if (fl->lhs.protocol == EPM_PROTOCOL_UUID) {
|
||||
ret += 18;
|
||||
} else {
|
||||
ret += fl->lhs.info.lhs_data.length;
|
||||
}
|
||||
ret += fl->rhs.rhs_data.length;
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t ndr_size_epm_towers(struct epm_towers *towers)
|
||||
{
|
||||
size_t ret = 2;
|
||||
int i;
|
||||
for (i=0;i<towers->num_floors;i++) {
|
||||
ret += ndr_size_epm_floor(&towers->floors[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
work out what TCP port to use for a given interface on a given host
|
||||
*/
|
||||
@ -96,28 +70,28 @@ NTSTATUS dcerpc_epm_map_tcp_port(const char *server,
|
||||
twr.towers.floors[0].lhs.protocol = EPM_PROTOCOL_UUID;
|
||||
GUID_from_string(uuid, &twr.towers.floors[0].lhs.info.uuid.uuid);
|
||||
twr.towers.floors[0].lhs.info.uuid.version = version;
|
||||
twr.towers.floors[0].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr.towers.floors[0].rhs.uuid.unknown = 0;
|
||||
|
||||
/* encoded with NDR ... */
|
||||
twr.towers.floors[1].lhs.protocol = EPM_PROTOCOL_UUID;
|
||||
GUID_from_string(NDR_GUID, &twr.towers.floors[1].lhs.info.uuid.uuid);
|
||||
twr.towers.floors[1].lhs.info.uuid.version = NDR_GUID_VERSION;
|
||||
twr.towers.floors[1].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr.towers.floors[1].rhs.uuid.unknown = 0;
|
||||
|
||||
/* on an RPC connection ... */
|
||||
twr.towers.floors[2].lhs.protocol = EPM_PROTOCOL_NCACN;
|
||||
twr.towers.floors[2].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr.towers.floors[2].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr.towers.floors[2].rhs.ncacn.minor_version = 0;
|
||||
|
||||
/* on a TCP port ... */
|
||||
twr.towers.floors[3].lhs.protocol = EPM_PROTOCOL_TCP;
|
||||
twr.towers.floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr.towers.floors[3].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr.towers.floors[3].rhs.tcp.port = 0;
|
||||
|
||||
/* on an IP link ... */
|
||||
twr.towers.floors[4].lhs.protocol = EPM_PROTOCOL_IP;
|
||||
twr.towers.floors[4].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr.towers.floors[4].rhs.rhs_data = data_blob_talloc_zero(p, 4);
|
||||
twr.towers.floors[4].rhs.ip.address = 0;
|
||||
|
||||
/* with some nice pretty paper around it of course */
|
||||
r.in.object = &guid;
|
||||
@ -143,13 +117,12 @@ NTSTATUS dcerpc_epm_map_tcp_port(const char *server,
|
||||
}
|
||||
|
||||
if (twr_r->towers.num_floors != 5 ||
|
||||
twr_r->towers.floors[3].lhs.protocol != twr.towers.floors[3].lhs.protocol ||
|
||||
twr_r->towers.floors[3].rhs.rhs_data.length != 2) {
|
||||
twr_r->towers.floors[3].lhs.protocol != twr.towers.floors[3].lhs.protocol) {
|
||||
dcerpc_pipe_close(p);
|
||||
return NT_STATUS_PORT_UNREACHABLE;
|
||||
}
|
||||
|
||||
*port = RSVAL(twr_r->towers.floors[3].rhs.rhs_data.data, 0);
|
||||
*port = twr_r->towers.floors[3].rhs.tcp.port;
|
||||
|
||||
dcerpc_pipe_close(p);
|
||||
|
||||
|
@ -63,47 +63,44 @@ static BOOL fill_protocol_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr,
|
||||
twr->floors[0].lhs.protocol = EPM_PROTOCOL_UUID;
|
||||
GUID_from_string(e->uuid, &twr->floors[0].lhs.info.uuid.uuid);
|
||||
twr->floors[0].lhs.info.uuid.version = e->if_version;
|
||||
twr->floors[0].rhs.rhs_data = data_blob_talloc_zero(mem_ctx, 2);
|
||||
twr->floors[0].rhs.uuid.unknown = 0;
|
||||
|
||||
/* encoded with NDR ... */
|
||||
twr->floors[1].lhs.protocol = EPM_PROTOCOL_UUID;
|
||||
GUID_from_string(NDR_GUID, &twr->floors[1].lhs.info.uuid.uuid);
|
||||
twr->floors[1].lhs.info.uuid.version = NDR_GUID_VERSION;
|
||||
twr->floors[1].rhs.rhs_data = data_blob_talloc_zero(mem_ctx, 2);
|
||||
twr->floors[1].rhs.uuid.unknown = 0;
|
||||
|
||||
/* on an RPC connection ... */
|
||||
twr->floors[2].lhs.protocol = EPM_PROTOCOL_NCACN;
|
||||
twr->floors[2].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->floors[2].rhs.rhs_data = data_blob_talloc_zero(mem_ctx, 2);
|
||||
twr->floors[2].rhs.ncacn.minor_version = 0;
|
||||
|
||||
switch (e->ep_description.type) {
|
||||
case ENDPOINT_SMB:
|
||||
/* on a SMB pipe ... */
|
||||
twr->floors[3].lhs.protocol = EPM_PROTOCOL_SMB;
|
||||
twr->floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->floors[3].rhs.rhs_data.data = talloc_asprintf(mem_ctx, "\\PIPE\\%s",
|
||||
twr->floors[3].rhs.smb.unc = talloc_asprintf(mem_ctx, "\\PIPE\\%s",
|
||||
e->ep_description.info.smb_pipe);
|
||||
twr->floors[3].rhs.rhs_data.length = strlen(twr->floors[3].rhs.rhs_data.data)+1;
|
||||
|
||||
/* on an NetBIOS link ... */
|
||||
twr->floors[4].lhs.protocol = EPM_PROTOCOL_NETBIOS;
|
||||
twr->floors[4].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->floors[4].rhs.rhs_data.data = talloc_asprintf(mem_ctx, "\\\\%s",
|
||||
twr->floors[4].rhs.netbios.name = talloc_asprintf(mem_ctx, "\\\\%s",
|
||||
lp_netbios_name());
|
||||
twr->floors[4].rhs.rhs_data.length = strlen(twr->floors[4].rhs.rhs_data.data)+1;
|
||||
break;
|
||||
|
||||
case ENDPOINT_TCP:
|
||||
/* on a TCP connection ... */
|
||||
twr->floors[3].lhs.protocol = EPM_PROTOCOL_TCP;
|
||||
twr->floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->floors[3].rhs.rhs_data = data_blob_talloc(mem_ctx, NULL, 2);
|
||||
RSSVAL(twr->floors[3].rhs.rhs_data.data, 0, e->ep_description.info.tcp_port);
|
||||
twr->floors[3].rhs.tcp.port = e->ep_description.info.tcp_port;
|
||||
|
||||
/* on an IP link ... */
|
||||
twr->floors[4].lhs.protocol = EPM_PROTOCOL_IP;
|
||||
twr->floors[4].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->floors[4].rhs.rhs_data = data_blob_talloc_zero(mem_ctx, 4);
|
||||
twr->floors[4].rhs.ip.address = 0;
|
||||
/* TODO: we should fill in our IP address here as a hint to the
|
||||
client */
|
||||
break;
|
||||
|
@ -32,7 +32,7 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr)
|
||||
|
||||
for (i=0;i<twr->num_floors;i++) {
|
||||
struct epm_lhs *lhs = &twr->floors[i].lhs;
|
||||
struct epm_rhs *rhs = &twr->floors[i].rhs;
|
||||
union epm_rhs *rhs = &twr->floors[i].rhs;
|
||||
|
||||
switch(lhs->protocol) {
|
||||
case EPM_PROTOCOL_UUID:
|
||||
@ -62,27 +62,27 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr)
|
||||
|
||||
case EPM_PROTOCOL_IP:
|
||||
printf(" IP:");
|
||||
if (rhs->rhs_data.length == 4) {
|
||||
{
|
||||
struct in_addr in;
|
||||
in.s_addr = IVAL(rhs->rhs_data.data, 0);
|
||||
in.s_addr = rhs->ip.address;
|
||||
printf("%s", inet_ntoa(in));
|
||||
}
|
||||
break;
|
||||
|
||||
case EPM_PROTOCOL_PIPE:
|
||||
printf(" PIPE:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
|
||||
printf(" PIPE:%s", rhs->pipe.path);
|
||||
break;
|
||||
|
||||
case EPM_PROTOCOL_SMB:
|
||||
printf(" SMB:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
|
||||
printf(" SMB:%s", rhs->smb.unc);
|
||||
break;
|
||||
|
||||
case EPM_PROTOCOL_UNIX_DS:
|
||||
printf(" Unix Domain Socket:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
|
||||
printf(" Unix Domain Socket:%s", rhs->unix_ds.path);
|
||||
break;
|
||||
|
||||
case EPM_PROTOCOL_NETBIOS:
|
||||
printf(" NetBIOS:%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
|
||||
printf(" NetBIOS:%s", rhs->netbios.name);
|
||||
break;
|
||||
|
||||
case EPM_PROTOCOL_NB_NB:
|
||||
@ -97,33 +97,23 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr)
|
||||
printf(" NB_IPX");
|
||||
break;
|
||||
|
||||
case 0x01:
|
||||
printf(" UNK(1):%.*s", rhs->rhs_data.length, rhs->rhs_data.data);
|
||||
break;
|
||||
|
||||
case EPM_PROTOCOL_HTTP:
|
||||
printf(" HTTP:");
|
||||
if (rhs->rhs_data.length == 2) {
|
||||
printf("%d", RSVAL(rhs->rhs_data.data, 0));
|
||||
}
|
||||
printf(" HTTP:%d", rhs->http.port);
|
||||
break;
|
||||
|
||||
case EPM_PROTOCOL_TCP:
|
||||
/* what is the difference between this and 0x1f? */
|
||||
printf(" TCP:");
|
||||
if (rhs->rhs_data.length == 2) {
|
||||
printf("%d", RSVAL(rhs->rhs_data.data, 0));
|
||||
}
|
||||
printf(" TCP:%d", rhs->tcp.port);
|
||||
break;
|
||||
|
||||
case EPM_PROTOCOL_UDP:
|
||||
printf(" UDP:");
|
||||
printf(" UDP:%d", rhs->udp.port);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf(" UNK(%02x):", lhs->protocol);
|
||||
if (rhs->rhs_data.length == 2) {
|
||||
printf("%d", RSVAL(rhs->rhs_data.data, 0));
|
||||
if (rhs->unknown.length == 2) {
|
||||
printf("%d", RSVAL(rhs->unknown.data, 0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -163,15 +153,15 @@ static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
twr->towers.floors[2].lhs.protocol = EPM_PROTOCOL_NCACN;
|
||||
twr->towers.floors[2].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->towers.floors[2].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr->towers.floors[2].rhs.ncacn.minor_version = 0;
|
||||
|
||||
twr->towers.floors[3].lhs.protocol = EPM_PROTOCOL_TCP;
|
||||
twr->towers.floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->towers.floors[3].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr->towers.floors[3].rhs.tcp.port = 0;
|
||||
|
||||
twr->towers.floors[4].lhs.protocol = EPM_PROTOCOL_IP;
|
||||
twr->towers.floors[4].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->towers.floors[4].rhs.rhs_data = data_blob_talloc_zero(p, 4);
|
||||
twr->towers.floors[4].rhs.ip.address = 0;
|
||||
|
||||
status = dcerpc_epm_Map(p, mem_ctx, &r);
|
||||
if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
|
||||
@ -184,7 +174,7 @@ static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
twr->towers.floors[3].lhs.protocol = EPM_PROTOCOL_HTTP;
|
||||
twr->towers.floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->towers.floors[3].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr->towers.floors[3].rhs.http.port = 0;
|
||||
|
||||
status = dcerpc_epm_Map(p, mem_ctx, &r);
|
||||
if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
|
||||
@ -197,11 +187,11 @@ static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
|
||||
twr->towers.floors[3].lhs.protocol = EPM_PROTOCOL_SMB;
|
||||
twr->towers.floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->towers.floors[3].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr->towers.floors[3].rhs.smb.unc = "";
|
||||
|
||||
twr->towers.floors[4].lhs.protocol = EPM_PROTOCOL_NETBIOS;
|
||||
twr->towers.floors[4].lhs.info.lhs_data = data_blob(NULL, 0);
|
||||
twr->towers.floors[4].rhs.rhs_data = data_blob_talloc_zero(p, 2);
|
||||
twr->towers.floors[4].rhs.netbios.name = "";
|
||||
|
||||
status = dcerpc_epm_Map(p, mem_ctx, &r);
|
||||
if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user