pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39206?usp=email )
Change subject: mgcp_endp: Add helpers accessing endp connections
......................................................................
mgcp_endp: Add helpers accessing endp connections
This has several benefits:
* easily improving/changing the impelemntation later on (eg. by storing
a count instead of iterating the whole list).
* Remove code complexity from mgcp_protocol.c.
Change-Id: I77c298abf0a1488b91f58c9e76507ef8add0168e
---
M include/osmocom/mgcp/mgcp_endp.h
M src/libosmo-mgcp/mgcp_endp.c
M src/libosmo-mgcp/mgcp_protocol.c
3 files changed, 25 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/06/39206/1
diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index 5ecebda..fbe0850 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -139,6 +139,8 @@
struct mgcp_endpoint *mgcp_endp_by_name(int *cause, const char *epname,
struct mgcp_config *cfg);
bool mgcp_endp_avail(const struct mgcp_endpoint *endp);
+unsigned int mgcp_endp_num_conns(const struct mgcp_endpoint *endp);
+bool mgcp_endp_is_full(const struct mgcp_endpoint *endp);
void mgcp_endp_add_conn(struct mgcp_endpoint *endp, struct mgcp_conn *conn);
void mgcp_endp_remove_conn(struct mgcp_endpoint *endp, struct mgcp_conn *conn);
void mgcp_endp_free_conn_oldest(struct mgcp_endpoint *endp);
diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c
index 4c51266..5653168 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -569,6 +569,24 @@
return false;
}
+/*! Get number of conns in an endpoint.
+ * \param[in] endp endpoint to check.
+ * \returns Number of connections present in the endpoint. */
+unsigned int mgcp_endp_num_conns(const struct mgcp_endpoint *endp)
+{
+ return llist_count(&endp->conns);
+}
+
+/*! check if an endpoint can in current state allocate new conns.
+ * \param[in] endp endpoint to check.
+ * \returns true if more connections can be allowed on endpoint, false if it is already busy. */
+bool mgcp_endp_is_full(const struct mgcp_endpoint *endp)
+{
+ if (endp->type->max_conns == 0)
+ return false;
+ return mgcp_endp_num_conns(endp) >= endp->type->max_conns;
+}
+
/*! claim endpoint, sets callid and activates endpoint, should be called at the
* beginning of the CRCX procedure when it is clear that a new call should be
* created.
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 4e63e4d..4c8f47c 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -967,7 +967,7 @@
}
/* Check if we are able to accept the creation of another connection */
- if (endp->type->max_conns > 0 && llist_count(&endp->conns) >= endp->type->max_conns) {
+ if (mgcp_endp_is_full(endp)) {
LOGPENDP(endp, DLMGCP, LOGL_ERROR,
"CRCX: endpoint full, max. %i connections allowed!\n",
endp->type->max_conns);
@@ -1173,7 +1173,7 @@
LOGPENDP(endp, DLMGCP, LOGL_ERROR, "MDCX: selected endpoint not available!\n");
return create_err_response(rq->trunk, NULL, 501, "MDCX", pdata->trans);
}
- if (llist_count(&endp->conns) <= 0) {
+ if (mgcp_endp_num_conns(endp) <= 0) {
LOGPENDP(endp, DLMGCP, LOGL_ERROR,
"MDCX: endpoint is not holding a connection.\n");
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_MDCX_FAIL_NO_CONN));
@@ -1396,7 +1396,7 @@
if (rq->wildcarded) {
int num_conns = 0;
for (i = 0; i < trunk->number_endpoints; i++) {
- num_conns += llist_count(&trunk->endpoints[i]->conns);
+ num_conns += mgcp_endp_num_conns(trunk->endpoints[i]);
mgcp_endp_release(trunk->endpoints[i]);
}
rate_ctr_add(rate_ctr_group_get_ctr(rate_ctrs, MGCP_DLCX_SUCCESS), num_conns);
@@ -1458,7 +1458,7 @@
* that we drop all connections on that specific endpoint at once.
* (See also RFC3435 Section F.7) */
if (!conn_id) {
- int num_conns = llist_count(&endp->conns);
+ int num_conns = mgcp_endp_num_conns(endp);
LOGPENDP(endp, DLMGCP, LOGL_NOTICE,
"DLCX: missing ci (connectionIdentifier), will remove all connections (%d total) at once\n",
num_conns);
@@ -1492,7 +1492,7 @@
/* When all connections are closed, the endpoint will be released
* in order to be ready to be used by another call. */
- if (llist_count(&endp->conns) <= 0) {
+ if (mgcp_endp_num_conns(endp) <= 0) {
mgcp_endp_release(endp);
LOGPENDP(endp, DLMGCP, LOGL_DEBUG, "DLCX: endpoint released\n");
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39206?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I77c298abf0a1488b91f58c9e76507ef8add0168e
Gerrit-Change-Number: 39206
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39205?usp=email )
Change subject: mgw: constify mgcp_endp_avail() param
......................................................................
mgw: constify mgcp_endp_avail() param
Change-Id: I31ed2f3abbcf024ee44f62e130dd4ec01611ae97
---
M include/osmocom/mgcp/mgcp_endp.h
M src/libosmo-mgcp/mgcp_endp.c
2 files changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/05/39205/1
diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h
index 4f41818..5ecebda 100644
--- a/include/osmocom/mgcp/mgcp_endp.h
+++ b/include/osmocom/mgcp/mgcp_endp.h
@@ -138,7 +138,7 @@
const struct mgcp_trunk *trunk);
struct mgcp_endpoint *mgcp_endp_by_name(int *cause, const char *epname,
struct mgcp_config *cfg);
-bool mgcp_endp_avail(struct mgcp_endpoint *endp);
+bool mgcp_endp_avail(const struct mgcp_endpoint *endp);
void mgcp_endp_add_conn(struct mgcp_endpoint *endp, struct mgcp_conn *conn);
void mgcp_endp_remove_conn(struct mgcp_endpoint *endp, struct mgcp_conn *conn);
void mgcp_endp_free_conn_oldest(struct mgcp_endpoint *endp);
diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c
index c91a00d..4c51266 100644
--- a/src/libosmo-mgcp/mgcp_endp.c
+++ b/src/libosmo-mgcp/mgcp_endp.c
@@ -446,7 +446,7 @@
/* Check if the selected E1 endpoint is avalable, which means that none of
* the overlapping endpoints are currently serving a call. (if the system
* is properly configured such a situation should never ocurr!) */
-static bool endp_avail_e1(struct mgcp_endpoint *endp)
+static bool endp_avail_e1(const struct mgcp_endpoint *endp)
{
/* The following map shows the overlapping of the subslots and their
* respective rates. The numbers on the right running from top to bottom
@@ -522,7 +522,7 @@
break;
/* Pick overlapping endpoint to check */
- epname_check = gen_e1_epname(endp, endp->trunk->cfg->domain,
+ epname_check = gen_e1_epname(NULL, endp->trunk->cfg->domain,
endp->trunk->trunk_nr, ts_nr,
interlock[i]);
endp_check = mgcp_endp_find_specific(epname_check, endp->trunk);
@@ -552,7 +552,7 @@
/*! check if an endpoint is available for any kind of operation.
* \param[in] endp endpoint to check.
* \returns true if endpoint is avalable, false it is blocked for any reason. */
-bool mgcp_endp_avail(struct mgcp_endpoint *endp)
+bool mgcp_endp_avail(const struct mgcp_endpoint *endp)
{
switch (endp->trunk->trunk_type) {
case MGCP_TRUNK_VIRTUAL:
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39205?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I31ed2f3abbcf024ee44f62e130dd4ec01611ae97
Gerrit-Change-Number: 39205
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Attention is currently required from: fixeria, laforge.
laforge has posted comments on this change by fixeria. ( https://gerrit.osmocom.org/c/libosmo-gprs/+/39187?usp=email )
Change subject: rlcmac: fix EGPRS BEP Link Quality Measurements Type 2
......................................................................
Patch Set 1: Code-Review+1
(1 comment)
Commit Message:
https://gerrit.osmocom.org/c/libosmo-gprs/+/39187/comment/60817bd2_126d9974… :
PS1, Line 9: is IE is defined in 3GPP TS 44.060 Table 12.5a.2.1.
might manke sense to add the spec reference directly above the struct definition?
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/39187?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: Iac4de18ef25386f774bb409201b7a7996d1c8824
Gerrit-Change-Number: 39187
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Sat, 21 Dec 2024 13:31:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes