1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1991, 1997-1998 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_BUFMOD_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_BUFMOD_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 31*7c478bd9Sstevel@tonic-gate #include <sys/types32.h> 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 34*7c478bd9Sstevel@tonic-gate extern "C" { 35*7c478bd9Sstevel@tonic-gate #endif 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate /* 38*7c478bd9Sstevel@tonic-gate * Definitions for the STREAMS Buffering module. 39*7c478bd9Sstevel@tonic-gate * 40*7c478bd9Sstevel@tonic-gate * The module gathers incoming (read-side) messages together into 41*7c478bd9Sstevel@tonic-gate * "chunks" and passes completed chunks up to the next module in 42*7c478bd9Sstevel@tonic-gate * line. The gathering process is controlled by two ioctl-settable 43*7c478bd9Sstevel@tonic-gate * parameters: 44*7c478bd9Sstevel@tonic-gate * 45*7c478bd9Sstevel@tonic-gate * timeout The maximum delay after passing the previous chunk 46*7c478bd9Sstevel@tonic-gate * upward before passing the current one up, even if the 47*7c478bd9Sstevel@tonic-gate * chunk isn't full. If the timeout value passed in is 48*7c478bd9Sstevel@tonic-gate * a null pointer, the timeout is infinite (as in the 49*7c478bd9Sstevel@tonic-gate * select system call); this is the default. 50*7c478bd9Sstevel@tonic-gate * chunksize The maximum size of a chunk of accumulated messages, 51*7c478bd9Sstevel@tonic-gate * unless a single message exceeds the chunksize, in 52*7c478bd9Sstevel@tonic-gate * which case it's passed up in a chunk containing only 53*7c478bd9Sstevel@tonic-gate * that message. Note that a given message's size includes 54*7c478bd9Sstevel@tonic-gate * the length of any leading M_PROTO blocks it may have. 55*7c478bd9Sstevel@tonic-gate * 56*7c478bd9Sstevel@tonic-gate * There is one important side-effect: setting the timeout to zero 57*7c478bd9Sstevel@tonic-gate * (polling) will force the chunksize to zero, regardless of its 58*7c478bd9Sstevel@tonic-gate * previous setting. 59*7c478bd9Sstevel@tonic-gate */ 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate /* 62*7c478bd9Sstevel@tonic-gate * Ioctls. 63*7c478bd9Sstevel@tonic-gate */ 64*7c478bd9Sstevel@tonic-gate #define SBIOC ('B' << 8) 65*7c478bd9Sstevel@tonic-gate #define SBIOCSTIME (SBIOC|1) /* set timeout info */ 66*7c478bd9Sstevel@tonic-gate #define SBIOCGTIME (SBIOC|2) /* get timeout info */ 67*7c478bd9Sstevel@tonic-gate #define SBIOCCTIME (SBIOC|3) /* clear timeout */ 68*7c478bd9Sstevel@tonic-gate #define SBIOCSCHUNK (SBIOC|4) /* set chunksize */ 69*7c478bd9Sstevel@tonic-gate #define SBIOCGCHUNK (SBIOC|5) /* get chunksize */ 70*7c478bd9Sstevel@tonic-gate #define SBIOCSSNAP (SBIOC|6) /* set snapshot length */ 71*7c478bd9Sstevel@tonic-gate #define SBIOCGSNAP (SBIOC|7) /* get snapshot length */ 72*7c478bd9Sstevel@tonic-gate #define SBIOCSFLAGS (SBIOC|8) /* set buffering modes */ 73*7c478bd9Sstevel@tonic-gate #define SBIOCGFLAGS (SBIOC|9) /* get buffering modes */ 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* 76*7c478bd9Sstevel@tonic-gate * Default chunk size. 77*7c478bd9Sstevel@tonic-gate */ 78*7c478bd9Sstevel@tonic-gate #define SB_DFLT_CHUNK 8192 /* arbitrary */ 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate /* 81*7c478bd9Sstevel@tonic-gate * buffering flags 82*7c478bd9Sstevel@tonic-gate */ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate #define SB_SEND_ON_WRITE 1 /* return buffered read data on write */ 85*7c478bd9Sstevel@tonic-gate #define SB_NO_HEADER 2 /* don't add header structure to data */ 86*7c478bd9Sstevel@tonic-gate #define SB_NO_PROTO_CVT 4 /* don't convert proto to data */ 87*7c478bd9Sstevel@tonic-gate #define SB_DEFER_CHUNK 8 /* fast response time buffering */ 88*7c478bd9Sstevel@tonic-gate #define SB_NO_DROPS 16 /* Don't drop messages */ 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate /* 91*7c478bd9Sstevel@tonic-gate * buffering state 92*7c478bd9Sstevel@tonic-gate */ 93*7c478bd9Sstevel@tonic-gate #define SB_FRCVD 1 /* first message in time window received */ 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate /* 96*7c478bd9Sstevel@tonic-gate * When adding a given message to an accumulating chunk, the module 97*7c478bd9Sstevel@tonic-gate * first converts any leading M_PROTO data block to M_DATA. 98*7c478bd9Sstevel@tonic-gate * It then constructs an sb_hdr (defined below), prepends it to 99*7c478bd9Sstevel@tonic-gate * the message, and pads the result out to force its length to a 100*7c478bd9Sstevel@tonic-gate * multiple of a machine-dependent alignment size guaranteed to be 101*7c478bd9Sstevel@tonic-gate * at least sizeof (ulong_t). It then adds the padded message to the 102*7c478bd9Sstevel@tonic-gate * chunk. 103*7c478bd9Sstevel@tonic-gate * 104*7c478bd9Sstevel@tonic-gate * sb_origlen is the original length of the message after the M_PROTO => M_DATA 105*7c478bd9Sstevel@tonic-gate * conversion, but before truncating or adding the header. 106*7c478bd9Sstevel@tonic-gate * 107*7c478bd9Sstevel@tonic-gate * sb_msglen is the length of the message after truncation, but before 108*7c478bd9Sstevel@tonic-gate * adding the header. 109*7c478bd9Sstevel@tonic-gate * 110*7c478bd9Sstevel@tonic-gate * sb_totlen is the length of the message after truncation, and including 111*7c478bd9Sstevel@tonic-gate * both the header itself and the trailing padding bytes. 112*7c478bd9Sstevel@tonic-gate * 113*7c478bd9Sstevel@tonic-gate * sb_drops is the cumulative number of messages dropped by the module 114*7c478bd9Sstevel@tonic-gate * due to stream read-side flow control or resource exhaustion. 115*7c478bd9Sstevel@tonic-gate * 116*7c478bd9Sstevel@tonic-gate * sb_timestamp is the packet arrival time expressed as a 'struct timeval'. 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate struct sb_hdr { 120*7c478bd9Sstevel@tonic-gate uint_t sbh_origlen; 121*7c478bd9Sstevel@tonic-gate uint_t sbh_msglen; 122*7c478bd9Sstevel@tonic-gate uint_t sbh_totlen; 123*7c478bd9Sstevel@tonic-gate uint_t sbh_drops; 124*7c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx) 125*7c478bd9Sstevel@tonic-gate struct timeval32 sbh_timestamp; 126*7c478bd9Sstevel@tonic-gate #else 127*7c478bd9Sstevel@tonic-gate struct timeval sbh_timestamp; 128*7c478bd9Sstevel@tonic-gate #endif /* !_LP64 */ 129*7c478bd9Sstevel@tonic-gate }; 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 132*7c478bd9Sstevel@tonic-gate } 133*7c478bd9Sstevel@tonic-gate #endif 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate #endif /* _SYS_BUFMOD_H */ 136