perfstat_netadapter Subroutine
Purpose
Retrieves the statistics of a network adapter.
Library
Perfstat library (libperfstat.a)
Syntax
#include <libperfstat.h>
int perfstat_netadapter (name, userbuff, sizeof_struct, desired_number)
perfstat_id_t *name;
perfstat_netadapter_t *userbuff;
size_t sizeof_struct;
int desired_number;
Description
The perfstat_netadapter subroutine retrieves one or more individual network adapter statistics. The same function is also used to retrieve the number of available network adapter statistics.
To get one or more network adapter statistics, specify the name parameter to the name of the first network adapter for which statistics are desired, and set the desired_number parameter accordingly. To start from the first network adapter, set the name parameter to "" or FIRST_NETADAPTER. The userbuff parameter always points to a memory area that can contain the desired number of perfstat_netadpater_t structures that are copied by this function. On successful completion of the subroutine, the name parameter is set to the name of the next network adapter or to "" after all the structures were copied.
To retrieve the number of available network adapter statistics, set the name and userbuff parameters to NULL, and the desired_number parameter to 0. The value returned is the number of available adapters.
Parameters
Item | Description |
---|---|
name | Specifies either "" or FIRST_NETADAPTER, or the name of the first network adapter for which statistics are desired. For example, ent0 or ent1. |
userbuff | Points to the memory area that is to be filled with one or more perfstat_netadapter_t structures. |
sizeof_struct | Specifies the size of the perfstat_netadapter_t structure. |
desired_number | Specifies the number of perfstat_netadapter_t structures to copy to userbuff. |
Return Values
On successful completion of the subroutine unless the function is used to retrieve the number of available structures, the number of structures filled is returned. If the subroutine is unsuccessful, a value of -1 is returned and the errno global variable is set.
Error Codes
The subroutine is unsuccessful if one of the following is true:
Item | Description |
---|---|
EINVAL | One of the parameters is not valid. |
EFAULT | Memory is not sufficient. |
ENOMEM | The default length of the string is too short. |
ENOMSG | Cannot access the dictionary. |
Files
The libperfstat.h file defines standard macros, data types, and subroutines.