示例
以下示例展示了创建本地 profile 并将其设置到 demand 或 flow 上的代码。
unsigned int count; /* number of entries in profile */
...
/* Construct profiles */
bps_profile_data_entries = (PrgT_Profile_Data_Entry *)
prg_mem_alloc (sizeof (PrgT_Profile_Data_Entry) * (count));
pps_profile_data_entries = (PrgT_Profile_Data_Entry *)
prg_mem_alloc (sizeof (PrgT_Profile_Data_Entry) * (count));
for (i = 0 ; i < count; i ++)
{
...
bps_profile_data_entries [i].x = x_axis_value;
bps_profile_data_entries [i].y = bps;
pps_profile_data_entries [i].x = x_axis_value;
pps_profile_data_entries [i].y = pps;
}
/* Create profile_hndls */
sprintf (bps_profile_name_str, "%s Bit Profile", demand_name_str);
sprintf (pps_profile_name_str, "%s Packet Profile", demand_name_str);
bps_profile_hndl = prg_profile_create_bt ("seconds", "bits/second", offset, bps_profile_name_str, count, bps_profile_data_entries);
pps_profile_hndl = prg_profile_create_bt ("seconds", "packets/second", offset, pps_profile_name_str, count, pps_profile_data_entries);
/* Set profiles on demand object. */
prg_profile_lib_profile_append (PRGC_LOCAL_PROFILE_LIB_HANDLE, bps_profile_hndl);
prg_profile_spec_get (bps_profile_hndl, bps_spec);
prg_profile_lib_profile_append (PRGC_LOCAL_PROFILE_LIB_HANDLE, pps_profile_hndl);
prg_profile_spec_get (flow_info_ptr->pps_profile_hndl, pps_spec);
Ets_Obj_Attr_Set (demand_hndl, "Traffic (bits/second)", bps_spec);
Ets_Obj_Attr_Set (demand_hndl, "Traffic (packets/second)", pps_spec);
prg_mem_free (bps_profile_data_entries);
prg_mem_free (pps_profile_data_entries);