summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-09-10 21:05:42 +0200
committerHarald Welte <laforge@gnumonks.org>2014-10-26 19:09:22 +0100
commita5c9255baa0dd97b564ea8d44444ac80c38153b9 (patch)
treee560df400e42937b1cb1216859d6c86bd1a3ec58 /src
parent495fe2682c37d7e2ba9d969fa0675e59db461790 (diff)
sim: strip the SW from the returned data, as SW is passed in msgb->cb
Diffstat (limited to 'src')
-rw-r--r--src/sim/reader.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/sim/reader.c b/src/sim/reader.c
index 71fb763d..5d6033bf 100644
--- a/src/sim/reader.c
+++ b/src/sim/reader.c
@@ -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;
}