[sr-dev] git:master:19e608f8: tsilot: t_store(...) accepts uri as parameter

Federico Cabiddu federico.cabiddu at gmail.com
Sat Sep 19 08:03:58 CEST 2015


Hi Daniel,
I woke up this morning with the idea to implement this, I swear!
I'm just wondering now if it still makes sense to use the current uri by
default to store the transactions.
If we use the current uri in the "basic" scenario we have to explicitly
call ts_store("$ou") after lookup(), while maybe it would be cleaner to
call it with a uri when we know that the original uri is not the uri we
want to use for storing the transaction. I don't know if I've been clear
enough :)
Anyway it's not a big point.
Thanks a lot for the contribution which moreover open new use cases for
tsilo in which I didn't think at the beginning.

Cheers,

Federico

On Sat, Sep 19, 2015 at 12:17 AM, Daniel-Constantin Mierla <
miconda at gmail.com> wrote:

> Module: kamailio
> Branch: master
> Commit: 19e608f803b7198543091bf41c468153567741d3
> URL:
> https://github.com/kamailio/kamailio/commit/19e608f803b7198543091bf41c468153567741d3
>
> Author: Daniel-Constantin Mierla <miconda at gmail.com>
> Committer: Daniel-Constantin Mierla <miconda at gmail.com>
> Date: 2015-09-18T22:59:44+02:00
>
> tsilot: t_store(...) accepts uri as parameter
>
> - uri can be explicitely given as parameter instead of taking it from
>   r-uri
> - can help avoiding: backup r-uri, set it to another uri and then restore
>   r-uri from backup
>
> ---
>
> Modified: modules/tsilo/ts_store.c
> Modified: modules/tsilo/ts_store.h
> Modified: modules/tsilo/tsilo.c
>
> ---
>
> Diff:
> https://github.com/kamailio/kamailio/commit/19e608f803b7198543091bf41c468153567741d3.diff
> Patch:
> https://github.com/kamailio/kamailio/commit/19e608f803b7198543091bf41c468153567741d3.patch
>
> ---
>
> diff --git a/modules/tsilo/ts_store.c b/modules/tsilo/ts_store.c
> index a05a4ef..2cec2ef 100644
> --- a/modules/tsilo/ts_store.c
> +++ b/modules/tsilo/ts_store.c
> @@ -39,7 +39,7 @@
>
>  extern int use_domain;
>
> -int ts_store(struct sip_msg* msg) {
> +int ts_store(struct sip_msg* msg, str *puri) {
>         struct cell             *t;
>         str aor;
>         struct sip_uri ruri;
> @@ -48,12 +48,16 @@ int ts_store(struct sip_msg* msg) {
>         ts_urecord_t* r;
>         int res;
>
> -       if (msg->new_uri.s!=NULL) {
> -               /* incoming r-uri was chaged by cfg or other component */
> -               suri = msg->new_uri;
> +       if(puri && puri->s && puri->len>0) {
> +               suri = *puri;
>         } else {
> -               /* no changes to incoming r-uri */
> -               suri = msg->first_line.u.request.uri;
> +               if (msg->new_uri.s!=NULL) {
> +                       /* incoming r-uri was chaged by cfg or other
> component */
> +                       suri = msg->new_uri;
> +               } else {
> +                       /* no changes to incoming r-uri */
> +                       suri = msg->first_line.u.request.uri;
> +               }
>         }
>
>         if (use_domain) {
> diff --git a/modules/tsilo/ts_store.h b/modules/tsilo/ts_store.h
> index 3a3a8a9..824ccc9 100644
> --- a/modules/tsilo/ts_store.h
> +++ b/modules/tsilo/ts_store.h
> @@ -22,6 +22,6 @@
>  #ifndef _TS_STORE_H
>  #define _TS_STORE_H
>
> -int ts_store(struct sip_msg* msg);
> +int ts_store(struct sip_msg* msg, str *puri);
>
>  #endif
> diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c
> index 51c1e81..f9bcfa9 100644
> --- a/modules/tsilo/tsilo.c
> +++ b/modules/tsilo/tsilo.c
> @@ -65,7 +65,8 @@ static int fixup_ts_append_to(void** param, int
> param_no);
>  static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri);
>  static int fixup_ts_append(void** param, int param_no);
>
> -static int w_ts_store(struct sip_msg* msg);
> +static int w_ts_store(struct sip_msg* msg, char *p1, char *p2);
> +static int w_ts_store1(struct sip_msg* msg, char *_ruri, char *p2);
>
>  extern stat_var *stored_ruris;
>  extern stat_var *stored_transactions;
> @@ -80,6 +81,8 @@ static cmd_export_t cmds[]={
>                 fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE },
>         {"ts_store", (cmd_function)w_ts_store,  0,
>                 0 , 0, REQUEST_ROUTE | FAILURE_ROUTE },
> +       {"ts_store", (cmd_function)w_ts_store1,  1,
> +               fixup_spve_null , 0, REQUEST_ROUTE | FAILURE_ROUTE },
>         {0,0,0,0,0,0}
>  };
>
> @@ -279,7 +282,22 @@ static int w_ts_append_to(struct sip_msg* msg, char
> *idx, char *lbl, char *table
>  /**
>   *
>   */
> -static int w_ts_store(struct sip_msg* msg)
> +static int w_ts_store(struct sip_msg* msg, char *p1, char *p2)
>  {
> -       return ts_store(msg);
> +       return ts_store(msg, 0);
> +}
> +
> +
> +/**
> + *
> + */
> +static int w_ts_store1(struct sip_msg* msg, char *_ruri, char *p2)
> +{
> +       str suri;
> +
> +       if(fixup_get_svalue(msg, (gparam_t*)_ruri, &suri)!=0) {
> +               LM_ERR("failed to conert r-uri parameter\n");
> +               return -1;
> +       }
> +       return ts_store(msg, &suri);
>  }
>
>
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20150919/d9817c3a/attachment.html>


More information about the sr-dev mailing list