Getting hme parameters using ioctl (not ndd)

Getting hme parameters using ioctl (not ndd)

Post by Scott Ort » Wed, 28 Aug 2002 05:20:35



I need to get network device interface settings via streams/ioctl (not
ndd).  Specifically, I am looking for link_status and link_duplex.
The DLPI and hme documentation is very sketchy (to be nice) and
appears to leave out the how to.  I have run truss on ndd with the
following relevant output:

open("/dev/hme", O_RDWR)                        = 3
ioctl(3, I_NREAD, 0xFFBEFD3C)                   = 0
ioctl(3, I_STR, 0xFFBEFCC8)                     = 0

It appears as though a single I_STR request can get the information.
In addition, things like link_status seem to be driver specific an not
covered by the DLPI spec.

Any thoughts?  Thanks.

 
 
 

Getting hme parameters using ioctl (not ndd)

Post by Richard Pettit [SE Toolkit Author » Thu, 29 Aug 2002 00:53:29



> I need to get network device interface settings via streams/ioctl (not
> ndd).  Specifically, I am looking for link_status and link_duplex.
> The DLPI and hme documentation is very sketchy (to be nice) and
> appears to leave out the how to.  I have run truss on ndd with the
> following relevant output:

> open("/dev/hme", O_RDWR)                        = 3
> ioctl(3, I_NREAD, 0xFFBEFD3C)                   = 0
> ioctl(3, I_STR, 0xFFBEFCC8)                     = 0

> It appears as though a single I_STR request can get the information.
> In addition, things like link_status seem to be driver specific an not
> covered by the DLPI spec.

> Any thoughts?  Thanks.

Sun Performance and Tuning Java and the Internet, page 412.

Rich
----

"As the purse is emptied, the heart is filled." - Victor Hugo

 
 
 

Getting hme parameters using ioctl (not ndd)

Post by Scott Ort » Fri, 30 Aug 2002 00:40:31


Many thanks Rich!

Here is example test code that to used get the link_mode (0=half
duplex, 1=full duplex) of /dev/hme for all who might be interested:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stropts.h>
#include <inet/nd.h>

int main(int argc, char *argv[])
{
    int fd, i;
    char nd_buf[12];
    struct strioctl str_cmd;

    // Open device
    fd = open("/dev/hme", O_RDWR);
    if (fd == -1) {
        perror("Open failed");
        return(1);
    }

    printf("Device opened\n");

    // Setup streams call
    str_cmd.ic_cmd = ND_GET;
    str_cmd.ic_timout = -1;
    str_cmd.ic_dp = nd_buf;
    str_cmd.ic_len = sizeof(nd_buf);

    // Clear buffer (important) and set parameter name
    memset(nd_buf, 0, sizeof(nd_buf));
    strcpy(str_cmd.ic_dp, "link_mode");

    //  Get
    i = ioctl(fd, I_STR, &str_cmd);

    if (i != -1) {
        printf("Value=%s\n", nd_buf);
    } else {
        perror("ioctl");
    }

    close(fd);

    return(0);

Quote:}