diff options
Diffstat (limited to 'man/fido_dev_set_io_functions.3')
-rw-r--r-- | man/fido_dev_set_io_functions.3 | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/man/fido_dev_set_io_functions.3 b/man/fido_dev_set_io_functions.3 new file mode 100644 index 0000000..adc4a9e --- /dev/null +++ b/man/fido_dev_set_io_functions.3 | |||
@@ -0,0 +1,95 @@ | |||
1 | .\" Copyright (c) 2018 Yubico AB. All rights reserved. | ||
2 | .\" Use of this source code is governed by a BSD-style | ||
3 | .\" license that can be found in the LICENSE file. | ||
4 | .\" | ||
5 | .Dd $Mdocdate: May 25 2018 $ | ||
6 | .Dt FIDO_DEV_SET_IO_FUNCTIONS 3 | ||
7 | .Os | ||
8 | .Sh NAME | ||
9 | .Nm fido_dev_set_io_functions | ||
10 | .Nd FIDO 2 device I/O interface | ||
11 | .Sh SYNOPSIS | ||
12 | .In fido.h | ||
13 | .Bd -literal | ||
14 | typedef void *fido_dev_io_open_t(const char *); | ||
15 | typedef void fido_dev_io_close_t(void *); | ||
16 | typedef int fido_dev_io_read_t(void *, unsigned char *, size_t, int); | ||
17 | typedef int fido_dev_io_write_t(void *, const unsigned char *, size_t); | ||
18 | |||
19 | typedef struct fido_dev_io { | ||
20 | fido_dev_io_open_t *open; | ||
21 | fido_dev_io_close_t *close; | ||
22 | fido_dev_io_read_t *read; | ||
23 | fido_dev_io_write_t *write; | ||
24 | } fido_dev_io_t; | ||
25 | .Ed | ||
26 | .Ft int | ||
27 | .Fn fido_dev_set_io_functions "fido_dev_t *dev" "const fido_dev_io_t *io" | ||
28 | .Sh DESCRIPTION | ||
29 | The | ||
30 | .Nm | ||
31 | interface defines the I/O handlers used to talk to | ||
32 | .Fa dev . | ||
33 | Its usage is optional. | ||
34 | By default, | ||
35 | .Em libfido2 | ||
36 | will use the operating system's native HID interface to talk to | ||
37 | a FIDO device. | ||
38 | .Pp | ||
39 | A | ||
40 | .Vt fido_dev_io_open_t | ||
41 | function is expected to return a non-NULL opaque pointer on success, | ||
42 | and NULL on error. | ||
43 | The returned opaque pointer is never dereferenced by | ||
44 | .Em libfido2 . | ||
45 | .Pp | ||
46 | A | ||
47 | .Vt fido_dev_io_close_t | ||
48 | function receives the opaque handle obtained from | ||
49 | .Vt fido_dev_io_open_t . | ||
50 | It is not expected to be idempotent. | ||
51 | .Pp | ||
52 | A | ||
53 | .Vt fido_dev_io_read_t | ||
54 | function reads from | ||
55 | .Fa dev . | ||
56 | The first parameter taken is the opaque handle obtained from | ||
57 | .Vt fido_dev_io_open_t . | ||
58 | The read buffer is pointed to by the second parameter, and the | ||
59 | third parameter holds its size. | ||
60 | Finally, the last argument passed to | ||
61 | .Vt fido_dev_io_read_t | ||
62 | is the number of milliseconds the caller is willing to sleep, | ||
63 | should the call need to block. | ||
64 | If this value holds -1, | ||
65 | .Vt fido_dev_io_read_t | ||
66 | may block indefinitely. | ||
67 | The number of bytes read is returned. | ||
68 | On error, -1 is returned. | ||
69 | .Pp | ||
70 | Conversely, a | ||
71 | .Vt fido_dev_io_write_t | ||
72 | function writes to | ||
73 | .Fa dev . | ||
74 | The first parameter taken is the opaque handle returned by | ||
75 | .Vt fido_dev_io_open_t . | ||
76 | The write buffer is pointed to by the second parameter, and the | ||
77 | third parameter holds its size. | ||
78 | A | ||
79 | .Vt fido_dev_io_write_t | ||
80 | function may block. | ||
81 | The number of bytes written is returned. | ||
82 | On error, -1 is returned. | ||
83 | .Pp | ||
84 | No references to | ||
85 | .Fa io | ||
86 | are held by | ||
87 | .Fn fido_dev_set_io_functions . | ||
88 | .Sh RETURN VALUES | ||
89 | On success, | ||
90 | .Fn fido_dev_set_io_functions | ||
91 | returns | ||
92 | .Dv FIDO_OK . | ||
93 | On error, a different error code defined in | ||
94 | .In fido/err.h | ||
95 | is returned. | ||