39 const uint8_t *p = (uint8_t *) (
dhcp + 1);
42 for (i = 0; i < optlen; ++i)
44 const uint8_t type = p[i];
45 const int room = optlen - i;
68 const int len = p[i+1];
79 uint8_t *p = (uint8_t *) (
dhcp + 1);
83 for (i = 0; i < optlen; )
85 const uint8_t type = p[i];
86 const int room = optlen - i;
99 const int len = p[i+1];
103 if (!ret && len >= 4 && (len & 3) == 0)
105 memcpy(&ret, p+i+2, 4);
110 uint8_t *dest = p + i;
111 const int owlen = len + 2;
112 uint8_t *src = dest + owlen;
113 uint8_t *end = p + optlen;
114 const int movlen = end - src;
117 memmove(dest, src, movlen);
119 memset(end - owlen,
DHCP_PAD, owlen);
136 const int len = p[i+1];
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.