sg_get_network_iface_stats — get network interface statistics
#include <statgrab.h>
sg_network_iface_stats *sg_get_network_iface_stats( | entries); |
| int * | entries; |
The sg_get_network_iface_stats function takes a pointer to an int, entries, which is filled with the number of network interfaces the machine has. This is needed to know how many sg_network_iface_stats structures have been returned. A pointer is returned to the first sg_network_iface_stats.
sg_get_network_iface_stats returns statistics about the network interfaces in the machine. Specifically, it returns the speed of the interface, the duplex state, and whether it is currently up.
The sg_get_network_iface_stats returns a pointer to a structure of type sg_network_iface_stats.
typedef enum{
SG_IFACE_DUPLEX_FULL,
SG_IFACE_DUPLEX_HALF,
SG_IFACE_DUPLEX_UNKNOWN
}sg_iface_duplex;
Note: The SG_IFACE_DUPLEX_UNKNOWN value could mean that duplex hasn't been negotiated yet.
typedef struct{
char *interface_name;
int speed;
sg_iface_duplex duplex;
int up;
}sg_network_iface_stats;
The name known to the operating system. (eg. on linux it might be eth0)
The speed of the interface, in megabits/sec.
The duplex state the interface is in. See sg_iface_duplex for permitted values.
Whether the interface is up.