BrlAPI 0.8

brlapi_protocol.h
Go to the documentation of this file.
1 /*
2 * libbrlapi - A library providing access to braille terminals for applications.
3 *
4 * Copyright (C) 2002-2021 by
5 * Samuel Thibault <Samuel.Thibault@ens-lyon.org>
6 * Sébastien Hinderer <Sebastien.Hinderer@ens-lyon.org>
7 *
8 * libbrlapi comes with ABSOLUTELY NO WARRANTY.
9 *
10 * This is free software, placed under the terms of the
11 * GNU Lesser General Public License, as published by the Free Software
12 * Foundation; either version 2.1 of the License, or (at your option) any
13 * later version. Please see the file LICENSE-LGPL for details.
14 *
15 * Web Page: http://brltty.app/
16 *
17 * This software is maintained by Dave Mielke <dave@mielke.cc>.
18 */
19
24 #ifndef BRLAPI_INCLUDED_PROTOCOL
25 #define BRLAPI_INCLUDED_PROTOCOL
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30
31 #include "brlapi.h"
32
33 /* this is for UINT32_MAX */
34 #include <inttypes.h>
35 #ifndef UINT32_MAX
36 #define UINT32_MAX (4294967295U)
37 #endif /* UINT32_MAX */
38
39 /* The type size_t is defined there! */
40 #include <unistd.h>
41
52 #define BRLAPI_PROTOCOL_VERSION ((uint32_t) 8)
56 #define BRLAPI_MAXPACKETSIZE 4096
57
58 #define BRLAPI_PACKET_VERSION 'v'
59 #define BRLAPI_PACKET_AUTH 'a'
60 #define BRLAPI_PACKET_GETDRIVERNAME 'n'
61 #define BRLAPI_PACKET_GETMODELID 'd'
62 #define BRLAPI_PACKET_GETDISPLAYSIZE 's'
63 #define BRLAPI_PACKET_ENTERTTYMODE 't'
64 #define BRLAPI_PACKET_SETFOCUS 'F'
65 #define BRLAPI_PACKET_LEAVETTYMODE 'L'
66 #define BRLAPI_PACKET_KEY 'k'
67 #define BRLAPI_PACKET_IGNOREKEYRANGES 'm'
68 #define BRLAPI_PACKET_ACCEPTKEYRANGES 'u'
69 #define BRLAPI_PACKET_WRITE 'w'
70 #define BRLAPI_PACKET_ENTERRAWMODE '*'
71 #define BRLAPI_PACKET_LEAVERAWMODE '#'
72 #define BRLAPI_PACKET_PACKET 'p'
73 #define BRLAPI_PACKET_ACK 'A'
74 #define BRLAPI_PACKET_ERROR 'e'
75 #define BRLAPI_PACKET_EXCEPTION 'E'
76 #define BRLAPI_PACKET_SUSPENDDRIVER 'S'
77 #define BRLAPI_PACKET_RESUMEDRIVER 'R'
78 #define BRLAPI_PACKET_SYNCHRONIZE 'Z'
79 #define BRLAPI_PACKET_PARAM_VALUE (('P'<<8) + 'V')
80 #define BRLAPI_PACKET_PARAM_REQUEST (('P'<<8) + 'R')
81 #define BRLAPI_PACKET_PARAM_UPDATE (('P'<<8) + 'U')
84 #define BRLAPI_DEVICE_MAGIC (0xdeadbeefL)
85
87 typedef struct {
88 uint32_t size;
89 brlapi_packetType_t type;
90 } brlapi_header_t;
91
93 #define BRLAPI_HEADERSIZE sizeof(brlapi_header_t)
94
96 typedef struct {
97 uint32_t protocolVersion;
98 } brlapi_versionPacket_t;
99
101 typedef struct {
102 uint32_t type;
103 unsigned char key;
104 } brlapi_authClientPacket_t;
105
106 typedef struct {
107 uint32_t type[1];
108 } brlapi_authServerPacket_t;
109
110 #define BRLAPI_AUTH_NONE 'N'
111 #define BRLAPI_AUTH_KEY 'K'
112 #define BRLAPI_AUTH_CRED 'C'
115 typedef struct {
116 uint32_t code;
117 brlapi_packetType_t type;
118 unsigned char packet;
119 } brlapi_errorPacket_t;
120
122 typedef struct {
123 uint32_t magic;
124 unsigned char nameLength;
125 char name;
126 } brlapi_getDriverSpecificModePacket_t;
127
129 #define BRLAPI_WF_DISPLAYNUMBER 0X01
130 #define BRLAPI_WF_REGION 0X02
131 #define BRLAPI_WF_TEXT 0X04
132 #define BRLAPI_WF_ATTR_AND 0X08
133 #define BRLAPI_WF_ATTR_OR 0X10
134 #define BRLAPI_WF_CURSOR 0X20
135 #define BRLAPI_WF_CHARSET 0X40
138 typedef struct {
139 uint32_t flags;
140 unsigned char data;
141 } brlapi_writeArgumentsPacket_t;
142
144 #define BRLAPI_PVF_GLOBAL 0X01
146 #define BRLAPI_MAXPARAMSIZE (BRLAPI_MAXPACKETSIZE - (sizeof(uint32_t) + sizeof(brlapi_param_t) + 2*sizeof(uint32_t)))
147
149 typedef struct {
150 uint32_t flags;
151 brlapi_param_t param;
152 uint32_t subparam_hi;
153 uint32_t subparam_lo;
154 unsigned char data[BRLAPI_MAXPARAMSIZE];
155 } brlapi_paramValuePacket_t;
156
158 #define BRLAPI_PARAMF_GET 0X100
159 #define BRLAPI_PARAMF_SUBSCRIBE 0X200
160 #define BRLAPI_PARAMF_UNSUBSCRIBE 0X400
163 typedef struct {
164 uint32_t flags;
165 brlapi_param_t param;
166 uint32_t subparam_hi;
167 uint32_t subparam_lo;
168 } brlapi_paramRequestPacket_t;
169
172 typedef union {
173 unsigned char data[BRLAPI_MAXPACKETSIZE];
174 brlapi_versionPacket_t version;
175 brlapi_authClientPacket_t authClient;
176 brlapi_authServerPacket_t authServer;
177 brlapi_errorPacket_t error;
178 brlapi_getDriverSpecificModePacket_t getDriverSpecificMode;
179 brlapi_writeArgumentsPacket_t writeArguments;
180 brlapi_paramValuePacket_t paramValue;
181 brlapi_paramRequestPacket_t paramRequest;
182 uint32_t uint32;
183 } brlapi_packet_t;
184
185 /* brlapi_writePacket */
201 ssize_t brlapi_writePacket(brlapi_fileDescriptor fd, brlapi_packetType_t type, const void *buf, size_t size);
202
203 /* brlapi_readPacketHeader */
220 ssize_t brlapi_readPacketHeader(brlapi_fileDescriptor fd, brlapi_packetType_t *packetType);
221
222 /* brlapi_readPacketContent */
243 ssize_t brlapi_readPacketContent(brlapi_fileDescriptor fd, size_t packetSize, void *buf, size_t bufSize);
244
245 /* brlapi_readPacket */
267 ssize_t brlapi_readPacket(brlapi_fileDescriptor fd, brlapi_packetType_t *type, void *buf, size_t size);
268
269 /* brlapi_fd_mutex */
295 #ifdef __MINGW32__
296 #include <windows.h>
297 extern HANDLE brlapi_fd_mutex;
298 #else /* __MINGW32__ */
299 #include <pthread.h>
300 extern pthread_mutex_t brlapi_fd_mutex;
301 #endif /* __MINGW32__ */
302
305 #ifdef __cplusplus
306 }
307 #endif /* __cplusplus */
308
309 #endif /* BRLAPI_INCLUDED_PROTOCOL */
brlapi_packet_t::authServer
brlapi_authServerPacket_t authServer
Definition: brlapi_protocol.h:176
brlapi_readPacket
ssize_t brlapi_readPacket(brlapi_fileDescriptor fd, brlapi_packetType_t *type, void *buf, size_t size)
brlapi_paramRequestPacket_t
Definition: brlapi_protocol.h:163
brlapi_readPacketContent
ssize_t brlapi_readPacketContent(brlapi_fileDescriptor fd, size_t packetSize, void *buf, size_t bufSize)
brlapi_packet_t
Definition: brlapi_protocol.h:172
brlapi_paramValuePacket_t::param
brlapi_param_t param
Definition: brlapi_protocol.h:151
brlapi_readPacketHeader
ssize_t brlapi_readPacketHeader(brlapi_fileDescriptor fd, brlapi_packetType_t *packetType)
brlapi_paramValuePacket_t::subparam_lo
uint32_t subparam_lo
Definition: brlapi_protocol.h:153
brlapi_getDriverSpecificModePacket_t
Definition: brlapi_protocol.h:122
brlapi_getDriverSpecificModePacket_t::nameLength
unsigned char nameLength
Definition: brlapi_protocol.h:124
brlapi_writeArgumentsPacket_t::flags
uint32_t flags
Definition: brlapi_protocol.h:139
brlapi_errorPacket_t::code
uint32_t code
Definition: brlapi_protocol.h:116
brlapi_paramRequestPacket_t::param
brlapi_param_t param
Definition: brlapi_protocol.h:165
brlapi_versionPacket_t::protocolVersion
uint32_t protocolVersion
Definition: brlapi_protocol.h:97
brlapi_getDriverSpecificModePacket_t::name
char name
Definition: brlapi_protocol.h:125
brlapi_paramRequestPacket_t::subparam_lo
uint32_t subparam_lo
Definition: brlapi_protocol.h:167
brlapi_errorPacket_t::type
brlapi_packetType_t type
Definition: brlapi_protocol.h:117
brlapi_packet_t::uint32
uint32_t uint32
Definition: brlapi_protocol.h:182
brlapi_header_t::size
uint32_t size
Definition: brlapi_protocol.h:88
brlapi_errorPacket_t::packet
unsigned char packet
Definition: brlapi_protocol.h:118
brlapi_getDriverSpecificModePacket_t::magic
uint32_t magic
Definition: brlapi_protocol.h:123
brlapi_header_t::type
brlapi_packetType_t type
Definition: brlapi_protocol.h:89
brlapi_param_t
brlapi_param_t
Definition: brlapi_param.h:36
brlapi_fd_mutex
pthread_mutex_t brlapi_fd_mutex
brlapi_header_t
Definition: brlapi_protocol.h:87
BRLAPI_MAXPACKETSIZE
#define BRLAPI_MAXPACKETSIZE
Definition: brlapi_protocol.h:56
brlapi_fileDescriptor
int brlapi_fileDescriptor
Definition: brlapi.h:164
brlapi_packet_t::version
brlapi_versionPacket_t version
Definition: brlapi_protocol.h:174
brlapi_versionPacket_t
Definition: brlapi_protocol.h:96
brlapi_paramValuePacket_t::flags
uint32_t flags
Definition: brlapi_protocol.h:150
brlapi_paramRequestPacket_t::subparam_hi
uint32_t subparam_hi
Definition: brlapi_protocol.h:166
brlapi_paramValuePacket_t
Definition: brlapi_protocol.h:149
brlapi_packet_t::writeArguments
brlapi_writeArgumentsPacket_t writeArguments
Definition: brlapi_protocol.h:179
brlapi_paramRequestPacket_t::flags
uint32_t flags
Definition: brlapi_protocol.h:164
brlapi.h
Types, defines and functions prototypes for BrlAPI's library.
brlapi_authServerPacket_t
Definition: brlapi_protocol.h:106
brlapi_writePacket
ssize_t brlapi_writePacket(brlapi_fileDescriptor fd, brlapi_packetType_t type, const void *buf, size_t size)
brlapi_errorPacket_t
Definition: brlapi_protocol.h:115
brlapi_writeArgumentsPacket_t::data
unsigned char data
Definition: brlapi_protocol.h:140
brlapi_packet_t::error
brlapi_errorPacket_t error
Definition: brlapi_protocol.h:177
brlapi_packetType_t
uint32_t brlapi_packetType_t
Definition: brlapi.h:1396
brlapi_writeArgumentsPacket_t
Definition: brlapi_protocol.h:138
BRLAPI_MAXPARAMSIZE
#define BRLAPI_MAXPARAMSIZE
Definition: brlapi_protocol.h:146
brlapi_packet_t::paramRequest
brlapi_paramRequestPacket_t paramRequest
Definition: brlapi_protocol.h:181
brlapi_authClientPacket_t
Definition: brlapi_protocol.h:101
brlapi_packet_t::getDriverSpecificMode
brlapi_getDriverSpecificModePacket_t getDriverSpecificMode
Definition: brlapi_protocol.h:178
brlapi_packet_t::paramValue
brlapi_paramValuePacket_t paramValue
Definition: brlapi_protocol.h:180
brlapi_authClientPacket_t::type
uint32_t type
Definition: brlapi_protocol.h:102
brlapi_paramValuePacket_t::subparam_hi
uint32_t subparam_hi
Definition: brlapi_protocol.h:152
brlapi_packet_t::authClient
brlapi_authClientPacket_t authClient
Definition: brlapi_protocol.h:175
brlapi_authClientPacket_t::key
unsigned char key
Definition: brlapi_protocol.h:103