1 /* Iperf Example - iperf declaration
2 
3    This example code is in the Public Domain (or CC0 licensed, at your option.)
4 
5    Unless required by applicable law or agreed to in writing, this
6    software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
7    CONDITIONS OF ANY KIND, either express or implied.
8 */
9 
10 #ifndef __IPERF_H_
11 #define __IPERF_H_
12 
13 #include "esp_err.h"
14 #include "esp_types.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define IPERF_IP_TYPE_IPV4 0
21 #define IPERF_IP_TYPE_IPV6 1
22 #define IPERF_TRANS_TYPE_TCP 0
23 #define IPERF_TRANS_TYPE_UDP 1
24 
25 #define IPERF_FLAG_SET(cfg, flag) ((cfg) |= (flag))
26 #define IPERF_FLAG_CLR(cfg, flag) ((cfg) &= (~(flag)))
27 
28 #define IPERF_FLAG_CLIENT (1)
29 #define IPERF_FLAG_SERVER (1 << 1)
30 #define IPERF_FLAG_TCP (1 << 2)
31 #define IPERF_FLAG_UDP (1 << 3)
32 
33 #define IPERF_DEFAULT_PORT 5001
34 #define IPERF_DEFAULT_INTERVAL 3
35 #define IPERF_DEFAULT_TIME 30
36 #define IPERF_DEFAULT_NO_BW_LIMIT -1
37 
38 #define IPERF_TRAFFIC_TASK_NAME "iperf_traffic"
39 #define IPERF_TRAFFIC_TASK_PRIORITY 4
40 #define IPERF_TRAFFIC_TASK_STACK 4096
41 #define IPERF_REPORT_TASK_NAME "iperf_report"
42 #define IPERF_REPORT_TASK_PRIORITY 6
43 #define IPERF_REPORT_TASK_STACK 4096
44 
45 #define IPERF_UDP_TX_LEN (1472)
46 #define IPERF_UDP_RX_LEN (16 << 10)
47 #define IPERF_TCP_TX_LEN (16 << 10)
48 #define IPERF_TCP_RX_LEN (16 << 10)
49 
50 #define IPERF_MAX_DELAY 64
51 
52 #define IPERF_SOCKET_RX_TIMEOUT 10
53 #define IPERF_SOCKET_ACCEPT_TIMEOUT 5
54 
55 typedef struct {
56     uint32_t flag;
57     union {
58         uint32_t destination_ip4;
59         char    *destination_ip6;
60     };
61     union {
62         uint32_t source_ip4;
63         char    *source_ip6;
64     };
65     uint8_t type;
66     uint16_t dport;
67     uint16_t sport;
68     uint32_t interval;
69     uint32_t time;
70     uint16_t len_send_buf;
71     int32_t bw_lim;
72 } iperf_cfg_t;
73 
74 esp_err_t iperf_start(iperf_cfg_t *cfg);
75 
76 esp_err_t iperf_stop(void);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif
83