From fdf7d2f8a5599934ae3fe252c9983576259ffd11 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 12 Jan 2013 08:59:05 +0100 Subject: layer23: Send SIM APDUs via GSMTAP, if enabled --- src/host/layer23/src/common/l1ctl.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/host/layer23/src/common/l1ctl.c b/src/host/layer23/src/common/l1ctl.c index fa6db7a1..91bab897 100644 --- a/src/host/layer23/src/common/l1ctl.c +++ b/src/host/layer23/src/common/l1ctl.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,9 @@ extern struct gsmtap_inst *gsmtap_inst; +static int apdu_len = -1; +static uint8_t apdu_data[256 + 7]; + static struct msgb *osmo_l1_alloc(uint8_t msg_type) { struct l1ctl_hdr *l1h; @@ -630,6 +634,12 @@ int l1ctl_tx_sim_req(struct osmocom_ms *ms, uint8_t *data, uint16_t length) struct msgb *msg; uint8_t *dat; + if (length <= sizeof(apdu_data)) { + memcpy(apdu_data, data, length); + apdu_len = length; + } else + apdu_len = -1; + msg = osmo_l1_alloc(L1CTL_SIM_REQ); if (!msg) return -1; @@ -645,7 +655,14 @@ static int rx_l1_sim_conf(struct osmocom_ms *ms, struct msgb *msg) { uint16_t len = msg->len - sizeof(struct l1ctl_hdr); uint8_t *data = msg->data + sizeof(struct l1ctl_hdr); - + + if (apdu_len > -1 && apdu_len + len <= sizeof(apdu_data)) { + memcpy(apdu_data + apdu_len, data, len); + apdu_len += len; + gsmtap_send_ex(gsmtap_inst, GSMTAP_TYPE_SIM, 0, 0, 0, 0, 0, 0, + 0, apdu_data, apdu_len); + } + LOGP(DL1C, LOGL_INFO, "SIM %s\n", osmo_hexdump(data, len)); /* pull the L1 header from the msgb */ -- cgit v1.2.3