B.2 STREAMS Driver and Module Interface

B.2.1 STREAMS_TDI_INFO Structure

The STREAMS_TDI_INFO structure provides information necessary to the TDI-TPI mapping portion of STREAMS. It is supplied in calls to StrmRegisterDriver described in B.2.2. The structure is defined as follows:

typedef struct _STREAMS_TDI_INFO{
    long SERV_type;
    struct streamtab *Partner;
    long PSERV_type;
    long OPT_length;
    PVOID OPT_ptr;
    BOOLEAN ReuseAddr;
    int AddressInfoCount;
    PSTREAMS_TDI_ADDRESS_INFO AddressInfo;
} STREAMS_TDI_INFO, *PSTREAMS_TDI_INFO;
 
Members
SERV_type
Specifies the type of service, T_COTS (connection-oriented) or T_CLTS (connectionless).
Partner
Points to NetBIOS partner information.
PSERV_type
Points to type of service of the NetBIOS partner.
OPT_length
Specifies size of option string pointed to by OPT_ptr, in bytes.
OPT_ptr
Points to option string to turn on TO_REUSE_ADDR.
ReuseAddr
Specifies reuse address. This member is set to TRUE if TO_REUSE_ADDR is on by default.
AddressInfoCount
Specifies number of TDI address types supported.
AddressInfo
Points to array of address types supported by provider.

The structure for this array is STREAMS_TDI_ADDRESS_INFO, described below:

typedef struct _STREAMS_TDI_ADDRESS_INFO {
    long ADDR_length;
    USHORT AddressType;
    BOOLEAN DirectedRouted;
    PVOID ADDR_ptr;
    BOOLEAN (*AddressCompare)(char *, int, char *, int, int);
} STREAMS_TDI_ADDRESS_INFO, *PSTREAMS_TDI_ADDRESS_INFO;
 
Members
ADDR_length
Specifies length of broadcast address.
AddressType
pecifies TDI address type.
DirectedRouted
Specifies message routing. This member is set to TRUE if a directed message travels farther than a broadcast or multicast message.
ADDR_ptr
Points to broadcast address, or NULL if none
AddressCompare
Points to a transport address comparison function or NULL for the default function.

By default, STREAMS performs a simple memory comparison to compare transport addresses for equality. For some transports, this test may not be sufficient. These transports may provide their own transport comparison function in the STREAMS_TDI_ADDRESS_INFO structure. The definition of a function of this type is as follows:

BOOLEAN
AddressCompare(
    IN CHAR * First Address,
    IN int FirstAddressLen,
    IN char * SecondAddress,
    IN int SecondAddressLen,
    IN int CompareType
    );
 
Parameters
FirstAddress
Points to the first address to be compared.
FirstAddressLen
Length in bytes of the FirstAddress.
SecondAddress
Points to the second address to be compared.
SecondAddressLen
Length in bytes of the SecondAddress.
CompareType
SHTDI_ADDRESS_COMPARE_BIND or
SHTDI_ADDRESS_COMPARE_RECEIVE.

Comparisons are required on two operations: bind and receive. During a bind, the FirstAddress parameter specifies the value passed in the T_BIND_REQ message. This value may contain wild cards. The SecondAddress parameter specifies the value returned in the T_BIND_ACK message, which will have been resolved by the transport to be a specific address devoid of wild cards. The two addresses are equal if a T_BIND_REQ of the FirstAddress should result in a T_BIND_ACK of the SecondAddress.

During a receive, the FirstAddress parameter specifies the address passed down by the transport user as a receive filter. The SecondAddress parameter specifies the address of the network packet being received. The two addresses are equal if a a filter specified by the FirstAddress should result in receiving packets addressed to the SecondAddress.