B.8.5.2  Binding a Stream to a Network Adapter Device

Usually, the lower edge of a STREAMS stack must be bound to one or more network adapter devices. This is best done by having the plumbing daemon for the stack issue a DATAL_IBIND IOCTL command to the dndis driver (open \Device\Streams\dndis).

Example: Associating a Stream with the Lance Network Adapter

#include <dl_ctrl.h>

 

cf_ndisdrv()

{

    int result;

    HANDLE fd;

    struct strioctl StrIoctl;

    struct datal_ibind DatalIbind;

 

    fd = s_open("\Device\Streams\dndis", 0, 0);

 

    strncpy(

        DatalIbind.buffer,

        "\Device\Lance01",

        sizeof(DatalIbind.buffer) - 1

        );

 

    RtlInitString(&DatalIbind.adapter_name, DatalIbind.buffer);

 

    Strioctl.ic_cmd = DATAL_IBIND;

    StrIoctl.ic_len = sizeof(DatalIbind);

    StriIoctl.ic_dp = (char *) &DatalIbind;

 

    result = s_ioctl(fd, I_STR, &StrIoctl);

 

    // now I_LINK fd under the ip driver

    ...

}