[sr-dev] git:master: pv: added $mt - return sip message type

Daniel-Constantin Mierla miconda at gmail.com
Sun Feb 27 16:46:25 CET 2011


Module: sip-router
Branch: master
Commit: 1baf83e9407bbbe1b25e390ed013a7ef87ffc196
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1baf83e9407bbbe1b25e390ed013a7ef87ffc196

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sat Feb 26 23:25:07 2011 +0100

pv: added $mt - return sip message type

- the value is 1 if the sip message is request
- the value is 2 if the sip message is reply

---

 modules_k/pv/pv.c      |    3 +++
 modules_k/pv/pv_core.c |   16 ++++++++++++++++
 modules_k/pv/pv_core.h |    3 +++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/modules_k/pv/pv.c b/modules_k/pv/pv.c
index e690ef7..77898cf 100644
--- a/modules_k/pv/pv.c
+++ b/modules_k/pv/pv.c
@@ -220,6 +220,9 @@ static pv_export_t mod_pvs[] = {
 	{{"ml", (sizeof("ml")-1)}, /* */
 		PVT_OTHER, pv_get_msg_len, 0,
 		0, 0, 0, 0},
+	{{"mt", (sizeof("mt")-1)}, /* */
+		PVT_OTHER, pv_get_msgtype, 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/modules_k/pv/pv_core.c b/modules_k/pv/pv_core.c
index f0b6415..698bda0 100644
--- a/modules_k/pv/pv_core.c
+++ b/modules_k/pv/pv_core.c
@@ -152,6 +152,22 @@ int pv_get_methodid(struct sip_msg *msg, pv_param_t *param,
 			(unsigned int)(get_cseq(msg)->method_id));
 }
 
+int pv_get_msgtype(struct sip_msg *msg, pv_param_t *param,
+		pv_value_t *res)
+{
+	unsigned int type = 0;
+
+	if(msg==NULL)
+		return -1;
+
+	if(msg->first_line.type == SIP_REQUEST)
+		type = 1;
+	else if(msg->first_line.type == SIP_REPLY)
+		type = 2;
+
+	return pv_get_uintval(msg, param, res, type);
+}
+
 int pv_get_version(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res)
 {
diff --git a/modules_k/pv/pv_core.h b/modules_k/pv/pv_core.h
index 3ee11b7..f222f59 100644
--- a/modules_k/pv/pv_core.h
+++ b/modules_k/pv/pv_core.h
@@ -48,6 +48,9 @@ int pv_get_method(struct sip_msg *msg, pv_param_t *param,
 int pv_get_methodid(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res);
 
+int pv_get_msgtype(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