Lines Matching refs:ip

52 #include <netinet/ip.h>
60 /* Caller must leave room for ethernet, ip and udp headers in front!! */
68 struct ip *ip;
85 ip = (struct ip *)uh - 1;
86 len += sizeof(*ip) + sizeof(*uh);
88 bzero(ip, sizeof(*ip) + sizeof(*uh));
90 ip->ip_v = IPVERSION; /* half-char */
91 ip->ip_hl = sizeof(*ip) >> 2; /* half-char */
92 ip->ip_len = htons(len);
93 ip->ip_p = IPPROTO_UDP; /* char */
94 ip->ip_ttl = IPDEFTTL; /* char */
95 ip->ip_src = d->myip;
96 ip->ip_dst = d->destip;
97 ip->ip_sum = in_cksum(ip, sizeof(*ip)); /* short, but special */
101 uh->uh_ulen = htons(len - sizeof(*ip));
106 struct ip tip;
108 /* Calculate checksum (must save and restore ip header) */
109 tip = *ip;
110 ui = (struct udpiphdr *)ip;
114 *ip = tip;
118 if (ip->ip_dst.s_addr == INADDR_BROADCAST || ip->ip_src.s_addr == 0 ||
119 netmask == 0 || SAMENET(ip->ip_src, ip->ip_dst, netmask))
120 ea = arpwhohas(d, ip->ip_dst);
124 cc = sendether(d, ip, len, ea, ETHERTYPE_IP);
129 return (cc - (sizeof(*ip) + sizeof(*uh)));
145 struct ip *ip;
155 ip = (struct ip *)uh - 1;
157 n = readether(d, ip, len + sizeof(*ip) + sizeof(*uh), tleft, &etype);
158 if (n == -1 || n < sizeof(*ip) + sizeof(*uh))
165 struct arphdr *ah = (void *)ip;
181 /* Check ip header */
182 if (ip->ip_v != IPVERSION ||
183 ip->ip_p != IPPROTO_UDP) { /* half char */
186 printf("readudp: IP version or not UDP. ip_v=%d ip_p=%d\n", ip->ip_v, ip->ip_p);
191 hlen = ip->ip_hl << 2;
192 if (hlen < sizeof(*ip) ||
193 in_cksum(ip, hlen) != 0) {
200 if (n < ntohs(ip->ip_len)) {
204 (int)n, ntohs(ip->ip_len));
208 if (d->myip.s_addr && ip->ip_dst.s_addr != d->myip.s_addr) {
212 printf("%s\n", inet_ntoa(ip->ip_dst));
218 /* If there were ip options, make them go away */
219 if (hlen != sizeof(*ip)) {
220 bcopy(((u_char *)ip) + hlen, uh, len - hlen);
221 ip->ip_len = htons(sizeof(*ip));
222 n -= hlen - sizeof(*ip);
236 struct ip tip;
238 n = ntohs(uh->uh_ulen) + sizeof(*ip);
244 /* Check checksum (must save and restore ip header) */
245 tip = *ip;
246 ui = (struct udpiphdr *)ip;
254 *ip = tip;
257 *ip = tip;