summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/common/l1ctl.c
diff options
context:
space:
mode:
authorAndreas.Eversberg <jolly@eversberg.eu>2010-09-18 19:15:15 +0000
committerAndreas.Eversberg <jolly@eversberg.eu>2010-09-18 19:15:15 +0000
commit0856c8a6a5ad48d810da598b421f81fc21d0ba55 (patch)
tree3b87fe6abbf65c4fc165827dea7f107e8f4c4435 /src/host/layer23/src/common/l1ctl.c
parentdf05c6ca94a5597a83afd29e7df5b2e4b6343fc2 (diff)
[layer23] SIM client completion
The SIM client is now complete. Because it usefull for multiple applications, i moved it to the layer23/src/common directory. The SIM reader works together with mobile process. Fixes were made. Thanx to all for testing, finding bugs, and making it work as it is supposed to do. The current version uses special L1CTL messages to send and receive APDUs. This will change in the future, when BTSAP interface is completed. Please note that this client will not work until the layer1 SIM reader fixes and extensions are committed.
Diffstat (limited to 'src/host/layer23/src/common/l1ctl.c')
-rw-r--r--src/host/layer23/src/common/l1ctl.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/host/layer23/src/common/l1ctl.c b/src/host/layer23/src/common/l1ctl.c
index abf4f8e0..72ccd5f7 100644
--- a/src/host/layer23/src/common/l1ctl.c
+++ b/src/host/layer23/src/common/l1ctl.c
@@ -157,6 +157,7 @@ static int rx_ph_data_ind(struct osmocom_ms *ms, struct msgb *msg)
meas->rxlev += dl->rx_level;
if (dl->num_biterr) {
+printf("Dropping frame with %u bit errors\n", dl->num_biterr);
LOGP(DL1C, LOGL_NOTICE, "Dropping frame with %u bit errors\n",
dl->num_biterr);
return 0;
@@ -521,6 +522,38 @@ int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len)
return osmo_send_l1(ms, msg);
}
+int l1ctl_tx_sim_req(struct osmocom_ms *ms, uint8_t *data, uint16_t length)
+{
+ struct msgb *msg;
+ uint8_t *dat;
+
+ msg = osmo_l1_alloc(L1CTL_SIM_REQ);
+ if (!msg)
+ return -1;
+
+ dat = msgb_put(msg, length);
+ memcpy(dat, data, length);
+
+ return osmo_send_l1(ms, msg);
+}
+
+/* just forward the SIM response to the SIM handler */
+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);
+
+ printf("SIM %s\n", hexdump(data, len));
+
+ /* pull the L1 header from the msgb */
+ msgb_pull(msg, sizeof(struct l1ctl_hdr));
+ msg->l1h = NULL;
+
+ sim_apdu_resp(ms, msg);
+
+ return 0;
+}
+
/* Transmit L1CTL_PM_REQ */
int l1ctl_tx_pm_req_range(struct osmocom_ms *ms, uint16_t arfcn_from,
uint16_t arfcn_to)
@@ -657,6 +690,9 @@ int l1ctl_recv(struct osmocom_ms *ms, struct msgb *msg)
rc = rx_l1_ccch_mode_conf(ms, msg);
msgb_free(msg);
break;
+ case L1CTL_SIM_CONF:
+ rc = rx_l1_sim_conf(ms, msg);
+ break;
default:
fprintf(stderr, "Unknown MSG: %u\n", l1h->msg_type);
msgb_free(msg);