<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/12750">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Sean Bright: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_unistim: Fix RTP port byte order for big-endian arch<br><br>This patch fixes one-way oudio that users expirienced on<br>big-endian architechtires. RTP port number bytes was stored<br>in improper order and phone sent RTP to wrong RTP port.<br><br>Reported-by: Andrey Ionov<br>Change-Id: I9a9ca7f26e31a67bbbceff12923baa10dfb8a3be<br>---<br>M channels/chan_unistim.c<br>1 file changed, 25 insertions(+), 43 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c</span><br><span>index c1328c1..c8dfaff 100644</span><br><span>--- a/channels/chan_unistim.c</span><br><span>+++ b/channels/chan_unistim.c</span><br><span>@@ -62,6 +62,7 @@</span><br><span> #include "asterisk/module.h"</span><br><span> #include "asterisk/pbx.h"</span><br><span> #include "asterisk/rtp_engine.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#include "asterisk/unaligned.h"</span><br><span> #include "asterisk/netsock2.h"</span><br><span> #include "asterisk/acl.h"</span><br><span> #include "asterisk/callerid.h"</span><br><span>@@ -575,7 +576,7 @@</span><br><span> { 0x16, 0x06, 0x1b, 0x00, 0x00, 0x05 };</span><br><span> static const unsigned char packet_send_stream_based_tone_single_freq[] =</span><br><span> { 0x16, 0x06, 0x1d, 0x00, 0x01, 0xb8 };</span><br><span style="color: hsl(0, 100%, 40%);">-static const unsigned char packet_send_stream_based_tone_dial_freq[] =</span><br><span style="color: hsl(120, 100%, 40%);">+static const unsigned char packet_send_stream_based_tone_dual_freq[] =</span><br><span> { 0x16, 0x08, 0x1d, 0x00, 0x01, 0xb8, 0x01, 0x5e };</span><br><span> static const unsigned char packet_send_select_output[] =</span><br><span> { 0x16, 0x06, 0x32, 0xc0, 0x01, 0x00 };</span><br><span>@@ -1208,19 +1209,16 @@</span><br><span> if (!tone2) {</span><br><span> memcpy(buffsend + SIZE_HEADER, packet_send_stream_based_tone_single_freq,</span><br><span> sizeof(packet_send_stream_based_tone_single_freq));</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[10] = (tone1 & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[11] = (tone1 & 0x00ff);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[10], htons(tone1));</span><br><span> send_client(SIZE_HEADER + sizeof(packet_send_stream_based_tone_single_freq), buffsend,</span><br><span> pte);</span><br><span> } else {</span><br><span> tone2 *= 8;</span><br><span style="color: hsl(0, 100%, 40%);">- memcpy(buffsend + SIZE_HEADER, packet_send_stream_based_tone_dial_freq,</span><br><span style="color: hsl(0, 100%, 40%);">- sizeof(packet_send_stream_based_tone_dial_freq));</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[10] = (tone1 & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[11] = (tone1 & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[12] = (tone2 & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[13] = (tone2 & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- send_client(SIZE_HEADER + sizeof(packet_send_stream_based_tone_dial_freq), buffsend,</span><br><span style="color: hsl(120, 100%, 40%);">+ memcpy(buffsend + SIZE_HEADER, packet_send_stream_based_tone_dual_freq,</span><br><span style="color: hsl(120, 100%, 40%);">+ sizeof(packet_send_stream_based_tone_dual_freq));</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[10], htons(tone1));</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[12], htons(tone2));</span><br><span style="color: hsl(120, 100%, 40%);">+ send_client(SIZE_HEADER + sizeof(packet_send_stream_based_tone_dual_freq), buffsend,</span><br><span> pte);</span><br><span> }</span><br><span> </span><br><span>@@ -2747,7 +2745,7 @@</span><br><span> sizeof(packet_send_jitter_buffer_conf));</span><br><span> send_client(SIZE_HEADER + sizeof(packet_send_jitter_buffer_conf), buffsend, pte);</span><br><span> if (pte->device->rtp_method != 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- uint16_t rtcpsin_port = htons(us.sin_port) + 1; /* RTCP port is RTP + 1 */</span><br><span style="color: hsl(120, 100%, 40%);">+ uint16_t rtcpsin_port = ntohs(us.sin_port) + 1; /* RTCP port is RTP + 1 */</span><br><span> </span><br><span> if (unistimdebug) {</span><br><span> ast_verb(0, "Sending OpenAudioStreamTX using method #%d\n", pte->device->rtp_method);</span><br><span>@@ -2761,20 +2759,14 @@</span><br><span> }</span><br><span> if (pte->device->rtp_method != 2) {</span><br><span> memcpy(buffsend + 28, &public.sin_addr, sizeof(public.sin_addr));</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[20] = (htons(sin.sin_port) & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[21] = (htons(sin.sin_port) & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[23] = (rtcpsin_port & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[22] = (rtcpsin_port & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[25] = (us.sin_port & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[24] = (us.sin_port & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[27] = (rtcpsin_port & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[26] = (rtcpsin_port & 0xff00) >> 8;</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[20], sin.sin_port);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[22], htons(rtcpsin_port));</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[24], us.sin_port);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[26], htons(rtcpsin_port));</span><br><span> } else {</span><br><span> memcpy(buffsend + 23, &public.sin_addr, sizeof(public.sin_addr));</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[15] = (htons(sin.sin_port) & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[16] = (htons(sin.sin_port) & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[20] = (us.sin_port & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[19] = (us.sin_port & 0x00ff);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[15], sin.sin_port);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[19], us.sin_port);</span><br><span> }</span><br><span> buffsend[11] = codec; /* rx */</span><br><span> buffsend[12] = codec; /* tx */</span><br><span>@@ -2792,20 +2784,14 @@</span><br><span> }</span><br><span> if (pte->device->rtp_method != 2) {</span><br><span> memcpy(buffsend + 28, &public.sin_addr, sizeof(public.sin_addr));</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[20] = (htons(sin.sin_port) & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[21] = (htons(sin.sin_port) & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[23] = (rtcpsin_port & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[22] = (rtcpsin_port & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[25] = (us.sin_port & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[24] = (us.sin_port & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[27] = (rtcpsin_port & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[26] = (rtcpsin_port & 0xff00) >> 8;</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[20], sin.sin_port);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[22], htons(rtcpsin_port));</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[24], us.sin_port);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[26], htons(rtcpsin_port));</span><br><span> } else {</span><br><span> memcpy(buffsend + 23, &public.sin_addr, sizeof(public.sin_addr));</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[15] = (htons(sin.sin_port) & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[16] = (htons(sin.sin_port) & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[20] = (us.sin_port & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[19] = (us.sin_port & 0x00ff);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[15], sin.sin_port);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[19], us.sin_port);</span><br><span> }</span><br><span> buffsend[11] = codec; /* rx */</span><br><span> buffsend[12] = codec; /* tx */</span><br><span>@@ -2820,11 +2806,9 @@</span><br><span> memcpy(buffsend + SIZE_HEADER, packet_send_call, sizeof(packet_send_call));</span><br><span> memcpy(buffsend + 53, &public.sin_addr, sizeof(public.sin_addr));</span><br><span> /* Destination port when sending RTP */</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[49] = (us.sin_port & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[50] = (us.sin_port & 0xff00) >> 8;</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[49], us.sin_port);</span><br><span> /* Destination port when sending RTCP */</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[52] = (rtcpsin_port & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[51] = (rtcpsin_port & 0xff00) >> 8;</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[51], htons(rtcpsin_port));</span><br><span> /* Codec */</span><br><span> buffsend[40] = codec;</span><br><span> buffsend[41] = codec;</span><br><span>@@ -2841,10 +2825,8 @@</span><br><span> ast_format_get_name(ast_channel_readformat(sub->owner)));</span><br><span> }</span><br><span> /* Source port for transmit RTP and Destination port for receiving RTP */</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[45] = (htons(sin.sin_port) & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[46] = (htons(sin.sin_port) & 0x00ff);</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[47] = (rtcpsin_port & 0xff00) >> 8;</span><br><span style="color: hsl(0, 100%, 40%);">- buffsend[48] = (rtcpsin_port & 0x00ff);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[45], sin.sin_port);</span><br><span style="color: hsl(120, 100%, 40%);">+ put_unaligned_uint16(&buffsend[47], htons(rtcpsin_port));</span><br><span> send_client(SIZE_HEADER + sizeof(packet_send_call), buffsend, pte);</span><br><span> }</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/12750">change 12750</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/12750"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I9a9ca7f26e31a67bbbceff12923baa10dfb8a3be </div>
<div style="display:none"> Gerrit-Change-Number: 12750 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Igor Goncharovsky <igor.goncharovsky@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>