<p>Max has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12080">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add msgb_tl_put() helper<br><br>When adding complex TLV structures where length of V is not known in<br>advance it's handy to be able to simply add Tag and save the pointer to<br>the Length field so it can be updated once entire Value is added and its<br>length is known.<br><br>Change-Id: I8dc1e4880352833a0a49c1dd0d7cb4148ac43aff<br>---<br>M include/osmocom/gsm/tlv.h<br>1 file changed, 12 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/80/12080/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h</span><br><span>index 1ab964a..51bedd6 100644</span><br><span>--- a/include/osmocom/gsm/tlv.h</span><br><span>+++ b/include/osmocom/gsm/tlv.h</span><br><span>@@ -324,6 +324,18 @@</span><br><span>   return v_put(buf, val);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! put (append) a TL fields to a \ref msgb</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns pointer to the length field so it can be updated after adding new information under specified tag */</span><br><span style="color: hsl(120, 100%, 40%);">+static inline uint8_t *msgb_tl_put(struct msgb *msg, uint8_t tag)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        uint8_t *len = msgb_v_put(msg, tag);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* reserve space for length, len points to this reserved space already */</span><br><span style="color: hsl(120, 100%, 40%);">+     msgb_v_put(msg, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return len;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! put (append) a TV16 field to a \ref msgb</span><br><span>  *  \returns pointer to first byte after newly-put information */</span><br><span> static inline uint8_t *msgb_tv16_put(struct msgb *msg, uint8_t tag, uint16_t val)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12080">change 12080</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/12080"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I8dc1e4880352833a0a49c1dd0d7cb4148ac43aff </div>
<div style="display:none"> Gerrit-Change-Number: 12080 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>