Lines Matching refs:ip

89 int	send_ip(nfd, mtu, ip, gwip, frag)  in send_ip()  argument
91 ip_t *ip;
128 bcopy((char *)ip, (char *)&ipsv, sizeof(*ip));
130 iplen = ip->ip_len;
131 ip->ip_len = htons(iplen);
133 if (!IP_V(ip))
134 IP_V_A(ip, IPVERSION);
135 if (!ip->ip_id)
136 ip->ip_id = htons(id++);
137 if (!ip->ip_ttl)
138 ip->ip_ttl = 60;
141 if (ip->ip_src.s_addr != local_ip.s_addr) {
142 (void) arp((char *)&ip->ip_src, (char *)A_A local_arp);
144 local_ip = ip->ip_src;
150 ip->ip_sum = 0;
151 ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2);
153 bcopy((char *)ip, ipbuf + sizeof(*eh), iplen);
168 hlen = IP_HL(ip) << 2;
175 ol = (IP_HL(ip) << 2) - sizeof(*ip);
176 for (i = 0, s = (char*)(ip + 1); ol > 0; )
206 s = (char *)ip + hlen;
207 iplen = ntohs(ip->ip_len) - hlen;
208 ip->ip_off |= htons(IP_MF);
214 ip->ip_off ^= htons(IP_MF);
219 ip->ip_off &= htons(0xe000);
220 ip->ip_off |= htons(sent >> 3);
222 ip->ip_len = htons(ts);
223 ip->ip_sum = 0;
224 ip->ip_sum = chksum((u_short *)ip, hlen);
225 bcopy((char *)ip, ipbuf + sizeof(*eh), hlen);
231 if (!(ntohs(ip->ip_off) & IP_MF))
233 else if (!(ip->ip_off & htons(0x1fff)))
235 hlen = i + sizeof(*ip);
236 IP_HL_A(ip, (sizeof(*ip) + i) >> 2);
237 bcopy(optcpy, (char *)(ip + 1), i);
242 bcopy((char *)&ipsv, (char *)ip, sizeof(*ip));
250 int send_tcp(nfd, mtu, ip, gwip) in send_tcp() argument
252 ip_t *ip;
261 iplen = ip->ip_len;
262 hlen = IP_HL(ip) << 2;
263 t = (tcphdr_t *)((char *)ip + hlen);
264 ip2 = (struct ip *)lbuf;
270 ip->ip_p = IPPROTO_TCP;
271 ip2->ip_p = ip->ip_p;
272 ip2->ip_src = ip->ip_src;
273 ip2->ip_dst = ip->ip_dst;
274 bcopy((char *)ip + hlen, (char *)t2, thlen);
282 if ((t2->th_flags == TH_SYN) && !ntohs(ip->ip_off) &&
285 bcopy((char *)ip + hlen + thlen, (char *)ip + hlen + thlen + 4,
291 ip->ip_len = hlen + thlen;
295 bcopy((char *)t2, (char *)ip + hlen, thlen);
296 return send_ip(nfd, mtu, ip, gwip, 1);
303 int send_udp(nfd, mtu, ip, gwip) in send_udp() argument
305 ip_t *ip;
315 ti->ti_pr = ip->ip_p;
316 ti->ti_src = ip->ip_src;
317 ti->ti_dst = ip->ip_dst;
318 bcopy((char *)ip + (IP_HL(ip) << 2),
322 ip->ip_len = (IP_HL(ip) << 2) + thlen;
327 (char *)ip + (IP_HL(ip) << 2), sizeof(udphdr_t));
328 return send_ip(nfd, mtu, ip, gwip, 1);
335 int send_icmp(nfd, mtu, ip, gwip) in send_icmp() argument
337 ip_t *ip;
342 ic = (struct icmp *)((char *)ip + (IP_HL(ip) << 2));
347 return send_ip(nfd, mtu, ip, gwip, 1);
351 int send_packet(nfd, mtu, ip, gwip) in send_packet() argument
353 ip_t *ip;
356 switch (ip->ip_p)
359 return send_tcp(nfd, mtu, ip, gwip);
361 return send_udp(nfd, mtu, ip, gwip);
363 return send_icmp(nfd, mtu, ip, gwip);
365 return send_ip(nfd, mtu, ip, gwip, 1);