From leonard.huebner at commsolid.com Thu Oct 22 14:53:39 2020 From: leonard.huebner at commsolid.com (=?iso-8859-1?Q?Leonard_H=FCbner?=) Date: Thu, 22 Oct 2020 14:53:39 +0000 Subject: simtrace2-remsim set-atr flag - code offer Message-ID: Hey there SIMTrace-Community! In the context of my current project I needed to set the ATR, which the SIMTrace2(cardem firmware) sends to the SIM-Terminal. To this end I added a cli flag (--set-atr) to the simtrace2-remsim host software which takes an ATR and signals to the cardem firmware to use this ATR. The later functionality is already present and therefore I only implemented the cli flag and the string to hex transformation (using osmo_hexparse). Would you be interested in this code? If you are, how can I contribute it? It currently lives inside a git branch on my machine. Thank you very much for making the code freely available! Leonard H?bner -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at osmocom.org Fri Oct 23 08:37:25 2020 From: laforge at osmocom.org (Harald Welte) Date: Fri, 23 Oct 2020 10:37:25 +0200 Subject: simtrace2-remsim set-atr flag - code offer In-Reply-To: References: Message-ID: <20201023083725.GG4634@nataraja> Hi Leonhard, thanks for reaching out. > Would you be interested in this code? > If you are, how can I contribute it? It currently lives inside a git branch on my machine. We're happy to review + merge your patch, please submit it using gerrit, see https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit If you have troubles setting that up, and it's just a small patch, and you don't expect to contribute more in the future, you can also simply use git send-email to send the patch [series] to this mailing list. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From leonard.huebner at commsolid.com Mon Oct 26 11:12:02 2020 From: leonard.huebner at commsolid.com (=?UTF-8?q?Leonard=20H=C3=BCbner?=) Date: Mon, 26 Oct 2020 12:12:02 +0100 Subject: [PATCH] remsim: adding cli argument to set the atr Message-ID: <20201026111202.20839-1-leonard.huebner@commsolid.com> --- host/src/simtrace2-remsim.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/host/src/simtrace2-remsim.c b/host/src/simtrace2-remsim.c index 201ff71..48186d8 100644 --- a/host/src/simtrace2-remsim.c +++ b/host/src/simtrace2-remsim.c @@ -50,6 +50,8 @@ #include #include +#define ATR_MAX_LEN 33 + static void atr_update_csum(uint8_t *atr, unsigned int atr_len) { uint8_t csum = 0; @@ -181,6 +183,7 @@ static void print_help(void) "\t-h\t--help\n" "\t-i\t--gsmtap-ip\tA.B.C.D\n" "\t-a\t--skip-atr\n" + "\t-t\t--set-atr\tATR-STRING in HEX\n" "\t-k\t--keep-running\n" "\t-n\t--pcsc-reader-num\n" "\t-V\t--usb-vendor\tVENDOR_ID\n" @@ -199,6 +202,7 @@ static const struct option opts[] = { { "remote-udp-port", 1, 0, 'p' }, { "gsmtap-ip", 1, 0, 'i' }, { "skip-atr", 0, 0, 'a' }, + { "set-atr", 1, 0, 't' }, { "help", 0, 0, 'h' }, { "keep-running", 0, 0, 'k' }, { "pcsc-reader-num", 1, 0, 'n' }, @@ -283,6 +287,9 @@ int main(int argc, char **argv) int rc; int c, ret = 1; int skip_atr = 0; + char *atr = "3b00"; + uint8_t real_atr[ATR_MAX_LEN]; + int atr_len; int keep_running = 0; int remote_udp_port = 52342; int if_num = 0, vendor_id = -1, product_id = -1; @@ -298,7 +305,7 @@ int main(int argc, char **argv) while (1) { int option_index = 0; - c = getopt_long(argc, argv, "r:p:hi:V:P:C:I:S:A:H:akn:", opts, &option_index); + c = getopt_long(argc, argv, "r:p:hi:V:P:C:I:S:A:H:akn:t:", opts, &option_index); if (c == -1) break; switch (c) { @@ -318,6 +325,9 @@ int main(int argc, char **argv) case 'a': skip_atr = 1; break; + case 't': + atr = optarg; + break; case 'k': keep_running = 1; break; @@ -348,6 +358,12 @@ int main(int argc, char **argv) } } + atr_len = osmo_hexparse(atr,real_atr,ATR_MAX_LEN); + if(atr_len < 2) { + fprintf(stderr, "Invalid ATR - please omit a leading 0x and only use valid hex digits and whitespace. ATRs need to be between 2 and 33 bytes long.\n"); + goto do_exit; + } + if (!remote_udp_host && (vendor_id < 0 || product_id < 0)) { fprintf(stderr, "You have to specify the vendor and product ID\n"); goto do_exit; @@ -438,9 +454,8 @@ int main(int argc, char **argv) if (!skip_atr) { /* set the ATR */ - uint8_t real_atr[] = { 0x3B, 0x00 }; // the simplest ATR - atr_update_csum(real_atr, sizeof(real_atr)); - osmo_st2_cardem_request_set_atr(ci, real_atr, sizeof(real_atr)); + atr_update_csum(real_atr, atr_len); + osmo_st2_cardem_request_set_atr(ci, real_atr, atr_len); } /* select remote (forwarded) SIM */ -- 2.26.2 From leonard.huebner at commsolid.com Mon Oct 26 11:18:53 2020 From: leonard.huebner at commsolid.com (=?iso-8859-1?Q?Leonard_H=FCbner?=) Date: Mon, 26 Oct 2020 11:18:53 +0000 Subject: simtrace2-remsim set-atr flag - code offer In-Reply-To: <20201023083725.GG4634@nataraja> References: , <20201023083725.GG4634@nataraja> Message-ID: Hey Harald! Unfortunately, I was unable to properly setup Gerrit on my system, as my firewall prevents me from accessing the required ssh port. As I won't be able to contribute much more, I decided to submit the 'feature' via git send-email. I hope this is fine. Best regards, Leo ________________________________ From: Harald Welte Sent: Friday, October 23, 2020 10:37 AM To: Leonard H?bner Cc: simtrace at lists.osmocom.org Subject: Re: simtrace2-remsim set-atr flag - code offer Hi Leonhard, thanks for reaching out. > Would you be interested in this code? > If you are, how can I contribute it? It currently lives inside a git branch on my machine. We're happy to review + merge your patch, please submit it using gerrit, see https://osmocom.org/projects/cellular-infrastructure/wiki/Gerrit If you have troubles setting that up, and it's just a small patch, and you don't expect to contribute more in the future, you can also simply use git send-email to send the patch [series] to this mailing list. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at osmocom.org Mon Oct 26 20:17:23 2020 From: laforge at osmocom.org (Harald Welte) Date: Mon, 26 Oct 2020 21:17:23 +0100 Subject: [PATCH] remsim: adding cli argument to set the atr In-Reply-To: <20201026111202.20839-1-leonard.huebner@commsolid.com> References: <20201026111202.20839-1-leonard.huebner@commsolid.com> Message-ID: <20201026201723.GC32319@nataraja> Hi Leonhard, thanks for your patch. I tried to apply it to current master, but it doesn't apply. The previous commit 201ff71 you reference in your patch also doesn't appear to be in the official git repository. Please try to re-submit as a patch that applies on top of current master. Thanks! -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From leonard.huebner at commsolid.com Tue Oct 27 09:16:41 2020 From: leonard.huebner at commsolid.com (=?UTF-8?q?Leonard=20H=C3=BCbner?=) Date: Tue, 27 Oct 2020 10:16:41 +0100 Subject: [PATCH] remsim: adding cli argument to set the atr Message-ID: <20201027091641.8020-1-leonard.huebner@commsolid.com> --- host/src/simtrace2-remsim.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/host/src/simtrace2-remsim.c b/host/src/simtrace2-remsim.c index 201ff71..48186d8 100644 --- a/host/src/simtrace2-remsim.c +++ b/host/src/simtrace2-remsim.c @@ -50,6 +50,8 @@ #include #include +#define ATR_MAX_LEN 33 + static void atr_update_csum(uint8_t *atr, unsigned int atr_len) { uint8_t csum = 0; @@ -181,6 +183,7 @@ static void print_help(void) "\t-h\t--help\n" "\t-i\t--gsmtap-ip\tA.B.C.D\n" "\t-a\t--skip-atr\n" + "\t-t\t--set-atr\tATR-STRING in HEX\n" "\t-k\t--keep-running\n" "\t-n\t--pcsc-reader-num\n" "\t-V\t--usb-vendor\tVENDOR_ID\n" @@ -199,6 +202,7 @@ static const struct option opts[] = { { "remote-udp-port", 1, 0, 'p' }, { "gsmtap-ip", 1, 0, 'i' }, { "skip-atr", 0, 0, 'a' }, + { "set-atr", 1, 0, 't' }, { "help", 0, 0, 'h' }, { "keep-running", 0, 0, 'k' }, { "pcsc-reader-num", 1, 0, 'n' }, @@ -283,6 +287,9 @@ int main(int argc, char **argv) int rc; int c, ret = 1; int skip_atr = 0; + char *atr = "3b00"; + uint8_t real_atr[ATR_MAX_LEN]; + int atr_len; int keep_running = 0; int remote_udp_port = 52342; int if_num = 0, vendor_id = -1, product_id = -1; @@ -298,7 +305,7 @@ int main(int argc, char **argv) while (1) { int option_index = 0; - c = getopt_long(argc, argv, "r:p:hi:V:P:C:I:S:A:H:akn:", opts, &option_index); + c = getopt_long(argc, argv, "r:p:hi:V:P:C:I:S:A:H:akn:t:", opts, &option_index); if (c == -1) break; switch (c) { @@ -318,6 +325,9 @@ int main(int argc, char **argv) case 'a': skip_atr = 1; break; + case 't': + atr = optarg; + break; case 'k': keep_running = 1; break; @@ -348,6 +358,12 @@ int main(int argc, char **argv) } } + atr_len = osmo_hexparse(atr,real_atr,ATR_MAX_LEN); + if(atr_len < 2) { + fprintf(stderr, "Invalid ATR - please omit a leading 0x and only use valid hex digits and whitespace. ATRs need to be between 2 and 33 bytes long.\n"); + goto do_exit; + } + if (!remote_udp_host && (vendor_id < 0 || product_id < 0)) { fprintf(stderr, "You have to specify the vendor and product ID\n"); goto do_exit; @@ -438,9 +454,8 @@ int main(int argc, char **argv) if (!skip_atr) { /* set the ATR */ - uint8_t real_atr[] = { 0x3B, 0x00 }; // the simplest ATR - atr_update_csum(real_atr, sizeof(real_atr)); - osmo_st2_cardem_request_set_atr(ci, real_atr, sizeof(real_atr)); + atr_update_csum(real_atr, atr_len); + osmo_st2_cardem_request_set_atr(ci, real_atr, atr_len); } /* select remote (forwarded) SIM */ -- 2.26.2 From leonard.huebner at commsolid.com Tue Oct 27 09:23:17 2020 From: leonard.huebner at commsolid.com (=?iso-8859-1?Q?Leonard_H=FCbner?=) Date: Tue, 27 Oct 2020 09:23:17 +0000 Subject: [PATCH] remsim: adding cli argument to set the atr In-Reply-To: <20201026201723.GC32319@nataraja> References: <20201026111202.20839-1-leonard.huebner@commsolid.com>, <20201026201723.GC32319@nataraja> Message-ID: Hey Harald! Yeah, sorry, I forgot to pull before creating the patch... I recreated it on top of the current HEAD of the repo and verified that the patch works on my local setup. I hope that this fixes the issue. This is my first time of contributing via patches and send-email. Sorry for the inconvenience.. Leo -------------- next part -------------- An HTML attachment was scrubbed... URL: From laforge at osmocom.org Tue Oct 27 10:22:54 2020 From: laforge at osmocom.org (Harald Welte) Date: Tue, 27 Oct 2020 11:22:54 +0100 Subject: [PATCH] remsim: adding cli argument to set the atr In-Reply-To: <20201027091641.8020-1-leonard.huebner@commsolid.com> References: <20201027091641.8020-1-leonard.huebner@commsolid.com> Message-ID: <20201027102254.GH32319@nataraja> thanks, pushed to https://gerrit.osmocom.org/c/simtrace2/+/20931 Please keep in mind that the proof-of-concept 'remsim' hack inside simtrace2.git has been long superseeded by a proper implementation in osmo-remsim.git. I'm actually quite tempted to remove the old proof-of-concept code, as it's not really offering anything that the real osmo-remsim cannot do. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From leonard.huebner at commsolid.com Tue Oct 27 10:34:18 2020 From: leonard.huebner at commsolid.com (=?iso-8859-1?Q?Leonard_H=FCbner?=) Date: Tue, 27 Oct 2020 10:34:18 +0000 Subject: [PATCH] remsim: adding cli argument to set the atr In-Reply-To: <20201027102254.GH32319@nataraja> References: <20201027091641.8020-1-leonard.huebner@commsolid.com>, <20201027102254.GH32319@nataraja> Message-ID: Thanks for pushing the change into Gerrit! I didn't know about the proper implementation in osmo-remsim.git so I will check that out and test if it works with my setup. Greetings, Leo ________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: