opnsense-src/tests/sys/netinet/libalias/util.h
Lutz Donnerhacke c1fbb54f4b test/libalias: Tests for outgoing NAT
Testing LibAliasOut functionality. This concentrates the typical use
case of initiating data transfers from the inside.  Provide a
exhaustive test for the data structure in order to check for
performance improvements.

Reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30335
2021-05-21 11:45:52 +02:00

29 lines
594 B
C

#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
#ifndef _UTIL_H
#define _UTIL_H
int randcmp(const void *a, const void *b);
void hexdump(void *p, size_t len);
struct ip * ip_packet(struct in_addr src, struct in_addr dst, u_char protocol, size_t len);
struct udphdr * set_udp(struct ip *p, u_short sport, u_short dport);
inline int
addr_eq(struct in_addr a, struct in_addr b)
{
return a.s_addr == b.s_addr;
}
#define a2h(a) ntohl(a.s_addr)
inline int
rand_range(int min, int max)
{
return min + rand()%(max - min);
}
#endif /* _UTIL_H */