Browse code

params retrieving extended to @msg.<HEADER>.params.<PARAM_NAME> for header which's value allows param like name=body @msg.<HEADER>.nameaddr.params[.<PARAM_NAME>] parameter of the header which has nameadde as value @msg.<HEADER>.nameaddr.uri.params[.<PARAM_NAME>] parameter of the URI which works for all selects returning uri

Michal Matyska authored on 30/06/2006 15:03:54
Showing 2 changed files
... ...
@@ -524,7 +524,7 @@ int select_anyheader(str* res, select_t* s, struct sip_msg* msg)
524 524
 	hf0 = NULL;
525 525
 
526 526
 	/* extract header index if present */
527
-	if (s->n == 3) {
527
+	if (s->param_offset[s->lvl+1] == 3) {
528 528
 		if (s->params[2].type == SEL_PARAM_INT) {
529 529
 			hi = s->params[2].v.i;
530 530
 		} else {
... ...
@@ -558,6 +558,7 @@ int select_anyheader(str* res, select_t* s, struct sip_msg* msg)
558 558
 	return 0;
559 559
 }
560 560
 
561
+ABSTRACT_F(select_anyheader_params)
561 562
 ABSTRACT_F(select_any_uri)
562 563
 
563 564
 static struct sip_uri uri;
... ...
@@ -655,6 +656,22 @@ int select_uri_hostport(str* res, select_t* s, struct sip_msg* msg)
655 656
 }
656 657
 
657 658
 int select_uri_params(str* res, select_t* s, struct sip_msg* msg)
659
+{
660
+	if (!msg || !res) {
661
+		return select_any_params(res, s, msg);
662
+	}
663
+
664
+	if (parse_uri(res->s, res->len, &uri)<0)
665
+		return -1;
666
+	
667
+	if (s->param_offset[s->lvl+1]-s->param_offset[s->lvl]==1)
668
+		RETURN0_res(uri.params);
669
+
670
+	*res=uri.params;
671
+	return select_any_params(res, s, msg);
672
+}
673
+
674
+int select_any_params(str* res, select_t* s, struct sip_msg* msg)
658 675
 {
659 676
 	param_hooks_t h;
660 677
 	param_t *p, *list=NULL;
... ...
@@ -671,17 +688,11 @@ int select_uri_params(str* res, select_t* s, struct sip_msg* msg)
671 688
 		return 0;
672 689
 	}
673 690
 	
674
-	if (parse_uri(res->s, res->len, &uri)<0)
675
-		return -1;
676
-	
677
-	if (s->param_offset[s->lvl+1]-s->param_offset[s->lvl]==1)
678
-		RETURN0_res(uri.params);
679
-
680 691
 	if (s->params[s->param_offset[s->lvl]+1].type!=SEL_PARAM_STR) return -1;
681 692
 	wanted=&s->params[s->param_offset[s->lvl]+1].v.s;
682 693
 	
683
-	if (!uri.params.len) return -1;
684
-	if (parse_params(&uri.params, CLASS_ANY, &h, &list)<0) return -1;
694
+	if (!res->len) return -1;
695
+	if (parse_params(res, CLASS_ANY, &h, &list)<0) return -1;
685 696
 	
686 697
 	for (p = list; p; p=p->next) {
687 698
 		if ((p->name.len==wanted->len) && 
... ...
@@ -973,3 +984,35 @@ int select_nameaddr_uri(str* res, select_t* s, struct sip_msg* msg)
973 984
 	res->len=p-res->s;
974 985
 	return 0;
975 986
 }
987
+
988
+int select_nameaddr_params(str* res, select_t* s, struct sip_msg* msg)
989
+{
990
+	char *p;
991
+	
992
+	p=find_not_quoted(res, '<');
993
+	if (!p) {
994
+		p=find_not_quoted(res, ';');
995
+	} else {
996
+		res->len=res->len - (p-res->s) -1;
997
+		res->s=p +1;
998
+		p=find_not_quoted(res, '>');
999
+		if (!p) {
1000
+			ERR("select_nameaddr_params: no > found, invalid nameaddr value\n");
1001
+			return -1;
1002
+		}
1003
+		res->len=res->len - (p-res->s) -1;
1004
+		res->s=p +1;
1005
+		
1006
+		p=find_not_quoted(res, ';');
1007
+	}
1008
+	if (!p) return 1;
1009
+	
1010
+	res->len=res->len - (p-res->s) -1;
1011
+	res->s=p +1;
1012
+	
1013
+	if (s->param_offset[s->lvl+1]-s->param_offset[s->lvl]==1)
1014
+		return (res->len ? 0 : 1);
1015
+
1016
+	return select_any_params(res, s, msg);
1017
+}
1018
+
... ...
@@ -90,10 +90,13 @@ SELECT_F(select_via_params_spec)
90 90
 
91 91
 SELECT_F(select_msgheader)
92 92
 SELECT_F(select_anyheader)
93
+SELECT_F(select_anyheader_params)
93 94
 
94 95
 SELECT_F(select_any_nameaddr)
95 96
 SELECT_F(select_nameaddr_name)
96 97
 SELECT_F(select_nameaddr_uri)
98
+SELECT_F(select_nameaddr_params)
99
+SELECT_F(select_any_params)
97 100
 	
98 101
 SELECT_F(select_any_uri)
99 102
 SELECT_F(select_uri_type)
... ...
@@ -187,10 +190,15 @@ static select_row_t select_core[] = {
187 190
 
188 191
 	{ select_any_nameaddr, SEL_PARAM_STR, STR_STATIC_INIT("name"), select_nameaddr_name, 0},
189 192
 	{ select_any_nameaddr, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_nameaddr_uri, 0},
193
+	{ select_any_nameaddr, SEL_PARAM_STR, STR_STATIC_INIT("params"), select_nameaddr_params, 0},
190 194
 	{ select_nameaddr_uri, SEL_PARAM_INT, STR_NULL, select_any_uri, NESTED},
195
+	{ select_nameaddr_params, SEL_PARAM_STR, STR_NULL, select_any_params, 0},
191 196
 
192 197
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("msg"), select_msgheader, SEL_PARAM_EXPECTED},
193 198
 	{ select_msgheader, SEL_PARAM_STR, STR_NULL, select_anyheader, OPTIONAL | CONSUME_NEXT_INT | FIXUP_CALL},
199
+	{ select_anyheader, SEL_PARAM_STR, STR_STATIC_INIT("nameaddr"), select_any_nameaddr, NESTED | CONSUME_NEXT_STR},
200
+	{ select_anyheader, SEL_PARAM_STR, STR_STATIC_INIT("params"), select_anyheader_params, NESTED},
201
+	{ select_anyheader_params, SEL_PARAM_STR, STR_STATIC_INIT("params"), select_any_params, CONSUME_NEXT_STR},
194 202
 
195 203
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("proxy_authorization"), select_auth, CONSUME_NEXT_STR | DIVERSION | SEL_AUTH_PROXY},
196 204
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("authorization"), select_auth, CONSUME_NEXT_STR | DIVERSION | SEL_AUTH_WWW}, 
... ...
@@ -207,7 +215,6 @@ static select_row_t select_core[] = {
207 215
 	{ select_auth_username, SEL_PARAM_STR, STR_STATIC_INIT("user"), select_auth_username_comp, DIVERSION | SEL_AUTH_USER},
208 216
 	{ select_auth_username, SEL_PARAM_STR, STR_STATIC_INIT("domain"), select_auth_username_comp, DIVERSION | SEL_AUTH_DOMAIN},
209 217
 
210
-	{ select_anyheader, SEL_PARAM_STR, STR_STATIC_INIT("nameaddr"), select_any_nameaddr, NESTED | CONSUME_NEXT_STR},
211 218
 	{ NULL, SEL_PARAM_INT, STR_NULL, NULL, 0}
212 219
 };
213 220