[sr-dev] git:master:f5d73407: textopsx: exported msg_set_buffer(data) function

Daniel-Constantin Mierla miconda at gmail.com
Fri Sep 24 12:17:32 CEST 2021


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-09-24T12:17:19+02:00

textopsx: exported msg_set_buffer(data) function

- it was available to KEMI

---

Modified: src/modules/textopsx/doc/functions.xml
Modified: src/modules/textopsx/textopsx.c

---

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

---

diff --git a/src/modules/textopsx/doc/functions.xml b/src/modules/textopsx/doc/functions.xml
index b5a6cac103..3de3a6c8e6 100644
--- a/src/modules/textopsx/doc/functions.xml
+++ b/src/modules/textopsx/doc/functions.xml
@@ -46,6 +46,34 @@ if(msg_apply_changes())
     }
 }
 ...
+</programlisting>
+		</example>
+	</section>
+
+	<section id="textopsx.f.msg_set_buffer">
+		<title>
+			<function moreinfo="none">msg_set_buffer(data)</function>
+		</title>
+		<para>
+		Set the content of the SIP message buffer, replacing the exiting data.
+		The parameter can contain variables, its value must be a valid SIP
+		request or reply, a matter of what the old message is.
+		</para>
+		<para>
+		This function can be used from REQUEST_ROUTE or core REPLY_ROUTE.
+		</para>
+		<para>
+		Note: It must be used before the transaction is created in
+		request_route and not inside the onreply_route[name] executed by tm
+		module. Also, do not use after resuming a suspended request or reply,
+		at that moment the transaction is already created.
+		</para>
+		<example>
+		<title><function>msg_set_buffer()</function> usage</title>
+		<programlisting format="linespecific">
+...
+msg_set_buffer("INVITE sip:...");
+...
 </programlisting>
 		</example>
 	</section>
diff --git a/src/modules/textopsx/textopsx.c b/src/modules/textopsx/textopsx.c
index a9a60f9ed8..5ddeffa2c7 100644
--- a/src/modules/textopsx/textopsx.c
+++ b/src/modules/textopsx/textopsx.c
@@ -46,6 +46,7 @@
 MODULE_VERSION
 
 static int msg_apply_changes_f(sip_msg_t *msg, char *str1, char *str2);
+static int msg_set_buffer_f(sip_msg_t *msg, char *p1data, char *p2);
 
 static int change_reply_status_f(sip_msg_t *, char *, char *);
 static int change_reply_status_fixup(void **param, int param_no);
@@ -121,6 +122,9 @@ static pv_export_t mod_pvs[] = {
 static cmd_export_t cmds[] = {
 	{"msg_apply_changes", (cmd_function)msg_apply_changes_f, 0, 0, 0,
 			REQUEST_ROUTE | ONREPLY_ROUTE},
+	{"msg_set_buffer", (cmd_function)msg_set_buffer_f, 1,
+			fixup_spve_null, fixup_free_spve_null,
+			REQUEST_ROUTE | ONREPLY_ROUTE},
 	{"change_reply_status", change_reply_status_f, 2,
 			change_reply_status_fixup, 0, ONREPLY_ROUTE},
 	{"change_reply_status_code", change_reply_status_code_f, 1,
@@ -242,6 +246,21 @@ static int ki_msg_set_buffer(sip_msg_t *msg, str *obuf)
 	return ki_msg_update_buffer(msg, obuf);
 }
 
+/**
+ *
+ */
+static int msg_set_buffer_f(sip_msg_t *msg, char *p1data, char *p2)
+{
+	str data = STR_NULL;
+
+	if(fixup_get_svalue(msg, (gparam_t*)p1data, &data) < 0) {
+		LM_ERR("could not get string param value\n");
+		return -1;
+	}
+
+	return ki_msg_set_buffer(msg, &data);
+}
+
 /**
  *
  */




More information about the sr-dev mailing list