forked from google/neper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.h
114 lines (98 loc) · 3.55 KB
/
lib.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NEPER_LIB_H
#define NEPER_LIB_H
#include <stdbool.h>
#include "percentiles.h"
struct host
{
char *host_name;
char *ctrl_port;
char *data_port;
};
struct callbacks {
void *logger;
/* Print in key=value format and keep track of the line number.
* Not thread-safe. */
void (*print)(void *logger, const char *key, const char *value, ...);
/* Use for undesired and unexpected events, that the program cannot
* recover from. Use these whenever an event happens from which you
* actually want all servers to die and dump a stack trace. */
void (*log_fatal)(void *logger, const char *file, int line,
const char *function, const char *format, ...);
/* Use for undesired and unexpected events that the program can recover
* from. All ERRORs should be actionable - it should be appropriate to
* file a bug whenever an ERROR occurs in production. */
void (*log_error)(void *logger, const char *file, int line,
const char *function, const char *format, ...);
/* Use for undesired but relatively expected events, which may indicate
* a problem. For example, the server received a malformed query. */
void (*log_warn)(void *logger, const char *file, int line,
const char *function, const char *format, ...);
/* Use for state changes or other major events, or to aid debugging. */
void (*log_info)(void *logger, const char *file, int line,
const char *function, const char *format, ...);
/* Notify the logger to log to stderr. */
void (*logtostderr)(void *logger);
};
struct options {
int magic;
int min_rto;
int maxevents;
int num_flows;
int num_threads;
int num_clients;
int test_length;
int buffer_size;
int listen_backlog;
int suicide_length;
bool ipv4;
bool ipv6;
bool client;
bool debug;
bool dry_run;
bool pin_cpu;
bool reuseaddr;
bool logtostderr;
bool nonblocking;
double interval;
long long max_pacing_rate;
const char *local_host;
struct host *host;
struct host *slaves;
bool slave_mode;
const char *control_port;
const char *peer_port;
const char *port;
const char *all_samples;
/* tcp_stream */
bool enable_read;
bool enable_write;
bool edge_trigger;
unsigned long delay;
/* tcp_rr */
int request_size;
int response_size;
struct percentiles percentiles;
/* udp_flood */
int burst_size;
int packet_size;
bool rr_hosts;
};
int tcp_stream(struct options *opts, struct callbacks *cb);
int tcp_rr(struct options *opts, struct callbacks *cb);
int udp_flood(struct options *opts, struct callbacks *cb);
#endif