diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/librfid/Makefile.am | 3 | ||||
-rw-r--r-- | include/librfid/rfid.h | 6 | ||||
-rw-r--r-- | include/librfid/rfid_asic_rc632.h | 68 | ||||
-rw-r--r-- | include/librfid/rfid_layer2.h | 2 | ||||
-rw-r--r-- | include/librfid/rfid_layer2_icode1.h | 11 | ||||
-rw-r--r-- | include/librfid/rfid_layer2_iso15693.h | 45 | ||||
-rw-r--r-- | include/librfid/rfid_protocol.h | 3 | ||||
-rw-r--r-- | include/librfid/rfid_protocol_icode.h | 10 | ||||
-rw-r--r-- | include/librfid/rfid_protocol_tagit.h | 10 | ||||
-rw-r--r-- | include/librfid/rfid_reader.h | 5 |
10 files changed, 157 insertions, 6 deletions
diff --git a/include/librfid/Makefile.am b/include/librfid/Makefile.am index 6d5acd3..a5deb20 100644 --- a/include/librfid/Makefile.am +++ b/include/librfid/Makefile.am @@ -3,9 +3,12 @@ include $(top_srcdir)/Makefile.flags.am pkginclude_HEADERS = rfid.h rfid_scan.h rfid_asic.h rfid_asic_rc632.h \ rfid_layer2.h rfid_layer2_iso14443a.h \ rfid_layer2_iso14443b.h rfid_layer2_iso15693.h \ + rfid_layer2_icode1.h \ rfid_protocol.h rfid_protocol_tcl.h \ rfid_protocol_mifare_ul.h \ rfid_protocol_mifare_classic.h \ + rfid_protocol_tagit.h \ + rfid_protocol_icode.h \ rfid_reader.h \ rfid_system.h \ rfid_access_mifare_classic.h \ diff --git a/include/librfid/rfid.h b/include/librfid/rfid.h index 64d6c06..bf21319 100644 --- a/include/librfid/rfid.h +++ b/include/librfid/rfid.h @@ -5,9 +5,13 @@ #include <sys/types.h> #include <stdio.h> +#define ECOLLISION 1000 + #ifdef __MINGW32__ #define ENOTSUP 100 +/* 110 under linux */ #define ETIMEDOUT 101 + typedef unsigned char u_int8_t; typedef unsigned short u_int16_t; typedef unsigned long u_int32_t; @@ -62,6 +66,8 @@ enum rfid_frametype { RFID_14443A_FRAME_REGULAR, RFID_14443B_FRAME_REGULAR, RFID_MIFARE_FRAME, + RFID_15693_FRAME, + RFID_15693_FRAME_ICODE1, }; #endif /* _RFID_H */ diff --git a/include/librfid/rfid_asic_rc632.h b/include/librfid/rfid_asic_rc632.h index ccc4f20..0602cd9 100644 --- a/include/librfid/rfid_asic_rc632.h +++ b/include/librfid/rfid_asic_rc632.h @@ -28,6 +28,7 @@ struct rfid_asic_handle; struct iso14443a_atqa; struct iso14443a_anticol_cmd; +struct iso15693_anticol_cmd; struct rfid_asic_rc632 { struct { @@ -59,6 +60,10 @@ struct rfid_asic_rc632 { } iso14443b; struct { int (*init)(struct rfid_asic_handle *h); + int (*transceive_ac)(struct rfid_asic_handle *h, + struct iso15693_anticol_cmd *acf, + unsigned char *uuid, + char *bit_of_col); } iso15693; struct { int (*setkey)(struct rfid_asic_handle *h, @@ -93,4 +98,67 @@ struct rfid_asic_rc632_impl { extern struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th); extern void rc632_close(struct rfid_asic_handle *h); + +/* register decoding inlines... */ +#define DEBUGP_ERROR_FLAG(value) do {DEBUGP("error_flag: 0x%0.2x",value); \ + if (value & RC632_ERR_FLAG_CRC_ERR ) \ + DEBUGPC(", CRC"); \ + if (value & RC632_ERR_FLAG_COL_ERR ) \ + DEBUGPC(", COL"); \ + if (value & RC632_ERR_FLAG_FRAMING_ERR ) \ + DEBUGPC(", FRAMING"); \ + if (value & RC632_ERR_FLAG_PARITY_ERR) \ + DEBUGPC(", PARITY"); \ + if (value & RC632_ERR_FLAG_KEY_ERR ) \ + DEBUGPC(", KEY"); \ + if (value & RC632_ERR_FLAG_ACCESS_ERR ) \ + DEBUGPC(", ACCESS"); \ + DEBUGPC("\n");} while (0); + +#define DEBUGP_STATUS_FLAG(foo) do {\ + DEBUGP("status_flag: 0x%0.2x",foo); \ + if (foo & RC632_STAT_ERR ) \ + DEBUGPC(", ERR"); \ + if (foo & RC632_STAT_HIALERT ) \ + DEBUGPC(", Hi"); \ + if (foo & RC632_STAT_IRQ ) \ + DEBUGPC(", IRQ"); \ + if (foo & RC632_STAT_LOALERT ) \ + DEBUGPC(", Lo"); \ + if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_AWAITINGRX ) \ + DEBUGPC(", mAwaitingRX"); \ + if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_GOTORX ) \ + DEBUGPC(", mGotoRX"); \ + if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_IDLE ) \ + DEBUGPC(", mIdle"); \ + if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_PREPARERX ) \ + DEBUGPC(", mPrepareRX"); \ + if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_RECV ) \ + DEBUGPC(", mRX"); \ + if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXDATA ) \ + DEBUGPC(", mTXData"); \ + if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXEOF ) \ + DEBUGPC(", mTXeof"); \ + if ((foo & RC632_STAT_MODEM_MASK) == RC632_STAT_MODEM_TXSOF ) \ + DEBUGPC(", mTXsof"); \ + DEBUGPC("\n"); } while (0); + +#define DEBUGP_INTERRUPT_FLAG(foo) do {\ + DEBUGP("interrupt_flag: 0x%0.2x",foo); \ + if (foo & RC632_INT_HIALERT) \ + DEBUGPC(", HiA"); \ + if (foo & RC632_INT_LOALERT) \ + DEBUGPC(", LoA"); \ + if (foo & RC632_INT_IDLE) \ + DEBUGPC(", IDLE"); \ + if (foo & RC632_INT_RX) \ + DEBUGPC(", RX"); \ + if (foo & RC632_INT_TX) \ + DEBUGPC(", TX"); \ + if (foo & RC632_INT_TIMER) \ + DEBUGPC(", TIMER"); \ + if (foo & RC632_INT_SET) \ + DEBUGPC(", SET"); \ + DEBUGPC("\n"); } while (0); + #endif diff --git a/include/librfid/rfid_layer2.h b/include/librfid/rfid_layer2.h index 45ae953..023b171 100644 --- a/include/librfid/rfid_layer2.h +++ b/include/librfid/rfid_layer2.h @@ -11,6 +11,7 @@ enum rfid_layer2_id { RFID_LAYER2_ISO14443A, RFID_LAYER2_ISO14443B, RFID_LAYER2_ISO15693, + RFID_LAYER2_ICODE1, }; /* 0...0xffff = global options, 0x10000...0x1ffff = private options */ @@ -41,6 +42,7 @@ char *rfid_layer2_name(struct rfid_layer2_handle *l2h); #include <librfid/rfid_layer2_iso14443a.h> #include <librfid/rfid_layer2_iso14443b.h> #include <librfid/rfid_layer2_iso15693.h> +#include <librfid/rfid_layer2_icode1.h> struct rfid_layer2 { unsigned int id; diff --git a/include/librfid/rfid_layer2_icode1.h b/include/librfid/rfid_layer2_icode1.h new file mode 100644 index 0000000..e8ebddb --- /dev/null +++ b/include/librfid/rfid_layer2_icode1.h @@ -0,0 +1,11 @@ +#ifndef _RFID_L2_ICODE1_H +#define _RFID_L2_ICODE1_H + +#ifdef __LIBRFID__ + +#include <librfid/rfid_layer2.h> +extern const struct rfid_layer2 rfid_layer2_icode1; + + +#endif /* __LIBRFID__ */ +#endif /* _ISO15693_H */ diff --git a/include/librfid/rfid_layer2_iso15693.h b/include/librfid/rfid_layer2_iso15693.h index d09daa7..5719a39 100644 --- a/include/librfid/rfid_layer2_iso15693.h +++ b/include/librfid/rfid_layer2_iso15693.h @@ -4,11 +4,28 @@ #include <sys/types.h> /* -07h = TagIt -04h = I.CODE -05h = Infineon -02h = ST -*/ + * ISO15693 tag manufacturer codes as found at + * http://rfid-handbook.de/forum/read.php?5,437,580#msg-580 + * + * 01h = Motorola + * 02h = ST Microelectronics + * 03h = Hitachi + * 04h = Philips/NXP I.CODE + * 05h = Siemens/Infineon + * 06h = Cylinc + * 07h = Texas Instruments TagIt + * 08h = Fujitsu Limited + * 09h = Mashushita Electric Industrial + * 0Ah = NEC + * 0Bh = Oki Electric + * 0Ch = Toshiba + * 0Dh = Mishubishi Electric + * 0Eh = Samsung Electronics + * 0Fh = Hyundai Electronics + * 10h = LG Semiconductors + * 16h = EMarin Microelectronic + * + */ /* protocol definitions */ @@ -51,6 +68,7 @@ struct iso15693_handle { enum rfid_15693_state { ISO15693_STATE_ERROR, ISO15693_STATE_NONE, + ISO15693_STATE_ANTICOL_RUNNING, }; enum rfid_15693_opt { @@ -85,7 +103,7 @@ enum rfid_15693_opt_vicc_speed { #define ISO15693_UID_LEN 8 #define ISO15693_CRC_LEN 2 -/* ISO 15693-3, Ch. 7.2 Table 3*/ +/* ISO 15693-3, Ch. 7.2 Table 3 */ enum iso15693_request_flags { RFID_15693_F_SUBC_TWO = 0x01, RFID_15693_F_RATE_HIGH = 0x02, @@ -114,6 +132,12 @@ struct iso15693_request { u_int8_t data[0]; } __attribute__ ((packed)); +/* ISO 15963-3, Ch. 7.2 Figure 5 */ +struct iso15693_response { + u_int8_t flags; + u_int8_t data[0]; +} __attribute__ ((packed)); + /* ISO 15693, Ch. 7.3 Table 6 */ enum iso15693_response_flags { RFID_15693_RF_ERROR = 0x01, @@ -130,6 +154,7 @@ enum iso15693_response_errors { RFID_15693_ERR_BLOCK_LOCKED_CH = 0x12, RFID_15693_ERR_BLOCK_NOTPROG = 0x13, RFID_15693_ERR_BLOCK_NOTLOCK = 0x14, + /* 0xA0 .. 0xDF Custom Command error Codes */ }; /* ISO 15693, Ch. 7.4 */ @@ -169,6 +194,14 @@ enum iso15693_commands { /* Proprietary 0xe0 .. 0xff */ }; +struct iso15693_anticol_cmd { + /* iso15693-3 table5 flags*/ + unsigned char flags; // SLOTS16 | SLOT1, AFI_PRESENT, OPTION_FLAG + unsigned char afi; // AFI 0 for any + unsigned char mask_len; + unsigned char mask_bits[ISO15693_UID_LEN]; + unsigned char current_slot; +} __attribute__((packed)); #include <librfid/rfid_layer2.h> extern const struct rfid_layer2 rfid_layer2_iso15693; diff --git a/include/librfid/rfid_protocol.h b/include/librfid/rfid_protocol.h index ea4dd34..b4a145d 100644 --- a/include/librfid/rfid_protocol.h +++ b/include/librfid/rfid_protocol.h @@ -40,6 +40,8 @@ enum rfid_protocol_id { RFID_PROTOCOL_TCL, RFID_PROTOCOL_MIFARE_UL, RFID_PROTOCOL_MIFARE_CLASSIC, + RFID_PROTOCOL_ICODE_SLI, + RFID_PROTOCOL_TAGIT, NUM_RFID_PROTOCOLS }; @@ -86,6 +88,7 @@ struct rfid_protocol { #include <librfid/rfid_protocol_tcl.h> #include <librfid/rfid_protocol_mifare_ul.h> #include <librfid/rfid_protocol_mifare_classic.h> +#include <librfid/rfid_protocol_tagit.h> struct rfid_protocol_handle { struct rfid_layer2_handle *l2h; diff --git a/include/librfid/rfid_protocol_icode.h b/include/librfid/rfid_protocol_icode.h new file mode 100644 index 0000000..9019243 --- /dev/null +++ b/include/librfid/rfid_protocol_icode.h @@ -0,0 +1,10 @@ +#ifndef _RFID_PROTOCOL_TAGIT_H +#define _RFID_PROTOCOL_TAGIT_H + +#ifdef __LIBRFID__ + +extern const struct rfid_protocol rfid_protocol_icode; + +#endif /* __LIBRFID__ */ + +#endif diff --git a/include/librfid/rfid_protocol_tagit.h b/include/librfid/rfid_protocol_tagit.h new file mode 100644 index 0000000..46a73bc --- /dev/null +++ b/include/librfid/rfid_protocol_tagit.h @@ -0,0 +1,10 @@ +#ifndef _RFID_PROTOCOL_TAGIT_H +#define _RFID_PROTOCOL_TAGIT_H + +#ifdef __LIBRFID__ + +extern const struct rfid_protocol rfid_protocol_tagit; + +#endif /* __LIBRFID__ */ + +#endif diff --git a/include/librfid/rfid_reader.h b/include/librfid/rfid_reader.h index 64ad862..8dc7860 100644 --- a/include/librfid/rfid_reader.h +++ b/include/librfid/rfid_reader.h @@ -3,6 +3,7 @@ #include <librfid/rfid_asic.h> #include <librfid/rfid_layer2_iso14443a.h> +#include <librfid/rfid_layer2_iso15693.h> struct rfid_reader_handle; @@ -56,6 +57,10 @@ struct rfid_reader { } iso14443b; struct rfid_15693_reader { int (*init)(struct rfid_reader_handle *rh); + int (*transceive_ac)(struct rfid_reader_handle *h, + struct iso15693_anticol_cmd *acf, + unsigned char *uuid, + char *bit_of_col); } iso15693; struct rfid_mifare_classic_reader { int (*setkey)(struct rfid_reader_handle *h, const unsigned char *key); |