blob: 1cd6de5077a56750689e5bdb07eefe2b4b531117 [file] [log] [blame]
Robert Swieckif827c982017-06-01 16:02:39 +02001#ifdef __cplusplus
2extern "C" {
3#endif
4
Robert Swiecki79255592017-06-01 16:50:56 +02005#include <stdbool.h>
Robert Swiecki67ed6c12017-06-06 21:49:07 +02006#include <stddef.h>
Robert Swiecki79255592017-06-01 16:50:56 +02007#include <stdint.h>
8
Robert Swiecki74c23a82017-06-01 15:58:45 +02009/*
10 * buf: input fuzzing data
11 * len: size of the 'buf' data
12 *
13 * Return value: should return 0
14 */
Robert Swieckicabf6e72017-06-01 16:12:23 +020015 int LLVMFuzzerTestOneInput(const uint8_t * buf, size_t len);
Robert Swiecki74c23a82017-06-01 15:58:45 +020016
17/*
18 * argc: ptr to main's argc
19 * argv: ptr to main's argv
20 *
21 * Return value: ignored
22 */
Robert Swieckif827c982017-06-01 16:02:39 +020023 int LLVMFuzzerInitialize(int *argc, char ***argv);
Robert Swiecki74c23a82017-06-01 15:58:45 +020024
25/*
Robert Swieckif98a9272017-06-02 13:56:42 +020026 * Data: data to mutate
27 * Size: size of the data to mutate
28 * MaxSize: maximum size of the destination buffer
29 *
30 * Return value: size of the mutated buffer
31 */
32 size_t LLVMFuzzerMutate(uint8_t * Data, size_t Size, size_t MaxSize);
33
34/*
Robert Swiecki74c23a82017-06-01 15:58:45 +020035 *
36 * An alternative for LLVMFuzzerTestOneInput()
37 *
38 * buf_ptr: will be set to input fuzzing data
39 * len_ptr: will be set to the size of the input fuzzing data
40 */
Robert Swieckicabf6e72017-06-01 16:12:23 +020041 void HF_ITER(const uint8_t ** buf_ptr, size_t * len_ptr);
Robert Swieckif827c982017-06-01 16:02:39 +020042
Robert Swieckifcf85112017-06-27 23:57:32 +020043/*
44 * Update comparison map:
45 *
46 * addr: address of original comparison
47 * n: new value (only if better than the old/current value)
48 */
49 void instrumentCmpMap(void *addr, unsigned int new);
50
Robert Swiecki0061b222017-06-01 16:49:35 +020051#if defined(__linux__)
Robert Swiecki649b89d2017-06-01 16:42:49 +020052
Robert Swieckic6802372017-06-16 19:35:20 +020053#include <sched.h>
54
Robert Swiecki649b89d2017-06-01 16:42:49 +020055/*
56 * Enter Linux namespaces
57 *
58 * cloneFlags: see 'man unshare'
59 */
60 bool linuxEnterNs(uintptr_t cloneFlags);
61/*
62 * Bring network interface up
63 *
64 * ifacename: name of the interface, typically "lo"
65 */
66 bool linuxIfaceUp(const char *ifacename);
67/*
68 * Mount tmpfs over a mount point
69 *
70 * dst: mount point for tmfs
71 */
72 bool linuxMountTmpfs(const char *dst);
73
Robert Swiecki0061b222017-06-01 16:49:35 +020074#endif /* defined(__linux__) */
Robert Swiecki649b89d2017-06-01 16:42:49 +020075
Robert Swieckif827c982017-06-01 16:02:39 +020076#ifdef __cplusplus
77} /* extern "C" */
78#endif