Solaris Bandwidth Manager 1.6 の開発

説明

ba_set_event_mask() 関数は、ユーザープロセスにどのイベントを報告するかを定義するイベントマスクを設定します。イベントマスクは、ba_close() 呼び出しによってドライバファイル /dev/ipqos が閉じられる際に、そのデフォルト値 (0) にリセットされます。

イベントマスクは、表 4-1 に示したイベントのビット単位の論理和です。

表 4-1 イベントマスクの設定

ビット値 

イベントタイプ 

説明 

1  

(00000001) 

BA_EVENT_CONFIG_STARTING

ポリシーエージェントが新しい設定の読み取りを開始する時に生成される 

2  

(00000010) 

BA_EVENT_CONFIG_ENDING

ポリシーエージェントが新しい設定の読み取りを終了する時に生成される 

4  

(00000100) 

BA_EVENT_DAEMON_ENDING

ポリシーエージェントが終了する場合または強制的に終了させられる場合に生成される 

64 

(01000000) 

BA_EVENT_FLOW_ACCOUNTING

フローがタイムアウトしたか、フローの TOS フィールドが変化した場合に生成される 

128 

(10000000) 

BA_EVENT_STATS_RESET

クラスがリセットまたは削除された場合に生成される 

次に例を示します。

イベントマスクの関連ビットが設定されると、発生するイベントについての情報は ba_get_next_event() 呼び出しによって取得できるように ba_event_t 型の構造体に書き込まれ、FIFO バッファー内の待ち行列に入ります。

ba_event_t 型の構造体は次のように定義されています。


typedef struct {
        uint_t          ba_event_type;
        uint_t          ba_event_drops;
        union {
                struct {
                        ba_name_t       ba_event_iface;
                        ba_name_t       ba_event_info;
                } ba_event_config;
                struct {
                        ba_name_t       ba_flow_iface;
                        uint_t          ba_num_flows;
                        ba_flow_event_t ba_event_flows[BA_EVENT_MAX_FLOWS];
                } ba_event_flow;
                ba_class_stats_t        ba_event_stats;
                /* the following is for Bandwidth Manager internal use only */
                ba_filter_event_t       ba_event_filter;
                ba_cl_filter_event_t    ba_event_cl_filter;
        } ba_event_union;
} ba_event_t;

ba_event_t 型の構造体の要素は次のように設定されます。

ba_event_type

発生したイベントのタイプを識別できるように設定される。可能な値については、表 3-1 を参照してください。

ba_event_iface

イベントが発生したインタフェースを識別できるように設定される。イベントの型が、BA_EVENT_CONFIG_STARTING または BA_EVENT_CONFIG_ENDING の場合は、再設定されたインタフェース名が設定され、BA_EVENT_DAEMON_ENDING の場合は、空文字列が設定される。

ba_event_info

将来使用するために予約されている 

ba_flow_event_t 型の構造体は次のように定義されています。


typedef struct {
     ba_name_t       classname_in; 
     ba_name_t       classname_out;
     struct in_addr  ip_local;
     struct in_addr  ip_remote;
     uchar_t         protocol;
     ushort_t        port_local;
     ushort_t        port_remote;
     uchar_t         tos_sent_in;
     uchar_t         tos_sent_out;
     uint_t          npackets_in;
     uint_t          nbytes_in;
     uint_t          npackets_out;
     uint_t          nbytes_out;
     uint_t          url_length;
     union {
             uchar_t         *url;
             u_longlong_t    url_pad;} url_union;
     hrtime_t   firstseen_in; /* timestamp of first packet sent (ns)*/
     hrtime_t   lastseen_in;  /* timestamp of last packet sent (ns) */
     hrtime_t   firstseen_out;/* timestamp of first packet sent (ns)*/
     hrtime_t   lastseen_out; /* timestamp of last packet sent (ns) */
} ba_flow_event_t;
 
#define ba_flow_url     url_union.url