AM_CONDITIONAL(ENABLE_WIN32, test "$BUILDENV" == "WIN32")
AM_CONDITIONAL(DISABLE_WIN32, test "$BUILDENV" != "WIN32")
+AC_C_BIGENDIAN(AC_DEFINE(RFID_BIG_ENDIAN_BITFIELD, 1, [Big-endian bitfield]),,)
+
AC_ARG_ENABLE(ccid,
[ --enable-ccid Include internal CCID driver for CM5121],
[MY_CCID=1], [MY_CCID=0])
};
struct mfcl_access_exp_block {
+#ifndef RFID_BIG_ENDIAN_BITFIELD
u_int8_t read:2,
write:2,
inc:2,
dec:2;
-};
+#else
+ u_int8_t dec:2,
+ inc:2,
+ write:2,
+ read:2;
+#endif
+} __attribute__ ((packed));
struct mfcl_access_exp_acc {
- u_int16_t key_a_rd:2,
+#ifndef RFID_BIG_ENDIAN_BITFIELD
+ u_int8_t key_a_rd:2,
key_a_wr:2,
acc_rd:2,
- acc_wr:2,
- key_b_rd:2,
- key_b_wr:2;
-};
+ acc_wr:2;
+ u_int8_t key_b_rd:2,
+ key_b_wr:2,
+ reserved:4;
+#else
+ u_int8_t acc_wr:2,
+ acc_rd:2,
+ key_a_wr:2,
+ key_a_rd:2;
+ u_int8_t reserved:4,
+ key_b_wr:2,
+ key_b_rd:2;
+#endif
+} __attribute__ ((packed));
struct mfcl_access_exp_sect {
};
struct iso14443a_atqa {
+#ifndef RFID_BIG_ENDIAN_BITFIELD
u_int8_t bf_anticol:5,
rfu1:1,
uid_size:2;
u_int8_t proprietary:4,
rfu2:4;
+#else
+ u_int8_t uid_size:2,
+ rfu1:1,
+ bf_anticol:5;
+ u_int8_t rfu2:4,
+ proprietary:4;
+#endif
} __attribute__((packed));
#define ISO14443A_HLTA 0x5000
unsigned char app_data[4];
struct {
unsigned char bit_rate_capability;
+#ifndef RFID_BIG_ENDIAN_BITFIELD
unsigned char protocol_type:4,
max_frame_size:4;
unsigned char fo:2,
adc:2,
fwi:4;
+#else
+ unsigned char max_frame_size:4,
+ protocol_type:4;
+ unsigned char fwi:4,
+ adc:2,
+ fo:2;
+#endif
} __attribute__ ((packed)) protocol_info;
} __attribute__ ((packed));
unsigned char one_d;
unsigned char identifier[4];
struct {
+#ifndef RFID_BIG_ENDIAN_BITFIELD
unsigned char rfu:2,
sof:1,
eof:1,
min_tr1:2,
min_tr0:2;
+#else
+ unsigned char min_tr0:2,
+ min_tr1:1,
+ eof:1,
+ sof:1,
+ rfu:2;
+#endif
} __attribute__ ((packed)) param1;
struct {
+#ifndef RFID_BIG_ENDIAN_BITFIELD
unsigned char fsdi:4,
spd_out:2,
spd_in:2;
+#else
+ unsigned char spd_in:2,
+ spd_out:2,
+ fsdi:4;
+#endif
} __attribute__ ((packed)) param2;
struct {
+#ifndef RFID_BIG_ENDIAN_BITFIELD
unsigned char protocol_type:4,
rfu:4;
+#else
+ unsigned char rfu:4,
+ protocol_type:4;
+#endif
} __attribute__ ((packed)) param3;
struct {
+#ifndef RFID_BIG_ENDIAN_BITFIELD
unsigned char cid:4,
rfu:4;
+#else
+ unsigned char rfu:4,
+ cid:4;
+#endif
} __attribute__ ((packed)) param4;
} __attribute__ ((packed));
mfcl_write(struct rfid_protocol_handle *ph, unsigned int page,
unsigned char *tx_data, unsigned int tx_len)
{
- unsigned int i;
unsigned char tx[18];
unsigned char rx[1];
unsigned int rx_len = sizeof(rx);
unsigned int *optlen)
{
int ret = -EINVAL;
- u_int16_t atqa;
+ u_int8_t atqa[2];
unsigned int atqa_size = sizeof(atqa);
unsigned int *size = optval;
*optlen = sizeof(*size);
ret = 0;
rfid_layer2_getopt(ph->l2h, RFID_OPT_14443A_ATQA,
- (void *) &atqa, &atqa_size);
- if (atqa == 0x0004)
+ atqa, &atqa_size);
+ if (atqa[0] == 0x04 && atqa[1] == 0x00)
*size = 1024;
- else if (atqa == 0x0002)
+ else if (atqa[0] == 0x02 && atqa[1] == 0x00)
*size = 4096;
else
ret = -EIO;
return ret;
}
-static int
-mful_transceive(struct rfid_protocol_handle *ph,
- const unsigned char *tx_data, unsigned int tx_len,
- unsigned char *rx_data, unsigned int *rx_len,
- unsigned int timeout, unsigned int flags)
-{
- return -EINVAL;
-}
-
static int
mful_getopt(struct rfid_protocol_handle *ph, int optname, void *optval,
unsigned int *optlen)
{
int ret = -EINVAL;
- u_int16_t atqa;
unsigned int *size = optval;
switch (optname) {
mful_init(struct rfid_layer2_handle *l2h)
{
struct rfid_protocol_handle *ph;
- u_int16_t atqa;
+ u_int8_t atqa[2];
unsigned int atqa_len = sizeof(atqa);
if (l2h->l2->id != RFID_LAYER2_ISO14443A)
/* According to "Type Identification Procedure Rev. 1.3" */
rfid_layer2_getopt(l2h, RFID_OPT_14443A_ATQA,
- &atqa, &atqa_len);
- if (atqa != 0x0044)
+ atqa, &atqa_len);
+ if (atqa[0] != 0x44 || atqa[1] != 0x00)
return NULL;
/* according to "Functional Specification Rev. 3.0 */