Build failure of network:osmocom:nightly/libosmo-abis in xUbuntu_18.04/x86_64

2020-03-21 Thread OBS Notification
Visit 
https://build.opensuse.org/package/live_build_log/network:osmocom:nightly/libosmo-abis/xUbuntu_18.04/x86_64

Package network:osmocom:nightly/libosmo-abis failed to build in 
xUbuntu_18.04/x86_64

Check out the package for editing:
  osc checkout network:osmocom:nightly libosmo-abis

Last lines of build log:
[   76s] [215/231] installing libpam-runtime-1.1.8-3.6ubuntu2
[   76s] Processing triggers for man-db (2.8.3-2) ...
[   76s] [216/231] installing po-debconf-1.0.20
[   76s] Processing triggers for man-db (2.8.3-2) ...
[   77s] [217/231] installing bash-4.4.18-2ubuntu1
[   77s] update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to 
provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode
[   77s] Processing triggers for install-info (6.5.0.dfsg.1-2) ...
[   77s] Processing triggers for man-db (2.8.3-2) ...
[   78s] [218/231] installing libpython3.6-3.6.5-3
[   78s] Processing triggers for libc-bin (2.27-3ubuntu1) ...
[   78s] [219/231] installing passwd-1:4.5-1ubuntu1
[   78s] [   68.350334] EXT4-fs error (device sda): __ext4_iget:4973: inode 
#68: block 1: comm dpkg: invalid block
[   78s] dpkg: error processing archive .init_b_cache/passwd.deb (--install):
[   78s]  unable to stat './usr/share/man/ru/man8/groupmems.8.gz' (which I was 
about to install): Structure needs cleaning
[   78s] dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
[   78s] Processing triggers for man-db (2.8.3-2) ...
[   78s] [   68.590941] EXT4-fs error (device sda): __ext4_iget:4973: inode 
#68: block 1: comm mandb: invalid block
[   78s] [   68.593572] EXT4-fs error (device sda): __ext4_iget:4973: inode 
#68: block 1: comm mandb: invalid block
[   78s] [   68.595934] EXT4-fs error (device sda): __ext4_iget:4973: inode 
#68: block 1: comm mandb: invalid block
[   78s] Errors were encountered while processing:
[   78s]  .init_b_cache/passwd.deb
[   78s] exit ...
[   78s] ### VM INTERACTION START ###
[   81s] [   71.797330] sysrq: SysRq : Power Off
[   81s] [   71.802052] reboot: Power down
[   81s] ### VM INTERACTION END ###
[   81s] 
[   81s] lamb08 failed "build libosmo-abis_0.8.0.18.54c9.dsc" at Sun Mar 22 
01:38:37 UTC 2020.
[   81s] 

-- 
Configure notifications at https://build.opensuse.org/my/notifications
openSUSE Build Service (https://build.opensuse.org/)


Change in osmo-gsm-tester[master]: srs_enb: make sure to only use a single PHY thread when running with ZMQ

2020-03-21 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17563 )

Change subject: srs_enb: make sure to only use a single PHY thread when running 
with ZMQ
..


Patch Set 1: Code-Review+1

(1 comment)

https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17563/1/src/osmo_gsm_tester/templates/srsenb.conf.tmpl
File src/osmo_gsm_tester/templates/srsenb.conf.tmpl:

https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17563/1/src/osmo_gsm_tester/templates/srsenb.conf.tmpl@269
PS1, Line 269:   nof_phy_threads  = 1
Just wondering: is it fine having whitespace at the start of the line?
BTW, since later we may want to change this based on other parameters when 
running with UHD, it may make sense to add a "num_phy_threads" to the 
dictionary in configure() function of srs_enb.py and simply use it here.



--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17563
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: Icc1e67705c0354ece77c037f224a9c756a16daaa
Gerrit-Change-Number: 17563
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Sat, 21 Mar 2020 23:58:43 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-gsm-tester[master]: srs_ue: run srsUE as normal RemoteProcess

2020-03-21 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17562 )

Change subject: srs_ue: run srsUE as normal RemoteProcess
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17562
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: Iab4dafc58167620362a36ec9e904b8d49a7d5fc1
Gerrit-Change-Number: 17562
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Sat, 21 Mar 2020 23:56:26 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-gsm-tester[master]: srs_ue: send t+Enter to stdin after launching app

2020-03-21 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17561 )

Change subject: srs_ue: send t+Enter to stdin after launching app
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17561/1/src/osmo_gsm_tester/srs_ue.py
File src/osmo_gsm_tester/srs_ue.py:

https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17561/1/src/osmo_gsm_tester/srs_ue.py@125
PS1, Line 125: self.log('Enabling console trace')
Probably better using self.dbg() here



--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17561
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: If1c998aff1c5c11d3fa636fb60cb4991e0def768
Gerrit-Change-Number: 17561
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin 
Gerrit-Comment-Date: Sat, 21 Mar 2020 23:55:01 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in osmo-gsm-tester[master]: process: add stdin_write method to communicate with child on stdin

2020-03-21 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17560 )

Change subject: process: add stdin_write method to communicate with child on 
stdin
..


Patch Set 1: Code-Review-1

(2 comments)

https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17560/1/src/osmo_gsm_tester/process.py
File src/osmo_gsm_tester/process.py:

https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17560/1/src/osmo_gsm_tester/process.py@358
PS1, Line 358: 
self.process_obj.communicate(input="{}".format(cmd).encode("utf-8"), timeout=5)
afair the timeout is to verify the process exits after sending the data through 
stdin, are you sure that's what you want here?


https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17560/1/src/osmo_gsm_tester/process.py@360
PS1, Line 360: self.log('Timeout expired while writing to stdout')
You mean while writing to stdin



--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17560
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I3e5d843911998bb50726d93e3dfd3de584dc81a5
Gerrit-Change-Number: 17560
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Sat, 21 Mar 2020 23:52:59 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-gsm-tester[master]: srs_ue: add class member to pass additional cmd line args

2020-03-21 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17536 )

Change subject: srs_ue: add class member to pass additional cmd line args
..


Patch Set 2: -Code-Review

I still lack some information regarding how do you plan to use this, to 
understand whether it makes more sense to have it passed through config (and 
not programatically in test).


--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17536
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I969fb7f34a865218e39563844de273cf5587e3ee
Gerrit-Change-Number: 17536
Gerrit-PatchSet: 2
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Sat, 21 Mar 2020 23:50:44 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-gsm-tester[master]: srsenb.conf.tmpl: update to new version

2020-03-21 Thread pespin
pespin has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17533 )

Change subject: srsenb.conf.tmpl: update to new version
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17533
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I204d03307aaaddcb15fed6f7310b64d09c43f64c
Gerrit-Change-Number: 17533
Gerrit-PatchSet: 2
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin 
Gerrit-Comment-Date: Sat, 21 Mar 2020 23:47:40 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in osmo-gsm-tester[master]: srs_enb: make sure to only use a single PHY thread when running with ZMQ

2020-03-21 Thread srs_andre
srs_andre has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17563 )


Change subject: srs_enb: make sure to only use a single PHY thread when running 
with ZMQ
..

srs_enb: make sure to only use a single PHY thread when running with ZMQ

Change-Id: Icc1e67705c0354ece77c037f224a9c756a16daaa
---
M src/osmo_gsm_tester/templates/srsenb.conf.tmpl
M src/osmo_gsm_tester/templates/srsue.conf.tmpl
2 files changed, 6 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester 
refs/changes/63/17563/1

diff --git a/src/osmo_gsm_tester/templates/srsenb.conf.tmpl 
b/src/osmo_gsm_tester/templates/srsenb.conf.tmpl
index 51afcce..cdfe5ca 100644
--- a/src/osmo_gsm_tester/templates/srsenb.conf.tmpl
+++ b/src/osmo_gsm_tester/templates/srsenb.conf.tmpl
@@ -265,7 +265,9 @@
 [expert]
 #pusch_max_its= 8 # These are half iterations
 #pusch_8bit_decoder   = false
-#nof_phy_threads  = 3
+% if enb.get('rf_dev_type') == 'zmq':
+  nof_phy_threads  = 1
+% endif
 #metrics_period_secs  = 1
 #metrics_csv_enable   = false
 #metrics_csv_filename = /tmp/enb_metrics.csv
diff --git a/src/osmo_gsm_tester/templates/srsue.conf.tmpl 
b/src/osmo_gsm_tester/templates/srsue.conf.tmpl
index 4a4828e..91f9277 100644
--- a/src/osmo_gsm_tester/templates/srsue.conf.tmpl
+++ b/src/osmo_gsm_tester/templates/srsue.conf.tmpl
@@ -317,7 +317,9 @@
 #snr_ema_coeff   = 0.1
 #snr_estim_alg   = refs
 #pdsch_max_its   = 8# These are half iterations
-#nof_phy_threads = 3
+% if ue.get('rf_dev_type') == 'zmq':
+  nof_phy_threads = 1
+% endif
 #equalizer_mode  = mmse
 #sfo_ema = 0.1
 #sfo_correct_period  = 10

--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17563
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: Icc1e67705c0354ece77c037f224a9c756a16daaa
Gerrit-Change-Number: 17563
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-MessageType: newchange


Change in osmo-gsm-tester[master]: srs_ue: send t+Enter to stdin after launching app

2020-03-21 Thread srs_andre
srs_andre has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17561 )


Change subject: srs_ue: send t+Enter to stdin after launching app
..

srs_ue: send t+Enter to stdin after launching app

this enables the console trace which is printed to stdout
and provides human readable radio statistics

Change-Id: If1c998aff1c5c11d3fa636fb60cb4991e0def768
---
M src/osmo_gsm_tester/srs_ue.py
1 file changed, 4 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester 
refs/changes/61/17561/1

diff --git a/src/osmo_gsm_tester/srs_ue.py b/src/osmo_gsm_tester/srs_ue.py
index 66ed18b..ffd847b 100644
--- a/src/osmo_gsm_tester/srs_ue.py
+++ b/src/osmo_gsm_tester/srs_ue.py
@@ -121,6 +121,10 @@
 else:
 self.start_remotely()

+# send t+Enter to enable console trace
+self.log('Enabling console trace')
+self.process.stdin_write('t\n')
+
 def start_remotely(self):
 self.inst = 
util.Dir(os.path.abspath(self.suite_run.trial.get_inst('srslte')))
 lib = self.inst.child('lib')

--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17561
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: If1c998aff1c5c11d3fa636fb60cb4991e0def768
Gerrit-Change-Number: 17561
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-MessageType: newchange


Change in osmo-gsm-tester[master]: srs_ue: add class member to pass additional cmd line args

2020-03-21 Thread srs_andre
Hello pespin, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17536

to look at the new patch set (#2).

Change subject: srs_ue: add class member to pass additional cmd line args
..

srs_ue: add class member to pass additional cmd line args

this is helpful to add temporary command line args from within tests

Change-Id: I969fb7f34a865218e39563844de273cf5587e3ee
---
M src/osmo_gsm_tester/srs_ue.py
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester 
refs/changes/36/17536/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17536
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I969fb7f34a865218e39563844de273cf5587e3ee
Gerrit-Change-Number: 17536
Gerrit-PatchSet: 2
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin 
Gerrit-MessageType: newpatchset


Change in osmo-gsm-tester[master]: srsenb.conf.tmpl: update to new version

2020-03-21 Thread srs_andre
Hello pespin, Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17533

to look at the new patch set (#2).

Change subject: srsenb.conf.tmpl: update to new version
..

srsenb.conf.tmpl: update to new version

Change-Id: I204d03307aaaddcb15fed6f7310b64d09c43f64c
---
M src/osmo_gsm_tester/templates/srsenb.conf.tmpl
1 file changed, 7 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester 
refs/changes/33/17533/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17533
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I204d03307aaaddcb15fed6f7310b64d09c43f64c
Gerrit-Change-Number: 17533
Gerrit-PatchSet: 2
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin 
Gerrit-MessageType: newpatchset


Change in osmo-gsm-tester[master]: process: add stdin_write method to communicate with child on stdin

2020-03-21 Thread srs_andre
srs_andre has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17560 )


Change subject: process: add stdin_write method to communicate with child on 
stdin
..

process: add stdin_write method to communicate with child on stdin

Change-Id: I3e5d843911998bb50726d93e3dfd3de584dc81a5
---
M src/osmo_gsm_tester/process.py
1 file changed, 9 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester 
refs/changes/60/17560/1

diff --git a/src/osmo_gsm_tester/process.py b/src/osmo_gsm_tester/process.py
index f399b29..4561a48 100644
--- a/src/osmo_gsm_tester/process.py
+++ b/src/osmo_gsm_tester/process.py
@@ -350,6 +350,15 @@
 def wait(self, timeout=300):
 MainLoop.wait(self, self.terminated, timeout=timeout)

+def stdin_write(self, cmd):
+'''
+Send a cmd to the stdin of a process (convert to byte before)
+'''
+try:
+
self.process_obj.communicate(input="{}".format(cmd).encode("utf-8"), timeout=5)
+except subprocess.TimeoutExpired:
+self.log('Timeout expired while writing to stdout')
+

 class RemoteProcess(Process):


--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17560
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I3e5d843911998bb50726d93e3dfd3de584dc81a5
Gerrit-Change-Number: 17560
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-MessageType: newchange


Change in osmo-gsm-tester[master]: srs_ue: run srsUE as normal RemoteProcess

2020-03-21 Thread srs_andre
srs_andre has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17562 )


Change subject: srs_ue: run srsUE as normal RemoteProcess
..

srs_ue: run srsUE as normal RemoteProcess

running with RemoteProcessFixIgnoreSIGHUP was needed bc
srsUE used to ignore SIGHUP that is delivered to the process
when the SSH session is terminated causing the UE to not
quit properly. This isn't the case anymore so we can use
RemoteProcess for spawning the UE.

Furthermore, the wrapper script didn't pass along stdin
to it's child process, i.e., srsUE. Therefore the console
trace can't be seen if the run through the wrapper.

Change-Id: Iab4dafc58167620362a36ec9e904b8d49a7d5fc1
---
M src/osmo_gsm_tester/srs_ue.py
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester 
refs/changes/62/17562/1

diff --git a/src/osmo_gsm_tester/srs_ue.py b/src/osmo_gsm_tester/srs_ue.py
index ffd847b..467fe9b 100644
--- a/src/osmo_gsm_tester/srs_ue.py
+++ b/src/osmo_gsm_tester/srs_ue.py
@@ -172,7 +172,7 @@
 '--general.metrics_csv_filename=' + self.remote_metrics_file,
 self.additional_args)

-self.process = 
self.rem_host.RemoteProcessFixIgnoreSIGHUP(srsUE.BINFILE, 
util.Dir(srsUE.REMOTE_DIR), args)
+self.process = self.rem_host.RemoteProcess(srsUE.BINFILE, args)
 #self.process = 
self.rem_host.RemoteProcessFixIgnoreSIGHUP(srsUE.BINFILE, remote_run_dir, args, 
remote_lib)
 self.suite_run.remember_to_stop(self.process)
 self.process.launch()

--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17562
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: Iab4dafc58167620362a36ec9e904b8d49a7d5fc1
Gerrit-Change-Number: 17562
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-MessageType: newchange


Change in osmo-gsm-tester[master]: log srsUE/srsENB cmd line args before launching

2020-03-21 Thread srs_andre
srs_andre has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17538 )

Change subject: log srsUE/srsENB cmd line args before launching
..


Patch Set 1:

True. I've removed the commit.


--
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17538
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: I9e18595433e883b37323e94c43f17162f011bc00
Gerrit-Change-Number: 17538
Gerrit-PatchSet: 1
Gerrit-Owner: srs_andre 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: srs_andre 
Gerrit-CC: pespin 
Gerrit-Comment-Date: Sat, 21 Mar 2020 20:41:33 +
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


Change in libosmocore[master]: osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17556 )

Change subject: osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17556
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6180a3f81a7d3006e8ece4302c2433db2588bfaa
Gerrit-Change-Number: 17556
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 16:16:22 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: sim: add osim_file_desc_find_aid()

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17554 )

Change subject: sim: add osim_file_desc_find_aid()
..

sim: add osim_file_desc_find_aid()

Change-Id: I80468c8c4f4590c262019f42285e8d8fd3444f7f
---
M TODO-RELEASE
M include/osmocom/sim/sim.h
M src/sim/core.c
3 files changed, 21 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/TODO-RELEASE b/TODO-RELEASE
index 329e217..4145300 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,4 +7,5 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library   whatdescription / commit summary line
-gsmAPI/ABI change  l1sap.h, added struct members to 
ph_data_param and ph_tch_param
\ No newline at end of file
+gsmAPI/ABI change  l1sap.h, added struct members to 
ph_data_param and ph_tch_param
+simAPI/ABI change  new osim_file_desc_find_aid()
diff --git a/include/osmocom/sim/sim.h b/include/osmocom/sim/sim.h
index 8eb3f11..5440d85 100644
--- a/include/osmocom/sim/sim.h
+++ b/include/osmocom/sim/sim.h
@@ -243,6 +243,9 @@
 osim_file_desc_find_name(struct osim_file_desc *parent, const char *name);

 struct osim_file_desc *
+osim_file_desc_find_aid(struct osim_file_desc *parent, const uint8_t *aid, 
uint8_t aid_len);
+
+struct osim_file_desc *
 osim_file_desc_find_fid(struct osim_file_desc *parent, uint16_t fid);

 struct osim_file_desc *
diff --git a/src/sim/core.c b/src/sim/core.c
index b93633c..4360ff1 100644
--- a/src/sim/core.c
+++ b/src/sim/core.c
@@ -187,6 +187,22 @@
 }

 struct osim_file_desc *
+osim_file_desc_find_aid(struct osim_file_desc *parent, const uint8_t *aid, 
uint8_t aid_len)
+{
+   struct osim_file_desc *ofd;
+   llist_for_each_entry(ofd, &parent->child_list, list) {
+   if (ofd->type != TYPE_ADF)
+   continue;
+   if (aid_len > ofd->df_name_len)
+   continue;
+   if (!memcmp(ofd->df_name, aid, aid_len)) {
+   return ofd;
+   }
+   }
+   return NULL;
+}
+
+struct osim_file_desc *
 osim_file_desc_find_fid(struct osim_file_desc *parent, uint16_t fid)
 {
struct osim_file_desc *ofd;

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17554
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I80468c8c4f4590c262019f42285e8d8fd3444f7f
Gerrit-Change-Number: 17554
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in libosmocore[master]: sim: Add HPSIM application support

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17558 )

Change subject: sim: Add HPSIM application support
..

sim: Add HPSIM application support

Change-Id: I883faae5e170803b8301d10c8b9fad7892da009c
---
M src/sim/Makefile.am
A src/sim/card_fs_hpsim.c
M src/sim/core.c
M src/sim/sim_int.h
4 files changed, 79 insertions(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/sim/Makefile.am b/src/sim/Makefile.am
index 14bbbd8..0539dd9 100644
--- a/src/sim/Makefile.am
+++ b/src/sim/Makefile.am
@@ -14,7 +14,7 @@

 libosmosim_la_SOURCES = core.c reader.c class_tables.c \
card_fs_sim.c card_fs_usim.c card_fs_uicc.c \
-   card_fs_isim.c card_fs_tetra.c
+   card_fs_isim.c card_fs_hpsim.c card_fs_tetra.c
 libosmosim_la_LDFLAGS = -version-info $(LIBVERSION)
 libosmosim_la_LIBADD = \
$(top_builddir)/src/libosmocore.la \
diff --git a/src/sim/card_fs_hpsim.c b/src/sim/card_fs_hpsim.c
new file mode 100644
index 000..4a5f7d9
--- /dev/null
+++ b/src/sim/card_fs_hpsim.c
@@ -0,0 +1,76 @@
+/*! \file card_fs_hpsim.c
+ * 3GPP HPSIM specific structures / routines. */
+/*
+ * (C) 2020 by Harald Welte 
+ *
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "sim_int.h"
+#include "gsm_int.h"
+
+/* TS 31.104 Version 15.0.0 Release 15 / Chapter 7.1.3 */
+const struct osim_card_sw ts31_104_sw[] = {
+   {
+   0x9862, 0x, SW_TYPE_STR, SW_CLS_ERROR,
+   .u.str = "Security management - Authentication error, incorrect 
MAC",
+   },
+   OSIM_CARD_SW_LAST
+};
+
+/* TS 31.104 Version 15.0.0 Release 15 / Chapter 4.2 */
+static const struct osim_file_desc hpsim_ef_in_adf_hpsim[] = {
+   EF_LIN_FIX_N(0x6F06, 0x06, "EF.ARR", 0, 1, 256,
+   "Access Rule TLV data objects"),
+   EF_TRANSP_N(0x6F07, 0x07, "EF.IMST", 0, 9, 9,
+   "IMSI"),
+   EF_TRANSP_N(0x6FAD, 0x03, "EF_AD", 0, 4, 8,
+   "Administrative Data"),
+};
+
+/* Annex E - TS 101 220 */
+static const uint8_t adf_hpsim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 
0x0A };
+
+struct osim_card_app_profile *osim_aprof_hpsim(void *ctx)
+{
+   struct osim_card_app_profile *aprof;
+   struct osim_file_desc *iadf;
+
+   aprof = talloc_zero(ctx, struct osim_card_app_profile);
+   aprof->name = "3GPP HPSIM";
+   aprof->sw = ts31_104_sw;
+   aprof->aid_len = sizeof(adf_hpsim_aid);
+   memcpy(aprof->aid, adf_hpsim_aid, aprof->aid_len);
+
+   /* ADF.HPSIM with its EF siblings */
+   iadf = alloc_adf_with_ef(aprof, adf_hpsim_aid, sizeof(adf_hpsim_aid), 
"ADF.HPSIM",
+hpsim_ef_in_adf_hpsim, 
ARRAY_SIZE(hpsim_ef_in_adf_hpsim));
+   aprof->adf = iadf;
+
+   return aprof;
+}
diff --git a/src/sim/core.c b/src/sim/core.c
index 80a168f..8b2d6f9 100644
--- a/src/sim/core.c
+++ b/src/sim/core.c
@@ -453,6 +453,7 @@
 {
osim_app_profile_register(osim_aprof_usim(ctx));
osim_app_profile_register(osim_aprof_isim(ctx));
+   osim_app_profile_register(osim_aprof_hpsim(ctx));

return 0;
 }
diff --git a/src/sim/sim_int.h b/src/sim/sim_int.h
index 99a2242..a96a9cd 100644
--- a/src/sim/sim_int.h
+++ b/src/sim/sim_int.h
@@ -33,5 +33,6 @@

 struct osim_card_app_profile *osim_aprof_usim(void *ctx);
 struct osim_card_app_profile *osim_aprof_isim(void *ctx);
+struct osim_card_app_profile *osim_aprof_hpsim(void *ctx);

 #endif

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17558
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I883faae5e170803b8301d10c8b9fad7892da009c
Gerrit-Change-Number: 17558
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in libosmocore[master]: sim: re-structure how we support cards + applications

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17555 )

Change subject: sim: re-structure how we support cards + applications
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17555
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ic4b4ac433a9976842b30a017fb0fc347d87201cd
Gerrit-Change-Number: 17555
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 16:16:20 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17556 )

Change subject: osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards
..

osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards

an USIM application can very well exist on a UICC without supporting
classic DF.GSM access.  However, most commonly, both are found on
cards.

Change-Id: I6180a3f81a7d3006e8ece4302c2433db2588bfaa
---
M src/sim/card_fs_uicc.c
M src/sim/card_fs_usim.c
M utils/osmo-sim-test.c
3 files changed, 12 insertions(+), 12 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/sim/card_fs_uicc.c b/src/sim/card_fs_uicc.c
index c73fc9a..5dcaaa1 100644
--- a/src/sim/card_fs_uicc.c
+++ b/src/sim/card_fs_uicc.c
@@ -231,7 +231,7 @@
 /* Annex E - TS 101 220 */
 static const uint8_t __attribute__((__unused__)) adf_uicc_aid[] = { 0xA0, 
0x00, 0x00, 0x00, 0x87, 0x10, 0x01 };

-struct osim_card_profile *osim_cprof_uicc(void *ctx)
+struct osim_card_profile *osim_cprof_uicc(void *ctx, bool have_df_gsm)
 {
struct osim_card_profile *cprof;
struct osim_file_desc *mf;
@@ -255,5 +255,14 @@
return NULL;
}

+   if (have_df_gsm) {
+   /* DF.GSM as sub-directory of MF */
+   rc = osim_int_cprof_add_gsm(mf);
+   if (rc != 0) {
+   talloc_free(cprof);
+   return NULL;
+   }
+   }
+
return cprof;
 }
diff --git a/src/sim/card_fs_usim.c b/src/sim/card_fs_usim.c
index 97f712a..d5d2736 100644
--- a/src/sim/card_fs_usim.c
+++ b/src/sim/card_fs_usim.c
@@ -345,14 +345,5 @@
/* OMA BCAST Smart Card Profile */
add_df_with_ef(uadf, 0x5F80, "DF.BCAST", NULL, 0);

-#if 0
-   /* DF.GSM as sub-directory of MF */
-   rc = osim_int_cprof_add_gsm(mf);
-   if (rc != 0) {
-   talloc_free(cprof);
-   return NULL;
-   }
-#endif
-
return aprof;
 }
diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index e71d0ef..6cf36a6 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -341,7 +341,7 @@


 extern struct osim_card_profile *osim_cprof_sim(void *ctx);
-extern struct osim_card_profile *osim_cprof_uicc(void *ctx);
+extern struct osim_card_profile *osim_cprof_uicc(void *ctx, bool have_df_gsm);

 static int dump_file(struct osim_chan_hdl *chan, const char *short_name, 
uint16_t fid)
 {
@@ -652,7 +652,7 @@

rc = osim_uicc_scan_apps(chan);
if (rc >= 0) {
-   chan->card->prof = osim_cprof_uicc(chan->card);
+   chan->card->prof = osim_cprof_uicc(chan->card, true);
chan->cwd = chan->card->prof->mf;
} else if (rc == -0x6e00) {
/* CLA not supported: must be classic SIM, not USIM */

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17556
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6180a3f81a7d3006e8ece4302c2433db2588bfaa
Gerrit-Change-Number: 17556
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in libosmocore[master]: card_fs_{usim, isim}: Update to 15.7.0 / Release 15

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17557 )

Change subject: card_fs_{usim,isim}: Update to 15.7.0 / Release 15
..

card_fs_{usim,isim}: Update to 15.7.0 / Release 15

Various new files and some new status words have been defined
by now. Let's add them.

Change-Id: Ia007281bcb61dcd8260d0a77203abeff21d5255f
---
M src/sim/card_fs_isim.c
M src/sim/card_fs_usim.c
2 files changed, 56 insertions(+), 6 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/sim/card_fs_isim.c b/src/sim/card_fs_isim.c
index 2970c45..f11c029 100644
--- a/src/sim/card_fs_isim.c
+++ b/src/sim/card_fs_isim.c
@@ -1,7 +1,7 @@
 /*! \file card_fs_isim.c
  * 3GPP ISIM specific structures / routines. */
 /*
- * (C) 2014 by Harald Welte 
+ * (C) 2014-2020 by Harald Welte 
  *
  * All Rights Reserved
  *
@@ -34,16 +34,19 @@
 #include "sim_int.h"
 #include "gsm_int.h"

-/* TS 31.103 Version 11.2.0 Release 11 / Chapoter 7.1.3 */
+/* TS 31.103 Version 15.5.0 Release 15 / Chapter 7.1.3 */
 const struct osim_card_sw ts31_103_sw[] = {
{
0x9862, 0x, SW_TYPE_STR, SW_CLS_ERROR,
.u.str = "Security management - Authentication error, incorrect 
MAC",
+   }, {
+   0x9864, 0x, SW_TYPE_STR, SW_CLS_ERROR,
+   .u.str = "Security management - Authentication error, security 
context not supported",
},
OSIM_CARD_SW_LAST
 };

-/* TS 31.103 Version 11.2.0 Release 11 / Chapoter 4.2 */
+/* TS 31.103 Version 15.5.0 Release 15 / Chapter 4.2 */
 static const struct osim_file_desc isim_ef_in_adf_isim[] = {
EF_TRANSP_N(0x6F02, 0x02, "EF.IMPI", 0, 1, 256,
"IMS private user identity"),
@@ -75,6 +78,14 @@
"Short message service parameters"),
EF_LIN_FIX_N(0x6FE7, SFI_NONE, "EF.UICCIARI", F_OPTIONAL, 1, 256,
"UICC IARI"),
+   EF_TRANSP_N(0x6FF7, SFI_NONE, "EF_FromPreferred", F_OPTIONAL, 1, 1,
+   "From Preferred"),
+   EF_TRANSP_N(0x6FF8, SFI_NONE, "EF_IMSConfigData", F_OPTIONAL, 3, 128,
+   "IMS Configuration Data"),
+   EF_TRANSP_N(0x6FFC, SFI_NONE, "EF_XCAPConfigData", F_OPTIONAL, 1, 128,
+   "XCAP Configuration Data"),
+   EF_LIN_FIX_N(0x6FFA, SFI_NONE, "EF_WebRTCURI", F_OPTIONAL, 3, 128,
+   "WebRTC URI"),
 };

 /* Annex E - TS 101 220 */
diff --git a/src/sim/card_fs_usim.c b/src/sim/card_fs_usim.c
index d5d2736..4c8f79c 100644
--- a/src/sim/card_fs_usim.c
+++ b/src/sim/card_fs_usim.c
@@ -32,7 +32,7 @@
 #include "sim_int.h"
 #include "gsm_int.h"

-/* TS 31.102 Version 7.7.0 / Chapter 7.3 */
+/* TS 31.102 Version 15.7.0 Release 15 / Chapter 7.3 */
 const struct osim_card_sw ts31_102_sw[] = {
{
0x9862, 0x, SW_TYPE_STR, SW_CLS_ERROR,
@@ -43,11 +43,17 @@
}, {
0x9865, 0x, SW_TYPE_STR, SW_CLS_ERROR,
.u.str = "Security management - Key freshness error",
+   }, {
+   0x9866, 0x, SW_TYPE_STR, SW_CLS_ERROR,
+   .u.str = "Security management - Authentication error, no memory 
space available",
+   }, {
+   0x9867, 0x, SW_TYPE_STR, SW_CLS_ERROR,
+   .u.str = "Security management - Authentication error, no memory 
space available in EF_MUK",
},
OSIM_CARD_SW_LAST
 };

-/* 31.102 Chapter 4.4.3 */
+/* 31.102 Version 15.7.0 Release 15 / Chapter 4.4.3 */
 static const struct osim_file_desc usim_ef_in_df_gsm_access[] = {
EF_TRANSP_N(0x4f20, 0x01, "EF.Kc", 0, 9, 9,
"Ciphering Key Kc"),
@@ -59,7 +65,7 @@
"Investigation Scan"),
 };

-/* 31.102 Chapter 4.2 */
+/* 31.102 Version 15.7.0 Release 15 / Chapter 4.2 */
 static const struct osim_file_desc usim_ef_in_adf_usim[] = {
EF_TRANSP(0x6F05, 0x02, "EF.LI", 0, 2, 16,
"Language Indication", &gsm_lp_decode, NULL),
@@ -243,6 +249,39 @@
"UICC IARI"),
EF_TRANSP_N(0x6FEC, SFI_NONE, "EF.PWS", F_OPTIONAL, 1, 32,
"Public Warning System"),
+   EF_LIN_FIX_N(0x6FED, SFI_NONE, "EF_FDNURI", F_OPTIONAL, 1, 128,
+   "Fixed Dialling Numbers URI"),
+   EF_LIN_FIX_N(0x6FEE, SFI_NONE, "EF_BDNURI", F_OPTIONAL, 1, 128,
+   "Barred Dialling Numbers URI"),
+   EF_LIN_FIX_N(0x6FEF, SFI_NONE, "EF_SDNURI", F_OPTIONAL, 1, 128,
+   "Service Dialling Numbers URI"),
+   EF_LIN_FIX_N(0x6FF0, SFI_NONE, "EF_IWL", F_OPTIONAL, 18, 32,
+   "IMEI(SV) White Lists"),
+   EF_CYCLIC_N(0x6FF1, SFI_NONE, "EF_IPS", F_OPTIONAL, 4, 4,
+   "IMEI(SV) Pairing Status"),
+   EF_LIN_FIX_N(0x6FF2, SFI_NONE, "EF_IPD", F_OPTIONAL, 10, 16,
+   "IMEI(SV) of Pairing Device"),
+   EF_TRANSP_N(0x6FF3, SFI_NONE, "EF_ePDGId", F_OPTIONAL, 1, 128,
+   "Home ePDG Ident

Change in libosmocore[master]: osmo-sim-test: Optionally dump card files to host filesystem

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17553 )

Change subject: osmo-sim-test: Optionally dump card files to host filesystem
..

osmo-sim-test: Optionally dump card files to host filesystem

Using the new '--output-dir' command line argument, the user can
instruct osmo-sim-test to dump the file content to a local directory.

osmo-sim-test will create one sub-directory per DF, and create a
text file for each EF.  The contents of the text files are a hexdump
of the contents.  Transparent EF are dumped as one line of hex,
while linear fixed EF are dumped as one record per line, i.e. the
number of lines corresponds to the number of records.

Change-Id: I35176f4a13c3537eaa8de550e231818a22b4c07c
---
M utils/osmo-sim-test.c
1 file changed, 97 insertions(+), 11 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index 4c704f6..a9ab0d0 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -1,5 +1,5 @@
 /* libosmosim test application - currently simply dumps a USIM */
-/* (C) 2012 by Harald Welte 
+/* (C) 2012-2020 by Harald Welte 
  * All Rights Reserved
  *
  * This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,12 @@
 #include 
 #include 

+#include 
+#include 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -34,6 +40,7 @@
 /* FIXME: this needs to be moved to card_fs_uicc.c */

 static uint8_t g_class = 0x00; /* UICC/USIM */
+static const char *g_output_dir;

 /* 11.1.1 */
 static struct msgb *_select_file(struct osim_chan_hdl *st, uint8_t p1, uint8_t 
p2,
@@ -317,13 +324,15 @@
return NULL;
 }

-static int dump_file(struct osim_chan_hdl *chan, uint16_t fid)
+static int dump_file(struct osim_chan_hdl *chan, const char *short_name, 
uint16_t fid)
 {
struct tlv_parsed tp;
struct osim_fcp_fd_decoded ffdd;
struct msgb *msg, *rmsg;
int rc, i, offset;
+   FILE *f_data = NULL;

+   /* Select the file */
msg = select_file(chan, fid);
if (!msg) {
fprintf(stderr, "Unable to select file\n");
@@ -363,23 +372,41 @@
goto out;
}

+   if (g_output_dir) {
+   f_data = fopen(short_name, "w");
+   if (!f_data) {
+   fprintf(stderr, "Couldn't create '%s': %s\n", 
short_name, strerror(errno));
+   goto out;
+   }
+   }
+
printf("EF type: %u\n", ffdd.ef_type);

switch (ffdd.ef_type) {
case EF_TYPE_RECORD_FIXED:
for (i = 0; i < ffdd.num_rec; i++) {
+   const char *hex;
rmsg = read_record_nr(chan, i+1, ffdd.rec_len);
-   if (!rmsg)
+   if (!rmsg) {
+   if (f_data)
+   fclose(f_data);
return -EIO;
+   }
printf("SW: %s\n", osim_print_sw(chan->card, 
msgb_apdu_sw(msg)));
-   printf("Rec %03u: %s\n", i+1,
-   osmo_hexdump(msgb_apdu_de(rmsg), 
msgb_apdu_le(rmsg)));
+
+   hex = osmo_hexdump_nospc(msgb_apdu_de(rmsg), 
msgb_apdu_le(rmsg));
+   printf("Rec %03u: %s\n", i+1, hex);
+   if (f_data)
+   fprintf(f_data, "%s\n", hex);
}
break;
case EF_TYPE_TRANSP:
if (g_class != 0xA0) {
-   if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_SIZE))
+   if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_SIZE)) {
+   if (f_data)
+   fclose(f_data);
goto out;
+   }
i = ntohs(*(uint16_t *)TLVP_VAL(&tp, 
UICC_FCP_T_FILE_SIZE));
printf("File size: %d bytes\n", i);
} else {
@@ -389,12 +416,18 @@
for (offset = 0; offset < i-1; ) {
uint16_t remain_len = i - offset;
uint16_t read_len = OSMO_MIN(remain_len, 256);
+   const char *hex;
rmsg = read_binary(chan, offset, read_len);
-   if (!rmsg)
+   if (!rmsg) {
+   if (f_data)
+   fclose(f_data);
return -EIO;
+   }
offset += read_len;
-   printf("Content: %s\n",
-   osmo_hexdump(msgb_apdu_de(rmsg), 
msgb_apdu_le(rmsg)));
+   hex = osmo_hexdump_nospc(msgb_apdu_de(rmsg), 
msg

Change in libosmocore[master]: osmo-sim-test: Optionally dump card files to host filesystem

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17553 )

Change subject: osmo-sim-test: Optionally dump card files to host filesystem
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17553
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I35176f4a13c3537eaa8de550e231818a22b4c07c
Gerrit-Change-Number: 17553
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 16:16:03 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: sim: re-structure how we support cards + applications

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17555 )

Change subject: sim: re-structure how we support cards + applications
..

sim: re-structure how we support cards + applications

Before this change, a card application (USIM, ISIM, ...) didn't
exist as a separate concept from a card profile.  This meant,
we had a manual combination of UICC card profile with USIM application,
and another one of UICC card profile and ISIM application.  But what
if there's a combined USIM+ISIM?

In reality, applications exist as separate objects, on top of an
ETSI UICC.  Lets therefore register all known applications to the
osim library core, and add code to osmo-sim-test which dynamically
detects all applications present on a given card (by reading EF.DIR).

Change-Id: Ic4b4ac433a9976842b30a017fb0fc347d87201cd
---
M include/osmocom/sim/sim.h
M src/sim/card_fs_isim.c
M src/sim/card_fs_uicc.c
M src/sim/card_fs_usim.c
M src/sim/core.c
M src/sim/reader_pcsc.c
M src/sim/sim_int.h
M utils/osmo-sim-test.c
8 files changed, 326 insertions(+), 122 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/include/osmocom/sim/sim.h b/include/osmocom/sim/sim.h
index 5440d85..33ebdd7 100644
--- a/include/osmocom/sim/sim.h
+++ b/include/osmocom/sim/sim.h
@@ -9,6 +9,7 @@
 #include 

 #define APDU_HDR_LEN   5
+#define MAX_AID_LEN16 /* Table 13.2 of TS 102 221 */

 /*! command-response pairs cases
  *
@@ -66,6 +67,8 @@
 #define msgb_apdu_dc(__x)  ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr))
 #define msgb_apdu_de(__x)  ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr) 
+ msgb_apdu_lc(__x))

+int osim_init(void *ctx);
+
 /* FILES */

 struct osim_file;
@@ -285,6 +288,28 @@
.class = SW_CLS_NONE, .u.str = NULL \
 }

+/*! A card application (e.g. USIM, ISIM, HPSIM) */
+struct osim_card_app_profile {
+   /*! entry in the global list of card application profiles */
+   struct llist_head list;
+   /*! human-readable name */
+   const char *name;
+   /*! AID of this application, as used in EF.DIR */
+   uint8_t aid[MAX_AID_LEN];
+   uint8_t aid_len;
+   /*! file system description */
+   struct osim_file_desc *adf;
+   /*! Status words defined by application */
+   const struct osim_card_sw *sw;
+};
+
+const struct osim_card_app_profile *
+osim_app_profile_find_by_name(const char *name);
+
+const struct osim_card_app_profile *
+osim_app_profile_find_by_aid(const uint8_t *aid, uint8_t aid_len);
+
+
 /*! A card profile (e.g. SIM card */
 struct osim_card_profile {
const char *name;
@@ -357,6 +382,19 @@
struct osim_card_hdl *card;
 };

+/*! descriptor for a given application present on a card */
+struct osim_card_app_hdl {
+   /*! member in card list of applications */
+   struct llist_head list;
+   /*! AID of the application */
+   uint8_t aid[MAX_AID_LEN];
+   uint8_t aid_len;
+   /*! application label from EF_DIR */
+   char *label;
+   /*! application profile (if any known) */
+   const struct osim_card_app_profile *prof;
+};
+
 struct osim_card_hdl {
/*! member in global list of cards */
struct llist_head list;
@@ -369,6 +407,9 @@

/*! list of channels for this card */
struct llist_head channels;
+
+   /*! list of applications found on card */
+   struct llist_head apps;
 };

 struct osim_chan_hdl {
@@ -376,9 +417,15 @@
struct llist_head list;
/*! card to which this channel belongs */
struct osim_card_hdl *card;
+   /*! current working directory */
const struct osim_file_desc *cwd;
+   /*! currently selected application (if any) */
+   struct osim_card_app_hdl *cur_app;
 };

+int osim_card_hdl_add_app(struct osim_card_hdl *ch, const uint8_t *aid, 
uint8_t aid_len,
+ const char *label);
+
 /* reader.c */
 int osim_transceive_apdu(struct osim_chan_hdl *st, struct msgb *amsg);
 struct osim_reader_hdl *osim_reader_open(enum osim_reader_driver drv, int idx,
diff --git a/src/sim/card_fs_isim.c b/src/sim/card_fs_isim.c
index e6ba0d0..2970c45 100644
--- a/src/sim/card_fs_isim.c
+++ b/src/sim/card_fs_isim.c
@@ -43,12 +43,6 @@
OSIM_CARD_SW_LAST
 };

-static const struct osim_card_sw *isim_card_sws[] = {
-   ts31_103_sw,
-   ts102221_uicc_sw,
-   NULL
-};
-
 /* TS 31.103 Version 11.2.0 Release 11 / Chapoter 4.2 */
 static const struct osim_file_desc isim_ef_in_adf_isim[] = {
EF_TRANSP_N(0x6F02, 0x02, "EF.IMPI", 0, 1, 256,
@@ -86,23 +80,21 @@
 /* Annex E - TS 101 220 */
 static const uint8_t adf_isim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 
0x04 };

-struct osim_card_profile *osim_cprof_isim(void *ctx)
+struct osim_card_app_profile *osim_aprof_isim(void *ctx)
 {
-   struct osim_card_profile *cprof;
-   struct osim_file_desc *mf;
+

Change in libosmocore[master]: sim: add osim_file_desc_find_aid()

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17554 )

Change subject: sim: add osim_file_desc_find_aid()
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17554
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I80468c8c4f4590c262019f42285e8d8fd3444f7f
Gerrit-Change-Number: 17554
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 16:16:07 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: osmo-sim-test: don't print SW in successful case of dump_file()

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17552 )

Change subject: osmo-sim-test: don't print SW in successful case of dump_file()
..

osmo-sim-test: don't print SW in successful case of dump_file()

Change-Id: Ie5a58a89052400d76a8607a2e0063917385beb25
---
M utils/osmo-sim-test.c
1 file changed, 0 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index 2bf83fa..4c704f6 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -329,7 +329,6 @@
fprintf(stderr, "Unable to select file\n");
return -EIO;
}
-   printf("SW: %s\n", osim_print_sw(chan->card, msgb_apdu_sw(msg)));
if (msgb_apdu_sw(msg) != 0x9000) {
fprintf(stderr, "status 0x%04x selecting file\n", 
msgb_apdu_sw(msg));
goto out;

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17552
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie5a58a89052400d76a8607a2e0063917385beb25
Gerrit-Change-Number: 17552
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in libosmocore[master]: osmo-sim-test: Use stderr for error messages

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17551 )

Change subject: osmo-sim-test: Use stderr for error messages
..

osmo-sim-test: Use stderr for error messages

Change-Id: I8f36b07b8601af2b0d54d95c3c6374d6c54bafd1
---
M utils/osmo-sim-test.c
1 file changed, 7 insertions(+), 7 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index 27de0bc..2bf83fa 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -326,25 +326,25 @@

msg = select_file(chan, fid);
if (!msg) {
-   printf("Unable to select file\n");
+   fprintf(stderr, "Unable to select file\n");
return -EIO;
}
printf("SW: %s\n", osim_print_sw(chan->card, msgb_apdu_sw(msg)));
if (msgb_apdu_sw(msg) != 0x9000) {
-   printf("status 0x%04x selecting file\n", msgb_apdu_sw(msg));
+   fprintf(stderr, "status 0x%04x selecting file\n", 
msgb_apdu_sw(msg));
goto out;
}

if (g_class != 0xA0) {
rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, 
msgb_apdu_le(msg)-2, 0, 0);
if (rc < 0) {
-   printf("Unable to parse FCP: %s\n", msgb_hexdump(msg));
+   fprintf(stderr, "Unable to parse FCP: %s\n", 
msgb_hexdump(msg));
goto out;
}

if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_DESC) ||
TLVP_LEN(&tp, UICC_FCP_T_FILE_DESC) < 2) {
-   printf("No file descriptor present ?!?\n");
+   fprintf(stderr, "No file descriptor present ?!?\n");
goto out;
}

@@ -355,12 +355,12 @@
}

if (rc < 0) {
-   printf("Unable to decode File Descriptor\n");
+   fprintf(stderr, "Unable to decode File Descriptor\n");
goto out;
}

if (ffdd.type != TYPE_EF) {
-   printf("File Type != EF\n");
+   fprintf(stderr, "File Type != EF\n");
goto out;
}

@@ -384,7 +384,7 @@
i = ntohs(*(uint16_t *)TLVP_VAL(&tp, 
UICC_FCP_T_FILE_SIZE));
printf("File size: %d bytes\n", i);
} else {
-   printf("Can not determine file size, invalid 
EF-type!\n");
+   fprintf(stderr, "Can not determine file size, invalid 
EF-type!\n");
goto out;
}
for (offset = 0; offset < i-1; ) {

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17551
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f36b07b8601af2b0d54d95c3c6374d6c54bafd1
Gerrit-Change-Number: 17551
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in libosmocore[master]: card_fs_sim: Avoid '/' in file names

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17559 )

Change subject: card_fs_sim: Avoid '/' in file names
..

card_fs_sim: Avoid '/' in file names

... as that doesn't work if we want to create a similarly-named
file in the local file system.

Change-Id: Ib8734e2e4b81c915ab0fbd0d9b6662275b1d33d1
---
M src/sim/card_fs_sim.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/sim/card_fs_sim.c b/src/sim/card_fs_sim.c
index 3f541f7..55ce9af 100644
--- a/src/sim/card_fs_sim.c
+++ b/src/sim/card_fs_sim.c
@@ -431,7 +431,7 @@
add_df_with_ef(gsm, 0x5F33, "DF.ACeS", NULL, 0);
add_df_with_ef(gsm, 0x5F3C, "DF.MExE", sim_ef_in_mexe,
ARRAY_SIZE(sim_ef_in_mexe));
-   add_df_with_ef(gsm, 0x5F40, "DF.EIA/TIA-533", NULL, 0);
+   add_df_with_ef(gsm, 0x5F40, "DF.EIA-TIA-533", NULL, 0);
add_df_with_ef(gsm, 0x5F60, "DF.CTS", NULL, 0);
add_df_with_ef(gsm, 0x5F70, "DF.SoLSA", sim_ef_in_solsa,
ARRAY_SIZE(sim_ef_in_solsa));

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17559
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib8734e2e4b81c915ab0fbd0d9b6662275b1d33d1
Gerrit-Change-Number: 17559
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in libosmocore[master]: sim: card_fs_usim.c: Fix FID of EF.EXT4

2020-03-21 Thread laforge
laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17550 )

Change subject: sim: card_fs_usim.c: Fix FID of EF.EXT4
..

sim: card_fs_usim.c: Fix FID of EF.EXT4

The 3GPP spec document also contains this error at one point, and
it seems I copied it from there :/

Change-Id: I7ad9f491c06f6540747b77017678ee37e6a1550d
---
M src/sim/card_fs_usim.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/src/sim/card_fs_usim.c b/src/sim/card_fs_usim.c
index 9e9fc87..3b33c0f 100644
--- a/src/sim/card_fs_usim.c
+++ b/src/sim/card_fs_usim.c
@@ -161,7 +161,7 @@
"Key for hidden phone book entries"),
EF_LIN_FIX_N(0x6F4D, SFI_NONE, "EF.BDN", F_OPTIONAL, 15, 32,
"Barred Dialling Numbers"),
-   EF_LIN_FIX_N(0x6F4E, SFI_NONE, "EF.EXT4", F_OPTIONAL, 13, 13,
+   EF_LIN_FIX_N(0x6F55, SFI_NONE, "EF.EXT4", F_OPTIONAL, 13, 13,
"Extension 4"),
EF_LIN_FIX_N(0x6F58, SFI_NONE, "EF.CMI", F_OPTIONAL, 2, 16,
"Comparison Method Information"),

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17550
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I7ad9f491c06f6540747b77017678ee37e6a1550d
Gerrit-Change-Number: 17550
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-MessageType: merged


Change in osmo-pcu[master]: tests/RLCMACTest: Several fixes and improvements to RAcap tests

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/17549 )

Change subject: tests/RLCMACTest: Several fixes and improvements to RAcap tests
..


Patch Set 1: Code-Review+1


--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/17549
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I1e7f8d8866695732ee24a79d8b54d660fd4f22d5
Gerrit-Change-Number: 17549
Gerrit-PatchSet: 1
Gerrit-Owner: pespin 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 15:33:18 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: osmo-sim-test: Optionally dump card files to host filesystem

2020-03-21 Thread laforge
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/17553

to look at the new patch set (#3).

Change subject: osmo-sim-test: Optionally dump card files to host filesystem
..

osmo-sim-test: Optionally dump card files to host filesystem

Using the new '--output-dir' command line argument, the user can
instruct osmo-sim-test to dump the file content to a local directory.

osmo-sim-test will create one sub-directory per DF, and create a
text file for each EF.  The contents of the text files are a hexdump
of the contents.  Transparent EF are dumped as one line of hex,
while linear fixed EF are dumped as one record per line, i.e. the
number of lines corresponds to the number of records.

Change-Id: I35176f4a13c3537eaa8de550e231818a22b4c07c
---
M utils/osmo-sim-test.c
1 file changed, 97 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/53/17553/3
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17553
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I35176f4a13c3537eaa8de550e231818a22b4c07c
Gerrit-Change-Number: 17553
Gerrit-PatchSet: 3
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: sim: Add HPSIM application support

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17558 )

Change subject: sim: Add HPSIM application support
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17558
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I883faae5e170803b8301d10c8b9fad7892da009c
Gerrit-Change-Number: 17558
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 15:29:56 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: card_fs_{usim, isim}: Update to 15.7.0 / Release 15

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17557 )

Change subject: card_fs_{usim,isim}: Update to 15.7.0 / Release 15
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17557
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ia007281bcb61dcd8260d0a77203abeff21d5255f
Gerrit-Change-Number: 17557
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 15:29:44 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: osmo-sim-test: Use stderr for error messages

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17551 )

Change subject: osmo-sim-test: Use stderr for error messages
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17551
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f36b07b8601af2b0d54d95c3c6374d6c54bafd1
Gerrit-Change-Number: 17551
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 15:28:06 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: osmo-sim-test: don't print SW in successful case of dump_file()

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17552 )

Change subject: osmo-sim-test: don't print SW in successful case of dump_file()
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17552
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie5a58a89052400d76a8607a2e0063917385beb25
Gerrit-Change-Number: 17552
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 15:28:16 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: card_fs_sim: Avoid '/' in file names

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17559 )

Change subject: card_fs_sim: Avoid '/' in file names
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17559
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib8734e2e4b81c915ab0fbd0d9b6662275b1d33d1
Gerrit-Change-Number: 17559
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: laforge 
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Sat, 21 Mar 2020 15:27:52 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: sim: card_fs_usim.c: Fix FID of EF.EXT4

2020-03-21 Thread laforge
laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17550 )

Change subject: sim: card_fs_usim.c: Fix FID of EF.EXT4
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17550
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I7ad9f491c06f6540747b77017678ee37e6a1550d
Gerrit-Change-Number: 17550
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge 
Gerrit-Comment-Date: Sat, 21 Mar 2020 15:27:44 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in libosmocore[master]: sim: re-structure how we support cards + applications

2020-03-21 Thread laforge
Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/libosmocore/+/17555

to look at the new patch set (#2).

Change subject: sim: re-structure how we support cards + applications
..

sim: re-structure how we support cards + applications

Before this change, a card application (USIM, ISIM, ...) didn't
exist as a separate concept from a card profile.  This meant,
we had a manual combination of UICC card profile with USIM application,
and another one of UICC card profile and ISIM application.  But what
if there's a combined USIM+ISIM?

In reality, applications exist as separate objects, on top of an
ETSI UICC.  Lets therefore register all known applications to the
osim library core, and add code to osmo-sim-test which dynamically
detects all applications present on a given card (by reading EF.DIR).

Change-Id: Ic4b4ac433a9976842b30a017fb0fc347d87201cd
---
M include/osmocom/sim/sim.h
M src/sim/card_fs_isim.c
M src/sim/card_fs_uicc.c
M src/sim/card_fs_usim.c
M src/sim/core.c
M src/sim/reader_pcsc.c
M src/sim/sim_int.h
M utils/osmo-sim-test.c
8 files changed, 326 insertions(+), 122 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/55/17555/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17555
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ic4b4ac433a9976842b30a017fb0fc347d87201cd
Gerrit-Change-Number: 17555
Gerrit-PatchSet: 2
Gerrit-Owner: laforge 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: newpatchset


Change in libosmocore[master]: card_fs_sim: Avoid '/' in file names

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17559 )


Change subject: card_fs_sim: Avoid '/' in file names
..

card_fs_sim: Avoid '/' in file names

... as that doesn't work if we want to create a similarly-named
file in the local file system.

Change-Id: Ib8734e2e4b81c915ab0fbd0d9b6662275b1d33d1
---
M src/sim/card_fs_sim.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/17559/1

diff --git a/src/sim/card_fs_sim.c b/src/sim/card_fs_sim.c
index 3f541f7..55ce9af 100644
--- a/src/sim/card_fs_sim.c
+++ b/src/sim/card_fs_sim.c
@@ -431,7 +431,7 @@
add_df_with_ef(gsm, 0x5F33, "DF.ACeS", NULL, 0);
add_df_with_ef(gsm, 0x5F3C, "DF.MExE", sim_ef_in_mexe,
ARRAY_SIZE(sim_ef_in_mexe));
-   add_df_with_ef(gsm, 0x5F40, "DF.EIA/TIA-533", NULL, 0);
+   add_df_with_ef(gsm, 0x5F40, "DF.EIA-TIA-533", NULL, 0);
add_df_with_ef(gsm, 0x5F60, "DF.CTS", NULL, 0);
add_df_with_ef(gsm, 0x5F70, "DF.SoLSA", sim_ef_in_solsa,
ARRAY_SIZE(sim_ef_in_solsa));

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17559
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib8734e2e4b81c915ab0fbd0d9b6662275b1d33d1
Gerrit-Change-Number: 17559
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in libosmocore[master]: osmo-sim-test: Optionally dump card files to host filesystem

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17553 )


Change subject: osmo-sim-test: Optionally dump card files to host filesystem
..

osmo-sim-test: Optionally dump card files to host filesystem

Using the new '--output-dir' command line argument, the user can
instruct osmo-sim-test to dump the file content to a local directory.

osmo-sim-test will create one sub-directory per DF, and create a
text file for each EF.  The contents of the text files are a hexdump
of the contents.  Transparent EF are dumped as one line of hex,
while linear fixed EF are dumped as one record per line, i.e. the
number of lines corresponds to the number of records.

Change-Id: I35176f4a13c3537eaa8de550e231818a22b4c07c
---
M utils/osmo-sim-test.c
1 file changed, 96 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/53/17553/1

diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index 4c704f6..a6ecfcf 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -1,5 +1,5 @@
 /* libosmosim test application - currently simply dumps a USIM */
-/* (C) 2012 by Harald Welte 
+/* (C) 2012-2020 by Harald Welte 
  * All Rights Reserved
  *
  * This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,12 @@
 #include 
 #include 

+#include 
+#include 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -34,6 +40,7 @@
 /* FIXME: this needs to be moved to card_fs_uicc.c */

 static uint8_t g_class = 0x00; /* UICC/USIM */
+static const char *g_output_dir;

 /* 11.1.1 */
 static struct msgb *_select_file(struct osim_chan_hdl *st, uint8_t p1, uint8_t 
p2,
@@ -317,13 +324,15 @@
return NULL;
 }

-static int dump_file(struct osim_chan_hdl *chan, uint16_t fid)
+static int dump_file(struct osim_chan_hdl *chan, const char *short_name, 
uint16_t fid)
 {
struct tlv_parsed tp;
struct osim_fcp_fd_decoded ffdd;
struct msgb *msg, *rmsg;
int rc, i, offset;
+   FILE *f_data = NULL;

+   /* Select the file */
msg = select_file(chan, fid);
if (!msg) {
fprintf(stderr, "Unable to select file\n");
@@ -363,23 +372,41 @@
goto out;
}

+   if (g_output_dir) {
+   f_data = fopen(short_name, "w");
+   if (!f_data) {
+   fprintf(stderr, "Couldn't create '%s': %s\n", 
short_name, strerror(errno));
+   goto out;
+   }
+   }
+
printf("EF type: %u\n", ffdd.ef_type);

switch (ffdd.ef_type) {
case EF_TYPE_RECORD_FIXED:
for (i = 0; i < ffdd.num_rec; i++) {
+   const char *hex;
rmsg = read_record_nr(chan, i+1, ffdd.rec_len);
-   if (!rmsg)
+   if (!rmsg) {
+   if (f_data)
+   fclose(f_data);
return -EIO;
+   }
printf("SW: %s\n", osim_print_sw(chan->card, 
msgb_apdu_sw(msg)));
-   printf("Rec %03u: %s\n", i+1,
-   osmo_hexdump(msgb_apdu_de(rmsg), 
msgb_apdu_le(rmsg)));
+
+   hex = osmo_hexdump_nospc(msgb_apdu_de(rmsg), 
msgb_apdu_le(rmsg));
+   printf("Rec %03u: %s\n", i+1, hex);
+   if (f_data)
+   fprintf(f_data, "%s\n", hex);
}
break;
case EF_TYPE_TRANSP:
if (g_class != 0xA0) {
-   if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_SIZE))
+   if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_SIZE)) {
+   if (f_data)
+   fclose(f_data);
goto out;
+   }
i = ntohs(*(uint16_t *)TLVP_VAL(&tp, 
UICC_FCP_T_FILE_SIZE));
printf("File size: %d bytes\n", i);
} else {
@@ -389,12 +416,18 @@
for (offset = 0; offset < i-1; ) {
uint16_t remain_len = i - offset;
uint16_t read_len = OSMO_MIN(remain_len, 256);
+   const char *hex;
rmsg = read_binary(chan, offset, read_len);
-   if (!rmsg)
+   if (!rmsg) {
+   if (f_data)
+   fclose(f_data);
return -EIO;
+   }
offset += read_len;
-   printf("Content: %s\n",
-   osmo_hexdump(msgb_apdu_de(rmsg), 
msgb_apdu_le(rmsg)));
+   hex = osmo_hexdump_nospc(msgb_apdu_de

Change in libosmocore[master]: sim: add osim_file_desc_find_aid()

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17554 )


Change subject: sim: add osim_file_desc_find_aid()
..

sim: add osim_file_desc_find_aid()

Change-Id: I80468c8c4f4590c262019f42285e8d8fd3444f7f
---
M TODO-RELEASE
M include/osmocom/sim/sim.h
M src/sim/core.c
3 files changed, 21 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/17554/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 329e217..4145300 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,4 +7,5 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library   whatdescription / commit summary line
-gsmAPI/ABI change  l1sap.h, added struct members to 
ph_data_param and ph_tch_param
\ No newline at end of file
+gsmAPI/ABI change  l1sap.h, added struct members to 
ph_data_param and ph_tch_param
+simAPI/ABI change  new osim_file_desc_find_aid()
diff --git a/include/osmocom/sim/sim.h b/include/osmocom/sim/sim.h
index 8eb3f11..5440d85 100644
--- a/include/osmocom/sim/sim.h
+++ b/include/osmocom/sim/sim.h
@@ -243,6 +243,9 @@
 osim_file_desc_find_name(struct osim_file_desc *parent, const char *name);

 struct osim_file_desc *
+osim_file_desc_find_aid(struct osim_file_desc *parent, const uint8_t *aid, 
uint8_t aid_len);
+
+struct osim_file_desc *
 osim_file_desc_find_fid(struct osim_file_desc *parent, uint16_t fid);

 struct osim_file_desc *
diff --git a/src/sim/core.c b/src/sim/core.c
index b93633c..4360ff1 100644
--- a/src/sim/core.c
+++ b/src/sim/core.c
@@ -187,6 +187,22 @@
 }

 struct osim_file_desc *
+osim_file_desc_find_aid(struct osim_file_desc *parent, const uint8_t *aid, 
uint8_t aid_len)
+{
+   struct osim_file_desc *ofd;
+   llist_for_each_entry(ofd, &parent->child_list, list) {
+   if (ofd->type != TYPE_ADF)
+   continue;
+   if (aid_len > ofd->df_name_len)
+   continue;
+   if (!memcmp(ofd->df_name, aid, aid_len)) {
+   return ofd;
+   }
+   }
+   return NULL;
+}
+
+struct osim_file_desc *
 osim_file_desc_find_fid(struct osim_file_desc *parent, uint16_t fid)
 {
struct osim_file_desc *ofd;

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17554
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I80468c8c4f4590c262019f42285e8d8fd3444f7f
Gerrit-Change-Number: 17554
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in libosmocore[master]: sim: re-structure how we support cards + applications

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17555 )


Change subject: sim: re-structure how we support cards + applications
..

sim: re-structure how we support cards + applications

Before this change, a card application (USIM, ISIM, ...) didn't
exist as a separate concept from a card profile.  This meant,
we had a manual combination of UICC card profile with USIM application,
and another one of UICC card profile and ISIM application.  But what
if there's a combined USIM+ISIM?

In reality, applications exist as separate objects, on top of an
ETSI UICC.  Lets therefore register all known applications to the
osim library core, and add code to osmo-sim-test which dynamically
detects all applications present on a given card (by reading EF.DIR).

Change-Id: Ic4b4ac433a9976842b30a017fb0fc347d87201cd
---
M include/osmocom/sim/sim.h
M src/sim/card_fs_isim.c
M src/sim/card_fs_uicc.c
M src/sim/card_fs_usim.c
M src/sim/core.c
M src/sim/reader_pcsc.c
M src/sim/sim_int.h
M utils/osmo-sim-test.c
8 files changed, 321 insertions(+), 122 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/55/17555/1

diff --git a/include/osmocom/sim/sim.h b/include/osmocom/sim/sim.h
index 5440d85..33ebdd7 100644
--- a/include/osmocom/sim/sim.h
+++ b/include/osmocom/sim/sim.h
@@ -9,6 +9,7 @@
 #include 

 #define APDU_HDR_LEN   5
+#define MAX_AID_LEN16 /* Table 13.2 of TS 102 221 */

 /*! command-response pairs cases
  *
@@ -66,6 +67,8 @@
 #define msgb_apdu_dc(__x)  ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr))
 #define msgb_apdu_de(__x)  ((__x)->l2h + sizeof(struct osim_apdu_cmd_hdr) 
+ msgb_apdu_lc(__x))

+int osim_init(void *ctx);
+
 /* FILES */

 struct osim_file;
@@ -285,6 +288,28 @@
.class = SW_CLS_NONE, .u.str = NULL \
 }

+/*! A card application (e.g. USIM, ISIM, HPSIM) */
+struct osim_card_app_profile {
+   /*! entry in the global list of card application profiles */
+   struct llist_head list;
+   /*! human-readable name */
+   const char *name;
+   /*! AID of this application, as used in EF.DIR */
+   uint8_t aid[MAX_AID_LEN];
+   uint8_t aid_len;
+   /*! file system description */
+   struct osim_file_desc *adf;
+   /*! Status words defined by application */
+   const struct osim_card_sw *sw;
+};
+
+const struct osim_card_app_profile *
+osim_app_profile_find_by_name(const char *name);
+
+const struct osim_card_app_profile *
+osim_app_profile_find_by_aid(const uint8_t *aid, uint8_t aid_len);
+
+
 /*! A card profile (e.g. SIM card */
 struct osim_card_profile {
const char *name;
@@ -357,6 +382,19 @@
struct osim_card_hdl *card;
 };

+/*! descriptor for a given application present on a card */
+struct osim_card_app_hdl {
+   /*! member in card list of applications */
+   struct llist_head list;
+   /*! AID of the application */
+   uint8_t aid[MAX_AID_LEN];
+   uint8_t aid_len;
+   /*! application label from EF_DIR */
+   char *label;
+   /*! application profile (if any known) */
+   const struct osim_card_app_profile *prof;
+};
+
 struct osim_card_hdl {
/*! member in global list of cards */
struct llist_head list;
@@ -369,6 +407,9 @@

/*! list of channels for this card */
struct llist_head channels;
+
+   /*! list of applications found on card */
+   struct llist_head apps;
 };

 struct osim_chan_hdl {
@@ -376,9 +417,15 @@
struct llist_head list;
/*! card to which this channel belongs */
struct osim_card_hdl *card;
+   /*! current working directory */
const struct osim_file_desc *cwd;
+   /*! currently selected application (if any) */
+   struct osim_card_app_hdl *cur_app;
 };

+int osim_card_hdl_add_app(struct osim_card_hdl *ch, const uint8_t *aid, 
uint8_t aid_len,
+ const char *label);
+
 /* reader.c */
 int osim_transceive_apdu(struct osim_chan_hdl *st, struct msgb *amsg);
 struct osim_reader_hdl *osim_reader_open(enum osim_reader_driver drv, int idx,
diff --git a/src/sim/card_fs_isim.c b/src/sim/card_fs_isim.c
index e6ba0d0..2970c45 100644
--- a/src/sim/card_fs_isim.c
+++ b/src/sim/card_fs_isim.c
@@ -43,12 +43,6 @@
OSIM_CARD_SW_LAST
 };

-static const struct osim_card_sw *isim_card_sws[] = {
-   ts31_103_sw,
-   ts102221_uicc_sw,
-   NULL
-};
-
 /* TS 31.103 Version 11.2.0 Release 11 / Chapoter 4.2 */
 static const struct osim_file_desc isim_ef_in_adf_isim[] = {
EF_TRANSP_N(0x6F02, 0x02, "EF.IMPI", 0, 1, 256,
@@ -86,23 +80,21 @@
 /* Annex E - TS 101 220 */
 static const uint8_t adf_isim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 
0x04 };

-struct osim_card_profile *osim_cprof_isim(void *ctx)
+struct osim_card_app_profile *osim_aprof_isim(void *ctx)
 {
-   struct osim_card_profile *cprof;
-   struct osim_file_des

Change in libosmocore[master]: card_fs_{usim, isim}: Update to 15.7.0 / Release 15

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17557 )


Change subject: card_fs_{usim,isim}: Update to 15.7.0 / Release 15
..

card_fs_{usim,isim}: Update to 15.7.0 / Release 15

Various new files and some new status words have been defined
by now. Let's add them.

Change-Id: Ia007281bcb61dcd8260d0a77203abeff21d5255f
---
M src/sim/card_fs_isim.c
M src/sim/card_fs_usim.c
2 files changed, 56 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/57/17557/1

diff --git a/src/sim/card_fs_isim.c b/src/sim/card_fs_isim.c
index 2970c45..f11c029 100644
--- a/src/sim/card_fs_isim.c
+++ b/src/sim/card_fs_isim.c
@@ -1,7 +1,7 @@
 /*! \file card_fs_isim.c
  * 3GPP ISIM specific structures / routines. */
 /*
- * (C) 2014 by Harald Welte 
+ * (C) 2014-2020 by Harald Welte 
  *
  * All Rights Reserved
  *
@@ -34,16 +34,19 @@
 #include "sim_int.h"
 #include "gsm_int.h"

-/* TS 31.103 Version 11.2.0 Release 11 / Chapoter 7.1.3 */
+/* TS 31.103 Version 15.5.0 Release 15 / Chapter 7.1.3 */
 const struct osim_card_sw ts31_103_sw[] = {
{
0x9862, 0x, SW_TYPE_STR, SW_CLS_ERROR,
.u.str = "Security management - Authentication error, incorrect 
MAC",
+   }, {
+   0x9864, 0x, SW_TYPE_STR, SW_CLS_ERROR,
+   .u.str = "Security management - Authentication error, security 
context not supported",
},
OSIM_CARD_SW_LAST
 };

-/* TS 31.103 Version 11.2.0 Release 11 / Chapoter 4.2 */
+/* TS 31.103 Version 15.5.0 Release 15 / Chapter 4.2 */
 static const struct osim_file_desc isim_ef_in_adf_isim[] = {
EF_TRANSP_N(0x6F02, 0x02, "EF.IMPI", 0, 1, 256,
"IMS private user identity"),
@@ -75,6 +78,14 @@
"Short message service parameters"),
EF_LIN_FIX_N(0x6FE7, SFI_NONE, "EF.UICCIARI", F_OPTIONAL, 1, 256,
"UICC IARI"),
+   EF_TRANSP_N(0x6FF7, SFI_NONE, "EF_FromPreferred", F_OPTIONAL, 1, 1,
+   "From Preferred"),
+   EF_TRANSP_N(0x6FF8, SFI_NONE, "EF_IMSConfigData", F_OPTIONAL, 3, 128,
+   "IMS Configuration Data"),
+   EF_TRANSP_N(0x6FFC, SFI_NONE, "EF_XCAPConfigData", F_OPTIONAL, 1, 128,
+   "XCAP Configuration Data"),
+   EF_LIN_FIX_N(0x6FFA, SFI_NONE, "EF_WebRTCURI", F_OPTIONAL, 3, 128,
+   "WebRTC URI"),
 };

 /* Annex E - TS 101 220 */
diff --git a/src/sim/card_fs_usim.c b/src/sim/card_fs_usim.c
index d5d2736..4c8f79c 100644
--- a/src/sim/card_fs_usim.c
+++ b/src/sim/card_fs_usim.c
@@ -32,7 +32,7 @@
 #include "sim_int.h"
 #include "gsm_int.h"

-/* TS 31.102 Version 7.7.0 / Chapter 7.3 */
+/* TS 31.102 Version 15.7.0 Release 15 / Chapter 7.3 */
 const struct osim_card_sw ts31_102_sw[] = {
{
0x9862, 0x, SW_TYPE_STR, SW_CLS_ERROR,
@@ -43,11 +43,17 @@
}, {
0x9865, 0x, SW_TYPE_STR, SW_CLS_ERROR,
.u.str = "Security management - Key freshness error",
+   }, {
+   0x9866, 0x, SW_TYPE_STR, SW_CLS_ERROR,
+   .u.str = "Security management - Authentication error, no memory 
space available",
+   }, {
+   0x9867, 0x, SW_TYPE_STR, SW_CLS_ERROR,
+   .u.str = "Security management - Authentication error, no memory 
space available in EF_MUK",
},
OSIM_CARD_SW_LAST
 };

-/* 31.102 Chapter 4.4.3 */
+/* 31.102 Version 15.7.0 Release 15 / Chapter 4.4.3 */
 static const struct osim_file_desc usim_ef_in_df_gsm_access[] = {
EF_TRANSP_N(0x4f20, 0x01, "EF.Kc", 0, 9, 9,
"Ciphering Key Kc"),
@@ -59,7 +65,7 @@
"Investigation Scan"),
 };

-/* 31.102 Chapter 4.2 */
+/* 31.102 Version 15.7.0 Release 15 / Chapter 4.2 */
 static const struct osim_file_desc usim_ef_in_adf_usim[] = {
EF_TRANSP(0x6F05, 0x02, "EF.LI", 0, 2, 16,
"Language Indication", &gsm_lp_decode, NULL),
@@ -243,6 +249,39 @@
"UICC IARI"),
EF_TRANSP_N(0x6FEC, SFI_NONE, "EF.PWS", F_OPTIONAL, 1, 32,
"Public Warning System"),
+   EF_LIN_FIX_N(0x6FED, SFI_NONE, "EF_FDNURI", F_OPTIONAL, 1, 128,
+   "Fixed Dialling Numbers URI"),
+   EF_LIN_FIX_N(0x6FEE, SFI_NONE, "EF_BDNURI", F_OPTIONAL, 1, 128,
+   "Barred Dialling Numbers URI"),
+   EF_LIN_FIX_N(0x6FEF, SFI_NONE, "EF_SDNURI", F_OPTIONAL, 1, 128,
+   "Service Dialling Numbers URI"),
+   EF_LIN_FIX_N(0x6FF0, SFI_NONE, "EF_IWL", F_OPTIONAL, 18, 32,
+   "IMEI(SV) White Lists"),
+   EF_CYCLIC_N(0x6FF1, SFI_NONE, "EF_IPS", F_OPTIONAL, 4, 4,
+   "IMEI(SV) Pairing Status"),
+   EF_LIN_FIX_N(0x6FF2, SFI_NONE, "EF_IPD", F_OPTIONAL, 10, 16,
+   "IMEI(SV) of Pairing Device"),
+   EF_TRANSP_N(0x6FF3, SFI_NONE, "EF_ePDGId", F_OPTIONAL, 1, 128,
+   "Hom

Change in libosmocore[master]: osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17556 )


Change subject: osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards
..

osmo-sim-test: Also [attempt to] dump DF.GSM on USIM cards

an USIM application can very well exist on a UICC without supporting
classic DF.GSM access.  However, most commonly, both are found on
cards.

Change-Id: I6180a3f81a7d3006e8ece4302c2433db2588bfaa
---
M src/sim/card_fs_uicc.c
M src/sim/card_fs_usim.c
M utils/osmo-sim-test.c
3 files changed, 12 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/56/17556/1

diff --git a/src/sim/card_fs_uicc.c b/src/sim/card_fs_uicc.c
index c73fc9a..5dcaaa1 100644
--- a/src/sim/card_fs_uicc.c
+++ b/src/sim/card_fs_uicc.c
@@ -231,7 +231,7 @@
 /* Annex E - TS 101 220 */
 static const uint8_t __attribute__((__unused__)) adf_uicc_aid[] = { 0xA0, 
0x00, 0x00, 0x00, 0x87, 0x10, 0x01 };

-struct osim_card_profile *osim_cprof_uicc(void *ctx)
+struct osim_card_profile *osim_cprof_uicc(void *ctx, bool have_df_gsm)
 {
struct osim_card_profile *cprof;
struct osim_file_desc *mf;
@@ -255,5 +255,14 @@
return NULL;
}

+   if (have_df_gsm) {
+   /* DF.GSM as sub-directory of MF */
+   rc = osim_int_cprof_add_gsm(mf);
+   if (rc != 0) {
+   talloc_free(cprof);
+   return NULL;
+   }
+   }
+
return cprof;
 }
diff --git a/src/sim/card_fs_usim.c b/src/sim/card_fs_usim.c
index 97f712a..d5d2736 100644
--- a/src/sim/card_fs_usim.c
+++ b/src/sim/card_fs_usim.c
@@ -345,14 +345,5 @@
/* OMA BCAST Smart Card Profile */
add_df_with_ef(uadf, 0x5F80, "DF.BCAST", NULL, 0);

-#if 0
-   /* DF.GSM as sub-directory of MF */
-   rc = osim_int_cprof_add_gsm(mf);
-   if (rc != 0) {
-   talloc_free(cprof);
-   return NULL;
-   }
-#endif
-
return aprof;
 }
diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index 78d6665..58e1813 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -339,7 +339,7 @@


 extern struct osim_card_profile *osim_cprof_sim(void *ctx);
-extern struct osim_card_profile *osim_cprof_uicc(void *ctx);
+extern struct osim_card_profile *osim_cprof_uicc(void *ctx, bool have_df_gsm);

 static int dump_file(struct osim_chan_hdl *chan, const char *short_name, 
uint16_t fid)
 {
@@ -646,7 +646,7 @@

rc = osim_uicc_scan_apps(chan);
if (rc >= 0) {
-   chan->card->prof = osim_cprof_uicc(chan->card);
+   chan->card->prof = osim_cprof_uicc(chan->card, true);
chan->cwd = chan->card->prof->mf;
} else if (rc == -0x6e00) {
/* CLA not supported: must be classic SIM, not USIM */

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17556
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6180a3f81a7d3006e8ece4302c2433db2588bfaa
Gerrit-Change-Number: 17556
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in libosmocore[master]: sim: Add HPSIM application support

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17558 )


Change subject: sim: Add HPSIM application support
..

sim: Add HPSIM application support

Change-Id: I883faae5e170803b8301d10c8b9fad7892da009c
---
M src/sim/Makefile.am
A src/sim/card_fs_hpsim.c
M src/sim/core.c
M src/sim/sim_int.h
4 files changed, 79 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/58/17558/1

diff --git a/src/sim/Makefile.am b/src/sim/Makefile.am
index 14bbbd8..0539dd9 100644
--- a/src/sim/Makefile.am
+++ b/src/sim/Makefile.am
@@ -14,7 +14,7 @@

 libosmosim_la_SOURCES = core.c reader.c class_tables.c \
card_fs_sim.c card_fs_usim.c card_fs_uicc.c \
-   card_fs_isim.c card_fs_tetra.c
+   card_fs_isim.c card_fs_hpsim.c card_fs_tetra.c
 libosmosim_la_LDFLAGS = -version-info $(LIBVERSION)
 libosmosim_la_LIBADD = \
$(top_builddir)/src/libosmocore.la \
diff --git a/src/sim/card_fs_hpsim.c b/src/sim/card_fs_hpsim.c
new file mode 100644
index 000..4a5f7d9
--- /dev/null
+++ b/src/sim/card_fs_hpsim.c
@@ -0,0 +1,76 @@
+/*! \file card_fs_hpsim.c
+ * 3GPP HPSIM specific structures / routines. */
+/*
+ * (C) 2020 by Harald Welte 
+ *
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "sim_int.h"
+#include "gsm_int.h"
+
+/* TS 31.104 Version 15.0.0 Release 15 / Chapter 7.1.3 */
+const struct osim_card_sw ts31_104_sw[] = {
+   {
+   0x9862, 0x, SW_TYPE_STR, SW_CLS_ERROR,
+   .u.str = "Security management - Authentication error, incorrect 
MAC",
+   },
+   OSIM_CARD_SW_LAST
+};
+
+/* TS 31.104 Version 15.0.0 Release 15 / Chapter 4.2 */
+static const struct osim_file_desc hpsim_ef_in_adf_hpsim[] = {
+   EF_LIN_FIX_N(0x6F06, 0x06, "EF.ARR", 0, 1, 256,
+   "Access Rule TLV data objects"),
+   EF_TRANSP_N(0x6F07, 0x07, "EF.IMST", 0, 9, 9,
+   "IMSI"),
+   EF_TRANSP_N(0x6FAD, 0x03, "EF_AD", 0, 4, 8,
+   "Administrative Data"),
+};
+
+/* Annex E - TS 101 220 */
+static const uint8_t adf_hpsim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 
0x0A };
+
+struct osim_card_app_profile *osim_aprof_hpsim(void *ctx)
+{
+   struct osim_card_app_profile *aprof;
+   struct osim_file_desc *iadf;
+
+   aprof = talloc_zero(ctx, struct osim_card_app_profile);
+   aprof->name = "3GPP HPSIM";
+   aprof->sw = ts31_104_sw;
+   aprof->aid_len = sizeof(adf_hpsim_aid);
+   memcpy(aprof->aid, adf_hpsim_aid, aprof->aid_len);
+
+   /* ADF.HPSIM with its EF siblings */
+   iadf = alloc_adf_with_ef(aprof, adf_hpsim_aid, sizeof(adf_hpsim_aid), 
"ADF.HPSIM",
+hpsim_ef_in_adf_hpsim, 
ARRAY_SIZE(hpsim_ef_in_adf_hpsim));
+   aprof->adf = iadf;
+
+   return aprof;
+}
diff --git a/src/sim/core.c b/src/sim/core.c
index 80a168f..8b2d6f9 100644
--- a/src/sim/core.c
+++ b/src/sim/core.c
@@ -453,6 +453,7 @@
 {
osim_app_profile_register(osim_aprof_usim(ctx));
osim_app_profile_register(osim_aprof_isim(ctx));
+   osim_app_profile_register(osim_aprof_hpsim(ctx));

return 0;
 }
diff --git a/src/sim/sim_int.h b/src/sim/sim_int.h
index 99a2242..a96a9cd 100644
--- a/src/sim/sim_int.h
+++ b/src/sim/sim_int.h
@@ -33,5 +33,6 @@

 struct osim_card_app_profile *osim_aprof_usim(void *ctx);
 struct osim_card_app_profile *osim_aprof_isim(void *ctx);
+struct osim_card_app_profile *osim_aprof_hpsim(void *ctx);

 #endif

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17558
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I883faae5e170803b8301d10c8b9fad7892da009c
Gerrit-Change-Number: 17558
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in libosmocore[master]: sim: card_fs_usim.c: Fix FID of EF.EXT4

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17550 )


Change subject: sim: card_fs_usim.c: Fix FID of EF.EXT4
..

sim: card_fs_usim.c: Fix FID of EF.EXT4

The 3GPP spec document also contains this error at one point, and
it seems I copied it from there :/

Change-Id: I7ad9f491c06f6540747b77017678ee37e6a1550d
---
M src/sim/card_fs_usim.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/50/17550/1

diff --git a/src/sim/card_fs_usim.c b/src/sim/card_fs_usim.c
index 9e9fc87..3b33c0f 100644
--- a/src/sim/card_fs_usim.c
+++ b/src/sim/card_fs_usim.c
@@ -161,7 +161,7 @@
"Key for hidden phone book entries"),
EF_LIN_FIX_N(0x6F4D, SFI_NONE, "EF.BDN", F_OPTIONAL, 15, 32,
"Barred Dialling Numbers"),
-   EF_LIN_FIX_N(0x6F4E, SFI_NONE, "EF.EXT4", F_OPTIONAL, 13, 13,
+   EF_LIN_FIX_N(0x6F55, SFI_NONE, "EF.EXT4", F_OPTIONAL, 13, 13,
"Extension 4"),
EF_LIN_FIX_N(0x6F58, SFI_NONE, "EF.CMI", F_OPTIONAL, 2, 16,
"Comparison Method Information"),

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17550
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I7ad9f491c06f6540747b77017678ee37e6a1550d
Gerrit-Change-Number: 17550
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in libosmocore[master]: osmo-sim-test: Use stderr for error messages

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17551 )


Change subject: osmo-sim-test: Use stderr for error messages
..

osmo-sim-test: Use stderr for error messages

Change-Id: I8f36b07b8601af2b0d54d95c3c6374d6c54bafd1
---
M utils/osmo-sim-test.c
1 file changed, 7 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/51/17551/1

diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index 27de0bc..2bf83fa 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -326,25 +326,25 @@

msg = select_file(chan, fid);
if (!msg) {
-   printf("Unable to select file\n");
+   fprintf(stderr, "Unable to select file\n");
return -EIO;
}
printf("SW: %s\n", osim_print_sw(chan->card, msgb_apdu_sw(msg)));
if (msgb_apdu_sw(msg) != 0x9000) {
-   printf("status 0x%04x selecting file\n", msgb_apdu_sw(msg));
+   fprintf(stderr, "status 0x%04x selecting file\n", 
msgb_apdu_sw(msg));
goto out;
}

if (g_class != 0xA0) {
rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, 
msgb_apdu_le(msg)-2, 0, 0);
if (rc < 0) {
-   printf("Unable to parse FCP: %s\n", msgb_hexdump(msg));
+   fprintf(stderr, "Unable to parse FCP: %s\n", 
msgb_hexdump(msg));
goto out;
}

if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_DESC) ||
TLVP_LEN(&tp, UICC_FCP_T_FILE_DESC) < 2) {
-   printf("No file descriptor present ?!?\n");
+   fprintf(stderr, "No file descriptor present ?!?\n");
goto out;
}

@@ -355,12 +355,12 @@
}

if (rc < 0) {
-   printf("Unable to decode File Descriptor\n");
+   fprintf(stderr, "Unable to decode File Descriptor\n");
goto out;
}

if (ffdd.type != TYPE_EF) {
-   printf("File Type != EF\n");
+   fprintf(stderr, "File Type != EF\n");
goto out;
}

@@ -384,7 +384,7 @@
i = ntohs(*(uint16_t *)TLVP_VAL(&tp, 
UICC_FCP_T_FILE_SIZE));
printf("File size: %d bytes\n", i);
} else {
-   printf("Can not determine file size, invalid 
EF-type!\n");
+   fprintf(stderr, "Can not determine file size, invalid 
EF-type!\n");
goto out;
}
for (offset = 0; offset < i-1; ) {

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17551
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f36b07b8601af2b0d54d95c3c6374d6c54bafd1
Gerrit-Change-Number: 17551
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange


Change in libosmocore[master]: osmo-sim-test: don't print SW in successful case of dump_file()

2020-03-21 Thread laforge
laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/17552 )


Change subject: osmo-sim-test: don't print SW in successful case of dump_file()
..

osmo-sim-test: don't print SW in successful case of dump_file()

Change-Id: Ie5a58a89052400d76a8607a2e0063917385beb25
---
M utils/osmo-sim-test.c
1 file changed, 0 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/52/17552/1

diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index 2bf83fa..4c704f6 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -329,7 +329,6 @@
fprintf(stderr, "Unable to select file\n");
return -EIO;
}
-   printf("SW: %s\n", osim_print_sw(chan->card, msgb_apdu_sw(msg)));
if (msgb_apdu_sw(msg) != 0x9000) {
fprintf(stderr, "status 0x%04x selecting file\n", 
msgb_apdu_sw(msg));
goto out;

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17552
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie5a58a89052400d76a8607a2e0063917385beb25
Gerrit-Change-Number: 17552
Gerrit-PatchSet: 1
Gerrit-Owner: laforge 
Gerrit-MessageType: newchange