Browse code

uac_redirect: fixup for using acc table parameter

- set reason parameter for acc function
- based on a patch by Federico Cabiddu, FS#327

Daniel-Constantin Mierla authored on 26/07/2013 12:52:21
Showing 2 changed files
... ...
@@ -57,6 +57,7 @@ int get_redirect( struct sip_msg *msg , int maxt, int maxb,
57 57
 	int n;
58 58
 	int i;
59 59
 	int first_branch;
60
+	char code_buf[INT2STR_MAX_LEN];
60 61
 
61 62
 	/* get transaction */
62 63
 	t = rd_tmb.t_gett();
... ...
@@ -95,6 +96,9 @@ int get_redirect( struct sip_msg *msg , int maxt, int maxb,
95 96
 		}
96 97
 		if (max==0)
97 98
 			continue;
99
+		/* put the response code into the acc_param reason struct */
100
+		reason->code = t->uac[i].last_received;
101
+		reason->code_s.s = int2bstr((unsigned long)reason->code, code_buf, &reason->code_s.len);
98 102
 		/* get the contact from it */
99 103
 		n = shmcontact2dset( msg, t->uac[i].reply, max, reason, bflags);
100 104
 		if ( n<0 ) {
... ...
@@ -164,25 +164,24 @@ static int get_redirect_fixup(void** param, int param_no)
164 164
 
165 165
 		pkg_free(*param);
166 166
 		*param=(void*)(long)( (((unsigned short)maxt)<<8) | maxb);
167
-
168 167
 	} else if (param_no==2) {
169 168
 		/* acc function loaded? */
170
-		if (rd_acc_fct!=0)
171
-			return 0;
172
-		/* must import the acc stuff */
173
-		if (acc_fct_s==0 || acc_fct_s[0]==0) {
174
-			LM_ERR("acc support enabled, but no acc function defined\n");
175
-			return E_UNSPEC;
176
-		}
177
-		fct = find_export(acc_fct_s, 2, REQUEST_ROUTE);
178
-		if ( fct==0 )
179
-			fct = find_export(acc_fct_s, 1, REQUEST_ROUTE);
180
-		if ( fct==0 ) {
181
-			LM_ERR("cannot import %s function; is acc loaded and proper "
182
-				"compiled?\n", acc_fct_s);
183
-			return E_UNSPEC;
169
+		if (rd_acc_fct==0) {
170
+			/* must import the acc stuff */
171
+			if (acc_fct_s==0 || acc_fct_s[0]==0) {
172
+				LM_ERR("acc support enabled, but no acc function defined\n");
173
+				return E_UNSPEC;
174
+			}
175
+			fct = find_export(acc_fct_s, 2, REQUEST_ROUTE);
176
+			if ( fct==0 )
177
+				fct = find_export(acc_fct_s, 1, REQUEST_ROUTE);
178
+			if ( fct==0 ) {
179
+				LM_ERR("cannot import %s function; is acc loaded and proper "
180
+					"compiled?\n", acc_fct_s);
181
+				return E_UNSPEC;
182
+			}
183
+			rd_acc_fct = fct;
184 184
 		}
185
-		rd_acc_fct = fct;
186 185
 		/* set the reason str */
187 186
 		accp = (struct acc_param*)pkg_malloc(sizeof(struct acc_param));
188 187
 		if (accp==0) {
... ...
@@ -264,6 +263,7 @@ static int regexp_compile(char *re_s, regex_t **re)
264 263
 static int redirect_init(void)
265 264
 {
266 265
 	regex_t *filter;
266
+	void *p;
267 267
 
268 268
 	/* load the TM API */
269 269
 	if (load_tm_api(&rd_tmb)!=0) {
... ...
@@ -271,6 +271,14 @@ static int redirect_init(void)
271 271
 		goto error;
272 272
 	}
273 273
 
274
+	p = (void*)acc_db_table;
275
+	/* fixup table name */
276
+	if(fixup_var_pve_str_12(&p, 1)<0) {
277
+		LM_ERR("failed to fixup acc db table\n");
278
+		goto error;
279
+	}
280
+	acc_db_table = p;
281
+
274 282
 	/* init filter */
275 283
 	init_filters();
276 284