Lines Matching refs:ip
62 struct ip *ipq_hdr;
78 struct ip *ip_hdr;
89 struct ip *ip; in sendip() local
104 ip = (struct ip *)pkt - 1; in sendip()
105 len += sizeof(*ip); in sendip()
107 bzero(ip, sizeof(*ip)); in sendip()
109 ip->ip_v = IPVERSION; /* half-char */ in sendip()
110 ip->ip_hl = sizeof(*ip) >> 2; /* half-char */ in sendip()
111 ip->ip_len = htons(len); in sendip()
112 ip->ip_p = proto; /* char */ in sendip()
113 ip->ip_ttl = IPDEFTTL; /* char */ in sendip()
114 ip->ip_src = d->myip; in sendip()
115 ip->ip_dst = d->destip; in sendip()
116 ip->ip_sum = in_cksum(ip, sizeof(*ip)); /* short, but special */ in sendip()
118 if (ip->ip_dst.s_addr == INADDR_BROADCAST || ip->ip_src.s_addr == 0 || in sendip()
119 netmask == 0 || SAMENET(ip->ip_src, ip->ip_dst, netmask)) in sendip()
120 ea = arpwhohas(d, ip->ip_dst); in sendip()
124 cc = sendether(d, ip, len, ea, ETHERTYPE_IP); in sendip()
129 return (cc - sizeof(*ip)); in sendip()
147 ip_reasm_add(struct ip_reasm *ipr, void *pkt, struct ip *ip) in ip_reasm_add() argument
155 ipq->ipq_hdr = ip; in ip_reasm_add()
160 (ntohs(ip->ip_off) & IP_OFFMASK)) { in ip_reasm_add()
184 struct ip *ip; in readipv4() local
196 ip = NULL; in readipv4()
198 n = readether(d, (void **)&ptr, (void **)&ip, tleft, &etype); in readipv4()
199 if (n == -1 || n < sizeof(*ip) + sizeof(*uh)) { in readipv4()
208 struct arphdr *ah = (void *)ip; in readipv4()
228 if (ip->ip_v != IPVERSION || /* half char */ in readipv4()
229 ip->ip_p != proto) { in readipv4()
233 ip->ip_v, ip->ip_p); in readipv4()
240 hlen = ip->ip_hl << 2; in readipv4()
241 if (hlen < sizeof(*ip) || in readipv4()
242 in_cksum(ip, hlen) != 0) { in readipv4()
250 if (n < ntohs(ip->ip_len)) { in readipv4()
254 (int)n, ntohs(ip->ip_len)); in readipv4()
259 if (d->myip.s_addr && ip->ip_dst.s_addr != d->myip.s_addr) { in readipv4()
263 printf("%s\n", inet_ntoa(ip->ip_dst)); in readipv4()
271 if ((ntohs(ip->ip_off) & IP_MF) == 0 && in readipv4()
272 (ntohs(ip->ip_off) & IP_OFFMASK) == 0) { in readipv4()
273 uh = (struct udphdr *)((uintptr_t)ip + sizeof (*ip)); in readipv4()
275 if (hlen != sizeof(*ip)) { in readipv4()
276 bcopy(((u_char *)ip) + hlen, uh, uh->uh_ulen - hlen); in readipv4()
277 ip->ip_len = htons(sizeof(*ip)); in readipv4()
278 n -= hlen - sizeof(*ip); in readipv4()
281 n = (n > (ntohs(ip->ip_len) - sizeof(*ip))) ? in readipv4()
282 ntohs(ip->ip_len) - sizeof(*ip) : n; in readipv4()
284 *payload = (void *)((uintptr_t)ip + sizeof(*ip)); in readipv4()
289 if (ipr->ip_src.s_addr == ip->ip_src.s_addr && in readipv4()
290 ipr->ip_dst.s_addr == ip->ip_dst.s_addr && in readipv4()
291 ipr->ip_id == ip->ip_id && in readipv4()
292 ipr->ip_proto == ip->ip_p) in readipv4()
303 ipr->ip_src = ip->ip_src; in readipv4()
304 ipr->ip_dst = ip->ip_dst; in readipv4()
305 ipr->ip_id = ip->ip_id; in readipv4()
306 ipr->ip_proto = ip->ip_p; in readipv4()
312 if (ip_reasm_add(ipr, ptr, ip) != 0) { in readipv4()
319 if ((ntohs(ip->ip_off) & IP_MF) == 0) { in readipv4()
320 ipr->ip_total_size = (8 * (ntohs(ip->ip_off) & IP_OFFMASK)); in readipv4()
321 ipr->ip_total_size += n + sizeof (*ip); in readipv4()
368 ipr->ip_hdr = (struct ip *)((uintptr_t)eh + sizeof (*eh)); in readipv4()