[sr-dev] git:jason.penton/kamailio_ims_extensions: TM: Expose fake reply via api

Daniel-Constantin Mierla miconda at gmail.com
Thu Oct 20 14:41:20 CEST 2011


Hi Jason,

just a quick thing since I saw affected files, doesn't make more sense 
to  have the function for sending fake reply in t_reply.c instead of 
t_cancel.c? The name would match better.

Cheers,
Daniel


On 10/20/11 2:12 PM, Jason Penton wrote:
> Module: sip-router
> Branch: jason.penton/kamailio_ims_extensions
> Commit: a8695bee7d918986fa32b05ae238cf1dcfa11aed
> URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a8695bee7d918986fa32b05ae238cf1dcfa11aed
>
> Author: Jason Penton<jason.penton at gmail.com>
> Committer: Jason Penton<jason.penton at gmail.com>
> Date:   Thu Oct 20 14:09:50 2011 +0200
>
> TM: Expose fake reply via api
>
>    - Allows to be able to send fake replies through TM api. Useful
>      for terminating early dialogs
>
> ---
>
>   modules/tm/t_cancel.c |    6 ++++++
>   modules/tm/t_cancel.h |    2 ++
>   modules/tm/timer.c    |    2 +-
>   modules/tm/timer.h    |    2 +-
>   modules/tm/tm_load.c  |    1 +
>   modules/tm/tm_load.h  |    1 +
>   modules/tm/uac.h      |    2 ++
>   7 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/modules/tm/t_cancel.c b/modules/tm/t_cancel.c
> index c1b52be..ac1bf4f 100644
> --- a/modules/tm/t_cancel.c
> +++ b/modules/tm/t_cancel.c
> @@ -65,6 +65,7 @@
>   #include "t_msgbuilder.h"
>   #include "t_lookup.h" /* for t_lookup_callid in fifo_uac_cancel */
>   #include "t_hooks.h"
> +#include "timer.h"
>
>
>   /** Prepare to cancel a transaction.
> @@ -543,3 +544,8 @@ error3:
>   }
>
>
> +void w_fake_reply(struct cell *t, int branch, int code )
> +{
> +    LOCK_REPLIES(t);
> +    fake_reply(t, branch, code);
> +}
> diff --git a/modules/tm/t_cancel.h b/modules/tm/t_cancel.h
> index 874483c..8b44cc9 100644
> --- a/modules/tm/t_cancel.h
> +++ b/modules/tm/t_cancel.h
> @@ -96,6 +96,8 @@ typedef int (*cancel_all_uacs_f)(struct cell *trans, int how);
>   typedef void (*prepare_to_cancel_f)(struct cell *t, branch_bm_t *cancel_bm,
>   									branch_bm_t skip_branches);
>
> +void w_fake_reply(struct cell *t, int branch, int code );
> +
>
>   /** Check if one branch needs CANCEL-ing and prepare it if it does.
>    * Can be called w/o REPLY_LOCK held
> diff --git a/modules/tm/timer.c b/modules/tm/timer.c
> index b834f11..768aa78 100644
> --- a/modules/tm/timer.c
> +++ b/modules/tm/timer.c
> @@ -335,7 +335,7 @@ inline static ticks_t  delete_cell( struct cell *p_cell, int unlock )
>
>   /* generate a fake reply
>    * it assumes the REPLY_LOCK is already held and returns unlocked */
> -static void fake_reply(struct cell *t, int branch, int code )
> +void fake_reply(struct cell *t, int branch, int code )
>   {
>   	struct cancel_info cancel_data;
>   	short do_cancel_branch;
> diff --git a/modules/tm/timer.h b/modules/tm/timer.h
> index d506adb..9acddc1 100644
> --- a/modules/tm/timer.h
> +++ b/modules/tm/timer.h
> @@ -148,7 +148,7 @@ extern struct msgid_var user_rt_t2_timeout_ms;
>   extern struct msgid_var user_inv_max_lifetime;
>   extern struct msgid_var user_noninv_max_lifetime;
>
> -
> +void fake_reply(struct cell *t, int branch, int code );
>   /**
>    * \brief fix timer values to ticks
>    */
> diff --git a/modules/tm/tm_load.c b/modules/tm/tm_load.c
> index d57fd45..cda04f0 100644
> --- a/modules/tm/tm_load.c
> +++ b/modules/tm/tm_load.c
> @@ -115,6 +115,7 @@ int load_tm( struct tm_binds *tmb)
>   	tmb->send_prepared_request = send_prepared_request;
>   	tmb->dlg_add_extra = dlg_add_extra;
>   	tmb->t_cancel_uac = t_uac_cancel;
> +        tmb->fake_reply = w_fake_reply;
>
>   #ifdef DIALOG_CALLBACKS
>   	tmb->register_new_dlg_cb=register_new_dlg_cb;
> diff --git a/modules/tm/tm_load.h b/modules/tm/tm_load.h
> index 370c2ef..58f0b70 100644
> --- a/modules/tm/tm_load.h
> +++ b/modules/tm/tm_load.h
> @@ -91,6 +91,7 @@ struct tm_binds {
>   	cancel_all_uacs_f  cancel_all_uacs;
>   	prepare_request_within_f  prepare_request_within;
>   	send_prepared_request_f   send_prepared_request;
> +        fake_reply_f       fake_reply;
>   	enum route_mode*   route_mode;
>   #ifdef DIALOG_CALLBACKS
>   	register_new_dlg_cb_f register_new_dlg_cb;
> diff --git a/modules/tm/uac.h b/modules/tm/uac.h
> index 619d43e..f10f0ab 100644
> --- a/modules/tm/uac.h
> +++ b/modules/tm/uac.h
> @@ -96,6 +96,8 @@ typedef int (*prepare_request_within_f)(uac_req_t *uac_r,
>   typedef void (*send_prepared_request_f)(struct retr_buf *request_dst);
>   typedef void (*generate_fromtag_f)(str*, str*);
>
> +typedef void (*fake_reply_f)(struct cell *cell, int branch, int code);
> +
>   /*
>    * Generate a fromtag based on given Call-ID
>    */
>
>
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Dec 5-8, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-dev mailing list