Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mblkl(9f) [sunos man page]

MBLKHEAD(9F)						   Kernel Functions for Drivers 					      MBLKHEAD(9F)

NAME
MBLKHEAD, MBLKIN, MBLKL, MBLKSIZE, MBLKTAIL - Message block utility macros SYNOPSIS
#include <sys/stream.h> #include <sys/strsun.h> int MBLKHEAD(mblk_t *mp); int MBLKTAIL(mblk_t *mp); int MBLKSIZE(mblk_t *mp); int MBLKL(mblk_t *mp); int MBLKIN(mblk_t *mp, int offset, int len); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI). PARAMETERS
mp Message to be examined. offset Offset from mp->b_rptr from which to start examining. len Number of bytes to examine. DESCRIPTION
The MBLKHEAD() macro calculates the number of bytes between the first byte and the first unread byte of the message block, that is: mp->b_rptr - mp->b_datap->db_base. The MBLKTAIL() macro calculates the number of bytes between the first unwritten byte and the last byte of the message block, that is: mp->b_datap->db_lim - mp->b_wptr. The MBLKSIZE() macros calculates the total size of the message block, that is: mp->b_datap->db_lim - mp->b_datap->db_base. The MBLKL() macro calculates the length of the message block, that is: mp->b_wptr - mp->b_rptr. The MBLKIN() macro checks whether the byte range specified by offset and len resides entirely within the message block. RETURN VALUES
The MBLKHEAD(), MBLKTAIL(), MBLKL() and MBLKSIZE() functions all return the appropriate byte count, as specified above. MBLKIN() returns non-zero if the check succeeds, or zero if it fails. CONTEXT
These functions can be called from user, kernel or interrupt context. NOTES
These macros may evaluate any of their arguments more than once. This precludes passing arguments with side effects. These macros assume the message itself is well formed, that is: mp->b_datap->db_base <= mp->b_rptr <= mp->b_wptr <= mp->b_datap->db_lim. SEE ALSO
msgb(9S) STREAMS Programming Guide SunOS 5.10 9 June 2004 MBLKHEAD(9F)

Check Out this Related Man Page

rmvb(9F)						   Kernel Functions for Drivers 						  rmvb(9F)

NAME
rmvb - remove a message block from a message SYNOPSIS
#include <sys/stream.h> mblk_t *rmvb(mblk_t *mp, mblk_t *bp); INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI). PARAMETERS
mp Message from which a block is to be removed. mblk_t is an instance of the msgb(9S) structure. bp Message block to be removed. DESCRIPTION
rmvb() removes a message block (bp) from a message (mp), and returns a pointer to the altered message. The message block is not freed, merely removed from the message. It is the module or driver's responsibility to free the message block. RETURN VALUES
If successful, a pointer to the message (minus the removed block) is returned. The pointer is NULL if bp was the only block of the message before rmvb() was called. If the designated message block (bp) does not exist, -1 is returned. CONTEXT
rmvb() can be called from user or interrupt context. EXAMPLES
This routine removes all zero-length M_DATA message blocks from the given message. For each message block in the message, save the next message block (line 10). If the current message block is of type M_DATA and has no data in its buffer (line 11), then remove it from the message (line 12) and free it (line 13). In either case, continue with the next message block in the message (line 16). 1 void 2 xxclean(mp) 3 mblk_t *mp; 4 { 5 mblk_t *tmp; 6 mblk_t *nmp; 7 8 tmp = mp; 9 while (tmp) { 10 nmp = tmp->b_cont; 11 if ((tmp->b_datap->db_type == M_DATA) && (tmp->b_rptr == tmp->b_wptr)) { 12 (void) rmvb(mp, tmp); 13 freeb(tmp); 14 } 15 tmp = nmp; 16 } 17 } SEE ALSO
freeb(9F), msgb(9S) Writing Device Drivers STREAMS Programming Guide SunOS 5.10 11 Apr 1991 rmvb(9F)
Man Page