43 const uint8_t *src_addr,
const uint8_t *dest_addr,
const int proto)
62#define LONGDOMAIN "a-reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaally-long-domain"
72 const unsigned char output_1[28] =
"\x77\x1a\x07openvpn\x03net\x00\x07openvpn\x03org";
92 const unsigned char output_3[0xEC + 3 + 10 + 7 + 1] =
"\x77\xFF\x09subdomain\xEC" LONGDOMAIN "\x06top123";
98 const unsigned char output_4[0xEC + 3 + 10 + 7 + 1] =
"\x77\xFF\xFDsubdomain-" LONGDOMAIN "-top123";
117 const char output_5[12] =
"\x77\x0a\x03sub\x00\x03tld";
129 const struct CMUnitTest tests[] = {
133 return cmocka_run_group_tests_name(
"dhcp", tests, NULL, NULL);
void buf_clear(struct buffer *buf)
Zeroise and reset a buffer.
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Allocate a buffer of the given size under garbage collection.
static struct buffer clear_buf(void)
Return an empty, undefined struct buffer (all fields zero).
#define BPTR(buf)
Return a pointer to the start of the buffer content.
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
static int buf_forward_capacity_total(const struct buffer *buf)
Return the total number of bytes available from the current offset to the end of the allocated memory...
static void write_dhcp_search_str(struct buffer *buf, const uint8_t type, const char *const *str_array, int array_len, bool *error)
#define DHCP_DOMAIN_SEARCH
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
Garbage collection arena used to keep track of dynamically allocated memory.
unsigned short sa_family_t
static void test_write_dhcp_search_str(void **state)
uint16_t ip_checksum(const sa_family_t af, const uint8_t *payload, const int len_payload, const uint8_t *src_addr, const uint8_t *dest_addr, const int proto)
Calculates an IP or IPv6 checksum with a pseudo header as required by TCP, UDP and ICMPv6.
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)