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

June 2024

  • 1 participants
  • 1566 discussions
[M] Change in pysim[master]: saip-tool: Add 'extract-apps' to dump all applications from eSIM profile
by laforge 13 Jun '24

13 Jun '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37169?usp=email ) Change subject: saip-tool: Add 'extract-apps' to dump all applications from eSIM profile ...................................................................... saip-tool: Add 'extract-apps' to dump all applications from eSIM profile This new action can be used to dump all java applications as either raw IJC file or converted to CAP format (the usual format generated by JavaCard toolchains). Change-Id: I51cffa5ba3ddbea491341d678ec9249d7cf470a5 --- M contrib/saip-tool.py M pySim/esim/saip/__init__.py A pySim/javacard.py 3 files changed, 68 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/contrib/saip-tool.py b/contrib/saip-tool.py index 68072fa..6f2a2a4 100755 --- a/contrib/saip-tool.py +++ b/contrib/saip-tool.py @@ -19,11 +19,13 @@ import sys import argparse import logging +import zipfile from pathlib import Path from typing import List from pySim.esim.saip import * from pySim.esim.saip.validation import CheckBasicStructure +from pySim import javacard from pySim.utils import h2b, b2h, swap_nibbles from pySim.pprint import HexBytesPrettyPrinter @@ -56,6 +58,10 @@ parser_info = subparsers.add_parser('info', help='Display information about the profile') +parser_eapp = subparsers.add_parser('extract-apps', help='Extract applications as loadblock file') +parser_eapp.add_argument('--output-dir', default='.', help='Output directory (where to store files)') +parser_eapp.add_argument('--format', default='cap', choices=['ijc', 'cap'], help='Data format of output files') + def do_split(pes: ProfileElementSequence, opts): i = 0 for pe in pes.pe_list: @@ -176,6 +182,21 @@ print("\tInstance AID: %s" % b2h(inst['instanceAID'])) pass +def do_extract_apps(pes:ProfileElementSequence, opts): + apps = pes.pe_by_type.get('application', []) + for app_pe in apps: + package_aid = b2h(app_pe.decoded['loadBlock']['loadPackageAID']) + + fname = os.path.join(opts.output_dir, '%s-%s.%s' % (pes.iccid, package_aid, opts.format)) + load_block_obj = app_pe.decoded['loadBlock']['loadBlockObject'] + print("Writing Load Package AID: %s to file %s" % (package_aid, fname)) + if opts.format == 'ijc': + with open(fname, 'wb') as f: + f.write(load_block_obj) + else: + with io.BytesIO(load_block_obj) as f, zipfile.ZipFile(fname, 'w') as z: + javacard.ijc_to_cap(f, z, package_aid) + if __name__ == '__main__': opts = parser.parse_args() @@ -197,3 +218,5 @@ do_remove_naa(pes, opts) elif opts.command == 'info': do_info(pes, opts) + elif opts.command == 'extract-apps': + do_extract_apps(pes, opts) diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index 278b5cf..e690e6c 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -617,7 +617,19 @@ # TODO: remove any records related to the ADFs from EF.DIR def __repr__(self) -> str: - return "PESequence(%s)" % ', '.join([str(x) for x in self.pe_list]) + return "PESequence(%s: %s)" % (self.iccid, ', '.join([str(x) for x in self.pe_list])) def __iter__(self) -> str: yield from self.pe_list + + @property + def iccid(self) -> Optional[str]: + """The ICCID of the profile.""" + if not 'header' in self.pe_by_type: + return None + if len(self.pe_by_type['header']) < 1: + return None + pe_hdr_dec = self.pe_by_type['header'][0].decoded + if not 'iccid' in pe_hdr_dec: + return None + return b2h(pe_hdr_dec['iccid']) diff --git a/pySim/javacard.py b/pySim/javacard.py new file mode 100644 index 0000000..46f6ec0 --- /dev/null +++ b/pySim/javacard.py @@ -0,0 +1,19 @@ +# JavaCard related utilities + +import zipfile +import struct +import sys +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"] + 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/+/37169?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I51cffa5ba3ddbea491341d678ec9249d7cf470a5 Gerrit-Change-Number: 37169 Gerrit-PatchSet: 4 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-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: saip-tool: Add new 'info' action to print general information
by laforge 13 Jun '24

13 Jun '24
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37168?usp=email ) Change subject: saip-tool: Add new 'info' action to print general information ...................................................................... saip-tool: Add new 'info' action to print general information It will print something like this: SAIP Profile Version: 2.1 Profile Type: 'GSMA Generic eUICC Test Profile' ICCID: 8949449999999990023f Mandatory Services: usim, isim, csim, javacard, usim-test-algorithm NAAs: mf[1], usim[1], csim[1], isim[1] NAA mf NAA usim (a0000000871002ff49ff0589) IMSI: 001010123456063 NAA csim NAA isim (a0000000871004ff49ff0589) Number of applications: 0 Change-Id: I107d457c3313a766229b569453c18a8d69134bec --- M contrib/saip-tool.py M pySim/esim/saip/__init__.py 2 files changed, 91 insertions(+), 3 deletions(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/contrib/saip-tool.py b/contrib/saip-tool.py index 9bbaddf..68072fa 100755 --- a/contrib/saip-tool.py +++ b/contrib/saip-tool.py @@ -54,6 +54,7 @@ parser_rn.add_argument('--naa-type', required=True, choices=NAAs.keys(), help='Network Access Application type to remove') # TODO: add an --naa-index or the like, so only one given instance can be removed +parser_info = subparsers.add_parser('info', help='Display information about the profile') def do_split(pes: ProfileElementSequence, opts): i = 0 @@ -136,6 +137,45 @@ with open(opts.output_file, 'wb') as f: f.write(pes.to_der()) +def do_info(pes: ProfileElementSequence, opts): + def get_naa_count(pes: ProfileElementSequence) -> dict: + """return a dict with naa-type (usim, isim) as key and the count of NAA instances as value.""" + ret = {} + for naa_type in pes.pes_by_naa: + ret[naa_type] = len(pes.pes_by_naa[naa_type]) + return ret + + pe_hdr_dec = pes.pe_by_type['header'][0].decoded + print() + print("SAIP Profile Version: %u.%u" % (pe_hdr_dec['major-version'], pe_hdr_dec['minor-version'])) + print("Profile Type: '%s'" % pe_hdr_dec['profileType']) + print("ICCID: %s" % b2h(pe_hdr_dec['iccid'])) + print("Mandatory Services: %s" % ', '.join(pe_hdr_dec['eUICC-Mandatory-services'].keys())) + print() + naa_strs = ["%s[%u]" % (k, v) for k, v in get_naa_count(pes).items()] + print("NAAs: %s" % ', '.join(naa_strs)) + for naa_type in pes.pes_by_naa: + for naa_inst in pes.pes_by_naa[naa_type]: + first_pe = naa_inst[0] + adf_name = '' + if hasattr(first_pe, 'adf_name'): + adf_name = '(' + first_pe.adf_name + ')' + print("NAA %s %s" % (first_pe.type, adf_name)) + if hasattr(first_pe, 'imsi'): + print("\tIMSI: %s" % first_pe.imsi) + + # applications + print() + apps = pes.pe_by_type.get('application', []) + print("Number of applications: %u" % len(apps)) + for app_pe in apps: + print("App Load Package AID: %s" % b2h(app_pe.decoded['loadBlock']['loadPackageAID'])) + print("\tMandated: %s" % ('mandated' in app_pe.decoded['app-Header'])) + print("\tLoad Block Size: %s" % len(app_pe.decoded['loadBlock']['loadBlockObject'])) + for inst in app_pe.decoded.get('instanceList', []): + print("\tInstance AID: %s" % b2h(inst['instanceAID'])) + pass + if __name__ == '__main__': opts = parser.parse_args() @@ -155,3 +195,5 @@ do_remove_pe(pes, opts) elif opts.command == 'remove-naa': do_remove_naa(pes, opts) + elif opts.command == 'info': + do_info(pes, opts) diff --git a/pySim/esim/saip/__init__.py b/pySim/esim/saip/__init__.py index ee2538c..278b5cf 100644 --- a/pySim/esim/saip/__init__.py +++ b/pySim/esim/saip/__init__.py @@ -22,7 +22,7 @@ import asn1tools -from pySim.utils import bertlv_parse_tag, bertlv_parse_len, b2h, h2b +from pySim.utils import bertlv_parse_tag, bertlv_parse_len, b2h, h2b, dec_imsi from pySim.ts_102_221 import FileDescriptor from pySim.construct import build_construct from pySim.esim import compile_asn1_subdir @@ -263,10 +263,15 @@ @classmethod def from_der(cls, der: bytes) -> 'ProfileElement': + class4petype = { + 'securityDomain': ProfileElementSD, + 'usim': ProfileElementUSIM, + 'isim': ProfileElementISIM, + } """Construct an instance from given raw, DER encoded bytes.""" pe_type, decoded = asn1.decode('ProfileElement', der) - if pe_type == 'securityDomain': - inst = ProfileElementSD(decoded) + if pe_type in class4petype: + inst = class4petype[pe_type](decoded) else: inst = ProfileElement(decoded) inst.type = pe_type @@ -437,6 +442,22 @@ 'uiccToolkitApplicationSpecificParametersField': h2b('01000001000000020112036C756500'), } +class ProfileElementUSIM(ProfileElement): + type = 'usim' + @property + def adf_name(self) -> str: + return b2h(self.decoded['adf-usim'][0][1]['dfName']) + @property + def imsi(self) -> Optional[str]: + f = File('ef-imsi', self.decoded['ef-imsi']) + return dec_imsi(b2h(f.stream.getvalue())) + +class ProfileElementISIM(ProfileElement): + type = 'isim' + @property + def adf_name(self) -> str: + return b2h(self.decoded['adf-isim'][0][1]['dfName']) + def bertlv_first_segment(binary: bytes) -> Tuple[bytes, bytes]: """obtain the first segment of a binary concatenation of BER-TLV objects. Returns: tuple of first TLV and remainder.""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37168?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I107d457c3313a766229b569453c18a8d69134bec Gerrit-Change-Number: 37168 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-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: saip-tool: Add 'extract-apps' to dump all applications from eSIM profile
by laforge 13 Jun '24

13 Jun '24
Attention is currently required from: fixeria. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/37169?usp=email ) Change subject: saip-tool: Add 'extract-apps' to dump all applications from eSIM profile ...................................................................... Patch Set 4: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37169?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I51cffa5ba3ddbea491341d678ec9249d7cf470a5 Gerrit-Change-Number: 37169 Gerrit-PatchSet: 4 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-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Thu, 13 Jun 2024 14:50:20 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in pysim[master]: saip-tool: Add new 'info' action to print general information
by laforge 13 Jun '24

13 Jun '24
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/37168?usp=email ) Change subject: saip-tool: Add new 'info' action to print general information ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37168?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I107d457c3313a766229b569453c18a8d69134bec Gerrit-Change-Number: 37168 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-Comment-Date: Thu, 13 Jun 2024 14:50:19 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in docker-playground[master]: jenkins-common: Treat -asan builds the same as -master
by daniel 12 Jun '24

12 Jun '24
daniel has submitted this change. ( https://gerrit.osmocom.org/c/docker-playground/+/37192?usp=email ) Change subject: jenkins-common: Treat -asan builds the same as -master ...................................................................... jenkins-common: Treat -asan builds the same as -master This fixes the jenkins test failures seen in ttcn3-stp-test-asan. TTCN3 tries to connect to stp via TCP, but since the jenkins.sh script doesn't consider this a build from master the corresponding config is not added to osmo-stp.cfg. Also change the function names from image_suffix_is_* to osmo_repo_is_* to better reflect what they are doing (instead of how). Related: OS#6486 Change-Id: Ibf93880345f38668f8dc812d1523b985d368dfcc --- M jenkins-common.sh M ttcn3-bts-test/jenkins.sh M ttcn3-pcu-test/jenkins-sns.sh M ttcn3-pcu-test/jenkins.sh M ttcn3-stp-test/jenkins.sh 5 files changed, 29 insertions(+), 10 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve daniel: Looks good to me, approved diff --git a/jenkins-common.sh b/jenkins-common.sh index 1caa5dd..5703675 100644 --- a/jenkins-common.sh +++ b/jenkins-common.sh @@ -536,24 +536,25 @@ exit 1 } -# Check if IMAGE_SUFFIX starts with "latest" (e.g. "latest-centos8") -image_suffix_is_latest() { +# Check if the "latest" repo is used (e.g. "latest-centos8") +osmo_repo_is_latest() { case "$IMAGE_SUFFIX" in latest*) return 0 ;; *) return 1 ;; esac } -# Check if IMAGE_SUFFIX starts with "master" (e.g. "master-centos8") -image_suffix_is_master() { +# Check if the "nightly" repo is used (e.g. "master-centos8") +osmo_repo_is_nightly() { case "$IMAGE_SUFFIX" in master*) return 0 ;; + asan*) return 0 ;; *) return 1 ;; esac } -# Check if IMAGE_SUFFIX starts with "2023q1" (e.g. "2023q1-centos8") -image_suffix_is_2023q1() { +# Check if the "2023q1" repo is used (e.g. "2023q1-centos8") +osmo_repo_is_2023q1() { case "$IMAGE_SUFFIX" in 2023q1*) return 0 ;; *) return 1 ;; diff --git a/ttcn3-bts-test/jenkins.sh b/ttcn3-bts-test/jenkins.sh index 38e3760..35415cd 100755 --- a/ttcn3-bts-test/jenkins.sh +++ b/ttcn3-bts-test/jenkins.sh @@ -126,7 +126,7 @@ } set_pcuif_version() { - if image_suffix_is_2023q1; then + if osmo_repo_is_2023q1; then sed -i 's/PCUIF_Types.mp_pcuif_version := 12/PCUIF_Types.mp_pcuif_version := 10/g' $1 fi } diff --git a/ttcn3-pcu-test/jenkins-sns.sh b/ttcn3-pcu-test/jenkins-sns.sh index c42ad18..4f55612 100755 --- a/ttcn3-pcu-test/jenkins-sns.sh +++ b/ttcn3-pcu-test/jenkins-sns.sh @@ -10,7 +10,7 @@ set -e set_pcuif_version() { - if image_suffix_is_2023q1; then + if osmo_repo_is_2023q1; then sed -i 's/PCUIF_Types.mp_pcuif_version := 12/PCUIF_Types.mp_pcuif_version := 10/g' $1 fi } diff --git a/ttcn3-pcu-test/jenkins.sh b/ttcn3-pcu-test/jenkins.sh index f92a08e..dcd0ce9 100755 --- a/ttcn3-pcu-test/jenkins.sh +++ b/ttcn3-pcu-test/jenkins.sh @@ -10,7 +10,7 @@ set -e set_pcuif_version() { - if image_suffix_is_2023q1; then + if osmo_repo_is_2023q1; then sed -i 's/PCUIF_Types.mp_pcuif_version := 12/PCUIF_Types.mp_pcuif_version := 10/g' $1 fi } diff --git a/ttcn3-stp-test/jenkins.sh b/ttcn3-stp-test/jenkins.sh index 4f90a4d..b1f02b9 100755 --- a/ttcn3-stp-test/jenkins.sh +++ b/ttcn3-stp-test/jenkins.sh @@ -17,7 +17,7 @@ cp osmo-stp.cfg $VOL_BASE_DIR/stp/ # XXX: M3UA-over-TCP is not supported by osmo-stp <= 1.8.1 -if image_suffix_is_master; then +if osmo_repo_is_nightly; then osmo-config-merge ./osmo-stp.cfg \ ./osmo-stp-tcp.confmerge \ > "$VOL_BASE_DIR/stp/osmo-stp.cfg" -- To view, visit https://gerrit.osmocom.org/c/docker-playground/+/37192?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: docker-playground Gerrit-Branch: master Gerrit-Change-Id: Ibf93880345f38668f8dc812d1523b985d368dfcc Gerrit-Change-Number: 37192 Gerrit-PatchSet: 3 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in docker-playground[master]: jenkins-common: Treat -asan builds the same as -master
by daniel 12 Jun '24

12 Jun '24
daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/docker-playground/+/37192?usp=email ) Change subject: jenkins-common: Treat -asan builds the same as -master ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/docker-playground/+/37192?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: docker-playground Gerrit-Branch: master Gerrit-Change-Id: Ibf93880345f38668f8dc812d1523b985d368dfcc Gerrit-Change-Number: 37192 Gerrit-PatchSet: 3 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Wed, 12 Jun 2024 20:37:49 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in ...osmo-s1gw[master]: sctp_server: fix state in catch-all handle_call()
by fixeria 12 Jun '24

12 Jun '24
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37218?usp=email ) Change subject: sctp_server: fix state in catch-all handle_call() ...................................................................... sctp_server: fix state in catch-all handle_call() Sending an unexpected call breaks the server, because the third member of a returned tuple (not_implemented) becomes the new state. It was actually meant to be part of the Reply - fix this. https://www.erlang.org/doc/apps/stdlib/gen_server.html#c:handle_call/3 {reply, Reply :: term(), NewState :: term()} Change-Id: I1cc683e549c3bb61e3e4c45bb3d244202d61be53 --- M src/sctp_server.erl 1 file changed, 18 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/src/sctp_server.erl b/src/sctp_server.erl index e93dd9f..806c559 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -95,7 +95,7 @@ handle_call(Info, _From, State) -> error_logger:error_report(["unknown handle_call()", {module, ?MODULE}, {info, Info}, {state, State}]), - {reply, error, not_implemented}. + {reply, {error, not_implemented}, State}. handle_cast({send_data, Aid, Data}, State) -> -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37218?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I1cc683e549c3bb61e3e4c45bb3d244202d61be53 Gerrit-Change-Number: 37218 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in ...osmo-s1gw[master]: logging: use ?LOG macros instead of calling logger:level()
by fixeria 12 Jun '24

12 Jun '24
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37216?usp=email ) Change subject: logging: use ?LOG macros instead of calling logger:level() ...................................................................... logging: use ?LOG macros instead of calling logger:level() The difference between using these macros and the exported functions is that macros add location (originator) information to the metadata, and perform lazy evaluation by wrapping the logger call in a case statement, so it is only evaluated if the log level of the event passes the primary log level check. https://www.erlang.org/doc/apps/kernel/logger_chapter.html#logger-api Change-Id: I3b6e4296f736f9c87d2706ef5fb75146fd9f1239 --- M src/s1ap_proxy.erl M src/sctp_client.erl M src/sctp_proxy.erl M src/sctp_server.erl 4 files changed, 63 insertions(+), 41 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl index d50d765..6c143e8 100644 --- a/src/s1ap_proxy.erl +++ b/src/s1ap_proxy.erl @@ -38,6 +38,8 @@ encode_pdu/1, decode_pdu/1]). +-include_lib("kernel/include/logger.hrl"). + -include("S1AP-PDU-Descriptions.hrl"). -include("S1AP-PDU-Contents.hrl"). -include("S1AP-Containers.hrl"). @@ -52,10 +54,10 @@ handle_pdu(Data) when is_binary(Data) -> case decode_pdu(Data) of {ok, Pdu} -> - logger:info("S1AP PDU: ~p", [Pdu]), + ?LOG_INFO("S1AP PDU: ~p", [Pdu]), handle_pdu(Data, Pdu); {error, {asn1, Error}} -> - logger:error("S1AP PDU decoding failed: ~p", [Error]), + ?LOG_ERROR("S1AP PDU decoding failed: ~p", [Error]), Data end. @@ -86,7 +88,7 @@ {ok, NewData} -> NewData; {error, {asn1, Error}} -> - logger:error("S1AP PDU encoding failed: ~p", [Error]), + ?LOG_ERROR("S1AP PDU encoding failed: ~p", [Error]), Data end. @@ -95,7 +97,7 @@ handle_pdu(Data, {Outcome = initiatingMessage, #'InitiatingMessage'{procedureCode = ?'id-E-RABSetup', value = Content} = Pdu}) -> - logger:debug("Patching E-RAB SETUP REQUEST"), + ?LOG_DEBUG("Patching E-RAB SETUP REQUEST"), IEs = handle_ies(Content#'E-RABSetupRequest'.protocolIEs, ?'id-E-RABToBeSetupListBearerSUReq'), NewContent = Content#'E-RABSetupRequest'{protocolIEs = IEs}, @@ -105,7 +107,7 @@ handle_pdu(Data, {Outcome = successfulOutcome, #'SuccessfulOutcome'{procedureCode = ?'id-E-RABSetup', value = Content} = Pdu}) -> - logger:debug("Patching E-RAB SETUP RESPONSE"), + ?LOG_DEBUG("Patching E-RAB SETUP RESPONSE"), IEs = handle_ies(Content#'E-RABSetupResponse'.protocolIEs, ?'id-E-RABSetupListBearerSURes'), NewContent = Content#'E-RABSetupResponse'{protocolIEs = IEs}, @@ -117,7 +119,7 @@ handle_pdu(Data, {Outcome = initiatingMessage, #'InitiatingMessage'{procedureCode = ?'id-E-RABModificationIndication', value = Content} = Pdu}) -> - logger:debug("Patching E-RAB MODIFICATION INDICATION"), + ?LOG_DEBUG("Patching E-RAB MODIFICATION INDICATION"), IEs = Content#'E-RABModificationIndication'.protocolIEs, %% E-RAB to be Modified List IEs1 = handle_ies(IEs, ?'id-E-RABToBeModifiedListBearerModInd'), @@ -130,7 +132,7 @@ handle_pdu(Data, {Outcome = initiatingMessage, #'InitiatingMessage'{procedureCode = ?'id-InitialContextSetup', value = Content} = Pdu}) -> - logger:debug("Patching INITIAL CONTEXT SETUP REQUEST"), + ?LOG_DEBUG("Patching INITIAL CONTEXT SETUP REQUEST"), IEs = handle_ies(Content#'InitialContextSetupRequest'.protocolIEs, ?'id-E-RABToBeSetupListCtxtSUReq'), NewContent = Content#'InitialContextSetupRequest'{protocolIEs = IEs}, @@ -140,7 +142,7 @@ handle_pdu(Data, {Outcome = successfulOutcome, #'SuccessfulOutcome'{procedureCode = ?'id-InitialContextSetup', value = Content} = Pdu}) -> - logger:debug("Patching INITIAL CONTEXT SETUP RESPONSE"), + ?LOG_DEBUG("Patching INITIAL CONTEXT SETUP RESPONSE"), IEs = handle_ies(Content#'InitialContextSetupResponse'.protocolIEs, ?'id-E-RABSetupListCtxtSURes'), NewContent = Content#'InitialContextSetupResponse'{protocolIEs = IEs}, @@ -234,7 +236,7 @@ %% Catch-all variant, which should not be called normally handle_ie(#'ProtocolIE-Field'{value = Content} = IE) -> - logger:error("[BUG] Unhandled S1AP IE: ~p", [IE]), + ?LOG_ERROR("[BUG] Unhandled S1AP IE: ~p", [IE]), Content. diff --git a/src/sctp_client.erl b/src/sctp_client.erl index 320d4da..06ee31d 100644 --- a/src/sctp_client.erl +++ b/src/sctp_client.erl @@ -40,6 +40,7 @@ send_data/2, disconnect/1]). +-include_lib("kernel/include/logger.hrl"). -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl index 29cc425..7f389aa 100644 --- a/src/sctp_proxy.erl +++ b/src/sctp_proxy.erl @@ -45,6 +45,7 @@ send_data/2, shutdown/1]). +-include_lib("kernel/include/logger.hrl"). -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). @@ -83,7 +84,7 @@ %% CONNECTING state connecting(enter, OldState, #{mme_addr := MmeAddr, mmr_port := MmePort} = S) -> - logger:info("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), + ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), %% Initiate connection establishment with the MME {ok, Sock} = sctp_client:connect(MmeAddr, MmePort), {keep_state, S#{sock => Sock}, @@ -104,29 +105,29 @@ assoc_id = Aid}}}, S) -> case ConnState of comm_up -> - logger:notice("MME connection (id=~p, ~p:~p) established", - [Aid, MmeAddr, MmePort]), + ?LOG_NOTICE("MME connection (id=~p, ~p:~p) established", + [Aid, MmeAddr, MmePort]), {next_state, connected, S#{mme_aid => Aid}}; _ -> - logger:notice("MME connection establishment failed: ~p", [ConnState]), + ?LOG_NOTICE("MME connection establishment failed: ~p", [ConnState]), {stop, {shutdown, conn_est_fail}} end; %% Catch-all for other kinds of SCTP events connecting(info, {sctp, _Socket, MmeAddr, MmePort, {AncData, Data}}, S) -> - logger:debug("Unhandled SCTP event (~p:~p): ~p, ~p", - [MmeAddr, MmePort, AncData, Data]), + ?LOG_DEBUG("Unhandled SCTP event (~p:~p): ~p, ~p", + [MmeAddr, MmePort, AncData, Data]), {keep_state, S}; connecting(Event, EventData, S) -> - logger:error("Unexpected event ~p: ~p", [Event, EventData]), + ?LOG_ERROR("Unexpected event ~p: ~p", [Event, EventData]), {keep_state, S}. %% CONNECTED state connected(enter, OldState, S) -> - logger:info("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), + ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), %% Send pending eNB -> MME messages (if any) ok = sctp_send_pending(S), {keep_state, maps:remove(tx_queue, S)}; @@ -142,32 +143,32 @@ assoc_id = Aid}}}, S) -> case ConnState of comm_up -> - logger:notice("MME connection (id=~p, ~p:~p) is already established?!?", - [Aid, MmeAddr, MmePort]), + ?LOG_NOTICE("MME connection (id=~p, ~p:~p) is already established?!?", + [Aid, MmeAddr, MmePort]), {keep_state, S}; _ -> - logger:notice("MME connection state: ~p", [ConnState]), + ?LOG_NOTICE("MME connection state: ~p", [ConnState]), {stop, {shutdown, conn_fail}} end; %% Handle an #sctp_sndrcvinfo event (MME -> eNB data) connected(info, {sctp, _Socket, MmeAddr, MmePort, {[#sctp_sndrcvinfo{assoc_id = Aid}], Data}}, S) -> - logger:debug("MME connection (id=~p, ~p:~p) -> eNB: ~p", - [Aid, MmeAddr, MmePort, Data]), + ?LOG_DEBUG("MME connection (id=~p, ~p:~p) -> eNB: ~p", + [Aid, MmeAddr, MmePort, Data]), sctp_server:send_data(maps:get(enb_aid, S), handle_pdu(Data)), {keep_state, S}; %% Catch-all for other kinds of SCTP events connected(info, {sctp, _Socket, MmeAddr, MmePort, {AncData, Data}}, S) -> - logger:debug("Unhandled SCTP event (~p:~p): ~p, ~p", - [MmeAddr, MmePort, AncData, Data]), + ?LOG_DEBUG("Unhandled SCTP event (~p:~p): ~p, ~p", + [MmeAddr, MmePort, AncData, Data]), {keep_state, S}; %% Catch-all handler for this state connected(Event, EventData, S) -> - logger:error("Unexpected event ~p: ~p", [Event, EventData]), + ?LOG_ERROR("Unexpected event ~p: ~p", [Event, EventData]), {keep_state, S}. @@ -177,7 +178,7 @@ terminate(Reason, State, S) -> - logger:notice("Terminating in state ~p, reason ~p", [State, Reason]), + ?LOG_NOTICE("Terminating in state ~p, reason ~p", [State, Reason]), case S of #{sock := Sock, mme_aid := Aid} -> sctp_client:disconnect({Sock, Aid}), @@ -199,7 +200,7 @@ NewData -> NewData catch Exception:Reason -> - logger:error("An exception occurred: ~p, ~p", [Exception, Reason]), + ?LOG_ERROR("An exception occurred: ~p, ~p", [Exception, Reason]), Data %% proxy as-is end. diff --git a/src/sctp_server.erl b/src/sctp_server.erl index 806c559..5c73fc2 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -44,6 +44,7 @@ send_data/2, shutdown/0]). +-include_lib("kernel/include/logger.hrl"). -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). @@ -85,7 +86,7 @@ {type, seqpacket}, {reuseaddr, true}, {active, true}]), - logger:info("SCTP server listening on ~w:~w", [BindAddr, BindPort]), + ?LOG_INFO("SCTP server listening on ~w:~w", [BindAddr, BindPort]), ok = gen_sctp:listen(Sock, true), {ok, #server_state{sock = Sock, clients = dict:new(), @@ -119,7 +120,7 @@ %% Handle termination events of the child processes handle_info({'EXIT', Pid, Reason}, #server_state{sock = Sock, clients = Clients} = State) -> - logger:debug("Child process ~p terminated with reason ~p", [Pid, Reason]), + ?LOG_DEBUG("Child process ~p terminated with reason ~p", [Pid, Reason]), case client_find(State, Pid) of {ok, {Aid, _Client}} -> %% gracefully close the eNB connection @@ -137,7 +138,7 @@ terminate(Reason, State) -> - logger:notice("Terminating, reason ~p", [Reason]), + ?LOG_NOTICE("Terminating, reason ~p", [Reason]), close_conns(State), gen_sctp:close(State#server_state.sock), ok. @@ -152,18 +153,18 @@ assoc_id = Aid}}) -> case ConnState of comm_up -> - logger:notice("eNB connection (id=~p, ~p:~p) established", [Aid, FromAddr, FromPort]), + ?LOG_NOTICE("eNB connection (id=~p, ~p:~p) established", [Aid, FromAddr, FromPort]), Clients = client_add(State#server_state.clients, Aid, FromAddr, FromPort, State#server_state.mme_addr_port); shutdown_comp -> - logger:notice("eNB connection (id=~p, ~p:~p) closed", [Aid, FromAddr, FromPort]), + ?LOG_NOTICE("eNB connection (id=~p, ~p:~p) closed", [Aid, FromAddr, FromPort]), Clients = client_del(State#server_state.clients, Aid); comm_lost -> - logger:notice("eNB connection (id=~p, ~p:~p) lost", [Aid, FromAddr, FromPort]), + ?LOG_NOTICE("eNB connection (id=~p, ~p:~p) lost", [Aid, FromAddr, FromPort]), Clients = client_del(State#server_state.clients, Aid); _ -> - logger:notice("eNB connection (id=~p, ~p:~p) state ~p", - [Aid, FromAddr, FromPort, ConnState]), + ?LOG_NOTICE("eNB connection (id=~p, ~p:~p) state ~p", + [Aid, FromAddr, FromPort, ConnState]), Clients = State#server_state.clients end, State#server_state{clients = Clients}; @@ -171,20 +172,20 @@ %% Handle an #sctp_sndrcvinfo event (incoming data) sctp_recv(State, {FromAddr, FromPort, [#sctp_sndrcvinfo{assoc_id = Aid}], Data}) -> - logger:debug("eNB connection (id=~p, ~p:~p) -> MME: ~p", [Aid, FromAddr, FromPort, Data]), + ?LOG_DEBUG("eNB connection (id=~p, ~p:~p) -> MME: ~p", [Aid, FromAddr, FromPort, Data]), case dict:find(Aid, State#server_state.clients) of {ok, #client_state{pid = Pid}} -> sctp_proxy:send_data(Pid, Data); error -> - logger:error("eNB connection (id=~p, ~p:~p) is not known to us?!?", - [Aid, FromAddr, FromPort]) + ?LOG_ERROR("eNB connection (id=~p, ~p:~p) is not known to us?!?", + [Aid, FromAddr, FromPort]) end, State; %% Catch-all for other kinds of SCTP events sctp_recv(State, {FromAddr, FromPort, AncData, Data}) -> - logger:debug("Unhandled SCTP event (~p:~p): ~p, ~p", - [FromAddr, FromPort, AncData, Data]), + ?LOG_DEBUG("Unhandled SCTP event (~p:~p): ~p, ~p", + [FromAddr, FromPort, AncData, Data]), State. @@ -228,7 +229,7 @@ close_conns(Sock, [{Aid, Client} | Clients]) -> {FromAddr, FromPort} = Client#client_state.addr_port, - logger:notice("Terminating eNB connection (id=~p, ~p:~p)", [Aid, FromAddr, FromPort]), + ?LOG_NOTICE("Terminating eNB connection (id=~p, ~p:~p)", [Aid, FromAddr, FromPort]), %% request to terminate an MME connection sctp_proxy:shutdown(Client#client_state.pid), %% gracefully close an eNB connection -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37216?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I3b6e4296f736f9c87d2706ef5fb75146fd9f1239 Gerrit-Change-Number: 37216 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> 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-MessageType: merged
1 0
0 0
[S] Change in ...osmo-s1gw[master]: logging: cosmetic: print mfa at the end of each line
by fixeria 12 Jun '24

12 Jun '24
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37217?usp=email ) Change subject: logging: cosmetic: print mfa at the end of each line ...................................................................... logging: cosmetic: print mfa at the end of each line Change-Id: Ib5b8aabd1d7285d22a4cee2beece77691c61f753 --- M config/sys.config 1 file changed, 12 insertions(+), 2 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/config/sys.config b/config/sys.config index 6904d65..5ccd43d 100644 --- a/config/sys.config +++ b/config/sys.config @@ -27,7 +27,8 @@ single_line => false, template => [time, " ", color, "[", level, "]", {pid, [" ", pid, ""], ""}, - {mfa, [" ", mfa, ":", line], ""}, - ": ", msg, reset, "\n"]}}}}]}]}]. + " ", msg, + {mfa, [" (", mfa, ":", line, ")"], ""}, + reset, "\n"]}}}}]}]}]. %% vim:set ts=2 sw=2 et: -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37217?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: Ib5b8aabd1d7285d22a4cee2beece77691c61f753 Gerrit-Change-Number: 37217 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> 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-MessageType: merged
1 0
0 0
[S] Change in ...osmo-s1gw[master]: logging: convert error_logger:error_report/1 to ?LOG_ERROR
by fixeria 12 Jun '24

12 Jun '24
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37219?usp=email ) Change subject: logging: convert error_logger:error_report/1 to ?LOG_ERROR ...................................................................... logging: convert error_logger:error_report/1 to ?LOG_ERROR In Erlang/OTP 21.0, a new API for logging was added. The old error_logger module can still be used by legacy code, but log events are redirected to the new Logger API. New code should use the Logger API directly. Change-Id: Id6c61fb5ca730209ef625fc5f63d627574e60fbe --- M src/sctp_server.erl 1 file changed, 17 insertions(+), 7 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/src/sctp_server.erl b/src/sctp_server.erl index 5c73fc2..2c3893a 100644 --- a/src/sctp_server.erl +++ b/src/sctp_server.erl @@ -93,9 +93,8 @@ mme_addr_port = MmeAddrPort}}. -handle_call(Info, _From, State) -> - error_logger:error_report(["unknown handle_call()", - {module, ?MODULE}, {info, Info}, {state, State}]), +handle_call(Info, From, State) -> + ?LOG_ERROR("unknown ~p() from ~p: ~p", [?FUNCTION_NAME, From, Info]), {reply, {error, not_implemented}, State}. @@ -107,8 +106,7 @@ {noreply, State}; handle_cast(Info, State) -> - error_logger:error_report(["unknown handle_cast()", - {module, ?MODULE}, {info, Info}, {state, State}]), + ?LOG_ERROR("unknown ~p(): ~p", [?FUNCTION_NAME, Info]), {noreply, State}. @@ -132,8 +130,7 @@ %% Catch-all for unknown messages handle_info(Info, State) -> - error_logger:error_report(["unknown handle_info()", - {module, ?MODULE}, {info, Info}, {state, State}]), + ?LOG_ERROR("unknown ~p(): ~p", [?FUNCTION_NAME, Info]), {noreply, State}. -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37219?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: Id6c61fb5ca730209ef625fc5f63d627574e60fbe Gerrit-Change-Number: 37219 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de> 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-MessageType: merged
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • ...
  • 157
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.