This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ethernet controller statistics (SMSC LAN91CXX)


On Tue, Feb 04, 2003 at 09:45:59AM +0100, llandre wrote:
> The driver for LAN91CXX controllers implements the function 
> lan91cxx_control that permits to get a lot of information about the 
> Ethernet interface. I guess these information must be retrieved through the 
> ioctl function. Is it right? If yes, which file do I have to open? I don't 
> see anything similar to /dev/smsc_eth0.

The statistics are used by the SNMP code for the "ethernet like"
mib. See packages/net/snmp/agent/current/src/mibgroup/mibII/dot3.c

Now that piece of code cheats and uses insider information instead of
a file descriptor. Im guessing here, but try something like they way
you get the mac address. interface should be "eth0".

int get_mac_address(const char *interface, char *eaddr) 
{
  int sd = -1;
  struct ifreq ifr;
  
  memset(&ifr, 0, sizeof(struct ifreq));      
               if ((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {  
        fatalerr("get_mac_address()::socket(): %s\n",strerror(errno));
  }     
        
  strcpy(ifr.ifr_name, interface);            
  if (ioctl(sd, SIOCGIFHWADDR, &ifr) == 0) {        
    /* Copy to parameter to pass back value */
    memcpy(eaddr, ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
        close(sd);
  } else {
    dbgprint(DBGETH,0,"get_mac_address()::ioctl(...,SIOCGIFHWADDR,...): %s\n",
             strerror(errno));
    close(sd);
    return 0;
  }
}

   Andrew

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]