packet.udp.source = htons(source_port);
packet.udp.dest = htons(dest_port);
- /* size, excluding IP header: */
packet.udp.source = htons(source_port);
packet.udp.dest = htons(dest_port);
- /* size, excluding IP header: */
- /* for UDP checksumming, ip.len is set to UDP packet len */
+ p_len += sizeof(packet.udp);
+ packet.udp.len = htons(p_len);
packet.ip.tot_len = packet.udp.len;
- /* for UDP checksumming, ip.len is set to UDP packet len */
+ p_len += sizeof(packet.udp);
+ packet.udp.len = htons(p_len);
packet.ip.tot_len = packet.udp.len;
+ p_len += sizeof(packet.ip);
+ packet.udp.check = udhcp_checksum(&packet, p_len);
+ packet.ip.tot_len = htons(p_len);
+ p_len += sizeof(packet.ip);
+ packet.udp.check = udhcp_checksum(&packet, p_len);
+ packet.ip.tot_len = htons(p_len);
packet.ip.check = udhcp_checksum(&packet.ip, sizeof(packet.ip));
udhcp_dump_packet(dhcp_pkt);
packet.ip.check = udhcp_checksum(&packet.ip, sizeof(packet.ip));
udhcp_dump_packet(dhcp_pkt);
-- result = sendto(fd, &packet, IP_UPD_DHCP_SIZE - padding, /*flags:*/ 0,
+- result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0,
+ result = sendto(fd, &packet, p_len, /*flags:*/ 0,
(struct sockaddr *) &dest_sll, sizeof(dest_sll));
msg = "sendto";
+ result = sendto(fd, &packet, p_len, /*flags:*/ 0,
(struct sockaddr *) &dest_sll, sizeof(dest_sll));
msg = "sendto";