Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/sctp_crc32.c
Show All 29 Lines | |||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||||
* THE POSSIBILITY OF SUCH DAMAGE. | * THE POSSIBILITY OF SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_sctp.h" | |||||
#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> | ||||
static uint32_t | static uint32_t | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | if (offset) { | ||||
offset -= SCTP_BUF_LEN(at); | offset -= SCTP_BUF_LEN(at); | ||||
} | } | ||||
at = SCTP_BUF_NEXT(at); | at = SCTP_BUF_NEXT(at); | ||||
} | } | ||||
base = sctp_finalize_crc32c(base); | base = sctp_finalize_crc32c(base); | ||||
return (base); | return (base); | ||||
} | } | ||||
#ifdef SCTP | |||||
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_len)) { | if (offset + sizeof(uint32_t) > (uint32_t)(m->m_len)) { | ||||
SCTP_PRINTF("sctp_delayed_cksum(): m->len: %d, off: %d.\n", | SCTP_PRINTF("sctp_delayed_cksum(): m->len: %d, off: %d.\n", | ||||
(uint32_t)m->m_len, offset); | (uint32_t)m->m_len, offset); | ||||
/* | /* | ||||
* XXX this shouldn't happen, but if it does, the correct | * XXX this shouldn't happen, but if it does, the correct | ||||
* behavior may be to insert the checksum in the appropriate | * behavior may be to insert the checksum in the appropriate | ||||
* next mbuf in the chain. | * next mbuf in the chain. | ||||
*/ | */ | ||||
return; | return; | ||||
} | } | ||||
*(uint32_t *)(m->m_data + offset) = checksum; | *(uint32_t *)(m->m_data + offset) = checksum; | ||||
} | } | ||||
#endif /* SCTP */ |