struct network_helper_opts { int timeout_ms; int proto; /* +ve: Passed to listen() as-is. * 0: Default when the test does not set * a particular value during the struct init. * It is changed to 1 before passing to listen(). * Most tests only have one on-going connection. * -ve: It is changed to 0 before passing to listen(). * It is useful to force syncookie without * changing the "tcp_syncookies" sysctl from 1 to 2.
*/ int backlog; int (*post_socket_cb)(int fd, void *opts); void *cb_opts;
};
int settimeo(int fd, int timeout_ms); int start_server_str(int family, int type, constchar *addr_str, __u16 port, conststruct network_helper_opts *opts); int start_server(int family, int type, constchar *addr, __u16 port, int timeout_ms); int *start_reuseport_server(int family, int type, constchar *addr_str,
__u16 port, int timeout_ms, unsignedint nr_listens); int start_server_addr(int type, conststruct sockaddr_storage *addr, socklen_t len, conststruct network_helper_opts *opts); void free_fds(int *fds, unsignedint nr_close_fds); int client_socket(int family, int type, conststruct network_helper_opts *opts); int connect_to_addr(int type, conststruct sockaddr_storage *addr, socklen_t len, conststruct network_helper_opts *opts); int connect_to_addr_str(int family, int type, constchar *addr_str, __u16 port, conststruct network_helper_opts *opts); int connect_to_fd(int server_fd, int timeout_ms); int connect_to_fd_opts(int server_fd, conststruct network_helper_opts *opts); int connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms); int fastopen_connect(int server_fd, constchar *data, unsignedint data_len, int timeout_ms); int make_sockaddr(int family, constchar *addr_str, __u16 port, struct sockaddr_storage *addr, socklen_t *len); char *ping_command(int family); int get_socket_local_port(int sock_fd); int get_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param); int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param);
int open_tuntap(constchar *dev_name, bool need_mac);
struct nstoken; /** * open_netns() - Switch to specified network namespace by name. * * Returns token with which to restore the original namespace * using close_netns().
*/ struct nstoken *open_netns(constchar *name); void close_netns(struct nstoken *token); int send_recv_data(int lfd, int fd, uint32_t total_bytes); int make_netns(constchar *name); int remove_netns(constchar *name);
/** * append_tid() - Append thread ID to the given string. * * @str: string to extend * @sz: string's size * * 8 characters are used to append the thread ID (7 digits + '\0') * * Returns -1 on errors, 0 otherwise
*/ int append_tid(char *str, size_t sz);
iph->check = 0;
p = (void *)iph;
sum = csum_partial(p, iph->ihl << 2, 0);
return csum_fold(sum);
}
/** * csum_tcpudp_magic - compute IP pseudo-header checksum * * Compute the IPv4 pseudo header checksum. The helper can take a * accumulated sum from the transport layer to accumulate it and directly * return the transport layer * * @saddr: IP source address * @daddr: IP dest address * @len: IP data size * @proto: transport layer protocol * @csum: The accumulated partial sum to add to the computation * * Returns the folded sum
*/ staticinline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
__u32 len, __u8 proto,
__wsum csum)
{
__u64 s = csum;
s += (__u32)saddr;
s += (__u32)daddr;
s += htons(proto + len);
s = (s & 0xffffffff) + (s >> 32);
s = (s & 0xffffffff) + (s >> 32);
return csum_fold((__u32)s);
}
/** * csum_ipv6_magic - compute IPv6 pseudo-header checksum * * Compute the ipv6 pseudo header checksum. The helper can take a * accumulated sum from the transport layer to accumulate it and directly * return the transport layer * * @saddr: IPv6 source address * @daddr: IPv6 dest address * @len: IPv6 data size * @proto: transport layer protocol * @csum: The accumulated partial sum to add to the computation * * Returns the folded sum
*/ staticinline __sum16 csum_ipv6_magic(conststruct in6_addr *saddr, conststruct in6_addr *daddr,
__u32 len, __u8 proto,
__wsum csum)
{
__u64 s = csum; int i;
for (i = 0; i < 4; i++)
s += (__u32)saddr->s6_addr32[i]; for (i = 0; i < 4; i++)
s += (__u32)daddr->s6_addr32[i];
s += htons(proto + len);
s = (s & 0xffffffff) + (s >> 32);
s = (s & 0xffffffff) + (s >> 32);
return csum_fold((__u32)s);
}
/** * build_udp_v4_csum - compute UDP checksum for UDP over IPv4 * * Compute the checksum to embed in UDP header, composed of the sum of IP * pseudo-header checksum, UDP header checksum and UDP data checksum * @iph IP header * @udph UDP header, which must be immediately followed by UDP data * * Returns the total checksum
*/
/** * build_udp_v6_csum - compute UDP checksum for UDP over IPv6 * * Compute the checksum to embed in UDP header, composed of the sum of IPv6 * pseudo-header checksum, UDP header checksum and UDP data checksum * @ip6h IPv6 header * @udph UDP header, which must be immediately followed by UDP data * * Returns the total checksum
*/ staticinline __sum16 build_udp_v6_csum(conststruct ipv6hdr *ip6h, conststruct udphdr *udph)
{ unsignedlong sum;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.