summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rfid_layer2_iso14443a.c7
-rw-r--r--src/rfid_proto_tcl.c42
-rw-r--r--src/rfid_protocol.c43
-rw-r--r--src/rfid_scan.c4
4 files changed, 91 insertions, 5 deletions
diff --git a/src/rfid_layer2_iso14443a.c b/src/rfid_layer2_iso14443a.c
index 34bd93f..b8e6ef4 100644
--- a/src/rfid_layer2_iso14443a.c
+++ b/src/rfid_layer2_iso14443a.c
@@ -112,7 +112,10 @@ iso14443a_anticol(struct rfid_layer2_handle *handle)
memset(&atqa, 0, sizeof(atqa));
memset(&acf, 0, sizeof(acf));
- ret = iso14443a_transceive_sf(handle, ISO14443A_SF_CMD_REQA, &atqa);
+ if (handle->flags & RFID_OPT_LAYER2_WUP)
+ ret = iso14443a_transceive_sf(handle, ISO14443A_SF_CMD_WUPA, &atqa);
+ else
+ ret = iso14443a_transceive_sf(handle, ISO14443A_SF_CMD_REQA, &atqa);
if (ret < 0) {
h->state = ISO14443A_STATE_REQA_SENT;
DEBUGP("error during transceive_sf: %d\n", ret);
@@ -291,6 +294,8 @@ iso14443a_init(struct rfid_reader_handle *rh)
if (!h)
return NULL;
+ memset(h, 0, sizeof(*h));
+
h->l2 = &rfid_layer2_iso14443a;
h->rh = rh;
h->priv.iso14443a.state = ISO14443A_STATE_NONE;
diff --git a/src/rfid_proto_tcl.c b/src/rfid_proto_tcl.c
index d00e966..af626c6 100644
--- a/src/rfid_proto_tcl.c
+++ b/src/rfid_proto_tcl.c
@@ -122,7 +122,8 @@ tcl_parse_ats(struct rfid_protocol_handle *h,
} else {
/* Section 7.2: fwi for type B is always in ATQB */
/* Value is assigned in tcl_connect() */
- /* This function is never called for Type B, since it has no (R)ATS */
+ /* This function is never called for Type B,
+ * since Type B has no (R)ATS */
}
return 0;
}
@@ -762,6 +763,43 @@ tcl_fini(struct rfid_protocol_handle *ph)
return 0;
}
+int
+tcl_getopt(struct rfid_protocol_handle *h, int optname, void *optval,
+ unsigned int *optlen)
+{
+ u_int8_t *opt_str = optval;
+
+ switch (optname) {
+ case RFID_OPT_P_TCL_ATS:
+ if (h->priv.tcl.ats_len < *optlen)
+ *optlen = h->priv.tcl.ats_len;
+ memcpy(opt_str, h->priv.tcl.ats, *optlen);
+ break;
+ case RFID_OPT_P_TCL_ATS_LEN:
+ if (*optlen < sizeof(u_int8_t))
+ return -E2BIG;
+ *optlen = sizeof(u_int8_t);
+ *opt_str = h->priv.tcl.ats_len & 0xff;
+ break;
+ }
+
+ return 0;
+}
+
+int
+tcl_setopt(struct rfid_protocol_handle *h, int optname, const void *optval,
+ unsigned int optlen)
+{
+ int ret = -EINVAL;
+
+ switch (optname) {
+ default:
+ break;
+ }
+
+ return ret;
+}
+
const struct rfid_protocol rfid_protocol_tcl = {
.id = RFID_PROTOCOL_TCL,
.name = "ISO 14443-4 / T=CL",
@@ -771,5 +809,7 @@ const struct rfid_protocol rfid_protocol_tcl = {
.transceive = &tcl_transceive,
.close = &tcl_deselect,
.fini = &tcl_fini,
+ .getopt = &tcl_getopt,
+ .setopt = &tcl_setopt,
},
};
diff --git a/src/rfid_protocol.c b/src/rfid_protocol.c
index 1a4262a..99fc8b1 100644
--- a/src/rfid_protocol.c
+++ b/src/rfid_protocol.c
@@ -1,4 +1,4 @@
-/* librfid - layer 3 protocol handler
+/* librfid - layer 4 protocol handler
* (C) 2005-2006 by Harald Welte <laforge@gnumonks.org>
*/
@@ -106,6 +106,47 @@ rfid_protocol_close(struct rfid_protocol_handle *ph)
return 0;
}
+int
+rfid_protocol_getopt(struct rfid_protocol_handle *ph, int optname,
+ void *optval, unsigned int *optlen)
+{
+ if (optname >> 16 == 0) {
+ unsigned char *optchar = optval;
+
+ switch (optname) {
+ break;
+ default:
+ return -EINVAL;
+ break;
+ }
+ } else {
+ if (!ph->proto->fn.getopt)
+ return -EINVAL;
+
+ return ph->proto->fn.getopt(ph, optname, optval, optlen);
+ }
+ return 0;
+}
+
+int
+rfid_protocol_setopt(struct rfid_protocol_handle *ph, int optname,
+ const void *optval, unsigned int optlen)
+{
+ if (optname >> 16 == 0) {
+ switch (optname) {
+ default:
+ return -EINVAL;
+ break;
+ }
+ } else {
+ if (!ph->proto->fn.setopt)
+ return -EINVAL;
+
+ return ph->proto->fn.setopt(ph, optname, optval, optlen);
+ }
+ return 0;
+}
+
char *rfid_protocol_name(struct rfid_protocol_handle *ph)
{
return ph->proto->name;
diff --git a/src/rfid_scan.c b/src/rfid_scan.c
index f50bee6..b19887e 100644
--- a/src/rfid_scan.c
+++ b/src/rfid_scan.c
@@ -43,7 +43,7 @@ rfid_layer2_scan1(struct rfid_reader_handle *rh, int l2)
return NULL;
}
-static struct rfid_layer2_handle *
+struct rfid_layer2_handle *
rfid_layer2_scan(struct rfid_reader_handle *rh)
{
struct rfid_layer2_handle *l2h;
@@ -80,7 +80,7 @@ rfid_protocol_scan1(struct rfid_layer2_handle *l2h, int proto)
return NULL;
}
-static struct rfid_protocol_handle *
+struct rfid_protocol_handle *
rfid_protocol_scan(struct rfid_layer2_handle *l2h)
{
struct rfid_protocol_handle *ph;
personal git repositories of Harald Welte. Your mileage may vary