summaryrefslogtreecommitdiff
path: root/src/rfid_layer2.c
diff options
context:
space:
mode:
authorlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2005-11-08 10:34:18 +0000
committerlaforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede>2005-11-08 10:34:18 +0000
commit7600eb5ebbb8ac0f7532e7e7ae6cb5d4dc29d30b (patch)
treef38665192c50bdcbbda8e74d00f585ced5cea63b /src/rfid_layer2.c
parent27e8fe5394184505e09318d3691761da59ecdff5 (diff)
- better layering abstraciton
- differentiate between library internal definitions and public ones - implement getopt/setopt like get/setsockopt - offer speed changing controls git-svn-id: https://svn.gnumonks.org/trunk/librfid@1662 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'src/rfid_layer2.c')
-rw-r--r--src/rfid_layer2.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/rfid_layer2.c b/src/rfid_layer2.c
index c1ab6a6..01443d8 100644
--- a/src/rfid_layer2.c
+++ b/src/rfid_layer2.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <errno.h>
#include <rfid/rfid.h>
#include <rfid/rfid_layer2.h>
@@ -41,6 +42,9 @@ rfid_layer2_init(struct rfid_reader_handle *rh, unsigned int id)
int
rfid_layer2_open(struct rfid_layer2_handle *ph)
{
+ if (!ph->l2->fn.open)
+ return 0;
+
return ph->l2->fn.open(ph);
}
@@ -51,18 +55,27 @@ rfid_layer2_transcieve(struct rfid_layer2_handle *ph,
unsigned char *rx_buf, unsigned int *rx_len,
u_int64_t timeout, unsigned int flags)
{
+ if (!ph->l2->fn.transcieve)
+ return -EIO;
+
return ph->l2->fn.transcieve(ph, frametype, tx_buf, len, rx_buf,
rx_len, timeout, flags);
}
int rfid_layer2_fini(struct rfid_layer2_handle *ph)
{
+ if (!ph->l2->fn.fini)
+ return 0;
+
return ph->l2->fn.fini(ph);
}
int
rfid_layer2_close(struct rfid_layer2_handle *ph)
{
+ if (!ph->l2->fn.close)
+ return 0;
+
return ph->l2->fn.close(ph);
}
@@ -74,3 +87,23 @@ rfid_layer2_register(struct rfid_layer2 *p)
return 0;
}
+
+int
+rfid_layer2_getopt(struct rfid_layer2_handle *ph, int optname,
+ void *optval, unsigned int *optlen)
+{
+ if (!ph->l2->fn.getopt)
+ return -EINVAL;
+
+ return ph->l2->fn.getopt(ph, optname, optval, optlen);
+}
+
+int
+rfid_layer2_setopt(struct rfid_layer2_handle *ph, int optname,
+ const void *optval, unsigned int optlen)
+{
+ if (!ph->l2->fn.setopt)
+ return -EINVAL;
+
+ return ph->l2->fn.setopt(ph, optname, optval, optlen);
+}
personal git repositories of Harald Welte. Your mileage may vary