libwebsockets
Lightweight C library for HTML5 websockets
Toggle main menu visibility
Loading...
Searching...
No Matches
lws-fault-injection.h
Go to the documentation of this file.
1
/*
2
* libwebsockets - small server side websockets and web server implementation
3
*
4
* Copyright (C) 2010 - 2021 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
* Fault injection api if built with LWS_WITH_SYS_FAULT_INJECTION
25
*/
26
27
typedef
struct
lws_xos
{
28
uint64_t
s
[4];
29
}
lws_xos_t
;
30
39
LWS_VISIBLE
LWS_EXTERN
void
40
lws_xos_init
(
struct
lws_xos
*xos, uint64_t seed);
41
51
LWS_VISIBLE
LWS_EXTERN
uint64_t
LWS_WARN_UNUSED_RESULT
52
lws_xos
(
struct
lws_xos
*xos);
53
64
LWS_VISIBLE
LWS_EXTERN
int
LWS_WARN_UNUSED_RESULT
65
lws_xos_percent
(
struct
lws_xos
*xos,
int
percent);
66
67
#if defined(LWS_WITH_SYS_FAULT_INJECTION)
68
69
enum
{
70
LWSFI_ALWAYS,
71
LWSFI_DETERMINISTIC,
/* do .count injections after .pre then stop */
72
LWSFI_PROBABILISTIC,
/* .pre % chance of injection */
73
LWSFI_PATTERN,
/* use .count bits in .pattern after .pre */
74
LWSFI_PATTERN_ALLOC,
/* as _PATTERN, but .pattern is malloc'd */
75
LWSFI_RANGE
/* pick a number between pre and count */
76
};
77
78
typedef
struct
lws_fi
{
79
const
char
*name;
80
const
uint8_t
*pattern;
81
uint64_t pre;
82
uint64_t count;
83
uint64_t times;
/* start at 0, tracks usage */
84
char
type;
/* LWSFI_* */
85
} lws_fi_t;
86
87
typedef
struct
lws_fi_ctx {
88
lws_dll2_owner_t
fi_owner;
89
struct
lws_xos
xos;
90
const
char
*name;
91
} lws_fi_ctx_t;
92
109
LWS_VISIBLE
LWS_EXTERN
int
110
lws_fi
(
const
lws_fi_ctx_t *fic,
const
char
*fi_name);
111
130
LWS_VISIBLE
LWS_EXTERN
int
131
lws_fi_range(
const
lws_fi_ctx_t *fic,
const
char
*name, uint64_t *result);
132
142
LWS_VISIBLE
LWS_EXTERN
int
143
lws_fi_add(lws_fi_ctx_t *fic,
const
lws_fi_t *fi);
144
154
LWS_VISIBLE
LWS_EXTERN
void
155
lws_fi_remove(lws_fi_ctx_t *fic,
const
char
*name);
156
166
LWS_VISIBLE
LWS_EXTERN
void
167
lws_fi_import(lws_fi_ctx_t *fic_dest,
const
lws_fi_ctx_t *fic_src);
168
182
LWS_VISIBLE
LWS_EXTERN
void
183
lws_fi_inherit_copy
(lws_fi_ctx_t *fic_dest,
const
lws_fi_ctx_t *fic_src,
184
const
char
*scope,
const
char
*value);
185
195
LWS_VISIBLE
LWS_EXTERN
void
196
lws_fi_destroy
(
const
lws_fi_ctx_t *fic);
197
210
211
LWS_VISIBLE
LWS_EXTERN
void
212
lws_fi_deserialize
(lws_fi_ctx_t *fic,
const
char
*sers);
213
214
LWS_VISIBLE
LWS_EXTERN
int
215
_lws_fi_user_wsi_fi(
struct
lws *wsi,
const
char
*name);
216
LWS_VISIBLE
LWS_EXTERN
int
217
_lws_fi_user_context_fi(
struct
lws_context *ctx,
const
char
*name);
218
219
#if defined(LWS_WITH_SECURE_STREAMS)
220
struct
lws_ss_handle;
221
LWS_VISIBLE
LWS_EXTERN
int
222
_lws_fi_user_ss_fi(
struct
lws_ss_handle *h,
const
char
*name);
223
#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API)
224
struct
lws_sspc_handle;
225
LWS_VISIBLE
LWS_EXTERN
int
226
_lws_fi_user_sspc_fi(
struct
lws_sspc_handle *h,
const
char
*name);
227
#endif
228
#endif
229
230
#define lws_fi_user_wsi_fi(_wsi, _name) _lws_fi_user_wsi_fi(_wsi, _name)
231
#define lws_fi_user_context_fi(_ctx, _name) _lws_fi_user_context_fi(_ctx, _name)
232
#define lws_fi_user_ss_fi(_h, _name) _lws_fi_user_ss_fi(_h, _name)
233
#define lws_fi_user_sspc_fi(_h, _name) _lws_fi_user_sspc_fi(_h, _name)
234
235
#else
236
237
/*
238
* Helper so we can leave lws_fi() calls embedded in the code being tested,
239
* if fault injection is not enabled then it just always says "no" at buildtime.
240
*/
241
242
#define lws_fi(_fi_name, _fic) (0)
243
#define lws_fi_destroy(_x)
244
#define lws_fi_inherit_copy(_a, _b, _c, _d)
245
#define lws_fi_deserialize(_x, _y)
246
#define lws_fi_user_wsi_fi(_wsi, _name) (0)
247
#define lws_fi_user_context_fi(_wsi, _name) (0)
248
#define lws_fi_user_ss_fi(_h, _name) (0)
249
#define lws_fi_user_sspc_fi(_h, _name) (0)
250
251
#endif
lws_dll2_owner_t
struct lws_dll2_owner lws_dll2_owner_t
LWS_EXTERN
#define LWS_EXTERN
Definition
libwebsockets.h:296
uint8_t
unsigned char uint8_t
Definition
libwebsockets.h:706
LWS_WARN_UNUSED_RESULT
#define LWS_WARN_UNUSED_RESULT
Definition
libwebsockets.h:292
LWS_VISIBLE
#define LWS_VISIBLE
Definition
libwebsockets.h:291
lws_xos_percent
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_xos_percent(struct lws_xos *xos, int percent)
lws_fi
#define lws_fi(_fi_name, _fic)
Definition
lws-fault-injection.h:242
lws_fi_deserialize
#define lws_fi_deserialize(_x, _y)
Definition
lws-fault-injection.h:245
lws_xos_t
struct lws_xos lws_xos_t
lws_xos
LWS_VISIBLE LWS_EXTERN uint64_t LWS_WARN_UNUSED_RESULT lws_xos(struct lws_xos *xos)
lws_xos::s
uint64_t s[4]
Definition
lws-fault-injection.h:28
lws_xos_init
LWS_VISIBLE LWS_EXTERN void lws_xos_init(struct lws_xos *xos, uint64_t seed)
lws_fi_inherit_copy
#define lws_fi_inherit_copy(_a, _b, _c, _d)
Definition
lws-fault-injection.h:244
lws_fi_destroy
#define lws_fi_destroy(_x)
Definition
lws-fault-injection.h:243
lws_xos
Definition
lws-fault-injection.h:27
include
libwebsockets
lws-fault-injection.h
Generated on
for libwebsockets by
1.18.0