AceT_Decoder_Decode_Proc
摘要
回调:用于生成摘要行。
语法
<decode_proc> (state_ptr, pk_ptr, protocol, layer, offset, next_protocol_offset, next_protocol_id)
| 参数 | 类型 | 说明 |
|---|---|---|
state_ptr |
void * |
状态信息。 |
pk_ptr |
AceT_Packet * |
目标数据包。 |
protocol |
int |
要解码的协议 ID。 |
layer |
int |
protocol 的层次(由增强解码器使用) |
offset |
int |
数据包中上一个协议结束的偏移位置。 |
next_protocol_offset |
int * |
用于存放已解码协议结束偏移位置(offset 加上 protocol 头部长度)的区域。 |
next_protocol_id |
int * |
用于存放下一个协议 ID 的区域。若 protocol 是该数据包的最高层协议,则将其设为 ACEC_DECODER_PROTOCOL_UNKNOWN。 |
返回类型
AceT_Decode_Status
解码操作的完成状态(取 表 4回调符号常量 中列出的值之一)。
头文件
ace_client_api.h
示例
AceT_Decode_Status
op_xyz_decoder_decode (void * state_ptr, AceT_Packet * pk_ptr, int protocol,
int layer, int offset, int * next_protocol_offset, int * next_protocol_id)
{
AceT_Decode_Status retval = AceC_Decode_OK;
AceT_Pk_Protocol_Info * info_ptr;
static unsigned char * rec_data = PRGC_NIL;
static int rec_data_arr_size = 0;
int rec_data_size;
AceT_Import_Handle * import_ptr = (AceT_Import_Handle *) state_ptr;
char decode_info_str [128];
FIN (op_xyz_decoder_decode);
/* Obtain the data from the file. Because this function might be called */
/* a lot, we want to reuse the array allocated of recorded data, that's why */
/* it is static. We also want to keep track of the size of the array, */
/* in case a bigger one must be allocated. */
rec_data_size = Ace_Packet_Raw_Binary_Get (pk_ptr, 0, &rec_data,
rec_data_arr_size);
if (rec_data_size > rec_data_arr_size)
rec_data_arr_size = rec_data_size;
/* Make sure we have enough data to decode XYZ */
if ((rec_data_size - offset) < OPC_XYZ_MIN_FRAME_LENGTH)
{
Ace_Decoder_Packet_Error_Log ("op_xyz",
Ace_Packet_Frame_Number_Get (pk_ptr),
"XYZ Custom Protocol", "Not enough data captured to decode", 0);
FRET (AceC_Decode_Packet_Error);
}
info_ptr = Ace_Packet_Protocol_Info_Append (pk_ptr, "XYZ", offset);
[Logic to parse the binary and figure out the values of the header fields]
[Logic to fill in the summary string (decode_info_str)]
Ace_Protocol_Info_Summary_Set (info_ptr, decode_info_str);
*next_protocol_id = ACEC_DECODER_PROTOCOL_UNKNOWN;
FRET (AceC_Decode_OK);
}
详情
每当 Transaction Analyzer 需要为自定义解码器解码的协议生成摘要行时,都会调用该回调。