Browse Source

tm: t_drop_replies() exported to kemi framework

Daniel-Constantin Mierla 8 years ago
parent
commit
358cf95e68
1 changed files with 29 additions and 4 deletions
  1. 29 4
      src/modules/tm/tm.c

+ 29 - 4
src/modules/tm/tm.c

@@ -2044,19 +2044,34 @@ int t_grep_status(struct sip_msg* msg, char* status, char* bar)
 
 /* drop all the existing replies in failure_route to make sure
  * that none of them is picked up again */
-static int w_t_drop_replies(struct sip_msg* msg, char* foo, char* bar)
+static int t_drop_replies_helper(sip_msg_t* msg, char* mode)
 {
-	if(foo==NULL)
+	if(mode==NULL)
 		t_drop_replies(1);
-	else if(*foo=='n')
+	else if(*mode=='n')
 		t_drop_replies(0);
-	else if(*foo=='l')
+	else if(*mode=='l')
 		t_drop_replies(2);
 	else
 		t_drop_replies(1);
 	return 1;
 }
 
+static int w_t_drop_replies(struct sip_msg* msg, char* mode, char* bar)
+{
+	return t_drop_replies_helper(msg, mode);
+}
+
+static int ki_t_drop_replies(sip_msg_t* msg, str* mode)
+{
+	return t_drop_replies_helper(msg, (mode)?mode->s:NULL);
+}
+
+static int ki_t_drop_replies_all(sip_msg_t* msg)
+{
+	return t_drop_replies_helper(msg, NULL);
+}
+
 /* save the message lumps after t_newtran() but before t_relay() */
 static int w_t_save_lumps(struct sip_msg* msg, char* foo, char* bar)
 {
@@ -2695,6 +2710,16 @@ static sr_kemi_t tm_kemi_exports[] = {
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init("tm"), str_init("t_drop_replies_all"),
+		SR_KEMIP_INT, ki_t_drop_replies_all,
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("tm"), str_init("t_drop_replies"),
+		SR_KEMIP_INT, ki_t_drop_replies,
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
 
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };