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

November 2023

  • 1 participants
  • 1508 discussions
[M] Change in libosmocore[master]: gsmtap_util: Use Osmo IO instead of Osmo write queues
by laforge 09 Nov '23

09 Nov '23
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email ) Change subject: gsmtap_util: Use Osmo IO instead of Osmo write queues ...................................................................... Patch Set 9: (1 comment) File src/core/gsmtap_util.c: https://gerrit.osmocom.org/c/libosmocore/+/34743/comment/7263655c_446a9895 PS5, Line 478: osmo_iofd_setup(gti, gti->sink_fd, "gsmtap_inst.out", OSMO_IO_FD_MODE_READ_WRITE, &gsmtap_sink_ops, NULL); > Test to reproduce your issue (even with the old wqueue code) and proposed fix here: […] the fix for that other issue (disabling log / endless loop) has been merged -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0 Gerrit-Change-Number: 34743 Gerrit-PatchSet: 9 Gerrit-Owner: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Nov 2023 12:48:17 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: arehbein <arehbein(a)sysmocom.de> Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Comment-In-Reply-To: daniel <dwillmann(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmocore[master]: gsmtap_util: Use Osmo IO instead of Osmo write queues
by laforge 09 Nov '23

09 Nov '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email ) Change subject: gsmtap_util: Use Osmo IO instead of Osmo write queues ...................................................................... gsmtap_util: Use Osmo IO instead of Osmo write queues - Adapt decl. of 'struct gsmtap_inst' for usage of Osmo IO while maintaining backwards compatibility - Maintain legacy behavior without any message queues if osmo_io_mode is zero Related: OS#6213 Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0 --- M src/core/gsmtap_util.c 1 file changed, 53 insertions(+), 37 deletions(-) Approvals: laforge: Looks good to me, approved daniel: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/core/gsmtap_util.c b/src/core/gsmtap_util.c index dcbd304..458d1d7 100644 --- a/src/core/gsmtap_util.c +++ b/src/core/gsmtap_util.c @@ -29,6 +29,7 @@ #include <osmocom/core/select.h> #include <osmocom/core/socket.h> #include <osmocom/core/byteswap.h> +#include <osmocom/core/utils.h> #include <osmocom/gsm/protocol/gsm_04_08.h> #include <osmocom/gsm/rsl.h> @@ -46,13 +47,28 @@ * * \file gsmtap_util.c */ -/*! one gsmtap instance */ +/*! one gsmtap instance + * Until gsmtap_inst_fd() is removed from the API at some point in the future, we have to keep the first member as + * 'int' and the second as 'struct osmo_wqueue' (this effectively makes sure that the struct member wq.bfd.fd maintains + * the same memory offset from the start of the struct) to ensure that inlined static 'instances' of gsmtap_inst_fd() in + * old binaries keep working the way they used to even with gsmtap_inst objects obtained from newer versions of libosmocore */ struct gsmtap_inst { - int ofd_wq_mode; /*!< wait queue mode? This field member may not be changed or moved (backwards compatibility) */ - struct osmo_wqueue wq; /*!< the wait queue. This field member may not be changed or moved (backwards compatibility) */ - struct osmo_fd sink_ofd; /*!< file descriptor */ + int osmo_io_mode; /*!< Indicates whether or not to use Osmo IO mode for message output (thus enabling use of tx queues). + * This field member may not be changed or moved (backwards compatibility) */ + struct osmo_wqueue wq; /*!< the wait queue. This field member may not be changed or moved (backwards compatibility) */ + + struct osmo_io_fd *out; /*!< Used when osmo_io_mode is nonzero */ + struct osmo_fd sink_ofd; }; +struct _gsmtap_inst_legacy { + int ofd_wq_mode; + struct osmo_wqueue wq; + struct osmo_fd sink_ofd; +}; +osmo_static_assert(offsetof(struct gsmtap_inst, wq) == offsetof(struct _gsmtap_inst_legacy, wq), + gsmtap_inst_new_wq_offset_equals_legacy_wq_offset); + /*! Deprecated, use gsmtap_inst_fd2() instead * \param[in] gti GSMTAP instance * \returns file descriptor of GSMTAP instance */ @@ -253,6 +269,7 @@ #include <sys/socket.h> #include <netinet/in.h> +#include <osmocom/core/osmo_io.h> /*! Create a new (sending) GSMTAP source socket * \param[in] host host name or IP address in string format @@ -346,8 +363,8 @@ if (!gti) return -ENODEV; - if (gti->ofd_wq_mode) - return osmo_wqueue_enqueue(&gti->wq, msg); + if (gti->osmo_io_mode) + return osmo_iofd_write_msgb(gti->out, msg); else { /* try immediate send and return error if any */ int rc; @@ -416,35 +433,17 @@ signal_dbm, snr, data, len); } -/* Callback from select layer if we can write to the socket */ -static int gsmtap_wq_w_cb(struct osmo_fd *ofd, struct msgb *msg) -{ - int rc; - - rc = write(ofd->fd, msg->data, msg->len); - if (rc < 0) { - return rc; - } - if (rc != msg->len) { - return -EIO; - } - - return 0; -} - /* Callback from select layer if we can read from the sink socket */ static int gsmtap_sink_fd_cb(struct osmo_fd *fd, unsigned int flags) { int rc; uint8_t buf[4096]; - if (!(flags & OSMO_FD_READ)) return 0; rc = read(fd->fd, buf, sizeof(buf)); - if (rc < 0) { + if (rc < 0) return rc; - } /* simply discard any data arriving on the socket */ return 0; @@ -473,7 +472,7 @@ if (fd < 0) return fd; - if (gti->ofd_wq_mode) { + if (gti->osmo_io_mode) { struct osmo_fd *sink_ofd; sink_ofd = &gti->sink_ofd; @@ -491,6 +490,12 @@ return fd; } +/* Registered in Osmo IO as a no-op to set the write callback. */ +static void gsmtap_ops_noop_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) +{ +} + +static struct osmo_io_ops gsmtap_ops = { .write_cb = gsmtap_ops_noop_cb }; /*! Open GSMTAP source socket, connect and register osmo_fd * \param[in] local_host IP address in string format @@ -509,27 +514,27 @@ const char *rem_host, uint16_t rem_port, int ofd_wq_mode) { struct gsmtap_inst *gti; - int fd, rc; + int fd; fd = gsmtap_source_init_fd2(local_host, local_port, rem_host, rem_port); if (fd < 0) return NULL; gti = talloc_zero(NULL, struct gsmtap_inst); - gti->ofd_wq_mode = ofd_wq_mode; + gti->osmo_io_mode = ofd_wq_mode; + /* Still using the wq member for its 'fd' field only, since we are keeping it for now, anyways */ gti->wq.bfd.fd = fd; gti->sink_ofd.fd = -1; if (ofd_wq_mode) { - osmo_wqueue_init(&gti->wq, 64); - gti->wq.write_cb = &gsmtap_wq_w_cb; - - rc = osmo_fd_register(&gti->wq.bfd); - if (rc < 0) { + gti->out = osmo_iofd_setup(gti, gti->wq.bfd.fd, "gsmtap_inst.io_fd", OSMO_IO_FD_MODE_READ_WRITE, &gsmtap_ops, NULL); + if (gti->out == NULL) { talloc_free(gti); close(fd); return NULL; } + /* osmo write queue previously used was set up with value of 64 */ + osmo_iofd_set_txqueue_max_length(gti->out, 64); } return gti; @@ -556,9 +561,8 @@ if (!gti) return; - if (gti->ofd_wq_mode) { - osmo_fd_unregister(&gti->wq.bfd); - osmo_wqueue_clear(&gti->wq); + if (gti->osmo_io_mode) { + osmo_iofd_free(gti->out); if (gti->sink_ofd.fd != -1) { osmo_fd_unregister(&gti->sink_ofd); @@ -566,7 +570,6 @@ } } - close(gti->wq.bfd.fd); talloc_free(gti); } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0 Gerrit-Change-Number: 34743 Gerrit-PatchSet: 9 Gerrit-Owner: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in libosmocore[master]: gsmtap_util: Use Osmo IO instead of Osmo write queues
by laforge 09 Nov '23

09 Nov '23
Attention is currently required from: arehbein, pespin. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email ) Change subject: gsmtap_util: Use Osmo IO instead of Osmo write queues ...................................................................... Patch Set 8: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34743?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iadbbef74e3add7001d84dd6b68f51eac293e44d0 Gerrit-Change-Number: 34743 Gerrit-PatchSet: 8 Gerrit-Owner: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: arehbein <arehbein(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Nov 2023 12:47:28 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmocore[master]: logging_gsmtap: Temporarily disable logging when sending the logs
by laforge 09 Nov '23

09 Nov '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34966?usp=email ) Change subject: logging_gsmtap: Temporarily disable logging when sending the logs ...................................................................... logging_gsmtap: Temporarily disable logging when sending the logs This avoids an infinite recursion when sending a gsmtap log message causes a log message. Temporarily set target->loglevel higher than LOGL_FATAL, which effectively disables logging for that target. Other targets like stderr will still log this message so there is still an indication that something went wrong. Change-Id: I19203cadbad6019a3834793b8ac816d903fe088e Related: OS#6213 --- M src/core/logging_gsmtap.c 1 file changed, 22 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/core/logging_gsmtap.c b/src/core/logging_gsmtap.c index dfd059b..7775c27 100644 --- a/src/core/logging_gsmtap.c +++ b/src/core/logging_gsmtap.c @@ -65,6 +65,7 @@ struct timeval tv; int rc; const char *file_basename; + unsigned int _level; /* get timestamp ASAP */ osmo_gettimeofday(&tv, NULL); @@ -114,7 +115,11 @@ } msgb_put(msg, rc); + /* Ensure that any error occurring when sending the log message doesn't cause infinite recursion */ + _level = target->loglevel; + target->loglevel = UINT8_MAX; rc = gsmtap_sendmsg(target->tgt_gsmtap.gsmtap_inst, msg); + target->loglevel = _level; if (rc) msgb_free(msg); } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34966?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I19203cadbad6019a3834793b8ac816d903fe088e Gerrit-Change-Number: 34966 Gerrit-PatchSet: 3 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in libosmocore[master]: logging_gsmtap: Temporarily disable logging when sending the logs
by laforge 09 Nov '23

09 Nov '23
Attention is currently required from: arehbein, daniel, fixeria, osmith. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34966?usp=email ) Change subject: logging_gsmtap: Temporarily disable logging when sending the logs ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34966?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I19203cadbad6019a3834793b8ac816d903fe088e Gerrit-Change-Number: 34966 Gerrit-PatchSet: 3 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: arehbein <arehbein(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Nov 2023 12:47:00 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmocore[master]: gsmtap_util: Simplify sink
by laforge 09 Nov '23

09 Nov '23
Attention is currently required from: arehbein. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email ) Change subject: gsmtap_util: Simplify sink ...................................................................... Patch Set 4: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34881?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4025920d5f62d17133e9b5fe81cd34a88c4f20b5 Gerrit-Change-Number: 34881 Gerrit-PatchSet: 4 Gerrit-Owner: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: arehbein <arehbein(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Nov 2023 12:40:13 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: transport: Extend the documentation for each transport driver
by laforge 09 Nov '23

09 Nov '23
Attention is currently required from: dexter. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34962?usp=email ) Change subject: transport: Extend the documentation for each transport driver ...................................................................... Patch Set 2: (1 comment) File pySim/transport/pcsc.py: https://gerrit.osmocom.org/c/pysim/+/34962/comment/1225bfa0_ccced6a1 PS2, Line 127: Microsoft : Windows > Linux not mentioned first? ;) PC/SC was specified by Microsoft for ... windows :P -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34962?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: I8807bfb11f43b167f1321d556e09ec5234fff629 Gerrit-Change-Number: 34962 Gerrit-PatchSet: 2 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: osmith <osmith(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Nov 2023 12:37:53 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: osmith <osmith(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[M] Change in pysim[master]: pySim-shell: Move init_card() function to new pySim.app module
by laforge 09 Nov '23

09 Nov '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34956?usp=email ) Change subject: pySim-shell: Move init_card() function to new pySim.app module ...................................................................... pySim-shell: Move init_card() function to new pySim.app module The point of this is to move generic code out of pySim-shell.py, paving the way for more/other executables using the full power of our class model without having to reinvent the wheel. Change-Id: Icf557ed3064ef613ed693ce28bd3514a97a938bd --- M pySim-shell.py A pySim/app.py 2 files changed, 133 insertions(+), 94 deletions(-) Approvals: osmith: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/pySim-shell.py b/pySim-shell.py index 0c559f9..795276a 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -2,7 +2,7 @@ # Interactive shell for working with SIM / UICC / USIM / ISIM cards # -# (C) 2021-2022 by Harald Welte <laforge(a)osmocom.org> +# (C) 2021-2023 by Harald Welte <laforge(a)osmocom.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 @@ -48,111 +48,20 @@ from pprint import pprint as pp from pySim.exceptions import * -from pySim.commands import SimCardCommands from pySim.transport import init_reader, ApduTracer, argparse_add_reader_args, ProactiveHandler -from pySim.cards import card_detect, SimCardBase, UiccCardBase from pySim.utils import h2b, b2h, i2h, swap_nibbles, rpad, JsonEncoder, bertlv_parse_one, sw_match from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr, dec_iccid from pySim.utils import is_hexstr_or_decimal, is_hexstr, is_decimal from pySim.card_handler import CardHandler, CardHandlerAuto -from pySim.filesystem import CardDF, CardADF, CardModel, CardApplication -from pySim.runtime import RuntimeState -from pySim.profile import CardProfile -from pySim.cdma_ruim import CardProfileRUIM -from pySim.ts_102_221 import CardProfileUICC +from pySim.filesystem import CardDF, CardADF from pySim.ts_102_222 import Ts102222Commands from pySim.gsm_r import DF_EIRENE from pySim.cat import ProactiveCommand -# we need to import this module so that the SysmocomSJA2 sub-class of -# CardModel is created, which will add the ATR-based matching and -# calling of SysmocomSJA2.add_files. See CardModel.apply_matching_models -import pySim.sysmocom_sja2 - -# we need to import these modules so that the various sub-classes of -# CardProfile are created, which will be used in init_card() to iterate -# over all known CardProfile sub-classes. -import pySim.ts_31_102 -import pySim.ts_31_103 -import pySim.ts_31_104 -import pySim.ara_m -import pySim.global_platform -import pySim.euicc - from pySim.card_key_provider import CardKeyProviderCsv, card_key_provider_register, card_key_provider_get_field - -def init_card(sl): - """ - Detect card in reader and setup card profile and runtime state. This - function must be called at least once on startup. The card and runtime - state object (rs) is required for all pySim-shell commands. - """ - - # Create command layer - scc = SimCardCommands(transport=sl) - - # Wait up to three seconds for a card in reader and try to detect - # the card type. - print("Waiting for card...") - try: - sl.wait_for_card(3) - except NoCardError: - print("No card detected!") - return None, None - except: - print("Card not readable!") - return None, None - - generic_card = False - card = card_detect(scc) - if card is None: - print("Warning: Could not detect card type - assuming a generic card type...") - card = SimCardBase(scc) - generic_card = True - - profile = CardProfile.pick(scc) - if profile is None: - print("Unsupported card type!") - return None, card - - # ETSI TS 102 221, Table 9.3 specifies a default for the PIN key - # references, however card manufactures may still decide to pick an - # arbitrary key reference. In case we run on a generic card class that is - # detected as an UICC, we will pick the key reference that is officially - # specified. - if generic_card and isinstance(profile, CardProfileUICC): - card._adm_chv_num = 0x0A - - print("Info: Card is of type: %s" % str(profile)) - - # FIXME: this shouldn't really be here but somewhere else/more generic. - # We cannot do it within pySim/profile.py as that would create circular - # dependencies between the individual profiles and profile.py. - if isinstance(profile, CardProfileUICC): - for app_cls in CardApplication.__subclasses__(): - constr_sig = inspect.signature(app_cls.__init__) - # skip any intermediary sub-classes such as CardApplicationSD - if len(constr_sig.parameters) != 1: - continue - profile.add_application(app_cls()) - # We have chosen SimCard() above, but we now know it actually is an UICC - # so it's safe to assume it supports USIM application (which we're adding above). - # IF we don't do this, we will have a SimCard but try USIM specific commands like - # the update_ust method (see https://osmocom.org/issues/6055) - if generic_card: - card = UiccCardBase(scc) - - # Create runtime state with card profile - rs = RuntimeState(card, profile) - - CardModel.apply_matching_models(scc, rs) - - # inform the transport that we can do context-specific SW interpretation - sl.set_sw_interpreter(rs) - - return rs, card +from pySim.app import init_card class Cmd2Compat(cmd2.Cmd): diff --git a/pySim/app.py b/pySim/app.py new file mode 100644 index 0000000..1711a1c --- /dev/null +++ b/pySim/app.py @@ -0,0 +1,117 @@ +# (C) 2021-2023 by Harald Welte <laforge(a)osmocom.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 inspect +from typing import Tuple + +from pySim.transport import LinkBase +from pySim.commands import SimCardCommands +from pySim.filesystem import CardModel, CardApplication +from pySim.cards import card_detect, SimCardBase, UiccCardBase +from pySim.exceptions import NoCardError +from pySim.runtime import RuntimeState +from pySim.profile import CardProfile +from pySim.cdma_ruim import CardProfileRUIM +from pySim.ts_102_221 import CardProfileUICC + +# we need to import this module so that the SysmocomSJA2 sub-class of +# CardModel is created, which will add the ATR-based matching and +# calling of SysmocomSJA2.add_files. See CardModel.apply_matching_models +import pySim.sysmocom_sja2 + +# we need to import these modules so that the various sub-classes of +# CardProfile are created, which will be used in init_card() to iterate +# over all known CardProfile sub-classes. +import pySim.ts_31_102 +import pySim.ts_31_103 +import pySim.ts_31_104 +import pySim.ara_m +import pySim.global_platform +import pySim.euicc + +def init_card(sl: LinkBase) -> Tuple[RuntimeState, SimCardBase]: + """ + Detect card in reader and setup card profile and runtime state. This + function must be called at least once on startup. The card and runtime + state object (rs) is required for all pySim-shell commands. + """ + + # Create command layer + scc = SimCardCommands(transport=sl) + + # Wait up to three seconds for a card in reader and try to detect + # the card type. + print("Waiting for card...") + try: + sl.wait_for_card(3) + except NoCardError: + print("No card detected!") + return None, None + except: + print("Card not readable!") + return None, None + + generic_card = False + card = card_detect(scc) + if card is None: + print("Warning: Could not detect card type - assuming a generic card type...") + card = SimCardBase(scc) + generic_card = True + + profile = CardProfile.pick(scc) + if profile is None: + print("Unsupported card type!") + return None, card + + # ETSI TS 102 221, Table 9.3 specifies a default for the PIN key + # references, however card manufactures may still decide to pick an + # arbitrary key reference. In case we run on a generic card class that is + # detected as an UICC, we will pick the key reference that is officially + # specified. + if generic_card and isinstance(profile, CardProfileUICC): + card._adm_chv_num = 0x0A + + print("Info: Card is of type: %s" % str(profile)) + + # FIXME: this shouldn't really be here but somewhere else/more generic. + # We cannot do it within pySim/profile.py as that would create circular + # dependencies between the individual profiles and profile.py. + if isinstance(profile, CardProfileUICC): + for app_cls in CardApplication.__subclasses__(): + constr_sig = inspect.signature(app_cls.__init__) + # skip any intermediary sub-classes such as CardApplicationSD + if len(constr_sig.parameters) != 1: + continue + profile.add_application(app_cls()) + # We have chosen SimCard() above, but we now know it actually is an UICC + # so it's safe to assume it supports USIM application (which we're adding above). + # IF we don't do this, we will have a SimCard but try USIM specific commands like + # the update_ust method (see https://osmocom.org/issues/6055) + if generic_card: + card = UiccCardBase(scc) + + # Create runtime state with card profile + rs = RuntimeState(card, profile) + + CardModel.apply_matching_models(scc, rs) + + # inform the transport that we can do context-specific SW interpretation + sl.set_sw_interpreter(rs) + + return rs, card + + + -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34956?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: Icf557ed3064ef613ed693ce28bd3514a97a938bd Gerrit-Change-Number: 34956 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> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[S] Change in libosmocore[master]: logging_gsmtap: Temporarily disable logging when sending the logs
by fixeria 09 Nov '23

09 Nov '23
Attention is currently required from: arehbein, daniel, laforge, osmith. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34966?usp=email ) Change subject: logging_gsmtap: Temporarily disable logging when sending the logs ...................................................................... Patch Set 3: (1 comment) File src/core/logging_gsmtap.c: https://gerrit.osmocom.org/c/libosmocore/+/34966/comment/7fc6d8c8_6b59a0af PS2, Line 118: level = target->loglevel > as daniel is on holidays and this is a fairly trivial change: @fixeria, would you mind amending thi […] Sure, done. LGTM. -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34966?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I19203cadbad6019a3834793b8ac816d903fe088e Gerrit-Change-Number: 34966 Gerrit-PatchSet: 3 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: arehbein <arehbein(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Nov 2023 12:35:50 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[S] Change in libosmocore[master]: logging_gsmtap: Temporarily disable logging when sending the logs
by fixeria 09 Nov '23

09 Nov '23
Attention is currently required from: arehbein, daniel, fixeria, osmith. fixeria has uploaded a new patch set (#3) to the change originally created by daniel. ( https://gerrit.osmocom.org/c/libosmocore/+/34966?usp=email ) The following approvals got outdated and were removed: Code-Review+1 by osmith, Verified+1 by Jenkins Builder Change subject: logging_gsmtap: Temporarily disable logging when sending the logs ...................................................................... logging_gsmtap: Temporarily disable logging when sending the logs This avoids an infinite recursion when sending a gsmtap log message causes a log message. Temporarily set target->loglevel higher than LOGL_FATAL, which effectively disables logging for that target. Other targets like stderr will still log this message so there is still an indication that something went wrong. Change-Id: I19203cadbad6019a3834793b8ac816d903fe088e Related: OS#6213 --- M src/core/logging_gsmtap.c 1 file changed, 22 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/66/34966/3 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34966?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I19203cadbad6019a3834793b8ac816d903fe088e Gerrit-Change-Number: 34966 Gerrit-PatchSet: 3 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: arehbein <arehbein(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • ...
  • 151
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.