[sr-dev] git:master:b05b0891: rr: exported to kemi record_route_preset_one()

Daniel-Constantin Mierla miconda at gmail.com
Mon Dec 9 07:07:48 CET 2019


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-12-09T07:03:18+01:00

rr: exported to kemi record_route_preset_one()

- the variant for record_route_preset() with one parameter
- GH #2171

---

Modified: src/modules/rr/rr_mod.c

---

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

---

diff --git a/src/modules/rr/rr_mod.c b/src/modules/rr/rr_mod.c
index 31a6031a5f..6ed7cd8131 100644
--- a/src/modules/rr/rr_mod.c
+++ b/src/modules/rr/rr_mod.c
@@ -292,26 +292,45 @@ static int ki_record_route(sip_msg_t *msg)
 }
 
 /**
- * wrapper for record_route_preset(msg, key1, key2)
+ * wrapper for record_route_preset(msg, addr1, addr2)
  */
-static int ki_record_route_preset(sip_msg_t *msg, str *key1, str *key2)
+static int ki_record_route_preset(sip_msg_t *msg, str *addr1, str *addr2)
 {
 	if (msg->msg_flags & FL_RR_ADDED) {
 		LM_ERR("Double attempt to record-route\n");
 		return -1;
 	}
-	if (key2 && !enable_double_rr) {
+	if (addr2 && addr2->len>0 && !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 )
+	if ( record_route_preset(msg, addr1)<0 )
 		return -1;
 
-	if (!key2)
+	if (!addr2 || addr2->len<=0)
 		goto done;
 
-	if ( record_route_preset( msg, key2)<0 )
+	if ( record_route_preset(msg, addr2)<0 )
+		return -1;
+
+done:
+	msg->msg_flags |= FL_RR_ADDED;
+	return 1;
+
+}
+
+/**
+ * wrapper for record_route_preset(msg, addr1)
+ */
+static int ki_record_route_preset_one(sip_msg_t *msg, str *addr1)
+{
+	if (msg->msg_flags & FL_RR_ADDED) {
+		LM_ERR("Double attempt to record-route\n");
+		return -1;
+	}
+
+	if ( record_route_preset( msg, addr1)<0 )
 		return -1;
 
 done:
@@ -776,6 +795,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_one"),
+		SR_KEMIP_INT, ki_record_route_preset_one,
+		{ 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,




More information about the sr-dev mailing list