Lines Matching refs:ip
65 _sendip(struct iodesc *d, struct ip *ip, size_t len) in _sendip() argument
69 if (ip->ip_dst.s_addr == INADDR_BROADCAST || ip->ip_src.s_addr == 0 || in _sendip()
70 netmask == 0 || SAMENET(ip->ip_src, ip->ip_dst, netmask)) { in _sendip()
71 ea = arpwhohas(d, ip->ip_dst); in _sendip()
76 return sendether(d, ip, len, ea, ETHERTYPE_IP); in _sendip()
87 struct ip *ip; in sendip() local
89 ip = (struct ip *)pkt - 1; in sendip()
90 len += sizeof(*ip); in sendip()
92 memset(ip, 0, sizeof(*ip)); in sendip()
94 ip->ip_v = IPVERSION; in sendip()
95 ip->ip_hl = sizeof(*ip) >> 2; in sendip()
96 ip->ip_len = htons(len); in sendip()
97 ip->ip_p = proto; in sendip()
98 ip->ip_ttl = IPDEFTTL; in sendip()
99 ip->ip_src = d->myip; in sendip()
100 ip->ip_dst = d->destip; in sendip()
101 ip->ip_sum = ip_cksum(ip, sizeof(*ip)); in sendip()
103 cc = _sendip(d, ip, len); in sendip()
109 return (cc - (sizeof(*ip))); in sendip()
125 struct ip *ip; in readip() local
128 ip = (struct ip *)pkt - 1; in readip()
130 n = readether(d, ip, len + sizeof(*ip), tleft, &etype); in readip()
131 if (n == -1 || (size_t)n < sizeof(*ip)) in readip()
135 struct arphdr *ah = (void *)ip; in readip()
149 if (ip->ip_v != IPVERSION || ip->ip_p != proto) { in readip()
153 hlen = ip->ip_hl << 2; in readip()
154 if (hlen != sizeof(*ip) || ip_cksum(ip, hlen) != 0) { in readip()
157 if (ntohs(ip->ip_len) < hlen) { in readip()
160 if (n < ntohs(ip->ip_len)) { in readip()
163 if (d->myip.s_addr && ip->ip_dst.s_addr != d->myip.s_addr) { in readip()
167 return (ntohs(ip->ip_len) - hlen); in readip()