Lines Matching refs:len
56 uint16_t dhcp_packet_checksum(uint8_t *buf, size_t len) {
58 uint64_t *end_64 = buf_64 + (len / sizeof(uint64_t));
72 if (len % sizeof(uint64_t)) {
77 memcpy(&buf_tail, buf_64, len % sizeof(uint64_t));
93 uint16_t destination_port, uint16_t len) {
96 packet->ip.tot_len = htobe16(len);
107 packet->udp.len = htobe16(len - DHCP_IP_SIZE);
109 packet->ip.check = packet->udp.len;
110 packet->udp.check = dhcp_packet_checksum((uint8_t*)&packet->ip.ttl, len - 8);
117 int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum) {
142 if (len < hdrlen) {
144 "smaller than expected (%zu) by IP header", len,
156 if (len < hdrlen + be16toh(packet->udp.len)) {
158 "smaller than expected (%zu) by UDP header", len,
159 hdrlen + be16toh(packet->udp.len));
180 packet->ip.check = packet->udp.len;
184 be16toh(packet->udp.len) + 12)) {