[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Communications Technical Reference, Volume 2

mi_open_comm Utility

Purpose

Performs housekeeping during STREAMS driver or module open operations.

Syntax

#include <pse/mi.h>
#include <sys/stream.h>
int mi_open_comm (StaticPointer, Size, Queue, Device, Flag, SFlag, credp)
caddr_t *StaticPointer;
uint Size;
queue_t *Queue;
dev_t *Device;
int Flag;
int SFlag;
cred_t *credp;

Description

The mi_open_comm subroutine performs housekeeping during STREAMS driver or module open operations. It is intended to be called by the driver or module open routine. It assigns a minor device number to the stream (as specified by the SFlag parameter), allocates the requested per-stream data, and sets the q_ptr fields of the stream being opened.

Notes:
  1. Each call to the mi_open_comm subroutine must have a corresponding call to the mi_close_comm subroutine. Executing one of these utilities without making a corresponding call to the other will lead to unpredictable results.
  2. The stream.h header file must be the last included header file of each source file using the stream library.

Parameters

StaticPointer Specifies the address of a static pointer which will be used internally by the mi_open_comm and related utilities to store the address of the module's list of open streams. This pointer should be initialized to NULL.
Size Specifies the amount of memory the module needs for its per-stream data. It is usually the size of the local structure which contains the module's instance data.
Queue Specifies the address of a queue_t structure. The q_ptr field of the of this structure, and of the corresponding read queue structure (if Queue points to a write queue) or write queue structure (if Queue points to a read queue), are filled in with the address of the queue_t structure being initialized.
Device Specifies the address of a dev_t structure. The use of this parameter depends on the value of the SFlag parameter.
Flag Unused.
SFlag Specifies how the Device parameter is to be used. The SFlag parameter may take one of the following values:
DEVOPEN The minor device number specified by the Device argument is used.
MODOPEN The Device parameter is NULL. This value should be used if the mi_open_com subroutine is called from the open routine of a STREAMS module rather than a STREAMS driver.
CLONEOPEN A unique minor device number above 5 is assigned (minor numbers 0-5 are reserved as special access codes).
credp Unused

Return Values

On successful completion, the mi_open_comm subroutine returns a value of zero, otherwise one of the following codes is returned:

ENXIO Indicates an invalid parameter.
EAGAIN Indicates that an internal structure could not be allocated, and that the call should be retried.

Implementation Specifics

The mi_open_comm subroutine is part of STREAMS kernel extensions.

Related Information

List of Streams Programming References in AIX Version 4.3 Communications Programming Concepts .

STREAMS Overview in AIX Version 4.3 Communications Programming Concepts .

The mi_close_comm subroutine, mi_next_ptr subroutine, mi_bufcall subroutine.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]