Browse code

modules/dialplan: allow xavp vars as parameters.

Victor Seva authored on 20/06/2013 06:34:05
Showing 1 changed files
... ...
@@ -164,7 +164,9 @@ static int mod_init(void)
164 164
 		attr_pvar_s.len = strlen(attr_pvar_s.s);
165 165
 		attr_pvar = pv_cache_get(&attr_pvar_s);
166 166
 		if( (attr_pvar==NULL) ||
167
-				((attr_pvar->type != PVT_AVP) && (attr_pvar->type!=PVT_SCRIPTVAR))) {
167
+				((attr_pvar->type != PVT_AVP) &&
168
+				 (attr_pvar->type != PVT_XAVP) &&
169
+				 (attr_pvar->type!=PVT_SCRIPTVAR))) {
168 170
 			LM_ERR("invalid pvar name\n");
169 171
 			return -1;
170 172
 		}
... ...
@@ -244,7 +246,7 @@ static int dp_get_ivalue(struct sip_msg* msg, dp_param_p dp, int *val)
244 246
 
245 247
 	if( pv_get_spec_value( msg, dp->v.sp[0], &value)!=0
246 248
 			|| value.flags&(PV_VAL_NULL|PV_VAL_EMPTY) || !(value.flags&PV_VAL_INT)) {
247
-		LM_ERR("no AVP or SCRIPTVAR found (error in scripts)\n");
249
+		LM_ERR("no AVP, XAVP or SCRIPTVAR found (error in scripts)\n");
248 250
 		return -1;
249 251
 	}
250 252
 	*val = value.ri;
... ...
@@ -260,7 +262,7 @@ static int dp_get_svalue(struct sip_msg * msg, pv_spec_t *spec, str* val)
260 262
 
261 263
 	if ( pv_get_spec_value(msg,spec,&value)!=0 || value.flags&PV_VAL_NULL
262 264
 			|| value.flags&PV_VAL_EMPTY || !(value.flags&PV_VAL_STR)){
263
-		LM_ERR("no AVP or SCRIPTVAR found (error in scripts)\n");
265
+		LM_ERR("no AVP, XAVP or SCRIPTVAR found (error in scripts)\n");
264 266
 		return -1;
265 267
 	}
266 268
 
... ...
@@ -369,20 +371,22 @@ static int dp_translate_f(struct sip_msg* msg, char* str1, char* str2)
369 371
 #define verify_par_type(_par_no, _spec)\
370 372
 	do{\
371 373
 		if( ((_par_no == 1) \
372
-					&& (_spec->type != PVT_AVP) && (_spec->type!=PVT_SCRIPTVAR) )\
374
+					&& (_spec->type != PVT_AVP) && (_spec->type != PVT_XAVP) && \
375
+					(_spec->type!=PVT_SCRIPTVAR) )\
373 376
 				||((_par_no == 2) \
374
-					&& (_spec->type != PVT_AVP) && (_spec->type!=PVT_SCRIPTVAR) \
377
+					&& (_spec->type != PVT_AVP) && (_spec->type != PVT_XAVP) && \
378
+					(_spec->type!=PVT_SCRIPTVAR) \
375 379
 					&& (_spec->type!=PVT_RURI) && (_spec->type!=PVT_RURI_USERNAME))){\
376 380
 			\
377
-			LM_ERR("Unsupported Parameter TYPE\n");\
381
+			LM_ERR("Unsupported Parameter TYPE[%d]\n", _spec->type);\
378 382
 			return E_UNSPEC;\
379 383
 		}\
380 384
 	}while(0);
381 385
 
382 386
 
383
-/* first param: DPID: type: INT, AVP, SVAR
387
+/* first param: DPID: type: INT, AVP, XAVP, SVAR
384 388
  * second param: SRC type: any psedo variable type
385
- * second param: DST type: RURI, RURI_USERNAME, AVP, SVAR, N/A
389
+ * second param: DST type: RURI, RURI_USERNAME, AVP, XAVP, SVAR, N/A
386 390
  * default value for the second param: $ru.user/$ru.user
387 391
  */
388 392
 static int dp_trans_fixup(void ** param, int param_no){
... ...
@@ -392,7 +396,7 @@ static int dp_trans_fixup(void ** param, int param_no){
392 396
 	char *p, *s=NULL;
393 397
 	str lstr;
394 398
 
395
-	if(param_no!=1 && param_no!=2) 
399
+	if(param_no!=1 && param_no!=2)
396 400
 		return 0;
397 401
 
398 402
 	p = (char*)*param;