summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/librfid/Makefile.am1
-rw-r--r--include/librfid/rfid.h2
-rw-r--r--include/librfid/rfid_layer2_iso14443a.h2
-rw-r--r--include/librfid/rfid_layer2_iso14443b.h6
-rw-r--r--include/librfid/rfid_layer2_iso15693.h2
-rw-r--r--include/librfid/rfid_protocol_mifare_classic.h4
-rw-r--r--include/librfid/rfid_protocol_mifare_ul.h2
-rw-r--r--include/librfid/rfid_protocol_tcl.h5
-rw-r--r--include/librfid/rfid_reader_cm5121.h5
-rw-r--r--include/librfid/rfid_reader_openpcd.h2
-rw-r--r--include/librfid/rfid_system.h53
11 files changed, 72 insertions, 12 deletions
diff --git a/include/librfid/Makefile.am b/include/librfid/Makefile.am
index 4b1337d..1edb60b 100644
--- a/include/librfid/Makefile.am
+++ b/include/librfid/Makefile.am
@@ -6,6 +6,7 @@ pkginclude_HEADERS = rfid.h rfid_scan.h rfid_asic.h rfid_asic_rc632.h \
rfid_protocol_mifare_ul.h \
rfid_protocol_mifare_classic.h \
rfid_reader.h \
+ rfid_system.h \
rfid_reader_cm5121.h \
rfid_reader_openpcd.h
diff --git a/include/librfid/rfid.h b/include/librfid/rfid.h
index c3f8fc1..f0ecc16 100644
--- a/include/librfid/rfid.h
+++ b/include/librfid/rfid.h
@@ -5,6 +5,8 @@
#ifdef __LIBRFID__
+#include <librfid/rfid_system.h>
+
enum rfid_frametype {
RFID_14443A_FRAME_REGULAR,
RFID_14443B_FRAME_REGULAR,
diff --git a/include/librfid/rfid_layer2_iso14443a.h b/include/librfid/rfid_layer2_iso14443a.h
index 87b6be0..283e6b6 100644
--- a/include/librfid/rfid_layer2_iso14443a.h
+++ b/include/librfid/rfid_layer2_iso14443a.h
@@ -84,7 +84,7 @@ enum iso14443a_state {
#include <librfid/rfid_layer2.h>
-struct rfid_layer2 rfid_layer2_iso14443a;
+extern const struct rfid_layer2 rfid_layer2_iso14443a;
#endif /* __LIBRFID__ */
diff --git a/include/librfid/rfid_layer2_iso14443b.h b/include/librfid/rfid_layer2_iso14443b.h
index 07c185f..7d2cb29 100644
--- a/include/librfid/rfid_layer2_iso14443b.h
+++ b/include/librfid/rfid_layer2_iso14443b.h
@@ -26,7 +26,7 @@ struct iso14443b_atqb {
adc:2,
fwi:4;
} protocol_info;
-};
+} __attribute__ ((packed));
struct iso14443b_attrib_hdr {
unsigned char one_d;
@@ -51,7 +51,7 @@ struct iso14443b_attrib_hdr {
unsigned char cid:4,
rfu:4;
} param4;
-};
+} __attribute__ ((packed));
struct iso14443b_handle {
unsigned int tcl_capable; /* do we support T=CL */
@@ -89,7 +89,7 @@ enum {
};
#include <librfid/rfid_layer2.h>
-struct rfid_layer2 rfid_layer2_iso14443b;
+extern const struct rfid_layer2 rfid_layer2_iso14443b;
#endif /* __LIBRFID__ */
diff --git a/include/librfid/rfid_layer2_iso15693.h b/include/librfid/rfid_layer2_iso15693.h
index d91b4ec..37d204d 100644
--- a/include/librfid/rfid_layer2_iso15693.h
+++ b/include/librfid/rfid_layer2_iso15693.h
@@ -50,6 +50,6 @@ enum iso15693_state {
};
#include <librfid/rfid_layer2.h>
-extern struct rfid_layer2 rfid_layer2_iso15693;
+extern const struct rfid_layer2 rfid_layer2_iso15693;
#endif /* _ISO15693_H */
diff --git a/include/librfid/rfid_protocol_mifare_classic.h b/include/librfid/rfid_protocol_mifare_classic.h
index e6b2400..06235b8 100644
--- a/include/librfid/rfid_protocol_mifare_classic.h
+++ b/include/librfid/rfid_protocol_mifare_classic.h
@@ -1,5 +1,7 @@
#ifndef _MIFARE_CLASSIC_H
+#include <librfid/rfid_protocol.h>
+
#define MIFARE_CL_KEYA_DEFAULT "\xa0\xa1\xa2\xa3\xa4\xa5"
#define MIFARE_CL_KEYB_DEFAULT "\xb0\xb1\xb2\xb3\xb4\xb5"
@@ -13,7 +15,7 @@
#ifdef __LIBRFID__
-extern struct rfid_protocol rfid_protocol_mfcl;
+extern const struct rfid_protocol rfid_protocol_mfcl;
#define MIFARE_CL_CMD_WRITE16 0xA0
diff --git a/include/librfid/rfid_protocol_mifare_ul.h b/include/librfid/rfid_protocol_mifare_ul.h
index cc93b6b..593894e 100644
--- a/include/librfid/rfid_protocol_mifare_ul.h
+++ b/include/librfid/rfid_protocol_mifare_ul.h
@@ -17,7 +17,7 @@ int rfid_mful_lock_otp(struct rfid_protocol_handle *ph);
#define MIFARE_UL_PAGE_LOCK 2
#define MIFARE_UL_PAGE_OTP 3
-extern struct rfid_protocol rfid_protocol_mful;
+extern const struct rfid_protocol rfid_protocol_mful;
#endif /* __LIBRFID__ */
diff --git a/include/librfid/rfid_protocol_tcl.h b/include/librfid/rfid_protocol_tcl.h
index 180c008..2ee1c27 100644
--- a/include/librfid/rfid_protocol_tcl.h
+++ b/include/librfid/rfid_protocol_tcl.h
@@ -36,7 +36,8 @@ struct tcl_handle {
unsigned int toggle; /* send toggle with next frame */
unsigned int ats_len;
- unsigned char ats[0];
+ unsigned char ats[256]; /* ATS cannot be bigger than FSD-2 bytes,
+ according to ISO 14443-4 5.2.2 */
};
enum tcl_handle_flags {
@@ -63,7 +64,7 @@ enum tcl_pcd_state {
TCL_STATE_DESELECTED, /* card deselected or HLTA'd */
};
-struct rfid_protocol rfid_protocol_tcl;
+extern const struct rfid_protocol rfid_protocol_tcl;
#endif /* __LIBRFID__ */
diff --git a/include/librfid/rfid_reader_cm5121.h b/include/librfid/rfid_reader_cm5121.h
index 8d9a312..5a1b7c3 100644
--- a/include/librfid/rfid_reader_cm5121.h
+++ b/include/librfid/rfid_reader_cm5121.h
@@ -1,6 +1,8 @@
#ifndef _RFID_READER_CM5121_H
#define _RFID_READER_CM5121_H
+#include <librfid/rfid_reader.h>
+
#define CM5121_CW_CONDUCTANCE 0x3f
#define CM5121_MOD_CONDUCTANCE 0x3f
#define CM5121_14443A_BITPHASE 0xa9
@@ -9,13 +11,12 @@
#define CM5121_14443B_BITPHASE 0xad
#define CM5121_14443B_THRESHOLD 0xff
-
extern int
PC_to_RDR_Escape(void *handle,
const unsigned char *tx_buf, unsigned int tx_len,
unsigned char *rx_buf, unsigned int *rx_len);
-extern struct rfid_reader rfid_reader_cm5121;
+extern const struct rfid_reader rfid_reader_cm5121;
// extern struct rfid_asic_transport cm5121_ccid;
#endif
diff --git a/include/librfid/rfid_reader_openpcd.h b/include/librfid/rfid_reader_openpcd.h
index e345132..49ee31c 100644
--- a/include/librfid/rfid_reader_openpcd.h
+++ b/include/librfid/rfid_reader_openpcd.h
@@ -92,6 +92,6 @@ enum openpcd_cmd_class {
#define OPENPCD_IN_EP 0x82
#define OPENPCD_IRQ_EP 0x83
-extern struct rfid_reader rfid_reader_openpcd;
+extern const struct rfid_reader rfid_reader_openpcd;
#endif
diff --git a/include/librfid/rfid_system.h b/include/librfid/rfid_system.h
new file mode 100644
index 0000000..56441bb
--- /dev/null
+++ b/include/librfid/rfid_system.h
@@ -0,0 +1,53 @@
+/* system / environment specific defines */
+
+//#define LIBRFID_FIRMWARE
+
+#ifdef __LIBRFID__
+
+#ifndef LIBRFID_FIRMWARE
+/* If we're not doing a firmware compile, then we just use the regular
+ * malloc()/free() functions as expected */
+
+#define malloc_asic_handle(x) malloc(x)
+#define free_asic_handle(x) free(x)
+
+#define malloc_layer2_handle(x) malloc(x)
+#define free_layer2_handle(x) free(x)
+
+#define malloc_protocol_handle(x) malloc(x)
+#define free_protocol_handle(x) free(x)
+
+#define malloc_rat_handle(x) malloc(x)
+#define free_rat_handle(x) free(x)
+
+#define malloc_reader_handle(x) malloc(x)
+#define free_reader_handle(x) free(x)
+
+#else
+/* If we're actually doing a firmware compile, then we use pre-allocated
+ * handles in order to avoid dynamic memory allocation. */
+
+#define EMPTY_STATEMENT do {} while(0)
+extern struct rfid_asic_handle rfid_ah;
+#define malloc_asic_handle(x) &rfid_ah
+#define free_asic_handle(x) EMPTY_STATEMENT
+
+extern struct rfid_layer2_handle rfid_l2h;
+#define malloc_layer2_handle(x) &rfid_l2h
+#define free_layer2_handle(x) EMPTY_STATEMENT
+
+extern struct rfid_protocol_handle rfid_ph;
+#define malloc_protocol_handle(x) &rfid_ph
+#define free_protocol_handle(x) EMPTY_STATEMENT
+
+extern struct rfid_asic_transport_handle rfid_ath;
+#define malloc_rat_handle(x) &rfid_ath
+#define free_rat_handle(x) EMPTY_STATEMENT
+
+extern struct rfid_reader_handle rfid_rh;
+#define malloc_reader_handle(x) &rfid_rh
+#define free_reader_handle(x) EMPTY_STATEMENT
+
+#endif /* LIBRFID_FIRMWARE */
+
+#endif /* __LIBRFID__ */
personal git repositories of Harald Welte. Your mileage may vary