Lines Matching refs:ip

104 #include <netinet/ip.h>
414 PE_parse_boot_argn("net.inet.ip.scopedroute",
463 ip_mutex_grp = lck_grp_alloc_init("ip", ip_mutex_grp_attr);
595 struct ip *ip;
618 ip = mtod(m, struct ip *);
619 ip->ip_len = htons(ip->ip_len + hlen);
620 ip->ip_off = htons(ip->ip_off);
621 ip->ip_sum = 0;
622 ip->ip_sum = in_cksum(m, hlen);
649 ip = mtod(m, struct ip *);
652 ip->ip_len = ntohs(ip->ip_len) - hlen;
653 ip->ip_off = ntohs(ip->ip_off);
656 if ((pr_input = ip_protox[ip->ip_p]->pr_input) == NULL) {
658 } else if (!(ip_protox[ip->ip_p]->pr_flags & PR_PROTOLOCK)) {
674 struct ip *ip;
748 ip = mtod(m, struct ip *);
749 hlen = IP_VHL_HL(ip->ip_vhl) << 2;
768 ip = mtod(m, struct ip *);
769 hlen = IP_VHL_HL(ip->ip_vhl) << 2;
772 struct ip *, ip, struct ifnet *, m->m_pkthdr.rcvif,
773 struct ip *, ip, struct ip6_hdr *, NULL);
775 ip->ip_len = ntohs(ip->ip_len) - hlen;
776 ip->ip_off = ntohs(ip->ip_off);
777 ip_proto_dispatch_in(m, hlen, ip->ip_p, inject_filter_ref);
782 if (m->m_pkthdr.len < sizeof(struct ip))
785 if (m->m_len < sizeof (struct ip) &&
786 (m = m_pullup(m, sizeof (struct ip))) == 0) {
790 ip = mtod(m, struct ip *);
792 KERNEL_DEBUG(DBG_LAYER_BEG, ip->ip_dst.s_addr,
793 ip->ip_src.s_addr, ip->ip_p, ip->ip_off, ip->ip_len);
795 if (IP_VHL_V(ip->ip_vhl) != IPVERSION) {
800 hlen = IP_VHL_HL(ip->ip_vhl) << 2;
801 if (hlen < sizeof(struct ip)) { /* minimum header length */
810 ip = mtod(m, struct ip *);
814 if ((ntohl(ip->ip_dst.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET ||
815 (ntohl(ip->ip_src.s_addr) >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET) {
823 if ((IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) ||
824 IN_LINKLOCAL(ntohl(ip->ip_src.s_addr)))) {
826 if (ip->ip_ttl != MAXTTL) {
840 struct ip *, ip, struct ifnet *, m->m_pkthdr.rcvif,
841 struct ip *, ip, struct ip6_hdr *, NULL);
856 ifnet_cached_rtlookup_inet(m->m_pkthdr.rcvif, ip->ip_src);
867 NTOHS(ip->ip_len);
870 if (ip->ip_len < hlen) {
876 NTOHS(ip->ip_off);
884 if (m->m_pkthdr.len < ip->ip_len) {
889 if (m->m_pkthdr.len > ip->ip_len) {
895 m->m_len = ip->ip_len;
896 m->m_pkthdr.len = ip->ip_len;
898 m_adj(m, ip->ip_len - m->m_pkthdr.len);
922 ip = mtod(m, struct ip *);
923 hlen = IP_VHL_HL(ip->ip_vhl) << 2;
960 ip = mtod(m, struct ip *); /* just in case m changed */
1001 if (hlen > sizeof (struct ip) && ip_dooptions(m, 0, args.fwa_next_hop)) {
1003 if (hlen > sizeof (struct ip) && ip_dooptions(m, 0, NULL)) {
1014 if (rsvp_on && ip->ip_p==IPPROTO_RSVP)
1033 ip->ip_dst : args.fwa_next_hop->sin_addr;
1035 pkt_dst = ip->ip_dst;
1112 if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) {
1126 if (ip_mforward && ip_mforward(ip, ifp, m, 0) != 0) {
1138 if (ip->ip_p == IPPROTO_IGMP)
1148 IN_LOOKUP_MULTI(&ip->ip_dst, ifp, inm);
1158 if (ip->ip_dst.s_addr == (u_int32_t)INADDR_BROADCAST)
1160 if (ip->ip_dst.s_addr == INADDR_ANY)
1166 && hlen == sizeof(struct ip)
1167 && ip->ip_p == IPPROTO_UDP) {
1178 ip = mtod(m, struct ip *); /* in case it changed */
1204 if (ip->ip_off & (IP_MF | IP_OFFMASK | IP_RF)) {
1223 if (ip->ip_id == fp->ipq_id &&
1224 ip->ip_src.s_addr == fp->ipq_src.s_addr &&
1225 ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
1226 ip->ip_p == fp->ipq_p) {
1240 sum = IPREASS_HASH(ip->ip_src.s_addr, ip->ip_id);
1246 if (ip->ip_id == fp->ipq_id &&
1247 ip->ip_src.s_addr == fp->ipq_src.s_addr &&
1248 ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
1252 ip->ip_p == fp->ipq_p)
1276 ip->ip_len -= hlen;
1277 if (ip->ip_off & IP_MF) {
1282 if (ip->ip_len == 0 || (ip->ip_len & 0x7) != 0) {
1292 ip->ip_off <<= 3;
1300 m->m_pkthdr.header = ip;
1312 ip = mtod(m, struct ip *);
1314 hlen = IP_VHL_HL(ip->ip_vhl) << 2;
1319 ip->ip_len += hlen;
1322 HTONS(ip->ip_len);
1323 HTONS(ip->ip_off);
1326 ip->ip_sum = 0;
1327 ip->ip_sum = in_cksum(m, hlen);
1330 NTOHS(ip->ip_off);
1331 NTOHS(ip->ip_len);
1334 ip->ip_len -= hlen;
1339 ip->ip_len -= hlen;
1356 ip->ip_len += hlen;
1359 HTONS(ip->ip_len);
1360 HTONS(ip->ip_off);
1371 ip = mtod(m, struct ip *);
1379 * code - like udp/tcp/raw ip.
1381 if (ipsec_bypass == 0 && (ip_protox[ip->ip_p]->pr_flags & PR_LASTHDR) != 0) {
1395 if (args.fwa_next_hop && ip->ip_p == IPPROTO_TCP) {
1412 KERNEL_DEBUG(DBG_LAYER_END, ip->ip_dst.s_addr,
1413 ip->ip_src.s_addr, ip->ip_p, ip->ip_off, ip->ip_len);
1421 ip_proto_dispatch_in(m, hlen, ip->ip_p, 0);
1423 KERNEL_DEBUG(DBG_LAYER_END, ip->ip_dst.s_addr,
1424 ip->ip_src.s_addr, ip->ip_p, ip->ip_off, ip->ip_len);
1426 ip_proto_dispatch_in(m, hlen, ip->ip_p, 0);
1429 if ((sw_lro) && (ip->ip_p == IPPROTO_TCP)) {
1434 ip_proto_dispatch_in(m, hlen, ip->ip_p, 0);
1466 struct ip *ip = mtod(m, struct ip *);
1469 int hlen = IP_VHL_HL(ip->ip_vhl) << 2;
1502 fp->ipq_p = ip->ip_p;
1503 fp->ipq_id = ip->ip_id;
1504 fp->ipq_src = ip->ip_src;
1505 fp->ipq_dst = ip->ip_dst;
1525 #define GETIP(m) ((struct ip*)((m)->m_pkthdr.header))
1532 ecn = ip->ip_tos & IPTOS_ECN_MASK;
1547 if (GETIP(q)->ip_off > ip->ip_off)
1560 i = GETIP(p)->ip_off + GETIP(p)->ip_len - ip->ip_off;
1562 if (i >= ip->ip_len)
1566 ip->ip_off += i;
1567 ip->ip_len -= i;
1580 for (; q != NULL && ip->ip_off + ip->ip_len > GETIP(q)->ip_off;
1582 i = (ip->ip_off + ip->ip_len) -
1606 if (ip->ip_off == 0) {
1652 ip = GETIP(q);
1653 if (next + (IP_VHL_HL(ip->ip_vhl) << 2) > IP_MAXPACKET) {
1698 * Create header for new ip packet by
1703 ip->ip_len = next;
1704 ip->ip_src = fp->ipq_src;
1705 ip->ip_dst = fp->ipq_dst;
1711 m->m_len += (IP_VHL_HL(ip->ip_vhl) << 2);
1712 m->m_data -= (IP_VHL_HL(ip->ip_vhl) << 2);
1827 struct ip *ip = mtod(m, struct ip *);
1840 dst = ip->ip_dst;
1841 cp = (u_char *)(ip + 1);
1842 cnt = (IP_VHL_HL(ip->ip_vhl) << 2) - sizeof (struct ip);
1851 code = &cp[IPOPT_OLEN] - (u_char *)ip;
1856 code = &cp[IPOPT_OLEN] - (u_char *)ip;
1877 code = &cp[IPOPT_OLEN] - (u_char *)ip;
1881 code = &cp[IPOPT_OFFSET] - (u_char *)ip;
1884 ipaddr.sin_addr = ip->ip_dst;
1912 save_rte(cp, ip->ip_src);
1926 inet_ntop(AF_INET, &ip->ip_src, buf, sizeof(buf)),
1927 inet_ntop(AF_INET, &ip->ip_dst, buf2, sizeof(buf2)));
1962 ip->ip_dst = ipaddr.sin_addr;
1973 forward = !IN_MULTICAST(ntohl(ip->ip_dst.s_addr));
1978 code = &cp[IPOPT_OFFSET] - (u_char *)ip;
1982 code = &cp[IPOPT_OFFSET] - (u_char *)ip;
1991 (void)memcpy(&ipaddr.sin_addr, &ip->ip_dst,
2015 code = cp - (u_char *)ip;
2018 code = (u_char *)&ipt->ipt_len - (u_char *)ip;
2022 code = (u_char *)&ipt->ipt_ptr - (u_char *)ip;
2029 (u_char *)ip;
2044 (u_char *)ip;
2065 (u_char *)ip;
2081 (u_char *)ip + 1;
2096 ip->ip_len -= IP_VHL_HL(ip->ip_vhl) << 2; /* XXX icmp_error adds in hdr length */
2233 struct ip *ip = mtod(m, struct ip *);
2240 olen = (IP_VHL_HL(ip->ip_vhl) << 2) - sizeof (struct ip);
2241 opts = (caddr_t)(ip + 1);
2242 i = m->m_len - (sizeof (struct ip) + olen);
2247 ip->ip_vhl = IP_MAKE_VHL(IPVERSION, sizeof(struct ip) >> 2);
2349 struct ip *ip = mtod(m, struct ip *);
2370 pkt_dst = next_hop ? next_hop->sin_addr : ip->ip_dst;
2372 pkt_dst = ip->ip_dst;
2378 (u_int32_t)ip->ip_src.s_addr, (u_int32_t)pkt_dst.s_addr,
2379 ip->ip_ttl);
2390 if (ip->ip_ttl <= IPTTLDEC) {
2441 mcopy->m_len = imin((IP_VHL_HL(ip->ip_vhl) << 2) + 8,
2442 (int)ip->ip_len);
2449 ip->ip_ttl -= IPTTLDEC;
2468 u_int32_t src = ntohl(ip->ip_src.s_addr);
2604 struct ip *ipm;
2607 ipm = mtod(mcopy, struct ip *);
2672 struct ip *ip,
2698 mp = sbcreatecontrol_mbuf((caddr_t) &ip->ip_dst,
2771 mp = sbcreatecontrol_mbuf((caddr_t)&ip->ip_ttl, sizeof(ip->ip_ttl),
2790 bcopy(&ip->ip_dst, &pi.ipi_addr, sizeof(struct in_addr));
2849 struct ip *ip;
2851 ip = mtod(m, struct ip *);
2855 ((m->m_pkthdr.csum_flags & CSUM_TCP_SUM16) && ip->ip_p != IPPROTO_TCP)) {