Browse code

pv: new variable $rsi - return status code for replies and 0 for requests

Daniel-Constantin Mierla authored on 16/11/2021 08:10:38
Showing 3 changed files
... ...
@@ -379,6 +379,9 @@ static pv_export_t mod_pvs[] = {
379 379
 	{{"rs", (sizeof("rs")-1)}, /* */
380 380
 		PVT_OTHER, pv_get_status, 0,
381 381
 		0, 0, 0, 0},
382
+	{{"rsi", (sizeof("rsi")-1)}, /* */
383
+		PVT_OTHER, pv_get_statusi, 0,
384
+		0, 0, 0, 0},
382 385
 	{{"rt", (sizeof("rt")-1)}, /* */
383 386
 		PVT_OTHER, pv_get_refer_to, 0,
384 387
 		0, 0, 0, 0},
... ...
@@ -248,6 +248,20 @@ int pv_get_status(struct sip_msg *msg, pv_param_t *param,
248 248
 			&msg->first_line.u.reply.status);
249 249
 }
250 250
 
251
+int pv_get_statusi(struct sip_msg *msg, pv_param_t *param,
252
+		pv_value_t *res)
253
+{
254
+	if(msg==NULL)
255
+		return -1;
256
+
257
+	if(msg->first_line.type != SIP_REPLY)
258
+		return pv_get_sintval(msg, param, res, 0);
259
+
260
+	return pv_get_intstrval(msg, param, res,
261
+			(int)msg->first_line.u.reply.statuscode,
262
+			&msg->first_line.u.reply.status);
263
+}
264
+
251 265
 int pv_get_reason(struct sip_msg *msg, pv_param_t *param,
252 266
 		pv_value_t *res)
253 267
 {
... ...
@@ -55,6 +55,9 @@ int pv_get_msgtypes(struct sip_msg *msg, pv_param_t *param,
55 55
 int pv_get_status(struct sip_msg *msg, pv_param_t *param,
56 56
 		pv_value_t *res);
57 57
 
58
+int pv_get_statusi(struct sip_msg *msg, pv_param_t *param,
59
+		pv_value_t *res);
60
+
58 61
 int pv_get_reason(struct sip_msg *msg, pv_param_t *param,
59 62
 		pv_value_t *res);
60 63