Browse Source

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

Michal Matyska 19 years ago
parent
commit
04023b50d0
2 changed files with 13 additions and 12 deletions
  1. 10 12
      select_core.c
  2. 3 0
      select_core.h

+ 10 - 12
select_core.c

@@ -53,6 +53,14 @@
 #define TEST_RET_res_body(x) if (x){*res=x->body;return 0;}else return 1;
 #define TEST_RET_res_value(x) if (x){*res=x->value;return 0;}else return 1;
 
+int select_ruri(str* res, select_t* s, struct sip_msg* msg)
+{
+	if (msg->first_line.type==SIP_REQUEST) {
+		RETURN0_res(msg->first_line.u.request.uri);
+	}
+	return 1;
+}
+
 int select_from(str* res, select_t* s, struct sip_msg* msg)
 {
 	if (parse_from_header(msg)<0)
@@ -536,10 +544,10 @@ int select_anyheader(str* res, select_t* s, struct sip_msg* msg)
 
 ABSTRACT_F(select_any_uri)
 
+static struct sip_uri uri;
+
 int select_uri_type(str* res, select_t* s, struct sip_msg* msg)
 {
-	struct sip_uri uri;
-	
 	trim(res);
 	if (parse_uri(res->s, res->len, &uri)<0)
 		return -1;
@@ -561,8 +569,6 @@ int select_uri_type(str* res, select_t* s, struct sip_msg* msg)
 
 int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
 {
-	struct sip_uri uri;
-
 	if (parse_uri(res->s, res->len, &uri)<0)
 		return -1;
 
@@ -571,8 +577,6 @@ int select_uri_user(str* res, select_t* s, struct sip_msg* msg)
 
 int select_uri_pwd(str* res, select_t* s, struct sip_msg* msg)
 {
-	struct sip_uri uri;
-
 	if (parse_uri(res->s, res->len, &uri)<0)
 		return -1;
 
@@ -581,8 +585,6 @@ int select_uri_pwd(str* res, select_t* s, struct sip_msg* msg)
 
 int select_uri_host(str* res, select_t* s, struct sip_msg* msg)
 {
-	struct sip_uri uri;
-
 	if (parse_uri(res->s, res->len, &uri)<0)
 		return -1;
 
@@ -591,8 +593,6 @@ int select_uri_host(str* res, select_t* s, struct sip_msg* msg)
 
 int select_uri_port(str* res, select_t* s, struct sip_msg* msg)
 {
-	struct sip_uri uri;
-	
 	if (parse_uri(res->s, res->len, &uri)<0)
 		return -1;
 
@@ -601,8 +601,6 @@ int select_uri_port(str* res, select_t* s, struct sip_msg* msg)
 
 int select_uri_params(str* res, select_t* s, struct sip_msg* msg)
 {
-	struct sip_uri uri;
-
 	if (parse_uri(res->s, res->len, &uri)<0)
 		return -1;
 		

+ 3 - 0
select_core.h

@@ -44,6 +44,7 @@ enum {
 	SEL_PARAM_BRANCH, SEL_PARAM_RPORT, SEL_PARAM_I, SEL_PARAM_ALIAS
        };
 
+SELECT_F(select_ruri)
 SELECT_F(select_from)
 SELECT_F(select_from_uri)
 SELECT_F(select_from_tag)
@@ -92,6 +93,8 @@ SELECT_F(select_cseq_method)
 SELECT_F(select_cseq_num)
 
 static select_row_t select_core[] = {
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("ruri"), select_ruri, 0},
+	{ select_ruri, SEL_PARAM_STR, STR_NULL, select_any_uri, NESTED},
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("from"), select_from, 0},
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("f"), select_from, 0},
 	{ select_from, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_from_uri, 0},