summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2008-01-22 15:45:50 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2008-01-22 15:45:50 +0000
commit237c7f9e9d0aad3a9830498a9bdb5fe5dd94df9e (patch)
tree1227af9867c9667020c05df81c93c87a89369a6f /include
parentbb01e0f8534a785beeb64f01960b29b69b0227c5 (diff)
Fix bitfields for big endian platforms (Jeremy Lainé)
git-svn-id: https://svn.gnumonks.org/trunk/librfid@2038 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'include')
-rw-r--r--include/librfid/rfid_access_mifare_classic.h30
-rw-r--r--include/librfid/rfid_layer2_iso14443a.h8
-rw-r--r--include/librfid/rfid_layer2_iso14443b.h32
3 files changed, 64 insertions, 6 deletions
diff --git a/include/librfid/rfid_access_mifare_classic.h b/include/librfid/rfid_access_mifare_classic.h
index 3c23724..4c7fbdf 100644
--- a/include/librfid/rfid_access_mifare_classic.h
+++ b/include/librfid/rfid_access_mifare_classic.h
@@ -17,20 +17,38 @@ enum mfcl_access_exp_data {
};
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 {
diff --git a/include/librfid/rfid_layer2_iso14443a.h b/include/librfid/rfid_layer2_iso14443a.h
index 9a795c2..a4af557 100644
--- a/include/librfid/rfid_layer2_iso14443a.h
+++ b/include/librfid/rfid_layer2_iso14443a.h
@@ -30,11 +30,19 @@ enum iso14443a_sf_cmd {
};
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
diff --git a/include/librfid/rfid_layer2_iso14443b.h b/include/librfid/rfid_layer2_iso14443b.h
index 89999c6..2a31997 100644
--- a/include/librfid/rfid_layer2_iso14443b.h
+++ b/include/librfid/rfid_layer2_iso14443b.h
@@ -20,11 +20,19 @@ struct iso14443b_atqb {
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));
@@ -32,24 +40,48 @@ struct iso14443b_attrib_hdr {
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));
personal git repositories of Harald Welte. Your mileage may vary