libwebsockets
Lightweight C library for HTML5 websockets
Toggle main menu visibility
Loading...
Searching...
No Matches
lws-smd.h
Go to the documentation of this file.
1
/*
2
* lws System Message Distribution
3
*
4
* Copyright (C) 2010 - 2020 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*/
24
25
#define LWS_SMD_MAX_PAYLOAD 384
26
#define LWS_SMD_CLASS_BITFIELD_BYTES 4
27
28
#define LWS_SMD_STREAMTYPENAME "_lws_smd"
29
#define LWS_SMD_SS_RX_HEADER_LEN 16
30
31
typedef
uint32_t
lws_smd_class_t
;
32
33
struct
lws_smd_msg;
/* opaque */
34
struct
lws_smd_peer;
/* opaque */
35
36
/*
37
* Well-known device classes
38
*/
39
40
enum
{
41
LWSSMDCL_INTERACTION
= (1 << 0),
46
LWSSMDCL_SYSTEM_STATE
= (1 << 1),
50
LWSSMDCL_NETWORK
= (1 << 2),
55
LWSSMDCL_METRICS
= (1 << 3),
60
LWSSMDCL_DNS
= (1 << 4),
70
71
LWSSMDCL_USER_BASE_BITNUM
= 24
72
};
73
95
LWS_VISIBLE
LWS_EXTERN
void
*
/* payload */
96
lws_smd_msg_alloc
(
struct
lws_context *ctx,
lws_smd_class_t
_class,
size_t
len);
97
109
LWS_VISIBLE
LWS_EXTERN
void
110
lws_smd_msg_free
(
void
**payload);
111
122
LWS_VISIBLE
LWS_EXTERN
int
123
lws_smd_msg_send
(
struct
lws_context *ctx,
void
*payload);
124
146
LWS_VISIBLE
LWS_EXTERN
int
147
lws_smd_msg_printf
(
struct
lws_context *ctx,
lws_smd_class_t
_class,
148
const
char
*format, ...)
LWS_FORMAT
(3);
149
165
166
struct lws_ss_handle;
167
LWS_VISIBLE
LWS_EXTERN
int
168
lws_smd_ss_msg_printf
(const
char
*tag,
uint8_t
*buf,
size_t
*len,
169
lws_smd_class_t
_class, const
char
*format, ...)
170
LWS_FORMAT
(5);
171
189
LWS_VISIBLE
LWS_EXTERN
int
190
lws_smd_ss_rx_forward
(
void
*ss_user, const
uint8_t
*buf,
size_t
len);
191
192
LWS_VISIBLE
LWS_EXTERN
int
193
lws_smd_sspc_rx_forward
(
void
*ss_user, const
uint8_t
*buf,
size_t
len);
194
195
typedef
int
(*
lws_smd_notification_cb_t
)(
void
*opaque,
lws_smd_class_t
_class,
196
lws_usec_t
timestamp,
void
*buf,
197
size_t
len);
198
199
#define LWSSMDREG_FLAG_PROXIED_SS (1 << 0)
201
202
/*
203
* lws_smd_register() - register to receive smd messages
204
*
205
* \param ctx: the lws_context
206
* \param opaque: an opaque pointer handed to the callback
207
* \param flags: typically 0
208
* \param _class_filter: bitmap of message classes we care about
209
* \param cb: the callback to receive messages
210
*
211
* Queues an allocated, prepared message for delivery to smd clients.
212
*
213
* Returns NULL on failure, or an opaque handle which may be given to
214
* lws_smd_unregister() to stop participating in the shared message queue.
215
*
216
* This is threadsafe to call from a non-service thread.
217
*/
218
219
LWS_VISIBLE
LWS_EXTERN
struct
lws_smd_peer *
220
lws_smd_register
(
struct
lws_context *ctx,
void
*opaque,
int
flags,
221
lws_smd_class_t
_class_filter,
lws_smd_notification_cb_t
cb);
222
223
/*
224
* lws_smd_unregister() - unregister receiving smd messages
225
*
226
* \param pr: the handle returned from the registration
227
*
228
* Destroys the registration of the callback for messages and ability to send
229
* messages.
230
*
231
* It's not necessary to call this if the registration wants to survive for as
232
* long as the lws_context... lws_context_destroy will also clean up any
233
* registrations still active by then.
234
*/
235
236
LWS_VISIBLE
LWS_EXTERN
void
237
lws_smd_unregister
(
struct
lws_smd_peer *pr);
uint32_t
unsigned int uint32_t
Definition
libwebsockets.h:744
LWS_FORMAT
#define LWS_FORMAT(string_index)
Definition
libwebsockets.h:325
LWS_EXTERN
#define LWS_EXTERN
Definition
libwebsockets.h:327
lws_usec_t
int64_t lws_usec_t
Definition
libwebsockets.h:750
uint8_t
unsigned char uint8_t
Definition
libwebsockets.h:746
LWS_VISIBLE
#define LWS_VISIBLE
Definition
libwebsockets.h:322
lws_smd_unregister
LWS_VISIBLE LWS_EXTERN void lws_smd_unregister(struct lws_smd_peer *pr)
LWSSMDCL_NETWORK
@ LWSSMDCL_NETWORK
Definition
lws-smd.h:50
LWSSMDCL_SYSTEM_STATE
@ LWSSMDCL_SYSTEM_STATE
Definition
lws-smd.h:46
LWSSMDCL_METRICS
@ LWSSMDCL_METRICS
Definition
lws-smd.h:55
LWSSMDCL_INTERACTION
@ LWSSMDCL_INTERACTION
Definition
lws-smd.h:41
LWSSMDCL_USER_BASE_BITNUM
@ LWSSMDCL_USER_BASE_BITNUM
Definition
lws-smd.h:71
LWSSMDCL_DNS
@ LWSSMDCL_DNS
Definition
lws-smd.h:60
lws_smd_register
LWS_VISIBLE LWS_EXTERN struct lws_smd_peer * lws_smd_register(struct lws_context *ctx, void *opaque, int flags, lws_smd_class_t _class_filter, lws_smd_notification_cb_t cb)
lws_smd_notification_cb_t
int(* lws_smd_notification_cb_t)(void *opaque, lws_smd_class_t _class, lws_usec_t timestamp, void *buf, size_t len)
Definition
lws-smd.h:195
lws_smd_ss_msg_printf
LWS_VISIBLE LWS_EXTERN int lws_smd_ss_msg_printf(const char *tag, uint8_t *buf, size_t *len, lws_smd_class_t _class, const char *format,...) LWS_FORMAT(5)
lws_smd_sspc_rx_forward
LWS_VISIBLE LWS_EXTERN int lws_smd_sspc_rx_forward(void *ss_user, const uint8_t *buf, size_t len)
lws_smd_msg_alloc
LWS_VISIBLE LWS_EXTERN void * lws_smd_msg_alloc(struct lws_context *ctx, lws_smd_class_t _class, size_t len)
lws_smd_msg_free
LWS_VISIBLE LWS_EXTERN void lws_smd_msg_free(void **payload)
lws_smd_msg_printf
LWS_VISIBLE LWS_EXTERN int lws_smd_msg_printf(struct lws_context *ctx, lws_smd_class_t _class, const char *format,...) LWS_FORMAT(3)
lws_smd_class_t
uint32_t lws_smd_class_t
Definition
lws-smd.h:31
lws_smd_ss_rx_forward
LWS_VISIBLE LWS_EXTERN int lws_smd_ss_rx_forward(void *ss_user, const uint8_t *buf, size_t len)
lws_smd_msg_send
LWS_VISIBLE LWS_EXTERN int lws_smd_msg_send(struct lws_context *ctx, void *payload)
include
libwebsockets
lws-smd.h
Generated on
for libwebsockets by
1.18.0