瀏覽代碼

Let tm module be relatively independent on the route action internal structure (resp. its data size).
When accessing param #1 while fixing param #2 in the fixup_hostport2proxy function
use correct type for pointer arithemtics.

Michal Matyska 20 年之前
父節點
當前提交
24c9352297
共有 2 個文件被更改,包括 13 次插入9 次删除
  1. 5 2
      modules/tm/tm.c
  2. 8 7
      route_struct.h

+ 5 - 2
modules/tm/tm.c

@@ -72,6 +72,8 @@
  *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
  *  2004-02-18  t_reply exported via FIFO - imported from VM (bogdan)
  *  2004-10-01  added a new param.: restart_fr_on_each_reply (andrei)
+ *  2005-12-09  fixup_hostport2proxy uses route_struct to access param #1
+ *              when fixing param #2
  */
 
 
@@ -91,6 +93,7 @@
 #include "../../usr_avp.h"
 #include "../../mem/mem.h"
 #include "../../unixsock_server.h"
+#include "../../route_struct.h"
 
 #include "sip_msg.h"
 #include "h_table.h"
@@ -312,7 +315,7 @@ static int fixup_hostport2proxy(void** param, int param_no)
 	if (param_no==1){
 		return 0;
 	} else if (param_no==2) {
-		host=(char *) (*(param-1)); 
+		host=((action_u_t*)(param)-1)->string;
 		port=str2s(*param, strlen(*param), &err);
 		if (err!=0) {
 			LOG(L_ERR, "TM module:fixup_hostport2proxy: bad port number <%s>\n",
@@ -329,7 +332,7 @@ static int fixup_hostport2proxy(void** param, int param_no)
 		}
 		/* success -- fix the first parameter to proxy now ! */
 
-		*(param-1)=proxy;
+		((action_u_t*)(param)-1)->data=proxy;
 		return 0;
 	} else {
 		LOG(L_ERR,"ERROR: fixup_hostport2proxy called with parameter #<>{1,2}\n");

+ 8 - 7
route_struct.h

@@ -109,19 +109,20 @@ struct expr{
 	union exp_op r;
 };
 
+typedef union {
+	long number;
+	char* string;
+	str str;
+	void* data;
+	avp_spec_t* attr;
+} action_u_t;
 
 struct action{
 	int type;  /* forward, drop, log, send ...*/
 	int p1_type;
 	int p2_type;
 	int p3_type;
-	union {
-		long number;
-		char* string;
-		str str;
-		void* data;
-		avp_spec_t* attr;
-	}p1, p2, p3;
+	action_u_t p1, p2, p3; /* tm module expects these parameters to be adjacent */
 	struct action* next;
 };