Lines Matching refs:ip

81 send_ip(int nfd, int mtu, ip_t *ip, struct in_addr gwip, int frag)  in send_ip()  argument
116 bcopy((char *)ip, (char *)&ipsv, sizeof(*ip)); in send_ip()
118 iplen = ip->ip_len; in send_ip()
119 ip->ip_len = htons(iplen); in send_ip()
121 if (!IP_V(ip)) in send_ip()
122 IP_V_A(ip, IPVERSION); in send_ip()
123 if (!ip->ip_id) in send_ip()
124 ip->ip_id = htons(id++); in send_ip()
125 if (!ip->ip_ttl) in send_ip()
126 ip->ip_ttl = 60; in send_ip()
129 if (ip->ip_src.s_addr != local_ip.s_addr) { in send_ip()
130 (void) arp((char *)&ip->ip_src, (char *) &local_arp); in send_ip()
132 local_ip = ip->ip_src; in send_ip()
138 ip->ip_sum = 0; in send_ip()
139 ip->ip_sum = chksum((u_short *)ip, IP_HL(ip) << 2); in send_ip()
141 bcopy((char *)ip, ipbuf + sizeof(*eh), iplen); in send_ip()
156 hlen = IP_HL(ip) << 2; in send_ip()
163 ol = (IP_HL(ip) << 2) - sizeof(*ip); in send_ip()
164 for (i = 0, s = (char*)(ip + 1); ol > 0; ) in send_ip()
194 s = (char *)ip + hlen; in send_ip()
195 iplen = ntohs(ip->ip_len) - hlen; in send_ip()
196 ip->ip_off |= htons(IP_MF); in send_ip()
202 ip->ip_off ^= htons(IP_MF); in send_ip()
207 ip->ip_off &= htons(0xe000); in send_ip()
208 ip->ip_off |= htons(sent >> 3); in send_ip()
210 ip->ip_len = htons(ts); in send_ip()
211 ip->ip_sum = 0; in send_ip()
212 ip->ip_sum = chksum((u_short *)ip, hlen); in send_ip()
213 bcopy((char *)ip, ipbuf + sizeof(*eh), hlen); in send_ip()
219 if (!(ntohs(ip->ip_off) & IP_MF)) in send_ip()
221 else if (!(ip->ip_off & htons(0x1fff))) in send_ip()
223 hlen = i + sizeof(*ip); in send_ip()
224 IP_HL_A(ip, (sizeof(*ip) + i) >> 2); in send_ip()
225 bcopy(optcpy, (char *)(ip + 1), i); in send_ip()
230 bcopy((char *)&ipsv, (char *)ip, sizeof(*ip)); in send_ip()
239 send_tcp(int nfd, int mtu, ip_t *ip, struct in_addr gwip) in send_tcp() argument
247 iplen = ip->ip_len; in send_tcp()
248 hlen = IP_HL(ip) << 2; in send_tcp()
249 t = (tcphdr_t *)((char *)ip + hlen); in send_tcp()
250 ip2 = (struct ip *)lbuf; in send_tcp()
256 ip->ip_p = IPPROTO_TCP; in send_tcp()
257 ip2->ip_p = ip->ip_p; in send_tcp()
258 ip2->ip_src = ip->ip_src; in send_tcp()
259 ip2->ip_dst = ip->ip_dst; in send_tcp()
260 bcopy((char *)ip + hlen, (char *)t2, thlen); in send_tcp()
268 if ((t2->th_flags == TH_SYN) && !ntohs(ip->ip_off) && in send_tcp()
271 bcopy((char *)ip + hlen + thlen, (char *)ip + hlen + thlen + 4, in send_tcp()
277 ip->ip_len = hlen + thlen; in send_tcp()
281 bcopy((char *)t2, (char *)ip + hlen, thlen); in send_tcp()
282 return (send_ip(nfd, mtu, ip, gwip, 1)); in send_tcp()
290 send_udp(int nfd, int mtu, ip_t *ip, struct in_addr gwip) in send_udp() argument
299 ti->ti_pr = ip->ip_p; in send_udp()
300 ti->ti_src = ip->ip_src; in send_udp()
301 ti->ti_dst = ip->ip_dst; in send_udp()
302 bcopy((char *)ip + (IP_HL(ip) << 2), in send_udp()
306 ip->ip_len = (IP_HL(ip) << 2) + thlen; in send_udp()
311 (char *)ip + (IP_HL(ip) << 2), sizeof(udphdr_t)); in send_udp()
312 return (send_ip(nfd, mtu, ip, gwip, 1)); in send_udp()
320 send_icmp(int nfd, int mtu, ip_t *ip, in_addr gwip) in send_icmp() argument
324 ic = (struct icmp *)((char *)ip + (IP_HL(ip) << 2)); in send_icmp()
329 return (send_ip(nfd, mtu, ip, gwip, 1)); in send_icmp()
334 send_packet(int nfd, int mtu, ip_t *ip, struct in_addr gwip)
336 ip_t *ip; variable
339 switch (ip->ip_p)
342 ( return send_tcp(nfd, mtu, ip, gwip));
344 ( return send_udp(nfd, mtu, ip, gwip));
346 ( return send_icmp(nfd, mtu, ip, gwip));
348 ( return send_ip(nfd, mtu, ip, gwip, 1));