Module: kamailio
Branch: master
Commit: 84e3191c165f00aaba61174dd627d7e67b57f8c7
URL:
https://github.com/kamailio/kamailio/commit/84e3191c165f00aaba61174dd627d7e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-07-13T09:12:17+02:00
pv: added $via1(...) - return attributes of 2nd via
---
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/84e3191c165f00aaba61174dd627d7e…
Patch:
https://github.com/kamailio/kamailio/commit/84e3191c165f00aaba61174dd627d7e…
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 41c53eaa3f..cc976c86c0 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -548,6 +548,8 @@ static pv_export_t mod_pvs[] = {
pv_parse_ccp_attrs_name, 0, 0, 0},
{{"via0", (sizeof("via0")-1)}, PVT_OTHER, pv_get_via0, 0,
pv_parse_via_name, 0, 0, 0},
+ {{"via1", (sizeof("via1")-1)}, PVT_OTHER, pv_get_via1, 0,
+ pv_parse_via_name, 0, 0, 0},
{{"viaZ", (sizeof("viaZ")-1)}, PVT_OTHER, pv_get_viaZ, 0,
pv_parse_via_name, 0, 0, 0},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 34998b9882..292c96758c 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -4595,6 +4595,19 @@ int pv_get_via0(sip_msg_t *msg, pv_param_t *param, pv_value_t
*res)
return pv_get_via_attr(msg, msg->via1, param, res);
}
+/**
+ *
+ */
+int pv_get_via1(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
+{
+ if (parse_headers(msg, HDR_EOH_F, 0)<0) {
+ LM_DBG("failed to parse sip headers\n");
+ return pv_get_null(msg, param, res);
+ }
+
+ return pv_get_via_attr(msg, msg->via2, param, res);
+}
+
/**
*
*/
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 19222bc63e..14c79ce86c 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -413,6 +413,7 @@ int pv_set_ccp_attrs(struct sip_msg* msg, pv_param_t *param,
int pv_parse_via_name(pv_spec_p sp, str *in);
int pv_get_via0(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
+int pv_get_via1(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
int pv_get_viaZ(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
#endif