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

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2024-04-05T13:00:32+02:00

core: msg translator - helper function to evaluate changes

---

Modified: src/core/msg_translator.c
Modified: src/core/msg_translator.h

---

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

---

diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index acd5911867a..ab02fb7c47c 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -3485,6 +3485,33 @@ int sip_msg_update_buffer(sip_msg_t *msg, str *obuf)
        return 1;
 }
 
+/**
+ * evaluate changes and set the output buffer
+ * - obuf->s has to be pkg freed
+ * - return: 1 on success, -1 on failure
+ */
+int sip_msg_eval_changes(sip_msg_t *msg, str *obuf)
+{
+       dest_info_t dst;
+
+       init_dest_info(&dst);
+       dst.proto = PROTO_UDP;
+       if(msg->first_line.type == SIP_REPLY) {
+               obuf->s = generate_res_buf_from_sip_res(
+                               msg, (unsigned int *)&obuf->len, 
BUILD_NO_VIA1_UPDATE);
+       } else {
+               obuf->s = build_req_buf_from_sip_req(msg, (unsigned int 
*)&obuf->len,
+                               &dst,
+                               BUILD_NO_PATH | BUILD_NO_LOCAL_VIA | 
BUILD_NO_VIA1_UPDATE);
+       }
+       if(obuf->s == NULL) {
+               LM_ERR("couldn't update msg buffer content\n");
+               return -1;
+       }
+
+       return 1;
+}
+
 /**
  *
  */
diff --git a/src/core/msg_translator.h b/src/core/msg_translator.h
index eac64186d56..9d41b472767 100644
--- a/src/core/msg_translator.h
+++ b/src/core/msg_translator.h
@@ -173,6 +173,11 @@ void process_lumps(struct sip_msg *msg, struct lump 
*lumps, char *new_buf,
  */
 int sip_msg_update_buffer(sip_msg_t *msg, str *obuf);
 
+/**
+ * evaluate changes and set the output buffer
+ */
+int sip_msg_eval_changes(sip_msg_t *msg, str *obuf);
+
 /**
  * apply changes to sip msg buffer and reparse
  */

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to