ba_list_interfaces() 関数には次の引数を渡します。
interfaces |
ba_name_t 型の構造体の配列を指すポインタ。これは、インタフェース名が書き込まれるバッファーである。名前ごとに構造体が 1 つ存在する |
ba_name_t 型の構造体は次のように定義されています。
typedef struct { char name[BA_NAMES_LEN + 1]; char padding[3]; u_short namelen; char padding2[2]; } ba_name_t; |
バッファーには、常にクラスの数に応じた十分なメモリーを割り当てる必要があります。次に例を示します。
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); } |