<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/16997">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">csn1: Extend CSN_SERIALIZE to allow 0 bit of length<br><br>Port of wireshark.git 2f024256bf337400ef3a82fa75e6d48d5707e059.<br><br>From c6ee558d3bb00bfd25cca7c534448bf60df3c7cf Mon Sep 17 00:00:00 2001<br>From: Sylvain Munaut <tnt@246tNt.com><br>Date: Sat, 4 Feb 2012 10:24:01 +0100<br>Subject: [PATCH 6/6] packet-csn: Extend CSN_SERIALIZE to allow 0 bit of length<br><br>In some coding there is no 'length' field at the top of a serialized<br>block, or it's more complex than a single field, in which case we<br>have to rely on the serialize decoder to consume the correct number<br>of bits.<br><br>We extend the CSN_SERIALIZE processing so that if a '0 bit' length<br>field is specified, then the length is not displayed and the<br>consumed bits by the serialize function is taken as the length<br>at posteriori.<br><br>The processing keeps the same behavior for any length > 0.<br><br>Change-Id: I9fadc99218594447001f7bb9943f4514b9877799<br>---<br>M src/csn1.cpp<br>1 file changed, 8 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/csn1.cpp b/src/csn1.cpp</span><br><span>index f7e9be0..4f761c7 100644</span><br><span>--- a/src/csn1.cpp</span><br><span>+++ b/src/csn1.cpp</span><br><span>@@ -548,15 +548,20 @@</span><br><span> bit_offset += length_len;</span><br><span> remaining_bits_len -= length_len;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- csnStreamInit(&arT, bit_offset, length);</span><br><span style="color: hsl(120, 100%, 40%);">+ csnStreamInit(&arT, bit_offset, length > 0 ? length : remaining_bits_len);</span><br><span> arT.direction = 1;</span><br><span> LOGPC(DCSN1, LOGL_NOTICE, "ptr = %p | offset = %d | ", (void *)data, (int)pDescr->offset);</span><br><span> Status = serialize(&arT, vector, readIndex, pvDATA(data, pDescr->offset));</span><br><span> </span><br><span> if (Status >= 0)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- remaining_bits_len -= length;</span><br><span style="color: hsl(0, 100%, 40%);">- bit_offset += length;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (length > 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ remaining_bits_len -= length;</span><br><span style="color: hsl(120, 100%, 40%);">+ bit_offset += length;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ remaining_bits_len = arT.remaining_bits_len;</span><br><span style="color: hsl(120, 100%, 40%);">+ bit_offset = arT.bit_offset;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> pDescr++;</span><br><span> }</span><br><span> else</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/16997">change 16997</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.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.osmocom.org/c/osmo-pcu/+/16997"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I9fadc99218594447001f7bb9943f4514b9877799 </div>
<div style="display:none"> Gerrit-Change-Number: 16997 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>