Home | History | Annotate | Download | only in libnetutils

Lines Matching defs:ip

22 #include <netinet/ip.h>
92 struct iphdr ip;
100 ip.version = IPVERSION;
101 ip.ihl = sizeof(ip) >> 2;
102 ip.tos = 0;
103 ip.tot_len = htons(sizeof(ip) + sizeof(udp) + size);
104 ip.id = 0;
105 ip.frag_off = 0;
106 ip.ttl = IPDEFTTL;
107 ip.protocol = IPPROTO_UDP;
108 ip.check = 0;
109 ip.saddr = saddr;
110 ip.daddr = daddr;
111 ip.check = finish_sum(checksum(&ip, sizeof(ip), 0));
119 udpsum = checksum(&ip.saddr, sizeof(ip.saddr), 0);
120 udpsum = checksum(&ip.daddr, sizeof(ip.daddr), udpsum);
133 iov[0].iov_base = (char *)&ip;
134 iov[0].iov_len = sizeof(ip);
161 struct iphdr ip;
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);
209 /* validate IP header checksum */
210 sum = finish_sum(checksum(&packet.ip, sizeof(packet.ip), 0));
212 LOGW("IP header checksum failure (0x%x)", packet.ip.check);
217 * Since we don't need the IP header anymore, we "borrow" it
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;