ba_list_interfaces() - 管理されているインタフェース名を取得します。
#include <netinet/ba_stat.h> int ba_list_interfaces ( ba_name_t *interfaces /* allocate buffer */ );
ba_list_interfaces() 関数は、ポリシーエージェントに管理対象として設定されているインタフェース名のリストを取得します。
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);
}
|
ba_list_interfaces() 関数は、正常に終了した場合にはインタフェース数、エラー時には -1 を返します。
ba_list_interfaces() 呼び出しの際にエラーが発生すると、変数 ba_errno は表 4-2 に示したエラーコードの 1 つに設定されます。