summaryrefslogtreecommitdiff
path: root/man/fido_dev_set_io_functions.3
diff options
context:
space:
mode:
Diffstat (limited to 'man/fido_dev_set_io_functions.3')
-rw-r--r--man/fido_dev_set_io_functions.369
1 files changed, 63 insertions, 6 deletions
diff --git a/man/fido_dev_set_io_functions.3 b/man/fido_dev_set_io_functions.3
index adc4a9e..67bc6d0 100644
--- a/man/fido_dev_set_io_functions.3
+++ b/man/fido_dev_set_io_functions.3
@@ -15,12 +15,16 @@ typedef void *fido_dev_io_open_t(const char *);
15typedef void fido_dev_io_close_t(void *); 15typedef void fido_dev_io_close_t(void *);
16typedef int fido_dev_io_read_t(void *, unsigned char *, size_t, int); 16typedef int fido_dev_io_read_t(void *, unsigned char *, size_t, int);
17typedef int fido_dev_io_write_t(void *, const unsigned char *, size_t); 17typedef int fido_dev_io_write_t(void *, const unsigned char *, size_t);
18typedef int fido_dev_io_rx_t(struct fido_dev *, uint8_t, unsigned char *, size_t, int);
19typedef int fido_dev_io_tx_t(struct fido_dev *, uint8_t, const unsigned char *, size_t);
18 20
19typedef struct fido_dev_io { 21typedef struct fido_dev_io {
20 fido_dev_io_open_t *open; 22 fido_dev_io_open_t *open;
21 fido_dev_io_close_t *close; 23 fido_dev_io_close_t *close;
22 fido_dev_io_read_t *read; 24 fido_dev_io_read_t *read;
23 fido_dev_io_write_t *write; 25 fido_dev_io_write_t *write;
26 fido_dev_io_rx_t *rx;
27 fido_dev_io_tx_t *tx;
24} fido_dev_io_t; 28} fido_dev_io_t;
25.Ed 29.Ed
26.Ft int 30.Ft int
@@ -28,12 +32,12 @@ typedef struct fido_dev_io {
28.Sh DESCRIPTION 32.Sh DESCRIPTION
29The 33The
30.Nm 34.Nm
31interface defines the I/O handlers used to talk to 35interface defines the I/O and transmission handlers used to talk to
32.Fa dev . 36.Fa dev .
33Its usage is optional. 37Its usage is optional.
34By default, 38By default,
35.Em libfido2 39.Em libfido2
36will use the operating system's native HID interface to talk to 40will use the operating system's native HID interface to talk CTAP2 to
37a FIDO device. 41a FIDO device.
38.Pp 42.Pp
39A 43A
@@ -51,13 +55,13 @@ It is not expected to be idempotent.
51.Pp 55.Pp
52A 56A
53.Vt fido_dev_io_read_t 57.Vt fido_dev_io_read_t
54function reads from 58function reads a single HID report from
55.Fa dev . 59.Fa dev .
56The first parameter taken is the opaque handle obtained from 60The first parameter taken is the opaque handle obtained from
57.Vt fido_dev_io_open_t . 61.Vt fido_dev_io_open_t .
58The read buffer is pointed to by the second parameter, and the 62The read buffer is pointed to by the second parameter, and the
59third parameter holds its size. 63third parameter holds its size.
60Finally, the last argument passed to 64The last argument passed to
61.Vt fido_dev_io_read_t 65.Vt fido_dev_io_read_t
62is the number of milliseconds the caller is willing to sleep, 66is the number of milliseconds the caller is willing to sleep,
63should the call need to block. 67should the call need to block.
@@ -67,9 +71,9 @@ may block indefinitely.
67The number of bytes read is returned. 71The number of bytes read is returned.
68On error, -1 is returned. 72On error, -1 is returned.
69.Pp 73.Pp
70Conversely, a 74A
71.Vt fido_dev_io_write_t 75.Vt fido_dev_io_write_t
72function writes to 76function writes a single HID report to
73.Fa dev . 77.Fa dev .
74The first parameter taken is the opaque handle returned by 78The first parameter taken is the opaque handle returned by
75.Vt fido_dev_io_open_t . 79.Vt fido_dev_io_open_t .
@@ -81,6 +85,59 @@ function may block.
81The number of bytes written is returned. 85The number of bytes written is returned.
82On error, -1 is returned. 86On error, -1 is returned.
83.Pp 87.Pp
88A
89.Vt fido_dev_io_rx_t
90function receives a complete CTAP2 message from
91.Fa dev .
92The first parameter taken is a pointer to
93.Fa dev .
94The second parameter holds the expected CTAP2 command byte.
95The read buffer is pointed to by the third parameter, and the
96fourth parameter holds its size.
97The last argument passed to
98.Vt fido_dev_io_rx_t
99is the number of milliseconds the caller is willing to sleep,
100should the call need to block.
101If this value holds -1,
102.Vt fido_dev_io_rx_t
103may block indefinitely.
104The number of bytes read is returned.
105On error, -1 is returned.
106.Pp
107A
108.Vt fido_dev_io_tx_t
109function transmits a complete CTAP2 message to
110.Fa dev .
111The first parameter taken is a pointer to
112.Fa dev .
113The second parameter holds the CTAP2 command byte.
114The write buffer is pointed to by the third parameter, and the
115fourth parameter holds its size.
116A
117.Vt fido_dev_io_tx_t
118function may block.
119On success, 0 is returned.
120On error, -1 is returned.
121.Pp
122When calling
123.Fn fido_dev_set_io_functions ,
124the
125.Fa open ,
126.Fa close ,
127.Fa read
128and
129.Fa write
130fields of
131.Fa io
132may not be NULL.
133Either
134.Fa rx
135or
136.Fa tx
137may be NULL, in which case
138.Em libfido2
139uses its corresponding CTAP2 HID transport method.
140.Pp
84No references to 141No references to
85.Fa io 142.Fa io
86are held by 143are held by