Browse code

pv: $fsp - return send socket port, or 0 if $fs not set

Daniel-Constantin Mierla authored on 05/01/2021 15:52:32
Showing 3 changed files
... ...
@@ -253,6 +253,9 @@ static pv_export_t mod_pvs[] = {
253 253
 	{{"fsn", (sizeof("fsn")-1)}, /* */
254 254
 		PVT_OTHER, pv_get_force_sock_name, pv_set_force_sock_name,
255 255
 		0, 0, 0, 0},
256
+	{{"fsp", (sizeof("fsp")-1)}, /* */
257
+		PVT_OTHER, pv_get_force_sock_port, 0,
258
+		0, 0, 0, 0},
256 259
 	{{"ft", (sizeof("ft")-1)}, /* */
257 260
 		PVT_OTHER, pv_get_from_attr, 0,
258 261
 		0, 0, pv_init_iname, 4},
... ...
@@ -1075,6 +1075,19 @@ int pv_get_force_sock_name(struct sip_msg *msg, pv_param_t *param,
1075 1075
 	return pv_get_strval(msg, param, res, &msg->force_send_socket->sockname);
1076 1076
 }
1077 1077
 
1078
+int pv_get_force_sock_port(struct sip_msg *msg, pv_param_t *param,
1079
+		pv_value_t *res)
1080
+{
1081
+	if(msg==NULL)
1082
+		return -1;
1083
+
1084
+	if (msg->force_send_socket==0)
1085
+		return pv_get_uintval(msg, param, res, 0);
1086
+
1087
+	return pv_get_intstrval(msg, param, res, (int)msg->force_send_socket->port_no,
1088
+			&msg->force_send_socket->port_no_str);
1089
+}
1090
+
1078 1091
 int pv_get_useragent(struct sip_msg *msg, pv_param_t *param,
1079 1092
 		pv_value_t *res)
1080 1093
 {
... ...
@@ -184,6 +184,9 @@ int pv_get_force_sock(struct sip_msg *msg, pv_param_t *param,
184 184
 int pv_get_force_sock_name(struct sip_msg *msg, pv_param_t *param,
185 185
 		pv_value_t *res);
186 186
 
187
+int pv_get_force_sock_port(struct sip_msg *msg, pv_param_t *param,
188
+		pv_value_t *res);
189
+
187 190
 int pv_get_useragent(struct sip_msg *msg, pv_param_t *param,
188 191
 		pv_value_t *res);
189 192