Operating System - HP-UX
1834557 Members
3106 Online
110069 Solutions
New Discussion

Re: how to get transmitted and recieved packages of an interface in C

 
Oliver Lehmann
Occasional Contributor

how to get transmitted and recieved packages of an interface in C

Hello,

i'm wondering if there is no way to get the packages which com in and go out through my lan0 interface. Netstat -i provide exactly the informations i need. But i can't find a way how to get them in my own program. the mib funtions only provide octets or unicast packages. All that i don't need. I tryed to access DL_HP_INFO_ACK but DL_ERROR_ACK tels me, that the DLS don't know the requested primitive (other thinks like DL_INFO_REQ,DL_HP_PPA_REQ and so on are working quite well - but don't gave me the informations i need).. So there must be another way to get the packets which are trasmitted and recieved over an interface at all.. maybe nlist(kernel) then open(dev/mem) and lseek it for the ifnet structure? I played a bit arround with that.. no success too.

Any ideas, suggestions? Should i post the code i tryed with?

Thanks for help!

Greetings, Oliver
3 REPLIES 3
Tom Jackson
Valued Contributor

Re: how to get transmitted and recieved packages of an interface in C

Oliver:

I looked at through the system and library calls and didn't see anything promissing.

You may want to consider an ugly approach. You could use the "system" library call to run the netstat command and direct the output to a file, then read the results back into your "C" program. A slicker way may be to use env variables.

Tom
Steven Mertens
Trusted Contributor

Re: how to get transmitted and recieved packages of an interface in C

hi,

Maybe you can have a look on the following url :

http://hpux.connect.org.uk/hppd/hpux/Networking/Admin/libpcap-0.7.1/


rgds.

Steven
rick jones
Honored Contributor

Re: how to get transmitted and recieved packages of an interface in C

Libpcap will have examples of some DLPI primitives, but I'm pretty sure that libpcap has no code to retrieve stats from DLPI, just to put interfaces into promiscuous mode and read the resulting packet stream.

There may be some examples of the stats DLPI primitive in the online docs at docs.hp.com.

The DLPI primitives are indeed the way to go. Don't forget that you will likely have to attach to the interface of interest prior to issuing the stats request.
there is no rest for the wicked yet the virtuous have no pillows