lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

September 2024

  • 1 participants
  • 1983 discussions
[XS] Change in libosmo-netif[master]: src/stream.c: Use sctp_assoc_id 'canary' to detect misisng sinfo
by laforge 03 Sep '24

03 Sep '24
laforge has posted comments on this change by laforge. ( https://gerrit.osmocom.org/c/libosmo-netif/+/38004?usp=email ) Change subject: src/stream.c: Use sctp_assoc_id 'canary' to detect misisng sinfo ...................................................................... Patch Set 1: -Verified -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/38004?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: Idf9c0fa4db65ab6ea34a9cb2011400aadf3dd54e Gerrit-Change-Number: 38004 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 03 Sep 2024 21:35:27 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[S] Change in pysim[master]: commands: avoid double lchan patching, get rid of cla_byte getter+set...
by laforge 03 Sep '24

03 Sep '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37937?usp=email ) Change subject: commands: avoid double lchan patching, get rid of cla_byte getter+setter methods ...................................................................... commands: avoid double lchan patching, get rid of cla_byte getter+setter methods The SimCardCommands has a cla_byte @property method, which automatically returns the lchan patched CLA byte. We use cla_byte property to build the UICC command APDUs inside SimCardCommands and then we hand the APDU over to the send_apdu* methods. The cla_byte @property method as well as the send_apdu* methods perform the lchan patching. This means the CLA byte gets patched twice, which is technically not an issue, but can be confusing when trying to understand the code. To fix this, let's remove the @property methods and turn cla_byte into a normal property again. This is also more accurate since the cla_byte property originally was introduced to switch between UICC and classic SIM APDU commands, which have almost identcal APDUs. Related: OS#6531 Change-Id: I420f8a5f7ff8d9e5ef94d6519fb3716d6c7caf64 --- M pySim/commands.py 1 file changed, 1 insertion(+), 12 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/commands.py b/pySim/commands.py index 656f71a..f13e18b 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -66,7 +66,6 @@ byte by the respective instance. """ def __init__(self, transport: LinkBase, lchan_nr: int = 0): self._tp = transport - self._cla_byte = None self.sel_ctrl = "0000" self.lchan_nr = lchan_nr # invokes the setter below @@ -76,16 +75,11 @@ def fork_lchan(self, lchan_nr: int) -> 'SimCardCommands': """Fork a per-lchan specific SimCardCommands instance off the current instance.""" ret = SimCardCommands(transport = self._tp, lchan_nr = lchan_nr) - ret.cla_byte = self._cla_byte + ret.cla_byte = self.cla_byte ret.sel_ctrl = self.sel_ctrl return ret @property - def cla_byte(self) -> Hexstr: - """Return the lchan patched default CLA value for this card.""" - return cla_with_lchan(self._cla_byte, self.lchan_nr) - - @property def max_cmd_len(self) -> int: """Maximum length of the command apdu data section. Depends on secure channel protocol used.""" if self.scp: @@ -93,11 +87,6 @@ else: return 255 - @cla_byte.setter - def cla_byte(self, new_val: Hexstr): - """Set the (raw, without lchan) default CLA value for this card.""" - self._cla_byte = new_val - def send_apdu(self, pdu: Hexstr, apply_lchan:bool = True) -> ResTuple: """Sends an APDU and auto fetch response data -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37937?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: I420f8a5f7ff8d9e5ef94d6519fb3716d6c7caf64 Gerrit-Change-Number: 37937 Gerrit-PatchSet: 4 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[S] Change in pysim[master]: commands: avoid double lchan patching, get rid of cla_byte getter+set...
by laforge 03 Sep '24

03 Sep '24
Attention is currently required from: dexter, fixeria. laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/37937?usp=email ) Change subject: commands: avoid double lchan patching, get rid of cla_byte getter+setter methods ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37937?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I420f8a5f7ff8d9e5ef94d6519fb3716d6c7caf64 Gerrit-Change-Number: 37937 Gerrit-PatchSet: 3 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Tue, 03 Sep 2024 21:17:15 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in pysim[master]: pySim.esim.saip: Another naming irregularity.
by laforge 03 Sep '24

03 Sep '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/38010?usp=email ) Change subject: pySim.esim.saip: Another naming irregularity. ...................................................................... pySim.esim.saip: Another naming irregularity. The choice member is called df-5gprose but the header is called 'df-5g-prose-header' (note the '-' between '5g' and 'prose'). WTF. Change-Id: I86004ac2e18a187c26c5e470344908512d21fb9e --- M pySim/esim/saip/__init__.py 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index bf39025..7b4d04e 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -386,6 +386,7 @@ 'pukCodes': 'puk-Header', 'pinCodes': 'pin-Header', 'securityDomain': 'sd-Header', + 'df-5gprose': 'df-5g-prose-header', } def __init__(self, decoded = None, mandated: bool = True, -- To view, visit https://gerrit.osmocom.org/c/pysim/+/38010?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: I86004ac2e18a187c26c5e470344908512d21fb9e Gerrit-Change-Number: 38010 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[XS] Change in pysim[master]: pySim.esim.saip: Add missing initialization of File.df_name
by laforge 03 Sep '24

03 Sep '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/38011?usp=email ) Change subject: pySim.esim.saip: Add missing initialization of File.df_name ...................................................................... pySim.esim.saip: Add missing initialization of File.df_name Change-Id: Iaf596a8914850ccae584c3b78dc7711db736ac80 --- M pySim/esim/saip/__init__.py 1 file changed, 1 insertion(+), 0 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 7b4d04e..f934a01 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -114,6 +114,7 @@ self.nb_rec: Optional[int] = None self.high_update: bool = False self.shareable: bool = True + self.df_name = None # apply some defaults from profile if self.template: self.from_template(self.template) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/38011?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: Iaf596a8914850ccae584c3b78dc7711db736ac80 Gerrit-Change-Number: 38011 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[S] Change in pysim[master]: pySim.esim.saip.File: Turn file_size into a computed property
by laforge 03 Sep '24

03 Sep '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/38012?usp=email ) Change subject: pySim.esim.saip.File: Turn file_size into a computed property ...................................................................... pySim.esim.saip.File: Turn file_size into a computed property This way, we can use file_size for both record-oriented and transparent EF Change-Id: Ib787cabe969202073a8c10042e200f3d2c29db73 --- M pySim/esim/saip/__init__.py 1 file changed, 14 insertions(+), 3 deletions(-) Approvals: fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index f934a01..88d7755 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -112,6 +112,7 @@ self.arr = None self.rec_len: Optional[int] = None self.nb_rec: Optional[int] = None + self._file_size = 0 self.high_update: bool = False self.shareable: bool = True self.df_name = None @@ -129,6 +130,16 @@ return self.template.name return None + @property + def file_size(self) -> Optional[int]: + """Return the size of the file in bytes.""" + if self.file_type in ['LF', 'CY']: + return self.nb_rec * self.rec_len + elif self.file_type in ['TR', 'BT']: + return self._file_size + else: + return None + @staticmethod def get_tuplelist_item(l: List[Tuple], key: str): """get the [first] value matching given key from a list of (key, value) tuples.""" @@ -194,7 +205,7 @@ if self.file_type in ['LF', 'CY']: fdb_dec['file_type'] = 'working_ef' if self.nb_rec and self.rec_len: - fileDescriptor['efFileSize'] = self._encode_file_size(self.nb_rec * self.rec_len) + fileDescriptor['efFileSize'] = self._encode_file_size(self.file_size) if self.file_type == 'LF': fdb_dec['structure'] = 'linear_fixed' elif self.file_type == 'CY': @@ -263,7 +274,7 @@ if fdb_dec['file_type'] == 'working_ef': efFileSize = fileDescriptor.get('efFileSize', None) if efFileSize: - self.file_size = self._decode_file_size(efFileSize) + self._file_size = self._decode_file_size(efFileSize) if fd_dec['num_of_rec']: self.nb_rec = fd_dec['num_of_rec'] if fd_dec['record_len']: @@ -277,7 +288,7 @@ elif fdb_dec['structure'] == 'ber_tlv': self.file_type = 'BT' if 'maximumFileSize' in pefi: - self.file_size = self._decode_file_size(pefi['maximumFileSize']) + self._file_size = self._decode_file_size(pefi['maximumFileSize']) specialFileInformation = pefi.get('specialFileInformation', None) if specialFileInformation: if specialFileInformation[0] & 0x80: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/38012?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: Ib787cabe969202073a8c10042e200f3d2c29db73 Gerrit-Change-Number: 38012 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[XS] Change in pysim[master]: esim.saip.templates: Fix expand_default_value_pattern for length==0
by laforge 03 Sep '24

03 Sep '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/38016?usp=email ) ( 1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: esim.saip.templates: Fix expand_default_value_pattern for length==0 ...................................................................... esim.saip.templates: Fix expand_default_value_pattern for length==0 The original code treated length==0 like length==None (unspecified), which is wrong. Change-Id: I39fa1e2b1b9d6d1c671ea37bdbec1d6f97e8a5e7 --- M pySim/esim/saip/templates.py 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/saip/templates.py b/pySim/esim/saip/templates.py index 04b2cd4..f69ec7a 100644 --- a/pySim/esim/saip/templates.py +++ b/pySim/esim/saip/templates.py @@ -117,9 +117,9 @@ def expand_default_value_pattern(self, length: Optional[int] = None) -> Optional[bytes]: """Expand the default value pattern to the specified length.""" - if not length: + if length is None: length = self._default_value_len() - if not length: + if length is None: raise ValueError("%s does not have a default length" % self) if not self.default_val: return None -- To view, visit https://gerrit.osmocom.org/c/pysim/+/38016?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: I39fa1e2b1b9d6d1c671ea37bdbec1d6f97e8a5e7 Gerrit-Change-Number: 38016 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[XS] Change in pysim[master]: pySim.esim.saip.ProfileElementGFM: Initialize 'fileManagementCMD'
by laforge 03 Sep '24

03 Sep '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/38013?usp=email ) Change subject: pySim.esim.saip.ProfileElementGFM: Initialize 'fileManagementCMD' ...................................................................... pySim.esim.saip.ProfileElementGFM: Initialize 'fileManagementCMD' When constructing a ProfileElmentGFM from scratch, initialize the decoded['fileManagementCMD'], as it is a mandatory member during ASN.1 encode. Change-Id: Iaae99348d36b7f0c739daf039d6ea2305b7ca9db --- M pySim/esim/saip/__init__.py 1 file changed, 3 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 88d7755..658810a 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -622,6 +622,9 @@ # indexed by PE-Name self.files = {} self.tdef = asn1.types['ProfileElement'].type.name_to_member[self.type] + if decoded: + return + self.decoded['fileManagementCMD'] = [] def supports_file_for_path(self, path: Path, adf: Optional[str] = None) -> bool: """Does this ProfileElement support a file of given path?""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/38013?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: Iaae99348d36b7f0c739daf039d6ea2305b7ca9db Gerrit-Change-Number: 38013 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[XS] Change in pysim[master]: contrib/jenkins.sh: Install dependencies before calling pylint
by laforge 03 Sep '24

03 Sep '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37966?usp=email ) Change subject: contrib/jenkins.sh: Install dependencies before calling pylint ...................................................................... contrib/jenkins.sh: Install dependencies before calling pylint This is the only way we can make sure pylint has all required information about imports from packages we depend upon. Change-Id: I29582aa3d7f9ace9ce832d5b907420aaf14881fb --- M contrib/jenkins.sh 1 file changed, 6 insertions(+), 0 deletions(-) Approvals: fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh index b3d83dd..5356fcb 100755 --- a/contrib/jenkins.sh +++ b/contrib/jenkins.sh @@ -51,6 +51,12 @@ "pylint") # Print pylint version pip3 freeze | grep pylint + + virtualenv -p python3 venv --system-site-packages + . venv/bin/activate + + pip install . + # Run pylint to find potential errors # Ignore E1102: not-callable # pySim/filesystem.py: E1102: method is not callable (not-callable) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37966?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: I29582aa3d7f9ace9ce832d5b907420aaf14881fb Gerrit-Change-Number: 37966 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
1 0
0 0
[M] Change in pysim[master]: remove pySim.gsmtap as it has moved to osmopython.gsmtap
by laforge 03 Sep '24

03 Sep '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37967?usp=email ) Change subject: remove pySim.gsmtap as it has moved to osmopython.gsmtap ...................................................................... remove pySim.gsmtap as it has moved to osmopython.gsmtap Change-Id: I631bb85bc6e76b089004d9f2e2082d70cbccf200 --- M pySim/apdu_source/gsmtap.py M pySim/apdu_source/pyshark_gsmtap.py M pySim/apdu_source/tca_loader_log.py D pySim/gsmtap.py M requirements.txt M setup.py 6 files changed, 5 insertions(+), 221 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/pySim/apdu_source/gsmtap.py b/pySim/apdu_source/gsmtap.py index bc2f4f8..65fb45d 100644 --- a/pySim/apdu_source/gsmtap.py +++ b/pySim/apdu_source/gsmtap.py @@ -16,7 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -from pySim.gsmtap import GsmtapSource +from osmocom.gsmtap import GsmtapReceiver from pySim.apdu.ts_102_221 import ApduCommands as UiccApduCommands from pySim.apdu.ts_102_222 import ApduCommands as UiccAdmApduCommands @@ -41,7 +41,7 @@ bind_port: UDP port number to which the socket should be bound (default: 4729) """ super().__init__() - self.gsmtap = GsmtapSource(bind_ip, bind_port) + self.gsmtap = GsmtapReceiver(bind_ip, bind_port) def read_packet(self) -> PacketType: gsmtap_msg, _addr = self.gsmtap.read_packet() diff --git a/pySim/apdu_source/pyshark_gsmtap.py b/pySim/apdu_source/pyshark_gsmtap.py index af53ec8..e8f5d18 100644 --- a/pySim/apdu_source/pyshark_gsmtap.py +++ b/pySim/apdu_source/pyshark_gsmtap.py @@ -19,10 +19,9 @@ import logging from typing import Tuple import pyshark +from osmocom.gsmtap import GsmtapMessage from pySim.utils import h2b -from pySim.gsmtap import GsmtapMessage - from pySim.apdu.ts_102_221 import ApduCommands as UiccApduCommands from pySim.apdu.ts_102_222 import ApduCommands as UiccAdmApduCommands from pySim.apdu.ts_31_102 import ApduCommands as UsimApduCommands diff --git a/pySim/apdu_source/tca_loader_log.py b/pySim/apdu_source/tca_loader_log.py index c7827e7..ce25c53 100644 --- a/pySim/apdu_source/tca_loader_log.py +++ b/pySim/apdu_source/tca_loader_log.py @@ -17,7 +17,6 @@ from pySim.utils import h2b -from pySim.gsmtap import GsmtapSource from pySim.apdu.ts_102_221 import ApduCommands as UiccApduCommands from pySim.apdu.ts_102_222 import ApduCommands as UiccAdmApduCommands diff --git a/pySim/gsmtap.py b/pySim/gsmtap.py deleted file mode 100644 index d167e59..0000000 --- a/pySim/gsmtap.py +++ /dev/null @@ -1,214 +0,0 @@ -# -*- coding: utf-8 -*- - -""" Osmocom GSMTAP python implementation. -GSMTAP is a packet format used for conveying a number of different -telecom-related protocol traces over UDP. -""" - -# -# Copyright (C) 2022 Harald Welte <laforge(a)gnumonks.org> -# -# 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 socket -from construct import Optional as COptional -from construct import Int8ub, Int8sb, Int32ub, BitStruct, Enum, GreedyBytes, Struct, Switch -from construct import this, PaddedString, Flag, BitsInteger, Bytes -from osmocom.construct import * - -# The root definition of GSMTAP can be found at -# https://cgit.osmocom.org/cgit/libosmocore/tree/include/osmocom/core/gsmtap.h - -GSMTAP_UDP_PORT = 4729 - -# GSMTAP_TYPE_* -gsmtap_type_construct = Enum(Int8ub, - gsm_um = 0x01, - gsm_abis = 0x02, - gsm_um_burst = 0x03, - sim = 0x04, - tetra_i1 = 0x05, - tetra_i1_burst = 0x06, - wimax_burst = 0x07, - gprs_gb_llc = 0x08, - gprs_gb_sndcp = 0x09, - gmr1_um = 0x0a, - umts_rlc_mac = 0x0b, - umts_rrc = 0x0c, - lte_rrc = 0x0d, - lte_mac = 0x0e, - lte_mac_framed = 0x0f, - osmocore_log = 0x10, - qc_diag = 0x11, - lte_nas = 0x12, - e1_t1 = 0x13) - - -# TYPE_UM_BURST -gsmtap_subtype_burst_construct = Enum(Int8ub, - unknown = 0x00, - fcch = 0x01, - partial_sch = 0x02, - sch = 0x03, - cts_sch = 0x04, - compact_sch = 0x05, - normal = 0x06, - dummy = 0x07, - access = 0x08, - none = 0x09) - -gsmtap_subtype_wimax_burst_construct = Enum(Int8ub, - cdma_code = 0x10, - fch = 0x11, - ffb = 0x12, - pdu = 0x13, - hack = 0x14, - phy_attributes = 0x15) - -# GSMTAP_CHANNEL_* -gsmtap_subtype_um_construct = Enum(Int8ub, - unknown = 0x00, - bcch = 0x01, - ccch = 0x02, - rach = 0x03, - agch = 0x04, - pch = 0x05, - sdcch = 0x06, - sdcch4 = 0x07, - sdcch8 = 0x08, - facch_f = 0x09, - facch_h = 0x0a, - pacch = 0x0b, - cbch52 = 0x0c, - pdtch = 0x0d, - ptcch = 0x0e, - cbch51 = 0x0f, - voice_f = 0x10, - voice_h = 0x11) - - -# GSMTAP_SIM_* -gsmtap_subtype_sim_construct = Enum(Int8ub, - apdu = 0x00, - atr = 0x01, - pps_req = 0x02, - pps_rsp = 0x03, - tpdu_hdr = 0x04, - tpdu_cmd = 0x05, - tpdu_rsp = 0x06, - tpdu_sw = 0x07) - -gsmtap_subtype_tetra_construct = Enum(Int8ub, - bsch = 0x01, - aach = 0x02, - sch_hu = 0x03, - sch_hd = 0x04, - sch_f = 0x05, - bnch = 0x06, - stch = 0x07, - tch_f = 0x08, - dmo_sch_s = 0x09, - dmo_sch_h = 0x0a, - dmo_sch_f = 0x0b, - dmo_stch = 0x0c, - dmo_tch = 0x0d) - -gsmtap_subtype_gmr1_construct = Enum(Int8ub, - unknown = 0x00, - bcch = 0x01, - ccch = 0x02, - pch = 0x03, - agch = 0x04, - bach = 0x05, - rach = 0x06, - cbch = 0x07, - sdcch = 0x08, - tachh = 0x09, - gbch = 0x0a, - tch3 = 0x10, - tch6 = 0x14, - tch9 = 0x18) - -gsmtap_subtype_e1t1_construct = Enum(Int8ub, - lapd = 0x01, - fr = 0x02, - raw = 0x03, - trau16 = 0x04, - trau8 = 0x05) - -gsmtap_arfcn_construct = BitStruct('pcs'/Flag, 'uplink'/Flag, 'arfcn'/BitsInteger(14)) - -gsmtap_hdr_construct = Struct('version'/Int8ub, - 'hdr_len'/Int8ub, - 'type'/gsmtap_type_construct, - 'timeslot'/Int8ub, - 'arfcn'/gsmtap_arfcn_construct, - 'signal_dbm'/Int8sb, - 'snr_db'/Int8sb, - 'frame_nr'/Int32ub, - 'sub_type'/Switch(this.type, { - 'gsm_um': gsmtap_subtype_um_construct, - 'gsm_um_burst': gsmtap_subtype_burst_construct, - 'sim': gsmtap_subtype_sim_construct, - 'tetra_i1': gsmtap_subtype_tetra_construct, - 'tetra_i1_burst': gsmtap_subtype_tetra_construct, - 'wimax_burst': gsmtap_subtype_wimax_burst_construct, - 'gmr1_um': gsmtap_subtype_gmr1_construct, - 'e1_t1': gsmtap_subtype_e1t1_construct, - }), - 'antenna_nr'/Int8ub, - 'sub_slot'/Int8ub, - 'res'/Int8ub, - 'body'/GreedyBytes) - -osmocore_log_ts_construct = Struct('sec'/Int32ub, 'usec'/Int32ub) -osmocore_log_level_construct = Enum(Int8ub, debug=1, info=3, notice=5, error=7, fatal=8) -gsmtap_osmocore_log_hdr_construct = Struct('ts'/osmocore_log_ts_construct, - 'proc_name'/PaddedString(16, 'ascii'), - 'pid'/Int32ub, - 'level'/osmocore_log_level_construct, - Bytes(3), - 'subsys'/PaddedString(16, 'ascii'), - 'src_file'/Struct('name'/PaddedString(32, 'ascii'), 'line_nr'/Int32ub)) - - -class GsmtapMessage: - """Class whose objects represent a single GSMTAP message. Can encode and decode messages.""" - def __init__(self, encoded = None): - self.encoded = encoded - self.decoded = None - - def decode(self): - self.decoded = parse_construct(gsmtap_hdr_construct, self.encoded) - return self.decoded - - def encode(self, decoded): - self.encoded = gsmtap_hdr_construct.build(decoded) - return self.encoded - -class GsmtapSource: - def __init__(self, bind_ip:str='127.0.0.1', bind_port:int=4729): - self.bind_ip = bind_ip - self.bind_port = bind_port - self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - self.sock.bind((self.bind_ip, self.bind_port)) - - def read_packet(self) -> GsmtapMessage: - data, addr = self.sock.recvfrom(1024) - gsmtap_msg = GsmtapMessage(data) - gsmtap_msg.decode() - if gsmtap_msg.decoded['version'] != 0x02: - raise ValueError('Unknown GSMTAP version 0x%02x' % gsmtap_msg.decoded['version']) - return gsmtap_msg.decoded, addr diff --git a/requirements.txt b/requirements.txt index 4368167..99fd5f9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ jsonpath-ng construct>=2.9.51 bidict -pyosmocom +pyosmocom>=0.0.2 pyyaml>=5.1 termcolor colorlog diff --git a/setup.py b/setup.py index e132e3d..d48b806 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ "jsonpath-ng", "construct >= 2.9.51", "bidict", - "pyosmocom", + "pyosmocom >= 0.0.2", "pyyaml >= 5.1", "termcolor", "colorlog", -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37967?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: I631bb85bc6e76b089004d9f2e2082d70cbccf200 Gerrit-Change-Number: 37967 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • ...
  • 199
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.