From a6ff6254dad51acfc484c0ef92c1c484d466f509 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 17 Oct 2003 15:03:46 +0000 Subject: Add (un)marshalling code for endpoint mapper map operation (This used to be commit bdd5158d9a45f4b935ea0fa495c0d83bc5ca96f8) --- source3/rpc_parse/parse_epmapper.c | 406 +++++++++++++++++++++++++++++++++++++ 1 file changed, 406 insertions(+) create mode 100644 source3/rpc_parse/parse_epmapper.c (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_epmapper.c b/source3/rpc_parse/parse_epmapper.c new file mode 100644 index 0000000000..9e21da04dd --- /dev/null +++ b/source3/rpc_parse/parse_epmapper.c @@ -0,0 +1,406 @@ +/* + Unix SMB/CIFS implementation. + Samba end point mapper functions + Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_PARSE + +/******************************************************************* + Reads or writes a handle. +********************************************************************/ +BOOL epm_io_handle(const char *desc, EPM_HANDLE *handle, prs_struct *ps, + int depth) +{ + + if (!prs_uint8s(False, "data", ps, depth, handle->data, + sizeof(handle->data))) + return False; + + return True; +} + +/******************************************************************* + inits an EPM_FLOOR structure. +********************************************************************/ +NTSTATUS init_epm_floor(EPM_FLOOR *floor, uint8 protocol) +{ + /* handle lhs */ + floor->lhs.protocol = protocol; + floor->lhs.length = sizeof(floor->lhs.protocol); + + switch(floor->lhs.protocol) { + case EPM_FLOOR_UUID: + floor->lhs.length += sizeof(floor->lhs.uuid.uuid); + floor->lhs.length += sizeof(floor->lhs.uuid.version); + break; + default: + break; + } + + /* handle rhs */ + switch(floor->lhs.protocol) { + case EPM_FLOOR_RPC: + case EPM_FLOOR_UUID: + floor->rhs.length = sizeof(floor->rhs.unknown); + break; + case EPM_FLOOR_TCP: + floor->rhs.length = sizeof(floor->rhs.tcp.port); + break; + case EPM_FLOOR_IP: + floor->rhs.length = sizeof(floor->rhs.ip.addr); + break; + default: + break; + } + + return NT_STATUS_OK; +} + +/******************************************************************* + inits an EPM_FLOOR structure with a UUID +********************************************************************/ +NTSTATUS init_epm_floor_uuid(EPM_FLOOR *floor, + const RPC_UUID *uuid, uint16 version) +{ + memcpy(&floor->lhs.uuid.uuid, uuid, sizeof(*uuid)); + floor->lhs.uuid.version = version; + floor->rhs.unknown = 0; + return init_epm_floor(floor, EPM_FLOOR_UUID); +} + +/******************************************************************* + inits an EPM_FLOOR structure for RPC +********************************************************************/ +NTSTATUS init_epm_floor_rpc(EPM_FLOOR *floor) +{ + floor->rhs.unknown = 0; + return init_epm_floor(floor, EPM_FLOOR_RPC); +} + +/******************************************************************* + inits an EPM_FLOOR structure for TCP +********************************************************************/ +NTSTATUS init_epm_floor_tcp(EPM_FLOOR *floor, uint16 port) +{ + floor->rhs.tcp.port = htons(port); + return init_epm_floor(floor, EPM_FLOOR_TCP); +} + +/******************************************************************* + inits an EPM_FLOOR structure for IP +********************************************************************/ +NTSTATUS init_epm_floor_ip(EPM_FLOOR *floor, uint8 addr[4]) +{ + memcpy(&floor->rhs.ip.addr, addr, sizeof(addr)); + return init_epm_floor(floor, EPM_FLOOR_IP); +} + +/******************************************************************* + reads and writes EPM_FLOOR. +********************************************************************/ +BOOL epm_io_floor(const char *desc, EPM_FLOOR *floor, + prs_struct *ps, int depth) +{ + prs_debug(ps, depth, desc, "epm_io_floor"); + depth++; + + if (!prs_uint16("lhs_length", ps, depth, &floor->lhs.length)) + return False; + if (!prs_uint8("protocol", ps, depth, &floor->lhs.protocol)) + return False; + + switch (floor->lhs.protocol) { + case EPM_FLOOR_UUID: + if (!smb_io_rpc_uuid("uuid", &floor->lhs.uuid.uuid, ps, depth)) + return False; + if (!prs_uint16("version", ps, depth, + &floor->lhs.uuid.version)) + return False; + break; + } + + if (!prs_uint16("rhs_length", ps, depth, &floor->rhs.length)) + return False; + + switch (floor->lhs.protocol) { + case EPM_FLOOR_UUID: + case EPM_FLOOR_RPC: + if (!prs_uint16("unknown", ps, depth, &floor->rhs.unknown)) + return False; + break; + case EPM_FLOOR_TCP: + if (!prs_uint16("tcp_port", ps, depth, &floor->rhs.tcp.port)) + return False; + break; + case EPM_FLOOR_IP: + if (!prs_uint8s(False, "ip_addr", ps, depth, + floor->rhs.ip.addr, + sizeof(floor->rhs.ip.addr))) + return False; + break; + default: + break; + } + + return True; +} + +/******************************************************************* + Inits a EPM_TOWER structure. +********************************************************************/ +NTSTATUS init_epm_tower(TALLOC_CTX *ctx, EPM_TOWER *tower, + const EPM_FLOOR *floors, int num_floors) +{ + static uint32 internal_referent_id = 0; + int size = 0; + int i; + + DEBUG(5, ("init_epm_tower\n")); + + for (i = 0; i < num_floors; i++) { + size += (sizeof(uint32) * 2); + size += floors[i].lhs.length; + size += floors[i].rhs.length; + } + size += sizeof(uint8); /* this could be aligning... */ + + tower->referent_id = ++internal_referent_id; + tower->max_length = tower->length = size; + tower->num_floors = num_floors; + tower->floors = talloc(ctx, sizeof(EPM_FLOOR) * num_floors); + if (!tower->floors) { + return NT_STATUS_NO_MEMORY; + } + memcpy(tower->floors, floors, sizeof(EPM_FLOOR) * num_floors); + tower->unknown = 0x7e; + + return NT_STATUS_OK; +} + +/******************************************************************* + Reads or writes an EPM_TOWER structure. +********************************************************************/ +BOOL epm_io_tower(const char *desc, EPM_TOWER *tower, + prs_struct *ps, int depth) +{ + int i; + + prs_debug(ps, depth, desc, "epm_io_tower"); + depth++; + + if (!prs_uint32("referent_id", ps, depth, &tower->referent_id)) + return False; + if (!prs_uint32("max_length", ps, depth, &tower->max_length)) + return False; + if (!prs_uint32("length", ps, depth, &tower->length)) + return False; + if (!prs_uint16("num_floors", ps, depth, &tower->num_floors)) + return False; + + if (UNMARSHALLING(ps)) { + tower->floors = talloc(ps->mem_ctx, + sizeof(EPM_FLOOR) * tower->num_floors); + if (!tower->floors) + return False; + } + + for (i = 0; i < tower->num_floors; i++) { + if (!epm_io_floor("floor", tower->floors + i, ps, depth)) + return False; + } + + if (!prs_uint8("unknown", ps, depth, &tower->unknown)) + return False; + + return True; +} + +/******************************************************************* + Initialize an EPM_TOWER_ARRAY structure +********************************************************************/ +NTSTATUS init_epm_tower_array(TALLOC_CTX *ctx, EPM_TOWER_ARRAY *array, + const EPM_TOWER *towers, int num_towers) +{ + array->max_count = num_towers; + array->offset = 0; + array->count = num_towers; + array->towers = talloc(ctx, sizeof(EPM_TOWER) * num_towers); + if (!array->towers) { + return NT_STATUS_NO_MEMORY; + } + memcpy(array->towers, towers, sizeof(EPM_TOWER) * num_towers); + + return NT_STATUS_OK; +} + +/******************************************************************* + Reads or writes an EPM_TOWER_ARRAY structure. +********************************************************************/ +BOOL epm_io_tower_array(const char *desc, EPM_TOWER_ARRAY *array, + prs_struct *ps, int depth) +{ + int i; + + prs_debug(ps, depth, desc, "epm_io_tower_array"); + depth++; + + if (!prs_uint32("max_count", ps, depth, &array->max_count)) + return False; + if (!prs_uint32("offset", ps, depth, &array->offset)) + return False; + if (!prs_uint32("count", ps, depth, &array->count)) + return False; + + if (!prs_set_offset(ps, prs_offset(ps) + array->offset)) + return False; + + if (UNMARSHALLING(ps)) { + array->towers = talloc(ps->mem_ctx, + sizeof(EPM_TOWER) * array->count); + if (!array->towers) { + return False; + } + } + + for (i = 0; i < array->count; i++) { + if (!epm_io_tower("tower", array->towers + 1, ps, depth)) + return False; + } + + return True; +} + +/******************************************************************* + Initialize EPM_R_MAP structure +******************************************************************/ +NTSTATUS init_epm_r_map(TALLOC_CTX *ctx, EPM_R_MAP *r_map, + const EPM_HANDLE *handle, const EPM_TOWER_ARRAY *array, + int num_elements, uint32 status) +{ + memcpy(&r_map->handle, handle, sizeof(*handle)); + r_map->num_results = num_elements; + r_map->results = talloc(ctx, sizeof(EPM_TOWER_ARRAY) * num_elements); + if (!r_map->results) { + return NT_STATUS_NO_MEMORY; + } + memcpy(r_map->results, array, sizeof(EPM_TOWER_ARRAY) * num_elements); + r_map->status = status; + return NT_STATUS_OK; +} + +/************************************************************************* + Inits a EPM_Q_MAP structure. +************************************************************************** +* We attempt to hide the ugliness of the wire format by taking a EPM_TOWER +* array with a defined size +**************************************************************************/ +NTSTATUS init_epm_q_map(TALLOC_CTX *ctx, EPM_Q_MAP *q_map, + const EPM_TOWER *towers, int num_towers) +{ + static uint32 handle = 1; + + ZERO_STRUCTP(q_map); + + DEBUG(5, ("init_epm_q_map\n")); + q_map->handle.data[0] = (handle >> 0) & 0xFF; + q_map->handle.data[1] = (handle >> 8) & 0xFF; + q_map->handle.data[2] = (handle >> 16) & 0xFF; + q_map->handle.data[3] = (handle >> 24) & 0xFF; + + q_map->tower = talloc(ctx, sizeof(EPM_TOWER) * (num_towers + 1)); + if (!q_map->tower) { + return NT_STATUS_NO_MEMORY; + } + + memcpy(q_map->tower, towers, sizeof(EPM_TOWER) * num_towers); + + ZERO_STRUCT(q_map->tower[num_towers]); + + /* For now let's not take more than 4 towers per result */ + q_map->max_towers = num_towers * 4; + + handle++; + + return NT_STATUS_OK; +} + +/***************************************************************** + epm_io_q_map - read or write EPM_Q_MAP structure +******************************************************************/ +BOOL epm_io_q_map(char *desc, EPM_Q_MAP *io_map, prs_struct *ps, int depth) +{ + prs_debug(ps, depth, desc, "epm_io_q_map"); + depth++; + + if (!epm_io_handle("handle", &io_map->handle, ps, depth)) + return False; + + /* HACK: We need a more elegant way of doing this */ + if (UNMARSHALLING(ps)) { + io_map->tower = talloc(ps->mem_ctx, sizeof(EPM_TOWER)); + if (!io_map->tower) + return False; + } + if (!epm_io_tower("tower", io_map->tower, ps, depth)) + return False; + if (!epm_io_handle("term_handle", &io_map->term_handle, ps, depth)) + return False; + + if (!prs_uint32("max_towers", ps, 0, &io_map->max_towers)) + return False; + + return True; +} + +/******************************************************************* + epm_io_r_map - Read/Write EPM_R_MAP structure +******************************************************************/ +BOOL epm_io_r_map(char *desc, EPM_R_MAP *io_map, + prs_struct *ps, int depth) +{ + int i; + + prs_debug(ps, depth, desc, "epm_io_r_map"); + depth++; + + if (!epm_io_handle("handle", &io_map->handle, ps, depth)) + return False; + if (!prs_uint32("num_results", ps, depth, &io_map->num_results)) + return False; + + if (UNMARSHALLING(ps)) { + io_map->results = talloc(ps->mem_ctx, + sizeof(EPM_TOWER_ARRAY) * + io_map->num_results); + if (!io_map->results) + return False; + } + for (i = 0; i < io_map->num_results; i++) { + if (!epm_io_tower_array("results", io_map->results + i, + ps, depth)) + return False; + } + + if (!prs_uint32("status", ps, depth, &io_map->status)) + return False; + + return True; +} -- cgit From d807bc12fb1d208de9b4f9e2532810cf1a9e3695 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 17 Oct 2003 15:07:23 +0000 Subject: Add epmapper pipe (This used to be commit 041c17bd665ea5fa771b111d7008036fb3e7b72f) --- source3/rpc_parse/parse_rpc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_rpc.c b/source3/rpc_parse/parse_rpc.c index 1ea59feaed..57ebe5d356 100644 --- a/source3/rpc_parse/parse_rpc.c +++ b/source3/rpc_parse/parse_rpc.c @@ -147,6 +147,15 @@ interface/version dce/rpc pipe identification }, 0x01 \ } +#define SYNT_EPM_V3 \ +{ \ + { \ + 0xe1af8308, 0x5d1f, 0x11c9, \ + { 0x91, 0xa4, 0x08, 0x00, \ + 0x2b, 0x14, 0xa0, 0xfa } \ + }, 0x03 \ +} + /* * IMPORTANT!! If you update this structure, make sure to * update the index #defines in smb.h. @@ -165,6 +174,7 @@ const struct pipe_id_info pipe_names [] = { PIPE_SPOOLSS , SYNT_SPOOLSS_V1 , PIPE_SPOOLSS , TRANS_SYNT_V2 }, { PIPE_NETDFS , SYNT_NETDFS_V3 , PIPE_NETDFS , TRANS_SYNT_V2 }, { PIPE_ECHO , SYNT_ECHO_V1 , PIPE_ECHO , TRANS_SYNT_V2 }, + { PIPE_EPM , SYNT_EPM_V3 , PIPE_EPM , TRANS_SYNT_V2 }, { NULL , SYNT_NONE_V0 , NULL , SYNT_NONE_V0 } }; @@ -246,7 +256,7 @@ BOOL smb_io_rpc_hdr(const char *desc, RPC_HDR *rpc, prs_struct *ps, int depth) Reads or writes an RPC_UUID structure. ********************************************************************/ -static BOOL smb_io_rpc_uuid(const char *desc, RPC_UUID *uuid, prs_struct *ps, int depth) +BOOL smb_io_rpc_uuid(const char *desc, RPC_UUID *uuid, prs_struct *ps, int depth) { if (uuid == NULL) return False; -- cgit From e6900132ca7d216662e3ab08ad37a1e34c752cd9 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 17 Oct 2003 19:47:06 +0000 Subject: uuid itself might not be aligned (as is the case in epm map requests), so it needs to be aligned outside the smb_io_rpc_uuid() call if a specific rpc or struct needs it that way. (This used to be commit e9fc15d58c52c12438c1f9c69394c11f76ce72d8) --- source3/rpc_parse/parse_rpc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_rpc.c b/source3/rpc_parse/parse_rpc.c index 57ebe5d356..f053297192 100644 --- a/source3/rpc_parse/parse_rpc.c +++ b/source3/rpc_parse/parse_rpc.c @@ -264,9 +264,6 @@ BOOL smb_io_rpc_uuid(const char *desc, RPC_UUID *uuid, prs_struct *ps, int depth prs_debug(ps, depth, desc, "smb_io_rpc_uuid"); depth++; - if(!prs_align(ps)) - return False; - if(!prs_uint32 ("data ", ps, depth, &uuid->time_low)) return False; if(!prs_uint16 ("data ", ps, depth, &uuid->time_mid)) @@ -292,6 +289,9 @@ static BOOL smb_io_rpc_iface(const char *desc, RPC_IFACE *ifc, prs_struct *ps, i prs_debug(ps, depth, desc, "smb_io_rpc_iface"); depth++; + if (!prs_align(ps)) + return False; + if (!smb_io_rpc_uuid( "uuid", &ifc->uuid, ps, depth)) return False; -- cgit From ba0c899510e81eddfc76eeb1b3d875d5a8c6d0d0 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Sat, 18 Oct 2003 01:07:37 +0000 Subject: Fix tower length calculations and add some const (This used to be commit 2f84c6c9a1c292535e73721a8bcdb27aaa2b2b46) --- source3/rpc_parse/parse_epmapper.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_epmapper.c b/source3/rpc_parse/parse_epmapper.c index 9e21da04dd..368ea319bd 100644 --- a/source3/rpc_parse/parse_epmapper.c +++ b/source3/rpc_parse/parse_epmapper.c @@ -175,12 +175,12 @@ NTSTATUS init_epm_tower(TALLOC_CTX *ctx, EPM_TOWER *tower, DEBUG(5, ("init_epm_tower\n")); + size += sizeof(uint16); /* number of floors is in tower length */ for (i = 0; i < num_floors; i++) { - size += (sizeof(uint32) * 2); + size += (sizeof(uint16) * 2); size += floors[i].lhs.length; size += floors[i].rhs.length; } - size += sizeof(uint8); /* this could be aligning... */ tower->referent_id = ++internal_referent_id; tower->max_length = tower->length = size; @@ -345,7 +345,8 @@ NTSTATUS init_epm_q_map(TALLOC_CTX *ctx, EPM_Q_MAP *q_map, /***************************************************************** epm_io_q_map - read or write EPM_Q_MAP structure ******************************************************************/ -BOOL epm_io_q_map(char *desc, EPM_Q_MAP *io_map, prs_struct *ps, int depth) +BOOL epm_io_q_map(const char *desc, EPM_Q_MAP *io_map, prs_struct *ps, + int depth) { prs_debug(ps, depth, desc, "epm_io_q_map"); depth++; @@ -373,7 +374,7 @@ BOOL epm_io_q_map(char *desc, EPM_Q_MAP *io_map, prs_struct *ps, int depth) /******************************************************************* epm_io_r_map - Read/Write EPM_R_MAP structure ******************************************************************/ -BOOL epm_io_r_map(char *desc, EPM_R_MAP *io_map, +BOOL epm_io_r_map(const char *desc, EPM_R_MAP *io_map, prs_struct *ps, int depth) { int i; -- cgit From 2cfb3e9b7046fe2db330a292aed71f1c27688a16 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Mon, 20 Oct 2003 18:35:12 +0000 Subject: Several updates: - add support for named pipe and netbios queries in parse code - fix map request structure...unknown byte was alignment - add sample of named pipe over netbios query in rpcclient (comment only) (This used to be commit 71dcdf54e60204d6b499d25d8759ed20fc7a021a) --- source3/rpc_parse/parse_epmapper.c | 45 +++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_epmapper.c b/source3/rpc_parse/parse_epmapper.c index 368ea319bd..2bdb755deb 100644 --- a/source3/rpc_parse/parse_epmapper.c +++ b/source3/rpc_parse/parse_epmapper.c @@ -29,6 +29,8 @@ BOOL epm_io_handle(const char *desc, EPM_HANDLE *handle, prs_struct *ps, int depth) { + if (!prs_align(ps)) + return False; if (!prs_uint8s(False, "data", ps, depth, handle->data, sizeof(handle->data))) @@ -67,6 +69,11 @@ NTSTATUS init_epm_floor(EPM_FLOOR *floor, uint8 protocol) case EPM_FLOOR_IP: floor->rhs.length = sizeof(floor->rhs.ip.addr); break; + case EPM_FLOOR_NMPIPES: + case EPM_FLOOR_LRPC: + case EPM_FLOOR_NETBIOS: + floor->rhs.length = strlen(floor->rhs.string) + 1; + break; default: break; } @@ -113,6 +120,33 @@ NTSTATUS init_epm_floor_ip(EPM_FLOOR *floor, uint8 addr[4]) return init_epm_floor(floor, EPM_FLOOR_IP); } +/******************************************************************* + inits an EPM_FLOOR structure for named pipe +********************************************************************/ +NTSTATUS init_epm_floor_np(EPM_FLOOR *floor, const char *pipe_name) +{ + safe_strcpy(floor->rhs.string, pipe_name, sizeof(floor->rhs.string)-1); + return init_epm_floor(floor, EPM_FLOOR_NMPIPES); +} + +/******************************************************************* + inits an EPM_FLOOR structure for named pipe +********************************************************************/ +NTSTATUS init_epm_floor_lrpc(EPM_FLOOR *floor, const char *pipe_name) +{ + safe_strcpy(floor->rhs.string, pipe_name, sizeof(floor->rhs.string)-1); + return init_epm_floor(floor, EPM_FLOOR_LRPC); +} + +/******************************************************************* + inits an EPM_FLOOR structure for named pipe +********************************************************************/ +NTSTATUS init_epm_floor_nb(EPM_FLOOR *floor, char *host_name) +{ + safe_strcpy(floor->rhs.string, host_name, sizeof(floor->rhs.string)-1); + return init_epm_floor(floor, EPM_FLOOR_NETBIOS); +} + /******************************************************************* reads and writes EPM_FLOOR. ********************************************************************/ @@ -156,6 +190,14 @@ BOOL epm_io_floor(const char *desc, EPM_FLOOR *floor, sizeof(floor->rhs.ip.addr))) return False; break; + case EPM_FLOOR_NMPIPES: + case EPM_FLOOR_LRPC: + case EPM_FLOOR_NETBIOS: + if (!prs_uint8s(False, "string", ps, depth, + floor->rhs.string, + floor->rhs.length)) + return False; + break; default: break; } @@ -227,9 +269,6 @@ BOOL epm_io_tower(const char *desc, EPM_TOWER *tower, return False; } - if (!prs_uint8("unknown", ps, depth, &tower->unknown)) - return False; - return True; } -- cgit From 6fe9423fc69f3c1a79d0e45ac47d0b3228e4d4d6 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Mon, 20 Oct 2003 21:10:18 +0000 Subject: Update structures after ethereal showed some marshalling/unmarshalling errors. (This used to be commit 9d0f322a851f487cea320e57076213435e5c6481) --- source3/rpc_parse/parse_epmapper.c | 44 ++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_epmapper.c b/source3/rpc_parse/parse_epmapper.c index 2bdb755deb..02340430ec 100644 --- a/source3/rpc_parse/parse_epmapper.c +++ b/source3/rpc_parse/parse_epmapper.c @@ -23,6 +23,9 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_PARSE +static uint32 internal_referent_id = 0; + + /******************************************************************* Reads or writes a handle. ********************************************************************/ @@ -211,7 +214,6 @@ BOOL epm_io_floor(const char *desc, EPM_FLOOR *floor, NTSTATUS init_epm_tower(TALLOC_CTX *ctx, EPM_TOWER *tower, const EPM_FLOOR *floors, int num_floors) { - static uint32 internal_referent_id = 0; int size = 0; int i; @@ -224,7 +226,6 @@ NTSTATUS init_epm_tower(TALLOC_CTX *ctx, EPM_TOWER *tower, size += floors[i].rhs.length; } - tower->referent_id = ++internal_referent_id; tower->max_length = tower->length = size; tower->num_floors = num_floors; tower->floors = talloc(ctx, sizeof(EPM_FLOOR) * num_floors); @@ -248,8 +249,9 @@ BOOL epm_io_tower(const char *desc, EPM_TOWER *tower, prs_debug(ps, depth, desc, "epm_io_tower"); depth++; - if (!prs_uint32("referent_id", ps, depth, &tower->referent_id)) + if (!prs_align(ps)) return False; + if (!prs_uint32("max_length", ps, depth, &tower->max_length)) return False; if (!prs_uint32("length", ps, depth, &tower->length)) @@ -278,9 +280,18 @@ BOOL epm_io_tower(const char *desc, EPM_TOWER *tower, NTSTATUS init_epm_tower_array(TALLOC_CTX *ctx, EPM_TOWER_ARRAY *array, const EPM_TOWER *towers, int num_towers) { + int i; + array->max_count = num_towers; array->offset = 0; array->count = num_towers; + array->tower_ref_ids = talloc(ctx, sizeof(uint32) * num_towers); + if (!array->tower_ref_ids) { + return NT_STATUS_NO_MEMORY; + } + for (i=0;itower_ref_ids[i] = ++internal_referent_id; + array->towers = talloc(ctx, sizeof(EPM_TOWER) * num_towers); if (!array->towers) { return NT_STATUS_NO_MEMORY; @@ -308,6 +319,18 @@ BOOL epm_io_tower_array(const char *desc, EPM_TOWER_ARRAY *array, if (!prs_uint32("count", ps, depth, &array->count)) return False; + + if (UNMARSHALLING(ps)) { + array->tower_ref_ids = talloc(ps->mem_ctx, + sizeof(uint32) * array->count); + if (!array->tower_ref_ids) { + return False; + } + } + for (i=0; i < array->count; i++) + if (!prs_uint32("ref_id", ps, depth, &array->tower_ref_ids[i])) + return False; + if (!prs_set_offset(ps, prs_offset(ps) + array->offset)) return False; @@ -376,6 +399,8 @@ NTSTATUS init_epm_q_map(TALLOC_CTX *ctx, EPM_Q_MAP *q_map, /* For now let's not take more than 4 towers per result */ q_map->max_towers = num_towers * 4; + q_map->tower_ref_id = ++internal_referent_id; + handle++; return NT_STATUS_OK; @@ -393,6 +418,9 @@ BOOL epm_io_q_map(const char *desc, EPM_Q_MAP *io_map, prs_struct *ps, if (!epm_io_handle("handle", &io_map->handle, ps, depth)) return False; + if (!prs_uint32("max_towers", ps, 0, &io_map->tower_ref_id)) + return False; + /* HACK: We need a more elegant way of doing this */ if (UNMARSHALLING(ps)) { io_map->tower = talloc(ps->mem_ctx, sizeof(EPM_TOWER)); @@ -416,8 +444,6 @@ BOOL epm_io_q_map(const char *desc, EPM_Q_MAP *io_map, prs_struct *ps, BOOL epm_io_r_map(const char *desc, EPM_R_MAP *io_map, prs_struct *ps, int depth) { - int i; - prs_debug(ps, depth, desc, "epm_io_r_map"); depth++; @@ -433,11 +459,11 @@ BOOL epm_io_r_map(const char *desc, EPM_R_MAP *io_map, if (!io_map->results) return False; } - for (i = 0; i < io_map->num_results; i++) { - if (!epm_io_tower_array("results", io_map->results + i, - ps, depth)) + if (!epm_io_tower_array("results", io_map->results, ps, depth)) return False; - } + + if (!prs_align(ps)) + return False; if (!prs_uint32("status", ps, depth, &io_map->status)) return False; -- cgit From 718634017933bbf39526b834981cde92cfe7a2da Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 21 Oct 2003 16:27:46 +0000 Subject: Fix typo (This used to be commit 26956cdef902819f94616c33694641752f0f14e9) --- source3/rpc_parse/parse_epmapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_epmapper.c b/source3/rpc_parse/parse_epmapper.c index 02340430ec..61704136a0 100644 --- a/source3/rpc_parse/parse_epmapper.c +++ b/source3/rpc_parse/parse_epmapper.c @@ -343,7 +343,7 @@ BOOL epm_io_tower_array(const char *desc, EPM_TOWER_ARRAY *array, } for (i = 0; i < array->count; i++) { - if (!epm_io_tower("tower", array->towers + 1, ps, depth)) + if (!epm_io_tower("tower", &array->towers[i], ps, depth)) return False; } -- cgit From bca9e7d3258058594daaaedd2518fcb2c793ded0 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 22 Oct 2003 20:59:46 +0000 Subject: Be sure referent ID is updated for incoming structures, too. (This used to be commit 00e0aba2cf97e686a0b6b4d7bab50afbc5e97ac1) --- source3/rpc_parse/parse_epmapper.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_epmapper.c b/source3/rpc_parse/parse_epmapper.c index 61704136a0..7a5f147c50 100644 --- a/source3/rpc_parse/parse_epmapper.c +++ b/source3/rpc_parse/parse_epmapper.c @@ -327,9 +327,17 @@ BOOL epm_io_tower_array(const char *desc, EPM_TOWER_ARRAY *array, return False; } } - for (i=0; i < array->count; i++) - if (!prs_uint32("ref_id", ps, depth, &array->tower_ref_ids[i])) + for (i=0; i < array->count; i++) { + if (!prs_uint32("ref_id", ps, depth, &array->tower_ref_ids[i])) { return False; + } else { + if (array->tower_ref_ids[i] > internal_referent_id) { + internal_referent_id = array->tower_ref_ids[i]; + } + } + } + + if (!prs_set_offset(ps, prs_offset(ps) + array->offset)) return False; @@ -418,8 +426,10 @@ BOOL epm_io_q_map(const char *desc, EPM_Q_MAP *io_map, prs_struct *ps, if (!epm_io_handle("handle", &io_map->handle, ps, depth)) return False; - if (!prs_uint32("max_towers", ps, 0, &io_map->tower_ref_id)) + if (!prs_uint32("referent_id", ps, 0, &io_map->tower_ref_id)) return False; + if (io_map->tower_ref_id > internal_referent_id) + internal_referent_id = io_map->tower_ref_id; /* HACK: We need a more elegant way of doing this */ if (UNMARSHALLING(ps)) { -- cgit From 6258550534050e59a80ae8e39d9fb308b2e648fb Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 24 Oct 2003 13:38:13 +0000 Subject: New files for support of initshutdown pipe. Win2k doesn't respond properly to all requests on the winreg pipe, so we need to handle this new pipe. First part of fix for bug #534 (This used to be commit 532fab74c12d8c55872c2bad2abead2647f919d7) --- source3/rpc_parse/parse_shutdown.c | 163 +++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 source3/rpc_parse/parse_shutdown.c (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_shutdown.c b/source3/rpc_parse/parse_shutdown.c new file mode 100644 index 0000000000..ad2d6e1a02 --- /dev/null +++ b/source3/rpc_parse/parse_shutdown.c @@ -0,0 +1,163 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_PARSE + +/******************************************************************* +Inits a structure. +********************************************************************/ + +void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg, + uint32 timeout, BOOL do_reboot, BOOL force) +{ + q_s->ptr_server = 1; + q_s->server = 1; + q_s->ptr_msg = 1; + + init_unistr2(&q_s->uni_msg, msg, UNI_FLAGS_NONE); + init_uni_hdr(&q_s->hdr_msg, &q_s->uni_msg); + + q_s->timeout = timeout; + + q_s->reboot = do_reboot ? 1 : 0; + q_s->force = force ? 1 : 0; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ + +BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps, + int depth) +{ + if (q_s == NULL) + return False; + + prs_debug(ps, depth, desc, "shutdown_io_q_init"); + depth++; + + if (!prs_align(ps)) + return False; + + if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server))) + return False; + if (!prs_uint16("server", ps, depth, &(q_s->server))) + return False; + + if (!prs_align(ps)) + return False; + if (!prs_uint32("ptr_msg", ps, depth, &(q_s->ptr_msg))) + return False; + + if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth)) + return False; + if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth)) + return False; + if (!prs_align(ps)) + return False; + + if (!prs_uint32("timeout", ps, depth, &(q_s->timeout))) + return False; + if (!prs_uint8("force ", ps, depth, &(q_s->force))) + return False; + if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot))) + return False; + + return True; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +BOOL shutdown_io_r_init(const char *desc, SHUTDOWN_R_INIT* r_s, prs_struct *ps, + int depth) +{ + if (r_s == NULL) + return False; + + prs_debug(ps, depth, desc, "shutdown_io_r_init"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_ntstatus("status", ps, depth, &r_s->status)) + return False; + + return True; +} + +/******************************************************************* +Inits a structure. +********************************************************************/ +void init_shutdown_q_abort(SHUTDOWN_Q_ABORT *q_s) +{ + + q_s->ptr_server = 0; + +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s, + prs_struct *ps, int depth) +{ + if (q_s == NULL) + return False; + + prs_debug(ps, depth, desc, "shutdown_io_q_abort"); + depth++; + + if (!prs_align(ps)) + return False; + + if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server))) + return False; + if (q_s->ptr_server != 0) + if (!prs_uint16("server", ps, depth, &(q_s->server))) + return False; + + return True; +} + +/******************************************************************* +reads or writes a structure. +********************************************************************/ +BOOL shutdown_io_r_abort(const char *desc, SHUTDOWN_R_ABORT *r_s, + prs_struct *ps, int depth) +{ + if (r_s == NULL) + return False; + + prs_debug(ps, depth, desc, "shutdown_io_r_abort"); + depth++; + + if (!prs_align(ps)) + return False; + + if (!prs_ntstatus("status", ps, depth, &r_s->status)) + return False; + + return True; +} -- cgit