State of the interface

Hi,

I want to control and monitor the state of the ethernet port of my system
(based on 4.24) in order to offer flexibility to our customers. This
includes the following parameters (note that the driver is already started
when I want to perform these tasks):

speed : read current connection speed (10 or 100base-T) and set the speed
(either 10, 100 or auto)
Duplex: read the current state (half or full) and set the duplex mode
(either half, full or auto)
Connection state: read the current state (link UP or link Down) (cable
connected/not connected)
Port status: read port status (up or down) and set it.

I have found:

  1. ‘netinfo -i’ reports me the current connection speed
  2. starting the driver in verbose mode (Net.ether82557 -v) reports me, live,
    the connection state
  3. I can read port status with ‘netstat -i’ and set it using ifconfig.

However I didn’t find a way to :

  1. set the speed
  2. read and set duplex mode
  3. query the current connection state

Seems to me it’s not an easy task but there must be a way to access this
data through C programming.

Any suggestion?

PS. I’m using the latest Net and Net.ether82557 driver (4.25E and 4.25G
respectively as reported by ‘sin ve’)

Regards

Alain Boyer

Previously, Alain Boyer wrote in qdn.public.qnx4:

Hi,

I want to control and monitor the state of the ethernet port of my system
(based on 4.24) in order to offer flexibility to our customers. This
includes the following parameters (note that the driver is already started
when I want to perform these tasks):

speed : read current connection speed (10 or 100base-T) and set the speed
(either 10, 100 or auto)
Duplex: read the current state (half or full) and set the duplex mode
(either half, full or auto)
Connection state: read the current state (link UP or link Down) (cable
connected/not connected)
Port status: read port status (up or down) and set it.

I have found:

  1. ‘netinfo -i’ reports me the current connection speed
  2. starting the driver in verbose mode (Net.ether82557 -v) reports me, live,
    the connection state
  3. I can read port status with ‘netstat -i’ and set it using ifconfig.

However I didn’t find a way to :

  1. set the speed
  2. read and set duplex mode
  3. query the current connection state

Seems to me it’s not an easy task but there must be a way to access this
data through C programming.

Any suggestion?

The only way to set the speed and duplex mode is through command line
arguments. The current connection state can be seen by parsing the output
from netinfo -l. If the speed is set to zero, then the link is down.

PS. I’m using the latest Net and Net.ether82557 driver (4.25E and 4.25G
respectively as reported by ‘sin ve’)

Regards

Alain Boyer

So reading a bit into what you said Hugh… In order to change these you’d
need to slay the driver, then re-start it with the desired options. There’s
no way to do this with it running.

Is this correct?

-Martin.




“Hugh Brown” <hsbrown@qnx.com> wrote in message > > Any suggestion?

The only way to set the speed and duplex mode is through command line
arguments. The current connection state can be seen by parsing the output
from netinfo -l. If the speed is set to zero, then the link is down.

PS. I’m using the latest Net and Net.ether82557 driver (4.25E and 4.25G
respectively as reported by ‘sin ve’)

Regards

Alain Boyer
\

Previously, Martin Walter wrote in qdn.public.qnx4:

So reading a bit into what you said Hugh… In order to change these you’d
need to slay the driver, then re-start it with the desired options. There’s
no way to do this with it running.

Is this correct?

Yes, that is correct.

-Martin.




“Hugh Brown” <> hsbrown@qnx.com> > wrote in message > > Any suggestion?


The only way to set the speed and duplex mode is through command line
arguments. The current connection state can be seen by parsing the output
from netinfo -l. If the speed is set to zero, then the link is down.

PS. I’m using the latest Net and Net.ether82557 driver (4.25E and 4.25G
respectively as reported by ‘sin ve’)

Regards

Alain Boyer



\

“Alain Boyer” : news:

Hi,

[skip]
3. query the current connection state

Hi! I hope this will be useful for you.

Use ioctl() on the raw socket to obtain interface flags:
int s;
struct ifreq ireq;
s = socket (AF_INET,SOCK_DGRAM,0);
strcpy(ireq.ifr_name,“en1”);
ioctl (sd, SIOCGIFFLAGS, &ireq);
if(ireq.ifr_flags & IFF_RUNING){

Others flags defenitions can be found in <net/if.h>
Others ioctl commands can be found in <ioctl.h>


Roman [SYSTEMPROM]. The best only for you!

Thanks Roman,

I tried that out but it seems it only reports if the interface is alive, not
if a cable is connected.
It’s going to be useful anyway.

I have not found any flag reporting if a cable is connected. The
Net.ether82557 sees it but I still don='t know how to query it. Do you have
any idea?

Regards

Alain
“Roman St.Zhavnis” <programmer@crazy.ru> wrote in message
news:bb1d4v$8do$1@inn.qnx.com

“Alain Boyer” : news:
Hi,

[skip]
3. query the current connection state

Hi! I hope this will be useful for you.
Use ioctl() on the raw socket to obtain interface flags:
int s;
struct ifreq ireq;
s = socket (AF_INET,SOCK_DGRAM,0);
strcpy(ireq.ifr_name,“en1”);
ioctl (sd, SIOCGIFFLAGS, &ireq);
if(ireq.ifr_flags & IFF_RUNING){

Others flags defenitions can be found in <net/if.h
Others ioctl commands can be found in <ioctl.h


Roman [SYSTEMPROM]. The best only for you!
\

Hello, Alain Boyer

I tried that out but it seems it only reports if the interface is alive,
not
if a cable is connected.
It’s going to be useful anyway.

I have not found any flag reporting if a cable is connected. The
Net.ether82557 sees it but I still don='t know how to query it. Do you
have
any idea?

just try to ping anybody… (i mean icmp-echo request/reply).


kris