Browse code

pv: added $via1(...) - return attributes of 2nd via

Daniel-Constantin Mierla authored on 13/07/2021 07:12:17
Showing 3 changed files
... ...
@@ -548,6 +548,8 @@ static pv_export_t mod_pvs[] = {
548 548
 		pv_parse_ccp_attrs_name, 0, 0, 0},
549 549
 	{{"via0", (sizeof("via0")-1)}, PVT_OTHER, pv_get_via0, 0,
550 550
 		pv_parse_via_name, 0, 0, 0},
551
+	{{"via1", (sizeof("via1")-1)}, PVT_OTHER, pv_get_via1, 0,
552
+		pv_parse_via_name, 0, 0, 0},
551 553
 	{{"viaZ", (sizeof("viaZ")-1)}, PVT_OTHER, pv_get_viaZ, 0,
552 554
 		pv_parse_via_name, 0, 0, 0},
553 555
 
... ...
@@ -4595,6 +4595,19 @@ int pv_get_via0(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
4595 4595
 	return pv_get_via_attr(msg, msg->via1, param, res);
4596 4596
 }
4597 4597
 
4598
+/**
4599
+ *
4600
+ */
4601
+int pv_get_via1(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
4602
+{
4603
+	if (parse_headers(msg, HDR_EOH_F, 0)<0) {
4604
+		LM_DBG("failed to parse sip headers\n");
4605
+		return pv_get_null(msg, param, res);
4606
+	}
4607
+
4608
+	return pv_get_via_attr(msg, msg->via2, param, res);
4609
+}
4610
+
4598 4611
 /**
4599 4612
  *
4600 4613
  */
... ...
@@ -413,6 +413,7 @@ int pv_set_ccp_attrs(struct sip_msg* msg, pv_param_t *param,
413 413
 
414 414
 int pv_parse_via_name(pv_spec_p sp, str *in);
415 415
 int pv_get_via0(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
416
+int pv_get_via1(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
416 417
 int pv_get_viaZ(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
417 418
 
418 419
 #endif