diff options
author | laforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede> | 2005-10-22 18:12:48 +0000 |
---|---|---|
committer | laforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede> | 2005-10-22 18:12:48 +0000 |
commit | 852829c4ab597ce137bac4bb9b612fd57b1dd282 (patch) | |
tree | f8f440953bfb901ada92241e75b8caf35572b8f3 /rfid_proto_mifare_ul.c | |
parent | 09a3dd030ddac3875b865be72e91d8326367dd4c (diff) |
add convenience functions to set lock bits
git-svn-id: https://svn.gnumonks.org/trunk/librfid@1553 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'rfid_proto_mifare_ul.c')
-rw-r--r-- | rfid_proto_mifare_ul.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/rfid_proto_mifare_ul.c b/rfid_proto_mifare_ul.c index 1d80702..e420fcf 100644 --- a/rfid_proto_mifare_ul.c +++ b/rfid_proto_mifare_ul.c @@ -136,3 +136,31 @@ struct rfid_protocol rfid_protocol_mful = { .fini = &mful_fini, }, }; + +/* Functions below are not (yet? covered in the generic librfid api */ + + +/* lock a certain page */ +int rfid_mful_lock_page(struct rfid_protocol_handle *ph, unsigned int page) +{ + unsigned char buf[4] = { 0x00, 0x00, 0x00, 0x00 }; + + if (ph->proto != &rfid_protocol_mful) + return -EINVAL; + + if (page < 3 || page > 15) + return -EINVAL; + + if (page > 8) + buf[2] = (1 << page); + else + buf[3] = (1 << (page - 8)); + + return mful_write(ph, MIFARE_UL_PAGE_LOCK, buf, sizeof(buf)); +} + +/* convenience wrapper to lock the otp page */ +int rfid_mful_lock_otp(struct rfid_protocol_handle *ph) +{ + return rfid_mful_lock_page(ph, MIFARE_UL_PAGE_OTP); +} |