what is the best way to display the different modes of a protocol in a custom c dissector
Hi,
i'm still working on my plugin c dissector for the iolink protocol. In the specification there are several operation modes of a iolink device. I want to display the mode on the GUI.
Until now i figured this out. The variable "iolink_mode" is static. The mode/status should be displayed for everyframe. The first incoming frame gives the first mode which stays until one of the following frames has a different mode. If i dont use the static variable i just have the one frame marked, where the mode changes. I'm sure there are better solutions out there but i couldn't finde one yet. Thanks in advance
greetings
Robin
The code:
static void determine_iolink_mode(packet_info *pinfo, guint32 iolink_mode)
{
switch (iolink_mode)
{
case 0x5A: // Fallback
col_append_fstr(pinfo->cinfo, COL_EXPERT,"%s", val_to_str(iolink_mode, values_for_mastercommand, "Unknown (0x%02x)"));
break;
case 0x95: // MasterIdent
col_append_fstr(pinfo->cinfo, COL_EXPERT,"%s", val_to_str(iolink_mode, values_for_mastercommand, "Unknown (0x%02x)"));
break;
case 0x96: // DeviceIdent
col_append_fstr(pinfo->cinfo, COL_EXPERT,"%s", val_to_str(iolink_mode, values_for_mastercommand, "Unknown (0x%02x)"));
break;
case 0x97: // DeviceStartUp
col_append_fstr(pinfo->cinfo, COL_EXPERT,"%s", val_to_str(iolink_mode, values_for_mastercommand, "Unknown (0x%02x)"));
break;
case 0x98: // ProcessDataOutputOperate
col_append_fstr(pinfo->cinfo, COL_EXPERT,"%s", val_to_str(iolink_mode, values_for_mastercommand, "Unknown (0x%02x)"));
break;
case 0x99: // DeviceOperate
col_append_fstr(pinfo->cinfo, COL_EXPERT,"%s", val_to_str(iolink_mode, values_for_mastercommand, "Unknown (0x%02x)"));
break;
case 0x9A: // Preoperate
col_append_fstr(pinfo->cinfo, COL_EXPERT,"%s", val_to_str(iolink_mode, values_for_mastercommand, "Unknown (0x%02x)"));
break;
}
}
To clarify, is it the case that the "mode" is set by a packet and remains constant for that conversation until modified by a subsequent packet which sets the "mode" until possibly changed later on by another packet?
It seems to me that the "mode" is a property of the state of the conversation between the end points and not in the state of the dissector itself, so should be held in per-conversation info. See README.dissector section 2.2.
Yes i think so. In one frame there can be three different data kinds (output, on-request and input data). The output always belongs to the bytes sent by the master and the input always belongs to the data sent by the device. The on-request data can belong to both. The state can just be changed, if the on-request data is sent by the master to the device. The first byte of the on-request data is then the mode, if on of the cases of my function fits. The mode won't change until the next frame with on-request data sent by the master follows and is one of the cases. Is this how you understood my question? I dont have implemented conversations yet. I wasn't sure if i need it and didn't understand the whole part of the conversations to be honest. Will look at this chapter again ...(more)