Hello all,
I need to pass the rpc printf params between two modules via a callback functions. The current implementation allows passing a pointer during the callback call and I would like to reuse the existing callback pointer to pass a everything that I need through it. I would like to define a new structure for rpc and pass a pointer to that structure during the callback call:
diff --git a/rpc.h b/rpc.h index 1434146..ff66b5a 100644 --- a/rpc.h +++ b/rpc.h @@ -88,6 +88,10 @@ typedef struct rpc_delayed_ctx{ /* more private data might follow */ } rpc_delayed_ctx_t;
+typedef struct rpc_cb_ctx { + rpc_t *rpc; + void *c; +} rpc_cb_ctx_t;
/* * RPC Function Prototype
This will allow printing mixed info from different modules, in my particular case, printing qos context info along with dialog context info (modules_k: dialog and qos). Since I'm not familiar with the rpc interface, please advice if this is the right way of doing it or if there is another better alternative.
Regards, Ovidiu Sas
So ... are there any objections of defining the rpc_cb_ctx_t typedef inside rpc.h?
Thanks, Ovidiu Sas
On Sat, Jun 26, 2010 at 9:13 AM, Ovidiu Sas osas@voipembedded.com wrote:
Hello all,
I need to pass the rpc printf params between two modules via a callback functions. The current implementation allows passing a pointer during the callback call and I would like to reuse the existing callback pointer to pass a everything that I need through it. I would like to define a new structure for rpc and pass a pointer to that structure during the callback call:
diff --git a/rpc.h b/rpc.h index 1434146..ff66b5a 100644 --- a/rpc.h +++ b/rpc.h @@ -88,6 +88,10 @@ typedef struct rpc_delayed_ctx{ /* more private data might follow */ } rpc_delayed_ctx_t;
+typedef struct rpc_cb_ctx {
- rpc_t *rpc;
- void *c;
+} rpc_cb_ctx_t;
/* * RPC Function Prototype
This will allow printing mixed info from different modules, in my particular case, printing qos context info along with dialog context info (modules_k: dialog and qos). Since I'm not familiar with the rpc interface, please advice if this is the right way of doing it or if there is another better alternative.
Regards, Ovidiu Sas
On Jun 28, 2010 at 17:55, Ovidiu Sas osas@voipembedded.com wrote:
So ... are there any objections of defining the rpc_cb_ctx_t typedef inside rpc.h?
I'm not sure I understand what it's needed for and what impact will it have on existing code. If it means changing the existing interface, then a lot of code would have to be updated and I wouldn't agree with it, particularly very close to a code freeze.
Could you come up with a small code/pseudo-code example?
From your description I don't understand why you need to pack
rpc_t and c (I assume c is here the rpc context) in a structure, since every rpc "callback" already gets both of them as parameters.
Andrei
Thanks, Ovidiu Sas
On Sat, Jun 26, 2010 at 9:13 AM, Ovidiu Sas osas@voipembedded.com wrote:
Hello all,
I need to pass the rpc printf params between two modules via a callback functions. The current implementation allows passing a pointer during the callback call and I would like to reuse the existing callback pointer to pass a everything that I need through it. I would like to define a new structure for rpc and pass a pointer to that structure during the callback call:
diff --git a/rpc.h b/rpc.h index 1434146..ff66b5a 100644 --- a/rpc.h +++ b/rpc.h @@ -88,6 +88,10 @@ typedef struct rpc_delayed_ctx{ /* more private data might follow */ } rpc_delayed_ctx_t;
+typedef struct rpc_cb_ctx {
- rpc_t *rpc;
- void *c;
+} rpc_cb_ctx_t;
/* * RPC Function Prototype
This will allow printing mixed info from different modules, in my particular case, printing qos context info along with dialog context info (modules_k: dialog and qos). Since I'm not familiar with the rpc interface, please advice if this is the right way of doing it or if there is another better alternative.
Regards, Ovidiu Sas
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Hello Andrei,
Thanks for getting back to me on this one.
Here's a pseudocode example. Let's assume that we have module a and module b. We have an rpc call into module a to print out some info. Module b has some relevant info that we would like to print out during the rpc call into module a.
inside module a we have: static void module_a_print_info(rpc_t *rpc, void *c) { /*declare a variable to pass rpc stuf up to module b */ rpc_cb_ctx_t *rpc_cb;
/* print stuff related to module a */ rpc->printf(c, "module a stuff ....");
/*let's print stuf from mudule b now via a callback */ rpc_cb->rpc = rpc; rpc_cb->c = c; run_callback_into_module_b( ...., (void *)rpc_cb); }
inside module b, we have the callback: void module_b_callback_function(...., struct module_b_generic_callback_param *param) /* extract rpc and c via the generic module_b_generic_callback_param */ rpc_cb_ctx_t* rpc_cb = (rpc_cb_ctx_t*)(param); rpc_t *rpc = rpc_cb->rpc; void *c = rpc_cb->c;
rpc->printf(c, "module b stuff ...."); }
Hope that the above pseudocode explains what I want to achieve. There is no impact on the core, all I want is to declare the rpc_cb_ctx_t structure into the rpc.h in order to make it available in an atomic way to both module a and b.
The real modules are: - module a: modules_k/dialog (dialog.c:internal_rpc_print_dlg) - module b: modules_k/qos (qos_handlers.c:qos_dialog_rpc_context_CB)
Regards, Ovidiu Sas
On Tue, Jun 29, 2010 at 5:08 AM, Andrei Pelinescu-Onciul andrei@iptel.org wrote:
On Jun 28, 2010 at 17:55, Ovidiu Sas osas@voipembedded.com wrote:
So ... are there any objections of defining the rpc_cb_ctx_t typedef inside rpc.h?
I'm not sure I understand what it's needed for and what impact will it have on existing code. If it means changing the existing interface, then a lot of code would have to be updated and I wouldn't agree with it, particularly very close to a code freeze.
Could you come up with a small code/pseudo-code example? From your description I don't understand why you need to pack rpc_t and c (I assume c is here the rpc context) in a structure, since every rpc "callback" already gets both of them as parameters.
Andrei
Thanks, Ovidiu Sas
On Sat, Jun 26, 2010 at 9:13 AM, Ovidiu Sas osas@voipembedded.com wrote:
Hello all,
I need to pass the rpc printf params between two modules via a callback functions. The current implementation allows passing a pointer during the callback call and I would like to reuse the existing callback pointer to pass a everything that I need through it. I would like to define a new structure for rpc and pass a pointer to that structure during the callback call:
diff --git a/rpc.h b/rpc.h index 1434146..ff66b5a 100644 --- a/rpc.h +++ b/rpc.h @@ -88,6 +88,10 @@ typedef struct rpc_delayed_ctx{ /* more private data might follow */ } rpc_delayed_ctx_t;
+typedef struct rpc_cb_ctx {
- rpc_t *rpc;
- void *c;
+} rpc_cb_ctx_t;
/* * RPC Function Prototype
This will allow printing mixed info from different modules, in my particular case, printing qos context info along with dialog context info (modules_k: dialog and qos). Since I'm not familiar with the rpc interface, please advice if this is the right way of doing it or if there is another better alternative.
Regards, Ovidiu Sas
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
On Jun 29, 2010 at 08:31, Ovidiu Sas osas@voipembedded.com wrote:
Hello Andrei,
Thanks for getting back to me on this one.
Here's a pseudocode example. Let's assume that we have module a and module b. We have an rpc call into module a to print out some info. Module b has some relevant info that we would like to print out during the rpc call into module a.
inside module a we have: static void module_a_print_info(rpc_t *rpc, void *c) { /*declare a variable to pass rpc stuf up to module b */ rpc_cb_ctx_t *rpc_cb;
/* print stuff related to module a */ rpc->printf(c, "module a stuff ...."); /*let's print stuf from mudule b now via a callback */ rpc_cb->rpc = rpc; rpc_cb->c = c; run_callback_into_module_b( ...., (void *)rpc_cb);
}
inside module b, we have the callback: void module_b_callback_function(...., struct module_b_generic_callback_param *param) /* extract rpc and c via the generic module_b_generic_callback_param */ rpc_cb_ctx_t* rpc_cb = (rpc_cb_ctx_t*)(param); rpc_t *rpc = rpc_cb->rpc; void *c = rpc_cb->c;
rpc->printf(c, "module b stuff ....");
}
Hope that the above pseudocode explains what I want to achieve. There is no impact on the core, all I want is to declare the rpc_cb_ctx_t structure into the rpc.h in order to make it available in an atomic way to both module a and b.
Ok, so you really need a common type used to pack the rpc functions and context, defined somewhere in a file included by both of the modules.
It's fine if you add it to rpc.h, but then please add some comments stating that is only a convenient way of packing an rpc callback (rpc_function_t) parameters and it's not used/needed by the rpc api/interface (to avoid confusion in the future).
The real modules are:
- module a: modules_k/dialog (dialog.c:internal_rpc_print_dlg)
- module b: modules_k/qos (qos_handlers.c:qos_dialog_rpc_context_CB)
Andrei [...]