[sr-dev] git:master:e1ab977f: module rr: KEMI expose record_route_preset

A Alba ascanio.alba7 at gmail.com
Wed Sep 4 00:21:20 CEST 2019


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

Author: A Alba <ascanio.alba7 at gmail.com>
Committer: A Alba <ascanio.alba7 at gmail.com>
Date: 2019-09-02T01:28:48+08:00

module rr: KEMI expose record_route_preset

---

Modified: src/modules/rr/rr_mod.c

---

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

---

diff --git a/src/modules/rr/rr_mod.c b/src/modules/rr/rr_mod.c
index 6e9dda1318..31a6031a5f 100644
--- a/src/modules/rr/rr_mod.c
+++ b/src/modules/rr/rr_mod.c
@@ -291,6 +291,35 @@ static int ki_record_route(sip_msg_t *msg)
 	return ki_record_route_params( msg, 0 );
 }
 
+/**
+ * wrapper for record_route_preset(msg, key1, key2)
+ */
+static int ki_record_route_preset(sip_msg_t *msg, str *key1, str *key2)
+{
+	if (msg->msg_flags & FL_RR_ADDED) {
+		LM_ERR("Double attempt to record-route\n");
+		return -1;
+	}
+	if (key2 && !enable_double_rr) {
+		LM_ERR("Attempt to double record-route while 'enable_double_rr' param is disabled\n");
+		return -1;
+	}
+
+	if ( record_route_preset( msg, key1)<0 )
+		return -1;
+
+	if (!key2)
+		goto done;
+
+	if ( record_route_preset( msg, key2)<0 )
+		return -1;
+
+done:
+	msg->msg_flags |= FL_RR_ADDED;
+	return 1;
+
+}
+
 /**
  * config wrapper for record_route(msg, params)
  */
@@ -317,7 +346,7 @@ static int w_record_route_preset(struct sip_msg *msg, char *key, char *key2)
 	str s;
 
 	if (msg->msg_flags & FL_RR_ADDED) {
-		LM_ERR("Duble attempt to record-route\n");
+		LM_ERR("Double attempt to record-route\n");
 		return -1;
 	}
 	if (key2 && !enable_double_rr) {
@@ -747,6 +776,11 @@ static sr_kemi_t sr_kemi_rr_exports[] = {
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init("rr"), str_init("record_route_preset"),
+		SR_KEMIP_INT, ki_record_route_preset,
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };
 




More information about the sr-dev mailing list