Browse code

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 authored on 09/12/2005 18:33:58
Showing 2 changed files
... ...
@@ -72,6 +72,8 @@
72 72
  *  2004-02-11  FIFO/CANCEL + alignments (hash=f(callid,cseq)) (uli+jiri)
73 73
  *  2004-02-18  t_reply exported via FIFO - imported from VM (bogdan)
74 74
  *  2004-10-01  added a new param.: restart_fr_on_each_reply (andrei)
75
+ *  2005-12-09  fixup_hostport2proxy uses route_struct to access param #1
76
+ *              when fixing param #2
75 77
  */
76 78
 
77 79
 
... ...
@@ -91,6 +93,7 @@
91 91
 #include "../../usr_avp.h"
92 92
 #include "../../mem/mem.h"
93 93
 #include "../../unixsock_server.h"
94
+#include "../../route_struct.h"
94 95
 
95 96
 #include "sip_msg.h"
96 97
 #include "h_table.h"
... ...
@@ -312,7 +315,7 @@ static int fixup_hostport2proxy(void** param, int param_no)
312 312
 	if (param_no==1){
313 313
 		return 0;
314 314
 	} else if (param_no==2) {
315
-		host=(char *) (*(param-1)); 
315
+		host=((action_u_t*)(param)-1)->string;
316 316
 		port=str2s(*param, strlen(*param), &err);
317 317
 		if (err!=0) {
318 318
 			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)
329 329
 		}
330 330
 		/* success -- fix the first parameter to proxy now ! */
331 331
 
332
-		*(param-1)=proxy;
332
+		((action_u_t*)(param)-1)->data=proxy;
333 333
 		return 0;
334 334
 	} else {
335 335
 		LOG(L_ERR,"ERROR: fixup_hostport2proxy called with parameter #<>{1,2}\n");
... ...
@@ -109,19 +109,20 @@ struct expr{
109 109
 	union exp_op r;
110 110
 };
111 111
 
112
+typedef union {
113
+	long number;
114
+	char* string;
115
+	str str;
116
+	void* data;
117
+	avp_spec_t* attr;
118
+} action_u_t;
112 119
 
113 120
 struct action{
114 121
 	int type;  /* forward, drop, log, send ...*/
115 122
 	int p1_type;
116 123
 	int p2_type;
117 124
 	int p3_type;
118
-	union {
119
-		long number;
120
-		char* string;
121
-		str str;
122
-		void* data;
123
-		avp_spec_t* attr;
124
-	}p1, p2, p3;
125
+	action_u_t p1, p2, p3; /* tm module expects these parameters to be adjacent */
125 126
 	struct action* next;
126 127
 };
127 128