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); }