forked from osmocom/wireshark
better conformance to the released DCP protocol spec:
- redesign/refactoring the code to support BlockQualifier - fix handling of BlockInfo - rename some display strings for better spec conformance - remove LLDP suboption svn path=/trunk/; revision=24120
This commit is contained in:
parent
ed88c589b0
commit
6cfbb485bf
|
@ -58,18 +58,18 @@ static int hf_pn_dcp_block_length = -1;
|
|||
|
||||
static int hf_pn_dcp_block = -1;
|
||||
|
||||
static int hf_pn_dcp_result = -1;
|
||||
static int hf_pn_dcp_block_error = -1;
|
||||
|
||||
static int hf_pn_dcp_option = -1;
|
||||
static int hf_pn_dcp_suboption = -1;
|
||||
static int hf_pn_dcp_req_status = -1;
|
||||
static int hf_pn_dcp_block_info = -1;
|
||||
static int hf_pn_dcp_block_qualifier = -1;
|
||||
|
||||
static int hf_pn_dcp_suboption_ip = -1;
|
||||
static int hf_pn_dcp_suboption_ip_block_info = -1;
|
||||
static int hf_pn_dcp_suboption_ip_ip = -1;
|
||||
static int hf_pn_dcp_suboption_ip_subnetmask = -1;
|
||||
static int hf_pn_dcp_suboption_ip_default_router = -1;
|
||||
static int hf_pn_dcp_suboption_ip_standard_gateway = -1;
|
||||
|
||||
static int hf_pn_dcp_suboption_device = -1;
|
||||
static int hf_pn_dcp_suboption_device_typeofstation = -1;
|
||||
|
@ -82,10 +82,8 @@ static int hf_pn_dcp_suboption_device_aliasname = -1;
|
|||
static int hf_pn_dcp_suboption_dhcp = -1;
|
||||
static int hf_pn_dcp_suboption_dhcp_device_id = -1;
|
||||
|
||||
static int hf_pn_dcp_suboption_lldp = -1;
|
||||
|
||||
static int hf_pn_dcp_suboption_control = -1;
|
||||
static int hf_pn_dcp_suboption_control_status = -1;
|
||||
static int hf_pn_dcp_suboption_control_response = -1;
|
||||
|
||||
static int hf_pn_dcp_suboption_deviceinitiative = -1;
|
||||
static int hf_pn_dcp_deviceinitiative_value = -1;
|
||||
|
@ -129,7 +127,7 @@ static const value_string pn_dcp_service_type[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const value_string pn_dcp_result[] = {
|
||||
static const value_string pn_dcp_block_error[] = {
|
||||
{ 0x00, "Ok" },
|
||||
{ 0x01, "Option unsupp." },
|
||||
{ 0x02, "Suboption unsupp." },
|
||||
|
@ -141,9 +139,15 @@ static const value_string pn_dcp_result[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const value_string pn_dcp_req_status[] = {
|
||||
{ 0x0000, "Don't save data permanent" },
|
||||
{ 0x0001, "Save data permanent" },
|
||||
static const value_string pn_dcp_block_info[] = {
|
||||
{ 0x0000, "Reserved" },
|
||||
/*0x0001 - 0xffff reserved */
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const value_string pn_dcp_block_qualifier[] = {
|
||||
{ 0x0000, "Use the value temporary" },
|
||||
{ 0x0001, "Save the value permanent" },
|
||||
/*0x0002 - 0xffff reserved */
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
@ -152,7 +156,7 @@ static const value_string pn_dcp_req_status[] = {
|
|||
#define PNDCP_OPTION_IP 0x01
|
||||
#define PNDCP_OPTION_DEVICE 0x02
|
||||
#define PNDCP_OPTION_DHCP 0x03
|
||||
#define PNDCP_OPTION_LLDP 0x04
|
||||
#define PNDCP_OPTION_RESERVED 0x04
|
||||
#define PNDCP_OPTION_CONTROL 0x05
|
||||
#define PNDCP_OPTION_DEVICEINITIATIVE 0x06
|
||||
#define PNDCP_OPTION_MANUF_X80 0x80
|
||||
|
@ -169,7 +173,7 @@ static const value_string pn_dcp_option[] = {
|
|||
{ PNDCP_OPTION_IP, "IP" },
|
||||
{ PNDCP_OPTION_DEVICE, "Device properties" },
|
||||
{ PNDCP_OPTION_DHCP, "DHCP" },
|
||||
{ PNDCP_OPTION_LLDP, "LLDP" },
|
||||
{ PNDCP_OPTION_RESERVED, "Reserved" },
|
||||
{ PNDCP_OPTION_CONTROL, "Control" },
|
||||
{ PNDCP_OPTION_DEVICEINITIATIVE, "Device Initiative" },
|
||||
/*0x07 - 0x7f reserved */
|
||||
|
@ -239,11 +243,6 @@ static const value_string pn_dcp_suboption_dhcp[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static const value_string pn_dcp_suboption_lldp[] = {
|
||||
/* currently unknown */
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
#define PNDCP_SUBOPTION_CONTROL_START_TRANS 0x01
|
||||
#define PNDCP_SUBOPTION_CONTROL_END_TRANS 0x02
|
||||
#define PNDCP_SUBOPTION_CONTROL_SIGNAL 0x03
|
||||
|
@ -313,10 +312,6 @@ dissect_PNDCP_Option(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp, &suboption);
|
||||
val_str = pn_dcp_suboption_dhcp;
|
||||
break;
|
||||
case(PNDCP_OPTION_LLDP):
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_lldp, &suboption);
|
||||
val_str = pn_dcp_suboption_lldp;
|
||||
break;
|
||||
case(PNDCP_OPTION_CONTROL):
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption);
|
||||
val_str = pn_dcp_suboption_control;
|
||||
|
@ -350,20 +345,23 @@ dissect_PNDCP_Option(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
static int
|
||||
dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
|
||||
gboolean is_response)
|
||||
guint8 service_id, gboolean is_response)
|
||||
{
|
||||
guint8 suboption;
|
||||
guint16 block_length;
|
||||
guint16 status;
|
||||
guint16 req_status;
|
||||
guint16 block_info;
|
||||
guint16 block_qualifier;
|
||||
guint32 ip;
|
||||
|
||||
|
||||
|
||||
/* SuboptionIPParameter */
|
||||
offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip, &suboption);
|
||||
/* DCPBlockLength */
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
|
||||
|
||||
switch(suboption) {
|
||||
case(PNDCP_SUBOPTION_IP_MAC):
|
||||
/* MACAddressValue? */
|
||||
pn_append_info(pinfo, dcp_item, ", MAC");
|
||||
proto_item_append_text(block_item, "IP/MAC");
|
||||
|
||||
|
@ -373,25 +371,35 @@ dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
pn_append_info(pinfo, dcp_item, ", IP");
|
||||
proto_item_append_text(block_item, "IP/IP");
|
||||
|
||||
if(is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_block_info, &status);
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(status, pn_dcp_suboption_ip_block_info, "Unknown"));
|
||||
} else {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_req_status, &req_status);
|
||||
proto_item_append_text(block_item, ", Status: %s", val_to_str(req_status, pn_dcp_req_status, "Unknown"));
|
||||
}
|
||||
/* BlockInfo? */
|
||||
if( (service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response ||
|
||||
(service_id == PNDCP_SERVICE_ID_HELLO) && !is_response ||
|
||||
(service_id == PNDCP_SERVICE_ID_GET) && is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_block_info, &block_info);
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_suboption_ip_block_info, "Undecoded"));
|
||||
block_length -= 2;
|
||||
}
|
||||
|
||||
/* ip address */
|
||||
/* BlockQualifier? */
|
||||
if( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier);
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
block_length -= 2;
|
||||
}
|
||||
|
||||
/* IPParameterValue ... */
|
||||
|
||||
/* IPAddress */
|
||||
offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_ip, &ip);
|
||||
proto_item_append_text(block_item, ", IP: %s", ip_to_str((guint8*)&ip));
|
||||
|
||||
/* subnetmask */
|
||||
/* Subnetmask */
|
||||
offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_subnetmask, &ip);
|
||||
proto_item_append_text(block_item, ", Subnet: %s", ip_to_str((guint8*)&ip));
|
||||
|
||||
/* default router */
|
||||
offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_default_router, &ip);
|
||||
proto_item_append_text(block_item, ", Router: %s", ip_to_str((guint8*)&ip));
|
||||
/* StandardGateway */
|
||||
offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip_standard_gateway, &ip);
|
||||
proto_item_append_text(block_item, ", Gateway: %s", ip_to_str((guint8*)&ip));
|
||||
break;
|
||||
default:
|
||||
offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
|
||||
|
@ -405,7 +413,7 @@ dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
static int
|
||||
dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
|
||||
gboolean is_response)
|
||||
guint8 service_id, gboolean is_response)
|
||||
{
|
||||
guint8 suboption;
|
||||
guint16 block_length;
|
||||
|
@ -416,15 +424,32 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
char *typeofstation;
|
||||
char *nameofstation;
|
||||
char *aliasname;
|
||||
guint16 status=0;
|
||||
guint16 block_info;
|
||||
guint16 block_qualifier;
|
||||
gboolean have_block_info=FALSE;
|
||||
gboolean have_block_qualifier=FALSE;
|
||||
|
||||
|
||||
/* SuboptionDevice... */
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device, &suboption);
|
||||
/* DCPBlockLength */
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
|
||||
if(is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
|
||||
block_length -= 2;
|
||||
}
|
||||
|
||||
/* BlockInfo? */
|
||||
if( (service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response ||
|
||||
(service_id == PNDCP_SERVICE_ID_HELLO) && !is_response ||
|
||||
(service_id == PNDCP_SERVICE_ID_GET) && is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &block_info);
|
||||
have_block_info=TRUE;
|
||||
block_length -= 2;
|
||||
}
|
||||
|
||||
/* BlockQualifier? */
|
||||
if( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier);
|
||||
have_block_qualifier=TRUE;
|
||||
block_length -= 2;
|
||||
}
|
||||
|
||||
switch(suboption) {
|
||||
case(PNDCP_SUBOPTION_DEVICE_MANUF):
|
||||
|
@ -434,8 +459,10 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
proto_tree_add_string (tree, hf_pn_dcp_suboption_device_typeofstation, tvb, offset, block_length, typeofstation);
|
||||
pn_append_info(pinfo, dcp_item, ", TypeOfStation");
|
||||
proto_item_append_text(block_item, "Device/Manufacturer specific");
|
||||
if(is_response)
|
||||
proto_item_append_text(block_item, ", Status: %u", status);
|
||||
if(have_block_qualifier)
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
if(have_block_info)
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown"));
|
||||
proto_item_append_text(block_item, ", TypeOfStation: \"%s\"", typeofstation);
|
||||
offset += block_length;
|
||||
break;
|
||||
|
@ -446,8 +473,10 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
proto_tree_add_string (tree, hf_pn_dcp_suboption_device_nameofstation, tvb, offset, block_length, nameofstation);
|
||||
pn_append_info(pinfo, dcp_item, ep_strdup_printf(", NameOfStation:\"%s\"", nameofstation));
|
||||
proto_item_append_text(block_item, "Device/NameOfStation");
|
||||
if(is_response)
|
||||
proto_item_append_text(block_item, ", Status: %u", status);
|
||||
if(have_block_qualifier)
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
if(have_block_info)
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown"));
|
||||
proto_item_append_text(block_item, ", \"%s\"", nameofstation);
|
||||
offset += block_length;
|
||||
break;
|
||||
|
@ -456,8 +485,10 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device_id, &device_id);
|
||||
pn_append_info(pinfo, dcp_item, ", Dev-ID");
|
||||
proto_item_append_text(block_item, "Device/Device ID");
|
||||
if(is_response)
|
||||
proto_item_append_text(block_item, ", Status: %u", status);
|
||||
if(have_block_qualifier)
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
if(have_block_info)
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown"));
|
||||
proto_item_append_text(block_item, ", VendorID: 0x%04x / DeviceID: 0x%04x", vendor_id, device_id);
|
||||
break;
|
||||
case(PNDCP_SUBOPTION_DEVICE_DEV_ROLE):
|
||||
|
@ -465,8 +496,10 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_reserved8, NULL);
|
||||
pn_append_info(pinfo, dcp_item, ", Dev-Role");
|
||||
proto_item_append_text(block_item, "Device/Device Role");
|
||||
if(is_response)
|
||||
proto_item_append_text(block_item, ", Status: %u", status);
|
||||
if(have_block_qualifier)
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
if(have_block_info)
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown"));
|
||||
if(device_role & 0x01)
|
||||
proto_item_append_text(block_item, ", IO-Device");
|
||||
if(device_role & 0x02)
|
||||
|
@ -480,8 +513,10 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
info_str = ep_strdup_printf(", Dev-Options(%u)", block_length/2);
|
||||
pn_append_info(pinfo, dcp_item, info_str);
|
||||
proto_item_append_text(block_item, "Device/Device Options");
|
||||
if(is_response)
|
||||
proto_item_append_text(block_item, ", Status: %u", status);
|
||||
if(have_block_qualifier)
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
if(have_block_info)
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown"));
|
||||
proto_item_append_text(block_item, ", %u options", block_length/2);
|
||||
for( ; block_length != 0; block_length -= 2) {
|
||||
offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, NULL /*block_item*/, hf_pn_dcp_option,
|
||||
|
@ -495,8 +530,10 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
proto_tree_add_string (tree, hf_pn_dcp_suboption_device_aliasname, tvb, offset, block_length, aliasname);
|
||||
pn_append_info(pinfo, dcp_item, ep_strdup_printf(", AliasName:\"%s\"", aliasname));
|
||||
proto_item_append_text(block_item, "Device/AliasName");
|
||||
if(is_response)
|
||||
proto_item_append_text(block_item, ", Status: %u", status);
|
||||
if(have_block_qualifier)
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
if(have_block_info)
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown"));
|
||||
proto_item_append_text(block_item, ", \"%s\"", aliasname);
|
||||
offset += block_length;
|
||||
break;
|
||||
|
@ -512,19 +549,43 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
static int
|
||||
dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
|
||||
gboolean is_response _U_)
|
||||
guint8 service_id _U_, gboolean is_response _U_)
|
||||
{
|
||||
guint8 suboption;
|
||||
guint16 block_length;
|
||||
guint16 block_info;
|
||||
guint16 block_qualifier;
|
||||
gboolean have_block_info=FALSE;
|
||||
gboolean have_block_qualifier=FALSE;
|
||||
|
||||
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp, &suboption);
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
|
||||
|
||||
/* BlockInfo? */
|
||||
if( (service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response ||
|
||||
(service_id == PNDCP_SERVICE_ID_HELLO) && !is_response ||
|
||||
(service_id == PNDCP_SERVICE_ID_GET) && is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &block_info);
|
||||
have_block_info=TRUE;
|
||||
block_length -= 2;
|
||||
}
|
||||
|
||||
/* BlockQualifier? */
|
||||
if( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier);
|
||||
have_block_qualifier=TRUE;
|
||||
block_length -= 2;
|
||||
}
|
||||
|
||||
switch(suboption) {
|
||||
case(PNDCP_SUBOPTION_DHCP_CLIENT_ID):
|
||||
pn_append_info(pinfo, dcp_item, ", DHCP client identifier");
|
||||
proto_item_append_text(block_item, "DHCP/Client-ID");
|
||||
if(have_block_qualifier)
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
if(have_block_info)
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown"));
|
||||
proto_tree_add_item(tree, hf_pn_dcp_suboption_dhcp_device_id, tvb, offset, block_length, FALSE);
|
||||
offset += block_length;
|
||||
break;
|
||||
|
@ -536,36 +597,17 @@ dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
}
|
||||
|
||||
|
||||
/* dissect the "LLDP" suboption */
|
||||
static int
|
||||
dissect_PNDCP_Suboption_LLDP(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *block_item _U_, proto_item *dcp_item _U_,
|
||||
gboolean is_response _U_)
|
||||
{
|
||||
guint8 suboption;
|
||||
guint16 block_length;
|
||||
|
||||
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_lldp, &suboption);
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
|
||||
|
||||
offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/* dissect the "control" suboption */
|
||||
static int
|
||||
dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
|
||||
gboolean is_response _U_)
|
||||
guint8 service_id _U_, gboolean is_response _U_)
|
||||
{
|
||||
guint8 result;
|
||||
guint8 suboption;
|
||||
guint16 block_length;
|
||||
guint16 block_qualifier;
|
||||
gchar *info_str;
|
||||
guint16 status;
|
||||
guint8 block_error;
|
||||
|
||||
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption);
|
||||
|
@ -575,30 +617,31 @@ dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
case(PNDCP_SUBOPTION_CONTROL_START_TRANS):
|
||||
pn_append_info(pinfo, dcp_item, ", Start-Trans");
|
||||
proto_item_append_text(block_item, "Control/Start-Transaction");
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier);
|
||||
break;
|
||||
case(PNDCP_SUBOPTION_CONTROL_END_TRANS):
|
||||
pn_append_info(pinfo, dcp_item, ", End-Trans");
|
||||
proto_item_append_text(block_item, "Control/End-Transaction");
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier);
|
||||
break;
|
||||
case(PNDCP_SUBOPTION_CONTROL_SIGNAL):
|
||||
pn_append_info(pinfo, dcp_item, ", Signal");
|
||||
proto_item_append_text(block_item, "Control/Signal");
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier);
|
||||
block_length -= 2;
|
||||
|
||||
offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
|
||||
break;
|
||||
case(PNDCP_SUBOPTION_CONTROL_RESPONSE):
|
||||
proto_item_append_text(block_item, "Control/Response");
|
||||
offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, block_item, hf_pn_dcp_suboption_control_status,
|
||||
offset = dissect_PNDCP_Option(tvb, offset, pinfo, tree, block_item, hf_pn_dcp_suboption_control_response,
|
||||
FALSE /* append_col */);
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_result, &result);
|
||||
info_str = ep_strdup_printf(", Response(%s)", val_to_str(result, pn_dcp_result, "Unknown"));
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_block_error, &block_error);
|
||||
info_str = ep_strdup_printf(", Response(%s)", val_to_str(block_error, pn_dcp_block_error, "Unknown"));
|
||||
pn_append_info(pinfo, dcp_item, info_str);
|
||||
proto_item_append_text(block_item, ", Result: %s", val_to_str(result, pn_dcp_result, "Unknown"));
|
||||
proto_item_append_text(block_item, ", BlockError: %s", val_to_str(block_error, pn_dcp_block_error, "Unknown"));
|
||||
break;
|
||||
/* XXX - add PNDCP_SUBOPTION_CONTROL_FACTORY_RESET */
|
||||
default:
|
||||
offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
|
||||
}
|
||||
|
@ -611,29 +654,40 @@ dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
static int
|
||||
dissect_PNDCP_Suboption_DeviceInitiative(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
|
||||
gboolean is_response _U_)
|
||||
guint8 service_id, gboolean is_response)
|
||||
{
|
||||
guint8 suboption;
|
||||
guint16 block_length;
|
||||
guint16 status;
|
||||
guint16 block_info;
|
||||
guint16 block_qualifier;
|
||||
guint16 value;
|
||||
|
||||
|
||||
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_deviceinitiative, &suboption);
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
|
||||
|
||||
/* BlockInfo */
|
||||
if(is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
|
||||
pn_append_info(pinfo, dcp_item, ", DeviceInitiative");
|
||||
proto_item_append_text(block_item, "DeviceInitiative/DeviceInitiative");
|
||||
|
||||
/* BlockInfo? */
|
||||
if( (service_id == PNDCP_SERVICE_ID_IDENTIFY) && is_response ||
|
||||
(service_id == PNDCP_SERVICE_ID_HELLO) && !is_response ||
|
||||
(service_id == PNDCP_SERVICE_ID_GET) && is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &block_info);
|
||||
proto_item_append_text(block_item, ", BlockInfo: %s", val_to_str(block_info, pn_dcp_block_info, "Unknown"));
|
||||
block_length -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* BlockQualifier? */
|
||||
if( (service_id == PNDCP_SERVICE_ID_SET) && !is_response) {
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_qualifier, &block_qualifier);
|
||||
proto_item_append_text(block_item, ", BlockQualifier: %s", val_to_str(block_qualifier, pn_dcp_block_qualifier, "Unknown"));
|
||||
block_length -= 2;
|
||||
}
|
||||
|
||||
/* DeviceInitiativeValue */
|
||||
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_deviceinitiative_value, &value);
|
||||
|
||||
pn_append_info(pinfo, dcp_item, ", DeviceInitiative");
|
||||
proto_item_append_text(block_item, "DeviceInitiative/DeviceInitiative");
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
@ -642,7 +696,7 @@ dissect_PNDCP_Suboption_DeviceInitiative(tvbuff_t *tvb, int offset, packet_info
|
|||
static int
|
||||
dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
|
||||
gboolean is_response _U_)
|
||||
guint8 service_id _U_, gboolean is_response _U_)
|
||||
{
|
||||
guint8 suboption;
|
||||
guint16 block_length;
|
||||
|
@ -668,7 +722,7 @@ dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
static int
|
||||
dissect_PNDCP_Suboption_Manuf(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *block_item, proto_item *dcp_item,
|
||||
gboolean is_response _U_)
|
||||
guint8 service_id _U_, gboolean is_response _U_)
|
||||
{
|
||||
guint8 suboption;
|
||||
guint16 block_length;
|
||||
|
@ -692,7 +746,7 @@ dissect_PNDCP_Suboption_Manuf(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
static int
|
||||
dissect_PNDCP_Block(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||
proto_tree *tree, proto_item *dcp_item,
|
||||
gboolean is_response)
|
||||
guint8 service_id, gboolean is_response)
|
||||
{
|
||||
guint8 option;
|
||||
proto_item *block_item;
|
||||
|
@ -709,30 +763,27 @@ dissect_PNDCP_Block(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
|
||||
switch(option) {
|
||||
case(PNDCP_OPTION_IP):
|
||||
offset = dissect_PNDCP_Suboption_IP(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
|
||||
offset = dissect_PNDCP_Suboption_IP(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response);
|
||||
break;
|
||||
case(PNDCP_OPTION_DEVICE):
|
||||
offset = dissect_PNDCP_Suboption_Device(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
|
||||
offset = dissect_PNDCP_Suboption_Device(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response);
|
||||
break;
|
||||
case(PNDCP_OPTION_DHCP):
|
||||
offset = dissect_PNDCP_Suboption_DHCP(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
|
||||
break;
|
||||
case(PNDCP_OPTION_LLDP):
|
||||
offset = dissect_PNDCP_Suboption_LLDP(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
|
||||
offset = dissect_PNDCP_Suboption_DHCP(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response);
|
||||
break;
|
||||
case(PNDCP_OPTION_CONTROL):
|
||||
offset = dissect_PNDCP_Suboption_Control(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
|
||||
offset = dissect_PNDCP_Suboption_Control(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response);
|
||||
break;
|
||||
case(PNDCP_OPTION_DEVICEINITIATIVE):
|
||||
offset = dissect_PNDCP_Suboption_DeviceInitiative(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
|
||||
offset = dissect_PNDCP_Suboption_DeviceInitiative(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response);
|
||||
break;
|
||||
case(PNDCP_OPTION_ALLSELECTOR):
|
||||
offset = dissect_PNDCP_Suboption_All(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
|
||||
offset = dissect_PNDCP_Suboption_All(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response);
|
||||
break;
|
||||
case(PNDCP_OPTION_MANUF_X80):
|
||||
case(PNDCP_OPTION_MANUF_X81):
|
||||
default:
|
||||
offset = dissect_PNDCP_Suboption_Manuf(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
|
||||
offset = dissect_PNDCP_Suboption_Manuf(tvb, offset, pinfo, block_tree, block_item, dcp_item, service_id, is_response);
|
||||
}
|
||||
|
||||
proto_item_set_len(block_item, offset-ori_offset);
|
||||
|
@ -785,7 +836,6 @@ dissect_PNDCP_PDU(tvbuff_t *tvb,
|
|||
break;
|
||||
case(PNDCP_SERVICE_ID_HELLO):
|
||||
pn_append_info(pinfo, dcp_item, "Hello");
|
||||
is_response = TRUE;
|
||||
break;
|
||||
default:
|
||||
offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset));
|
||||
|
@ -821,7 +871,7 @@ dissect_PNDCP_PDU(tvbuff_t *tvb,
|
|||
offset = dissect_PNDCP_Option(tvb, offset, pinfo,
|
||||
tree, dcp_item, hf_pn_dcp_option, TRUE /* append_col */);
|
||||
} else {
|
||||
offset = dissect_PNDCP_Block(tvb, offset, pinfo, tree, dcp_item, is_response);
|
||||
offset = dissect_PNDCP_Block(tvb, offset, pinfo, tree, dcp_item, service_id, is_response);
|
||||
}
|
||||
/* prevent an infinite loop */
|
||||
if(offset <= ori_offset || data_length < (offset - ori_offset)) {
|
||||
|
@ -894,14 +944,14 @@ proto_register_pn_dcp (void)
|
|||
{ "Option", "pn_dcp.option", FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption,
|
||||
{ "Suboption", "pn_dcp.suboption", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_result,
|
||||
{ "Result", "pn_dcp.result", FT_UINT8, BASE_DEC, VALS(pn_dcp_result), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_block_error,
|
||||
{ "BlockError", "pn_dcp.block_error", FT_UINT8, BASE_DEC, VALS(pn_dcp_block_error), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_block,
|
||||
{ "Block", "pn_dcp.block", FT_NONE, BASE_NONE, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_req_status,
|
||||
{ "Status", "pn_dcp.req_status", FT_UINT16, BASE_DEC, VALS(pn_dcp_req_status), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_block_info,
|
||||
{ "BlockInfo", "pn_dcp.block_info", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
|
||||
{ "BlockInfo", "pn_dcp.block_info", FT_UINT16, BASE_DEC, VALS(pn_dcp_block_info), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_block_qualifier,
|
||||
{ "BlockQualifier", "pn_dcp.block_qualifier", FT_UINT16, BASE_DEC, VALS(pn_dcp_block_qualifier), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_ip,
|
||||
{ "Suboption", "pn_dcp.suboption_ip", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_ip), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_ip_block_info,
|
||||
|
@ -910,8 +960,8 @@ proto_register_pn_dcp (void)
|
|||
{ "IPaddress", "pn_dcp.subobtion_ip_ip", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_ip_subnetmask,
|
||||
{ "Subnetmask", "pn_dcp.subobtion_ip_subnetmask", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_ip_default_router,
|
||||
{ "Default-router", "pn_dcp.subobtion_ip_default_router", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_ip_standard_gateway,
|
||||
{ "StandardGateway", "pn_dcp.suboption_ip_standard_gateway", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
|
||||
|
||||
{ &hf_pn_dcp_suboption_device,
|
||||
{ "Suboption", "pn_dcp.suboption_device", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_device), 0x0, "", HFILL }},
|
||||
|
@ -924,7 +974,7 @@ proto_register_pn_dcp (void)
|
|||
{ &hf_pn_dcp_suboption_device_id,
|
||||
{ "DeviceID", "pn_dcp.suboption_device_id", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_device_role,
|
||||
{ "Device-role", "pn_dcp.suboption_device_role", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
|
||||
{ "DeviceRoleDetails", "pn_dcp.suboption_device_role", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_device_aliasname,
|
||||
{ "AliasName", "pn_dcp.suboption_device_aliasname", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
|
||||
|
||||
|
@ -933,13 +983,10 @@ proto_register_pn_dcp (void)
|
|||
{ &hf_pn_dcp_suboption_dhcp_device_id,
|
||||
{ "Device ID", "pn_dcp.suboption_dhcp_device_id", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
|
||||
|
||||
{ &hf_pn_dcp_suboption_lldp,
|
||||
{ "Suboption", "pn_dcp.suboption_lldp", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_lldp), 0x0, "", HFILL }},
|
||||
|
||||
{ &hf_pn_dcp_suboption_control,
|
||||
{ "Suboption", "pn_dcp.suboption_control", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_control), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_control_status,
|
||||
{ "ResponseStatus", "pn_dcp.suboption_control_status", FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, "", HFILL }},
|
||||
{ &hf_pn_dcp_suboption_control_response,
|
||||
{ "Response", "pn_dcp.suboption_control_response", FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, "", HFILL }},
|
||||
|
||||
{ &hf_pn_dcp_suboption_deviceinitiative,
|
||||
{ "Suboption", "pn_dcp.suboption_deviceinitiative", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_deviceinitiative), 0x0, "", HFILL }},
|
||||
|
|
Loading…
Reference in New Issue