Hi,
I was wondering why t_reply_callid is not exported to MI. Since I needed
it, I wrote a patch to make it available via MI. It might be interesting
to others as well, so here goes the patch.
Helmut
Index: kamailio-3.1.2/modules_k/tmx/t_mi.c
===================================================================
--- kamailio-3.1.2.orig/modules_k/tmx/t_mi.c 2011-02-08 19:46:43.000000000 +0100
+++ kamailio-3.1.2/modules_k/tmx/t_mi.c 2011-06-15 11:10:29.000000000 +0200
@@ -824,3 +824,77 @@
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);
+}
+
Index: kamailio-3.1.2/modules_k/tmx/t_mi.h
===================================================================
--- kamailio-3.1.2.orig/modules_k/tmx/t_mi.h 2011-02-08 19:46:43.000000000 +0100
+++ kamailio-3.1.2/modules_k/tmx/t_mi.h 2011-06-15 11:10:29.000000000 +0200
@@ -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_reply(struct mi_root* cmd_tree, void* param);
+struct mi_root* mi_tm_reply_callid(struct mi_root* cmd_tree, void* param);
+
#endif
Index: kamailio-3.1.2/modules_k/tmx/tmx_mod.c
===================================================================
--- kamailio-3.1.2.orig/modules_k/tmx/tmx_mod.c 2011-02-08 19:46:43.000000000 +0100
+++ kamailio-3.1.2/modules_k/tmx/tmx_mod.c 2011-06-15 11:10:29.000000000 +0200
@@ -124,6 +124,7 @@
{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}
};
_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev