MOS Source Code
Loading...
Searching...
No Matches
random_data.h
Go to the documentation of this file.
1/* This module handles generating & modifying messages randomly for the fuzz test. */
2
3#ifndef RANDOM_DATA_H
4#define RANDOM_DATA_H
5
6#include <pb.h>
7
10
11/* Random 32-bit integer */
13
14/* Get a random integer in range, with approximately flat distribution. */
15int rand_int(int min, int max);
16
17/* Random boolean, equal probability */
18bool rand_bool();
19
20/* Get a random byte, with skewed distribution.
21 * Important corner cases like 0xFF, 0x00 and 0xFE occur more
22 * often than other values. */
24
25/* Get a random length, with skewed distribution.
26 * Favors the shorter lengths, but always at least 1. */
27size_t rand_len(size_t max);
28
29/* Fills a buffer with random bytes with skewed distribution. */
30void rand_fill(uint8_t *buf, size_t count);
31
32/* Fill with random protobuf-like data */
33size_t rand_fill_protobuf(uint8_t *buf, size_t min_bytes, size_t max_bytes, int min_tag);
34
35/* Given a buffer of data, mess it up a bit by copying / swapping bytes */
36void rand_mess(uint8_t *buf, size_t count);
37
38/* Append or prepend protobuf noise, with tag values > 1000 */
39void rand_protobuf_noise(uint8_t *buffer, size_t bufsize, size_t *msglen);
40
41
42
43
44#endif
unsigned int uint32_t
Definition pb_syshdr.h:24
unsigned char uint8_t
Definition pb_syshdr.h:20
size_t rand_len(size_t max)
Definition random_data.c:59
void random_set_seed(uint32_t seed)
Definition random_data.c:10
uint32_t random_get_seed()
Definition random_data.c:15
uint8_t rand_byte()
Definition random_data.c:44
void rand_fill(uint8_t *buf, size_t count)
Definition random_data.c:78
size_t rand_fill_protobuf(uint8_t *buf, size_t min_bytes, size_t max_bytes, int min_tag)
Definition random_data.c:87
uint32_t rand_word()
Definition random_data.c:22
void rand_mess(uint8_t *buf, size_t count)
bool rand_bool()
Definition random_data.c:36
int rand_int(int min, int max)
Definition random_data.c:31
void rand_protobuf_noise(uint8_t *buffer, size_t bufsize, size_t *msglen)
static char buffer[2048]
Definition test_printf.c:7