Lines Matching refs:ip
77 send_ip(int nfd, int mtu, ip_t *ip, struct in_addr gwip, int frag) in send_ip() argument
112 bcopy((char *)ip, (char *)&ipsv, sizeof(*ip)); in send_ip()
114 iplen = ip->ip_len; in send_ip()
115 ip->ip_len = htons(iplen); in send_ip()
117 if (!IP_V(ip)) in send_ip()
118 IP_V_A(ip, IPVERSION); in send_ip()
119 if (!ip->ip_id) in send_ip()
120 ip->ip_id = htons(id++); in send_ip()
121 if (!ip->ip_ttl) in send_ip()
122 ip->ip_ttl = 60; in send_ip()
125 if (ip->ip_src.s_addr != local_ip.s_addr) { in send_ip()
126 (void) arp((char *)&ip->ip_src, (char *) &local_arp); in send_ip()
128 local_ip = ip->ip_src; in send_ip()
134 ip->ip_sum = 0; in send_ip()
135 ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2); in send_ip()
137 bcopy((char *)ip, ipbuf + sizeof(*eh), iplen); in send_ip()
152 hlen = IP_HL(ip) << 2; in send_ip()
159 ol = (IP_HL(ip) << 2) - sizeof(*ip); in send_ip()
160 for (i = 0, s = (char*)(ip + 1); ol > 0; ) in send_ip()
190 s = (char *)ip + hlen; in send_ip()
191 iplen = ntohs(ip->ip_len) - hlen; in send_ip()
192 ip->ip_off |= htons(IP_MF); in send_ip()
198 ip->ip_off ^= htons(IP_MF); in send_ip()
203 ip->ip_off &= htons(0xe000); in send_ip()
204 ip->ip_off |= htons(sent >> 3); in send_ip()
206 ip->ip_len = htons(ts); in send_ip()
207 ip->ip_sum = 0; in send_ip()
208 ip->ip_sum = chksum((u_short *)ip, hlen); in send_ip()
209 bcopy((char *)ip, ipbuf + sizeof(*eh), hlen); in send_ip()
215 if (!(ntohs(ip->ip_off) & IP_MF)) in send_ip()
217 else if (!(ip->ip_off & htons(0x1fff))) in send_ip()
219 hlen = i + sizeof(*ip); in send_ip()
220 IP_HL_A(ip, (sizeof(*ip) + i) >> 2); in send_ip()
221 bcopy(optcpy, (char *)(ip + 1), i); in send_ip()
226 bcopy((char *)&ipsv, (char *)ip, sizeof(*ip)); in send_ip()
235 send_tcp(int nfd, int mtu, ip_t *ip, struct in_addr gwip) in send_tcp() argument
243 iplen = ip->ip_len; in send_tcp()
244 hlen = IP_HL(ip) << 2; in send_tcp()
245 t = (tcphdr_t *)((char *)ip + hlen); in send_tcp()
246 ip2 = (struct ip *)lbuf; in send_tcp()
252 ip->ip_p = IPPROTO_TCP; in send_tcp()
253 ip2->ip_p = ip->ip_p; in send_tcp()
254 ip2->ip_src = ip->ip_src; in send_tcp()
255 ip2->ip_dst = ip->ip_dst; in send_tcp()
256 bcopy((char *)ip + hlen, (char *)t2, thlen); in send_tcp()
264 if ((t2->th_flags == TH_SYN) && !ntohs(ip->ip_off) && in send_tcp()
267 bcopy((char *)ip + hlen + thlen, (char *)ip + hlen + thlen + 4, in send_tcp()
273 ip->ip_len = hlen + thlen; in send_tcp()
277 bcopy((char *)t2, (char *)ip + hlen, thlen); in send_tcp()
278 return (send_ip(nfd, mtu, ip, gwip, 1)); in send_tcp()
286 send_udp(int nfd, int mtu, ip_t *ip, struct in_addr gwip) in send_udp() argument
295 ti->ti_pr = ip->ip_p; in send_udp()
296 ti->ti_src = ip->ip_src; in send_udp()
297 ti->ti_dst = ip->ip_dst; in send_udp()
298 bcopy((char *)ip + (IP_HL(ip) << 2), in send_udp()
302 ip->ip_len = (IP_HL(ip) << 2) + thlen; in send_udp()
307 (char *)ip + (IP_HL(ip) << 2), sizeof(udphdr_t)); in send_udp()
308 return (send_ip(nfd, mtu, ip, gwip, 1)); in send_udp()
316 send_icmp(int nfd, int mtu, ip_t *ip, in_addr gwip) in send_icmp() argument
320 ic = (struct icmp *)((char *)ip + (IP_HL(ip) << 2)); in send_icmp()
325 return (send_ip(nfd, mtu, ip, gwip, 1)); in send_icmp()
330 send_packet(int nfd, int mtu, ip_t *ip, struct in_addr gwip)
332 ip_t *ip; variable
335 switch (ip->ip_p)
338 ( return send_tcp(nfd, mtu, ip, gwip));
340 ( return send_udp(nfd, mtu, ip, gwip));
342 ( return send_icmp(nfd, mtu, ip, gwip));
344 ( return send_ip(nfd, mtu, ip, gwip, 1));