ioctl Specifics

The dlpi driver supports the ioctl operations.

The dlpi driver supports the following ioctl operations:

  • DL_ROUTE
  • DL_TUNE_LLC
  • DL_ZERO_STATS
  • DL_SET_REMADDR

These commands and their associated data structures are described in the /usr/include/sys/dlpi_aix.h header file.

Note: The ioctl commands that require an argument longer than one long word, or that specify a pointer for either reading or writing, must use the I_STR format, as in the following example:

int
istr(int fd, int cmd, char *data, int len) {
       struct strioctl  ic;
       ic.cmd = cmd;
       ic.timout = -1;
       ic.dp = data;
       ic.dp = data;
       ic.len = len;
       return ioctl(fd, I_STR, &ic);
}
Item Description
DL_ROUTE Disables the source routing on the current stream, queries the Dynamic Route Discovery for a source route, or statically assigns a source route to this stream. It is only accepted when the stream is idle (DL_IDLE).
  • If the argument length is 0, no source route is used on outgoing frames.
  • If the argument length is equal to the length of the MAC address for the current medium (for example, 6 for most 802.x providers), the DRD algorithm is used to obtain the source route for the address specified in the argument. The MAC address is replaced with the source route on return from the ioctl.
  • Otherwise, the argument is assumed to contain an address of the form mac_addr.source_route, and the source_route portion is used as the source route for this stream in all communications.
As an example, the following code can be used to discover the source route for an arbitrary address:

char *
getroute(int fd, char *addr, int len) {
        static char route[MAXROUTE_LEN];
        bcopy(addr, route, len);
        if (istr(fd, DL_ROUTE, route, len))
                return 0;
        return route;
}
DL_TUNE_LLC Allows the DLS user to alter the default LLC tunable parameters. The argument must point to an llctune_t data structure.

The flags field is examined to determine which, if any, parameters should be changed. Each bit in the flags field corresponds to a similarly named field in the llctune_t; if the bit is set, the corresponding parameter is set to the value in llctune_t. Only the current stream is affected, and changes are discarded when the stream is closed.

If the F_LLC_SET flag is set and the user has root authority, the altered parameters are saved as the new default parameters for all new streams.

This command returns as its argument an update of the current tunable parameters.

For example, to double the t1 value, the following code might be used:

int
more_t1(int fd) {
        llctune_t t;
        t.flags = 0;
        if (istr(fd, DL_TUNE_LLC, &t, sizeof(t)))
           return -1;
        t.flags = F_LLC_T1;
        t.t1 *= 2;
        return istr(fd, DL_TUNE_LLC, &t, sizeof(t));
}

To query the tunables, issue DL_TUNE_LLC with the flags field set to zero. This will alter no parameters and return the current tunable values.

DL_ZERO_STATS Resets the statistics counters to zero. The driver maintains two independent sets of statistics, one for each stream (local), and another that is the cumulative statistics for all streams (global).

This command accepts a simple boolean argument. If the argument is True (nonzero), the global statistics are zeroed. Otherwise, only the current stream's statistics are zeroed.

For example, to zero the statistics counters on the current stream, the following code might be used:

int
zero_stats(int fd) {
        return ioctl(fd, DL_ZERO_STATS, 0);
}
DL_SET_REMADDR Allows XID/TEST exchange on connection-oriented streams while still in the DL_IDLE state.

The dlpi driver uses both the source (remote) address and the dl_sap to determine where to route incoming messages for connection-oriented streams. The remote address is ordinarily specified in DL_CONNECT_REQ. If the DLS user needs to exchange XID or TEST messages before connecting to the remote station, DL_SET_REMADDR must be used.

Note: Note that this command is not necessary if XID and TEST messages are to be exchanged only when the state is DL_DATAXFER.
The argument to this command is the remote MAC address. One possible code fragment might be:

int
setaddr(int fd, char *addr, int len) {
        return istr(fd, DL_SET_REMADDR, addr, len);
}