From 5df58c38f3c29d87c5918d1611c17e016c6f7545 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 4 Mar 2006 00:05:40 +0000 Subject: r13829: From the "It's not pretty but it works" category * Finish prototype of the "add port command" implementation Format is "addportcommand portname deviceURI" * DeviceURI is either - socket://hostname:port/ - lpr://hostname/queue depending on what the client sent in the request (This used to be commit 6d74de7a676b71e83a3c3714743e6380c04e4425) --- source3/rpc_parse/parse_spoolss.c | 100 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'source3/rpc_parse') diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 2bb8a7bbdd..576d75f88c 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -7488,3 +7488,103 @@ BOOL make_monitorui_buf( RPC_BUFFER *buf, const char *dllname ) return True; } + +/******************************************************************* + ********************************************************************/ + +static BOOL smb_io_port_data_1( const char *desc, RPC_BUFFER *buf, int depth, SPOOL_PORT_DATA_1 *p1 ) +{ + prs_struct *ps = &buf->prs; + uint8 *fodder; + + prs_debug(ps, depth, desc, "smb_io_port_data_1"); + depth++; + + if(!prs_align(ps)) + return False; + + if ( UNMARSHALLING(ps) ) { + p1->portname.buffer = PRS_ALLOC_MEM( ps, uint16, 64 ); + p1->hostaddress.buffer = PRS_ALLOC_MEM( ps, uint16, 49 ); + p1->snmpcommunity.buffer = PRS_ALLOC_MEM( ps, uint16, 33 ); + p1->queue.buffer = PRS_ALLOC_MEM( ps, uint16, 33 ); + p1->ipaddress.buffer = PRS_ALLOC_MEM( ps, uint16, 17 ); + fodder = PRS_ALLOC_MEM( ps, uint8, 540 ); + } + + if( !prs_uint16s(True, "portname", ps, depth, p1->portname.buffer, 64)) + return False; + + if (!prs_uint32("version", ps, depth, &p1->version)) + return False; + if (!prs_uint32("protocol", ps, depth, &p1->protocol)) + return False; + if (!prs_uint32("size", ps, depth, &p1->size)) + return False; + if (!prs_uint32("reserved", ps, depth, &p1->reserved)) + return False; + + if( !prs_uint16s(True, "hostaddress", ps, depth, p1->hostaddress.buffer, 49)) + return False; + if( !prs_uint16s(True, "snmpcommunity", ps, depth, p1->snmpcommunity.buffer, 33)) + return False; + + if (!prs_uint32("dblspool", ps, depth, &p1->dblspool)) + return False; + + if( !prs_uint16s(True, "queue", ps, depth, p1->queue.buffer, 33)) + return False; + if( !prs_uint16s(True, "ipaddress", ps, depth, p1->ipaddress.buffer, 17)) + return False; + + /* fodder according to MSDN */ + if( !prs_uint8s(False, "", ps, depth, fodder, 540)) + return False; + + if (!prs_uint32("port", ps, depth, &p1->port)) + return False; + if (!prs_uint32("snmpenabled", ps, depth, &p1->snmpenabled)) + return False; + if (!prs_uint32("snmpdevindex", ps, depth, &p1->snmpdevindex)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +BOOL convert_port_data_1( NT_PORT_DATA_1 *port1, RPC_BUFFER *buf ) +{ + SPOOL_PORT_DATA_1 spdata_1; + + ZERO_STRUCT( spdata_1 ); + + if ( !smb_io_port_data_1( "port_data_1", buf, 0, &spdata_1 ) ) + return False; + + rpcstr_pull(port1->name, spdata_1.portname.buffer, sizeof(port1->name), + -1, 0); + rpcstr_pull(port1->queue, spdata_1.queue.buffer, sizeof(port1->queue), + -1, 0); + rpcstr_pull(port1->hostaddr, spdata_1.hostaddress.buffer, + sizeof(port1->hostaddr), -1, 0); + + port1->port = spdata_1.port; + + switch ( spdata_1.protocol ) { + case 1: + port1->protocol = PORT_PROTOCOL_DIRECT; + break; + case 2: + port1->protocol = PORT_PROTOCOL_LPR; + break; + default: + DEBUG(3,("convert_port_data_1: unknown protocol [%d]!\n", + spdata_1.protocol)); + return False; + } + + return True; +} + -- cgit