Browse code

AVP track searching resolution ------------------------------ new AVP prefixes registered fu - FROM USER and tu - TO USER $avp and $f.avp now searches in from track $t.avp searches in to track

specify fu, tu, fd, td, g if you want to search in one list only

Michal Matyska authored on 15/02/2006 17:29:18
Showing 4 changed files
... ...
@@ -200,8 +200,10 @@ MINUS	"-"
200 200
 /* Attribute specification */
201 201
 ATTR_MARK   "$"|"%"
202 202
 SELECT_MARK  "@"
203
-ATTR_FROMUSER     "f"
204
-ATTR_TOUSER       "t"
203
+ATTR_FROM         "f"
204
+ATTR_TO           "t"
205
+ATTR_FROMUSER     "fu"
206
+ATTR_TOUSER       "tu"
205 207
 ATTR_FROMDOMAIN   "fd"
206 208
 ATTR_TODOMAIN     "td"
207 209
 ATTR_GLOBAL       "g"
... ...
@@ -506,6 +508,8 @@ EAT_ABLE	[\ \t\b\r]
506 506
 
507 507
 
508 508
 <INITIAL>{ATTR_MARK}    { count(); state = ATTR_S; BEGIN(ATTR); return ATTR_MARK; }
509
+<ATTR>{ATTR_FROM}       { count(); return ATTR_FROM; }
510
+<ATTR>{ATTR_TO}         { count(); return ATTR_TO; }
509 511
 <ATTR>{ATTR_FROMUSER}   { count(); return ATTR_FROMUSER; }
510 512
 <ATTR>{ATTR_TOUSER}     { count(); return ATTR_TOUSER; }
511 513
 <ATTR>{ATTR_FROMDOMAIN} { count(); return ATTR_FROMDOMAIN; }
... ...
@@ -282,6 +282,8 @@ static struct socket_id* mk_listen_id(char*, int, int);
282 282
 
283 283
 %token ATTR_MARK
284 284
 %token SELECT_MARK
285
+%token ATTR_FROM
286
+%token ATTR_TO
285 287
 %token ATTR_FROMUSER
286 288
 %token ATTR_TOUSER
287 289
 %token ATTR_FROMDOMAIN
... ...
@@ -1202,7 +1204,7 @@ exp_elem:
1202 1202
 	| exp_stm	{ $$=mk_elem( NO_OP, ACTION_O, 0, ACTIONS_ST, $1);  }
1203 1203
 	| NUMBER	{ $$=mk_elem( NO_OP, NUMBER_O, 0, NUMBER_ST, (void*)$1 ); }
1204 1204
 
1205
-	| attr_id_val			{$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
1205
+	| attr_id_any				{$$=mk_elem( NO_OP, AVP_O, (void*)$1, 0, 0); }
1206 1206
 	| attr_id_val strop STRING	{$$=mk_elem( $2, AVP_O, (void*)$1, STRING_ST, $3); }
1207 1207
 	| attr_id_val strop select_id	{$$=mk_elem( $2, AVP_O, (void*)$1, SELECT_ST, $3); }
1208 1208
 	| attr_id_val intop NUMBER	{$$=mk_elem( $2, AVP_O, (void*)$1, NUMBER_ST, (void*)$3); }
... ...
@@ -1348,7 +1350,9 @@ select_id:
1348 1348
 	}
1349 1349
 	;
1350 1350
 attr_class_spec:
1351
-	ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
1351
+	ATTR_FROM { s_attr->type |= AVP_TRACK_FROM; }
1352
+	| ATTR_TO { s_attr->type |= AVP_TRACK_TO; }
1353
+	| ATTR_FROMUSER { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_USER; }
1352 1354
 	| ATTR_TOUSER { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_USER; }
1353 1355
 	| ATTR_FROMDOMAIN { s_attr->type |= AVP_TRACK_FROM | AVP_CLASS_DOMAIN; }
1354 1356
 	| ATTR_TODOMAIN { s_attr->type |= AVP_TRACK_TO | AVP_CLASS_DOMAIN; }
... ...
@@ -713,6 +713,10 @@ inline static int comp_avp(int op, avp_spec_t* spec, int rtype, union exp_op* r,
713 713
 	avp_t* avp;
714 714
 	int_str val;
715 715
 
716
+	if (spec->type & AVP_INDEX_ALL) {
717
+		avp = search_first_avp(spec->type & ~AVP_INDEX_ALL, spec->name, NULL, NULL);
718
+		return (avp!=0);
719
+	}
716 720
 	avp = search_avp_by_index(spec->type, spec->name, &val, spec->index);
717 721
 	if (!avp) return 0;
718 722
 
... ...
@@ -417,12 +417,10 @@ avp_t *search_avp (avp_ident_t ident, avp_value_t* val, struct search_state* sta
417 417
 		ident.flags |= AVP_CLASS_ALL;
418 418
 		
419 419
 		if ((ident.flags & AVP_TRACK_ALL) == 0) {
420
-		    /* The caller did not specify even the track to search in, so try
421
-		     * track_from first, and if not found try track_to
420
+		    /* The caller did not specify even the track to search in, so search
421
+		     * in the track_from
422 422
 		     */
423
-		     	ident.flags |= AVP_TRACK_FROM;
424
-		     	if ((ret = search_avp(ident, val, state))) return ret;
425
-		     	ident.flags = (ident.flags & ~AVP_TRACK_ALL) | AVP_TRACK_TO;
423
+			ident.flags |= AVP_TRACK_FROM;
426 424
 		}
427 425
 	}
428 426
 
... ...
@@ -837,15 +835,21 @@ int parse_avp_ident( str *name, avp_ident_t* attr)
837 837
 		}
838 838
 		switch (id) {
839 839
 			case 'f':
840
-				attr->flags = AVP_TRACK_FROM | AVP_CLASS_USER;
840
+				attr->flags = AVP_TRACK_FROM;
841 841
 				break;
842 842
 			case 't':
843
+				attr->flags = AVP_TRACK_TO;
844
+				break;
845
+			case 0x6675: /* 'fu' */
846
+				attr->flags = AVP_TRACK_FROM | AVP_CLASS_USER;
847
+				break;
848
+			case 0x7475: /* 'tu' */
843 849
 				attr->flags = AVP_TRACK_TO | AVP_CLASS_USER;
844 850
 				break;
845
-			case 0x6664: //'fd'
851
+			case 0x6664: /* 'fd' */
846 852
 				attr->flags = AVP_TRACK_FROM | AVP_CLASS_DOMAIN;
847 853
 				break;
848
-			case 0x7464: // 'td'
854
+			case 0x7464: /* 'td' */
849 855
 				attr->flags = AVP_TRACK_TO | AVP_CLASS_DOMAIN;
850 856
 				break;
851 857
 			case 'g':