Linux Audio

Check our new training course

Loading...
v5.14.15
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __NETWORK_HELPERS_H
 3#define __NETWORK_HELPERS_H
 4#include <sys/socket.h>
 5#include <sys/types.h>
 6#include <linux/types.h>
 7typedef __u16 __sum16;
 8#include <linux/if_ether.h>
 9#include <linux/if_packet.h>
10#include <linux/ip.h>
11#include <linux/ipv6.h>
12#include <netinet/tcp.h>
13#include <bpf/bpf_endian.h>
14
15#define MAGIC_VAL 0x1234
16#define NUM_ITER 100000
17#define VIP_NUM 5
18#define MAGIC_BYTES 123
19
 
 
 
 
 
 
20/* ipv4 test vector */
21struct ipv4_packet {
22	struct ethhdr eth;
23	struct iphdr iph;
24	struct tcphdr tcp;
25} __packed;
26extern struct ipv4_packet pkt_v4;
27
28/* ipv6 test vector */
29struct ipv6_packet {
30	struct ethhdr eth;
31	struct ipv6hdr iph;
32	struct tcphdr tcp;
33} __packed;
34extern struct ipv6_packet pkt_v6;
35
36int settimeo(int fd, int timeout_ms);
37int start_server(int family, int type, const char *addr, __u16 port,
38		 int timeout_ms);
 
 
 
 
 
 
39int connect_to_fd(int server_fd, int timeout_ms);
 
40int connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms);
41int fastopen_connect(int server_fd, const char *data, unsigned int data_len,
42		     int timeout_ms);
43int make_sockaddr(int family, const char *addr_str, __u16 port,
44		  struct sockaddr_storage *addr, socklen_t *len);
 
45
 
 
 
 
 
 
 
 
 
46#endif
v6.2
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef __NETWORK_HELPERS_H
 3#define __NETWORK_HELPERS_H
 4#include <sys/socket.h>
 5#include <sys/types.h>
 6#include <linux/types.h>
 7typedef __u16 __sum16;
 8#include <linux/if_ether.h>
 9#include <linux/if_packet.h>
10#include <linux/ip.h>
11#include <linux/ipv6.h>
12#include <netinet/tcp.h>
13#include <bpf/bpf_endian.h>
14
15#define MAGIC_VAL 0x1234
16#define NUM_ITER 100000
17#define VIP_NUM 5
18#define MAGIC_BYTES 123
19
20struct network_helper_opts {
21	const char *cc;
22	int timeout_ms;
23	bool must_fail;
24};
25
26/* ipv4 test vector */
27struct ipv4_packet {
28	struct ethhdr eth;
29	struct iphdr iph;
30	struct tcphdr tcp;
31} __packed;
32extern struct ipv4_packet pkt_v4;
33
34/* ipv6 test vector */
35struct ipv6_packet {
36	struct ethhdr eth;
37	struct ipv6hdr iph;
38	struct tcphdr tcp;
39} __packed;
40extern struct ipv6_packet pkt_v6;
41
42int settimeo(int fd, int timeout_ms);
43int start_server(int family, int type, const char *addr, __u16 port,
44		 int timeout_ms);
45int start_mptcp_server(int family, const char *addr, __u16 port,
46		       int timeout_ms);
47int *start_reuseport_server(int family, int type, const char *addr_str,
48			    __u16 port, int timeout_ms,
49			    unsigned int nr_listens);
50void free_fds(int *fds, unsigned int nr_close_fds);
51int connect_to_fd(int server_fd, int timeout_ms);
52int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts);
53int connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms);
54int fastopen_connect(int server_fd, const char *data, unsigned int data_len,
55		     int timeout_ms);
56int make_sockaddr(int family, const char *addr_str, __u16 port,
57		  struct sockaddr_storage *addr, socklen_t *len);
58char *ping_command(int family);
59
60struct nstoken;
61/**
62 * open_netns() - Switch to specified network namespace by name.
63 *
64 * Returns token with which to restore the original namespace
65 * using close_netns().
66 */
67struct nstoken *open_netns(const char *name);
68void close_netns(struct nstoken *token);
69#endif