aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-07-26 14:51:15 +0200
committerKévin Redon <kredon@sysmocom.de>2018-07-26 14:51:15 +0200
commitd1c65361546203e6c886ff4b8d27ef71696ef76e (patch)
tree10d8040f8b0aadbe3fc8d4e933cc7fa1ab87ad7c
parent352809992cfbe748dba7b5b565fcd2bc3dbeac6d (diff)
sniff: send ATR over GSMTAP
-rw-r--r--host/simtrace2-sniff.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/host/simtrace2-sniff.c b/host/simtrace2-sniff.c
index 776253a..6d5766f 100644
--- a/host/simtrace2-sniff.c
+++ b/host/simtrace2-sniff.c
@@ -65,7 +65,7 @@ struct st_transport {
/* global GSMTAP instance */
static struct gsmtap_inst *g_gti;
-static int gsmtap_send_sim(const uint8_t *apdu, unsigned int len)
+static int gsmtap_send_sim(uint8_t sub_type, const uint8_t *data, unsigned int len)
{
struct gsmtap_hdr *gh;
unsigned int gross_len = len + sizeof(*gh);
@@ -80,8 +80,9 @@ static int gsmtap_send_sim(const uint8_t *apdu, unsigned int len)
gh->version = GSMTAP_VERSION;
gh->hdr_len = sizeof(*gh)/4;
gh->type = GSMTAP_TYPE_SIM;
+ gh->sub_type = sub_type;
- memcpy(buf + sizeof(*gh), apdu, len);
+ memcpy(buf + sizeof(*gh), data, len);
rc = write(gsmtap_inst_fd(g_gti), buf, gross_len);
if (rc < 0) {
@@ -235,9 +236,17 @@ static int process_data(enum simtrace_msg_type_sniff type, const uint8_t *buf, i
}
printf("\n");
- if (SIMTRACE_MSGT_SNIFF_TPDU == type) {
- /* send TPDU (now considered as APDU) to GSMTAP */
- gsmtap_send_sim(data->data, data->length);
+ /* Send message as GSNTAP */
+ switch (type) {
+ case SIMTRACE_MSGT_SNIFF_ATR:
+ gsmtap_send_sim(GSMTAP_SIM_ATR, data->data, data->length);
+ break;
+ case SIMTRACE_MSGT_SNIFF_TPDU:
+ /* TPDU is now considered as APDU since SIMtrace sends complete TPDU */
+ gsmtap_send_sim(GSMTAP_SIM_APDU, data->data, data->length);
+ break;
+ default:
+ break;
}
return 0;