ba_list_class_names() -- retrieve the names of classes for a managed interface
#include <netinet/ba_stat.h> int ba_list_class_names ( const char *interface, /* interface name: le0, hme0, ... */ ba_class_pair_t *classes /* allocate buffer */ );
The function ba_list_class_names() retrieves a list of the names of all configured classes and their respective parents for a given managed interface. The parent of the root class is root.
The function ba_list_class_names() is passed the following arguments:
|
interface |
Pointer to a character string that contains the name of the managed interface (for example, le0, hih0, or hme0). |
|
classes |
Pointer to an array of structures of type ba_class_pair_t, which is the buffer into which the names of the classes are written. There is one structure per class/parent pair. |
Structures of type ba_class_pair_t are defined as follows:
typedef struct {
ba_name_t parent; /* name of the parent */
ba_name_t child; /* name of the class */
} ba_class_pair_t;
Structures of type ba_class_pair_t contain a pair of structures of type ba_name_t, which are defined as follows:
typedef struct {
char name[BA_NAMES_LEN + 1];
char padding[3];
u_short namelen;
char padding2[2];
} ba_name_t;
You must always allocate sufficient memory for the buffer, the size of which is dependent on the number of classes. For example:
int nclasses;
ba_class_pairs_t *classesp;
nclasses = ba_get_num_classes("hme0");
if (nclasses > 0) {
classesp = (ba_class_pairs_t *) calloc(nclasses,sizeof ba_class_pairs_t);
if (ba_list_class_names("hme0", classesp) != -1) {
/* process classesp ... */
} else {
/* error handling */
}
free(classesp);
}
The function ba_list_class_names() returns 0 on success, and -1 on error.
If an error occurs during a call to ba_get_list_class_names(), the variable ba_errno is set to one of the error codes listed in Table 4-2.