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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2018-04-23T09:22:23+02:00

pv: new variable $mbu - updated msg buffer

- get the message buffer after applying changes
- the original buffer stays unchanged

---

Modified: src/modules/pv/pv.c
Modified: src/modules/pv/pv_core.c
Modified: src/modules/pv/pv_core.h

---

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

---

diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c
index 1bc2af1e8e..d03a52409a 100644
--- a/src/modules/pv/pv.c
+++ b/src/modules/pv/pv.c
@@ -263,6 +263,9 @@ static pv_export_t mod_pvs[] = {
        {{"mb", (sizeof("mb")-1)}, /* */
                PVT_OTHER, pv_get_msg_buf, 0,
                0, 0, 0, 0},
+       {{"mbu", (sizeof("mbu")-1)}, /* */
+               PVT_OTHER, pv_get_msg_buf_updated, 0,
+               0, 0, 0, 0},
        {{"mf", (sizeof("mf")-1)}, /* */
                PVT_OTHER, pv_get_flags, pv_set_mflags,
                0, 0, 0, 0},
diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c
index 098d5435c2..8d8f35f250 100644
--- a/src/modules/pv/pv_core.c
+++ b/src/modules/pv/pv_core.c
@@ -33,6 +33,7 @@
 #include "../../core/tcp_conn.h"
 #include "../../core/pvapi.h"
 #include "../../core/trim.h"
+#include "../../core/msg_translator.h"
 
 #include "../../core/parser/parse_from.h"
 #include "../../core/parser/parse_uri.h"
@@ -518,6 +519,45 @@ int pv_get_msg_buf(struct sip_msg *msg, pv_param_t *param,
        return pv_get_strval(msg, param, res, &s);
 }
 
+
+static str _ksr_pv_msg_buf_updated = STR_NULL;
+int pv_get_msg_buf_updated(struct sip_msg *msg, pv_param_t *param,
+               pv_value_t *res)
+{
+       dest_info_t send_info;
+
+       if(msg==NULL)
+               return -1;
+
+       if(_ksr_pv_msg_buf_updated.s!=NULL) {
+               pkg_free(_ksr_pv_msg_buf_updated.s);
+               _ksr_pv_msg_buf_updated.s = NULL;
+               _ksr_pv_msg_buf_updated.len = 0;
+       }
+
+       init_dest_info(&send_info);
+       send_info.proto = PROTO_UDP;
+       if(msg->first_line.type == SIP_REPLY) {
+               _ksr_pv_msg_buf_updated.s = generate_res_buf_from_sip_res(msg,
+                               (unsigned int*)&_ksr_pv_msg_buf_updated.len,
+                               BUILD_NO_VIA1_UPDATE);
+       } else if(msg->first_line.type == SIP_REQUEST) {
+               _ksr_pv_msg_buf_updated.s = build_req_buf_from_sip_req(msg,
+                               (unsigned int*)&_ksr_pv_msg_buf_updated.len,
+                               &send_info,
+                               
BUILD_NO_PATH|BUILD_NO_LOCAL_VIA|BUILD_NO_VIA1_UPDATE);
+       } else {
+               return pv_get_null(msg, param, res);
+       }
+
+       if(_ksr_pv_msg_buf_updated.s == NULL) {
+               LM_ERR("couldn't update msg buffer content\n");
+               _ksr_pv_msg_buf_updated.len = 0;
+               return pv_get_null(msg, param, res);
+       }
+       return pv_get_strval(msg, param, res, &_ksr_pv_msg_buf_updated);
+}
+
 int pv_get_msg_len(struct sip_msg *msg, pv_param_t *param,
                pv_value_t *res)
 {
diff --git a/src/modules/pv/pv_core.h b/src/modules/pv/pv_core.h
index 148e87f269..453c1c3197 100644
--- a/src/modules/pv/pv_core.h
+++ b/src/modules/pv/pv_core.h
@@ -94,6 +94,9 @@ int pv_get_cseq_body(struct sip_msg *msg, pv_param_t *param,
 int pv_get_msg_buf(struct sip_msg *msg, pv_param_t *param,
                pv_value_t *res);
 
+int pv_get_msg_buf_updated(struct sip_msg *msg, pv_param_t *param,
+               pv_value_t *res);
+
 int pv_get_msg_len(struct sip_msg *msg, pv_param_t *param,
                pv_value_t *res);
 


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to