summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-11-28 10:06:24 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2006-11-28 10:06:24 +0000
commit2da53a43badc7bd578ab5df850648f14807aecd2 (patch)
tree7041dc431c25664d9ba280a02504157407eb774d /include
parentc972071a03825d8fe595d33f9128b4341b0478bd (diff)
- fix mifare write support
- make mifare auth more reliable - add mifare permission / access bit en/decoding - some more 15693 bits - add new 'mifare-tool' program git-svn-id: https://svn.gnumonks.org/trunk/librfid@1928 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'include')
-rw-r--r--include/librfid/Makefile.am1
-rw-r--r--include/librfid/rfid_access_mifare_classic.h46
-rw-r--r--include/librfid/rfid_asic.h10
-rw-r--r--include/librfid/rfid_asic_rc632.h86
-rw-r--r--include/librfid/rfid_layer2_iso15693.h47
-rw-r--r--include/librfid/rfid_protocol.h1
-rw-r--r--include/librfid/rfid_protocol_mifare_classic.h4
7 files changed, 114 insertions, 81 deletions
diff --git a/include/librfid/Makefile.am b/include/librfid/Makefile.am
index 1edb60b..9af455b 100644
--- a/include/librfid/Makefile.am
+++ b/include/librfid/Makefile.am
@@ -7,6 +7,7 @@ pkginclude_HEADERS = rfid.h rfid_scan.h rfid_asic.h rfid_asic_rc632.h \
rfid_protocol_mifare_classic.h \
rfid_reader.h \
rfid_system.h \
+ rfid_access_mifare_classic.h \
rfid_reader_cm5121.h \
rfid_reader_openpcd.h
diff --git a/include/librfid/rfid_access_mifare_classic.h b/include/librfid/rfid_access_mifare_classic.h
new file mode 100644
index 0000000..3c23724
--- /dev/null
+++ b/include/librfid/rfid_access_mifare_classic.h
@@ -0,0 +1,46 @@
+#ifndef _RFID_MIFARE_ACCESS_H
+#define _RFID_MIFARE_ACCESS_H
+
+struct mfcl_access_sect {
+ u_int8_t block[4];
+};
+
+int mfcl_compile_access(u_int8_t *encoded,
+ const struct mfcl_access_sect *ac);
+int mfcl_parse_access(struct mfcl_access_sect *ac, u_int8_t *encoded);
+
+
+enum mfcl_access_exp_data {
+ MFCL_ACCESS_NEVER = 0,
+ MFCL_ACCESS_KEY_A = 1,
+ MFCL_ACCESS_KEY_B = 2,
+};
+
+struct mfcl_access_exp_block {
+ u_int8_t read:2,
+ write:2,
+ inc:2,
+ dec:2;
+};
+
+struct mfcl_access_exp_acc {
+ u_int16_t key_a_rd:2,
+ key_a_wr:2,
+ acc_rd:2,
+ acc_wr:2,
+ key_b_rd:2,
+ key_b_wr:2;
+};
+
+
+struct mfcl_access_exp_sect {
+ struct mfcl_access_exp_block block[3];
+ struct mfcl_access_exp_acc acc;
+};
+
+void mfcl_access_to_exp(struct mfcl_access_exp_sect *exp,
+ const struct mfcl_access_sect *sect);
+
+char *mfcl_access_exp_stringify(const struct mfcl_access_exp_block *exp);
+char *mfcl_access_exp_acc_stringify(const struct mfcl_access_exp_acc *acc);
+#endif
diff --git a/include/librfid/rfid_asic.h b/include/librfid/rfid_asic.h
index 3686a7c..113eb19 100644
--- a/include/librfid/rfid_asic.h
+++ b/include/librfid/rfid_asic.h
@@ -5,6 +5,7 @@ enum rfid_frametype;
#include <librfid/rfid_asic_rc632.h>
+/* a low-level transport, over which the ASIC layer can talk to its ASIC */
struct rfid_asic_transport {
char *name;
union {
@@ -12,12 +13,21 @@ struct rfid_asic_transport {
} priv;
};
+/* An instance handle to 'struct rfid_asic_transport' */
struct rfid_asic_transport_handle {
void *data; /* handle to stuff like even lower layers */
struct rfid_asic_transport *rat;
};
+/* Some implementation-specific data. A reader will specify one of these for
+ * ASIC-specific parameters such as e.g. RC632 mod conductance */
+
+struct rfid_asic_implementation {
+ union {
+ struct rfid_asic_rc632_impl rc632;
+ } priv;
+};
struct rfid_asic_handle {
struct rfid_asic_transport_handle *rath;
diff --git a/include/librfid/rfid_asic_rc632.h b/include/librfid/rfid_asic_rc632.h
index 642c940..4eac82e 100644
--- a/include/librfid/rfid_asic_rc632.h
+++ b/include/librfid/rfid_asic_rc632.h
@@ -78,82 +78,18 @@ struct rfid_asic_rc632_handle {
struct rc632_transport_handle th;
};
-#if 0
-int
-rc632_reg_write(struct rfid_asic_handle *handle,
- u_int8_t reg,
- u_int8_t val);
-
-int
-rc632_reg_read(struct rfid_asic_handle *handle,
- u_int8_t reg,
- u_int8_t *val);
-int
-rc632_fifo_write(struct rfid_asic_handle *handle,
- u_int8_t len,
- const u_int32_t *buf,
- u_int8_t flags);
-
-int
-rc632_fifo_read(struct rfid_asic_handle *handle,
- u_int8_t len,
- u_int8_t *buf);
-
-int
-rc632_set_bits(struct rfid_asic_handle *handle, u_int8_t reg,
- u_int82_t val);
-
-int
-rc632_clear_bits(struct rfid_asic_handle *handle, u_int32_t reg,
- u_int32_t val);
-
-
-int
-rc632_turn_on_rf(struct rfid_asic_handle *handle);
-
-
-int
-rc632_turn_off_rf(struct rfid_asic_handle *handle);
-
-int
-rc632_power_up(struct rfid_asic_handle *handle);
-
-int
-rc632_power_down(struct rfid_asic_handle *handle);
-
-
-int
-rc632_wait_idle(struct rfid_asic_handle *handle, u_int64_t time);
-
-int
-rc632_transmit(struct rfid_asic_handle *handle,
- const u_int32_t *buf,
- u_int32_t len,
- u_int64_t timeout);
-
-int
-rc632_transceive(struct rfid_asic_handle *handle,
- const u_int32_t *tx_buf,
- u_int32_t tx_len,
- u_int32_t *rx_buf,
- u_int32_t *rx_len,
- unsigned int timer,
- unsigned int toggle);
-
-int
-rc632_read_eeprom(struct rfid_asic_handle *handle);
-
-
-int
-rc632_calc_crc16_from(struct rfid_asic_handle *handle);
-
-int
-rc632_register_dump(struct rfid_asic_handle *handle, u_int32_t *buf);
-
-
+struct rfid_asic_rc632_impl_proto {
+ u_int8_t mod_conductance;
+ u_int8_t cw_conductance;
+ u_int8_t bitphase;
+ u_int8_t threshold;
+};
-extern struct rfid_asic rc632;
-#endif
+struct rfid_asic_rc632_impl {
+ u_int32_t mru; /* maximum receive unit (PICC->PCD) */
+ u_int32_t mtu; /* maximum transmit unit (PCD->PICC) */
+ //struct rfid_asic_rc632_impl_proto proto[NUM_RFID_PROTOCOLS];
+};
extern struct rfid_asic_handle * rc632_open(struct rfid_asic_transport_handle *th);
extern void rc632_close(struct rfid_asic_handle *h);
diff --git a/include/librfid/rfid_layer2_iso15693.h b/include/librfid/rfid_layer2_iso15693.h
index f84a6e1..d09daa7 100644
--- a/include/librfid/rfid_layer2_iso15693.h
+++ b/include/librfid/rfid_layer2_iso15693.h
@@ -12,9 +12,10 @@
/* protocol definitions */
-struct iso15693_handle;
+#if 0
+struct rfid_15693_handle;
-struct iso15693_transport {
+struct rfid_layer2_15693t {
unsigned char *name;
struct {
@@ -39,16 +40,46 @@ struct iso15693_transport {
union {
} priv;
};
+#endif
struct iso15693_handle {
unsigned int state;
+ unsigned int ask100:1,
+ out256:1;
};
-enum iso15693_state {
+enum rfid_15693_state {
ISO15693_STATE_ERROR,
ISO15693_STATE_NONE,
};
+enum rfid_15693_opt {
+ RFID_OPT_15693_MOD_DEPTH = 0x00010001,
+ RFID_OPT_15693_VCD_CODING = 0x00010002,
+ RFID_OPT_15693_VICC_SUBC = 0x00010003,
+ RFID_OPT_15693_VICC_SPEED = 0x00010004,
+};
+
+enum rfid_15693_opt_mod_depth {
+ RFID_15693_MOD_10ASK = 0x01,
+ RFID_15693_MOD_100ASK = 0x02,
+};
+
+enum rfid_15693_opt_vcd_coding {
+ RFID_15693_VCD_CODING_1OUT256 = 0x01,
+ RFID_15693_VCD_CODING_1OUT4 = 0x02,
+};
+
+enum rfid_15693_opt_vicc_subc {
+ RFID_15693_VICC_SUBC_SINGLE = 0x01,
+ RFID_15693_VICC_SUBC_DUAL = 0x02,
+};
+
+enum rfid_15693_opt_vicc_speed {
+ RFID_15693_VICC_SPEED_SLOW = 0x01,
+ RFID_15693_VICC_SPEED_FAST = 0x02,
+};
+
#ifdef __LIBRFID__
#define ISO15693_UID_LEN 8
@@ -83,8 +114,6 @@ struct iso15693_request {
u_int8_t data[0];
} __attribute__ ((packed));
-
-
/* ISO 15693, Ch. 7.3 Table 6 */
enum iso15693_response_flags {
RFID_15693_RF_ERROR = 0x01,
@@ -129,8 +158,14 @@ enum iso15693_commands {
ISO15693_CMD_WRITE_DSFID = 0x29,
ISO15693_CMD_LOCK_DSFID = 0x2a,
ISO15693_CMD_GET_SYSINFO = 0x2b,
- ISO15693_CMD_GET_BLOCK_SECURITY = 0x2c
+ ISO15693_CMD_GET_BLOCK_SECURITY = 0x2c,
/* Custom 0xa0 .. 0xdf */
+ ICODE_CMD_INVENTORY_READ = 0xa0,
+ ICODE_CMD_FAST_INVENTORY_READ = 0xa1,
+ ICODE_CMD_EAS_SET = 0xa2,
+ ICODE_CMD_EAS_RESET = 0xa3,
+ ICODE_CMD_EAS_LOCK = 0xa4,
+ ICODE_CMD_EAS_ALARM = 0xa5,
/* Proprietary 0xe0 .. 0xff */
};
diff --git a/include/librfid/rfid_protocol.h b/include/librfid/rfid_protocol.h
index 2c1d0e8..fd649ef 100644
--- a/include/librfid/rfid_protocol.h
+++ b/include/librfid/rfid_protocol.h
@@ -40,6 +40,7 @@ enum rfid_protocol_id {
RFID_PROTOCOL_TCL,
RFID_PROTOCOL_MIFARE_UL,
RFID_PROTOCOL_MIFARE_CLASSIC,
+ NUM_RFID_PROTOCOLS
};
enum rfid_protocol_opt {
diff --git a/include/librfid/rfid_protocol_mifare_classic.h b/include/librfid/rfid_protocol_mifare_classic.h
index f1e1403..99c447d 100644
--- a/include/librfid/rfid_protocol_mifare_classic.h
+++ b/include/librfid/rfid_protocol_mifare_classic.h
@@ -9,7 +9,10 @@
#define MIFARE_CL_KEYA_DEFAULT_INFINEON "\xff\xff\xff\xff\xff\xff"
#define MIFARE_CL_KEYB_DEFAULT_INFINEON MIFARE_CL_KEYA_DEFAULT_INFINEON
+#define MIFARE_CL_KEY_LEN (sizeof(MIFARE_CL_KEYA_DEFAULT)-1)
+
#define MIFARE_CL_PAGE_MAX 0xff
+#define MIFARE_CL_PAGE_SIZE 20
#define RFID_CMD_MIFARE_AUTH1A 0x60
#define RFID_CMD_MIFARE_AUTH1B 0x61
@@ -20,6 +23,7 @@ extern const struct rfid_protocol rfid_protocol_mfcl;
#define MIFARE_CL_CMD_WRITE16 0xA0
+#define MIFARE_CL_CMD_WRITE4 0xA2
#define MIFARE_CL_CMD_READ 0x30
#define MIFARE_CL_RESP_ACK 0x0a
personal git repositories of Harald Welte. Your mileage may vary