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;
... ...
@@ -656,6 +657,22 @@ int select_uri_hostport(str* res, select_t* s, struct sip_msg* msg)
656 656
 
657 657
 int select_uri_params(str* res, select_t* s, struct sip_msg* msg)
658 658
 {
659
+	if (!msg || !res) {
660
+		return select_any_params(res, s, msg);
661
+	}
662
+
663
+	if (parse_uri(res->s, res->len, &uri)<0)
664
+		return -1;
665
+	
666
+	if (s->param_offset[s->lvl+1]-s->param_offset[s->lvl]==1)
667
+		RETURN0_res(uri.params);
668
+
669
+	*res=uri.params;
670
+	return select_any_params(res, s, msg);
671
+}
672
+
673
+int select_any_params(str* res, select_t* s, struct sip_msg* msg)
674
+{
659 675
 	param_hooks_t h;
660 676
 	param_t *p, *list=NULL;
661 677
 	str* wanted;
... ...
@@ -671,17 +688,11 @@ int select_uri_params(str* res, select_t* s, struct sip_msg* msg)
671 671
 		return 0;
672 672
 	}
673 673
 	
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 674
 	if (s->params[s->param_offset[s->lvl]+1].type!=SEL_PARAM_STR) return -1;
681 675
 	wanted=&s->params[s->param_offset[s->lvl]+1].v.s;
682 676
 	
683
-	if (!uri.params.len) return -1;
684
-	if (parse_params(&uri.params, CLASS_ANY, &h, &list)<0) return -1;
677
+	if (!res->len) return -1;
678
+	if (parse_params(res, CLASS_ANY, &h, &list)<0) return -1;
685 679
 	
686 680
 	for (p = list; p; p=p->next) {
687 681
 		if ((p->name.len==wanted->len) && 
... ...
@@ -973,3 +984,35 @@ int select_nameaddr_uri(str* res, select_t* s, struct sip_msg* msg)
973 973
 	res->len=p-res->s;
974 974
 	return 0;
975 975
 }
976
+
977
+int select_nameaddr_params(str* res, select_t* s, struct sip_msg* msg)
978
+{
979
+	char *p;
980
+	
981
+	p=find_not_quoted(res, '<');
982
+	if (!p) {
983
+		p=find_not_quoted(res, ';');
984
+	} else {
985
+		res->len=res->len - (p-res->s) -1;
986
+		res->s=p +1;
987
+		p=find_not_quoted(res, '>');
988
+		if (!p) {
989
+			ERR("select_nameaddr_params: no > found, invalid nameaddr value\n");
990
+			return -1;
991
+		}
992
+		res->len=res->len - (p-res->s) -1;
993
+		res->s=p +1;
994
+		
995
+		p=find_not_quoted(res, ';');
996
+	}
997
+	if (!p) return 1;
998
+	
999
+	res->len=res->len - (p-res->s) -1;
1000
+	res->s=p +1;
1001
+	
1002
+	if (s->param_offset[s->lvl+1]-s->param_offset[s->lvl]==1)
1003
+		return (res->len ? 0 : 1);
1004
+
1005
+	return select_any_params(res, s, msg);
1006
+}
1007
+
... ...
@@ -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 187
 
188 188
 	{ select_any_nameaddr, SEL_PARAM_STR, STR_STATIC_INIT("name"), select_nameaddr_name, 0},
189 189
 	{ select_any_nameaddr, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_nameaddr_uri, 0},
190
+	{ select_any_nameaddr, SEL_PARAM_STR, STR_STATIC_INIT("params"), select_nameaddr_params, 0},
190 191
 	{ select_nameaddr_uri, SEL_PARAM_INT, STR_NULL, select_any_uri, NESTED},
192
+	{ select_nameaddr_params, SEL_PARAM_STR, STR_NULL, select_any_params, 0},
191 193
 
192 194
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("msg"), select_msgheader, SEL_PARAM_EXPECTED},
193 195
 	{ select_msgheader, SEL_PARAM_STR, STR_NULL, select_anyheader, OPTIONAL | CONSUME_NEXT_INT | FIXUP_CALL},
196
+	{ select_anyheader, SEL_PARAM_STR, STR_STATIC_INIT("nameaddr"), select_any_nameaddr, NESTED | CONSUME_NEXT_STR},
197
+	{ select_anyheader, SEL_PARAM_STR, STR_STATIC_INIT("params"), select_anyheader_params, NESTED},
198
+	{ select_anyheader_params, SEL_PARAM_STR, STR_STATIC_INIT("params"), select_any_params, CONSUME_NEXT_STR},
194 199
 
195 200
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("proxy_authorization"), select_auth, CONSUME_NEXT_STR | DIVERSION | SEL_AUTH_PROXY},
196 201
 	{ 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 207
 	{ select_auth_username, SEL_PARAM_STR, STR_STATIC_INIT("user"), select_auth_username_comp, DIVERSION | SEL_AUTH_USER},
208 208
 	{ select_auth_username, SEL_PARAM_STR, STR_STATIC_INIT("domain"), select_auth_username_comp, DIVERSION | SEL_AUTH_DOMAIN},
209 209
 
210
-	{ select_anyheader, SEL_PARAM_STR, STR_STATIC_INIT("nameaddr"), select_any_nameaddr, NESTED | CONSUME_NEXT_STR},
211 210
 	{ NULL, SEL_PARAM_INT, STR_NULL, NULL, 0}
212 211
 };
213 212