Module: sip-router
Branch: master
Commit: b70650026f280a9d989cc4f6290d6d93a80df058
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b706500…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Jun 3 14:00:34 2009 +0300
pv: added new PV: $bs
- return body size computed from structure, not from Content Lenght
- $cl stays shortcut to $hdr(Content-Lenght) for backward compatibility
---
modules_k/pv/pv.c | 3 +++
modules_k/pv/pv_core.c | 17 +++++++++++++++++
modules_k/pv/pv_core.h | 3 +++
3 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/modules_k/pv/pv.c b/modules_k/pv/pv.c
index 596b618..f990a55 100644
--- a/modules_k/pv/pv.c
+++ b/modules_k/pv/pv.c
@@ -104,6 +104,9 @@ static pv_export_t mod_pvs[] = {
{{"bR", (sizeof("bR")-1)}, /* */
PVT_CONTEXT, pv_get_branches, 0,
0, 0, 0, 0},
+ {{"bs", (sizeof("bs")-1)}, /* */
+ PVT_OTHER, pv_get_body_size, 0,
+ 0, 0, 0, 0},
{{"ci", (sizeof("ci")-1)}, /* */
PVT_OTHER, pv_get_callid, 0,
0, 0, 0, 0},
diff --git a/modules_k/pv/pv_core.c b/modules_k/pv/pv_core.c
index 87b83fe..f8e527e 100644
--- a/modules_k/pv/pv_core.c
+++ b/modules_k/pv/pv_core.c
@@ -896,6 +896,7 @@ int pv_get_content_type(struct sip_msg *msg, pv_param_t *param,
return pv_get_strval(msg, param, res, &msg->content_type->body);
}
+
int pv_get_content_length(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
@@ -939,6 +940,22 @@ int pv_get_msg_body(struct sip_msg *msg, pv_param_t *param,
}
+int pv_get_body_size(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res)
+{
+ str s;
+ if(msg==NULL)
+ return -1;
+
+ s.s = get_body( msg );
+
+ s.len = 0;
+ if (s.s != NULL)
+ s.len = msg->buf + msg->len - s.s;
+ return pv_get_sintval(msg, param, res, s.len);
+}
+
+
int pv_get_authattr(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
{
diff --git a/modules_k/pv/pv_core.h b/modules_k/pv/pv_core.h
index 18dc55a..f0e4e0e 100644
--- a/modules_k/pv/pv_core.h
+++ b/modules_k/pv/pv_core.h
@@ -165,6 +165,9 @@ int pv_get_content_length(struct sip_msg *msg, pv_param_t *param,
int pv_get_msg_body(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
+int pv_get_body_size(struct sip_msg *msg, pv_param_t *param,
+ pv_value_t *res);
+
int pv_get_authattr(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);