18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __NETWORK_HELPERS_H 38c2ecf20Sopenharmony_ci#define __NETWORK_HELPERS_H 48c2ecf20Sopenharmony_ci#include <sys/socket.h> 58c2ecf20Sopenharmony_ci#include <sys/types.h> 68c2ecf20Sopenharmony_ci#include <linux/types.h> 78c2ecf20Sopenharmony_citypedef __u16 __sum16; 88c2ecf20Sopenharmony_ci#include <linux/if_ether.h> 98c2ecf20Sopenharmony_ci#include <linux/if_packet.h> 108c2ecf20Sopenharmony_ci#include <linux/ip.h> 118c2ecf20Sopenharmony_ci#include <linux/ipv6.h> 128c2ecf20Sopenharmony_ci#include <netinet/tcp.h> 138c2ecf20Sopenharmony_ci#include <bpf/bpf_endian.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define MAGIC_VAL 0x1234 168c2ecf20Sopenharmony_ci#define NUM_ITER 100000 178c2ecf20Sopenharmony_ci#define VIP_NUM 5 188c2ecf20Sopenharmony_ci#define MAGIC_BYTES 123 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* ipv4 test vector */ 218c2ecf20Sopenharmony_cistruct ipv4_packet { 228c2ecf20Sopenharmony_ci struct ethhdr eth; 238c2ecf20Sopenharmony_ci struct iphdr iph; 248c2ecf20Sopenharmony_ci struct tcphdr tcp; 258c2ecf20Sopenharmony_ci} __packed; 268c2ecf20Sopenharmony_ciextern struct ipv4_packet pkt_v4; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* ipv6 test vector */ 298c2ecf20Sopenharmony_cistruct ipv6_packet { 308c2ecf20Sopenharmony_ci struct ethhdr eth; 318c2ecf20Sopenharmony_ci struct ipv6hdr iph; 328c2ecf20Sopenharmony_ci struct tcphdr tcp; 338c2ecf20Sopenharmony_ci} __packed; 348c2ecf20Sopenharmony_ciextern struct ipv6_packet pkt_v6; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciint start_server(int family, int type, const char *addr, __u16 port, 378c2ecf20Sopenharmony_ci int timeout_ms); 388c2ecf20Sopenharmony_ciint connect_to_fd(int server_fd, int timeout_ms); 398c2ecf20Sopenharmony_ciint connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms); 408c2ecf20Sopenharmony_ciint fastopen_connect(int server_fd, const char *data, unsigned int data_len, 418c2ecf20Sopenharmony_ci int timeout_ms); 428c2ecf20Sopenharmony_ciint make_sockaddr(int family, const char *addr_str, __u16 port, 438c2ecf20Sopenharmony_ci struct sockaddr_storage *addr, socklen_t *len); 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#endif 46