/* ISO 14443-4 (T=CL) implementation, PCD side.
*
- * (C) 2005 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2005-2006 by Harald Welte <laforge@gnumonks.org>
*
*/
} 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;
}
h->priv.tcl.historical_len = (ats+len) - cur;
h->priv.tcl.historical_bytes = cur;
+
+ DEBUGP("ATS parsed: %s\n", rfid_hexdump(ats, size));
return 0;
}
{
int ret;
unsigned char ppss[3];
- unsigned char pps_response[1];
+ /* FIXME: this stinks like hell. IF we reduce pps_response size to one,
+ we'll get stack corruption! */
+ unsigned char pps_response[10];
unsigned int rx_len = 1;
unsigned char Dr, Ds, DrI, DsI;
unsigned int speed;
prlg[*prlg_len] = th->cid & 0x0f;
}
- /* nad only for I-block (0xc0 == 00) */
- if ((th->flags & TCL_HANDLE_F_NAD_USED) &&
- ((pcb & 0xc0) == 0x00)) {
+ /* nad only for I-block */
+ if ((th->flags & TCL_HANDLE_F_NAD_USED) && is_i_block(pcb)) {
/* ISO 14443-4:2000(E) Section 7.1.1.3 */
/* FIXME: in case of chaining only for first frame */
*prlg |= TCL_PCB_NAD_FOLLOWING;
struct rfid_protocol_handle *th;
unsigned int mru = l2h->rh->ah->mru;
- th = malloc(sizeof(struct rfid_protocol_handle) + mru);
+ th = malloc_protocol_handle(sizeof(struct rfid_protocol_handle));
if (!th)
return NULL;
/* FIXME: mru should be attribute of layer2 (in case it adds/removes
* some overhead */
- memset(th, 0, sizeof(struct rfid_protocol_handle) + mru);
+ memset(th, 0, sizeof(struct rfid_protocol_handle));
/* maximum received ats length equals mru of asic/reader */
th->priv.tcl.state = TCL_STATE_INITIAL;
static int
tcl_fini(struct rfid_protocol_handle *ph)
{
- free(ph);
+ free_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;
+ default:
+ return -EINVAL;
+ }
+
return 0;
}
-struct rfid_protocol rfid_protocol_tcl = {
+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",
.fn = {
.transceive = &tcl_transceive,
.close = &tcl_deselect,
.fini = &tcl_fini,
+ .getopt = &tcl_getopt,
+ .setopt = &tcl_setopt,
},
};