pv: new var $mts - return msg type as string
authorDaniel-Constantin Mierla <miconda@gmail.com>
Sun, 31 May 2020 09:21:25 +0000 (11:21 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 1 Jun 2020 07:21:25 +0000 (09:21 +0200)
- rq - for request
- rp - for response

src/modules/pv/pv.c
src/modules/pv/pv_core.c
src/modules/pv/pv_core.h

index 492344f..0308514 100644 (file)
@@ -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},
index 5a83a89..e53db70 100644 (file)
@@ -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)
 {
index 919fa39..cf87a7e 100644 (file)
@@ -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);