浏览代码

topoh: discover local request direction from th cookie

- l can be used to mark local requests for topoh handling
Daniel-Constantin Mierla 10 年之前
父节点
当前提交
0219d5a909
共有 2 个文件被更改,包括 22 次插入2 次删除
  1. 9 0
      modules/topoh/th_msg.c
  2. 13 2
      modules/topoh/topoh_mod.c

+ 9 - 0
modules/topoh/th_msg.c

@@ -1002,6 +1002,15 @@ int th_del_cookie(sip_msg_t *msg)
 }
 
 
+/**
+ * return the special topoh cookie
+ * - TH header of TH Via parame
+ * - value is 3 chars
+ *   [0] - direction:    d - downstream; u - upstream
+ *   [1] - request type: i - initial; c - in-dialog; l - local in-dialog
+ *   [2] - location:     h - header; v - via param
+ * - if not found, returns 'xxx'
+ */
 char* th_get_cookie(sip_msg_t *msg, int *clen)
 {
 	hdr_field_t *hf;

+ 13 - 2
modules/topoh/topoh_mod.c

@@ -401,13 +401,24 @@ int th_msg_sent(void *data)
 	{
 		direction = (th_cookie_value.s[0]=='u')?1:0; /* upstream/downstram */
 		dialog = (get_to(&msg)->tag_value.len>0)?1:0;
-		local = (th_cookie_value.s[0]!='d'&&th_cookie_value.s[0]!='u')?1:0;
+
+		if(msg.via2==0) {
+			local = 1;
+			if(direction==0 && th_cookie_value.s[1]=='l') {
+				/* downstream local request (e.g., dlg bye) */
+				local = 2;
+			}
+		} else {
+			/* more than one Via, but no received th cookie */
+			local = (th_cookie_value.s[0]!='d' && th_cookie_value.s[0]!='u')?1:0;
+		}
 		/* local generated requests */
 		if(local)
 		{
 			/* ACK and CANCEL go downstream */
 			if(get_cseq(&msg)->method_id==METHOD_ACK
-					|| get_cseq(&msg)->method_id==METHOD_CANCEL)
+					|| get_cseq(&msg)->method_id==METHOD_CANCEL
+					|| local==2)
 			{
 				th_mask_callid(&msg);
 				goto ready;