-
Notifications
You must be signed in to change notification settings - Fork 1
/
target_gen_test.c
93 lines (74 loc) · 1.77 KB
/
target_gen_test.c
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include "utils.h"
#include "rand.h"
#include "target.h"
//extern struct range_cfg builtin_ranges;
int main()
{
static struct range_cfg ranges = {
3,
16, 31,
{
5, 5,
45, 11,
54, 16
}
};
static struct range_cfg ports = {
2,
11, 15,
{
80, 9,
81, 11
}
};
/*
//we operate on test version of gen_rand32
srand(time(NULL)); // should only be called once
int fuzz = 8000000;
unsigned int atime = 0, btime = 0;
unsigned long long now, now2;
while (fuzz --> 0)
{
int t= rand() % (ranges.max_addr_idx+1);
gen_rand32(0, t);
now = get_us();
int r1 = random_ip(&ranges);
now2 = get_us();
btime += now2-now;
now = get_us();
int r2 = random_ip2(&ranges);
now2 = get_us();
atime += now2-now;
if (r1 != r2)
{
printf("%d vs %d for %d\n", r1, r2, t);
break;
}
}
printf("atime %d, btime %d\n", atime, btime);
return;
*/
int t;
for(t=0;t<17;t++)
{
gen_rand32(0, t);
printf("r is %d\n", random_ip(&ranges));
}
for(t=0;t<12;t++)
{
gen_rand32(0, t);
printf("p is %d\n", random_port(&ports));
}
struct range_cfg *parsed = make_port_ranges("443:2,80");
printf("portspec 2,2,3,443,1,80,2 vs %d,%d,%d,%d,%d,%d,%d\n", parsed->num, parsed->max_idx, parsed->mask, parsed->ranges[0], parsed->ranges[1], parsed->ranges[2], parsed->ranges[3]);
for(t=0;t<3;t++)
{
gen_rand32(0, t);
printf("p is %d\n", random_port(parsed));
}
struct range_cfg *fromfile = load_range_cfg("test.csw");
printf("from file 3,16,31,5,5,45,11,54,16 vs %d,%d,%d,%d,%d,%d,%d,%d,%d\n", fromfile->num, fromfile->max_idx, fromfile->mask, fromfile->ranges[0], fromfile->ranges[1], fromfile->ranges[2], fromfile->ranges[3], fromfile->ranges[4], fromfile->ranges[5]);
}