3.4  WindNet STREAMS Utilities

The WindNet STREAMS for Tornado component release provides a set of utilities to help build various streams configurations and to debug STREAMS modules and drivers.

The autopush facility configures streams by opening devices onto which lists of modules are automatically pushed before the open system call is completed. It can also remove a previous setting or get information on a setting. A set of three routines comprise the autopush facility in WindNet STREAMS: autopushGet( ), autopushAdd( ), and autopushDelete( ).

The debugging utilities, strace and strerr, the strlog( ) routine, and numerous STREAMS show routines are described in §5. WindNet STREAMS Debugging, along with examples showing how to use each facility.

3.4.1  The Autopush Utility

The autopush utility works in conjunction with the STREAMS Administration Driver (SAD) when pushing modules onto specified devices during an open. The SAD driver stores the list of modules to push for specified drivers. When a driver is opened, the stream head references the SAD cache to see if that driver has been configured for autopush. If so, any modules listed for the specified device are pushed.

autopushGet( )

The autopushGet( ) utility obtains autopush configuration information for a device from the STREAMS Administration Driver (SAD) and displays it. The device name is that of either a clone device or a minor device. If it is a clone device, autopush information is displayed for all minor devices. If it is a minor device, then autopush information is displayed only for the specific minor device.

For example, the following command prints autopush information for all minor devices of the /dev/echo device:

-> autopushGet "/dev/echo" 

If no modules have been pushed onto the /dev/echo device, console output would be:

Device(13,0) not configured for autopush

In this case, the number 13 specifies the major number of the /dev/echo device. The number 0 specifies the minor number.

The following command prints autopush information for the minor device 2 of the /dev/echo device:

-> autopushGet "/dev/echo2"

The console output would be:

Device (13,2)  not configured for autopush

autopushAdd( )

The autopushAdd( ) utility augments a list of STREAMS modules that have been automatically pushed onto a device. The autopushAdd( )routine sets up the autopush configuration information for the device passed. The routine takes a string specifying the device name and the names of modules to be pushed. If a clone device is given, the modules are pushed on all minor devices. Modules are pushed onto specific minor devices if minor devices are specified as the device parameters.

For example, the following command automatically pushes pass and spass modules onto all minor devices of the /dev/echo device at open time:

-> autopushAdd "/dev/echo pass spass"

To list the configuration of the /dev/echo device, use autopushGet( ). The console output of autopushGet( ) would be as follows:

Major     Minor     Last Minor      2 module(s)
-------   ------    ------------    ------------
13        ALL           ---         pass spass 

The following command automatically pushes pass and spass modules onto the minor device 2 of the /dev/echo device.

autopushAdd "/dev/echo2 pass spass"

The console output of the autopushGet( ) command would be as follows.

Major    Minor     Last Minor     2 module(s)
------   ------    ------------   ------------
13       2            -----       pass spass

autopushDelete( )

The autopushDelete( ) utility removes from the STREAMS Administration Driver (SAD) autopush information for the device passed. If the device name passed is a clone device, then autopush information for all minor devices is removed. If the device name is a minor device, then autopush information is removed only for that specific minor device.

For example, the following command removes autopush information for all minor devices of /dev/echo:

-> autopushDelete "/dev/echo"

To list the configuration of the /dev/echo device, use autopushGet( ). The console output of autopushGet( ) would be as follows:

Device(13,0) not configured for autopush

The following command removes autopush information for the minor number 2 of /dev/echo2.

-> autopushDelete "/dev/echo2"

The console output of autopushGet( ) would be as follows:

Device (13, 2) not configured for autopush 

3.4.2  WindNet STREAMS Pipes and FIFOs

A streams pipe is a full-duplex connection between two file descriptors.

Figure 12 shows the structure of a streams pipe. Each file descriptor has its own stream head with the write queue pointing to the other's read queue. Data written to one file descriptor is placed on the read queue at the other end of the pipe. Streams pipes can be used as a bidirectional data transfer path in WindNet STREAMS.

WindNet STREAMS creates streams pipes using strmPipe( ), as follows:

{
int pipeFds [2]; /* Values filled by the strmPipe function */

if (strmPipe (&pipeFds[0]) == ERROR)
    /* Pipe was not created */
else
    /* Pipe was created successful. */
}

For more information about using streams pipes in WindNet STREAMS, see the manual entry for strmPipe( ). For a comprehensive discussion of streams pipes, as well as the pipemod driver, refer to UNIX System V Network Programming, by Stephen Rago.

FIFOs are first-in-first-out streams configuration. WindNet STREAMS constructs a FIFO using strmMkfifo( ), as follows:

{
int fifoFd; /* Set by function Mkfifo */

fifoFd = strmMkfifo ();
}

For both of the pipe and FIFO build procedures, the queues of the stream heads are interconnected to provide pipe and FIFO facilities.