[sr-dev] rpc: inter module rpc printf callback structure

Ovidiu Sas osas at voipembedded.com
Tue Jun 29 14:31:43 CEST 2010


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 at iptel.org> wrote:
> On Jun 28, 2010 at 17:55, Ovidiu Sas <osas at 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 at 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 at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>



More information about the sr-dev mailing list