summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/librfid/rfid_layer2.h2
-rw-r--r--include/librfid/rfid_protocol.h2
-rw-r--r--src/rfid_layer2.c5
-rw-r--r--src/rfid_protocol.c5
-rw-r--r--src/rfid_scan.c6
-rw-r--r--utils/librfid-tool.c21
6 files changed, 36 insertions, 5 deletions
diff --git a/include/librfid/rfid_layer2.h b/include/librfid/rfid_layer2.h
index 514a735..0f6f683 100644
--- a/include/librfid/rfid_layer2.h
+++ b/include/librfid/rfid_layer2.h
@@ -34,7 +34,7 @@ int rfid_layer2_getopt(struct rfid_layer2_handle *ph, int optname,
void *optval, unsigned int *optlen);
int rfid_layer2_setopt(struct rfid_layer2_handle *ph, int optname,
const void *optval, unsigned int optlen);
-
+char *rfid_layer2_name(struct rfid_layer2_handle *l2h);
#ifdef __LIBRFID__
#include <librfid/rfid_layer2_iso14443a.h>
diff --git a/include/librfid/rfid_protocol.h b/include/librfid/rfid_protocol.h
index d1960ef..28fae69 100644
--- a/include/librfid/rfid_protocol.h
+++ b/include/librfid/rfid_protocol.h
@@ -27,6 +27,8 @@ rfid_protocol_write(struct rfid_protocol_handle *ph,
int rfid_protocol_fini(struct rfid_protocol_handle *ph);
int rfid_protocol_close(struct rfid_protocol_handle *ph);
+char *rfid_protocol_name(struct rfid_protocol_handle *ph);
+
enum rfid_protocol_id {
RFID_PROTOCOL_UNKNOWN,
RFID_PROTOCOL_TCL,
diff --git a/src/rfid_layer2.c b/src/rfid_layer2.c
index 7461d87..a6ee43f 100644
--- a/src/rfid_layer2.c
+++ b/src/rfid_layer2.c
@@ -132,3 +132,8 @@ rfid_layer2_setopt(struct rfid_layer2_handle *ph, int optname,
}
return 0;
}
+
+char *rfid_layer2_name(struct rfid_layer2_handle *l2h)
+{
+ return l2h->l2->name;
+}
diff --git a/src/rfid_protocol.c b/src/rfid_protocol.c
index 46dc48d..b24243a 100644
--- a/src/rfid_protocol.c
+++ b/src/rfid_protocol.c
@@ -111,3 +111,8 @@ rfid_protocol_register(struct rfid_protocol *p)
return 0;
}
+
+char *rfid_protocol_name(struct rfid_protocol_handle *ph)
+{
+ return ph->proto->name;
+}
diff --git a/src/rfid_scan.c b/src/rfid_scan.c
index 1abb4df..f50bee6 100644
--- a/src/rfid_scan.c
+++ b/src/rfid_scan.c
@@ -51,6 +51,7 @@ rfid_layer2_scan(struct rfid_reader_handle *rh)
#define RFID_LAYER2_MAX 16
for (i = 0; i < RFID_LAYER2_MAX; i++) {
+ DEBUGP("testing l2 %u\n", i);
l2h = rfid_layer2_scan1(rh, i);
if (l2h)
return l2h;
@@ -87,6 +88,7 @@ rfid_protocol_scan(struct rfid_layer2_handle *l2h)
#define RFID_PROTOCOL_MAX 16
for (i = 0; i < RFID_PROTOCOL_MAX; i++) {
+ DEBUGP("testing proto %u\n", i);
ph = rfid_protocol_scan1(l2h, i);
if (ph)
return ph;
@@ -105,9 +107,9 @@ int rfid_scan(struct rfid_reader_handle *rh,
if (!*l2h)
return 0;
- *ph = rfid_protocol_scan(l2h);
+ *ph = rfid_protocol_scan(*l2h);
if (!*ph)
return 2;
-
+
return 3;
}
diff --git a/utils/librfid-tool.c b/utils/librfid-tool.c
index c96f948..e1270f1 100644
--- a/utils/librfid-tool.c
+++ b/utils/librfid-tool.c
@@ -330,6 +330,24 @@ static int l2_by_name(const char *name)
return -1;
}
+static void do_scan(void)
+{
+ int rc;
+ printf("scanning for RFID token...\n");
+ rc = rfid_scan(rh, &l2h, &ph);
+ if (rc >= 2) {
+ unsigned char uid_buf[16];
+ unsigned int uid_len = sizeof(uid_buf);
+ rfid_layer2_getopt(l2h, RFID_OPT_LAYER2_UID, &uid_buf,
+ &uid_len);
+ printf("Layer 2 success (%s): %s\n", rfid_layer2_name(l2h),
+ hexdump(uid_buf, uid_len));
+ }
+ if (rc >= 3) {
+ printf("Protocol success (%s)\n", rfid_protocol_name(ph));
+ }
+}
+
static void help(void)
{
printf( " -s --scan\n"
@@ -368,8 +386,7 @@ int main(int argc, char **argv)
case 's':
if (reader() < 0)
exit(1);
- printf("scanning for RFID token...\n");
- i = rfid_scan(rh, &l2h, &ph);
+ do_scan();
exit(0);
break;
case 'p':
personal git repositories of Harald Welte. Your mileage may vary