<p>neels has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-mgw/+/15141">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">SDP: store all ptmap entries<br><br>If a ptmap appears in the SDP, always store it in the ptmap array. No longer<br>attempt to drop entries if they match the conventional payload type number.<br><br>- One reason is that the past code only matched full explicit "FOO/8000/1"<br> strings, while the channel number "/1" can be omitted to imply 1; by simply<br> storing everything received in the SDP, there is no need to add complexity<br> to match both "FOO/8000" and "FOO/8000/1".<br><br>- The other reason is to rather parse exactly what was received, instead of<br> filtering entries, to take away a degree of implied magic.<br><br>Change-Id: I2a69c21e68c602daf804744212d335ab1eafd81b<br>---<br>M src/libosmo-mgcp-client/mgcp_client.c<br>1 file changed, 8 insertions(+), 20 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/41/15141/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>index 6275385..5823e2b 100644</span><br><span>--- a/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>+++ b/src/libosmo-mgcp-client/mgcp_client.c</span><br><span>@@ -337,7 +337,7 @@</span><br><span> {</span><br><span> unsigned int pt;</span><br><span> char codec_resp[64];</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned int codec;</span><br><span style="color: hsl(120, 100%, 40%);">+ enum mgcp_codecs codec;</span><br><span> </span><br><span> #define A_PTIME "a=ptime:"</span><br><span> #define A_RTPMAP "a=rtpmap:"</span><br><span>@@ -354,26 +354,14 @@</span><br><span> "Failed to parse SDP parameter, invalid rtpmap: %s\n", osmo_quote_str(line, -1));</span><br><span> return -EINVAL;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- /* The MGW may assign an own payload type in the</span><br><span style="color: hsl(0, 100%, 40%);">- * response if the choosen codec falls into the IANA</span><br><span style="color: hsl(0, 100%, 40%);">- * assigned dynamic payload type range (96-127).</span><br><span style="color: hsl(0, 100%, 40%);">- * Normally the MGW should obey the 3gpp payload type</span><br><span style="color: hsl(0, 100%, 40%);">- * assignments, which are fixed, so we likely wont see</span><br><span style="color: hsl(0, 100%, 40%);">- * anything unexpected here. In order to be sure that</span><br><span style="color: hsl(0, 100%, 40%);">- * we will now check the codec string and if the result</span><br><span style="color: hsl(0, 100%, 40%);">- * does not match to what is IANA / 3gpp assigned, we</span><br><span style="color: hsl(0, 100%, 40%);">- * will create an entry in the ptmap table so we can</span><br><span style="color: hsl(0, 100%, 40%);">- * lookup later what has been assigned. */</span><br><span style="color: hsl(0, 100%, 40%);">- codec = map_str_to_codec(codec_resp);</span><br><span style="color: hsl(0, 100%, 40%);">- if (codec != pt) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (r->ptmap_len >= ARRAY_SIZE(r->ptmap)) {</span><br><span style="color: hsl(0, 100%, 40%);">- LOGP(DLMGCP, LOGL_ERROR, "No more space in ptmap array (len=%u)\n", r->ptmap_len);</span><br><span style="color: hsl(0, 100%, 40%);">- return -ENOSPC;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- r->ptmap[r->ptmap_len].pt = pt;</span><br><span style="color: hsl(0, 100%, 40%);">- r->ptmap[r->ptmap_len].codec = codec;</span><br><span style="color: hsl(0, 100%, 40%);">- r->ptmap_len++;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (r->ptmap_len >= ARRAY_SIZE(r->ptmap)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGP(DLMGCP, LOGL_ERROR, "No more space in ptmap array (len=%u)\n", r->ptmap_len);</span><br><span style="color: hsl(120, 100%, 40%);">+ return -ENOSPC;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ codec = map_str_to_codec(codec_resp);</span><br><span style="color: hsl(120, 100%, 40%);">+ r->ptmap[r->ptmap_len].pt = pt;</span><br><span style="color: hsl(120, 100%, 40%);">+ r->ptmap[r->ptmap_len].codec = codec;</span><br><span style="color: hsl(120, 100%, 40%);">+ r->ptmap_len++;</span><br><span> }</span><br><span> </span><br><span> return 0;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-mgw/+/15141">change 15141</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-mgw/+/15141"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-mgw </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I2a69c21e68c602daf804744212d335ab1eafd81b </div>
<div style="display:none"> Gerrit-Change-Number: 15141 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>