Bladeren bron

@dst_uri and @next_hop select calls are introduced:
- @dst_uri returns the destination uri
- @next_hop returns the dst_uri/new_uri/ruri

Miklos Tirpak 19 jaren geleden
bovenliggende
commit
eea15f4312
2 gewijzigde bestanden met toevoegingen van 29 en 0 verwijderingen
  1. 23 0
      select_core.c
  2. 6 0
      select_core.h

+ 23 - 0
select_core.c

@@ -78,6 +78,29 @@ int select_ruri(str* res, select_t* s, struct sip_msg* msg)
 	return -1;
 	return -1;
 }
 }
 
 
+int select_dst_uri(str* res, select_t* s, struct sip_msg* msg)
+{
+	if (msg->first_line.type!=SIP_REQUEST)
+		return -1;
+	RETURN0_res(msg->dst_uri);
+}
+
+int select_next_hop(str* res, select_t* s, struct sip_msg* msg)
+{
+	if (msg->first_line.type==SIP_REQUEST) {
+		if(msg->dst_uri.s) {
+			RETURN0_res(msg->dst_uri);
+		}
+		else if(msg->new_uri.s) {
+			RETURN0_res(msg->new_uri);
+		}
+		else {
+			RETURN0_res(msg->first_line.u.request.uri);
+		}
+	}
+	return -1;
+}
+
 int select_from(str* res, select_t* s, struct sip_msg* msg)
 int select_from(str* res, select_t* s, struct sip_msg* msg)
 {
 {
 	if (parse_from_header(msg)<0)
 	if (parse_from_header(msg)<0)

+ 6 - 0
select_core.h

@@ -73,6 +73,8 @@ enum {
 
 
 SELECT_F(select_method)
 SELECT_F(select_method)
 SELECT_F(select_ruri)
 SELECT_F(select_ruri)
+SELECT_F(select_dst_uri)
+SELECT_F(select_next_hop)
 SELECT_F(select_from)
 SELECT_F(select_from)
 SELECT_F(select_from_uri)
 SELECT_F(select_from_uri)
 SELECT_F(select_from_tag)
 SELECT_F(select_from_tag)
@@ -142,6 +144,10 @@ static select_row_t select_core[] = {
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("method"), select_method, 0},
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("method"), select_method, 0},
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("ruri"), select_ruri, 0},
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("ruri"), select_ruri, 0},
 	{ select_ruri, SEL_PARAM_STR, STR_NULL, select_any_uri, NESTED},
 	{ select_ruri, SEL_PARAM_STR, STR_NULL, select_any_uri, NESTED},
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("dst_uri"), select_dst_uri, 0},
+	{ select_dst_uri, SEL_PARAM_STR, STR_NULL, select_any_uri, NESTED},
+	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("next_hop"), select_next_hop, 0},
+	{ select_next_hop, 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("from"), select_from, 0},
 	{ NULL, SEL_PARAM_STR, STR_STATIC_INIT("f"), 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},
 	{ select_from, SEL_PARAM_STR, STR_STATIC_INIT("uri"), select_from_uri, 0},