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];
75#if defined(__GNUC__) || defined(__clang__)
76#pragma GCC diagnostic push
77#pragma GCC diagnostic ignored "-Wconversion"
83 uint8_t *p = (uint8_t *)(
dhcp + 1);
87 for (
i = 0;
i < optlen;)
89 const uint8_t type = p[
i];
90 const int room = optlen -
i;
103 const int len = p[
i + 1];
104 if (len <= (room - 2))
107 if (!ret && len >= 4 && (len & 3) == 0)
109 memcpy(&ret, p +
i + 2, 4);
114 uint8_t *dest = p +
i;
115 const int owlen = len + 2;
116 uint8_t *src = dest + owlen;
117 uint8_t *end = p + optlen;
118 const int movlen = end - src;
121 memmove(dest, src, movlen);
123 memset(end - owlen,
DHCP_PAD, owlen);
140 const int len = p[
i + 1];
173 AF_INET, (uint8_t *)&df->
udp,
194#if defined(__GNUC__) || defined(__clang__)
195#pragma GCC diagnostic pop
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.