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 536
 
537 537
 ABSTRACT_F(select_any_uri)
538 538
 
539
+static struct sip_uri uri;
540
+
539 541
 int select_uri_type(str* res, select_t* s, struct sip_msg* msg)
540 542
 {
541
-	struct sip_uri uri;
542
-	
543 543
 	trim(res);
544 544
 	if (parse_uri(res->s, res->len, &uri)<0)
545 545
 		return -1;
... ...
@@ -561,8 +569,6 @@ int select_uri_type(str* res, select_t* s, struct sip_msg* msg)
561 561
 
562 562
 int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
563 563
 {
564
-	struct sip_uri uri;
565
-
566 564
 	if (parse_uri(res->s, res->len, &uri)<0)
567 565
 		return -1;
568 566
 
... ...
@@ -571,8 +577,6 @@ int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
571 571
 
572 572
 int select_uri_pwd(str* res, select_t* s, struct sip_msg* msg)
573 573
 {
574
-	struct sip_uri uri;
575
-
576 574
 	if (parse_uri(res->s, res->len, &uri)<0)
577 575
 		return -1;
578 576
 
... ...
@@ -581,8 +585,6 @@ int select_uri_pwd(str* res, select_t* s, struct sip_msg* msg)
581 581
 
582 582
 int select_uri_host(str* res, select_t* s, struct sip_msg* msg)
583 583
 {
584
-	struct sip_uri uri;
585
-
586 584
 	if (parse_uri(res->s, res->len, &uri)<0)
587 585
 		return -1;
588 586
 
... ...
@@ -591,8 +593,6 @@ int select_uri_host(str* res, select_t* s, struct sip_msg* msg)
591 591
 
592 592
 int select_uri_port(str* res, select_t* s, struct sip_msg* msg)
593 593
 {
594
-	struct sip_uri uri;
595
-	
596 594
 	if (parse_uri(res->s, res->len, &uri)<0)
597 595
 		return -1;
598 596
 
... ...
@@ -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 92
 SELECT_F(select_cseq_num)
93 93
 
94 94
 static select_row_t select_core[] = {
95
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("ruri"), select_ruri, 0},
96
+	{ select_ruri, SEL_PARAM_STR, STR_NULL, select_any_uri, NESTED},
95 97
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("from"), select_from, 0},
96 98
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("f"), select_from, 0},
97 99
 	{ select_from, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_from_uri, 0},