[sr-dev] git:master:52f9c668: pv: new var $mts - return msg type as string

Daniel-Constantin Mierla miconda at gmail.com
Mon Jun 1 20:22:26 CEST 2020


Module: kamailio
Branch: master
Commit: 52f9c668d77746383d8fdae6e90fabd6c7a018fa
URL: https://github.com/kamailio/kamailio/commit/52f9c668d77746383d8fdae6e90fabd6c7a018fa

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-06-01T09:21:25+02:00

pv: new var $mts - return msg type as string

- rq - for request
- rp - for response

---

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/52f9c668d77746383d8fdae6e90fabd6c7a018fa.diff
Patch: https://github.com/kamailio/kamailio/commit/52f9c668d77746383d8fdae6e90fabd6c7a018fa.patch

---

diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 492344f80e..0308514e70 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -293,6 +293,9 @@ static pv_export_t mod_pvs[] = {
 	{{"mt", (sizeof("mt")-1)}, /* */
 		PVT_OTHER, pv_get_msgtype, 0,
 		0, 0, 0, 0},
+	{{"mts", (sizeof("mts")-1)}, /* */
+		PVT_OTHER, pv_get_msgtypes, 0,
+		0, 0, 0, 0},
 	{{"od", (sizeof("od")-1)}, /* */
 		PVT_OTHER, pv_get_ouri_attr, 0,
 		0, 0, pv_init_iname, 2},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 5a83a8999b..e53db70c25 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -195,6 +195,23 @@ int pv_get_msgtype(struct sip_msg *msg, pv_param_t *param,
 	return pv_get_uintval(msg, param, res, type);
 }
 
+int pv_get_msgtypes(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res)
+{
+	char *types = "xx";
+
+	if(msg==NULL)
+		return -1;
+
+	if(msg->first_line.type == SIP_REQUEST) {
+		types = "rq";
+	} else if(msg->first_line.type == SIP_REPLY) {
+		types = "rp";
+	}
+
+	return pv_get_strzval(msg, param, res, types);
+}
+
 int pv_get_version(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res)
 {
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 919fa3910f..cf87a7e0c9 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -49,6 +49,9 @@ int pv_get_methodid(struct sip_msg *msg, pv_param_t *param,
 int pv_get_msgtype(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res);
 
+int pv_get_msgtypes(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res);
+
 int pv_get_status(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res);
 




More information about the sr-dev mailing list