mirror of https://gerrit.osmocom.org/libosmocore
sim: strip the SW from the returned data, as SW is passed in msgb->cb
This commit is contained in:
parent
495fe2682c
commit
a5c9255baa
|
@ -27,11 +27,15 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <osmocom/core/msgb.h>
|
||||
#include <osmocom/sim/sim.h>
|
||||
|
||||
|
||||
#include "sim_int.h"
|
||||
|
||||
/* remove the SW from end of the message */
|
||||
static int get_sw(struct msgb *resp)
|
||||
{
|
||||
int ret;
|
||||
|
@ -39,8 +43,7 @@ static int get_sw(struct msgb *resp)
|
|||
if (!msgb_apdu_de(resp) || msgb_apdu_le(resp) < 2)
|
||||
return -EIO;
|
||||
|
||||
ret = resp->data[resp->len-2] << 8;
|
||||
ret |= resp->data[resp->len-1];
|
||||
ret = msgb_get_u16(resp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ static int dump_fcp_template_msg(struct msgb *msg)
|
|||
struct tlv_parsed tp;
|
||||
int rc;
|
||||
|
||||
rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-4, 0, 0);
|
||||
rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-2, 0, 0);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
|
@ -223,7 +223,7 @@ static struct msgb *try_select_adf_usim(struct osim_chan_hdl *st)
|
|||
int rc, i;
|
||||
|
||||
msg = select_file(st, 0x2f00);
|
||||
rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-4, 0, 0);
|
||||
rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-2, 0, 0);
|
||||
if (rc < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -302,7 +302,7 @@ static int dump_file(struct osim_chan_hdl *chan, uint16_t fid)
|
|||
goto out;
|
||||
}
|
||||
|
||||
rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-4, 0, 0);
|
||||
rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-2, 0, 0);
|
||||
if (rc < 0) {
|
||||
printf("Unable to parse FCP\n");
|
||||
goto out;
|
||||
|
|
Loading…
Reference in New Issue