diff options
author | laforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede> | 2006-10-07 20:55:16 +0000 |
---|---|---|
committer | laforge <laforge@e0336214-984f-0b4b-a45f-81c69e1f0ede> | 2006-10-07 20:55:16 +0000 |
commit | fe4ffab6d97f2e2696bf7f1fb52a175342611aec (patch) | |
tree | 528bd408acafde03001e6d9296069badba9dcffb /src/rfid_layer2.c | |
parent | 2f426580fa990c1e190d09f9d6a4a7fc9b6d25c3 (diff) |
- use C99 compiler flags
- implement some getopt/setopt functions for UID and layer2 specific parameters
- basic rfid scanning support
- add commandline arguments for layer2 / scanning to librfid-tool
- try to detect both supported readers automatically in librfid-tool
- add new 'l2_supported' and 'proto_supported members to rfid_reader
git-svn-id: https://svn.gnumonks.org/trunk/librfid@1895 e0336214-984f-0b4b-a45f-81c69e1f0ede
Diffstat (limited to 'src/rfid_layer2.c')
-rw-r--r-- | src/rfid_layer2.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/rfid_layer2.c b/src/rfid_layer2.c index eef0560..7461d87 100644 --- a/src/rfid_layer2.c +++ b/src/rfid_layer2.c @@ -1,5 +1,5 @@ /* librfid - layer 2 protocol handler - * (C) 2005 by Harald Welte <laforge@gnumonks.org> + * (C) 2005-2006 by Harald Welte <laforge@gnumonks.org> */ /* @@ -92,18 +92,43 @@ 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); + if (optname >> 16 == 0) { + unsigned char *optchar = optval; + + switch (optname) { + case RFID_OPT_LAYER2_UID: + if (ph->uid_len < *optlen) + *optlen = ph->uid_len; + memcpy(optchar, ph->uid, *optlen); + break; + default: + return -EINVAL; + break; + } + } else { + if (!ph->l2->fn.getopt) + return -EINVAL; + + return ph->l2->fn.getopt(ph, optname, optval, optlen); + } + return 0; } 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); + if (optname >> 16 == 0) { + switch (optname) { + default: + return -EINVAL; + break; + } + } else { + if (!ph->l2->fn.setopt) + return -EINVAL; + + return ph->l2->fn.setopt(ph, optname, optval, optlen); + } + return 0; } |