summaryrefslogtreecommitdiff
path: root/rfid_proto_tcl.c
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2005-09-11 19:59:58 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2005-09-11 19:59:58 +0000
commit098ef26c87b27ddac5eb41f1317fe552fe16e3a7 (patch)
tree20af129bed33a3c942ea7d38eda0cc432e09ba67 /rfid_proto_tcl.c
parenta740a7a578cb8a3f53b1b12b2e0833c8dbf4dcff (diff)
use 64bit timeout values throughout the code, since some timeouts exceeds 4.8 billion microseconds (seconds).
git-svn-id: https://svn.gnumonks.org/trunk/librfid@1426 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'rfid_proto_tcl.c')
-rw-r--r--rfid_proto_tcl.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/rfid_proto_tcl.c b/rfid_proto_tcl.c
index b8586f5..e60af55 100644
--- a/rfid_proto_tcl.c
+++ b/rfid_proto_tcl.c
@@ -41,6 +41,7 @@ static unsigned int sfgi_to_sfgt(struct rfid_protocol_handle *h,
unsigned char sfgi)
{
unsigned int multiplier;
+ unsigned int tmp;
if (sfgi > 14)
sfgi = 14;
@@ -49,14 +50,15 @@ static unsigned int sfgi_to_sfgt(struct rfid_protocol_handle *h,
/* ISO 14443-4:2000(E) Section 5.2.5:
* (256 * 16 / h->l2h->rh->ah->fc) * (2 ^ sfgi) */
+ tmp = (unsigned int) 1000000 * 256 * 16;
- return (1000000 * 256*16 / h->l2h->rh->ah->fc) * multiplier;
+ return (tmp / h->l2h->rh->ah->fc) * multiplier;
}
static unsigned int fwi_to_fwt(struct rfid_protocol_handle *h,
unsigned char fwi)
{
- unsigned int multiplier;
+ unsigned int multiplier, tmp;
if (fwi > 14)
fwi = 14;
@@ -66,10 +68,13 @@ static unsigned int fwi_to_fwt(struct rfid_protocol_handle *h,
/* ISO 14443-4:2000(E) Section 7.2.:
* (256*16 / h->l2h->rh->ah->fc) * (2 ^ fwi) */
- return (1000000 * 256*16 / h->l2h->rh->ah->fc) * multiplier;
+ tmp = (unsigned int) 1000000 * 256 * 16;
+
+ return (tmp / h->l2h->rh->ah->fc) * multiplier;
}
-#define activation_fwt(x) (65536 / x->l2h->rh->ah->fc)
+/* 4.9seconds as microseconds (4.9 billion seconds) exceeds 2^32 */
+#define activation_fwt(x) (((u_int64_t)1000000 * 65536 / x->l2h->rh->ah->fc))
#define deactivation_fwt(x) activation_fwt(x)
static int
personal git repositories of Harald Welte. Your mileage may vary