Attention is currently required from: laforge.
Hello Jenkins Builder, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/python/pyosmocom/+/39193?usp=email
to look at the new patch set (#4).
Change subject: construct: allow stripping of leading zeros with StripHeaderAdapter
......................................................................
construct: allow stripping of leading zeros with StripHeaderAdapter
This patch adds a new class StripHeaderAdapter. This adapter class can
be used to strip leading zeros in the same way that StripTrailerAdapter
strips trailing zeros.
Related: OS#6679
Change-Id: I1a9fff17abbbef0c5f6d45f58198debfa12e78b6
---
M src/osmocom/construct.py
M tests/test_construct.py
2 files changed, 89 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/python/pyosmocom refs/changes/93/39193/4
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/39193?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: I1a9fff17abbbef0c5f6d45f58198debfa12e78b6
Gerrit-Change-Number: 39193
Gerrit-PatchSet: 4
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Attention is currently required from: laforge.
dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/39193?usp=email )
Change subject: construct: allow stripping of leading zeros with StripTrailerAdapter
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS2:
> please implement this as a new adapter. […]
I had that in mind too, but I wasn't sure if this would create too much code dup. I have added StripHeaderAdapter now. However, I am not sure about how much code we could really put into a base class. As far as I can see only the constructor could be shared. The majority of the code is very similar, but it is different. I think we should keep it like that.
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/39193?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: I1a9fff17abbbef0c5f6d45f58198debfa12e78b6
Gerrit-Change-Number: 39193
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Thu, 02 Jan 2025 13:16:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Attention is currently required from: laforge.
Hello Jenkins Builder, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/python/pyosmocom/+/39193?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Code-Review-1 by laforge, Verified+1 by Jenkins Builder
Change subject: construct: allow stripping of leading zeros with StripTrailerAdapter
......................................................................
construct: allow stripping of leading zeros with StripTrailerAdapter
The class StripTrailerAdapter is currently only able to strip zeros at the end
of an integer. What it can not do is stripping leading zeros. Let's add a
parameter for that and extend the unittests accordingly.
Related: OS#6679
Change-Id: I1a9fff17abbbef0c5f6d45f58198debfa12e78b6
---
M src/osmocom/construct.py
M tests/test_construct.py
2 files changed, 89 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/python/pyosmocom refs/changes/93/39193/3
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/39193?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: I1a9fff17abbbef0c5f6d45f58198debfa12e78b6
Gerrit-Change-Number: 39193
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
dexter has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/39194?usp=email )
Change subject: javacard, cosmetic: fix sourcecode fromatting and improve docstring
......................................................................
javacard, cosmetic: fix sourcecode fromatting and improve docstring
The line with TAGS is longer than 120 columns and there is some
comment that should be moved to the python docstring.
Related: OS#6679
Change-Id: I1d02098320cfbe17a0eb1bfdcf3bc85034cc8e20
---
M pySim/javacard.py
1 file changed, 7 insertions(+), 5 deletions(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim/javacard.py b/pySim/javacard.py
index 46f6ec0..07b0f39 100644
--- a/pySim/javacard.py
+++ b/pySim/javacard.py
@@ -6,14 +6,16 @@
import io
def ijc_to_cap(in_file: io.IOBase, out_zip: zipfile.ZipFile, p : str = "foo"):
- """Convert an ICJ (Interoperable Java Card) file [back] to a CAP file."""
- TAGS = ["Header", "Directory", "Applet", "Import", "ConstantPool", "Class", "Method", "StaticField", "RefLocation", "Export", "Descriptor", "Debug"]
+ """Convert an ICJ (Interoperable Java Card) file [back] to a CAP file.
+ example usage:
+ with io.open(sys.argv[1],"rb") as f, zipfile.ZipFile(sys.argv[2], "wb") as z:
+ ijc_to_cap(f, z)
+ """
+ TAGS = ["Header", "Directory", "Applet", "Import", "ConstantPool", "Class", "Method", "StaticField", "RefLocation",
+ "Export", "Descriptor", "Debug"]
b = in_file.read()
while len(b):
tag, size = struct.unpack('!BH', b[0:3])
out_zip.writestr(p+"/javacard/"+TAGS[tag-1]+".cap", b[0:3+size])
b = b[3+size:]
-# example usage:
-# with io.open(sys.argv[1],"rb") as f, zipfile.ZipFile(sys.argv[2], "wb") as z:
-# ijc_to_cap(f, z)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/39194?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1d02098320cfbe17a0eb1bfdcf3bc85034cc8e20
Gerrit-Change-Number: 39194
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39223?usp=email )
Change subject: Rename and cleanup code allocating rtp/rtcp ports in trunk
......................................................................
Rename and cleanup code allocating rtp/rtcp ports in trunk
Clean up pointers passed. Rename function since it's clearly operating
on trunk related fields through mutexes.
Change-Id: Ib894afcb61609c247883d5ccdd7b8fbf29b2cbf8
---
M include/osmocom/mgcp/mgcp_trunk.h
M src/libosmo-mgcp/mgcp_protocol.c
M src/libosmo-mgcp/mgcp_trunk.c
3 files changed, 45 insertions(+), 43 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/23/39223/1
diff --git a/include/osmocom/mgcp/mgcp_trunk.h b/include/osmocom/mgcp/mgcp_trunk.h
index 68d37dd..8d87954 100644
--- a/include/osmocom/mgcp/mgcp_trunk.h
+++ b/include/osmocom/mgcp/mgcp_trunk.h
@@ -2,9 +2,10 @@
#include <osmocom/gsm/i460_mux.h>
#include <osmocom/abis/e1_input.h>
+#include <osmocom/mgcp/mgcp_conn.h>
+#include <osmocom/mgcp/mgcp_network.h>
#include <osmocom/mgcp/mgcp_ratectr.h>
-
#define LOGPTRUNK(trunk, cat, level, fmt, args...) \
LOGP(cat, level, "trunk:%u " fmt, \
trunk ? trunk->trunk_nr : 0, \
@@ -78,6 +79,7 @@
struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char *epname);
int e1_trunk_nr_from_epname(unsigned int *trunk_nr, const char *epname);
struct mgcp_trunk *mgcp_trunk_by_line_num(const struct mgcp_config *cfg, unsigned int num);
+int mgcp_trunk_allocate_conn_rtp_ports(struct mgcp_trunk *trunk, struct mgcp_conn_rtp *conn);
/* The virtual trunk is always created on trunk id 0 for historical reasons,
* use this define constant as ID when allocating a virtual trunk. Other
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 3efa0e0..32fbd43 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -489,46 +489,6 @@
return create_ok_response(rq->trunk, rq->endp, 200, "AUEP", rq->pdata->trans);
}
-/* Try to find a free port by attempting to bind on it. Also handle the
- * counter that points on the next free port. Since we have a pointer
- * to the next free port, binding should in work on the first attempt in
- * general. In case of failure the next port is tried until the whole port
- * range is tried once. */
-static int allocate_port(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn)
-{
- int i;
- struct mgcp_port_range *range;
- unsigned int tries;
-
- OSMO_ASSERT(conn);
-
- range = &endp->trunk->cfg->net_ports;
-
- pthread_mutex_lock(&range->lock);
- /* attempt to find a port */
- tries = (range->range_end - range->range_start) / 2;
- for (i = 0; i < tries; ++i) {
- int rc;
-
- if (range->last_port >= range->range_end)
- range->last_port = range->range_start;
-
- rc = mgcp_conn_rtp_bind_rtp_ports(conn, range->last_port);
-
- range->last_port += 2;
- if (rc == 0) {
- pthread_mutex_unlock(&range->lock);
- return 0;
- }
-
- }
- pthread_mutex_unlock(&range->lock);
- LOGPENDP(endp, DLMGCP, LOGL_ERROR,
- "Allocating a RTP/RTCP port failed %u times.\n",
- tries);
- return -1;
-}
-
/*! Helper function for check_local_cx_options() to get a pointer of the next
* lco option identifier
* \param[in] lco string
@@ -1077,7 +1037,7 @@
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_BIND_PORT));
goto error2;
}
- if (allocate_port(endp, conn_rtp) != 0) {
+ if (mgcp_trunk_allocate_conn_rtp_ports(trunk, conn_rtp) != 0) {
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_BIND_PORT));
goto error2;
}
@@ -1311,7 +1271,7 @@
if (strcmp(new_local_addr, conn_rtp->end.local_addr)) {
osmo_strlcpy(conn_rtp->end.local_addr, new_local_addr, sizeof(conn_rtp->end.local_addr));
mgcp_rtp_end_free_port(&conn_rtp->end);
- if (allocate_port(endp, conn_rtp) != 0) {
+ if (mgcp_trunk_allocate_conn_rtp_ports(trunk, conn_rtp) != 0) {
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_BIND_PORT));
goto error3;
}
diff --git a/src/libosmo-mgcp/mgcp_trunk.c b/src/libosmo-mgcp/mgcp_trunk.c
index 69750f8..8d258e2 100644
--- a/src/libosmo-mgcp/mgcp_trunk.c
+++ b/src/libosmo-mgcp/mgcp_trunk.c
@@ -306,3 +306,43 @@
return NULL;
}
+
+/* Try to find a free port by attempting to bind on it. Also handle the
+ * counter that points on the next free port. Since we have a pointer
+ * to the next free port, binding should in work on the first attempt in
+ * general. In case of failure the next port is tried until the whole port
+ * range is tried once. */
+int mgcp_trunk_allocate_conn_rtp_ports(struct mgcp_trunk *trunk, struct mgcp_conn_rtp *conn)
+{
+ int i;
+ struct mgcp_port_range *range;
+ unsigned int tries;
+
+ OSMO_ASSERT(trunk);
+ OSMO_ASSERT(conn);
+
+ range = &trunk->cfg->net_ports;
+
+ pthread_mutex_lock(&range->lock);
+ /* attempt to find a port */
+ tries = (range->range_end - range->range_start) / 2;
+ for (i = 0; i < tries; ++i) {
+ int rc;
+
+ if (range->last_port >= range->range_end)
+ range->last_port = range->range_start;
+
+ rc = mgcp_conn_rtp_bind_rtp_ports(conn, range->last_port);
+
+ range->last_port += 2;
+ if (rc == 0) {
+ pthread_mutex_unlock(&range->lock);
+ return 0;
+ }
+
+ }
+ pthread_mutex_unlock(&range->lock);
+ LOGPCONN(conn->conn, DLMGCP, LOGL_ERROR,
+ "Allocating a RTP/RTCP port failed %u times.\n", tries);
+ return -1;
+}
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39223?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: Ib894afcb61609c247883d5ccdd7b8fbf29b2cbf8
Gerrit-Change-Number: 39223
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>