Ver Fonte

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 há 12 anos atrás
pai
commit
3d33733f29
2 ficheiros alterados com 28 adições e 16 exclusões
  1. 4 0
      modules/uac_redirect/rd_funcs.c
  2. 24 16
      modules/uac_redirect/redirect.c

+ 4 - 0
modules/uac_redirect/rd_funcs.c

@@ -57,6 +57,7 @@ int get_redirect( struct sip_msg *msg , int maxt, int maxb,
 	int n;
 	int i;
 	int first_branch;
+	char code_buf[INT2STR_MAX_LEN];
 
 	/* get transaction */
 	t = rd_tmb.t_gett();
@@ -95,6 +96,9 @@ int get_redirect( struct sip_msg *msg , int maxt, int maxb,
 		}
 		if (max==0)
 			continue;
+		/* put the response code into the acc_param reason struct */
+		reason->code = t->uac[i].last_received;
+		reason->code_s.s = int2bstr((unsigned long)reason->code, code_buf, &reason->code_s.len);
 		/* get the contact from it */
 		n = shmcontact2dset( msg, t->uac[i].reply, max, reason, bflags);
 		if ( n<0 ) {

+ 24 - 16
modules/uac_redirect/redirect.c

@@ -164,25 +164,24 @@ static int get_redirect_fixup(void** param, int param_no)
 
 		pkg_free(*param);
 		*param=(void*)(long)( (((unsigned short)maxt)<<8) | maxb);
-
 	} else if (param_no==2) {
 		/* acc function loaded? */
-		if (rd_acc_fct!=0)
-			return 0;
-		/* must import the acc stuff */
-		if (acc_fct_s==0 || acc_fct_s[0]==0) {
-			LM_ERR("acc support enabled, but no acc function defined\n");
-			return E_UNSPEC;
-		}
-		fct = find_export(acc_fct_s, 2, REQUEST_ROUTE);
-		if ( fct==0 )
-			fct = find_export(acc_fct_s, 1, REQUEST_ROUTE);
-		if ( fct==0 ) {
-			LM_ERR("cannot import %s function; is acc loaded and proper "
-				"compiled?\n", acc_fct_s);
-			return E_UNSPEC;
+		if (rd_acc_fct==0) {
+			/* must import the acc stuff */
+			if (acc_fct_s==0 || acc_fct_s[0]==0) {
+				LM_ERR("acc support enabled, but no acc function defined\n");
+				return E_UNSPEC;
+			}
+			fct = find_export(acc_fct_s, 2, REQUEST_ROUTE);
+			if ( fct==0 )
+				fct = find_export(acc_fct_s, 1, REQUEST_ROUTE);
+			if ( fct==0 ) {
+				LM_ERR("cannot import %s function; is acc loaded and proper "
+					"compiled?\n", acc_fct_s);
+				return E_UNSPEC;
+			}
+			rd_acc_fct = fct;
 		}
-		rd_acc_fct = fct;
 		/* set the reason str */
 		accp = (struct acc_param*)pkg_malloc(sizeof(struct acc_param));
 		if (accp==0) {
@@ -264,6 +263,7 @@ static int regexp_compile(char *re_s, regex_t **re)
 static int redirect_init(void)
 {
 	regex_t *filter;
+	void *p;
 
 	/* load the TM API */
 	if (load_tm_api(&rd_tmb)!=0) {
@@ -271,6 +271,14 @@ static int redirect_init(void)
 		goto error;
 	}
 
+	p = (void*)acc_db_table;
+	/* fixup table name */
+	if(fixup_var_pve_str_12(&p, 1)<0) {
+		LM_ERR("failed to fixup acc db table\n");
+		goto error;
+	}
+	acc_db_table = p;
+
 	/* init filter */
 	init_filters();