laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37613?usp=email )
Change subject: pySim-shell: turn "ADF-escape-code" into an lchan method.
......................................................................
pySim-shell: turn "ADF-escape-code" into an lchan method.
When we traverse the file system using the command "export" we will
also select all ADFs but not all ADFs may have UICC file system support.
This makes it impossible to exit those ADFs again. To exit anyway we
select an application with filesystem support first and then the parent
EF we wanted to select originally. This method may not only be useful
when traversing the filesystem, so let's put it into the RuntimeLchan
class and change it a little so that it would also work if the ADF in
question is an a sub DF.
Related: OS#6092
Change-Id: I72de51bc7519fafbcc71d829719a8af35d774342
---
M pySim-shell.py
M pySim/runtime.py
2 files changed, 50 insertions(+), 26 deletions(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim-shell.py b/pySim-shell.py
index 4f5959b..2eb37ea 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -535,32 +535,7 @@
# below, so we must not move up.
if skip_df == False:
self.walk(indent + 1, action_ef, action_df, context, **kwargs)
-
- parent = self._cmd.lchan.selected_file.parent
- df = self._cmd.lchan.selected_file
- adf = self._cmd.lchan.selected_adf
- if isinstance(parent, CardMF) and (adf and adf.has_fs == False):
- # 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 automate 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 has no file system
- # support, we will select an arbitrary ADF that has file system support first and from there
- # we will then select the MF.
- for selectable in parent.get_selectables().items():
- if isinstance(selectable[1], CardADF) and selectable[1].has_fs == True:
- self._cmd.lchan.select(selectable[1].name, self._cmd)
- break
- self._cmd.lchan.select(df.get_mf().name, self._cmd)
- else:
- # Normal DF/ADF selection
- fcp_dec = self._cmd.lchan.select("..", self._cmd)
+ self._cmd.lchan.select_parent(self._cmd)
elif action_ef:
df_before_action = self._cmd.lchan.selected_file
diff --git a/pySim/runtime.py b/pySim/runtime.py
index a56d884..a56df4d 100644
--- a/pySim/runtime.py
+++ b/pySim/runtime.py
@@ -396,6 +396,36 @@
return self.selected_file_fcp
+ def select_parent(self, cmd_app=None):
+ """Select the parent file of the currently selected file. This method also works in case the currently selected
+ file is an ADF without UICC file system support and can be used to exit those ADFs.
+ """
+ parent = self.selected_file.parent
+ df = self.selected_file
+ adf = self.selected_adf
+ if adf and adf.has_fs == False:
+ # 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 automate 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 has no file system
+ # support, we will select an arbitrary ADF that has file system support first and from there
+ # we will then select the MF.
+ for selectable in parent.get_selectables().items():
+ if isinstance(selectable[1], CardADF) and selectable[1].has_fs == True:
+ self.select(selectable[1].name, cmd_app)
+ break
+ self.select_file(parent, cmd_app)
+
+ # Select the parent file normally
+ self.select_file(parent, cmd_app)
+
def status(self):
"""Request STATUS (current selected file FCP) from card."""
(data, _sw) = self.scc.status()
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37613?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: I72de51bc7519fafbcc71d829719a8af35d774342
Gerrit-Change-Number: 37613
Gerrit-PatchSet: 3
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Attention is currently required from: laforge, lynxis lazus.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37646?usp=email )
Change subject: sgsn: Introduce test TC_pmm_idle_rx_mt_data
......................................................................
Patch Set 1:
(1 comment)
File sgsn/SGSN_Tests_Iu.ttcn:
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37646/comment/579870ee_a484…
PS1, Line 249: f_service_request(apars, pdp_status := '2000'O /*NSAPI=5*/, ran_index := 3);
@laforge@gnumonks.org @daniel@totalueberwachung.de @lynxis@fe80.eu I'm not sure if this is the expected type of answer to Paging for a UE in 3G.
In any case, the test is now passing after applying fix https://gerrit.osmocom.org/c/osmo-sgsn/+/37644/
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37646?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I35d660b8e546f6ce0af8c05d7b5c56833a26fb76
Gerrit-Change-Number: 37646
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-CC: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Comment-Date: Fri, 26 Jul 2024 17:31:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37646?usp=email )
Change subject: sgsn: Introduce test TC_pmm_idle_rx_mt_data
......................................................................
Set Ready For Review
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37646?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I35d660b8e546f6ce0af8c05d7b5c56833a26fb76
Gerrit-Change-Number: 37646
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Fri, 26 Jul 2024 17:29:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/37644?usp=email )
Change subject: Announce SGSN own TEID during UpdatePDPCtxReq after UE goes PMM-IDLE
......................................................................
Announce SGSN own TEID during UpdatePDPCtxReq after UE goes PMM-IDLE
When the UE/RNC closes the Iu conn (while keeping the PDP Context
activated), the SGSN updates the GGSN to point the GTPU tunnel to
itself. Unfortunately, only the IP address was being updated while the
TEID was kept the same (the one from the RNC).
As a result, when new MT data arrived at the GGSN, it would forward it
over GTPU to the SGSN using the incorrect RNC TEID, which the libgtp
stack at osmo-sgsn would silently drop due to not being known (because
it was >PDP_MAX=1024).
The issue can be triggered in test SGSN_Tests_Iu.TC_pmm_idle_rx_mt_data.
Related: OS#5773
Related: SYS#5435
Change-Id: I782aa43c71569922a945bd44544bb1388bf8c878
---
M include/osmocom/sgsn/pdpctx.h
M src/sgsn/gprs_mm_state_iu_fsm.c
M src/sgsn/sgsn_libgtp.c
3 files changed, 36 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/44/37644/1
diff --git a/include/osmocom/sgsn/pdpctx.h b/include/osmocom/sgsn/pdpctx.h
index f3cf0ed..39d744a 100644
--- a/include/osmocom/sgsn/pdpctx.h
+++ b/include/osmocom/sgsn/pdpctx.h
@@ -69,6 +69,9 @@
uint8_t radio_prio;
//uint32_t charging_id;
bool ue_pdp_active; /* PDP Context is active for this NSAPI? */
+ /* Keeps original SGSN local TEID when lib->teid_own is updated with
+ * RNC's TEID upon use of Direct Tunnel feature: */
+ uint32_t sgsn_teid_own;
struct osmo_timer_list timer;
unsigned int T; /* Txxxx number */
diff --git a/src/sgsn/gprs_mm_state_iu_fsm.c b/src/sgsn/gprs_mm_state_iu_fsm.c
index b883278..b376d98 100644
--- a/src/sgsn/gprs_mm_state_iu_fsm.c
+++ b/src/sgsn/gprs_mm_state_iu_fsm.c
@@ -49,9 +49,11 @@
char buf[INET_ADDRSTRLEN];
struct sgsn_pdp_ctx *pdp;
llist_for_each_entry(pdp, &mm_ctx->pdp_list, list) {
- LOGMMCTXP(LOGL_INFO, mm_ctx, "Changing GTP-U endpoints %s -> %s\n",
- sgsn_gtp_ntoa(&pdp->lib->gsnlu),
- inet_ntop(AF_INET, &sgsn->cfg.gtp_listenaddr.sin_addr, buf, sizeof(buf)));
+ LOGMMCTXP(LOGL_INFO, mm_ctx, "Changing GTP-U endpoints %s/0x%08x -> %s/0x%08x\n",
+ sgsn_gtp_ntoa(&pdp->lib->gsnlu), pdp->lib->teid_own,
+ inet_ntop(AF_INET, &sgsn->cfg.gtp_listenaddr.sin_addr, buf, sizeof(buf)),
+ pdp->sgsn_teid_own);
+ pdp->lib->teid_own = pdp->sgsn_teid_own;
/* Disable Direct Tunnel Flags DTI: */
pdp->lib->dir_tun_flags.l = 1;
pdp->lib->dir_tun_flags.v[0] &= 0xFE;
diff --git a/src/sgsn/sgsn_libgtp.c b/src/sgsn/sgsn_libgtp.c
index 4885ada..f497609 100644
--- a/src/sgsn/sgsn_libgtp.c
+++ b/src/sgsn/sgsn_libgtp.c
@@ -166,6 +166,9 @@
pdp->priv = pctx;
pctx->lib = pdp;
+ /* Back up our own local TEID in case we update the library one with RNC TEID when setting up Direct Tunnel: */
+ pctx->sgsn_teid_own = pdp->teid_own;
+
//pdp->peer = /* sockaddr_in of GGSN (receive) */
//pdp->ipif = /* not used by library */
pdp->version = ggsn->gtp_version;
@@ -783,6 +786,8 @@
#ifdef BUILD_IU
/* Ignore the packet for now and page the UE to get the RAB
* reestablished */
+ LOGMMCTXP(LOGL_INFO, mm, "Rx GTP for UE in PMM state %s, paging it\n",
+ osmo_fsm_inst_state_name(mm->iu.mm_state_fsm));
ranap_iu_page_ps(mm->imsi, &mm->p_tmsi, mm->ra.lac, mm->ra.rac);
return 0;
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/37644?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I782aa43c71569922a945bd44544bb1388bf8c878
Gerrit-Change-Number: 37644
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange