sim: logical access API
PATCH 1/3 sim: logical access API
Moved logical access API from simauth to sim atom. This removes the need for a simauth driver completely, as the rest of the functionality was moved in previous commits.
--- include/sim.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/sim.h +10 -0
@@ -129,6 +129,9 @@ typedef void (*ofono_sim_open_channel_cb_t)(const struct ofono_error *error,typedef void (*ofono_sim_close_channel_cb_t )(const struct ofono_error *error,void *data); +typedef void (*ofono_sim_logical_access_cb_t )(const struct ofono_error *error, +const unsigned char *resp,unsigned int len,void *data); +struct ofono_sim_driver {const char *name;int (*probe)(struct ofono_sim *sim,unsigned int vendor,void *data);
@@ -199,6 +202,9 @@ struct ofono_sim_driver { int fileid, const unsigned char *path, unsigned int path_len, ofono_sim_file_info_cb_t cb, void *data); +void (*logical_access)(struct ofono_sim *sim,int session_id, +const unsigned char *pdu,unsigned int len, +ofono_sim_logical_access_cb_t cb,void *data); };int ofono_sim_driver_register (const struct ofono_sim_driver *d);
@@ -278,6 +284,10 @@ unsigned int ofono_sim_add_file_watch(struct ofono_sim_context *context,void ofono_sim_remove_file_watch (struct ofono_sim_context *context,unsigned int id); +int ofono_sim_logical_access (struct ofono_sim *sim,int session_id, +unsigned char *pdu,unsigned int len, +ofono_sim_logical_access_cb_t cb,void *data); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH 2/3 sim: logical access API implementation
Implemented wrapper for the sim drivers logical
access API
--- src/sim.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
src/sim.c +15 -0
@@ -3644,3 +3644,18 @@ GSList *__ofono_sim_get_aid_list(struct ofono_sim *sim) {return sim->aid_list; } + +int ofono_sim_logical_access (struct ofono_sim *sim,int session_id, +unsigned char *pdu,unsigned int len, +ofono_sim_logical_access_cb_t cb,void *data) +{ +if (!sim->driver->logical_access) +return -ENOTSUP ; + +if (session_id <=0 ) +return -EINVAL ; + + sim->driver->logical_access (sim, session_id, pdu, len, cb, data); + +return 0 ; +}
Signature · 1 line
2.7.4
PATCH 3/3 atmodem: implemented logical access driver API
In reply to James PrestwoodThis moves the logical access API from the simauth driver to the sim atmodem driver.
--- drivers/atmodem/sim.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)
drivers/atmodem/sim.c +66 -0
@@ -74,6 +74,7 @@ static const char *upincnt_prefix[] = { "+UPINCNT:", NULL };static const char *cuad_prefix[] = {"+CUAD:" ,NULL };static const char *ccho_prefix[] = {"+CCHO:" ,NULL };static const char *crla_prefix[] = {"+CRLA:" ,NULL }; +static const char *cgla_prefix[] = {"+CGLA:" ,NULL };static const char *none_prefix[] = {NULL }; static void append_file_path(char *buf, const unsigned char *path,
@@ -1871,6 +1872,70 @@ static void at_session_read_info(struct ofono_sim *sim, int session_id, EF_STATUS_INVALIDATED, data); } +static void logical_access_cb (gboolean ok,GAtResult *result, +gpointer user_data) +{ +struct cb_data *cbd = user_data; +ofono_sim_logical_access_cb_t cb = cbd->cb; +struct ofono_error error; +const char *str_data; +unsigned char *raw; +gint len =0 ; +GAtResultIter iter; + +decode_at_error (&error,g_at_result_final_response (result)); + +if (!ok) + goto error; + +g_at_result_iter_init (&iter, result); + +if (!g_at_result_iter_next (&iter,"+CGLA:" )) + goto error; + +if (!g_at_result_iter_next_number (&iter, &len)) + goto error; + +if (!g_at_result_iter_next_string (&iter, &str_data)) + goto error; + + raw =alloca (len /2 ); + +decode_hex_own_buf (str_data, len,NULL ,0 , raw); + +cb (&error, raw, len /2 , cbd->data); + +return ; + +error: +cb (&error,NULL ,0 , cbd->data); +} + +static void at_logical_access (struct ofono_sim *sim,int session_id, +const unsigned char *pdu,unsigned int len, +ofono_sim_logical_access_cb_t cb,void *data) +{ +struct sim_data *sd =ofono_sim_get_data (sim); +struct cb_data *cbd =cb_data_new (cb, data); +int ret =0 ; +char cmd[(len *2 ) +19 ]; + + ret =sprintf (cmd,"AT+CGLA=%d,%d,\"" , session_id, len *2 ); + +encode_hex_own_buf (pdu, len,0 , cmd + ret); + ret += len *2 ; + +strcpy (cmd + ret,"\"" ); + +if (g_at_chat_send (sd->chat, cmd, cgla_prefix, logical_access_cb, + cbd, g_free) >0 ) +return ; + +g_free (cbd); + +CALLBACK_WITH_FAILURE (cb,NULL ,0 , data); +} +static int at_sim_probe (struct ofono_sim *sim,unsigned int vendor,void *data) {
@@ -1936,6 +2001,7 @@ static struct ofono_sim_driver driver = { .session_read_binary = at_session_read_binary, .session_read_record = at_session_read_record, .session_read_info = at_session_read_info, + .logical_access = at_logical_access };static struct ofono_sim_driver driver_noef = {
Signature · 1 line
2.7.4
Hi James,
Quoted 7 lines · James Prestwood
Moved logical access API from simauth to sim atom. This removes the need for a simauth driver completely, as the rest of the functionality was moved in previous commits.
--- include/sim.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
All three applied, thanks.
Regards,
-Denis