[sr-dev] git:master:f177124d: pv: $msg(hdrc) returns the number of headers in sip message

Daniel-Constantin Mierla miconda at gmail.com
Mon Aug 6 09:54:44 CEST 2018


Module: kamailio
Branch: master
Commit: f177124dfd72a9f6569797ad8b4d3945e39f7cd7
URL: https://github.com/kamailio/kamailio/commit/f177124dfd72a9f6569797ad8b4d3945e39f7cd7

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-08-05T23:42:21+02:00

pv: $msg(hdrc) returns the number of headers in sip message

---

Modified: src/modules/pv/pv_core.c

---

Diff:  https://github.com/kamailio/kamailio/commit/f177124dfd72a9f6569797ad8b4d3945e39f7cd7.diff
Patch: https://github.com/kamailio/kamailio/commit/f177124dfd72a9f6569797ad8b4d3945e39f7cd7.patch

---

diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 65e9491b93..5aedfd8a8d 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -3458,6 +3458,8 @@ int pv_parse_msg_attrs_name(pv_spec_p sp, str *in)
 				sp->pvp.pvn.u.isname.name.n = 2;
 			else if(strncmp(in->s, "hdrs", 4)==0)
 				sp->pvp.pvn.u.isname.name.n = 3;
+			else if(strncmp(in->s, "hdrc", 4)==0)
+				sp->pvp.pvn.u.isname.name.n = 6;
 			else goto error;
 		break;
 		case 5:
@@ -3489,6 +3491,9 @@ int pv_parse_msg_attrs_name(pv_spec_p sp, str *in)
 int pv_get_msg_attrs(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
 {
 	str s;
+	hdr_field_t* hdr;
+	int n;
+
 	if(msg==NULL)
 		return pv_get_null(msg, param, res);
 
@@ -3535,6 +3540,13 @@ int pv_get_msg_attrs(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
 				s.len = msg->buf + msg->len - s.s;
 			return pv_get_sintval(msg, param, res, s.len);
 
+		case 6: /* headers count */
+			n = 0;
+			for(hdr=msg->headers; hdr!=NULL; hdr=hdr->next) {
+				n++;
+			}
+			return pv_get_sintval(msg, param, res, n);
+
 		default:
 			return pv_get_null(msg, param, res);
 	}




More information about the sr-dev mailing list