[moved from comp.unix.sco.misc; Cc'd to convey that]

Scott Shinault wrote:

> Does anyone have any docs/links related to this old SCO's kernel symbols and
> how to access the related data? Or what is actually available via ioctl() as
> it relates to network interfaces?
>
> I am trying to update an old CMU-SNMP agent on this SCO. Updating the OS is
> not an option and the new NET-SNMP does not build on SCO. I don't thinnk it
> ever supported SCO because the interfaces/ifTable/ipAddrTable stuff was all
> blank. So, I am trying to add some rudimentary interface data and related
> counters, like incoming octets, blah, blah.
>
> My problem is that on my dev box, what I see is socket.h/if.h/etc. is not
> always what is actually supported by this OS. ioctl() using a number of the
> SIOCGxxx (e.g. SIOCGENADDR) just outright fail and even what looks like it
> should work for kernel symbols (ifstats, ipstats, etc.) do not really work -
> I can get the symbol and seek to the info, but the info is not in the format
> I expect (e.g., the ifstats symbol does NOT map to the "struct ifstats" (at
> least past the first 4 bytes!).


I'm looking at a 3.2v4.2 box without reference to source, just dumping
data at the address of symbol `ifstats' and comparing it to the struct
in . What I've learned is that the kernel symbol
`ifstats' is the address not of a `struct ifstats', but of a pointer to
one (i.e. the source must look like `struct ifstats *ifstats;', not
`struct ifstats ifstats[blah];'). Dereferencing the longword at
`ifstats', I get a longword of 0, a longword that points to the string
"lo\0", etc. The fields make sense as far as I cared to compare (e.g.
the values of `ifs_ipackets' and `ifs_opackets' were identical, which
makes sense on a loopback interface; and `ifs_ierrors' was 0, again
sensible).

On the other hand, this system had two interfaces and I could only find
stats for the loopback, not the NIC.

Now looking at the source, code in `netstat` which gets `ifstats' works
by doing a STREAMS ioctl `MACIOC_GETIFSTAT' on the interface device
(/dev/net0, net1, lo0, etc.). That's an ioctl(I_STR) with ic_cmd ==
MACIOC_GETIFSTAT. If that fails then it does a `DL_GET_STATISTICS_REQ'
which is too complicated to get into here -- I think it's also
unnecessary.

Interface names are gotten by doing a STREAMS ioctl `SIOCGIFNUM', then
`SIOCGIFALL' with if_all.if_entry.if_index == interface # to be looked
up.

Code that gets `ipstat' works by doing a STREAMS ioctl `SIOCGIPSTUFF' on
/dev/inet/ip (_PATH_IP in ).

Some sample code:

http://groups.google.com/groups?th=5197d5f94900a9c8

> The snmp agent that ships with this can find all this info somehow, so I
> know it's there - but where? I can't use that agent because I need to extend
> it for our products enterprise MIB.


Well, that will get you started. The general technique of setting up
STREAMS ioctls correctly, plus finding ioctl names in headers, doc,
google, and previous ports, will get you farther. Ask when you hit a
specific roadblock...

>Bela,