#ifndef _INET_IP_IMPL_H
#define _INET_IP_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
#include <sys/sdt.h>
#include <sys/dld.h>
#include <inet/tunables.h>
#define IP_MOD_ID 5701
#define INET_NAME "ip"
#ifdef _BIG_ENDIAN
#define IP_HDR_CSUM_TTL_ADJUST 256
#define IP_TCP_CSUM_COMP IPPROTO_TCP
#define IP_UDP_CSUM_COMP IPPROTO_UDP
#define IP_ICMP_CSUM_COMP IPPROTO_ICMP
#define IP_ICMPV6_CSUM_COMP IPPROTO_ICMPV6
#else
#define IP_HDR_CSUM_TTL_ADJUST 1
#define IP_TCP_CSUM_COMP (IPPROTO_TCP << 8)
#define IP_UDP_CSUM_COMP (IPPROTO_UDP << 8)
#define IP_ICMP_CSUM_COMP (IPPROTO_ICMP << 8)
#define IP_ICMPV6_CSUM_COMP (IPPROTO_ICMPV6 << 8)
#endif
#define TCP_CHECKSUM_OFFSET 16
#define TCP_CHECKSUM_SIZE 2
#define UDP_CHECKSUM_OFFSET 6
#define UDP_CHECKSUM_SIZE 2
#define ICMP_CHECKSUM_OFFSET 2
#define ICMP_CHECKSUM_SIZE 2
#define ICMPV6_CHECKSUM_OFFSET 2
#define ICMPV6_CHECKSUM_SIZE 2
#define SCTP_CHECKSUM_OFFSET 8
#define SCTP_CHECKSUM_SIZE 4
#define IPH_TCPH_CHECKSUMP(ipha, hlen) \
((uint16_t *)(((uchar_t *)(ipha)) + ((hlen) + TCP_CHECKSUM_OFFSET)))
#define IPH_UDPH_CHECKSUMP(ipha, hlen) \
((uint16_t *)(((uchar_t *)(ipha)) + ((hlen) + UDP_CHECKSUM_OFFSET)))
#define IPH_ICMPV6_CHECKSUMP(ipha, hlen) \
((uint16_t *)(((uchar_t *)(ipha)) + ((hlen) + ICMPV6_CHECKSUM_OFFSET)))
#define ILL_HCKSUM_CAPABLE(ill) \
(((ill)->ill_capabilities & ILL_CAPAB_HCKSUM) != 0)
#define IP_ADJCKSUM_PARTIAL(cksum_start, mp, mp1, len, adj) { \
\
if ((len) > 0) \
(adj) = IP_BCSUM_PARTIAL(cksum_start, len, 0); \
else \
(adj) = 0; \
\
(len) = MBLKL(mp); \
if ((mp1) == NULL) \
(mp1) = (mp); \
else \
(len) += MBLKL(mp1); \
\
if (((len) = (DB_CKSUMEND(mp) - len)) > 0) { \
uint32_t _pad; \
\
_pad = IP_BCSUM_PARTIAL((mp1)->b_wptr, len, 0); \
\
if ((uintptr_t)(mp1)->b_wptr & 1) \
(adj) += ((_pad << 8) & 0xFFFF) | (_pad >> 8); \
else \
(adj) += _pad; \
(adj) = ((adj) & 0xFFFF) + ((int)(adj) >> 16); \
} \
}
#define IS_SIMPLE_IPH(ipha) \
((ipha)->ipha_version_and_hdr_length == IP_SIMPLE_HDR_VERSION)
#define LSO_BASIC_TCP_IPV4 DLD_LSO_BASIC_TCP_IPV4
#define LSO_BASIC_TCP_IPV6 DLD_LSO_BASIC_TCP_IPV6
#define ILL_LSO_CAPABLE(ill) \
(((ill)->ill_capabilities & ILL_CAPAB_LSO) != 0)
#define ILL_LSO_USABLE(ill) \
(ILL_LSO_CAPABLE(ill) && \
ill->ill_lso_capab != NULL)
#define ILL_LSO_TCP_IPV4_USABLE(ill) \
(ILL_LSO_USABLE(ill) && \
ill->ill_lso_capab->ill_lso_flags & LSO_BASIC_TCP_IPV4)
#define ILL_LSO_TCP_IPV6_USABLE(ill) \
(ILL_LSO_USABLE(ill) && \
ill->ill_lso_capab->ill_lso_flags & LSO_BASIC_TCP_IPV6)
#define ILL_ZCOPY_CAPABLE(ill) \
(((ill)->ill_capabilities & ILL_CAPAB_ZEROCOPY) != 0)
#define ILL_ZCOPY_USABLE(ill) \
(ILL_ZCOPY_CAPABLE(ill) && (ill->ill_zerocopy_capab != NULL) && \
(ill->ill_zerocopy_capab->ill_zerocopy_flags != 0))
#define IP_DROP_ON_NO_DESC 0x01
#define ILL_DIRECT_CAPABLE(ill) \
(((ill)->ill_capabilities & ILL_CAPAB_DLD_DIRECT) != 0)
#define IP_REAL_ZONEID(zoneid, ipst) \
(((zoneid) == GLOBAL_ZONEID) ? \
netstackid_to_zoneid((ipst)->ips_netstack->netstack_stackid) : \
(zoneid))
extern void ill_flow_enable(void *, ip_mac_tx_cookie_t);
extern zoneid_t ip_get_zoneid_v4(ipaddr_t, mblk_t *, ip_recv_attr_t *,
zoneid_t);
extern zoneid_t ip_get_zoneid_v6(in6_addr_t *, mblk_t *, const ill_t *,
ip_recv_attr_t *, zoneid_t);
extern void conn_ire_revalidate(conn_t *, void *);
extern void ip_ire_unbind_walker(ire_t *, void *);
extern void ip_ire_rebind_walker(ire_t *, void *);
#define IP_HELPER_STR SO_FALLBACK
#define IP_MOD_MINPSZ 1
#define IP_MOD_MAXPSZ INFPSZ
#define IP_MOD_HIWAT 65536
#define IP_MOD_LOWAT 1024
#define DEV_IP "/devices/pseudo/ip@0:ip"
#define DEV_IP6 "/devices/pseudo/ip6@0:ip6"
#endif
#ifdef __cplusplus
}
#endif
#endif