Kea 2.5.8
fuzz.h
Go to the documentation of this file.
1// Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef FUZZ_H
8#define FUZZ_H
9
10#ifdef ENABLE_AFL
11
13
14#include <arpa/inet.h>
15#include <net/if.h>
16#include <sys/socket.h>
17#include <unistd.h>
18
19#include <condition_variable>
20#include <mutex>
21#include <string>
22#include <thread>
23
24namespace isc {
25
26
42
43class Fuzz {
44public:
51 static constexpr size_t BUFFER_SIZE = 256 * 1024;
52
58 static constexpr size_t MAX_SEND_SIZE = 64000;
59
66 static constexpr long MAX_LOOP_COUNT = 1000;
67
68
78 Fuzz(int ipversion, uint16_t port);
79
84 ~Fuzz();
85
91 void transfer(void) const;
92
101 long maxLoopCount() const {
102 return loop_max_;
103 }
104
105private:
120 void createAddressStructures(int ipversion, const char* interface,
121 const char* address, uint16_t port);
122
123 // Other member variables.
124 long loop_max_; //< Maximum number of loop iterations
125 size_t sockaddr_len_; //< Length of the structure
126 struct sockaddr* sockaddr_ptr_; //< Pointer to structure used
127 struct sockaddr_in servaddr4_; //< IPv6 address information
128 struct sockaddr_in6 servaddr6_; //< IPv6 address information
129 int sockfd_; //< Socket used to transfer data
130};
131
132
134class FuzzInitFail : public Exception {
135public:
136 FuzzInitFail(const char* file, size_t line, const char* what) :
137 isc::Exception(file, line, what) { };
138};
139
140}
141
142#endif // ENABLE_AFL
143
144#endif // FUZZ_H
Defines the logger used by the top-level component of kea-lfc.