| |
| ..Multiplexing | 18 |
| ..Benefits of STREAMS | 23 |
| ....Standardized Service Interfaces | 23 |
| ....Manipulating Modules | 24 |
3. STREAMS Mechanism | 29 |
| ..STREAMS Mechanism Overview | 29 |
| ....STREAMS System Calls | 30 |
| ..Stream Construction | 30 |
| ....Opening a STREAMS Device File | 33 |
| ....Creating a STREAMS-based Pipe | 34 |
| ....Adding and Removing Modules | 35 |
| ....Closing the Stream | 35 |
| ....Stream Construction Example | 36 |
4. STREAMS Processing Routines | 43 |
| ..Put and Service Procedures | 43 |
| ....Put Procedure | 44 |
| ....Service Procedure | 45 |
| ..An Asynchronous Protocol Stream Example | 46 |
| ....Read-Side Processing | 49 |
| ....Write-Side Processing | 52 |
| ....Analysis | 52 |
5. Messages | 53 |
| ..Message Overview | 53 |
| ....Message Types | 53 |
| |
| ....Expedited Data | 55 |
| ..Message Structure | 56 |
| ....Sending/Receiving Messages | 59 |
| ....Control of Stream Head Processing | 64 |
| ..Message Queues and Message Priority | 66 |
| ....The queue Structure | 70 |
| ....Message Processing | 75 |
| ..Service Interfaces | 82 |
| ....Service Interface Benefits | 83 |
| ....Service Interface Library Example | 86 |
| ..Message Allocation and Freeing | 99 |
| ....Recovering From No Buffers | 102 |
| ....Releasing Callback Requests | 105 |
| ..Extended STREAMS Buffers | 105 |
| .... esballoc Example | 108 |
6. Polling and Signaling | 111 |
| ..Input/Output Polling | 111 |
| ....Synchronous Input/Output | 112 |
| ....Asynchronous Input/Output | 116 |
| ....Signals | 118 |
| ..Stream as a Controlling Terminal | 119 |
| ....Job Control | 119 |
| ....Allocation and Deallocation | 122 |
| ....Hungup Streams | 122 |
| |
| ....Hangup Signals | 122 |
| ....Accessing the Controlling Terminal | 123 |
7. Overview of Modules and Drivers | 125 |
| ..Module and Driver Environment | 125 |
| ....Module and Driver Declarations | 126 |
| ..Module and Driver ioctls | 130 |
| ....General ioctl Processing | 132 |
| ....I_STR ioctl Processing | 134 |
| ....Transparent ioctl Processing | 135 |
| ....Transparent ioctl Messages | 138 |
| ....Transparent ioctl Examples | 139 |
| ....I_LIST ioctl | 151 |
| ..Flush Handling | 153 |
| ....Flushing Priority Bands | 156 |
| ....Device Driver Interface and Driver-Kernel Interface | 158 |
| ....STREAMS Interface | 159 |
| ..Configuring the System for STREAMS Drivers and Modules . | 160 |
| ..Design Guidelines | 160 |
| ....Data Structures | 165 |
8. Modules | 167 |
| ..Module Overview | 167 |
| ....STREAMS Module Configuration | 167 |
| ....Module Procedures | 168 |
| ....Filter Module Example | 172 |
| |
| .....Connecting Lower Streams | 223 |
| .....Disconnecting Lower Streams | 224 |
| ..Multiplexer Construction Example | 225 |
| ..Multiplexing Driver | 228 |
| .....Upper Write Put Procedure | 232 |
| .....Upper Write Service Procedure | 236 |
| .....Lower Write Service Procedure | 237 |
| .....Lower Read Put Procedure | 237 |
| ..Persistent Links | 240 |
| ..Design Guidelines | 244 |
11. STREAMS-Based Pipes and FIFOS | 247 |
| ..Overview of Pipes and FIFOs | 247 |
| ..Creating and Opening Pipes and FIFOs | 248 |
| .....Accessing Pipes and FIFOs | 249 |
| .....Flushing Pipes and FIFOs | 252 |
| .....Named Streams | 252 |
| .....Unique Connections | 256 |
12. STREAMS-Based Terminal Subsystem | 261 |
| ..Overview of Terminal Subsystem | 261 |
| .....Line-Discipline Module | 263 |
| .....Hardware Emulation Module | 270 |
| ..STREAMS-based Pseudo-Terminal Subsystem | 272 |
| .....Line-Discipline Module | 273 |
| .....Pseudo-TTY Emulation Module - PTEM | 274 |
| |
| .....Remote Mode | 278 |
| .....Packet Mode | 278 |
| .....Pseudo-TTY Drivers - ptm and pts | 279 |
13. Multi-Threaded STREAMS | 285 |
| ..MT STREAMS Overview | 285 |
| ..MT STREAMS Framework | 286 |
| .....STREAMS Framework Integrity | 287 |
| .....Message Ordering | 287 |
| ..Your MT Options | 288 |
| .....MT SAFE modules | 288 |
| .....MT UNSAFE modules | 289 |
| ..Preparing to Port | 289 |
| .....Porting to SunOS 5.x | 291 |
| ..MT SAFE Modules | 292 |
| .....MT STREAMS perimeters | 292 |
| .....Perimeter options | 294 |
| .....MT configuration | 295 |
| .....qprocson()/qprocsoff() | 295 |
| .....qtimeout()/qbufcall() | 296 |
| .....qwriter() | 296 |
| .....qwait() | 297 |
| .....Asynchronous Callbacks | 297 |
| .....Close Race Conditions | 298 |
| .....Module unloading and esballoc | 298 |
| |
| .....M_IOCNAK | 347 |
| .....M_PCPROTO | 348 |
| .....M_PCRSE | 348 |
| .....M_PCSIG | 348 |
| .....M_READ | 348 |
| .....M_START and M_STOP | 349 |
| .....M_STARTI and M_STOPI | 349 |
| .....M_UNHANGUP | 349 |
C. STREAMS Utilities | 351 |
| ..Introduction | 351 |
| ..Utility Descriptions | 352 |
| .....adjmsg - trim bytes in a message | 352 |
| .....allocb - allocate a message and data block | 353 |
| .....backq - get pointer to the queue behind a given queue | 353 |
| .....bcanput - test for flow control in the given priority band . | 353 |
| .....bcanputnext- test for flow control in the given priority band | 353 |
| .....bufcall - recover from failure of allocb | 354 |
| .....canput - test for room in a queue | 354 |
| .....canputnext - test for room in the next queue | 355 |
| .....copyb - copy a message block | 355 |
| .....copymsg - copy a message | 355 |
| .....datamsg - test whether message is a data message | 356 |
| .....dupb - duplicate a message block descriptor | 356 |
| .....dupmsg - duplicate a message | 356 |
| |
| .....enableok - re-allow a queue to be scheduled for service / | 357 |
| .....esballoc - allocate message and data blocks | 357 |
| .....esbbcall - call function when buffer is available | 358 |
| .....flushband - flush the messages in a given priority band | 358 |
| .....flushq - flush a queue | 358 |
| .....freeb - free a single message block | 358 |
| .....freemsg - free all message blocks in a message | 359 |
| .....freezestr - freeze a stream | 359 |
| .....getq - get a message from a queue | 359 |
| .....insq - put a message at a specific place in a queue | 360 |
| .....linkb - concatenate two messages into one | 361 |
| .....msgdsize - get the number of data bytes in a message | 361 |
| .....msgpullup - concatenate bytes in a message | 361 |
| .....noenable - prevent a queue from being scheduled | 361 |
| .....OTHERQ - get pointer to the mate queue | 361 |
| .....pullupmsg - concatenate and align bytes in a message | 362 |
| .....put - call a STREAMS put procedure | 362 |
| .....putbq - return a message to the beginning of a queue | 362 |
| .....putctl - put a control message | 363 |
| .....putctl1 - put a control message with a one-byte parameter | 363 |
| .....putnext - put a message to the next queue | 363 |
| .....putnextctl - put a control message | 363 |
| .....putnextctl1 - put a control message | 364 |
| .....putq - put a message on a queue | 364 |
| |
| .....qenable - enable a queue | 365 |
| .....qsize - find the number of messages on a queue | 366 |
| .....RD - get pointer to the read queue | 366 |
| .....rmvb - remove a message block from a message | 366 |
| .....rmvq - remove a message from a queue | 367 |
| .....strlog - submit messages for logging | 367 |
| .....testb - check for an available buffer | 368 |
| .....unbufcall - cancel a bufcall request | 369 |
| .....unfreezestr- unfreeze a stream | 369 |
| .....WR - get pointer to the write queue | 369 |
| ..DKI Interface | 369 |
| ..New MT perimeter utility routines | 370 |
| .....qbufcall - recover from failure of allocb | 370 |
| .....qunbufcall - cancel a qbufcall request | 371 |
| .....quntimeout - cancel a qtimeout request | 371 |
| .....qwait/qwait_sig -STREAMS perimeter wait routines | 371 |
| .....qwriter - asynchronous STREAMS perimeter upgrade | 372 |
| ..Utility Routine Summary | 373 |
D. Debugging | 377 |
| ..Overview of Debugging Facilities | 377 |
| ..Kernel Debug Printing | 378 |
| .....Console Messages | 378 |
| ..STREAMS Error Logging | 379 |
| .....Error and Trace Logging | 379 |