1FIDO_DEV_SET_IO_FUNCT... BSD Library Functions Manual FIDO_DEV_SET_IO_FUNCT...
2

NAME

4     fido_dev_set_io_functions — FIDO 2 device I/O interface
5

SYNOPSIS

7     #include <fido.h>
8
9     typedef void *fido_dev_io_open_t(const char *);
10     typedef void  fido_dev_io_close_t(void *);
11     typedef int   fido_dev_io_read_t(void *, unsigned char *, size_t, int);
12     typedef int   fido_dev_io_write_t(void *, const unsigned char *, size_t);
13
14     typedef struct fido_dev_io {
15             fido_dev_io_open_t  *open;
16             fido_dev_io_close_t *close;
17             fido_dev_io_read_t  *read;
18             fido_dev_io_write_t *write;
19     } fido_dev_io_t;
20
21     int
22     fido_dev_set_io_functions(fido_dev_t *dev, const fido_dev_io_t *io);
23

DESCRIPTION

25     The fido_dev_set_io_functions interface defines the I/O handlers used to
26     talk to dev.  Its usage is optional.  By default, libfido2 will use the
27     operating system's native HID interface to talk to a FIDO device.
28
29     A fido_dev_io_open_t function is expected to return a non-NULL opaque
30     pointer on success, and NULL on error.  The returned opaque pointer is
31     never dereferenced by libfido2.
32
33     A fido_dev_io_close_t function receives the opaque handle obtained from
34     fido_dev_io_open_t.  It is not expected to be idempotent.
35
36     A fido_dev_io_read_t function reads from dev.  The first parameter taken
37     is the opaque handle obtained from fido_dev_io_open_t.  The read buffer
38     is pointed to by the second parameter, and the third parameter holds its
39     size.  Finally, the last argument passed to fido_dev_io_read_t is the
40     number of milliseconds the caller is willing to sleep, should the call
41     need to block.  If this value holds -1, fido_dev_io_read_t may block
42     indefinitely.  The number of bytes read is returned.  On error, -1 is
43     returned.
44
45     Conversely, a fido_dev_io_write_t function writes to dev.  The first
46     parameter taken is the opaque handle returned by fido_dev_io_open_t.  The
47     write buffer is pointed to by the second parameter, and the third parame‐
48     ter holds its size.  A fido_dev_io_write_t function may block.  The num‐
49     ber of bytes written is returned.  On error, -1 is returned.
50
51     No references to io are held by fido_dev_set_io_functions().
52

RETURN VALUES

54     On success, fido_dev_set_io_functions() returns FIDO_OK.  On error, a
55     different error code defined in <fido/err.h> is returned.
56
57BSD                              May 10, 2020                              BSD
Impressum