summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/common
diff options
context:
space:
mode:
authorЯницкий Ва дим <axilirator@gmail.com>2016-01-10 19:14:18 +0600
committerSylvain Munaut <tnt@246tNt.com>2016-01-18 21:08:45 +0100
commitbec943f0b7b46680c107d9ee634a6e281222aa20 (patch)
tree4f9c7a036e436beded37c7c48f69fd1a4e80561e /src/host/layer23/src/common
parent65f05ce618fc79466d7ea9810361289c6119abdb (diff)
host/mobile: Improved SAP interface integration
1) Now the SAP interface is selectable as SIM source using the 'sim sap' command in VTY. 2) SAP connection starts only if it is configured as SIM source. 3) Fixed sap_socket_path configuration r/w errors. Written-by: Яницкий Ва дим <axilirator@gmail.com> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/host/layer23/src/common')
-rw-r--r--src/host/layer23/src/common/sap_interface.c16
-rw-r--r--src/host/layer23/src/common/sim.c8
2 files changed, 6 insertions, 18 deletions
diff --git a/src/host/layer23/src/common/sap_interface.c b/src/host/layer23/src/common/sap_interface.c
index a56f4f28..22f95503 100644
--- a/src/host/layer23/src/common/sap_interface.c
+++ b/src/host/layer23/src/common/sap_interface.c
@@ -500,7 +500,6 @@ int sap_open(struct osmocom_ms *ms, const char *socket_path)
{
ssize_t rc;
struct sockaddr_un local;
- struct gsm_settings *set = &ms->settings;
ms->sap_wq.bfd.fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (ms->sap_wq.bfd.fd < 0) {
@@ -515,7 +514,7 @@ int sap_open(struct osmocom_ms *ms, const char *socket_path)
rc = connect(ms->sap_wq.bfd.fd, (struct sockaddr *) &local, sizeof(local));
if (rc < 0) {
fprintf(stderr, "Failed to connect to '%s'\n", local.sun_path);
- set->sap_socket_path[0] = 0;
+ ms->sap_entity.sap_state = SAP_SOCKET_ERROR;
close(ms->sap_wq.bfd.fd);
return rc;
}
@@ -582,22 +581,11 @@ int osmosap_sapsocket(struct osmocom_ms *ms, const char *path)
int osmosap_init(struct osmocom_ms *ms)
{
struct osmosap_entity *sap = &ms->sap_entity;
- int rc;
+ LOGP(DSAP, LOGL_INFO, "init SAP client\n");
sap->sap_state = SAP_NOT_CONNECTED;
sap->max_msg_size = GSM_SAP_LENGTH;
- LOGP(DSAP, LOGL_INFO, "init SAP client\n");
-
- if(ms->settings.sap_socket_path){
- rc = sap_open(ms, ms->settings.sap_socket_path);
- if (rc < 0) {
- fprintf(stderr, "Failed during sap_open(), no SAP based SIM reader\n");
- ms->sap_wq.bfd.fd = -1;
- return rc;
- }
- }
-
return 0;
}
diff --git a/src/host/layer23/src/common/sim.c b/src/host/layer23/src/common/sim.c
index 8e8d7bfe..9aad9666 100644
--- a/src/host/layer23/src/common/sim.c
+++ b/src/host/layer23/src/common/sim.c
@@ -188,12 +188,12 @@ static int sim_apdu_send(struct osmocom_ms *ms, uint8_t *data, uint16_t length)
/* adding SAP client support
* it makes more sense to do it here then in L1CTL */
- if(ms->settings.sap_socket_path[0] == 0) {
- LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n");
- l1ctl_tx_sim_req(ms, data, length);
- } else {
+ if (ms->subscr.sim_type == GSM_SIM_TYPE_SAP) {
LOGP(DSIM, LOGL_INFO, "Using SAP backend\n");
osmosap_send_apdu(ms, data, length);
+ } else {
+ LOGP(DSIM, LOGL_INFO, "Using built-in SIM reader\n");
+ l1ctl_tx_sim_req(ms, data, length);
}
return 0;