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

October 2023

  • 1 participants
  • 1843 discussions
[S] Change in osmo-bsc[master]: pcuif_proto: clean up last remains of old PCUIF v10
by dexter 24 Oct '23

24 Oct '23
dexter has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/34708?usp=email ) ( 2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: pcuif_proto: clean up last remains of old PCUIF v10 ...................................................................... pcuif_proto: clean up last remains of old PCUIF v10 There are still some remains that are related to the old PCUIF v10 protocol version. Let's clean those up. Related: OS#5927 Depends: osmo-pcu.git I68a3f59d5c960ae3a4fbd74f9d4a894295cb9ed8 Change-Id: Iebb3a634fee680bdc3636a61f3ccaa1e97e54a64 --- M include/osmocom/bsc/pcuif_proto.h M src/osmo-bsc/pcu_sock.c 2 files changed, 14 insertions(+), 6 deletions(-) Approvals: osmith: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/bsc/pcuif_proto.h b/include/osmocom/bsc/pcuif_proto.h index 9df85d9..1133ca6 100644 --- a/include/osmocom/bsc/pcuif_proto.h +++ b/include/osmocom/bsc/pcuif_proto.h @@ -13,7 +13,6 @@ /* msg_type */ #define PCU_IF_MSG_DATA_REQ 0x00 /* send data to given channel */ -#define PCU_IF_MSG_DATA_CNF 0x01 /* confirm (e.g. transmission on PCH) */ #define PCU_IF_MSG_DATA_IND 0x02 /* receive data from given channel */ #define PCU_IF_MSG_SUSP_REQ 0x03 /* BTS forwards GPRS SUSP REQ to PCU */ #define PCU_IF_MSG_APP_INFO_REQ 0x04 /* BTS asks PCU to transmit APP INFO via PACCH */ @@ -35,8 +34,6 @@ /* sapi */ #define PCU_IF_SAPI_RACH 0x01 /* channel request on CCCH */ -#define PCU_IF_SAPI_AGCH 0x02 /* assignment on AGCH */ -#define PCU_IF_SAPI_PCH 0x03 /* paging/assignment on PCH */ #define PCU_IF_SAPI_BCCH 0x04 /* SI on BCCH */ #define PCU_IF_SAPI_PDTCH 0x05 /* packet data/control/ccch block */ #define PCU_IF_SAPI_PRACH 0x06 /* packet random access channel */ @@ -297,7 +294,6 @@ union { struct gsm_pcu_if_data data_req; - struct gsm_pcu_if_data data_cnf; struct gsm_pcu_if_data_cnf data_cnf2; struct gsm_pcu_if_data data_ind; struct gsm_pcu_if_susp_req susp_req; diff --git a/src/osmo-bsc/pcu_sock.c b/src/osmo-bsc/pcu_sock.c index d279093..24f3c1c 100644 --- a/src/osmo-bsc/pcu_sock.c +++ b/src/osmo-bsc/pcu_sock.c @@ -50,8 +50,6 @@ static const char *sapi_string[] = { [PCU_IF_SAPI_RACH] = "RACH", - [PCU_IF_SAPI_AGCH] = "AGCH", - [PCU_IF_SAPI_PCH] = "PCH", [PCU_IF_SAPI_BCCH] = "BCCH", [PCU_IF_SAPI_PDTCH] = "PDTCH", [PCU_IF_SAPI_PRACH] = "PRACH", -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/34708?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: Iebb3a634fee680bdc3636a61f3ccaa1e97e54a64 Gerrit-Change-Number: 34708 Gerrit-PatchSet: 4 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> 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-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmo-pcu[master]: pcuif_proto: drop support for PCUIF v10
by dexter 24 Oct '23

24 Oct '23
dexter has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/34706?usp=email ) Change subject: pcuif_proto: drop support for PCUIF v10 ...................................................................... pcuif_proto: drop support for PCUIF v10 We now use PCUIF v11 in the TTCN3 tests exclusively and also osmo-bts and osmo-bsc only support PCUIF v11. There is no longer a need to maintain a backward compatibility to PCUIF v10 in osmo-pcu. Related: OS#5927 Change-Id: I68a3f59d5c960ae3a4fbd74f9d4a894295cb9ed8 --- M include/osmocom/pcu/pcuif_proto.h M src/bts.cpp M src/gprs_rlcmac.c M src/pcu_l1_if.cpp M tests/app_info/AppInfoTest.err 5 files changed, 34 insertions(+), 123 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve osmith: Looks good to me, approved diff --git a/include/osmocom/pcu/pcuif_proto.h b/include/osmocom/pcu/pcuif_proto.h index 9df85d9..1133ca6 100644 --- a/include/osmocom/pcu/pcuif_proto.h +++ b/include/osmocom/pcu/pcuif_proto.h @@ -13,7 +13,6 @@ /* msg_type */ #define PCU_IF_MSG_DATA_REQ 0x00 /* send data to given channel */ -#define PCU_IF_MSG_DATA_CNF 0x01 /* confirm (e.g. transmission on PCH) */ #define PCU_IF_MSG_DATA_IND 0x02 /* receive data from given channel */ #define PCU_IF_MSG_SUSP_REQ 0x03 /* BTS forwards GPRS SUSP REQ to PCU */ #define PCU_IF_MSG_APP_INFO_REQ 0x04 /* BTS asks PCU to transmit APP INFO via PACCH */ @@ -35,8 +34,6 @@ /* sapi */ #define PCU_IF_SAPI_RACH 0x01 /* channel request on CCCH */ -#define PCU_IF_SAPI_AGCH 0x02 /* assignment on AGCH */ -#define PCU_IF_SAPI_PCH 0x03 /* paging/assignment on PCH */ #define PCU_IF_SAPI_BCCH 0x04 /* SI on BCCH */ #define PCU_IF_SAPI_PDTCH 0x05 /* packet data/control/ccch block */ #define PCU_IF_SAPI_PRACH 0x06 /* packet random access channel */ @@ -297,7 +294,6 @@ union { struct gsm_pcu_if_data data_req; - struct gsm_pcu_if_data data_cnf; struct gsm_pcu_if_data_cnf data_cnf2; struct gsm_pcu_if_data data_ind; struct gsm_pcu_if_susp_req susp_req; diff --git a/src/bts.cpp b/src/bts.cpp index 50c21a3..0fe8fbc 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -1033,10 +1033,7 @@ rip->burst_type); bts_do_rate_ctr_inc(bts, CTR_IMMEDIATE_ASSIGN_UL_TBF); if (plen >= 0) { - if (the_pcu->pcu_if_version >= 0x0b) - pcu_l1if_tx_agch2(bts, bv, plen, false, GSM_RESERVED_TMSI); - else - pcu_l1if_tx_agch(bts, bv, plen); + pcu_l1if_tx_agch2(bts, bv, plen, false, GSM_RESERVED_TMSI); rc = 0; } else { rc = plen; @@ -1050,12 +1047,8 @@ bv, rip->ra, rip->rfn, rip->burst_type, (uint8_t)osmo_tdef_get(bts->T_defs_bts, 3142, OSMO_TDEF_S, -1)); bts_do_rate_ctr_inc(bts, CTR_IMMEDIATE_ASSIGN_REJ); - if (plen >= 0) { - if (the_pcu->pcu_if_version >= 0x0b) - pcu_l1if_tx_agch2(bts, bv, plen, false, GSM_RESERVED_TMSI); - else - pcu_l1if_tx_agch(bts, bv, plen); - } + if (plen >= 0) + pcu_l1if_tx_agch2(bts, bv, plen, false, GSM_RESERVED_TMSI); bitvec_free(bv); /* rc was already properly set before goto */ return rc; @@ -1136,24 +1129,20 @@ if (plen >= 0) { bts_do_rate_ctr_inc(bts, CTR_IMMEDIATE_ASSIGN_DL_TBF); - if (the_pcu->pcu_if_version >= 0x0b) { - if (ms_imsi_is_valid(tbf->ms())) { - pcu_l1if_tx_pch2(bts, immediate_assignment, plen, true, tbf->imsi(), tbf->tlli()); - } else { - /* During GMM ATTACH REQUEST, the IMSI is not yet known to the PCU or SGSN. (It is - * requested after the GMM ATTACH REQUEST with the GMM IDENTITY REQUEST.) When the PCU - * has to assign a DL TBF but the IMSI is not known, then the IMMEDIATE ASSIGNMENT is - * sent on the AGCH. The reason for this is that without an IMSI we can not calculate - + the paging group, which would be necessary for transmission on PCH. Since the IMSI - * is usually only unknown during the GMM ATTACH REQUEST, we may assume that the MS - * is in non-DRX mode and hence it is listening on all CCCH blocks, including AGCH. - * - * See also: 3gpp TS 44.060, section 5.5.1.5 - * 3gpp TS 45.002, section 6.5.3, 6.5.6 */ - pcu_l1if_tx_agch2(bts, immediate_assignment, plen, true, tbf->tlli()); - } + if (ms_imsi_is_valid(tbf->ms())) { + pcu_l1if_tx_pch2(bts, immediate_assignment, plen, true, tbf->imsi(), tbf->tlli()); } else { - pcu_l1if_tx_pch(bts, immediate_assignment, plen, tbf->imsi()); + /* During GMM ATTACH REQUEST, the IMSI is not yet known to the PCU or SGSN. (It is + * requested after the GMM ATTACH REQUEST with the GMM IDENTITY REQUEST.) When the PCU + * has to assign a DL TBF but the IMSI is not known, then the IMMEDIATE ASSIGNMENT is + * sent on the AGCH. The reason for this is that without an IMSI we can not calculate + * the paging group, which would be necessary for transmission on PCH. Since the IMSI + * is usually only unknown during the GMM ATTACH REQUEST, we may assume that the MS + * is in non-DRX mode and hence it is listening on all CCCH blocks, including AGCH. + * + * See also: 3gpp TS 44.060, section 5.5.1.5 + * 3gpp TS 45.002, section 6.5.3, 6.5.6 */ + pcu_l1if_tx_agch2(bts, immediate_assignment, plen, true, tbf->tlli()); } } diff --git a/src/gprs_rlcmac.c b/src/gprs_rlcmac.c index d15445e..b2cbeca 100644 --- a/src/gprs_rlcmac.c +++ b/src/gprs_rlcmac.c @@ -44,11 +44,7 @@ } bts_do_rate_ctr_inc(bts, CTR_PCH_REQUESTS); - if (the_pcu->pcu_if_version >= 0x0b) - pcu_l1if_tx_pch2(bts, paging_request, plen, false, imsi, GSM_RESERVED_TMSI); - else - pcu_l1if_tx_pch(bts, paging_request, plen, imsi); - + pcu_l1if_tx_pch2(bts, paging_request, plen, false, imsi, GSM_RESERVED_TMSI); bitvec_free(paging_request); return 0; diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 4fcec31..9557f66 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -249,22 +249,6 @@ pcu_tx_data_req(bts, trx, ts, PCU_IF_SAPI_PTCCH, arfcn, fn, block_nr, data, data_len); } -void pcu_l1if_tx_agch(struct gprs_rlcmac_bts *bts, bitvec *block, int plen) -{ - /* TODO: When PCUIF v.11 has become mainline, we will use pcu_l1if_tx_agch2() exclusively. - * This will make this function obsolote, so we can remove it. */ - uint8_t data[GSM_MACBLOCK_LEN]; /* prefix PLEN */ - - /* FIXME: why does OpenBTS has no PLEN and no fill in message? */ - bitvec_pack(block, data + 1); - data[0] = (plen << 2) | 0x01; - - if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_AGCH)) - gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_AGCH, 0, 0, 0, 0, data, GSM_MACBLOCK_LEN); - - pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_AGCH, 0, 0, 0, data, sizeof(data)); -} - /* Send a MAC block via the access grant channel. This will (obviously) only work for MAC blocks that contain * an IMMEDIATE ASSIGNMENT. In case the confirm flag is set, the receiving end is required to send a confirmation * back when the IMMEDIATE ASSIGNMENT has been sent. */ @@ -283,43 +267,6 @@ pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_AGCH_2, 0, 0, 0, (uint8_t*)&agch, sizeof(agch)); } -#define IMSI_DIGITS_FOR_PAGING 3 -/* Send a MAC block via the paging channel. (See also comment below) */ -void pcu_l1if_tx_pch(struct gprs_rlcmac_bts *bts, bitvec *block, int plen, const char *imsi) -{ - /* TODO: When PCUIF v.11 has become mainline, we will use pcu_l1if_tx_pch2() exclusively. - * This will make this function obsolote, so we can remove it. */ - - uint8_t data[IMSI_DIGITS_FOR_PAGING + GSM_MACBLOCK_LEN]; - - /* prepend last three IMSI digits (if present) from which BTS/BSC will calculate the paging group */ - if (imsi && strlen(imsi) >= IMSI_DIGITS_FOR_PAGING) - memcpy(data, imsi + strlen(imsi) - IMSI_DIGITS_FOR_PAGING, IMSI_DIGITS_FOR_PAGING); - else - memset(data, '0', IMSI_DIGITS_FOR_PAGING); - - /* OS#6097: if strlen(imsi) == 0: We assume the MS is in non-DRX - * mode (TS 44.060 5.5.1.5) and hence it is listening on all CCCH blocks - * (TS 45.002 6.5.3, 6.5.6). - * Hence, pgroup 000 is taken "randomly" to send it over it. This of - * course not optimal since it can actually be sent on any CCCH blocks, - * so we are delaying the ImmAss for no good reason. But anyway, - * pcu_l1if_tx_pch() is deprecated and pcu_l1if_tx_pch2() should be - * used instead, which doesn't suffer from this problem. - */ - - /* block provided by upper layer comes without first byte (plen), prepend it manually: */ - OSMO_ASSERT(sizeof(data) >= IMSI_DIGITS_FOR_PAGING + 1 + block->data_len); - data[IMSI_DIGITS_FOR_PAGING] = (plen << 2) | 0x01; - bitvec_pack(block, data + IMSI_DIGITS_FOR_PAGING + 1); - - if (the_pcu->gsmtap_categ_mask & (1 << PCU_GSMTAP_C_DL_PCH)) - gsmtap_send(the_pcu->gsmtap, 0, 0, GSMTAP_CHANNEL_PCH, 0, 0, 0, 0, - data + IMSI_DIGITS_FOR_PAGING, GSM_MACBLOCK_LEN); - - pcu_tx_data_req(bts, 0, 0, PCU_IF_SAPI_PCH, 0, 0, 0, data, sizeof(data)); -} - /* Send a MAC block via the paging channel. This will (obviously) only work for MAC blocks that contain an * IMMEDIATE ASSIGNMENT or a PAGING COMMAND message. In case the MAC block contains an IMMEDIATE ASSIGNMENT * message, the receiving end is required to confirm when the IMMEDIATE ASSIGNMENT has been sent. */ @@ -556,26 +503,6 @@ return rc; } -static int pcu_rx_data_cnf(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_data *data_cnf) -{ - int rc = 0; - - LOGP(DL1IF, LOGL_DEBUG, "Data confirm received: sapi=%d\n", data_cnf->sapi); - - switch (data_cnf->sapi) { - case PCU_IF_SAPI_PCH: - if (data_cnf->data[2] == GSM48_MT_RR_IMM_ASS) - bts_rcv_imm_ass_cnf(bts, data_cnf->data, GSM_RESERVED_TMSI); - break; - default: - LOGP(DL1IF, LOGL_ERROR, "Received PCU data confirm with " - "unsupported sapi %d\n", data_cnf->sapi); - rc = -EINVAL; - } - - return rc; -} - static int pcu_rx_data_cnf2(struct gprs_rlcmac_bts *bts, struct gsm_pcu_if_data_cnf *data_cnf) { int rc = 0; @@ -809,14 +736,7 @@ LOGP(DL1IF, LOGL_DEBUG, "Info indication received:\n"); - /* NOTE: The classic way to confirm an IMMEDIATE assignment is to send the whole MAC block payload back to the - * PCU. So it is the MAC block itsself that serves a reference for the confirmation. This method has certain - * disadvantages so it was replaced with a method that uses the TLLI as a reference (msg_id). This new - * method will replace the old one. The code that handles the old method will be removed in the foreseeable - * future. (see also OS#5927) */ - if (info_ind->version == 0x0a) { - LOGP(DL1IF, LOGL_NOTICE, "PCUIF version 10 is deprecated. OS#5927\n"); - } else if (info_ind->version != PCU_IF_VERSION) { + if (info_ind->version != PCU_IF_VERSION) { fprintf(stderr, "PCU interface version number of BTS/BSC (%u) is different (%u).\nPlease use a BTS/BSC with a compatble interface!\n", info_ind->version, PCU_IF_VERSION); exit(-1); @@ -1294,10 +1214,6 @@ CHECK_IF_MSG_SIZE(pcu_prim_length, pcu_prim->u.data_ind); rc = pcu_rx_data_ind(bts, &pcu_prim->u.data_ind); break; - case PCU_IF_MSG_DATA_CNF: - CHECK_IF_MSG_SIZE(pcu_prim_length, pcu_prim->u.data_cnf); - rc = pcu_rx_data_cnf(bts, &pcu_prim->u.data_cnf); - break; case PCU_IF_MSG_DATA_CNF_2: CHECK_IF_MSG_SIZE(pcu_prim_length, pcu_prim->u.data_cnf2); rc = pcu_rx_data_cnf2(bts, &pcu_prim->u.data_cnf2); diff --git a/tests/app_info/AppInfoTest.err b/tests/app_info/AppInfoTest.err index 6428556..7cb89f4 100644 --- a/tests/app_info/AppInfoTest.err +++ b/tests/app_info/AppInfoTest.err @@ -23,7 +23,7 @@ ws(64) MS(TA-220:MSCLS-10-11) Attaching DL TBF: TBF(DL:TFI-0-0-0:E){NEW} MS(TA-220:MSCLS-10-11:DL): + tbf: now used by 1 (tbf) -(bts=0,trx=0,ts=0) FN=0 Sending data request: sapi=3 arfcn=0 cur_fn=-1 block=0 data=30 30 30 2d 06 3f 30 0e 00 00 7d 80 00 1c 00 df ff ff ff f8 00 00 03 2b 2b 2b +(bts=0,trx=0,ts=0) FN=0 Sending data request: sapi=9 arfcn=0 cur_fn=-1 block=0 data=ff ff ff ff 2d 06 3f 30 0e 00 00 7d 80 00 1c 00 df ff ff ff f8 00 00 03 2b 2b 2b 01 Creating MS object Modifying MS object, TLLI = 0xffffffff, MS class 0 -> 12 Modifying MS object, TLLI = 0xffffffff, EGPRS MS class 0 -> 13 @@ -33,7 +33,7 @@ ws(64) MS(TA-220:MSCLS-12-13) Attaching DL TBF: TBF(DL:TFI-0-0-1:E){NEW} MS(TA-220:MSCLS-12-13:DL): + tbf: now used by 1 (tbf) -(bts=0,trx=0,ts=0) FN=0 Sending data request: sapi=3 arfcn=0 cur_fn=-1 block=0 data=30 30 30 2d 06 3f 30 0d 00 00 7d 80 00 1c 00 df ff ff ff f8 40 00 03 2b 2b 2b +(bts=0,trx=0,ts=0) FN=0 Sending data request: sapi=9 arfcn=0 cur_fn=-1 block=0 data=ff ff ff ff 2d 06 3f 30 0d 00 00 7d 80 00 1c 00 df ff ff ff f8 40 00 03 2b 2b 2b 01 --- test_sched_app_info_ok --- Application Information Request received: type=0x00000000 len=15 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/34706?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Change-Id: I68a3f59d5c960ae3a4fbd74f9d4a894295cb9ed8 Gerrit-Change-Number: 34706 Gerrit-PatchSet: 3 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> 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-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmo-bsc[master]: Make RLC timing data configurable
by arehbein 24 Oct '23

24 Oct '23
Attention is currently required from: pespin. arehbein has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/31878?usp=email ) Change subject: Make RLC timing data configurable ...................................................................... Patch Set 2: (1 comment) File src/osmo-bsc/net_init.c: https://gerrit.osmocom.org/c/osmo-bsc/+/31878/comment/03fbfef7_b9faad9b PS2, Line 51: { .T = 3142, .default_val = 20, > So we really need to add a osmo_tdef group per bts object. You can have a look at > asp->cfg.T_defs_lm in libosmo-sccp/src/osmo_ss7_asp.c:673 to find out how to add > a T_def instance per object (as opposed to a single structure per process like > the gsm_network_T_defs here). Basically: > """ > asp->cfg.T_defs_lm = talloc_memdup(asp, ss7_asp_lm_timer_defaults, > sizeof(ss7_asp_lm_timer_defaults)); > osmo_tdefs_reset(asp->cfg.T_defs_lm); > """ I have written some of the per-bts part on my local working copy, but I thought I'd ask before proceeding. I added an array of tdefs and an array of timer groups like in net_init.c, but since it's per BTS, I can't just add a tdef group to the one in net_init.c and use the tdef API with that to generate VTY commands automatically (the VTY command wouldn't be per BTS). I moved that code to bts_init.c - thinking I could use `osmo_tdef_vty_groups_init()` from libosmocore.git:src/vty/tdef_vty.c (which unfortunately didn't work out, because or reliance on a global variable `global_tdef_groups` that cannot be changed without breaking a previously set up tdef group). So my thought now is basically to replicate the tdef API code - pretty much staying the same except for I'd probably have to change usage of `global_tdef_groups` into usage of some BTS-dependent arrays of tdef groups automatically generating the commands for all tdef groups (I'm thinking "rlc", "bssgp" (other upcoming patch) and "nse" (other upcoming patch) would be appropriate groups for each BTS). So, to sum it up, the approach I would go for something like this (for each BTS): - Copy and adapt code from tdef_vty.c in libosmocore to enable per BTS tdef API functionality (put it in osmo-bsc.git:src/osmo-bsc/bts_vty.c ) - Set up an array of tdefs (copied from a default set) *(in theory we could make that configurable so that if a bts config is missing config values, it can take those from a 'global' bts timer config put in `global_tdef_groups` set up in the net_init.c code)* - Set up an array of tdef groups referenced in the bts struct I did look at the example in libosmo-sccp/src/osmo_ss7_asp.c, but since we're adding quite a few more timers here, using timer numbers from the specs and also with BSSGP and NSE timers in two other upcoming patches, I assume it makes more sence to go for the above mentioned approach instead of writing out each VTY timer command manually. What do you think? -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/31878?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I2c24110d8c977d6cc74c3c8e77bcc709ad9d2675 Gerrit-Change-Number: 31878 Gerrit-PatchSet: 2 Gerrit-Owner: arehbein <arehbein(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Tue, 24 Oct 2023 14:55:58 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: arehbein <arehbein(a)sysmocom.de> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: pySim-shell: don't get trapped in applications without file system
by dexter 24 Oct '23

24 Oct '23
Attention is currently required from: dexter. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/34884?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Verified-1 by Jenkins Builder Change subject: pySim-shell: don't get trapped in applications without file system ...................................................................... pySim-shell: don't get trapped in applications without file system When we traverse the file system, we may also end up selecting applications (ADF), which do not support an USIM/ISIM like file system. This will leave us without the ability to select the MF (or any other file) again. The only way out is to select the ISIM or USIM application again to get the access to the file system again. Related: OS#5418 Change-Id: Ia2fdd65f430c07acb1afdaf265d24c6928b654e0 --- M pySim-shell.py 1 file changed, 42 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/84/34884/2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34884?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: Ia2fdd65f430c07acb1afdaf265d24c6928b654e0 Gerrit-Change-Number: 34884 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in pysim[master]: pySim-shell: don't get trapped in applications without file system
by Jenkins Builder 24 Oct '23

24 Oct '23
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34884?usp=email ) Change subject: pySim-shell: don't get trapped in applications without file system ...................................................................... Patch Set 1: (1 comment) File pySim-shell.py: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-12083): https://gerrit.osmocom.org/c/pysim/+/34884/comment/286d2213_543ba27b PS1, Line 615: # To automatize this escape-route while traversing the file system we will check whether 'automatize' may be misspelled - perhaps 'automate'? -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34884?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: Ia2fdd65f430c07acb1afdaf265d24c6928b654e0 Gerrit-Change-Number: 34884 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Tue, 24 Oct 2023 14:26:39 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
[S] Change in pysim[master]: pySim-shell: don't get trapped in applications without file system
by dexter 24 Oct '23

24 Oct '23
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/34884?usp=email ) Change subject: pySim-shell: don't get trapped in applications without file system ...................................................................... pySim-shell: don't get trapped in applications without file system When we traverse the file system, we may also end up selecting applications (ADF), which do not support an USIM/ISIM like file system. This will leave us without the ability to select the MF (or any other file) again. The only way out is to select the ISIM or USIM application again to get the access to the file system again. Related: OS#5418 Change-Id: Ia2fdd65f430c07acb1afdaf265d24c6928b654e0 --- M pySim-shell.py 1 file changed, 42 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/84/34884/1 diff --git a/pySim-shell.py b/pySim-shell.py index 8a1ad01..2368f95 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -55,7 +55,7 @@ from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr, dec_iccid from pySim.card_handler import CardHandler, CardHandlerAuto -from pySim.filesystem import CardDF, CardADF, CardModel, CardApplication +from pySim.filesystem import CardMF, CardDF, CardADF, CardModel, CardApplication from pySim.runtime import RuntimeState from pySim.profile import CardProfile from pySim.cdma_ruim import CardProfileRUIM @@ -599,7 +599,31 @@ # below, so we must not move up. if skip_df == False: self.walk(indent + 1, action_ef, action_df, context, **kwargs) - fcp_dec = self._cmd.lchan.select("..", self._cmd) + + parent = self._cmd.lchan.selected_file.get_selectables()[".."] + df = self._cmd.lchan.selected_file + if isinstance(parent, CardMF) and (df.name not in [ "ADF.USIM", "ADF.ISIM"]): + # Not every application that may be present on a GlobalPlatform card will support the SELECT + # command as we know it from ETSI TS 102 221, section 11.1.1. In fact the only subset of + # SELECT we may rely on is the OPEN SELECT command as specified in GlobalPlatform Card + # Specification, section 11.9. Unfortunately the OPEN SELECT command only supports the + # "select by name" method, which means we can only select an application and not a file. + # The consequence of this is that we may get trapped in an application that does not have + # ISIM/USIM like file system support and the only way to leave that application is to select + # an ISIM/USIM application in order to get the file system access back. + # + # To automatize this escape-route while traversing the file system we will check whether + # the parent file is the MF. When this is the case and the selected ADF is not ADF.ISIM or + # ADF.USIM, we will select ADF.USIM or ADF.ISIM (depending on what is available) and from + # from there we will then select the MF. + for app in parent.applications: + if app in [ "a0000000871002", "a0000000871004"]: + adf_xsim = app + self._cmd.lchan.select(adf_xsim, self._cmd) + self._cmd.lchan.select("MF", self._cmd) + else: + # Normal DF/ADF selection + fcp_dec = self._cmd.lchan.select("..", self._cmd) elif action_ef: df_before_action = self._cmd.lchan.selected_file -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34884?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: Ia2fdd65f430c07acb1afdaf265d24c6928b654e0 Gerrit-Change-Number: 34884 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
[S] Change in pysim[master]: prevent SimCardCommands.select_adf_by_aid bypassing lchan
by laforge 24 Oct '23

24 Oct '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34849?usp=email ) ( 3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: prevent SimCardCommands.select_adf_by_aid bypassing lchan ...................................................................... prevent SimCardCommands.select_adf_by_aid bypassing lchan Now that pySim-shell is aware of logical channels and issues almost all of its APDUs on the currently selected channel, we must also make sure that ADF selection by AID (implemented by the CardBase class) issues the SELECT on the respective logical channel. Before this patch, SELECT ADF by AID would always be issued on the primary logical channel (0), irrespective of the currently active RuntimeLchan. Change-Id: Idf05c297e6a2e24ca539408b8912e348c0782bb4 Related: OS#6230 --- M pySim/cards.py M pySim/runtime.py 2 files changed, 26 insertions(+), 5 deletions(-) Approvals: Jenkins Builder: Verified dexter: Looks good to me, approved diff --git a/pySim/cards.py b/pySim/cards.py index 84f53e1..4573616 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -146,8 +146,10 @@ return True return False - def select_adf_by_aid(self, adf: str = "usim") -> Tuple[Optional[Hexstr], Optional[SwHexstr]]: + def select_adf_by_aid(self, adf: str = "usim", scc: Optional[SimCardCommands] = None) -> Tuple[Optional[Hexstr], Optional[SwHexstr]]: """Select ADF.U/ISIM in the Card using its full AID""" + # caller may pass a custom scc; we fall back to default + scc = scc or self._scc if is_hex(adf): aid = adf else: @@ -155,10 +157,10 @@ if aid: aid_full = self._complete_aid(aid) if aid_full: - return self._scc.select_adf(aid_full) + return scc.select_adf(aid_full) else: # If we cannot get the full AID, try with short AID - return self._scc.select_adf(aid) + return scc.select_adf(aid) return (None, None) def card_detect(scc: SimCardCommands) -> Optional[CardBase]: diff --git a/pySim/runtime.py b/pySim/runtime.py index 27c2ef1..a54a1b6 100644 --- a/pySim/runtime.py +++ b/pySim/runtime.py @@ -299,7 +299,7 @@ for p in inter_path: try: if isinstance(p, CardADF): - (data, sw) = self.rs.card.select_adf_by_aid(p.aid) + (data, sw) = self.rs.card.select_adf_by_aid(p.aid, scc=self.scc) self.selected_adf = p else: (data, sw) = self.scc.select_file(p.fid) @@ -343,7 +343,7 @@ f = sels[name] try: if isinstance(f, CardADF): - (data, sw) = self.rs.card.select_adf_by_aid(f.aid) + (data, sw) = self.rs.card.select_adf_by_aid(f.aid, scc=self.scc) else: (data, sw) = self.scc.select_file(f.fid) self.selected_file = f -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34849?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: Idf05c297e6a2e24ca539408b8912e348c0782bb4 Gerrit-Change-Number: 34849 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-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: commands.py: Add support for multiple logical channels.
by laforge 24 Oct '23

24 Oct '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34846?usp=email ) Change subject: commands.py: Add support for multiple logical channels. ...................................................................... commands.py: Add support for multiple logical channels. Historically we always only had one instance of SimCardCommands, but with this patch we can now have multiple instances, one for each lchan. The SimCardCommands class is aware of the logical channel it runs on and will patch the CLA byte accordingly. Change-Id: Ibe5650dedc0f7681acf82018a86f83377ba81d30 Related: OS#6230 --- M pySim/commands.py 1 file changed, 84 insertions(+), 9 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/commands.py b/pySim/commands.py index e072069..3edee98 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -26,7 +26,7 @@ from construct import * from pySim.construct import LV -from pySim.utils import rpad, lpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, str_sanitize, expand_hex +from pySim.utils import rpad, lpad, b2h, h2b, sw_match, bertlv_encode_len, Hexstr, h2i, i2h, str_sanitize, expand_hex from pySim.utils import Hexstr, SwHexstr, ResTuple from pySim.exceptions import SwMatchError from pySim.transport import LinkBase @@ -34,11 +34,70 @@ # A path can be either just a FID or a list of FID Path = typing.Union[Hexstr, List[Hexstr]] +def lchan_nr_to_cla(cla: int, lchan_nr: int) -> int: + """Embed a logical channel number into the CLA byte.""" + # TS 102 221 10.1.1 Coding of Class Byte + if lchan_nr < 4: + # standard logical channel number + if cla >> 4 in [0x0, 0xA, 0x8]: + return (cla & 0xFC) | (lchan_nr & 3) + else: + raise ValueError('Undefined how to use CLA %2X with logical channel %u' % (cla, lchan_nr)) + elif lchan_nr < 16: + # extended logical channel number + if cla >> 6 in [1, 3]: + return (cla & 0xF0) | ((lchan_nr - 4) & 0x0F) + else: + raise ValueError('Undefined how to use CLA %2X with logical channel %u' % (cla, lchan_nr)) + else: + raise ValueError('logical channel outside of range 0 .. 15') + +def cla_with_lchan(cla_byte: Hexstr, lchan_nr: int) -> Hexstr: + """Embed a logical channel number into the hex-string encoded CLA value.""" + cla_int = h2i(cla_byte)[0] + return i2h([lchan_nr_to_cla(cla_int, lchan_nr)]) + class SimCardCommands: - def __init__(self, transport: LinkBase): + """Class providing methods for various card-specific commands such as SELECT, READ BINARY, etc. + Historically one instance exists below CardBase, but with the introduction of multiple logical + channels there can be multiple instances. The lchan number will then be patched into the CLA + byte by the respective instance. """ + def __init__(self, transport: LinkBase, lchan_nr: int = 0): self._tp = transport - self.cla_byte = "a0" + self._cla_byte = None self.sel_ctrl = "0000" + self.lchan_nr = lchan_nr + # invokes the setter below + self.cla_byte = "a0" + + 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 + return ret + + @property + def cla_byte(self) -> Hexstr: + """Return the (cached) patched default CLA byte for this card.""" + return self._cla4lchan + + @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 + # compute cached result + self._cla4lchan = cla_with_lchan(self._cla_byte, self.lchan_nr) + + def cla4lchan(self, cla: Hexstr) -> Hexstr: + """Compute the lchan-patched value of the given CLA value. If no CLA + value is provided as argument, the lchan-patched version of the SimCardCommands._cla_byte + value is used. Most commands will use the latter, while some wish to override it and + can pass it as argument here.""" + if not cla: + # return cached result to avoid re-computing this over and over again + return self._cla4lchan + else: + return cla_with_lchan(cla, self.lchan_nr) # Extract a single FCP item from TLV def __parse_fcp(self, fcp: Hexstr): @@ -344,9 +403,9 @@ # TS 102 221 Section 11.3.1 low-level helper def _retrieve_data(self, tag: int, first: bool = True) -> ResTuple: if first: - pdu = '80cb008001%02x' % (tag) + pdu = self.cla4lchan('80') + 'cb008001%02x' % (tag) else: - pdu = '80cb000000' + pdu = self.cla4lchan('80') + 'cb000000' return self._tp.send_apdu_checksw(pdu) def retrieve_data(self, ef: Path, tag: int) -> ResTuple: @@ -376,7 +435,7 @@ p1 = 0x00 if isinstance(data, bytes) or isinstance(data, bytearray): data = b2h(data) - pdu = '80db00%02x%02x%s' % (p1, len(data)//2, data) + pdu = self.cla4lchan('80') + 'db00%02x%02x%s' % (p1, len(data)//2, data) return self._tp.send_apdu_checksw(pdu) def set_data(self, ef, tag: int, value: str, verify: bool = False, conserve: bool = False) -> ResTuple: @@ -419,7 +478,7 @@ if len(rand) != 32: raise ValueError('Invalid rand') self.select_path(['3f00', '7f20']) - return self._tp.send_apdu_checksw('a0' + '88000010' + rand, sw='9000') + return self._tp.send_apdu_checksw(self.cla4lchan('a0') + '88000010' + rand, sw='9000') def authenticate(self, rand: Hexstr, autn: Hexstr, context: str = '3g') -> ResTuple: """Execute AUTHENTICATE (USIM/ISIM). @@ -451,7 +510,7 @@ def status(self) -> ResTuple: """Execute a STATUS command as per TS 102 221 Section 11.1.2.""" - return self._tp.send_apdu_checksw('80F20000ff') + return self._tp.send_apdu_checksw(self.cla4lchan('80') + 'F20000ff') def deactivate_file(self) -> ResTuple: """Execute DECATIVATE FILE command as per TS 102 221 Section 11.1.14.""" @@ -471,7 +530,7 @@ def resize_file(self, payload: Hexstr) -> ResTuple: """Execute RESIZE FILE command as per TS 102 222 Section 6.10""" - return self._tp.send_apdu_checksw('80d40000%02x%s' % (len(payload)//2, payload)) + return self._tp.send_apdu_checksw(self.cla4lchan('80') + 'd40000%02x%s' % (len(payload)//2, payload)) def delete_file(self, fid: Hexstr) -> ResTuple: """Execute DELETE FILE command as per TS 102 222 Section 6.4""" -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34846?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: Ibe5650dedc0f7681acf82018a86f83377ba81d30 Gerrit-Change-Number: 34846 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-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: pySim-shell: Create + use per-RuntimeLchan SimCardCommands
by laforge 24 Oct '23

24 Oct '23
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34847?usp=email ) ( 3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: pySim-shell: Create + use per-RuntimeLchan SimCardCommands ...................................................................... pySim-shell: Create + use per-RuntimeLchan SimCardCommands This new approach will "fork" separate SimCardCommands instances for each RuntimeLchan. Higher-layer code should now always use the RuntimeLchan.scc rather than the RuntimeState.card._scc in order to make sure commands use the correct logical channel. Change-Id: I13e2e871f2afc2460d9fd1cd566de42267c7d389 Related: OS#6230 --- M pySim-shell.py M pySim/ara_m.py M pySim/commands.py M pySim/global_platform.py M pySim/runtime.py M pySim/ts_102_222.py M pySim/ts_31_102.py M pySim/ts_51_011.py 8 files changed, 60 insertions(+), 43 deletions(-) Approvals: dexter: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim-shell.py b/pySim-shell.py index 867795c..8a1ad01 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -326,7 +326,7 @@ DANGEROUS: pySim-shell will not know any card state changes, and not continue to work as expected if you e.g. select a different file.""" - data, sw = self.card._scc._tp.send_apdu(opts.APDU) + data, sw = self.lchan.scc._tp.send_apdu(opts.APDU) if data: self.poutput("SW: %s, RESP: %s" % (sw, data)) else: @@ -790,7 +790,7 @@ "cannot find ADM-PIN for ICCID '%s'" % (self._cmd.iccid)) if pin_adm: - self._cmd.card._scc.verify_chv(self._cmd.card._adm_chv_num, h2b(pin_adm)) + self._cmd.lchan.scc.verify_chv(self._cmd.card._adm_chv_num, h2b(pin_adm)) else: raise ValueError("error: cannot authenticate, no adm-pin!") @@ -798,10 +798,10 @@ """Display information about the currently inserted card""" self._cmd.poutput("Card info:") self._cmd.poutput(" Name: %s" % self._cmd.card.name) - self._cmd.poutput(" ATR: %s" % b2h(self._cmd.card._scc.get_atr())) + self._cmd.poutput(" ATR: %s" % b2h(self._cmd.lchan.scc.get_atr())) self._cmd.poutput(" ICCID: %s" % self._cmd.iccid) - self._cmd.poutput(" Class-Byte: %s" % self._cmd.card._scc.cla_byte) - self._cmd.poutput(" Select-Ctrl: %s" % self._cmd.card._scc.sel_ctrl) + self._cmd.poutput(" Class-Byte: %s" % self._cmd.lchan.scc.cla_byte) + self._cmd.poutput(" Select-Ctrl: %s" % self._cmd.lchan.scc.sel_ctrl) self._cmd.poutput(" AIDs:") for a in self._cmd.rs.mf.applications: self._cmd.poutput(" %s" % a) @@ -859,7 +859,7 @@ call it if you authenticate yourself using the specified PIN. There usually is at least PIN1 and PIN2.""" pin = self.get_code(opts.pin_code) - (data, sw) = self._cmd.card._scc.verify_chv(opts.pin_nr, h2b(pin)) + (data, sw) = self._cmd.lchan.scc.verify_chv(opts.pin_nr, h2b(pin)) self._cmd.poutput("CHV verification successful") unblock_chv_parser = argparse.ArgumentParser() @@ -875,7 +875,7 @@ """Unblock PIN code using specified PUK code""" new_pin = self.get_code(opts.new_pin_code) puk = self.get_code(opts.puk_code) - (data, sw) = self._cmd.card._scc.unblock_chv( + (data, sw) = self._cmd.lchan.scc.unblock_chv( opts.pin_nr, h2b(puk), h2b(new_pin)) self._cmd.poutput("CHV unblock successful") @@ -892,7 +892,7 @@ """Change PIN code to a new PIN code""" new_pin = self.get_code(opts.new_pin_code) pin = self.get_code(opts.pin_code) - (data, sw) = self._cmd.card._scc.change_chv( + (data, sw) = self._cmd.lchan.scc.change_chv( opts.pin_nr, h2b(pin), h2b(new_pin)) self._cmd.poutput("CHV change successful") @@ -906,7 +906,7 @@ def do_disable_chv(self, opts): """Disable PIN code using specified PIN code""" pin = self.get_code(opts.pin_code) - (data, sw) = self._cmd.card._scc.disable_chv(opts.pin_nr, h2b(pin)) + (data, sw) = self._cmd.lchan.scc.disable_chv(opts.pin_nr, h2b(pin)) self._cmd.poutput("CHV disable successful") enable_chv_parser = argparse.ArgumentParser() @@ -919,12 +919,12 @@ def do_enable_chv(self, opts): """Enable PIN code using specified PIN code""" pin = self.get_code(opts.pin_code) - (data, sw) = self._cmd.card._scc.enable_chv(opts.pin_nr, h2b(pin)) + (data, sw) = self._cmd.lchan.scc.enable_chv(opts.pin_nr, h2b(pin)) self._cmd.poutput("CHV enable successful") def do_deactivate_file(self, opts): """Deactivate the currently selected EF""" - (data, sw) = self._cmd.card._scc.deactivate_file() + (data, sw) = self._cmd.lchan.scc.deactivate_file() activate_file_parser = argparse.ArgumentParser() activate_file_parser.add_argument('NAME', type=str, help='File name or FID of file to activate') @@ -946,7 +946,7 @@ @cmd2.with_argparser(open_chan_parser) def do_open_channel(self, opts): """Open a logical channel.""" - (data, sw) = self._cmd.card._scc.manage_channel( + (data, sw) = self._cmd.lchan.scc.manage_channel( mode='open', lchan_nr=opts.chan_nr) # this is executed only in successful case, as unsuccessful raises exception self._cmd.lchan.add_lchan(opts.chan_nr) @@ -958,7 +958,7 @@ @cmd2.with_argparser(close_chan_parser) def do_close_channel(self, opts): """Close a logical channel.""" - (data, sw) = self._cmd.card._scc.manage_channel( + (data, sw) = self._cmd.lchan.scc.manage_channel( mode='close', lchan_nr=opts.chan_nr) # this is executed only in successful case, as unsuccessful raises exception self._cmd.rs.del_lchan(opts.chan_nr) diff --git a/pySim/ara_m.py b/pySim/ara_m.py index 8144381..b4ac747 100644 --- a/pySim/ara_m.py +++ b/pySim/ara_m.py @@ -306,13 +306,13 @@ def do_aram_get_all(self, opts): """GET DATA [All] on the ARA-M Applet""" - res_do = ADF_ARAM.get_all(self._cmd.card._scc._tp) + res_do = ADF_ARAM.get_all(self._cmd.lchan.scc._tp) if res_do: self._cmd.poutput_json(res_do.to_dict()) def do_aram_get_config(self, opts): """Perform GET DATA [Config] on the ARA-M Applet: Tell it our version and retrieve its version.""" - res_do = ADF_ARAM.get_config(self._cmd.card._scc._tp) + res_do = ADF_ARAM.get_config(self._cmd.lchan.scc._tp) if res_do: self._cmd.poutput_json(res_do.to_dict()) @@ -373,14 +373,14 @@ d = [{'ref_ar_do': [{'ref_do': ref_do_content}, {'ar_do': ar_do_content}]}] csrado = CommandStoreRefArDO() csrado.from_dict(d) - res_do = ADF_ARAM.store_data(self._cmd.card._scc._tp, csrado) + res_do = ADF_ARAM.store_data(self._cmd.lchan.scc._tp, csrado) if res_do: self._cmd.poutput_json(res_do.to_dict()) def do_aram_delete_all(self, opts): """Perform STORE DATA [Command-Delete[all]] to delete all access rules.""" deldo = CommandDelete() - res_do = ADF_ARAM.store_data(self._cmd.card._scc._tp, deldo) + res_do = ADF_ARAM.store_data(self._cmd.lchan.scc._tp, deldo) if res_do: self._cmd.poutput_json(res_do.to_dict()) diff --git a/pySim/commands.py b/pySim/commands.py index 3edee98..336cf0c 100644 --- a/pySim/commands.py +++ b/pySim/commands.py @@ -74,6 +74,7 @@ """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.sel_ctrl = self.sel_ctrl return ret @property diff --git a/pySim/global_platform.py b/pySim/global_platform.py index ea8b70d..bfa2adf 100644 --- a/pySim/global_platform.py +++ b/pySim/global_platform.py @@ -238,7 +238,7 @@ self._cmd.poutput('Unknown data object "%s", available options: %s' % (tlv_cls_name, do_names)) return - (data, sw) = self._cmd.card._scc.get_data(cla=0x80, tag=tlv_cls.tag) + (data, sw) = self._cmd.lchan.scc.get_data(cla=0x80, tag=tlv_cls.tag) ie = tlv_cls() ie.from_tlv(h2b(data)) self._cmd.poutput_json(ie.to_dict()) diff --git a/pySim/runtime.py b/pySim/runtime.py index 88de69e..27c2ef1 100644 --- a/pySim/runtime.py +++ b/pySim/runtime.py @@ -167,6 +167,7 @@ self.selected_adf = None self.selected_file_fcp = None self.selected_file_fcp_hex = None + self.scc = self.rs.card._scc.fork_lchan(lchan_nr) def add_lchan(self, lchan_nr: int) -> 'RuntimeLchan': """Add a new logical channel from the current logical channel. Just affects @@ -246,7 +247,7 @@ "Cannot select unknown file by name %s, only hexadecimal 4 digit FID is allowed" % fid) try: - (data, sw) = self.rs.card._scc.select_file(fid) + (data, sw) = self.scc.select_file(fid) except SwMatchError as swm: k = self.interpret_sw(swm.sw_actual) if not k: @@ -301,7 +302,7 @@ (data, sw) = self.rs.card.select_adf_by_aid(p.aid) self.selected_adf = p else: - (data, sw) = self.rs.card._scc.select_file(p.fid) + (data, sw) = self.scc.select_file(p.fid) self.selected_file = p except SwMatchError as swm: self._select_post(cmd_app) @@ -344,7 +345,7 @@ if isinstance(f, CardADF): (data, sw) = self.rs.card.select_adf_by_aid(f.aid) else: - (data, sw) = self.rs.card._scc.select_file(f.fid) + (data, sw) = self.scc.select_file(f.fid) self.selected_file = f except SwMatchError as swm: k = self.interpret_sw(swm.sw_actual) @@ -364,7 +365,7 @@ def status(self): """Request STATUS (current selected file FCP) from card.""" - (data, sw) = self.rs.card._scc.status() + (data, sw) = self.scc.status() return self.selected_file.decode_select_response(data) def get_file_for_selectable(self, name: str): @@ -375,7 +376,7 @@ """Request ACTIVATE FILE of specified file.""" sels = self.selected_file.get_selectables() f = sels[name] - data, sw = self.rs.card._scc.activate_file(f.fid) + data, sw = self.scc.activate_file(f.fid) return data, sw def read_binary(self, length: int = None, offset: int = 0): @@ -389,7 +390,7 @@ """ if not isinstance(self.selected_file, TransparentEF): raise TypeError("Only works with TransparentEF") - return self.rs.card._scc.read_binary(self.selected_file.fid, length, offset) + return self.scc.read_binary(self.selected_file.fid, length, offset) def read_binary_dec(self) -> Tuple[dict, str]: """Read [part of] a transparent EF binary data and decode it. @@ -413,7 +414,7 @@ """ if not isinstance(self.selected_file, TransparentEF): raise TypeError("Only works with TransparentEF") - return self.rs.card._scc.update_binary(self.selected_file.fid, data_hex, offset, conserve=self.rs.conserve_write) + return self.scc.update_binary(self.selected_file.fid, data_hex, offset, conserve=self.rs.conserve_write) def update_binary_dec(self, data: dict): """Update transparent EF from abstract data. Encodes the data to binary and @@ -436,7 +437,7 @@ if not isinstance(self.selected_file, LinFixedEF): raise TypeError("Only works with Linear Fixed EF") # returns a string of hex nibbles - return self.rs.card._scc.read_record(self.selected_file.fid, rec_nr) + return self.scc.read_record(self.selected_file.fid, rec_nr) def read_record_dec(self, rec_nr: int = 0) -> Tuple[dict, str]: """Read a record and decode it to abstract data. @@ -458,7 +459,7 @@ """ if not isinstance(self.selected_file, LinFixedEF): raise TypeError("Only works with Linear Fixed EF") - return self.rs.card._scc.update_record(self.selected_file.fid, rec_nr, data_hex, + return self.scc.update_record(self.selected_file.fid, rec_nr, data_hex, conserve=self.rs.conserve_write, leftpad=self.selected_file.leftpad) @@ -484,7 +485,7 @@ if not isinstance(self.selected_file, BerTlvEF): raise TypeError("Only works with BER-TLV EF") # returns a string of hex nibbles - return self.rs.card._scc.retrieve_data(self.selected_file.fid, tag) + return self.scc.retrieve_data(self.selected_file.fid, tag) def retrieve_tags(self): """Retrieve tags available on BER-TLV EF. @@ -494,7 +495,7 @@ """ if not isinstance(self.selected_file, BerTlvEF): raise TypeError("Only works with BER-TLV EF") - data, sw = self.rs.card._scc.retrieve_data(self.selected_file.fid, 0x5c) + data, sw = self.scc.retrieve_data(self.selected_file.fid, 0x5c) tag, length, value, remainder = bertlv_parse_one(h2b(data)) return list(value) @@ -507,7 +508,7 @@ """ if not isinstance(self.selected_file, BerTlvEF): raise TypeError("Only works with BER-TLV EF") - return self.rs.card._scc.set_data(self.selected_file.fid, tag, data_hex, conserve=self.rs.conserve_write) + return self.scc.set_data(self.selected_file.fid, tag, data_hex, conserve=self.rs.conserve_write) def unregister_cmds(self, cmd_app=None): """Unregister all file specific commands.""" diff --git a/pySim/ts_102_222.py b/pySim/ts_102_222.py index a4ea453..372d67f 100644 --- a/pySim/ts_102_222.py +++ b/pySim/ts_102_222.py @@ -49,7 +49,7 @@ self._cmd.perror("Refusing to permanently delete the file, please read the help text.") return f = self._cmd.lchan.get_file_for_selectable(opts.NAME) - (data, sw) = self._cmd.card._scc.delete_file(f.fid) + (data, sw) = self._cmd.lchan.scc.delete_file(f.fid) def complete_delete_file(self, text, line, begidx, endidx) -> List[str]: """Command Line tab completion for DELETE FILE""" @@ -70,7 +70,7 @@ self._cmd.perror("Refusing to terminate the file, please read the help text.") return f = self._cmd.lchan.get_file_for_selectable(opts.NAME) - (data, sw) = self._cmd.card._scc.terminate_df(f.fid) + (data, sw) = self._cmd.lchan.scc.terminate_df(f.fid) def complete_terminate_df(self, text, line, begidx, endidx) -> List[str]: """Command Line tab completion for TERMINATE DF""" @@ -86,7 +86,7 @@ self._cmd.perror("Refusing to terminate the file, please read the help text.") return f = self._cmd.lchan.get_file_for_selectable(opts.NAME) - (data, sw) = self._cmd.card._scc.terminate_ef(f.fid) + (data, sw) = self._cmd.lchan.scc.terminate_ef(f.fid) def complete_terminate_ef(self, text, line, begidx, endidx) -> List[str]: """Command Line tab completion for TERMINATE EF""" @@ -104,7 +104,7 @@ if not opts.force_terminate_card: self._cmd.perror("Refusing to permanently terminate the card, please read the help text.") return - (data, sw) = self._cmd.card._scc.terminate_card_usage() + (data, sw) = self._cmd.lchan.scc.terminate_card_usage() create_parser = argparse.ArgumentParser() create_parser.add_argument('FILE_ID', type=str, help='File Identifier as 4-character hex string') @@ -149,7 +149,7 @@ ShortFileIdentifier(decoded=opts.short_file_id), ] fcp = FcpTemplate(children=ies) - (data, sw) = self._cmd.card._scc.create_file(b2h(fcp.to_tlv())) + (data, sw) = self._cmd.lchan.scc.create_file(b2h(fcp.to_tlv())) # the newly-created file is automatically selected but our runtime state knows nothing of it self._cmd.lchan.select_file(self._cmd.lchan.selected_file) @@ -200,7 +200,7 @@ } ies.append(ProprietaryInformation(children=[ToolkitAccessConditions(decoded=toolkit_ac)])) fcp = FcpTemplate(children=ies) - (data, sw) = self._cmd.card._scc.create_file(b2h(fcp.to_tlv())) + (data, sw) = self._cmd.lchan.scc.create_file(b2h(fcp.to_tlv())) # the newly-created file is automatically selected but our runtime state knows nothing of it self._cmd.lchan.select_file(self._cmd.lchan.selected_file) @@ -217,7 +217,7 @@ ies = [FileIdentifier(decoded=f.fid), FileSize(decoded=opts.file_size)] fcp = FcpTemplate(children=ies) - (data, sw) = self._cmd.card._scc.resize_file(b2h(fcp.to_tlv())) + (data, sw) = self._cmd.lchan.scc.resize_file(b2h(fcp.to_tlv())) # the resized file is automatically selected but our runtime state knows nothing of it self._cmd.lchan.select_file(self._cmd.lchan.selected_file) diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 54ff4c8..cd0d99c 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -1512,7 +1512,7 @@ @cmd2.with_argparser(authenticate_parser) def do_authenticate(self, opts): """Perform Authentication and Key Agreement (AKA).""" - (data, sw) = self._cmd.card._scc.authenticate(opts.rand, opts.autn) + (data, sw) = self._cmd.lchan.scc.authenticate(opts.rand, opts.autn) self._cmd.poutput_json(data) term_prof_parser = argparse.ArgumentParser() @@ -1526,7 +1526,7 @@ in the context of SIM Toolkit, Proactive SIM and OTA. You must specify a hex-string with the encoded terminal profile you want to send to the card.""" - (data, sw) = self._cmd.card._scc.terminal_profile(opts.PROFILE) + (data, sw) = self._cmd.lchan.scc.terminal_profile(opts.PROFILE) self._cmd.poutput('SW: %s, data: %s' % (sw, data)) envelope_parser = argparse.ArgumentParser() @@ -1538,7 +1538,7 @@ variety of information is communicated from the terminal (modem/phone) to the card, particularly in the context of SIM Toolkit, Proactive SIM and OTA.""" - (data, sw) = self._cmd.card._scc.envelope(opts.PAYLOAD) + (data, sw) = self._cmd.lchan.scc.envelope(opts.PAYLOAD) self._cmd.poutput('SW: %s, data: %s' % (sw, data)) envelope_sms_parser = argparse.ArgumentParser() @@ -1556,7 +1556,7 @@ dev_ids = DeviceIdentities( decoded={'source_dev_id': 'network', 'dest_dev_id': 'uicc'}) sms_dl = SMSPPDownload(children=[dev_ids, tpdu_ie]) - (data, sw) = self._cmd.card._scc.envelope(b2h(sms_dl.to_tlv())) + (data, sw) = self._cmd.lchan.scc.envelope(b2h(sms_dl.to_tlv())) self._cmd.poutput('SW: %s, data: %s' % (sw, data)) get_id_parser = argparse.ArgumentParser() @@ -1570,7 +1570,7 @@ context = 0x01 # SUCI if opts.nswo_context: context = 0x02 # SUCI 5G NSWO - (data, sw) = self._cmd.card._scc.get_identity(context) + (data, sw) = self._cmd.lchan.scc.get_identity(context) do = SUCI_TlvDataObject() do.from_tlv(h2b(data)) do_d = do.to_dict() diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py index 14db686..7413098 100644 --- a/pySim/ts_51_011.py +++ b/pySim/ts_51_011.py @@ -1001,7 +1001,7 @@ @cmd2.with_argparser(authenticate_parser) def do_authenticate(self, opts): """Perform GSM Authentication.""" - (data, sw) = self._cmd.card._scc.run_gsm(opts.rand) + (data, sw) = self._cmd.lchan.scc.run_gsm(opts.rand) self._cmd.poutput_json(data) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34847?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: I13e2e871f2afc2460d9fd1cd566de42267c7d389 Gerrit-Change-Number: 34847 Gerrit-PatchSet: 4 Gerrit-Owner: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
[M] Change in pysim[master]: commands.py: Add support for multiple logical channels.
by laforge 24 Oct '23

24 Oct '23
Attention is currently required from: dexter, fixeria. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/34846?usp=email ) Change subject: commands.py: Add support for multiple logical channels. ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/34846?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: Ibe5650dedc0f7681acf82018a86f83377ba81d30 Gerrit-Change-Number: 34846 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-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Tue, 24 Oct 2023 13:26:50 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • ...
  • 185
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.