[Asterisk-code-review] Resolve an issue with chan sip Call-Id not reported reported (asterisk[master])

Nir Simionovich (GreenfieldTech - Israel) asteriskteam at digium.com
Mon Oct 10 14:57:09 CDT 2016


Nir Simionovich (GreenfieldTech - Israel) has uploaded a new change for review.

  https://gerrit.asterisk.org/4011

Change subject: Resolve an issue with chan_sip Call-Id not reported reported
......................................................................

Resolve an issue with chan_sip Call-Id not reported reported

Change-Id: I466d7503ea73e5b09c5d0fb5568ba8c9e6f248fa
---
M res/res_hep_rtcp.c
1 file changed, 20 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/11/4011/1

diff --git a/res/res_hep_rtcp.c b/res/res_hep_rtcp.c
index 03db181..ddcfdf2 100644
--- a/res/res_hep_rtcp.c
+++ b/res/res_hep_rtcp.c
@@ -55,21 +55,28 @@
 		return NULL;
 	}
 
-	if (uuid_type == HEP_UUID_TYPE_CALL_ID && ast_begins_with(channel_name, "PJSIP")) {
-		struct ast_channel *chan = ast_channel_get_by_name(channel_name);
-		char buf[128];
-
-		if (chan && !ast_func_read(chan, "CHANNEL(pjsip,call-id)", buf, sizeof(buf))) {
-			uuid = ast_strdup(buf);
-		}
-
-		ast_channel_cleanup(chan);
+	/* We need the channel to continue properly, so let's extract that one first */
+	struct ast_channel *chan = ast_channel_get_by_name(channel_name);
+	switch(uuid_type) {
+		case HEP_UUID_TYPE_CHANNEL:
+			uuid = ast_strdup(channel_name);
+			break;
+		case HEP_UUID_TYPE_CALL_ID:
+		default:
+			char buf[128];
+			if(ast_begins_with(channel_name, "PJSIP")) {
+				if (chan && !ast_func_read(chan, "CHANNEL(pjsip,call-id)", buf, sizeof(buf))) {
+					uuid = ast_strdup(buf);
+				}
+			} else {
+				if (chan && !ast_func_read(chan, "SIP_HEADER(call-id)", buf, sizeof(buf))) {
+					uuid = ast_strdup(buf);
+				}
+			}
+			break;
 	}
 
-	/* If we couldn't get the call-id or didn't want it, just use the channel name */
-	if (!uuid) {
-		uuid = ast_strdup(channel_name);
-	}
+	ast_channel_cleanup(chan);
 
 	return uuid;
 }

-- 
To view, visit https://gerrit.asterisk.org/4011
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I466d7503ea73e5b09c5d0fb5568ba8c9e6f248fa
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Nir Simionovich (GreenfieldTech - Israel) <nirs at greenfieldtech.net>



More information about the asterisk-code-review mailing list