laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38023?usp=email )
Change subject: Introduce a new 'hexstr' type to represent hex-strings
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS3:
mh. now this change broke the master build. Somehow both of the last two builds did not report back here via comments 😞
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38023?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: I16c0df809bc11ec0f98e8ade404f9b82072e3a06
Gerrit-Change-Number: 38023
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Wed, 11 Sep 2024 11:39:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: neels, pespin.
laforge has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/osmo-upf/+/37757?usp=email )
Change subject: pfcp-tool: n-sessions [1/4]: add generators for TEID and UE IP
......................................................................
Patch Set 2:
(1 comment)
File src/osmo-pfcp-tool/pfcp_tool.h:
https://gerrit.osmocom.org/c/osmo-upf/+/37757/comment/116489de_70e78fcf?usp… :
PS2, Line 124: uint32_t pfcp_tool_new_teid(void);
> Acknowledged
I'd love to see this move ahead. But it's been sitting just over a week for something that looks like a very trivial renaming task?
--
To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/37757?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-upf
Gerrit-Branch: master
Gerrit-Change-Id: Iec164a222782d382aefe8d0342f398ebba1eac05
Gerrit-Change-Number: 37757
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 11 Sep 2024 11:21:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Attention is currently required from: neels, pespin.
laforge has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/37808?usp=email )
Change subject: on RUA DT for unknown context, respond with RUA Disconnect
......................................................................
Patch Set 2:
(1 comment)
File src/osmo-hnbgw/hnbgw_rua.c:
https://gerrit.osmocom.org/c/osmo-hnbgw/+/37808/comment/aacfd01e_21baf59f?u… :
PS2, Line 292: goto tx_disconnect;
> I see you are now using it twice, but now we end up with a mixture of early returns and gotos. […]
Acknowledged
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/37808?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: If0b9a999649c9822f55b42b0cae8408af668e1b8
Gerrit-Change-Number: 37808
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 11 Sep 2024 11:19:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Attention is currently required from: neels, pespin.
laforge has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/37807?usp=email )
Change subject: on RUA Connect failure, respond with RUA Disconnect
......................................................................
Patch Set 2:
(1 comment)
File src/osmo-hnbgw/hnbgw_rua.c:
https://gerrit.osmocom.org/c/osmo-hnbgw/+/37807/comment/cf1845c8_d247512f?u… :
PS2, Line 313: tx_disconnect:
> I find this goto here not really useful and adding complexity to the code, since it's only used in o […]
Acknowledged
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/37807?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Iafb30c31a4c5db53ecdda99a0e0b5937b71e362c
Gerrit-Change-Number: 37807
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 11 Sep 2024 11:18:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38023?usp=email )
Change subject: Introduce a new 'hexstr' type to represent hex-strings
......................................................................
Introduce a new 'hexstr' type to represent hex-strings
hexstr differs from str in that comparisons are case-insensitive, and it
offers encoding-free conversion from hexstr to bytes and vice-versa.
Change-Id: I16c0df809bc11ec0f98e8ade404f9b82072e3a06
---
M src/osmocom/utils.py
A tests/test_utils.py
2 files changed, 88 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, approved; Verified
fixeria: Looks good to me, but someone else must approve
diff --git a/src/osmocom/utils.py b/src/osmocom/utils.py
index cbcdd46..183bbb8 100644
--- a/src/osmocom/utils.py
+++ b/src/osmocom/utils.py
@@ -138,6 +138,36 @@
except:
return False
+class hexstr(str):
+ """Class derived from 'str', represeting a string of hexadecimal digits. It differs in that
+ comparisons are case-insensitive, and it offers encoding-free conversion from hexstr to bytes
+ and vice-versa."""
+ def __new__(cls, s: str):
+ if not all(c in string.hexdigits for c in s):
+ raise ValueError('Input must be hexadecimal digits only')
+ # store as lower case digits
+ return super().__new__(cls, s.lower())
+
+ def __eq__(self, other: str) -> bool:
+ # make sure comparison is done case-insensitive
+ return str(self) == other.lower()
+
+ def __getitem__(self, val) -> 'hexstr':
+ # make sure slicing a hexstr will return a hexstr
+ return hexstr(super().__getitem__(val))
+
+ def to_bytes(self) -> bytes:
+ """return hex-string converted to bytes"""
+ s = str(self)
+ if len(s) & 1:
+ raise ValueError('Cannot convert hex string with odd number of digits')
+ return h2b(s)
+
+ @classmethod
+ def from_bytes(cls, bt: bytes) -> 'hexstr':
+ """instantiate hex-string from bytes"""
+ return cls(b2h(bt))
+
#########################################################################
# ARGPARSE HELPERS
#########################################################################
diff --git a/tests/test_utils.py b/tests/test_utils.py
new file mode 100755
index 0000000..8e4732f
--- /dev/null
+++ b/tests/test_utils.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+
+# (C) 2022 by Harald Welte <laforge(a)osmocom.org>
+# All Rights Reserved
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import unittest
+
+from osmocom.utils import *
+
+class TestHexstr(unittest.TestCase):
+ def test_cmp(self):
+ s = hexstr('aBcD')
+ self.assertEqual(s, 'abcd')
+ self.assertEqual(s, 'ABCD')
+ self.assertEqual(s, 'AbCd')
+ self.assertEqual(s, hexstr('AbCd'))
+
+ def test_tobytes(self):
+ s = hexstr('aBcDeF')
+ self.assertEqual(s.to_bytes(), b'\xab\xcd\xef')
+
+ def test_tobytes_odd(self):
+ s2 = hexstr('aBc')
+ with self.assertRaises(ValueError):
+ s2.to_bytes()
+
+ def test_frombytes(self):
+ s = hexstr.from_bytes(b'\x01\x02\xaa')
+ self.assertEqual(s, '0102aa')
+
+ def test_slice(self):
+ s = hexstr('abcdef')
+ slice1 = s[-2:]
+ self.assertTrue(isinstance(slice1, hexstr))
+ self.assertEqual(slice1, 'ef')
+ slice2 = s[1]
+ self.assertTrue(isinstance(slice2, hexstr))
+ self.assertEqual(slice2, 'b')
+
+ def test_str_lower(self):
+ self.assertEqual(str(hexstr('ABCD')), 'abcd')
+
+
+if __name__ == "__main__":
+ unittest.main()
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38023?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: python/pyosmocom
Gerrit-Branch: master
Gerrit-Change-Id: I16c0df809bc11ec0f98e8ade404f9b82072e3a06
Gerrit-Change-Number: 38023
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Attention is currently required from: pespin.
laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/python/pyosmocom/+/38023?usp=email )
Change subject: Introduce a new 'hexstr' type to represent hex-strings
......................................................................
Patch Set 3: Code-Review+2 Verified+1
--
To view, visit https://gerrit.osmocom.org/c/python/pyosmocom/+/38023?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: I16c0df809bc11ec0f98e8ade404f9b82072e3a06
Gerrit-Change-Number: 38023
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 11 Sep 2024 11:17:11 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: dexter, fixeria, pespin.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/osmo-bsc/+/38091?usp=email )
Change subject: pcuif: fix TXT_IND/PCU_VERSION BTS initialization behavior
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
I'm really not hapyp with *again* incrementing the PCU interface version and *again* creating incompatibility, forcing everyone to update BTS+PCU or BSC+PCU at the same time. At the same time, I don't understand right now fully if we have any alternatives that would not break compatibility, so I won't veto it. But let me say I'm strongly advising against it.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/38091?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ie92f5833a80b06e78c6cec8f03f054e2e2625fad
Gerrit-Change-Number: 38091
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 11 Sep 2024 11:14:17 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No