diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2004-10-12 12:41:50 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:59:50 -0500 |
commit | ae0aa86039aaa4fd02f2646cb7edf54106354119 (patch) | |
tree | 5f6c611f97de0612b8a48940cf37b66fbf09e46e /source4/librpc | |
parent | f2657b2cb16514d22f01c8909292e7c81c6847e5 (diff) | |
download | samba-ae0aa86039aaa4fd02f2646cb7edf54106354119.tar.gz samba-ae0aa86039aaa4fd02f2646cb7edf54106354119.tar.bz2 samba-ae0aa86039aaa4fd02f2646cb7edf54106354119.zip |
r2938: Use IDL to dissect the RHS of floors in protocol towers
(This used to be commit 273d0049b5339e3288b264e5a4393bfab1d4e239)
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/idl/epmapper.idl | 107 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_util.c | 41 |
2 files changed, 108 insertions, 40 deletions
diff --git a/source4/librpc/idl/epmapper.idl b/source4/librpc/idl/epmapper.idl index 80c2fe5ee0..042c55f2a9 100644 --- a/source4/librpc/idl/epmapper.idl +++ b/source4/librpc/idl/epmapper.idl @@ -75,17 +75,112 @@ interface epmapper } epm_protocol_info; typedef struct { - uint8 protocol; - [switch_is(protocol)] epm_protocol_info info; - } epm_lhs; + //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 { - [flag(NDR_REMAINING)] DATA_BLOB rhs_data; + 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 { [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; diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index d3c461a2f4..5f3d911d15 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -23,32 +23,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 */ NTSTATUS dcerpc_epm_map_tcp_port(const char *server, @@ -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); |