forked from jedisct1/dnsblast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dnsblast.h
77 lines (62 loc) · 1.91 KB
/
dnsblast.h
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
#ifndef __DNSBLAST_H__
#define __DNSBLAST_H__ 1
#define _POSIX_C_SOURCE 200112L
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <netdb.h>
#include <netinet/in.h>
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <unistd.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include "dns.h"
#define MAX_UDP_DATA_SIZE (0xffff - 20U - 8U)
#ifndef UPDATE_STATUS_PERIOD
# define UPDATE_STATUS_PERIOD 500000000ULL
#endif
#ifndef MAX_UDP_BUFFER_SIZE
# define MAX_UDP_BUFFER_SIZE (16 * 1024 * 1024)
#endif
#define REPEATED_NAME_PROBABILITY (int) ((RAND_MAX * 13854LL) / 100000LL)
#define REFUZZ_PROBABILITY (int) ((RAND_MAX * 500LL) / 100000LL)
typedef struct Context_ {
unsigned char question[MAX_UDP_DATA_SIZE];
const struct addrinfo *ai;
unsigned long long last_status_update;
unsigned long long startup_date;
unsigned long pps;
unsigned long received_packets;
unsigned long sent_packets;
int sock;
uint16_t id;
_Bool fuzz;
_Bool sending;
} Context;
typedef struct WeightedType_ {
int weight;
uint16_t type;
} WeightedType;
const WeightedType weighted_types[] = {
{ .type = TYPE_A, .weight = (int) ((RAND_MAX * 77662LL) / 100000LL) },
{ .type = TYPE_SOA, .weight = (int) ((RAND_MAX * 803LL) / 100000LL) },
{ .type = TYPE_MX, .weight = (int) ((RAND_MAX * 5073LL) / 100000LL) },
{ .type = TYPE_TXT, .weight = (int) ((RAND_MAX * 2604LL) / 100000LL) },
{ .type = TYPE_AAAA, .weight = (int) ((RAND_MAX * 13858LL) / 100000LL) }
};
#ifndef SO_RCVBUFFORCE
# define SO_RCVBUFFORCE SO_RCVBUF
#endif
#ifndef SO_SNDBUFFORCE
# define SO_SNDBUFFORCE SO_SNDBUF
#endif
#endif