<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/10163">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ipa: if there are PCs in the msg, use them for routing<br><br>patch_sccp_with_pc() overwrites the SCCP addresses' point-codes only if there<br>are none yet in the message.<br><br>ipa_rx_msg_sccp() feeds opc and dpc to patch into the message, and so far uses<br>these opc and dpc in the xua_msg_hdr even if there are different PCs in the<br>SCCP message already, and these opc and dpc were never patched into the msg.<br><br>Change the opc and dpc args of patch_sccp_with_pc() as in+out params, and if<br>not patched into the message, return the opc and dpc actually found in the<br>message.<br><br>Hence in ipa_rx_msg_sccp() compose the m3ua_data_hdr with the point-codes found<br>in the message, instead of those that would have been but were not actually<br>patched into the message and potentially mismatch it.<br><br>Testing with an SCCPlite MSC actually gives me complete SCCP addresses with<br>point-codes, so it is not set in stone to receive no point-codes over IPA.<br><br>If the cs7 vty config matches the point-codes received, there is no problem,<br>but I faced a weird situation when the config is wrong: osmo-bsc logs the PCs<br>received in the message while it confusingly uses the config ones for routing.<br><br>Change-Id: I157c43a5dc12f6e24828efef1dceac246497e313<br>---<br>M src/ipa.c<br>1 file changed, 17 insertions(+), 9 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/63/10163/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/ipa.c b/src/ipa.c</span><br><span>index f3a7a52..dc0c603 100644</span><br><span>--- a/src/ipa.c</span><br><span>+++ b/src/ipa.c</span><br><span>@@ -138,9 +138,10 @@</span><br><span>    return NULL;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* Patch a SCCP message and add point codes to Called/Calling Party (if missing) */</span><br><span style="color: hsl(120, 100%, 40%);">+/* Patch a SCCP message and add point codes to Called/Calling Party (if missing).</span><br><span style="color: hsl(120, 100%, 40%);">+ * If not missing, report back the actually present opc and dpc. */</span><br><span> static struct msgb *patch_sccp_with_pc(struct osmo_ss7_asp *asp, struct msgb *sccp_msg_in,</span><br><span style="color: hsl(0, 100%, 40%);">-                                  uint32_t opc, uint32_t dpc)</span><br><span style="color: hsl(120, 100%, 40%);">+                                  uint32_t *opc, uint32_t *dpc)</span><br><span> {</span><br><span>    struct osmo_sccp_addr addr;</span><br><span>  struct msgb *sccp_msg_out;</span><br><span>@@ -161,11 +162,13 @@</span><br><span>   rc = sua_addr_parse(&addr, sua, SUA_IEI_DEST_ADDR);</span><br><span>      switch (rc) {</span><br><span>        case 0:</span><br><span style="color: hsl(0, 100%, 40%);">-         if (addr.presence & OSMO_SCCP_ADDR_T_PC)</span><br><span style="color: hsl(120, 100%, 40%);">+          if (addr.presence & OSMO_SCCP_ADDR_T_PC) {</span><br><span style="color: hsl(120, 100%, 40%);">+                        *dpc = addr.pc;</span><br><span>                      break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span>            /* if there's no point code in dest_addr, add one */</span><br><span>             addr.presence |= OSMO_SCCP_ADDR_T_PC;</span><br><span style="color: hsl(0, 100%, 40%);">-           addr.pc = dpc;</span><br><span style="color: hsl(120, 100%, 40%);">+                addr.pc = *dpc;</span><br><span>              xua_msg_free_tag(sua, SUA_IEI_DEST_ADDR);</span><br><span>            xua_msg_add_sccp_addr(sua, SUA_IEI_DEST_ADDR, &addr);</span><br><span>            break;</span><br><span>@@ -179,11 +182,13 @@</span><br><span>       rc = sua_addr_parse(&addr, sua, SUA_IEI_SRC_ADDR);</span><br><span>       switch (rc) {</span><br><span>        case 0:</span><br><span style="color: hsl(0, 100%, 40%);">-         if (addr.presence & OSMO_SCCP_ADDR_T_PC)</span><br><span style="color: hsl(120, 100%, 40%);">+          if (addr.presence & OSMO_SCCP_ADDR_T_PC) {</span><br><span style="color: hsl(120, 100%, 40%);">+                        *opc = addr.pc;</span><br><span>                      break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span>            /* if there's no point code in src_addr, add one */</span><br><span>              addr.presence |= OSMO_SCCP_ADDR_T_PC;</span><br><span style="color: hsl(0, 100%, 40%);">-           addr.pc = opc;</span><br><span style="color: hsl(120, 100%, 40%);">+                addr.pc = *opc;</span><br><span>              xua_msg_free_tag(sua, SUA_IEI_SRC_ADDR);</span><br><span>             xua_msg_add_sccp_addr(sua, SUA_IEI_SRC_ADDR, &addr);</span><br><span>             break;</span><br><span>@@ -219,7 +224,7 @@</span><br><span> </span><br><span>     /* We have received an IPA-encapsulated SCCP message, without</span><br><span>         * any MTP routing label.  Furthermore, the SCCP Called/Calling</span><br><span style="color: hsl(0, 100%, 40%);">-  * Party are SSN-only, with no GT or PC.  This means we have no</span><br><span style="color: hsl(120, 100%, 40%);">+        * Party possibly are SSN-only, with no GT or PC.  This means we have no</span><br><span>      * real idea where it came from, nor where it goes to.  We could</span><br><span>      * simply treat it as being for the local point code, but then</span><br><span>        * this means that we would have to implement SCCP connection</span><br><span>@@ -247,10 +252,13 @@</span><br><span>                opc = as->cfg.pc_override.dpc;</span><br><span>            /* Destination: PC of the routing key */</span><br><span>             dpc = as->cfg.routing_key.pc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+            LOGPASP(asp, DLSS7, LOGL_INFO, "Rx message: setting opc=%u dpc=%u\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                       opc, dpc);</span><br><span>   }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   /* Second, patch this into the SCCP message */</span><br><span style="color: hsl(0, 100%, 40%);">-  msg = patch_sccp_with_pc(asp, msg, opc, dpc);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Second, patch this into the SCCP message, if they lack PCs */</span><br><span style="color: hsl(120, 100%, 40%);">+      msg = patch_sccp_with_pc(asp, msg, &opc, &dpc);</span><br><span> </span><br><span>  /* Third, create a MTP3/M3UA label with those point codes */</span><br><span>         memset(&data_hdr, 0, sizeof(data_hdr));</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10163">change 10163</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/10163"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-sccp </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I157c43a5dc12f6e24828efef1dceac246497e313 </div>
<div style="display:none"> Gerrit-Change-Number: 10163 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>