aboutsummaryrefslogtreecommitdiffstats
path: root/tbl_qcmd.c
diff options
context:
space:
mode:
authorFreeArtMan <dos21h@gmail.com>2017-09-30 22:51:45 +0100
committerFreeArtMan <dos21h@gmail.com>2017-09-30 22:51:45 +0100
commit512f057166af84c11fc7ed5e4768b9dd2fe9f590 (patch)
treebe57349725502ad9ef14d70a4e32ff3ffb2bea94 /tbl_qcmd.c
parent8c97104aa6fac4a7ed54d97bbcb1aed5e2398713 (diff)
downloadagni-512f057166af84c11fc7ed5e4768b9dd2fe9f590.tar.gz
agni-512f057166af84c11fc7ed5e4768b9dd2fe9f590.zip
comand rpc sends/recieves packets woohoo
Diffstat (limited to 'tbl_qcmd.c')
-rw-r--r--tbl_qcmd.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/tbl_qcmd.c b/tbl_qcmd.c
index adc3503..f56dbc4 100644
--- a/tbl_qcmd.c
+++ b/tbl_qcmd.c
@@ -81,7 +81,7 @@ int tbl_exec_in_s(tbl_exec *tbl, char *cmd)
return -1;
}
-int tbl_exec_run(tbl_exec *tbl, char *cmd, void **resp)
+int tbl_exec_run(tbl_exec *tbl, char *cmd, char *user, char *mask, char *server, void **resp)
{
int ret=-1;
void *clbk_data=NULL;
@@ -90,6 +90,7 @@ int tbl_exec_run(tbl_exec *tbl, char *cmd, void **resp)
int i;
tble_exec *el=NULL;
+ //user,mask,server could be NULL
if ((tbl == NULL) || (cmd == NULL) || (resp==NULL) || (*resp != NULL))
{
PERM();
@@ -140,7 +141,47 @@ int tbl_exec_run(tbl_exec *tbl, char *cmd, void **resp)
ret_resp = el->callback(clbk_data); //no params for now
} else if (el->type == TBL_T_RPC)
{
- ERROR("Not implemented\n");
+ rpc_call_request *req = NULL;
+ rpc_call_response *resp = NULL;
+ netbyte_store *nb_req=NULL, *nb_resp=NULL;
+ char *buf_nb = NULL, *resp_buf=NULL;
+
+ nb_resp = malloc(sizeof(netbyte_store));
+ nb_req = malloc(sizeof(netbyte_store));
+ nb_init(nb_resp);
+ nb_init(nb_req);
+
+ //create request
+ req = rpc_call_req_new(el->name, "asd", 1);
+ if (!req) PERM();
+ if (user != NULL)
+ {
+ req->user = alloc_new_str(user);
+ }
+ if (mask != NULL)
+ {
+ req->mask = alloc_new_str(mask);
+ }
+ if (server != NULL)
+ {
+ req->server = alloc_new_str(server);
+ }
+ rpc_call_req_marsh(req, &nb_req);
+ buf_nb = nb_create(nb_req);
+ resp_buf = el->callback(buf_nb);
+ if (resp_buf!=NULL)
+ {
+ nb_load(nb_resp, resp_buf);
+ rpc_call_resp_unmarsh(nb_resp, &resp);
+ ret_resp = alloc_new_str(resp->result);
+ rpc_call_resp_free(resp);
+ } else
+ {
+ ERROR("No response from RPC command\n");
+ }
+ FREE(buf_nb);
+ rpc_call_req_free(req);
+
} else if (el->type == TBL_T_LUA)
{
ERROR("Not implemented\n");