Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

in_cksum(9) [netbsd man page]

IN_CKSUM(9)						   BSD Kernel Developer's Manual					       IN_CKSUM(9)

in_cksum, in4_cksum, in6_cksum -- compute Internet checksum SYNOPSIS
uint16_t in_cksum(struct mbuf *m, int len); uint16_t in4_cksum(struct mbuf *m, uint8_t nxt, int off, int len); uint16_t in6_cksum(struct mbuf *m, uint8_t nxt, int off, int len); DESCRIPTION
These functions are used to compute the ones-complement checksum required by IP and IPv6. The in4_cksum() function is used to compute the transport-layer checksum required by tcp(4) and udp(4) over a range of bytes starting at off and continuing on for len bytes within the mbuf m. If the nxt parameter is non-zero, it is assumed to be an IP protocol number. It is also assumed that the data within m starts with an IP header, and the transport-layer header starts at off; a pseudo-header is constructed as specified in RFC768 and RFC793, and the pseudo-header is prepended to the data covered by the checksum. The in6_cksum() function is similar; if nxt is non-zero, it is assumed that m starts with an IPv6 header, and that the transport-layer header starts after off bytes. The in_cksum() function is equivalent to in4_cksum(m, 0, 0, len). These functions are always performance critical and should be reimplemented in assembler or optimized C for each platform; when available, use of repeated full-width add-with-carry followed by reduction of the sum to a 16 bit width usually leads to best results. See RFC's 1071, 1141, 1624, and 1936 for more information about efficient computation of the internet checksum. RETURN VALUES
All three functions return the computed checksum value. SEE ALSO
inet(4), inet6(4), tcp(4), udp(4), protocols(5), mbuf(9) STANDARDS
These functions implement the Internet transport-layer checksum as specified in RFC768, RFC793, and RFC2460. BUGS
The in6_cksum() function currently requires special handling of link-local addresses in the pseudo-header due to the use of embedded scope- id's within link-local addresses. BSD
May 22, 2001 BSD

Check Out this Related Man Page

NGATMBASE(4)						   BSD Kernel Interfaces Manual 					      NGATMBASE(4)

ngatmbase -- netgraph ATM utility module SYNOPSIS
#include <netnatm/unimsg.h> #include <netgraph/atm/ngatmbase.h> struct mbuf * uni_msg_pack_mbuf(struct uni_msg *msg, void *hdr, size_t len); struct uni_msg * uni_msg_alloc(size_t len); struct uni_msg * uni_msg_build(void *buf, ...); void uni_msg_destroy(struct uni_msg *msg); int uni_msg_unpack_mbuf(struct mbuf *m, struct uni_msg *msgp); DESCRIPTION
This module provides utility functions for the handling of signalling messages to the NgATM modules. The uni_msg_pack_mbuf() function packs a message into one or several mbufs optionally prepending a header. The header is given by its address hdr and length len. If hdr is NULL or len equals 0, no header is prepended. Either msg or hdr may be NULL but not both. The uni_msg_pack_mbuf() function returns a pointer to the allocated mbuf chain or NULL in the case of an error. The uni_msg_alloc() function allocates a new message with space for at least len bytes. In the case of an error NULL is returned. The uni_msg_build() function constructs a message from pieces. Each piece is given by a pair of arguments, the first of type void * and the second a size_t. The list of pieces must be terminated by (void *)NULL. The uni_msg_destroy() function destroyes the messages and frees all the messages's memory. The uni_msg_unpack_mbuf() function unpacks an mbuf chain info a uni_msg. A pointer to the newly allocated message is stored in msgp and 0 is returned. In the case of an error (either when no packet header is found in the first mbuf or memory cannot be allocated) the function returns an appropriate error code. SEE ALSO
ng_ccatm(4), ng_sscfu(4), ng_sscop(4), ng_uni(4) AUTHORS
Harti Brandt <> BSD
August 24, 2004 BSD
Man Page