mirror of git://git.sysmocom.de/ofono
rilmodem: Convert decode_hex to l_util_from_hexstring
This commit is contained in:
parent
2984391b31
commit
b2ebd60bcd
|
@ -31,6 +31,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <ell/ell.h>
|
||||||
|
|
||||||
#include <ofono/log.h>
|
#include <ofono/log.h>
|
||||||
#include <ofono/modem.h>
|
#include <ofono/modem.h>
|
||||||
|
@ -150,7 +151,7 @@ static void ril_file_info_cb(struct ril_msg *message, gpointer user_data)
|
||||||
int sw1, sw2;
|
int sw1, sw2;
|
||||||
char *hex_response;
|
char *hex_response;
|
||||||
unsigned char *response = NULL;
|
unsigned char *response = NULL;
|
||||||
long len;
|
size_t len;
|
||||||
gboolean ok = FALSE;
|
gboolean ok = FALSE;
|
||||||
int flen = 0, rlen = 0, str = 0;
|
int flen = 0, rlen = 0, str = 0;
|
||||||
guchar access[3] = { 0x00, 0x00, 0x00 };
|
guchar access[3] = { 0x00, 0x00, 0x00 };
|
||||||
|
@ -173,7 +174,7 @@ static void ril_file_info_cb(struct ril_msg *message, gpointer user_data)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (hex_response != NULL) {
|
if (hex_response != NULL) {
|
||||||
response = decode_hex(hex_response, -1, &len, -1);
|
response = l_util_from_hexstring(hex_response, &len);
|
||||||
g_free(hex_response);
|
g_free(hex_response);
|
||||||
hex_response = NULL;
|
hex_response = NULL;
|
||||||
|
|
||||||
|
@ -217,9 +218,6 @@ static void ril_file_info_cb(struct ril_msg *message, gpointer user_data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (response[0] == 0x62) {
|
if (response[0] == 0x62) {
|
||||||
ok = sim_parse_3g_get_response(response, len,
|
ok = sim_parse_3g_get_response(response, len,
|
||||||
&flen, &rlen, &str,
|
&flen, &rlen, &str,
|
||||||
|
@ -230,7 +228,7 @@ static void ril_file_info_cb(struct ril_msg *message, gpointer user_data)
|
||||||
&flen, &rlen, &str,
|
&flen, &rlen, &str,
|
||||||
access, &file_status);
|
access, &file_status);
|
||||||
|
|
||||||
g_free(response);
|
l_free(response);
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -240,7 +238,7 @@ static void ril_file_info_cb(struct ril_msg *message, gpointer user_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
g_free(response);
|
l_free(response);
|
||||||
CALLBACK_WITH_FAILURE(cb, -1, -1, -1, NULL,
|
CALLBACK_WITH_FAILURE(cb, -1, -1, -1, NULL,
|
||||||
EF_STATUS_INVALIDATED, cbd->data);
|
EF_STATUS_INVALIDATED, cbd->data);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +378,7 @@ static void ril_file_io_cb(struct ril_msg *message, gpointer user_data)
|
||||||
if (hex_response == NULL)
|
if (hex_response == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
response = decode_hex(hex_response, -1, &len, -1);
|
response = l_util_from_hexstring(hex_response, &len);
|
||||||
g_free(hex_response);
|
g_free(hex_response);
|
||||||
hex_response = NULL;
|
hex_response = NULL;
|
||||||
|
|
||||||
|
@ -390,11 +388,11 @@ static void ril_file_io_cb(struct ril_msg *message, gpointer user_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
CALLBACK_WITH_SUCCESS(cb, response, len, cbd->data);
|
CALLBACK_WITH_SUCCESS(cb, response, len, cbd->data);
|
||||||
g_free(response);
|
l_free(response);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
g_free(response);
|
l_free(response);
|
||||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
|
CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <ell/ell.h>
|
||||||
|
|
||||||
#include <ofono/log.h>
|
#include <ofono/log.h>
|
||||||
#include <ofono/modem.h>
|
#include <ofono/modem.h>
|
||||||
|
@ -94,20 +95,21 @@ static void ril_stk_envelope_cb(struct ril_msg *message, gpointer user_data)
|
||||||
struct stk_data *sd = cbd->user;
|
struct stk_data *sd = cbd->user;
|
||||||
struct parcel rilp;
|
struct parcel rilp;
|
||||||
unsigned char *response = NULL;
|
unsigned char *response = NULL;
|
||||||
long len = 0;
|
|
||||||
char *pdu;
|
|
||||||
|
|
||||||
g_ril_print_response(sd->ril, message);
|
g_ril_print_response(sd->ril, message);
|
||||||
|
|
||||||
if (message->error == RIL_E_SUCCESS) {
|
if (message->error == RIL_E_SUCCESS) {
|
||||||
|
char *pdu;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
g_ril_init_parcel(message, &rilp);
|
g_ril_init_parcel(message, &rilp);
|
||||||
pdu = parcel_r_string(&rilp);
|
pdu = parcel_r_string(&rilp);
|
||||||
|
|
||||||
if (pdu)
|
if (pdu)
|
||||||
response = decode_hex(pdu, -1, &len, -1);
|
response = l_util_from_hexstring(pdu, &len);
|
||||||
|
|
||||||
CALLBACK_WITH_SUCCESS(cb, response, len, cbd->data);
|
CALLBACK_WITH_SUCCESS(cb, response, len, cbd->data);
|
||||||
g_free(response);
|
l_free(response);
|
||||||
} else {
|
} else {
|
||||||
ofono_error("%s RILD reply failure: %s",
|
ofono_error("%s RILD reply failure: %s",
|
||||||
g_ril_request_id_to_string(sd->ril, message->req),
|
g_ril_request_id_to_string(sd->ril, message->req),
|
||||||
|
@ -145,32 +147,32 @@ static void ril_stk_proactive_cmd_notify(struct ril_msg *message,
|
||||||
{
|
{
|
||||||
struct ofono_stk *stk = user_data;
|
struct ofono_stk *stk = user_data;
|
||||||
struct parcel rilp;
|
struct parcel rilp;
|
||||||
long pdulen;
|
size_t pdulen;
|
||||||
unsigned char *pdu;
|
unsigned char *pdu;
|
||||||
|
|
||||||
DBG("");
|
DBG("");
|
||||||
|
|
||||||
g_ril_init_parcel(message, &rilp);
|
g_ril_init_parcel(message, &rilp);
|
||||||
pdu = decode_hex(parcel_r_string(&rilp), -1, &pdulen, -1);
|
pdu = l_util_from_hexstring(parcel_r_string(&rilp), &pdulen);
|
||||||
|
|
||||||
ofono_stk_proactive_command_notify(stk, pdulen, pdu);
|
ofono_stk_proactive_command_notify(stk, pdulen, pdu);
|
||||||
g_free(pdu);
|
l_free(pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ril_stk_event_notify(struct ril_msg *message, gpointer user_data)
|
static void ril_stk_event_notify(struct ril_msg *message, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct ofono_stk *stk = user_data;
|
struct ofono_stk *stk = user_data;
|
||||||
struct parcel rilp;
|
struct parcel rilp;
|
||||||
long pdulen;
|
size_t pdulen;
|
||||||
unsigned char *pdu;
|
unsigned char *pdu;
|
||||||
|
|
||||||
DBG("");
|
DBG("");
|
||||||
|
|
||||||
g_ril_init_parcel(message, &rilp);
|
g_ril_init_parcel(message, &rilp);
|
||||||
pdu = decode_hex(parcel_r_string(&rilp), -1, &pdulen, -1);
|
pdu = l_util_from_hexstring(parcel_r_string(&rilp), &pdulen);
|
||||||
|
|
||||||
ofono_stk_proactive_command_handled_notify(stk, pdulen, pdu);
|
ofono_stk_proactive_command_handled_notify(stk, pdulen, pdu);
|
||||||
g_free(pdu);
|
l_free(pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ril_stk_session_end_notify(struct ril_msg *message,
|
static void ril_stk_session_end_notify(struct ril_msg *message,
|
||||||
|
|
Loading…
Reference in New Issue