<p>Max has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12373">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">TLV: add convenience function for 1-byte values<br><br>Similar to existing 16 and 32 bit value helpers but simpler because we<br>don't have to worry about alingment and endianness.<br><br>Change-Id: Ic0a148bd04b8860e321f509fdcd913f688c8e920<br>---<br>M include/osmocom/gsm/tlv.h<br>1 file changed, 16 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/73/12373/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 4c39264..621a282 100644</span><br><span>--- a/include/osmocom/gsm/tlv.h</span><br><span>+++ b/include/osmocom/gsm/tlv.h</span><br><span>@@ -495,6 +495,22 @@</span><br><span>  (TLVP_PRES_LEN(_tp, tag, min_len)? (_tp)->lv[tag].val : NULL)</span><br><span> </span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Obtain 1-byte TLV element</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] tp pointer to \ref tlv_parsed</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] tag the Tag to look for</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] default_val default value to use if tag not available</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns the 1st byte of value with a given tag or default_val if tag was not found</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static inline uint8_t tlvp_val8(const struct tlv_parsed *tp, uint8_t tag, uint8_t default_val)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  const uint8_t *res = TLVP_VAL_MINLEN(tp, tag, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (res)</span><br><span style="color: hsl(120, 100%, 40%);">+              return res[0];</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      return default_val;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! Align given TLV element with 16 bit value to an even address</span><br><span>  *  \param[in] tp pointer to \ref tlv_parsed</span><br><span>  *  \param[in] pos element to return</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12373">change 12373</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/12373"/><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: Ic0a148bd04b8860e321f509fdcd913f688c8e920 </div>
<div style="display:none"> Gerrit-Change-Number: 12373 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Max <msuraev@sysmocom.de> </div>