Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/sctp_crc32.c
Show All 32 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_sctp.h" | #include "opt_sctp.h" | ||||
#include <sys/gsb_crc32.h> | #include <sys/gsb_crc32.h> | ||||
#ifdef SCTP | #if defined(SCTP) || defined(SCTP_SUPPORT) | ||||
#include <netinet/sctp_os.h> | #include <netinet/sctp_os.h> | ||||
#include <netinet/sctp.h> | #include <netinet/sctp.h> | ||||
#include <netinet/sctp_crc32.h> | #include <netinet/sctp_crc32.h> | ||||
#include <netinet/sctp_pcb.h> | #include <netinet/sctp_pcb.h> | ||||
#else | #else | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | base = calculate_crc32c(base, | ||||
(unsigned char *)m->m_data, | (unsigned char *)m->m_data, | ||||
(unsigned int)m->m_len); | (unsigned int)m->m_len); | ||||
m = m->m_next; | m = m->m_next; | ||||
} | } | ||||
base = sctp_finalize_crc32c(base); | base = sctp_finalize_crc32c(base); | ||||
return (base); | return (base); | ||||
} | } | ||||
#ifdef SCTP | #if defined(SCTP) || defined(SCTP_SUPPORT) | ||||
/* | /* | ||||
* Compute and insert the SCTP checksum in network byte order for a given | * Compute and insert the SCTP checksum in network byte order for a given | ||||
* mbuf chain m which contains an SCTP packet starting at offset. | * mbuf chain m which contains an SCTP packet starting at offset. | ||||
*/ | */ | ||||
void | void | ||||
sctp_delayed_cksum(struct mbuf *m, uint32_t offset) | sctp_delayed_cksum(struct mbuf *m, uint32_t offset) | ||||
{ | { | ||||
uint32_t checksum; | uint32_t checksum; | ||||
checksum = sctp_calculate_cksum(m, offset); | checksum = sctp_calculate_cksum(m, offset); | ||||
SCTP_STAT_DECR(sctps_sendhwcrc); | //SCTP_STAT_DECR(sctps_sendhwcrc); | ||||
SCTP_STAT_INCR(sctps_sendswcrc); | //SCTP_STAT_INCR(sctps_sendswcrc); | ||||
offset += offsetof(struct sctphdr, checksum); | offset += offsetof(struct sctphdr, checksum); | ||||
if (offset + sizeof(uint32_t) > (uint32_t)(m->m_pkthdr.len)) { | if (offset + sizeof(uint32_t) > (uint32_t)(m->m_pkthdr.len)) { | ||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
panic("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.", | panic("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.", | ||||
m->m_pkthdr.len, offset); | m->m_pkthdr.len, offset); | ||||
#else | #else | ||||
SCTP_PRINTF("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.\n", | SCTP_PRINTF("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.\n", | ||||
m->m_pkthdr.len, offset); | m->m_pkthdr.len, offset); | ||||
#endif | #endif | ||||
return; | return; | ||||
} | } | ||||
m_copyback(m, (int)offset, (int)sizeof(uint32_t), (caddr_t)&checksum); | m_copyback(m, (int)offset, (int)sizeof(uint32_t), (caddr_t)&checksum); | ||||
} | } | ||||
#endif | #endif |