ndd commands using function calls

Hi,

Is there any function calls available ( for using in a C program ) to get the Ethernet Link status. ?

I am looking for the status available from

ndd /dev/hme link_status

And how about plumbing and configuring an interface using C program ?

BTW, Is all this documented anywere ?

Thanks in Advance ...

All of this stuff is currently done via c programs so you know it's possible. You can use a program like truss to reverse engineer the operation of those programs.

But you shouldn't do this. For example, the SunOS man page for ndd states: "The ioctl() command that ndd uses to communicate with drivers is likely to change in a future release. User programs should avoid making dependencies on it." And that's the problem when you use undocumented interfaces. Sun will keep the driver and the ndd program in sync as changes are made and you are out of the loop.

The right move in a case like this is to just use popen() to run the ndd program and then read and parse the output.

Hi,

Thanks for the reply.

Actually you can write a litle bash script to get all the informations you require:

all the commands below, just assemble them to do anything you need:

#To find which driver, interfaces you have:
<ifconfig -a>

Here are some NIC drivers userd by Solaris (just in case)
# hme - Sun Fast-Ethernet device driver
# qfe - Sun qfe Quad Fast-Ethernet device driver
# eri - Fast-Ethernet device driver
# fjqe - Fujitsu PCI Quad 10/100 Ethernet
# fjgi - Fujitsu PCI Gigabit Ethernet
# e1000g - Gigabit Ethernet driver Intel PRO/1000
# bge - Gigabit Ethernet driver for Broadcom BCM57xx
# nxge - Sun 10/1 Gigabit Ethernet network driver
# ce - Cassini Gigabit-Ethernet device driver

#Check the which instance of NIC port we are connecting to:

ndd -get /dev/interface instance

#Check status:
ndd -get /dev/interface link_status (0=down, 1=up)

#Check link mode:
ndd -get /dev/interface link_mode (0=half-duplex, 1=full-duplex)

#Check link speed :
ndd -get /dev/interface link_speed (0=10mbs, 1=100mbs)

#Check autonegotiation capabilities:
ndd -get /dev/interface adv_autoneg_cap (0=false, 1=true)

#Set autonegotiation:
ndd -set /dev/intergace adv_autoneg_cap 1 (set to true)

#Finding errors in dmesg
grep -i <interface> /var/adm/messages

Note: Those changes written with ndd -set, are not persisten, they will be lost at system reboot. But if you like to add them permanently, you may consider editing file /kernel/drv/<interface>.conf

Hope this helped :slight_smile:
______________________
The power of Solaris cannot be experienced on an Intel machine!!!