Home | History | Annotate | Download | only in libnetutils

Lines Matching refs:packet

164     } packet;
170 nread = read(s, &packet, sizeof(packet));
175 * The raw packet interface gives us all packets received by the
182 LOGD("Packet is too small (%d) to be a UDP datagram", nread);
184 } else if (packet.ip.version != IPVERSION || packet.ip.ihl != (sizeof(packet.ip) >> 2)) {
186 LOGD("Not a valid IP packet");
188 } else if (nread < ntohs(packet.ip.tot_len)) {
190 LOGD("Packet was truncated (read %d, needed %d)", nread, ntohs(packet.ip.tot_len));
192 } else if (packet.ip.protocol != IPPROTO_UDP) {
194 LOGD("IP protocol (%d) is not UDP", packet.ip.protocol);
196 } else if (packet.udp.dest != htons(PORT_BOOTP_CLIENT)) {
198 LOGD("UDP dest port (%d) is not DHCP client", ntohs(packet.udp.dest));
208 /* Seems like it's probably a valid DHCP packet */
210 sum = finish_sum(checksum(&packet.ip, sizeof(packet.ip), 0));
212 LOGW("IP header checksum failure (0x%x)", packet.ip.check);
220 dhcp_size = ntohs(packet.udp.len) - sizeof(packet.udp);
221 saddr = packet.ip.saddr;
222 daddr = packet.ip.daddr;
223 nread = ntohs(packet.ip.tot_len);
224 memset(&packet.ip, 0, sizeof(packet.ip));
225 packet.ip.saddr = saddr;
226 packet.ip.daddr = daddr;
227 packet.ip.protocol = IPPROTO_UDP;
228 packet.ip.tot_len = packet.udp.len;
229 temp = packet.udp.check;
230 packet.udp.check = 0;
231 sum = finish_sum(checksum(&packet, nread, 0));
232 packet.udp.check = temp;
237 memcpy(msg, &packet.dhcp, dhcp_size);