Browse code

Core select R-URI splitting into parts introduced: @ruri.(type|user|host|port)

Michal Matyska authored on 21/03/2006 00:54:40
Showing 2 changed files
... ...
@@ -53,6 +53,14 @@
53 53
 #define TEST_RET_res_body(x) if (x){*res=x->body;return 0;}else return 1;
54 54
 #define TEST_RET_res_value(x) if (x){*res=x->value;return 0;}else return 1;
55 55
 
56
+int select_ruri(str* res, select_t* s, struct sip_msg* msg)
57
+{
58
+	if (msg->first_line.type==SIP_REQUEST) {
59
+		RETURN0_res(msg->first_line.u.request.uri);
60
+	}
61
+	return 1;
62
+}
63
+
56 64
 int select_from(str* res, select_t* s, struct sip_msg* msg)
57 65
 {
58 66
 	if (parse_from_header(msg)<0)
... ...
@@ -536,10 +544,10 @@ int select_anyheader(str* res, select_t* s, struct sip_msg* msg)
536 544
 
537 545
 ABSTRACT_F(select_any_uri)
538 546
 
547
+static struct sip_uri uri;
548
+
539 549
 int select_uri_type(str* res, select_t* s, struct sip_msg* msg)
540 550
 {
541
-	struct sip_uri uri;
542
-	
543 551
 	trim(res);
544 552
 	if (parse_uri(res->s, res->len, &uri)<0)
545 553
 		return -1;
... ...
@@ -561,8 +569,6 @@ int select_uri_type(str* res, select_t* s, struct sip_msg* msg)
561 569
 
562 570
 int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
563 571
 {
564
-	struct sip_uri uri;
565
-
566 572
 	if (parse_uri(res->s, res->len, &uri)<0)
567 573
 		return -1;
568 574
 
... ...
@@ -571,8 +577,6 @@ int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
571 577
 
572 578
 int select_uri_pwd(str* res, select_t* s, struct sip_msg* msg)
573 579
 {
574
-	struct sip_uri uri;
575
-
576 580
 	if (parse_uri(res->s, res->len, &uri)<0)
577 581
 		return -1;
578 582
 
... ...
@@ -581,8 +585,6 @@ int select_uri_pwd(str* res, select_t* s, struct sip_msg* msg)
581 585
 
582 586
 int select_uri_host(str* res, select_t* s, struct sip_msg* msg)
583 587
 {
584
-	struct sip_uri uri;
585
-
586 588
 	if (parse_uri(res->s, res->len, &uri)<0)
587 589
 		return -1;
588 590
 
... ...
@@ -591,8 +593,6 @@ int select_uri_host(str* res, select_t* s, struct sip_msg* msg)
591 593
 
592 594
 int select_uri_port(str* res, select_t* s, struct sip_msg* msg)
593 595
 {
594
-	struct sip_uri uri;
595
-	
596 596
 	if (parse_uri(res->s, res->len, &uri)<0)
597 597
 		return -1;
598 598
 
... ...
@@ -601,8 +601,6 @@ int select_uri_port(str* res, select_t* s, struct sip_msg* msg)
601 601
 
602 602
 int select_uri_params(str* res, select_t* s, struct sip_msg* msg)
603 603
 {
604
-	struct sip_uri uri;
605
-
606 604
 	if (parse_uri(res->s, res->len, &uri)<0)
607 605
 		return -1;
608 606
 		
... ...
@@ -44,6 +44,7 @@ enum {
44 44
 	SEL_PARAM_BRANCH, SEL_PARAM_RPORT, SEL_PARAM_I, SEL_PARAM_ALIAS
45 45
        };
46 46
 
47
+SELECT_F(select_ruri)
47 48
 SELECT_F(select_from)
48 49
 SELECT_F(select_from_uri)
49 50
 SELECT_F(select_from_tag)
... ...
@@ -92,6 +93,8 @@ SELECT_F(select_cseq_method)
92 93
 SELECT_F(select_cseq_num)
93 94
 
94 95
 static select_row_t select_core[] = {
96
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("ruri"), select_ruri, 0},
97
+	{ select_ruri, SEL_PARAM_STR, STR_NULL, select_any_uri, NESTED},
95 98
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("from"), select_from, 0},
96 99
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("f"), select_from, 0},
97 100
 	{ select_from, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_from_uri, 0},