]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/kpi_mbuf.c
xnu-7195.81.3.tar.gz
[apple/xnu.git] / bsd / kern / kpi_mbuf.c
index 7fb3d23d1ced8c397dad42bea54254461fd8258d..8cd16e22061498630bc1b0d737a3bbfde629534e 100644 (file)
@@ -34,7 +34,6 @@
 #include <sys/socket.h>
 #include <kern/debug.h>
 #include <libkern/OSAtomic.h>
-#include <kern/kalloc.h>
 #include <string.h>
 #include <net/dlil.h>
 #include <netinet/in.h>
@@ -528,9 +527,13 @@ errno_t
 mbuf_copydata(const mbuf_t m0, size_t off, size_t len, void *out_data)
 {
        /* Copied m_copydata, added error handling (don't just panic) */
-       int count;
+       size_t count;
        mbuf_t  m = m0;
 
+       if (off >= INT_MAX || len >= INT_MAX) {
+               return EINVAL;
+       }
+
        while (off > 0) {
                if (m == 0) {
                        return EINVAL;
@@ -810,14 +813,12 @@ mbuf_outbound_finalize(struct mbuf *m, u_int32_t pf, size_t o)
                break;
 
        case PF_INET6:
-#if INET6
                /*
                 * Checksum offload should not have been enabled when
                 * extension headers exist; indicate that the callee
                 * should skip such case by setting optlen to -1.
                 */
                (void) in6_finalize_cksum(m, o, -1, -1, m->m_pkthdr.csum_flags);
-#endif /* INET6 */
                break;
 
        default:
@@ -979,7 +980,6 @@ mbuf_inet_cksum(mbuf_t mbuf, int protocol, u_int32_t offset, u_int32_t length,
        return 0;
 }
 
-#if INET6
 errno_t
 mbuf_inet6_cksum(mbuf_t mbuf, int protocol, u_int32_t offset, u_int32_t length,
     u_int16_t *csum)
@@ -992,45 +992,6 @@ mbuf_inet6_cksum(mbuf_t mbuf, int protocol, u_int32_t offset, u_int32_t length,
        *csum = inet6_cksum(mbuf, protocol, offset, length);
        return 0;
 }
-#else /* INET6 */
-errno_t
-mbuf_inet6_cksum(__unused mbuf_t mbuf, __unused int protocol,
-    __unused u_int32_t offset, __unused u_int32_t length,
-    __unused u_int16_t *csum)
-{
-       panic("mbuf_inet6_cksum() doesn't exist on this platform\n");
-       return 0;
-}
-
-u_int16_t
-inet6_cksum(__unused struct mbuf *m, __unused unsigned int nxt,
-    __unused unsigned int off, __unused unsigned int len)
-{
-       panic("inet6_cksum() doesn't exist on this platform\n");
-       return 0;
-}
-
-void nd6_lookup_ipv6(void);
-void
-nd6_lookup_ipv6(void)
-{
-       panic("nd6_lookup_ipv6() doesn't exist on this platform\n");
-}
-
-int
-in6addr_local(__unused struct in6_addr *a)
-{
-       panic("in6addr_local() doesn't exist on this platform\n");
-       return 0;
-}
-
-void nd6_storelladdr(void);
-void
-nd6_storelladdr(void)
-{
-       panic("nd6_storelladdr() doesn't exist on this platform\n");
-}
-#endif /* INET6 */
 
 /*
  * Mbuf tag KPIs
@@ -2014,3 +1975,31 @@ m_do_tx_compl_callback(struct mbuf *m, struct ifnet *ifp)
        }
 #endif /* (DEBUG || DEVELOPMENT) */
 }
+
+errno_t
+mbuf_get_keepalive_flag(mbuf_t m, boolean_t *is_keepalive)
+{
+       if (m == NULL || is_keepalive == NULL || !(m->m_flags & M_PKTHDR)) {
+               return EINVAL;
+       }
+
+       *is_keepalive = (m->m_pkthdr.pkt_flags & PKTF_KEEPALIVE);
+
+       return 0;
+}
+
+errno_t
+mbuf_set_keepalive_flag(mbuf_t m, boolean_t is_keepalive)
+{
+       if (m == NULL || !(m->m_flags & M_PKTHDR)) {
+               return EINVAL;
+       }
+
+       if (is_keepalive) {
+               m->m_pkthdr.pkt_flags |= PKTF_KEEPALIVE;
+       } else {
+               m->m_pkthdr.pkt_flags &= ~PKTF_KEEPALIVE;
+       }
+
+       return 0;
+}