<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-mgw/+/19166">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">mgcp_endp: add function to claim an endpoint<br><br>At the moment where the first CRCX writes the CALLID to the endp struct<br>the endpoint is marked as "serving a call", which could also be<br>described as a "claimed" state. Lets have a function to do that. This<br>way we also create an entry point where the endpoint could call some<br>type specific initalization functions.<br><br>Change-Id: I402ac43dffd2c85789e4f0308a540e227063cc28<br>Related: OS#2659<br>---<br>M include/osmocom/mgcp/mgcp_endp.h<br>M src/libosmo-mgcp/mgcp_endp.c<br>M src/libosmo-mgcp/mgcp_protocol.c<br>3 files changed, 15 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/66/19166/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h</span><br><span>index 879947b..22a1b81 100644</span><br><span>--- a/include/osmocom/mgcp/mgcp_endp.h</span><br><span>+++ b/include/osmocom/mgcp/mgcp_endp.h</span><br><span>@@ -109,6 +109,7 @@</span><br><span> </span><br><span> struct mgcp_endpoint *mgcp_endp_alloc(struct mgcp_trunk *trunk, unsigned int index);</span><br><span> void mgcp_endp_release(struct mgcp_endpoint *endp);</span><br><span style="color: hsl(120, 100%, 40%);">+void mgcp_endp_claim(struct mgcp_endpoint *endp, const char *callid);</span><br><span> struct mgcp_endpoint *mgcp_endp_by_name_trunk(int *cause, const char *epname,</span><br><span>                                         const struct mgcp_trunk *trunk);</span><br><span> struct mgcp_endpoint *mgcp_endp_by_name(int *cause, const char *epname,</span><br><span>diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c</span><br><span>index eac5832..d745aff 100644</span><br><span>--- a/src/libosmo-mgcp/mgcp_endp.c</span><br><span>+++ b/src/libosmo-mgcp/mgcp_endp.c</span><br><span>@@ -151,6 +151,19 @@</span><br><span>        endp->wildcarded_req = false;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! claim endpoint, sets callid and initializes endpoint.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] endp endpoint to release */</span><br><span style="color: hsl(120, 100%, 40%);">+void mgcp_endp_claim(struct mgcp_endpoint *endp, const char *callid)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     /* TODO: Make this function more intelligent, it should run the</span><br><span style="color: hsl(120, 100%, 40%);">+        * call id checks we currently have in protocol.c directly here. */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Set the callid, creation of another connection will only be possible</span><br><span style="color: hsl(120, 100%, 40%);">+        * when the callid matches up. (Connections are distinguished by their</span><br><span style="color: hsl(120, 100%, 40%);">+         * connection ids) */</span><br><span style="color: hsl(120, 100%, 40%);">+ endp->callid = talloc_strdup(endp, callid);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Check if the endpoint name contains the prefix (e.g. "rtpbridge/" or</span><br><span>  * "ds/e1-") and write the epname without the prefix back to the memory</span><br><span>  * pointed at by epname. (per trunk the prefix is the same for all endpoints,</span><br><span>diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c</span><br><span>index f2fc20c..5d9509a 100644</span><br><span>--- a/src/libosmo-mgcp/mgcp_protocol.c</span><br><span>+++ b/src/libosmo-mgcp/mgcp_protocol.c</span><br><span>@@ -855,7 +855,7 @@</span><br><span>    /* Set the callid, creation of another connection will only be possible</span><br><span>       * when the callid matches up. (Connections are distinguished by their</span><br><span>        * connection ids) */</span><br><span style="color: hsl(0, 100%, 40%);">-   endp->callid = talloc_strdup(trunk->endpoints, callid);</span><br><span style="color: hsl(120, 100%, 40%);">+ mgcp_endp_claim(endp, callid);</span><br><span> </span><br><span>   snprintf(conn_name, sizeof(conn_name), "%s", callid);</span><br><span>      _conn = mgcp_conn_alloc(trunk->endpoints, endp, MGCP_CONN_TYPE_RTP, conn_name);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-mgw/+/19166">change 19166</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/+/19166"/><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: I402ac43dffd2c85789e4f0308a540e227063cc28 </div>
<div style="display:none"> Gerrit-Change-Number: 19166 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>