The function ba_list_interfaces() is passed the following argument:
interfaces |
Pointer to an array of structures of type ba_name_t, which is the buffer into which the names of the interfaces are written. There is one structure per name. |
Structures of type ba_name_t 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:
nintface = ba_get_num_interfaces(); if (nintface > 0) { interfaces = (ba_name_t *) calloc(nintface, sizeof ba_name_t); if (ba_list_interfaces(interfaces) != -1) { /* process interfaces .. */ } else { /* error handling */ } free(interfaces); }