2 Unix SMB/Netbios implementation.
4 SMB client generic functions
5 Copyright (C) Andrew Tridgell 1994-2000
6 Copyright (C) Luke Kenneth Casson Leighton 1996-2000
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "rpc_parse.h"
27 #include "rpc_client.h"
30 extern int DEBUGLEVEL;
31 extern pstring global_myname;
39 static struct ncacn_np_use **msrpcs = NULL;
40 static uint32 num_msrpcs = 0;
42 /****************************************************************************
43 terminate client connection
44 ****************************************************************************/
45 static void ncacn_np_shutdown(struct ncacn_np *cli)
51 if (cli->smb->initialised)
53 /* cli_nt_session_close(cli->smb, cli->fnum); JERRY */
54 cli_nt_session_close(cli->smb);
56 #if 0 /* commented out by JERRY */
57 cli_net_use_del(cli->smb->desthost,
58 &cli->smb->usr, False, False);
65 /****************************************************************************
66 terminate client connection
67 ****************************************************************************/
68 static void ncacn_np_use_free(struct ncacn_np_use *cli)
72 if (cli->cli->initialised)
74 ncacn_np_shutdown(cli->cli);
76 ZERO_STRUCTP(cli->cli);
84 /****************************************************************************
86 ****************************************************************************/
87 BOOL ncacn_np_use_del(const char *srv_name, const char *pipe_name,
88 const vuser_key * key,
89 BOOL force_close, BOOL *connection_closed)
92 DEBUG(10, ("ncacn_np_net_use_del: %s. force close: %s ",
93 pipe_name, BOOLSTR(force_close)));
96 DEBUG(10, ("[%d,%x]", key->pid, key->vuid));
100 if (connection_closed != NULL)
102 *connection_closed = False;
105 if (strnequal("\\PIPE\\", pipe_name, 6))
107 pipe_name = &pipe_name[6];
110 if (strnequal("\\\\", srv_name, 2))
112 srv_name = &srv_name[6];
115 for (i = 0; i < num_msrpcs; i++)
117 char *ncacn_np_name = NULL;
118 char *ncacn_np_srv_name = NULL;
119 struct ncacn_np_use *c = msrpcs[i];
122 if (c == NULL || c->cli == NULL || c->cli->smb == NULL)
125 ncacn_np_name = c->cli->pipe_name;
126 ncacn_np_srv_name = c->cli->smb->desthost;
128 k = c->cli->smb->key;
130 DEBUG(10, ("use_del[%d]: %s %s %s %s [%d,%x]\n",
131 i, ncacn_np_name, ncacn_np_srv_name,
132 c->cli->smb->user_name,
133 c->cli->smb->domain, k.pid, k.vuid));
135 if (strnequal("\\PIPE\\", ncacn_np_name, 6))
137 ncacn_np_name = &ncacn_np_name[6];
139 if (!strequal(ncacn_np_srv_name, srv_name))
143 if (strnequal("\\\\", ncacn_np_srv_name, 2))
145 ncacn_np_srv_name = &ncacn_np_srv_name[6];
147 if (!strequal(ncacn_np_name, pipe_name))
151 if (key->pid != k.pid || key->vuid != k.vuid)
155 /* decrement number of users */
157 DEBUG(10, ("idx: %i num_users now: %d\n",
159 if (force_close || c->num_users == 0)
161 ncacn_np_use_free(c);
163 if (connection_closed != NULL)
165 *connection_closed = True;