summaryrefslogtreecommitdiff
path: root/src/rfid_layer2_iso14443b.c
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-10-14 12:34:38 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-10-14 12:34:38 +0000
commite404cccecd20a2418c2429cd182c18218e54bd28 (patch)
tree5a15b5ca51874f0f8e96ccc4ee0457a66de3cec7 /src/rfid_layer2_iso14443b.c
parent6e87a007525b313dcf2da194977bb1abdf62026f (diff)
Prepare RFID compilation in firmware mode
- switch from linked lists to static arrays - remove all non-handle dynamic allocations (at the expense of stack) - declare all proto/reader/asic/layer2 structures as const - wrap all handle allocations in macros that expand to references to static structures in case of firmware mode - update copyright notices - add skeleton code for openpcd-inside-firmware driver - update TODO with remaining TODO for firmware mode git-svn-id: https://svn.gnumonks.org/trunk/librfid@1903 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'src/rfid_layer2_iso14443b.c')
-rw-r--r--src/rfid_layer2_iso14443b.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/rfid_layer2_iso14443b.c b/src/rfid_layer2_iso14443b.c
index 8227a32..d88fee5 100644
--- a/src/rfid_layer2_iso14443b.c
+++ b/src/rfid_layer2_iso14443b.c
@@ -162,29 +162,24 @@ static int
transceive_attrib(struct rfid_layer2_handle *h, const unsigned char *inf,
unsigned int inf_len, unsigned char *rx_data, unsigned int *rx_len)
{
- struct iso14443b_attrib_hdr *attrib;
- unsigned int attrib_size = sizeof(*attrib) + inf_len;
- unsigned char *rx_buf;
+ struct {
+ struct iso14443b_attrib_hdr attrib;
+ char buf[256-3];
+ } _attrib_buf;
+
+ struct iso14443b_attrib_hdr *attrib = &_attrib_buf.attrib;
+ unsigned char rx_buf[256];
unsigned char fsdi;
int ret = 0;
DEBUGP("fsd is %u\n", h->priv.iso14443b.fsd);
- attrib = malloc(attrib_size);
- if (!attrib) {
- perror("attrib_alloc");
- return -1;
- }
-
- DEBUGP("fsd is %u\n", h->priv.iso14443b.fsd);
- rx_buf = malloc(*rx_len+1);
- if (!rx_buf) {
- perror("rx_buf malloc");
- ret = -1;
+ if (rx_len >= rx_len-1) {
+ perror("rx_len too large\n");
goto out_attrib;
}
/* initialize attrib frame */
- memset(attrib, 0, attrib_size);
+ memset(&_attrib_buf, 0, sizeof(_attrib_buf));
if (inf_len)
memcpy((unsigned char *)attrib+sizeof(*attrib), inf, inf_len);
@@ -237,7 +232,6 @@ transceive_attrib(struct rfid_layer2_handle *h, const unsigned char *inf,
out_rx:
free(rx_buf);
out_attrib:
- free(attrib);
return ret;
}
@@ -295,7 +289,7 @@ static struct rfid_layer2_handle *
iso14443b_init(struct rfid_reader_handle *rh)
{
int ret;
- struct rfid_layer2_handle *h = malloc(sizeof(*h));
+ struct rfid_layer2_handle *h = malloc_layer2_handle(sizeof(*h));
if (!h)
return NULL;
@@ -317,7 +311,7 @@ iso14443b_init(struct rfid_reader_handle *rh)
ret = h->rh->reader->iso14443b.init(h->rh);
if (ret < 0) {
DEBUGP("error during reader 14443b init\n");
- free(h);
+ free_layer2_handle(h);
return NULL;
}
@@ -327,7 +321,7 @@ iso14443b_init(struct rfid_reader_handle *rh)
static int
iso14443b_fini(struct rfid_layer2_handle *handle)
{
- free(handle);
+ free_layer2_handle(handle);
return 0;
}
@@ -394,7 +388,7 @@ iso14443b_setopt(struct rfid_layer2_handle *handle,
}
-struct rfid_layer2 rfid_layer2_iso14443b = {
+const struct rfid_layer2 rfid_layer2_iso14443b = {
.id = RFID_LAYER2_ISO14443B,
.name = "ISO 14443-3 B",
.fn = {
personal git repositories of Harald Welte. Your mileage may vary