Browse code

pv: added $Ras - return local received address in socket format

Daniel-Constantin Mierla authored on 17/12/2021 07:34:46
Showing 3 changed files
... ...
@@ -406,6 +406,9 @@ static pv_export_t mod_pvs[] = {
406 406
 	{{"rz", (sizeof("rz")-1)}, /* */
407 407
 		PVT_OTHER, pv_get_ruri_attr, 0,
408 408
 		0, 0, pv_init_iname, 5},
409
+	{{"Ras", (sizeof("Ras")-1)}, /* */
410
+		PVT_OTHER, pv_get_rcvaddr_socket, 0,
411
+		0, 0, 0, 0},
409 412
 	{{"Ri", (sizeof("Ri")-1)}, /* */
410 413
 		PVT_OTHER, pv_get_rcvip, 0,
411 414
 		0, 0, 0, 0},
... ...
@@ -932,6 +932,18 @@ int pv_get_rcvaddr_uri_full(struct sip_msg *msg, pv_param_t *param,
932 932
 	return pv_get_rcvaddr_uri_helper(msg, param, 1, res);
933 933
 }
934 934
 
935
+int pv_get_rcvaddr_socket(struct sip_msg *msg, pv_param_t *param,
936
+		pv_value_t *res)
937
+{
938
+	if(msg==NULL)
939
+		return -1;
940
+
941
+	if(msg->rcv.bind_address==NULL || msg->rcv.bind_address->sock_str.s==NULL) {
942
+		return pv_get_null(msg, param, res);
943
+	}
944
+	return pv_get_strval(msg, param, res, &msg->rcv.bind_address->sock_str);
945
+}
946
+
935 947
 int pv_get_rcv_advertised_ip(struct sip_msg *msg, pv_param_t *param,
936 948
 		pv_value_t *res)
937 949
 {
... ...
@@ -166,6 +166,9 @@ int pv_get_rcvaddr_uri(struct sip_msg *msg, pv_param_t *param,
166 166
 int pv_get_rcvaddr_uri_full(struct sip_msg *msg, pv_param_t *param,
167 167
 		pv_value_t *res);
168 168
 
169
+int pv_get_rcvaddr_socket(struct sip_msg *msg, pv_param_t *param,
170
+		pv_value_t *res);
171
+
169 172
 int pv_get_rcvsname(struct sip_msg *msg, pv_param_t *param,
170 173
 		pv_value_t *res);
171 174