Lines Matching refs:ip
158 * ip here is ip header + 64bytes readed from ICMP packet
161 icmp_find_original_mbuf(PNATState pData, struct ip *ip)
164 struct ip *ip0;
182 LogFlowFunc(("ENTER: ip->ip_p:%d\n", ip->ip_p));
183 switch (ip->ip_p)
186 icp = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
190 ip0 = mtod(m0, struct ip *);
209 if ( ( (icp->icmp_type != ICMP_ECHO && ip->ip_src.s_addr == ip0->ip_dst.s_addr)
210 || (icp->icmp_type == ICMP_ECHO && ip->ip_dst.s_addr == ip0->ip_dst.s_addr))
228 udp = (struct udphdr *)((char *)ip + (ip->ip_hl << 2));
229 faddr.s_addr = ip->ip_dst.s_addr;
238 tcp = (struct tcphdr *)((char *)ip + (ip->ip_hl << 2));
240 faddr.s_addr = ip->ip_dst.s_addr;
269 Log(("NAT:ICMP: unsupported protocol(%d)\n", ip->ip_p));
343 struct ip *ip;
344 ip = mtod(m, struct ip *);
345 Assert(ip->ip_p == IPPROTO_ICMP);
363 register struct ip *ip = mtod(m, struct ip *);
364 int icmplen = ip->ip_len;
408 ip->ip_len += hlen; /* since ip_input subtracts this */
409 dst = ip->ip_dst.s_addr;
417 ip->ip_dst.s_addr = ip->ip_src.s_addr;
418 ip->ip_src.s_addr = dst;
435 if ((ip->ip_dst.s_addr & RT_H2N_U32(pData->netmask)) == pData->special_addr.s_addr)
438 switch (RT_N2H_U32(ip->ip_dst.s_addr) & ~pData->netmask)
448 addr.sin_addr.s_addr = ip->ip_dst.s_addr;
471 ttl = ip->ip_ttl;
537 * It is reported as the bad ip packet. The header should
543 * so the largest possible datagram is 14 (ethernet) + 20 (ip) +
544 * 8 (icmp) + 60 (max original ip with options) + 8 (original payload)
554 struct ip *oip, *ip;
571 oip = mtod(msrc, struct ip *);
581 AssertStmt(ohlen >= sizeof(struct ip), goto end_error);
609 ip = mtod(m, struct ip *);
610 m->m_pkthdr.header = (void *)ip;
612 /* fill in ip (ip_output0() does the boilerplate for us) */
613 ip->ip_tos = ((oip->ip_tos & 0x1E) | 0xC0); /* high priority for errors */
614 /* ip->ip_len will be set later */
615 ip->ip_off = 0;
616 ip->ip_ttl = MAXTTL;
617 ip->ip_p = IPPROTO_ICMP;
618 ip->ip_src = alias_addr;
619 ip->ip_dst = oip->ip_src;
622 icp = (struct icmp *)((char *)ip + sizeof(*ip));
628 /* fill in icmp payload: original ip header plus 8 bytes of its payload */
641 /* hide ip header for icmp checksum calculation */
642 m->m_data += sizeof(struct ip);
648 /* reveal ip header */
649 m->m_data -= sizeof(struct ip);
650 m->m_len += sizeof(struct ip);
651 ip->ip_len = m->m_len;
682 * Reflect the ip packet back to the source
688 register struct ip *ip = mtod(m, struct ip *);
689 int hlen = ip->ip_hl << 2;
694 * Send an icmp packet back to the ip level,
702 icp->icmp_cksum = cksum(m, ip->ip_len - hlen);