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