[sr-dev] git:master:fe9da5b3: pv: $msg(hdrs_len) - return the length of all headers

Daniel-Constantin Mierla miconda at gmail.com
Wed Aug 8 09:32:29 CEST 2018


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-08-08T09:31:17+02:00

pv: $msg(hdrs_len) - return the length of all headers

---

Modified: src/modules/pv/pv_core.c

---

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

---

diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 7911d75bc7..01cebc8534 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -3472,6 +3472,8 @@ int pv_parse_msg_attrs_name(pv_spec_p sp, str *in)
 		case 8:
 			if(strncmp(in->s, "body_len", 8)==0)
 				sp->pvp.pvn.u.isname.name.n = 5;
+			else if(strncmp(in->s, "hdrs_len", 8)==0)
+				sp->pvp.pvn.u.isname.name.n = 8;
 			else goto error;
 		break;
 		default:
@@ -3541,14 +3543,12 @@ int pv_get_msg_attrs(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
 			if (s.s != NULL)
 				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);
-
 		case 7: /* first part - first line + headers */
 			if(msg->unparsed==NULL)
 				return pv_get_null(msg, param, res);
@@ -3556,6 +3556,13 @@ int pv_get_msg_attrs(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
 			s.len = msg->unparsed - s.s;
 			trim(&s);
 			return pv_get_strval(msg, param, res, &s);
+		case 8: /* headers size */
+			if(msg->unparsed==NULL)
+				return pv_get_sintval(msg, param, res, 0);
+			s.s = msg->buf + msg->first_line.len;
+			s.len = msg->unparsed - s.s;
+			trim(&s);
+			return pv_get_sintval(msg, param, res, s.len);
 
 		default:
 			return pv_get_null(msg, param, res);




More information about the sr-dev mailing list