STREAMS-UX Programmer's Guide (February 2007)

Multiplexing
Building and Dismantling Multiplexors
Chapter 5
111
Building and Dismantling Multiplexors
Multiplexor configurations can be built and dismantled at the user level by using I_LINK/I_UNLINK ioctl
commands.
To Build a Multiplexor
Multiplexor configurations are created at the user level via system calls. The multiplexor driver is like any
other software driver. It owns a node in the file system and is opened just like any other STREAMS device
driver.
The mux multiplexor, illustrated in Figure 5-1, multiplexes stream(s) opened to it over a single lower stream
to the drv driver.
Opening the mux multiplexor and the drv device driver creates two distinct streams as shown in Figure 5-1,
“Multiplexor Before Link,”. The drv stream can be connected below the multiplexor stream using the I_LINK
ioctl call as shown in the following code snippet:
muxfd = open("/dev/mux", O_RDWR);
drvfd = open("/dev/drv", O_RDWR);
muxid = ioctl(muxfd, I_LINK, drvfd);
muxfd
Is the file descriptor open to the multiplexor.
drvfd
Is a file descriptor of the stream to be linked under the multiplexor.
When an I_LINK command is executed, the stream head queues of the stream to be linked under the
multiplexor are used by the multiplexor to manage its lower-half. The state of the two streams after the link
is shown in Figure 5-2, “Multiplexor After Link,”.
Figure 5-1 Multiplexor Before Link