Browse code

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

- rq - for request
- rp - for response

Daniel-Constantin Mierla authored on 31/05/2020 09:21:25
Showing 3 changed files
... ...
@@ -293,6 +293,9 @@ static pv_export_t mod_pvs[] = {
293 293
 	{{"mt", (sizeof("mt")-1)}, /* */
294 294
 		PVT_OTHER, pv_get_msgtype, 0,
295 295
 		0, 0, 0, 0},
296
+	{{"mts", (sizeof("mts")-1)}, /* */
297
+		PVT_OTHER, pv_get_msgtypes, 0,
298
+		0, 0, 0, 0},
296 299
 	{{"od", (sizeof("od")-1)}, /* */
297 300
 		PVT_OTHER, pv_get_ouri_attr, 0,
298 301
 		0, 0, pv_init_iname, 2},
... ...
@@ -195,6 +195,23 @@ int pv_get_msgtype(struct sip_msg *msg, pv_param_t *param,
195 195
 	return pv_get_uintval(msg, param, res, type);
196 196
 }
197 197
 
198
+int pv_get_msgtypes(struct sip_msg *msg, pv_param_t *param,
199
+		pv_value_t *res)
200
+{
201
+	char *types = "xx";
202
+
203
+	if(msg==NULL)
204
+		return -1;
205
+
206
+	if(msg->first_line.type == SIP_REQUEST) {
207
+		types = "rq";
208
+	} else if(msg->first_line.type == SIP_REPLY) {
209
+		types = "rp";
210
+	}
211
+
212
+	return pv_get_strzval(msg, param, res, types);
213
+}
214
+
198 215
 int pv_get_version(struct sip_msg *msg, pv_param_t *param,
199 216
 		pv_value_t *res)
200 217
 {
... ...
@@ -49,6 +49,9 @@ int pv_get_methodid(struct sip_msg *msg, pv_param_t *param,
49 49
 int pv_get_msgtype(struct sip_msg *msg, pv_param_t *param,
50 50
 		pv_value_t *res);
51 51
 
52
+int pv_get_msgtypes(struct sip_msg *msg, pv_param_t *param,
53
+		pv_value_t *res);
54
+
52 55
 int pv_get_status(struct sip_msg *msg, pv_param_t *param,
53 56
 		pv_value_t *res);
54 57