38 const uint8_t *p = (uint8_t *)(
dhcp + 1);
41 for (
i = 0;
i < optlen; ++
i)
43 const uint8_t type = p[
i];
44 const int room = optlen -
i;
67 const int len = p[
i + 1];
78 uint8_t *p = (uint8_t *)(
dhcp + 1);
82 for (
i = 0;
i < optlen;)
84 const uint8_t type = p[
i];
85 const int room = optlen -
i;
98 const int len = p[
i + 1];
99 if (len <= (room - 2))
102 if (!ret && len >= 4 && (len & 3) == 0)
104 memcpy(&ret, p +
i + 2, 4);
109 uint8_t *dest = p +
i;
110 const int owlen = len + 2;
111 uint8_t *src = dest + owlen;
112 uint8_t *end = p + optlen;
113 const int movlen = end - src;
116 memmove(dest, src, movlen);
118 memset(end - owlen,
DHCP_PAD, owlen);
135 const int len = p[
i + 1];
168 AF_INET, (uint8_t *)&df->
udp,
static void gc_free(struct gc_arena *a)
static struct gc_arena gc_new(void)
in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf)
static in_addr_t do_extract(struct dhcp *dhcp, int optlen)
static int get_dhcp_message_type(const struct dhcp *dhcp, const int optlen)
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.
#define OPENVPN_IPPROTO_UDP
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)
Wrapper structure for dynamically allocated memory.
struct openvpn_udphdr udp
Garbage collection arena used to keep track of dynamically allocated memory.