fido_dev_set_io_functions
FIDO 2 device I/O interface
- Provided by: libfido2-doc (Version: 1.3.1-1ubuntu2)
- Source: libfido2
- Report a bug
FIDO 2 device I/O interface
#include
<fido.h>
typedef void *fido_dev_io_open_t(const char *);
typedef void fido_dev_io_close_t(void *);
typedef int fido_dev_io_read_t(void *, unsigned char *, size_t, int);
typedef int fido_dev_io_write_t(void *, const unsigned char *, size_t);
typedef struct fido_dev_io {
fido_dev_io_open_t *open;
fido_dev_io_close_t *close;
fido_dev_io_read_t *read;
fido_dev_io_write_t *write;
} fido_dev_io_t;
fido_dev_set_io_functions(fido_dev_t
*dev, const fido_dev_io_t
*io);
The fido_dev_set_io_functions interface
defines the I/O handlers used to talk to dev. Its
usage is optional. By default, libfido2 will use the
operating system's native HID interface to talk to a FIDO device.
A fido_dev_io_open_t function is expected to return a non-NULL opaque pointer on success, and NULL on error. The returned opaque pointer is never dereferenced by libfido2.
A fido_dev_io_close_t function receives the opaque handle obtained from fido_dev_io_open_t. It is not expected to be idempotent.
A fido_dev_io_read_t function reads from dev. The first parameter taken is the opaque handle obtained from fido_dev_io_open_t. The read buffer is pointed to by the second parameter, and the third parameter holds its size. Finally, the last argument passed to fido_dev_io_read_t is the number of milliseconds the caller is willing to sleep, should the call need to block. If this value holds -1, fido_dev_io_read_t may block indefinitely. The number of bytes read is returned. On error, -1 is returned.
Conversely, a fido_dev_io_write_t function writes to dev. The first parameter taken is the opaque handle returned by fido_dev_io_open_t. The write buffer is pointed to by the second parameter, and the third parameter holds its size. A fido_dev_io_write_t function may block. The number of bytes written is returned. On error, -1 is returned.
No references to
io are held by
fido_dev_set_io_functions().
On success, fido_dev_set_io_functions()
returns FIDO_OK. On error, a different error code
defined in <fido/err.h> is
returned.