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
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
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.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "lib/cmdline/popt_common.h"
#include "lib/messaging/irpc.h"
#include "scripting/ejs/ejsrpc.h"
-#include "dlinklist.h"
+#include "lib/util/dlinklist.h"
#include "lib/events/events.h"
-#include "librpc/rpc/dcerpc_table.h"
+#include "librpc/ndr/ndr_table.h"
#include "auth/credentials/credentials.h"
#include "librpc/rpc/dcerpc.h"
+#include "cluster/cluster.h"
/*
state of a irpc 'connection'
*/
struct ejs_irpc_connection {
const char *server_name;
- uint32_t *dest_ids;
+ struct server_id *dest_ids;
struct messaging_context *msg_ctx;
};
/* create a messaging context, looping as we have no way to
allocate temporary server ids automatically */
for (i=0;i<10000;i++) {
- p->msg_ctx = messaging_init(p, EJS_ID_BASE + i, ev);
+ p->msg_ctx = messaging_init(p,
+ lp_messaging_path(p, global_loadparm),
+ cluster_id(EJS_ID_BASE + i), ev);
if (p->msg_ctx) break;
}
if (p->msg_ctx == NULL) {
return -1;
}
- p->dest_ids = irpc_servers_byname(p->msg_ctx, p->server_name);
- if (p->dest_ids == NULL || p->dest_ids[0] == 0) {
+ p->dest_ids = irpc_servers_byname(p->msg_ctx, p, p->server_name);
+ if (p->dest_ids == NULL || p->dest_ids[0].id == 0) {
talloc_free(p);
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
} else {
static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv)
{
const char *binding, *pipe_name;
- const struct dcerpc_interface_table *iface;
+ const struct ndr_interface_table *iface;
NTSTATUS status;
struct dcerpc_pipe *p;
struct cli_credentials *creds;
pipe_name = mprToString(mprGetProperty(this, "pipe_name", NULL));
}
- iface = idl_iface_by_name(pipe_name);
+ iface = ndr_table_by_name(pipe_name);
if (iface == NULL) {
status = NT_STATUS_OBJECT_NAME_INVALID;
goto done;
credentials = mprGetProperty(this, "credentials", NULL);
if (credentials) {
- creds = mprGetPtr(credentials, "creds");
+ creds = (struct cli_credentials *)
+ mprGetPtr(credentials, "creds");
} else {
creds = cmdline_credentials;
}
if (creds == NULL) {
creds = cli_credentials_init(mprMemCtx());
- cli_credentials_guess(creds);
cli_credentials_set_anonymous(creds);
}
make an irpc call - called via the same interface as rpc
*/
static int ejs_irpc_call(int eid, struct MprVar *io,
- const struct dcerpc_interface_table *iface, int callnum,
+ const struct ndr_interface_table *iface, int callnum,
ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push)
{
NTSTATUS status;
void *ptr;
struct ejs_rpc *ejs;
- const struct dcerpc_interface_call *call;
+ const struct ndr_interface_call *call;
struct ejs_irpc_connection *p;
struct irpc_request **reqs;
int i, count;
struct MprVar *results;
- p = mprGetThisPtr(eid, "irpc");
+ p = (struct ejs_irpc_connection *)mprGetThisPtr(eid, "irpc");
ejs = talloc(mprMemCtx(), struct ejs_rpc);
if (ejs == NULL) {
goto done;
}
- for (count=0;p->dest_ids[count];count++) /* noop */ ;
+ for (count=0;p->dest_ids[count].id;count++) /* noop */ ;
/* we need to make a call per server */
reqs = talloc_array(ejs, struct irpc_request *, count);
code
*/
int ejs_rpc_call(int eid, int argc, struct MprVar **argv,
- const struct dcerpc_interface_table *iface, int callnum,
+ const struct ndr_interface_table *iface, int callnum,
ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push)
{
struct MprVar *io;
void *ptr;
struct rpc_request *req;
struct ejs_rpc *ejs;
- const struct dcerpc_interface_call *call;
+ const struct ndr_interface_call *call;
if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) {
ejsSetErrorMsg(eid, "rpc_call invalid arguments");
*/
int ejs_rpc_init(struct MprVar *obj, const char *name)
{
- dcerpc_table_init();
+ ndr_table_init();
mprSetStringCFunction(obj, "connect", ejs_rpc_connect);
if (mprGetProperty(obj, "pipe_name", NULL) == NULL) {