Pārlūkot izejas kodu

pv: new variables - $RAu and $RAut

- $RAu - URI format for local socket where the SIP message was received,
  without trasport parameter for UDP, using the advertised address if available
- $RAut - URI format for local socket where the SIP message was received,
  always with transport parameter, using the advertised address if available
Daniel-Constantin Mierla 8 gadi atpakaļ
vecāks
revīzija
e1df92080a
3 mainītis faili ar 69 papildinājumiem un 1 dzēšanām
  1. 6 0
      src/modules/pv/pv.c
  2. 57 1
      src/modules/pv/pv_core.c
  3. 6 0
      src/modules/pv/pv_core.h

+ 6 - 0
src/modules/pv/pv.c

@@ -387,6 +387,12 @@ static pv_export_t mod_pvs[] = {
 	{{"RAp", (sizeof("RAp")-1)}, /* */
 		PVT_OTHER, pv_get_rcv_advertised_port, 0,
 		0, 0, 0, 0},
+	{{"RAu", (sizeof("RAu")-1)}, /* */
+		PVT_OTHER, pv_get_rcvadv_uri, 0,
+		0, 0, 0, 0},
+	{{"RAut", (sizeof("RAut")-1)}, /* */
+		PVT_OTHER, pv_get_rcvadv_uri_full, 0,
+		0, 0, 0, 0},
 	{{"sf", (sizeof("sf")-1)}, /* */
 		PVT_OTHER, pv_get_sflags, pv_set_sflags,
 		0, 0, 0, 0},

+ 57 - 1
src/modules/pv/pv_core.c

@@ -760,7 +760,7 @@ int pv_get_rcvaddr_uri_helper(struct sip_msg *msg, pv_param_t *param,
 	if(msg==NULL)
 		return -1;
 
-	if(get_rcv_socket_uri(msg, tmode, &uri)<0)
+	if(get_rcv_socket_uri(msg, tmode, &uri, 0)<0)
 		return pv_get_null(msg, param, res);
 
 	if (uri.len + 1 >= pv_get_buffer_size())
@@ -820,6 +820,62 @@ int pv_get_rcv_advertised_port(struct sip_msg *msg, pv_param_t *param,
 	return pv_get_rcvport(msg, param, res);
 }
 
+int pv_get_rcvadv_uri_helper(struct sip_msg *msg, pv_param_t *param,
+		int tmode, pv_value_t *res)
+{
+	str uri;
+	str sr;
+
+	if(msg==NULL)
+		return -1;
+
+	if(get_rcv_socket_uri(msg, tmode, &uri, 1)<0)
+		return pv_get_null(msg, param, res);
+
+	if (uri.len + 1 >= pv_get_buffer_size())
+	{
+		LM_ERR("local buffer size exceeded\n");
+		return pv_get_null(msg, param, res);
+	}
+
+	sr.s = pv_get_buffer();
+	strncpy(sr.s, uri.s, uri.len);
+	sr.len = uri.len;
+	sr.s[sr.len] = '\0';
+
+	return pv_get_strval(msg, param, res, &sr);
+}
+
+int pv_get_rcvadv_uri(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res)
+{
+	if(msg==NULL)
+		return -1;
+
+	if(msg->rcv.bind_address!=NULL
+			&& (msg->rcv.bind_address->useinfo.address_str.len > 0
+				|| msg->rcv.bind_address->useinfo.port_no_str.len > 0)) {
+		return pv_get_rcvadv_uri_helper(msg, param, 0, res);
+	}
+
+	return pv_get_rcvaddr_uri_helper(msg, param, 0, res);
+}
+
+int pv_get_rcvadv_uri_full(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res)
+{
+	if(msg==NULL)
+		return -1;
+
+	if(msg->rcv.bind_address!=NULL
+			&& (msg->rcv.bind_address->useinfo.address_str.len > 0
+				|| msg->rcv.bind_address->useinfo.port_no_str.len > 0)) {
+		return pv_get_rcvadv_uri_helper(msg, param, 1, res);
+	}
+
+	return pv_get_rcvaddr_uri_helper(msg, param, 1, res);
+}
+
 /**
  *
  */

+ 6 - 0
src/modules/pv/pv_core.h

@@ -157,6 +157,12 @@ int pv_get_rcv_advertised_ip(struct sip_msg *msg, pv_param_t *param,
 int pv_get_rcv_advertised_port(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res);
 
+int pv_get_rcvadv_uri(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res);
+
+int pv_get_rcvadv_uri_full(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res);
+
 int pv_get_force_sock(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res);