Change in osmo-remsim[master]: add ATR as command line argument

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Kévin Redon gerrit-no-reply at lists.osmocom.org
Mon Nov 12 21:54:19 UTC 2018


Kévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/11753


Change subject: add ATR as command line argument
......................................................................

add ATR as command line argument

we could add a function checking the ATR validity
also before updating the (conditional) checksum we should check if
it is actually present in the ATR

Change-Id: Id1084abdf2318e96c22f8e69cc1ef161b12ef5ea
---
M src/simtrace2-remsim_client.c
1 file changed, 16 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/53/11753/1

diff --git a/src/simtrace2-remsim_client.c b/src/simtrace2-remsim_client.c
index 365acb4..f033e7d 100644
--- a/src/simtrace2-remsim_client.c
+++ b/src/simtrace2-remsim_client.c
@@ -245,6 +245,7 @@
 	return st_slot_tx_msg(ci->slot, msg, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_DT_CEMU_TX_DATA);
 }
 
+// FIXME check if the ATR actually includes a checksum
 static void atr_update_csum(uint8_t *atr, unsigned int atr_len)
 {
 	uint8_t csum = 0;
@@ -617,6 +618,7 @@
 		"\t-S\t--usb-altsetting ALTSETTING_ID\n"
 		"\t-A\t--usb-address\tADDRESS\n"
 		"\t-H\t--usb-path\tPATH\n"
+		"\t-a\t--atr\tATR\n"
 		"\n"
 		);
 }
@@ -636,6 +638,7 @@
 	{ "usb-altsetting", 1, 0, 'S' },
 	{ "usb-address", 1, 0, 'A' },
 	{ "usb-path", 1, 0, 'H' },
+	{ "atr", 1, 0, 'a' },
 	{ NULL, 0, 0, 0 }
 };
 
@@ -652,13 +655,15 @@
 	int config_id = -1, altsetting = 0, addr = -1;
 	char *bankd_host = "127.0.0.1";
 	char *path = NULL;
+	uint8_t atr_data[33] = { 0x3B, 0x00 }; // the shortest simplest ATR possible
+	uint8_t atr_len = 2;
 
 	print_welcome();
 
 	while (1) {
 		int option_index = 0;
 
-		c = getopt_long(argc, argv, "b:p:c:s:hi:V:P:C:I:S:A:H:k", opts, &option_index);
+		c = getopt_long(argc, argv, "b:p:c:s:hi:V:P:C:I:S:A:H:a:k", opts, &option_index);
 		if (c == -1)
 			break;
 		switch (c) {
@@ -705,6 +710,14 @@
 		case 'H':
 			path = optarg;
 			break;
+		case 'a':
+			rc = osmo_hexparse(optarg, atr_data, ARRAY_SIZE(atr_data));
+			if (rc < 2 || rc > ARRAY_SIZE(atr_data)) {
+				fprintf(stderr, "ATR matlformed\n");
+				goto do_exit;
+			}
+			atr_len = rc;
+			break;
 		}
 	}
 
@@ -839,9 +852,8 @@
 		st_modem_sim_select_remote(ci->slot);
 
 		/* set the ATR */
-		uint8_t real_atr[] = { 0x3B, 0x00 }; // the shortest simplest ATR possible
-		atr_update_csum(real_atr, sizeof(real_atr));
-		cardem_request_set_atr(ci, real_atr, sizeof(real_atr));
+		//atr_update_csum(real_atr, sizeof(real_atr));
+		cardem_request_set_atr(ci, atr_data, atr_len);
 
 		/* select remote (forwarded) SIM */
 		st_modem_reset_pulse(ci->slot, 300);

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

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id1084abdf2318e96c22f8e69cc1ef161b12ef5ea
Gerrit-Change-Number: 11753
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181112/8413ced7/attachment.htm>


More information about the gerrit-log mailing list