aboutsummaryrefslogtreecommitdiffstats
path: root/tests/afl-radix/generate_in.c
blob: 684cd48fc99abcab88e79ebb8626e65dee46a024 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "dbg.h"
#include "ip_util.h"

int main(void)
{
	char buf[4096];
	int fd = open("in/1", O_CREAT | O_WRONLY);
	int i = 0;

	buf[i++] = 'a';
	buf[i++] = 0x01;
	buf[i++] = 28;
	memcpy(buf + i, ip4_from("192.168.4.0"), 4);
	i += 4;
	memset(buf + i, 0x0, 12);
	i += 12;
	buf[i++] = '\n';

	buf[i++] = 'a';
	buf[i++] = 0x02;
	buf[i++] = 124;
	memcpy(buf + i, ip6_from("2001:db8:1234::"), 16);
	i += 16;
	buf[i++] = '\n';

	buf[i++] = 'b';
	buf[i++] = 0x01;
	buf[i++] = 0;
	memcpy(buf + i, ip4_from("192.168.4.0"), 4);
	i += 4;
	memset(buf + i, 0x0, 12);
	i += 12;
	buf[i++] = '\n';

	buf[i++] = 'b';
	buf[i++] = 0x02;
	buf[i++] = 0;
	memcpy(buf + i, ip6_from("2001:db8:1234::"), 16);
	i += 16;
	buf[i++] = '\n';

	if (write(fd, buf, i) < i)
		fatal("write()");

	return 0;
}