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
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37643?usp=email )
Change subject: ara_m: add export support for the ARA-M application
......................................................................
ara_m: add export support for the ARA-M application
This patch adds an export method to the CardApplicationARAM class.
This method reads the ARA-M configuration and transforms it into
executeable command lines, which can be executed as a script later
to restore an ARA-M configuration.
Related: OS#6092
Change-Id: I811cb9d25cb8ee194b4ead5fb2cabf1fdc0c1c43
---
M pySim/ara_m.py
1 file changed, 86 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/43/37643/1
diff --git a/pySim/ara_m.py b/pySim/ara_m.py
index c283cf0..c327e13 100644
--- a/pySim/ara_m.py
+++ b/pySim/ara_m.py
@@ -415,3 +415,74 @@
class CardApplicationARAM(CardApplication):
def __init__(self):
super().__init__('ARA-M', adf=ADF_ARAM(), sw=sw_aram)
+
+ @staticmethod
+ def export(as_json: bool, lchan):
+
+ # TODO: Add JSON output as soon as aram_store_ref_ar_do is able to process input in JSON format.
+ if as_json:
+ raise NotImplementedError("res_do encoder not yet implemented. Patches welcome.")
+
+ export_str = ""
+ export_str += "aram_delete_all\n"
+
+ res_do = ADF_ARAM.get_all(lchan.scc._tp)
+ if res_do:
+ for res_do_dict in res_do.to_dict():
+ if 'response_all_ref_ar_do' in res_do_dict and res_do_dict['response_all_ref_ar_do']:
+ for ref_ar_do_list in res_do_dict['response_all_ref_ar_do']:
+ ref_do_list = None
+ ar_do_list = None
+ if 'ref_ar_do' in ref_ar_do_list:
+ for ref_ar_do in ref_ar_do_list['ref_ar_do']:
+ if 'ref_do' in ref_ar_do:
+ ref_do_list = ref_ar_do['ref_do']
+ if 'ar_do' in ref_ar_do:
+ ar_do_list = ref_ar_do['ar_do']
+
+ if ref_do_list and ar_do_list:
+ aid_ref_do = None
+ dev_app_id_ref_do = None
+ apdu_ar_do = None
+ nfc_ar_do = None
+ perm_ar_do = None
+ pkg_ref_do = None
+ for ref_do in ref_do_list:
+ if 'aid_ref_do' in ref_do:
+ aid_ref_do = ref_do['aid_ref_do']
+ if 'dev_app_id_ref_do' in ref_do:
+ dev_app_id_ref_do = ref_do['dev_app_id_ref_do']
+ if 'pkg_ref_do' in ref_do:
+ pkg_ref_do = ref_do['pkg_ref_do']
+ for ar_do in ar_do_list:
+ if 'apdu_ar_do' in ar_do:
+ apdu_ar_do = ar_do['apdu_ar_do']
+ if 'nfc_ar_do' in ar_do:
+ nfc_ar_do = ar_do['nfc_ar_do']
+ if 'perm_ar_do' in ar_do:
+ perm_ar_do = ar_do['perm_ar_do']
+
+ # Write command-line
+ export_str += "aram_store_ref_ar_do"
+ if aid_ref_do:
+ export_str += (" --aid %s" % aid_ref_do)
+ else:
+ export_str += " --aid-empty"
+ if dev_app_id_ref_do:
+ export_str += (" --device-app-id %s" % dev_app_id_ref_do)
+ if apdu_ar_do and 'generic_access_rule' in apdu_ar_do:
+ export_str += (" --apdu-%s" % apdu_ar_do['generic_access_rule'])
+ elif apdu_ar_do and 'apdu_filter' in apdu_ar_do:
+ export_str += (" --apdu-filter ")
+ for apdu_filter in apdu_ar_do['apdu_filter']:
+ export_str += apdu_filter['header']
+ export_str += apdu_filter['mask']
+ if nfc_ar_do and 'nfc_event_access_rule' in nfc_ar_do:
+ export_str += (" --nfc-%s" % nfc_ar_do['nfc_event_access_rule'])
+ if perm_ar_do:
+ export_str += (" --android-permissions %s" % perm_ar_do['permissions'])
+ if pkg_ref_do:
+ export_str += (" --pkg-ref %s" % pkg_ref_do['package_name_string'])
+ export_str += "\n"
+
+ return export_str.strip()
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37643?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: I811cb9d25cb8ee194b4ead5fb2cabf1fdc0c1c43
Gerrit-Change-Number: 37643
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37637?usp=email )
Change subject: pySim-shell: fix comment formatting
......................................................................
pySim-shell: fix comment formatting
Related: OS#6092
Change-Id: Icea88c061436d26a3240fc666fcc3fe1bd36d2ba
---
M pySim-shell.py
1 file changed, 16 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/37/37637/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 8f654bd..168c916 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -813,14 +813,14 @@
@cmd2.with_argparser(activate_file_parser)
def do_activate_file(self, opts):
"""Activate the specified EF by sending an ACTIVATE FILE apdu command (used to be called REHABILITATE
-in TS 11.11 for classic SIM).
+ in TS 11.11 for classic SIM).
-This command is used to (re-)activate a file that is currently in deactivated (sometimes also called
-"invalidated") state. You need to call this from the DF above the to-be-activated EF and specify the name or
-FID of the file to activate.
+ This command is used to (re-)activate a file that is currently in deactivated (sometimes also called
+ "invalidated") state. You need to call this from the DF above the to-be-activated EF and specify the name or
+ FID of the file to activate.
-Note that for *deactivation* the to-be-deactivated EF must be selected, but for *activation*, the DF
-above the to-be-activated EF must be selected!"""
+ Note that for *deactivation* the to-be-deactivated EF must be selected, but for *activation*, the DF
+ above the to-be-activated EF must be selected!"""
(data, sw) = self._cmd.lchan.activate_file(opts.NAME)
def complete_activate_file(self, text, line, begidx, endidx) -> List[str]:
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37637?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: Icea88c061436d26a3240fc666fcc3fe1bd36d2ba
Gerrit-Change-Number: 37637
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37642?usp=email )
Change subject: filesystem: add export method for ADF files
......................................................................
filesystem: add export method for ADF files
This patch adds an export method to CardADF, which calls the application
specific export method in CardApplication class
Related: OS#6092
Change-Id: I8129656096ecaf41b36e5f2afbbfbebcd0587886
---
M pySim/filesystem.py
1 file changed, 20 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/42/37642/1
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 5414fb9..028b906 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -530,6 +530,13 @@
else:
return self.aid
+ @staticmethod
+ def export(as_json: bool, lchan):
+ """
+ Export application specific parameters that are not part of the eUICC filesystem.
+ """
+ return lchan.selected_file.application.export(as_json, lchan)
+
class CardEF(CardFile):
"""EF (Entry File) in the smart card filesystem"""
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37642?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: I8129656096ecaf41b36e5f2afbbfbebcd0587886
Gerrit-Change-Number: 37642
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37641?usp=email )
Change subject: pySim-shell: enable export of DF and ADF files
......................................................................
pySim-shell: enable export of DF and ADF files
Since we now have the ability to provide export methods for all files
in the file system (this also includes DF and ADF files), we need
to support this at shell command level as well.
Related: OS#6092
Change-Id: I3ee661dbae5c11fec23911775f352ac13bc2c6e5
---
M pySim-shell.py
1 file changed, 82 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/41/37641/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 168c916..8fc348e 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -494,12 +494,22 @@
self._cmd.poutput(directory_str)
self._cmd.poutput("%d files" % len(selectables))
+ def _walk_action(self, action, file, context, **kwargs):
+ df_before_action = self._cmd.lchan.selected_file
+ action(file, context, **kwargs)
+ # When walking through the file system tree the action must not
+ # always restore the currently selected file to the file that
+ # was selected before executing the action() callback.
+ if df_before_action != self._cmd.lchan.selected_file:
+ raise RuntimeError("inconsistent walk, %s is currently selected but expecting %s to be selected"
+ % (str(self._cmd.lchan.selected_file), str(df_before_action)))
+
def walk(self, indent=0, action_ef=None, action_df=None, context=None, **kwargs):
"""Recursively walk through the file system, starting at the currently selected DF"""
if isinstance(self._cmd.lchan.selected_file, CardDF):
if action_df:
- action_df(context, **kwargs)
+ self._walk_action(action_df, self._cmd.lchan.selected_file.name, context, **kwargs)
files = self._cmd.lchan.selected_file.get_selectables(
flags=['FNAMES', 'ANAMES'])
@@ -536,14 +546,7 @@
self._cmd.lchan.select_parent(self._cmd)
elif action_ef:
- df_before_action = self._cmd.lchan.selected_file
- action_ef(f, context, **kwargs)
- # When walking through the file system tree the action must not
- # always restore the currently selected file to the file that
- # was selected before executing the action() callback.
- if df_before_action != self._cmd.lchan.selected_file:
- raise RuntimeError("inconsistent walk, %s is currently selected but expecting %s to be selected"
- % (str(self._cmd.lchan.selected_file), str(df_before_action)))
+ self._walk_action(action_ef, f, context, **kwargs)
def do_tree(self, opts):
"""Display a filesystem-tree with all selectable files"""
@@ -594,11 +597,58 @@
self._cmd.poutput("#")
+ def export_df(self, filename, context, as_json):
+ """ Select and export a single application dedicated file (ADF) """
+ context['COUNT'] += 1
+ df = self._cmd.lchan.selected_file
+
+ # The currently selected file (not the file we are going to export)
+ # must always be an ADF or DF. From this starting point we select
+ # the ADF we want to export. To maintain consistency we will then
+ # select the current DF again (see comment below).
+ if not isinstance(df, CardDF):
+ raise RuntimeError(
+ "currently selected file %s is not a DF or ADF" % str(df))
+
+ df_path_list = df.fully_qualified_path(True)
+ df_path = df.fully_qualified_path_str(True)
+ df_path_fid = df.fully_qualified_path_str(False)
+
+ file_str = df_path + "/" + str(filename)
+ self._cmd.poutput(boxed_heading_str(file_str))
+
+ self._cmd.poutput("# directory: %s (%s)" % (df_path, df_path_fid))
+ try:
+ fcp_dec = self._cmd.lchan.select(filename, self._cmd)
+ self._cmd.poutput("# file: %s (%s)" %
+ (self._cmd.lchan.selected_file.name, self._cmd.lchan.selected_file.aid))
+ self._cmd.poutput("# RAW FCP Template: %s" % str(self._cmd.lchan.selected_file_fcp_hex))
+ self._cmd.poutput("# Decoded FCP Template: %s" % str(self._cmd.lchan.selected_file_fcp))
+ self._cmd.poutput("select " + self._cmd.lchan.selected_file.fully_qualified_path_str())
+ self._cmd.poutput(self._cmd.lchan.selected_file.export(as_json, self._cmd.lchan))
+
+ except Exception as e:
+ bad_file_str = df_path + "/" + str(filename) + ", " + str(e)
+ self._cmd.poutput("# bad file: %s" % bad_file_str)
+ context['ERR'] += 1
+ context['BAD'].append(bad_file_str)
+
+ # When reading the file is done, make sure the parent file is
+ # selected again. This will be the usual case, however we need
+ # to check before since we must not select the same DF twice
+ if df != self._cmd.lchan.selected_file:
+ self._cmd.lchan.select_parent(self._cmd)
+
+ self._cmd.poutput("#")
+
+
export_parser = argparse.ArgumentParser()
export_parser.add_argument(
'--filename', type=str, default=None, help='only export specific file')
export_parser.add_argument(
'--json', action='store_true', help='export as JSON (less reliable)')
+ export_parser.add_argument(
+ '--include_df', action='store_true', help='also export DF and ADF files (where possible)')
@cmd2.with_argparser(export_parser)
def do_export(self, opts):
@@ -609,10 +659,17 @@
exception_str_add = ""
if opts.filename:
- self.export_ef(opts.filename, context, **kwargs_export)
+ file = self._cmd.lchan.get_file_for_filename(opts.filename)
+ if isinstance(file, CardDF):
+ self.export_df(opts.filename, context, **kwargs_export)
+ else:
+ self.export_ef(opts.filename, context, **kwargs_export)
else:
try:
- self.walk(0, self.export_ef, None, context, **kwargs_export)
+ if opts.include_df:
+ self.walk(0, self.export_ef, self.export_df, context, **kwargs_export)
+ else:
+ self.walk(0, self.export_ef, None, context, **kwargs_export)
except Exception as e:
print("# Stopping early here due to exception: " + str(e))
print("#")
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37641?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: I3ee661dbae5c11fec23911775f352ac13bc2c6e5
Gerrit-Change-Number: 37641
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: newchange