void mac_hcksum_set(mblk_t *mp, uint32_t start, uint32_t stuff, uint32_t end, uint32_t value, uint32_t flags) { ASSERT(DB_TYPE(mp) == M_DATA); DB_CKSUMSTART(mp) = (intptr_t)start; DB_CKSUMSTUFF(mp) = (intptr_t)stuff; DB_CKSUMEND(mp) = (intptr_t)end; DB_CKSUMFLAGS(mp) = (uint16_t)flags; DB_CKSUM16(mp) = (uint16_t)value; }
/*ARGSUSED*/ static int ip_isvalidchecksum(net_handle_t neti, mblk_t *mp) { unsigned char *wptr; ipha_t *ipha = (ipha_t *)mp->b_rptr; int hlen; int ret; ASSERT(mp != NULL); if (dohwcksum && DB_CKSUM16(mp) != 0xFFFF && (DB_CKSUMFLAGS(mp) & HCK_FULLCKSUM) && (DB_CKSUMFLAGS(mp) & HCK_FULLCKSUM_OK) && (DB_CKSUMFLAGS(mp) & HCK_IPV4_HDRCKSUM)) return (1); hlen = (ipha->ipha_version_and_hdr_length & 0x0F) << 2; /* * Check that the mblk being passed in has enough data in it * before blindly checking ip_cksum. */ if (msgdsize(mp) < hlen) return (0); if (mp->b_wptr < mp->b_rptr + hlen) { if (pullupmsg(mp, hlen) == 0) return (0); wptr = mp->b_wptr; } else { wptr = mp->b_wptr; mp->b_wptr = mp->b_rptr + hlen; } if (ipha->ipha_hdr_checksum == ip_cksum(mp, 0, ipha->ipha_hdr_checksum)) ret = 1; else ret = 0; mp->b_wptr = wptr; return (ret); }
void mac_hcksum_get(mblk_t *mp, uint32_t *start, uint32_t *stuff, uint32_t *end, uint32_t *value, uint32_t *flags_ptr) { uint32_t flags; ASSERT(DB_TYPE(mp) == M_DATA); flags = DB_CKSUMFLAGS(mp) & HCK_FLAGS; if ((flags & (HCK_PARTIALCKSUM | HCK_FULLCKSUM)) != 0) { if (value != NULL) *value = (uint32_t)DB_CKSUM16(mp); if ((flags & HCK_PARTIALCKSUM) != 0) { if (start != NULL) *start = (uint32_t)DB_CKSUMSTART(mp); if (stuff != NULL) *stuff = (uint32_t)DB_CKSUMSTUFF(mp); if (end != NULL) *end = (uint32_t)DB_CKSUMEND(mp); } } if (flags_ptr != NULL) *flags_ptr = flags; }