Module: sip-router
Branch: master
Commit: 03cda297c97bc098c0389b04b180a6ec27c3e5e6
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=03cda29…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sat Jun 18 19:30:09 2011 +0200
tmx: added t_reply_callid MI command
- patch by Helmut Grohne
---
modules_k/tmx/t_mi.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++
modules_k/tmx/t_mi.h | 3 ++
modules_k/tmx/tmx_mod.c | 1 +
3 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/modules_k/tmx/t_mi.c b/modules_k/tmx/t_mi.c
index 405ed88..973061e 100644
--- a/modules_k/tmx/t_mi.c
+++ b/modules_k/tmx/t_mi.c
@@ -824,3 +824,77 @@ struct mi_root* mi_tm_reply(struct mi_root* cmd_tree, void* param)
return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
}
+/*
+ Syntax of "t_reply_callid" :
+ code
+ reason
+ callid
+ cseq
+ to_tag
+ new headers
+ [Body]
+*/
+struct mi_root* mi_tm_reply_callid(struct mi_root* cmd_tree, void* param)
+{
+ struct mi_node* node;
+ unsigned int rpl_code;
+ struct cell *trans;
+ str reason = {0, 0};
+ str totag = {0, 0};
+ str new_hdrs = {0, 0};
+ str body = {0, 0};
+ str callid = {0, 0};
+ str cseq = {0, 0};
+ int n;
+
+ for( n=0,node = cmd_tree->node.kids; n<7 && node ; n++,node=node->next
);
+ if ( !(n==6 || n==7) || node!=0)
+ return init_mi_tree( 400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN);
+
+ /* get all info from the command */
+
+ /* reply code (param 1) */
+ node = cmd_tree->node.kids;
+ if (str2int( &node->value, &rpl_code)!=0 || rpl_code>=700)
+ return init_mi_tree( 400, "Invalid reply code", 18);
+
+ /* reason text (param 2) */
+ node = node->next;
+ reason = node->value;
+
+ /* callid (param 3) */
+ node = node->next;
+ callid = node->value;
+
+ /* cseq (param 4) */
+ node = node->next;
+ cseq = node->value;
+
+ if(_tmx_tmb.t_lookup_callid( &trans, callid, cseq) < 0 )
+ return init_mi_tree( 400, "Lookup failed - no transaction", 30);
+
+ /* to_tag (param 5) */
+ node = node->next;
+ totag = node->value;
+
+ /* new headers (param 6) */
+ node = node->next;
+ if (!(node->value.len==1 && node->value.s[0]=='.'))
+ new_hdrs = node->value;
+
+ /* body (param 7 - optional) */
+ node = node->next;
+ if (node)
+ body = node->value;
+
+ /* it's refcounted now, t_reply_with body unrefs for me -- I can
+ * continue but may not use T anymore */
+ n = _tmx_tmb.t_reply_with_body(trans, rpl_code, &reason, &body,
+ &new_hdrs, &totag);
+
+ if (n<0)
+ return init_mi_tree( 500, "Reply failed", 12);
+
+ return init_mi_tree( 200, MI_OK_S, MI_OK_LEN);
+}
+
diff --git a/modules_k/tmx/t_mi.h b/modules_k/tmx/t_mi.h
index 23c4f9f..3b10d57 100644
--- a/modules_k/tmx/t_mi.h
+++ b/modules_k/tmx/t_mi.h
@@ -43,6 +43,7 @@
#define MI_TM_CANCEL "t_uac_cancel"
#define MI_TM_HASH "t_hash"
#define MI_TM_REPLY "t_reply"
+#define MI_TM_REPLY_CALLID "t_reply_callid"
struct mi_root* mi_tm_uac_dlg(struct mi_root* cmd_tree, void* param);
@@ -52,4 +53,6 @@ struct mi_root* mi_tm_hash(struct mi_root* cmd_tree, void* param);
struct mi_root* mi_tm_reply(struct mi_root* cmd_tree, void* param);
+struct mi_root* mi_tm_reply_callid(struct mi_root* cmd_tree, void* param);
+
#endif
diff --git a/modules_k/tmx/tmx_mod.c b/modules_k/tmx/tmx_mod.c
index 36f7e6c..8a36352 100644
--- a/modules_k/tmx/tmx_mod.c
+++ b/modules_k/tmx/tmx_mod.c
@@ -129,6 +129,7 @@ static mi_export_t mi_cmds [] = {
{MI_TM_CANCEL, mi_tm_cancel, 0, 0, 0 },
{MI_TM_HASH, mi_tm_hash, MI_NO_INPUT_FLAG, 0, 0 },
{MI_TM_REPLY, mi_tm_reply, 0, 0, 0 },
+ {MI_TM_REPLY_CALLID, mi_tm_reply_callid, 0, 0, 0 },
{0,0,0,0,0}
};