Module: kamailio
Branch: master
Commit: 10af978e2ee6dcb7bb2dfcec07d14987600b7c43
URL:
https://github.com/kamailio/kamailio/commit/10af978e2ee6dcb7bb2dfcec07d1498…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-04-02T12:22:51+02:00
pv: new config variable $fsn - forced send socket name
- retrieve the name of the forced send socket
- setting the send socket can be done by assigning socket name:
$fsn = "sock1";
---
Modified: src/modules/pv/pv.c
Modified: src/modules/pv/pv_core.c
Modified: src/modules/pv/pv_core.h
---
Diff:
https://github.com/kamailio/kamailio/commit/10af978e2ee6dcb7bb2dfcec07d1498…
Patch:
https://github.com/kamailio/kamailio/commit/10af978e2ee6dcb7bb2dfcec07d1498…
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 1c4133c6e7..6ee89e7e52 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -250,6 +250,9 @@ static pv_export_t mod_pvs[] = {
{{"fs", (sizeof("fs")-1)}, /* */
PVT_OTHER, pv_get_force_sock, pv_set_force_sock,
0, 0, 0, 0},
+ {{"fsn", (sizeof("fsn")-1)}, /* */
+ PVT_OTHER, pv_get_force_sock_name, pv_set_force_sock_name,
+ 0, 0, 0, 0},
{{"ft", (sizeof("ft")-1)}, /* */
PVT_OTHER, pv_get_from_attr, 0,
0, 0, pv_init_iname, 4},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 9087fe01bf..ad5db64eb4 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -1021,6 +1021,21 @@ int pv_get_force_sock(struct sip_msg *msg, pv_param_t *param,
return pv_get_strval(msg, param, res, &msg->force_send_socket->sock_str);
}
+int pv_get_force_sock_name(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ if(msg==NULL) {
+ return -1;
+ }
+
+ if (msg->force_send_socket==0
+ || msg->force_send_socket->sockname.s == NULL) {
+ return pv_get_null(msg, param, res);
+ }
+
+ return pv_get_strval(msg, param, res, &msg->force_send_socket->sockname);
+}
+
int pv_get_useragent(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
@@ -2655,6 +2670,40 @@ int pv_set_force_sock(struct sip_msg* msg, pv_param_t *param,
return -1;
}
+int pv_set_force_sock_name(struct sip_msg* msg, pv_param_t *param,
+ int op, pv_value_t *val)
+{
+ struct socket_info *si;
+
+ if(msg==NULL || param==NULL) {
+ LM_ERR("bad parameters\n");
+ return -1;
+ }
+
+ if(val==NULL || (val->flags&PV_VAL_NULL)) {
+ reset_force_socket(msg);
+ return 0;
+ }
+
+ if(!(val->flags&PV_VAL_STR) || val->rs.len<=0) {
+ LM_ERR("str value required to set the force send sock\n");
+ goto error;
+ }
+
+ LM_DBG("trying to set send-socket to name [%.*s]\n", val->rs.len,
val->rs.s);
+ si = ksr_get_socket_by_name(&val->rs);
+ if (si!=NULL) {
+ set_force_socket(msg, si);
+ } else {
+ LM_WARN("no socket found to match name [%.*s]\n",
+ val->rs.len, val->rs.s);
+ }
+
+ return 0;
+error:
+ return -1;
+}
+
int pv_set_mflags(struct sip_msg* msg, pv_param_t *param,
int op, pv_value_t *val)
{
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index ee45b915cd..919fa3910f 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -175,6 +175,9 @@ int pv_get_rcvadv_uri_full(struct sip_msg *msg, pv_param_t *param,
int pv_get_force_sock(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_force_sock_name(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
int pv_get_useragent(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
@@ -295,6 +298,9 @@ int pv_set_branch(struct sip_msg* msg, pv_param_t *param,
int pv_set_force_sock(struct sip_msg* msg, pv_param_t *param,
int op, pv_value_t *val);
+int pv_set_force_sock_name(struct sip_msg* msg, pv_param_t *param,
+ int op, pv_value_t *val);
+
int pv_set_mflags(struct sip_msg* msg, pv_param_t *param,
int op, pv_value_t *val);