B.2.3  STREAMS Interface Functions

To use the STREAMS environment, STREAMS drivers and modules that are part of the transport provider must conform to the interface prototyped in this section. Interface definitions are specified in Reference 1 (Further Readings on Streams). STREAMS drivers/modules must provide the following interface procedures which are called by STREAMS:

·XxxOpen

·XxxClose

·XxxPut

·XxxSrv

Note The prefix “Xxx” is used as an example only. In real life, a descriptive prefix is used for these procedures. For example, the open procedure of the TCP driver is called TcpOpen; the close procedure of the UDP driver is called UdpClose.

Xxxopen

The procedure Xxxopen is called by STREAMS to open a STREAMS driver or module. See Reference 1 for details.

INT

Xxxopen(

    IN STRUCT queue *rq,

    IN OUT dev_t *devp,

    IN INT flag,

    IN INT sflag,

    IN VOID *credp

    );

 

Parameters

rq

Points to read queue.

devp

Points to assigned device number.

flag

Indicates the Open() flag; 0 for modules.

sflag

Indicates the stream flag, which is CLONEOPEN or MODOPEN.

credp

Unused.

After being registered by StrmRegisterDriver, a STREAMS driver can be opened via the Windows NT path:

\Device\Streams\name

where name is the driver specified in the streamtab structure, as follows:

streamtab.st_rdinit->qi_minfo->mi_idname

Every STREAMS driver for Windows NT must be clonable. The stream head creates a new file object every time a STREAMS driver is opened, and always calls the open procedure of the driver with the CLONEOPEN flag.

The return value from the open procedure of the driver (egopen) must either be 0 or OPENFAIL. If the return value is 0, egopen must have assigned a minor device number to the stream, and returned it via the devp parameter.

Xxxclose

The Xxxclose procedure is called by STREAMS to close a STREAMS driver or module. See Further Readings on Streams, Reference 1 for details.

INT

Xxxclose(

    IN STRUCT queue *rq,

    IN INT flag,

    IN VOID *credp

    );

 

Parameters

rq

Points to the read queue.

flag

Indicates the Open() flag.

credp

Unused.

Xxxput

The Xxxput procedure is an example of a queue routine that receives messages from preceding queues in the stream. See Further Readings on Streams, Reference 1 for details.

INT

Xxxput(

    IN STRUCT queue *q,

    IN STRUCT msgb *mp

    );

 

Parameters

q

Points to the queue to be used.

mp

Points to the message to be processed.

Xxxsrv

The procedure Xxxsrv is an example of a service procedure for a STREAMS driver/module.

INT

Xxxsrv(

    IN STRUCT queue *q

    );

Parameters

q

Points to the queue to be used.