Lines Matching refs:ip

99 static void do_icmp(ip, args)  in do_icmp()  argument
100 ip_t *ip; in do_icmp()
106 ip->ip_p = IPPROTO_ICMP;
107 ip->ip_len += sizeof(*ic);
108 ic = (struct icmp *)(ip + 1);
150 int send_packets(dev, mtu, ip, gwip) in send_packets() argument
153 ip_t *ip;
161 return send_packet(wfd, mtu, ip, gwip);
165 udpcksum(ip_t *ip, struct udphdr *udp, int len) in udpcksum() argument
183 ph.h.src = ip->ip_src.s_addr; in udpcksum()
184 ph.h.dst = ip->ip_dst.s_addr; in udpcksum()
204 ip_t *ip; local
213 ip = (ip_t *)calloc(1, 65536);
214 tcp = (tcphdr_t *)(ip + 1);
216 ip->ip_len = sizeof(*ip);
217 IP_HL_A(ip, sizeof(*ip) >> 2);
224 if (ip->ip_p)
227 ip->ip_p);
230 do_icmp(ip, optarg);
252 if (ip->ip_p)
255 ip->ip_p);
259 ip->ip_p = p->p_proto;
267 if (ip->ip_p)
270 ip->ip_p);
273 ip->ip_p = IPPROTO_TCP;
274 ip->ip_len += sizeof(tcphdr_t);
278 if (ip->ip_p)
281 ip->ip_p);
284 ip->ip_p = IPPROTO_UDP;
285 ip->ip_len += sizeof(udphdr_t);
292 ip->ip_off = strtol(optarg, NULL, 0);
313 olen = buildopts(optarg, options, (IP_HL(ip) - 5) << 2);
321 if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP)
329 if (ip->ip_p == IPPROTO_TCP)
350 if (resolve(src, (char *)&ip->ip_src) == -1)
356 if (resolve(dst, (char *)&ip->ip_dst) == -1)
363 gwip = ip->ip_dst;
376 hlen = sizeof(*ip) + olen;
377 IP_HL_A(ip, hlen >> 2);
378 ip->ip_len += olen;
386 bcopy(ip, p, sizeof(*ip));
387 bcopy(options, p + sizeof(*ip), olen);
388 bcopy(ip + 1, p + hlen, ip->ip_len - hlen);
389 ip = (ip_t *)p;
391 if (ip->ip_p == IPPROTO_TCP) {
393 } else if (ip->ip_p == IPPROTO_UDP) {
398 if (ip->ip_p == IPPROTO_TCP)
425 printf("Source: %s\n", inet_ntoa(ip->ip_src));
426 printf("Dest: %s\n", inet_ntoa(ip->ip_dst));
428 if (ip->ip_p == IPPROTO_TCP && tcp->th_flags)
432 if (ip->ip_p == IPPROTO_UDP) {
434 udpcksum(ip, udp, ip->ip_len - (IP_HL(ip) << 2));
437 if (ip->ip_p == IPPROTO_TCP && tcp->th_dport)
438 return do_socket(dev, mtu, ip, gwip);
440 return send_packets(dev, mtu, ip, gwip);