-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrandom.c
More file actions
55 lines (41 loc) · 715 Bytes
/
random.c
File metadata and controls
55 lines (41 loc) · 715 Bytes
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
struct mod_random
{
size_t module_number;
};
void *
random_init(struct userdata *u, size_t n)
{
struct mod_random *data;
data = malloc(sizeof(struct mod_random));
if (!data) {
fprintf(stderr, "Module %s: malloc(%lu) failed\n",
modules[n].name, (long)sizeof(struct mod_random));
goto fail_alloc;
}
data->module_number = n;
return data;
fail_alloc:
return NULL;
}
void
random_conf(void *arg, char *param1, char *param2)
{
}
int
random_postconf(void *arg)
{
return 1;
}
void
random_free(void *arg)
{
struct mod_random *data = arg;
free(data);
}
double
random_weight(void *arg, char *packet, int packetlen, int mark)
{
double m;
m = ((double)RAND_MAX + 1) / (rand() + 1);
return m;
}