summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/Makefile.common4
-rw-r--r--epan/dissectors/packet-dcom.h4
-rw-r--r--epan/libwireshark.def33
-rw-r--r--plugins/profinet/Makefile.common12
-rw-r--r--plugins/profinet/packet-dcerpc-pn-io.c278
-rw-r--r--plugins/profinet/packet-dcom-cba-acco.c (renamed from epan/dissectors/packet-dcom-cba-acco.c)12
-rw-r--r--plugins/profinet/packet-dcom-cba-acco.h (renamed from epan/dissectors/packet-dcom-cba-acco.h)0
-rw-r--r--plugins/profinet/packet-dcom-cba.c (renamed from epan/dissectors/packet-dcom-cba.c)6
-rw-r--r--plugins/profinet/packet-pn-dcp.c353
-rw-r--r--plugins/profinet/packet-pn-mrp.c102
-rw-r--r--plugins/profinet/packet-pn-mrrt.c49
-rw-r--r--plugins/profinet/packet-pn-ptcp.c206
-rw-r--r--plugins/profinet/packet-pn-rt.c (renamed from epan/dissectors/packet-pn-rt.c)36
-rw-r--r--plugins/profinet/packet-pn.c288
-rw-r--r--plugins/profinet/packet-pn.h70
15 files changed, 696 insertions, 757 deletions
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common
index f3ccb924ef..f551b23f15 100644
--- a/epan/dissectors/Makefile.common
+++ b/epan/dissectors/Makefile.common
@@ -248,8 +248,6 @@ DISSECTOR_SRC = \
packet-dcerpc.c \
packet-dcm.c \
packet-dcom.c \
- packet-dcom-cba.c \
- packet-dcom-cba-acco.c \
packet-dcom-dispatch.c \
packet-dcom-oxid.c \
packet-dcom-remact.c \
@@ -523,7 +521,6 @@ DISSECTOR_SRC = \
packet-pgm.c \
packet-pim.c \
packet-pingpongprotocol.c \
- packet-pn-rt.c \
packet-pkcs1.c \
packet-pkcs12.c \
packet-pkix1explicit.c \
@@ -798,7 +795,6 @@ DISSECTOR_INCLUDES = \
packet-dcerpc-wzcsvc.h \
packet-dcerpc.h \
packet-dcom.h \
- packet-dcom-cba-acco.h \
packet-dcom-dispatch.h \
packet-ddtp.h \
packet-diameter-defs.h \
diff --git a/epan/dissectors/packet-dcom.h b/epan/dissectors/packet-dcom.h
index 2d86337dd5..d3a1fded56 100644
--- a/epan/dissectors/packet-dcom.h
+++ b/epan/dissectors/packet-dcom.h
@@ -26,8 +26,8 @@
#define __PACKET_DCERPC_DCOM_H
-extern const value_string dcom_hresult_vals[];
-extern const value_string dcom_variant_type_vals[];
+WS_VAR_IMPORT const value_string dcom_hresult_vals[];
+WS_VAR_IMPORT const value_string dcom_variant_type_vals[];
extern const value_string dcom_protseq_vals[];
extern int hf_dcom_iid;
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index 206fd6ffcc..897c726e45 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -102,6 +102,10 @@ dcerpc_get_transport_salt
dcerpc_hooks_init_protos DATA
dcerpc_init_uuid
dcerpc_uuids DATA
+dcom_hresult_vals DATA
+dcom_interface_find
+dcom_interface_new
+dcom_variant_type_vals DATA
decode_bitfield_value
decode_boolean_bitfield
decode_enumerated_bitfield
@@ -154,13 +158,40 @@ dissect_ber_restricted_string
dissect_ber_sequence
dissect_ber_sequence_of
dissect_ber_set_of
-dissect_CBA_Connection_Data
dissect_dcerpc_uint8
dissect_dcerpc_uint16
dissect_dcerpc_uint32
dissect_dcerpc_uint64
dissect_dcerpc_uuid_t
+dissect_dcom_BSTR
+dissect_dcom_dcerpc_array_size
+dissect_dcom_dcerpc_pointer
+dissect_dcom_HRESULT
+dissect_dcom_indexed_DWORD
+dissect_dcom_indexed_HRESULT
+dissect_dcom_indexed_LPWSTR
+dissect_dcom_LPWSTR
+dissect_dcom_MInterfacePointer
+dissect_dcom_PMInterfacePointer
+dissect_dcom_SAFEARRAY
+dissect_dcom_simple_resp
+dissect_dcom_simple_rqst
+dissect_dcom_that
+dissect_dcom_this
+dissect_dcom_VARIANT
+dissect_dcom_VARTYPE
dissect_h245_H223Capability
+dissect_IDispatch_Invoke_resp
+dissect_IDispatch_Invoke_rqst
+dissect_IDispatch_GetIDsOfNames_resp
+dissect_IDispatch_GetIDsOfNames_rqst
+dissect_IDispatch_GetTypeInfo_resp
+dissect_IDispatch_GetTypeInfo_rqst
+dissect_IDispatch_GetTypeInfoCount_resp
+dissect_ndr_double
+dissect_ndr_duint32
+dissect_ndr_uint8
+dissect_ndr_uint16
dissect_ndr_uint32
dissect_ndr_uuid_t
dissect_nt_64bit_time
diff --git a/plugins/profinet/Makefile.common b/plugins/profinet/Makefile.common
index aec80c427f..87c7b9e42a 100644
--- a/plugins/profinet/Makefile.common
+++ b/plugins/profinet/Makefile.common
@@ -29,7 +29,17 @@ PLUGIN_NAME = profinet
# the dissector sources (without any helpers)
DISSECTOR_SRC = \
packet-dcerpc-pn-io.c \
+ packet-dcom-cba.c \
+ packet-dcom-cba-acco.c \
+ packet-pn.c \
packet-pn-dcp.c \
packet-pn-mrp.c \
packet-pn-mrrt.c \
- packet-pn-ptcp.c
+ packet-pn-ptcp.c \
+ packet-pn-rt.c
+
+# corresponding headers
+DISSECTOR_INCLUDES = \
+ packet-dcom-cba-acco.h \
+ packet-pn.h
+
diff --git a/plugins/profinet/packet-dcerpc-pn-io.c b/plugins/profinet/packet-dcerpc-pn-io.c
index 7592e29a11..be94db920c 100644
--- a/plugins/profinet/packet-dcerpc-pn-io.c
+++ b/plugins/profinet/packet-dcerpc-pn-io.c
@@ -62,6 +62,8 @@
#include <epan/dissectors/packet-dcerpc.h>
#include <epan/expert.h>
+#include "packet-pn.h"
+
static int proto_pn_io = -1;
@@ -77,8 +79,6 @@ static int hf_pn_io_array_max_count = -1;
static int hf_pn_io_array_offset = -1;
static int hf_pn_io_array_act_count = -1;
-static int hf_pn_io_data = -1;
-
static int hf_pn_io_ar_type = -1;
static int hf_pn_io_cminitiator_macadd = -1;
static int hf_pn_io_cminitiator_objectuuid = -1;
@@ -157,7 +157,6 @@ static int hf_pn_io_subslot_nr = -1;
static int hf_pn_io_index = -1;
static int hf_pn_io_seq_number = -1;
static int hf_pn_io_record_data_length = -1;
-static int hf_pn_io_padding = -1;
static int hf_pn_io_add_val1 = -1;
static int hf_pn_io_add_val2 = -1;
@@ -1383,43 +1382,6 @@ static int dissect_PNIO_IOxS(tvbuff_t *tvb, int offset,
-/* dissect a 6 byte MAC address */
-static int
-dissect_MAC(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint8 *pdata)
-{
- guint8 data[6];
-
- tvb_memcpy(tvb, data, offset, 6);
- if(tree)
- proto_tree_add_ether(tree, hfindex, tvb, offset, 6, data);
-
- if (pdata)
- memcpy(pdata, data, 6);
-
- return offset + 6;
-}
-
-
-/* dissect an IPv4 address */
-static int
-dissect_ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint32 *pdata)
-{
- guint32 data;
-
- data = tvb_get_ipv4(tvb, offset);
- if(tree)
- proto_tree_add_ipv4(tree, hfindex, tvb, offset, 4, data);
-
- if (pdata)
- *pdata = data;
-
- return offset + 4;
-}
-
-
-
/* dissect the four status (error) fields */
@@ -1643,7 +1605,6 @@ dissect_AlarmUserStructure(tvbuff_t *tvb, int offset,
guint16 u16ChannelErrorType;
guint16 u16ExtChannelErrorType;
guint32 u32ExtChannelAddValue;
- proto_item *sub_item;
guint16 u16Index;
guint32 u32RecDataLen;
@@ -1679,14 +1640,12 @@ dissect_AlarmUserStructure(tvbuff_t *tvb, int offset,
case(0x8001): /* DiagnosisData */
case(0x8003): /* QualifiedChannelDiagnosisData */
default:
- sub_item = proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, *body_length, "data",
- "Data of UserStructureIdentifier(0x%x): %u bytes", u16UserStructureIdentifier, *body_length);
if(u16UserStructureIdentifier >= 0x8000) {
- expert_add_info_format(pinfo, sub_item, PI_UNDECODED, PI_WARN,
- "Unknown UserStructureIdentifier 0x%x", u16UserStructureIdentifier);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, *body_length);
+ } else {
+ offset = dissect_pn_user_data(tvb, offset, pinfo, tree, *body_length, "UserStructureIdentifier");
}
- offset += *body_length;
*body_length = 0;
}
@@ -1885,8 +1844,7 @@ dissect_IandM4_block(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 *drep)
{
- proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, 54, "data",
- "IM_Signature: %u bytes", 54);
+ dissect_pn_user_data(tvb, offset, pinfo, tree, 54, "IM Signature");
return offset;
}
@@ -2064,8 +2022,7 @@ dissect_SubstituteValue_block(tvbuff_t *tvb, int offset,
offset = dissect_PNIO_IOxS(tvb, offset, pinfo, tree, drep, hf_pn_io_iocs);
u16BodyLength -= 3;
/* SubstituteDataObjectElement */
- proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u16BodyLength, "undecoded",
- "SubstituteDataObjectElement: %d bytes", u16BodyLength);
+ dissect_pn_user_data(tvb, offset, pinfo, tree, u16BodyLength, "SubstituteDataObjectElement");
return offset;
}
@@ -2095,8 +2052,7 @@ dissect_RecordInputDataObjectElement_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_length_data, &u16LengthData);
/* Data */
- proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u16LengthData, "undecoded",
- "Data: %d bytes", u16LengthData);
+ offset = dissect_pn_user_data(tvb, offset, pinfo, tree, u16LengthData, "Data");
return offset;
}
@@ -2131,9 +2087,7 @@ dissect_RecordOutputDataObjectElement_block(tvbuff_t *tvb, int offset,
/* DataItem (IOCS, Data, IOPS) */
offset = dissect_PNIO_IOxS(tvb, offset, pinfo, tree, drep, hf_pn_io_iocs);
- proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u16LengthData, "undecoded",
- "Data: %d bytes", u16LengthData);
- offset += u16LengthData;
+ offset = dissect_pn_user_data(tvb, offset, pinfo, tree, u16LengthData, "Data");
offset = dissect_PNIO_IOxS(tvb, offset, pinfo, tree, drep, hf_pn_io_iops);
@@ -2172,8 +2126,7 @@ dissect_Maintenance_block(tvbuff_t *tvb, int offset,
guint32 u32MaintenanceStatus;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
sub_item = proto_tree_add_item(tree, hf_pn_io_maintenance_status, tvb, offset, 4, FALSE);
sub_tree = proto_item_add_subtree(sub_item, ett_pn_io_maintenance_status);
@@ -2219,8 +2172,7 @@ dissect_ReadWrite_header(tvbuff_t *tvb, int offset,
hf_pn_io_slot_nr, &u16SlotNr);
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_subslot_nr, &u16SubslotNr);
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_index, u16Index);
@@ -2255,8 +2207,7 @@ dissect_IODWriteReqHeader_block(tvbuff_t *tvb, int offset,
hf_pn_io_target_ar_uuid, &aruuid);
}
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 24, "padding", "Padding: 24 bytes");
- offset += 24;
+ offset = dissect_pn_padding(tvb, offset, pinfo, tree, 24);
proto_item_append_text(item, ", Len:%u", *u32RecDataLen);
@@ -2285,11 +2236,9 @@ dissect_IODReadReqHeader_block(tvbuff_t *tvb, int offset,
if(memcmp(&aruuid, &null_uuid, sizeof (e_uuid_t)) == 0) {
offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
hf_pn_io_target_ar_uuid, &aruuid);
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 8, "padding", "Padding: 8 bytes");
- offset += 8;
+ offset = dissect_pn_padding(tvb, offset, pinfo, tree, 8);
} else {
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 24, "padding", "Padding: 24 bytes");
- offset += 24;
+ offset = dissect_pn_padding(tvb, offset, pinfo, tree, 24);
}
proto_item_append_text(item, ", Len:%u", *u32RecDataLen);
@@ -2323,8 +2272,7 @@ dissect_IODWriteResHeader_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_add_val2, &u16AddVal2);
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 16, "padding", "Padding: 16 bytes");
- offset += 16;
+ offset = dissect_pn_padding(tvb, offset, pinfo, tree, 16);
proto_item_append_text(item, ", Len:%u, AddVal1:%u, AddVal2:%u",
*u32RecDataLen, u16AddVal1, u16AddVal2);
@@ -2358,8 +2306,7 @@ dissect_IODReadResHeader_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_add_val2, &u16AddVal2);
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 20, "padding", "Padding: 20 bytes");
- offset += 20;
+ offset = dissect_pn_padding(tvb, offset, pinfo, tree, 20);
proto_item_append_text(item, ", Len:%u, AddVal1:%u, AddVal2:%u",
*u32RecDataLen, u16AddVal1, u16AddVal2);
@@ -2451,8 +2398,7 @@ dissect_PDevData_block(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item _U_, guint8 *drep)
{
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
offset = dissect_blocks(tvb, offset, pinfo, tree, drep);
@@ -2470,8 +2416,7 @@ dissect_PDPortData_Check_Adjust_block(tvbuff_t *tvb, int offset,
tvbuff_t *tvb_new;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* SlotNumber */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
@@ -2494,29 +2439,6 @@ dissect_PDPortData_Check_Adjust_block(tvbuff_t *tvb, int offset,
}
-static int
-dissect_padding4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint8 *drep _U_)
-{
- /* Padding */
- switch(offset % 4) {
- case(3):
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 1, "padding", "Padding: 1 byte");
- offset += 1;
- break;
- case(2):
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
- break;
- case(1):
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 3, "padding", "Padding: 3 bytes");
- offset += 3;
- break;
- }
-
- return offset;
-}
-
-
/* dissect the PDPortDataReal blocks */
static int
dissect_PDPortDataReal_block(tvbuff_t *tvb, int offset,
@@ -2541,8 +2463,7 @@ dissect_PDPortDataReal_block(tvbuff_t *tvb, int offset,
guint32 u32MediaType;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* SlotNumber */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
@@ -2565,7 +2486,7 @@ dissect_PDPortDataReal_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint8(tvb, offset, pinfo, tree, drep,
hf_pn_io_number_of_peers, &u8NumberOfPeers);
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
u8I = u8NumberOfPeers;
while(u8I--) {
@@ -2590,24 +2511,24 @@ dissect_PDPortDataReal_block(tvbuff_t *tvb, int offset,
offset += u8LengthPeerChassisID;
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* LineDelay */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
hf_pn_io_line_delay, &u32LineDelay);
/* PeerMACAddress */
- offset = dissect_MAC(tvb, offset, pinfo, tree,
+ offset = dissect_pn_mac(tvb, offset, pinfo, tree,
hf_pn_io_peer_macadd, mac);
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
}
/* MAUType */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_mau_type, &u16MAUType);
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* DomainBoundary */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
@@ -2619,7 +2540,7 @@ dissect_PDPortDataReal_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_port_state, &u16PortState);
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MediaType */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
@@ -2646,8 +2567,7 @@ dissect_PDInterfaceMrpDataAdjust_block(tvbuff_t *tvb, int offset,
#endif
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MRP_DomainUUID */
offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
@@ -2656,7 +2576,7 @@ dissect_PDInterfaceMrpDataAdjust_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_mrp_role, &u16Role);
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
#if 0
/* XXX - these fields will be added later */
@@ -2673,7 +2593,7 @@ dissect_PDInterfaceMrpDataAdjust_block(tvbuff_t *tvb, int offset,
#endif
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
offset = dissect_blocks(tvb, offset, pinfo, tree, drep);
@@ -2690,8 +2610,7 @@ dissect_PDInterfaceMrpDataReal_block(tvbuff_t *tvb, int offset,
guint16 u16Version;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MRP_DomainUUID */
offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
@@ -2718,8 +2637,7 @@ dissect_PDInterfaceMrpDataCheck_block(tvbuff_t *tvb, int offset,
guint16 u16Check;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MRP_DomainUUID */
offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
@@ -2742,8 +2660,7 @@ dissect_PDPortMrpData_block(tvbuff_t *tvb, int offset,
e_uuid_t uuid;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MRP_DomainUUID */
offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
@@ -2783,7 +2700,7 @@ dissect_MrpManagerParams_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_mrp_tstnrmax, &u16TSTNRmax);
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
return offset;
}
@@ -2830,7 +2747,7 @@ dissect_MrpRTModeManagerData_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_mrp_tstdefaultt, &u16TSTdefaultT);
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MRP_RTMode */
offset = dissect_MrpRTMode(tvb, offset, pinfo, tree, item, drep);
@@ -2896,8 +2813,7 @@ static int
dissect_MrpRTModeClientData_block(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 *drep)
{
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MRP_RTMode */
offset = dissect_MrpRTMode(tvb, offset, pinfo, tree, item, drep);
@@ -2915,8 +2831,7 @@ dissect_AdjustDomainBoundary_block(tvbuff_t *tvb, int offset,
guint16 u16AdjustProperties;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* Boundary */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
@@ -2941,8 +2856,7 @@ dissect_AdjustMulticastBoundary_block(tvbuff_t *tvb, int offset,
guint16 u16AdjustProperties;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* Boundary */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
@@ -2967,8 +2881,7 @@ dissect_AdjustMAUType_block(tvbuff_t *tvb, int offset,
guint16 u16AdjustProperties;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MAUType */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
@@ -3012,8 +2925,7 @@ dissect_CheckLineDelay_block(tvbuff_t *tvb, int offset,
guint32 u32LineDelay;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* LineDelay */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
@@ -3080,8 +2992,7 @@ dissect_AdjustPortState_block(tvbuff_t *tvb, int offset,
guint16 u16AdjustProperties;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* PortState */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
@@ -3128,8 +3039,7 @@ dissect_PDPortFODataReal_block(tvbuff_t *tvb, int offset,
/* Padding */
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* FiberOpticType */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
@@ -3169,8 +3079,7 @@ dissect_FiberOpticManufacturerSpecific_block(tvbuff_t *tvb, int offset,
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_vendor_block_type, &u16VendorBlockType);
/* Data */
- proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u16BodyLength-4, "data",
- "Data: %u bytes", u16BodyLength-4);
+ offset = dissect_pn_user_data(tvb, offset, pinfo, tree, u16BodyLength-4, "Data");
return offset;
}
@@ -3186,8 +3095,7 @@ dissect_PDPortFODataAdjust_block(tvbuff_t *tvb, int offset,
/* Padding */
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* FiberOpticType */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
@@ -3214,8 +3122,7 @@ dissect_PDPortFODataCheck_block(tvbuff_t *tvb, int offset,
/* Padding */
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MaintenanceRequiredPowerBudget */
/* XXX - decode the u32FiberOpticPowerBudget better */
@@ -3247,8 +3154,7 @@ dissect_PDNCDataCheck_block(tvbuff_t *tvb, int offset,
/* Padding */
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MaintenanceRequiredDropBudget */
/* XXX - decode the u32NCDropBudget better */
@@ -3293,24 +3199,24 @@ dissect_PDInterfaceDataReal_block(tvbuff_t *tvb, int offset,
offset += u8LengthOwnChassisID;
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* MACAddressValue */
- offset = dissect_MAC(tvb, offset, pinfo, tree, hf_pn_io_macadd, mac);
+ offset = dissect_pn_mac(tvb, offset, pinfo, tree, hf_pn_io_macadd, mac);
/* Padding */
- offset = dissect_padding4(tvb,offset, pinfo, tree, drep);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* IPAddress */
- offset = dissect_ipv4(tvb, offset, pinfo, tree, hf_pn_io_ip_address, &ip);
+ offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_io_ip_address, &ip);
/*proto_item_append_text(block_item, ", IP: %s", ip_to_str((guint8*)&ip));*/
/* Subnetmask */
- offset = dissect_ipv4(tvb, offset, pinfo, tree, hf_pn_io_subnetmask, &ip);
+ offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_io_subnetmask, &ip);
/*proto_item_append_text(block_item, ", Subnet: %s", ip_to_str((guint8*)&ip));*/
/* StandardGateway */
- offset = dissect_ipv4(tvb, offset, pinfo, tree, hf_pn_io_standard_gateway, &ip);
+ offset = dissect_pn_ipv4(tvb, offset, pinfo, tree, hf_pn_io_standard_gateway, &ip);
/*proto_item_append_text(block_item, ", Router: %s", ip_to_str((guint8*)&ip));*/
@@ -3336,8 +3242,7 @@ dissect_PDSyncData_block(tvbuff_t *tvb, int offset,
guint16 u16PTCPTimeoutFactor;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* SlotNumber */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
@@ -3395,8 +3300,7 @@ dissect_PDIRData_block(tvbuff_t *tvb, int offset,
guint32 u32RecDataLen;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* SlotNumber */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
@@ -3425,8 +3329,7 @@ dissect_PDIRGlobalData_block(tvbuff_t *tvb, int offset,
e_uuid_t uuid;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* IRDataID */
offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
@@ -3452,8 +3355,7 @@ dissect_PDIRFrameData_block(tvbuff_t *tvb, int offset,
guint8 u8NumberOfTxPortGroups;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* FrameSendOffset */
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
@@ -3825,7 +3727,7 @@ dissect_ARBlockReq(tvbuff_t *tvb, int offset,
hf_pn_io_ar_uuid, &uuid);
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_sessionkey, &u16SessionKey);
- offset = dissect_MAC(tvb, offset, pinfo, tree,
+ offset = dissect_pn_mac(tvb, offset, pinfo, tree,
hf_pn_io_cminitiator_macadd, mac);
offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
hf_pn_io_cminitiator_objectuuid, &uuid);
@@ -3875,7 +3777,7 @@ dissect_ARBlockRes(tvbuff_t *tvb, int offset,
hf_pn_io_ar_uuid, &uuid);
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_sessionkey, &u16SessionKey);
- offset = dissect_MAC(tvb, offset, pinfo, tree,
+ offset = dissect_pn_mac(tvb, offset, pinfo, tree,
hf_pn_io_cmresponder_macadd, mac);
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_cmresponder_udprtport, &u16UDPRTPort);
@@ -3955,7 +3857,7 @@ dissect_IOCRBlockReq(tvbuff_t *tvb, int offset,
hf_pn_io_data_hold_factor, &u16DataHoldFactor);
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
hf_pn_io_iocr_tag_header, &u16IOCRTagHeader);
- offset = dissect_MAC(tvb, offset, pinfo, tree,
+ offset = dissect_pn_mac(tvb, offset, pinfo, tree,
hf_pn_io_iocr_multicast_mac_add, mac);
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
@@ -4470,8 +4372,7 @@ dissect_IsochronousModeData(tvbuff_t *tvb, int offset,
guint32 u32TimeIOOutputValid;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* SlotNumber */
offset = dissect_dcerpc_uint16(tvb, offset, pinfo, tree, drep,
@@ -4515,8 +4416,7 @@ dissect_MultipleBlockHeader_block(tvbuff_t *tvb, int offset,
tvbuff_t *tvb_new;
- proto_tree_add_string_format(tree, hf_pn_io_padding, tvb, offset, 2, "padding", "Padding: 2 bytes");
- offset += 2;
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
offset = dissect_dcerpc_uint32(tvb, offset, pinfo, tree, drep,
hf_pn_io_api, &u32Api);
@@ -4543,11 +4443,7 @@ dissect_RecordDataReadQuery_block(tvbuff_t *tvb, int offset,
packet_info *pinfo _U_, proto_tree *tree, proto_item *item _U_, guint8 *drep _U_, guint16 u16BodyLength)
{
-
- proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u16BodyLength, "undecoded",
- "Undecoded Data: %d bytes", u16BodyLength);
-
- return offset;
+ return dissect_pn_undecoded(tvb, offset, pinfo, tree, u16BodyLength);
}
@@ -4825,11 +4721,7 @@ dissect_block(tvbuff_t *tvb, int offset,
dissect_ControlConnect_block(tvb, offset, pinfo, sub_tree, sub_item, drep);
break;
default:
- header_item = proto_tree_add_string_format(sub_tree, hf_pn_io_data, tvb, offset, u16BodyLength, "undecoded", "Undecoded Block Data: %d bytes", u16BodyLength);
- expert_add_info_format(pinfo, header_item, PI_UNDECODED, PI_WARN,
- "Undecoded block type %s (0x%x), %u bytes",
- val_to_str(u16BlockType, pn_io_block_type, ""),
- u16BlockType, u16BodyLength);
+ dissect_pn_undecoded(tvb, offset, pinfo, sub_tree, u16BodyLength);
}
offset += u16BodyLength;
@@ -4979,21 +4871,16 @@ static int
dissect_RecordDataRead(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, guint8 *drep, guint16 u16Index, guint32 u32RecDataLen)
{
- proto_item *item;
/* user specified format? */
if(u16Index < 0x8000) {
- item = proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u32RecDataLen, "data",
- "RecordDataRead: %d bytes", u32RecDataLen);
- offset += u32RecDataLen;
+ offset = dissect_pn_user_data(tvb, offset, pinfo, tree, u32RecDataLen, "User Specified Data");
return offset;
}
/* "reserved for profiles" */
if(u16Index == 0xb02e) {
- item = proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u32RecDataLen, "data",
- "RecordDataRead: %d bytes - undecoded as index is reserved for profiles", u32RecDataLen);
- offset += u32RecDataLen;
+ offset = dissect_pn_user_data(tvb, offset, pinfo, tree, u32RecDataLen, "Reserved for Profiles");
return offset;
}
@@ -5128,13 +5015,7 @@ dissect_RecordDataRead(tvbuff_t *tvb, int offset,
offset = dissect_blocks(tvb, offset, pinfo, tree, drep);
break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u32RecDataLen, "data",
- "RecordDataRead: %d bytes", u32RecDataLen);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded index %s (0x%x), %u bytes",
- val_to_str(u16Index, pn_io_index, ""),
- u16Index, u32RecDataLen);
- offset += u32RecDataLen;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, u32RecDataLen);
}
return offset;
@@ -5167,21 +5048,14 @@ static int
dissect_RecordDataWrite(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, guint8 *drep, guint16 u16Index, guint32 u32RecDataLen)
{
- proto_item *item;
/* user specified format? */
if(u16Index < 0x8000) {
- item = proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u32RecDataLen, "data",
- "RecordDataWrite: %d bytes", u32RecDataLen);
- offset += u32RecDataLen;
- return offset;
+ return dissect_pn_user_data(tvb, offset, pinfo, tree, u32RecDataLen, "User Specified Data");
}
/* "reserved for profiles" */
if(u16Index == 0xb02e) {
- item = proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u32RecDataLen, "data",
- "RecordDataWrite: %d bytes - undecoded as index is reserved for profiles", u32RecDataLen);
- offset += u32RecDataLen;
- return offset;
+ return dissect_pn_user_data(tvb, offset, pinfo, tree, u32RecDataLen, "Reserved for profiles");
}
/* see: pn_io_index */
@@ -5202,13 +5076,7 @@ dissect_RecordDataWrite(tvbuff_t *tvb, int offset,
offset = dissect_block(tvb, offset, pinfo, tree, drep, &u16Index, &u32RecDataLen);
break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_io_data, tvb, offset, u32RecDataLen, "data",
- "RecordDataWrite: %d bytes", u32RecDataLen);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded index %s (0x%x), %u bytes",
- val_to_str(u16Index, pn_io_index, ""),
- u16Index, u32RecDataLen);
- offset += u32RecDataLen;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, u32RecDataLen);
}
return offset;
@@ -5355,8 +5223,8 @@ dissect_PNIO_C_SDU(tvbuff_t *tvb, int offset,
/* XXX - dissect the remaining data */
/* this will be one or more DataItems followed by an optional GAP and RTCPadding */
/* as we don't have the required context information to dissect the specific DataItems, this will be tricky :-( */
- data_item = proto_tree_add_protocol_format(data_tree, proto_pn_io, tvb, offset, tvb_length_remaining(tvb, offset),
- "Data: %u bytes (including GAP and RTCPadding)", tvb_length_remaining(tvb, offset));
+ offset = dissect_pn_user_data(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset), "User Data (including GAP and RTCPadding)");
+
}
return offset;
@@ -5459,8 +5327,7 @@ dissect_PNIO_RTA(tvbuff_t *tvb, int offset,
offset = dissect_PNIO_status(tvb, offset, pinfo, rta_tree, drep);
break;
default:
- proto_tree_add_string_format(tree, hf_pn_io_data, tvb, 0, tvb_length(tvb), "data",
- "PN-IO Alarm: unknown PDU type 0x%x", u8PDUType);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length(tvb));
}
proto_item_set_len(rta_item, offset - start_offset);
@@ -5720,8 +5587,6 @@ proto_register_pn_io (void)
{ "SeqNumber", "pn_io.seq_number", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_io_record_data_length,
{ "RecordDataLength", "pn_io.record_data_length", FT_UINT32, BASE_DEC, NULL, 0x0, "", HFILL }},
- { &hf_pn_io_padding,
- { "Padding", "pn_io.padding", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_io_add_val1,
{ "AdditionalValue1", "pn_io.add_val1", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_io_add_val2,
@@ -5769,8 +5634,6 @@ proto_register_pn_io (void)
{ "ErrorCode2 ", "pn_io.error_code2", FT_UINT8, BASE_HEX, VALS(pn_io_error_code2_pnio_rta_err_cls_protocol), 0x0, "", HFILL }},
{ &hf_pn_io_block,
{ "", "pn_io.block", FT_NONE, BASE_NONE, NULL, 0x0, "", HFILL }},
- { &hf_pn_io_data,
- { "Undecoded Data", "pn_io.data", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_io_alarm_type,
{ "AlarmType", "pn_io.alarm_type", FT_UINT16, BASE_HEX, VALS(pn_io_alarm_type), 0x0, "", HFILL }},
@@ -6068,6 +5931,7 @@ proto_register_pn_io (void)
{ "IMVersionMinor", "pn_io.im_version_minor", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
{ &hf_pn_io_im_supported,
{ "IM_Supported", "pn_io.im_supported", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
+
{ &hf_pn_io_number_of_ars,
{ "NumberOfARs", "pn_io.number_of_ars", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_io_cycle_counter,
diff --git a/epan/dissectors/packet-dcom-cba-acco.c b/plugins/profinet/packet-dcom-cba-acco.c
index b87340b976..3becc4a40d 100644
--- a/epan/dissectors/packet-dcom-cba-acco.c
+++ b/plugins/profinet/packet-dcom-cba-acco.c
@@ -37,8 +37,8 @@
#include <epan/expert.h>
#include <epan/emem.h>
#include <epan/addr_resolv.h>
-#include "packet-dcerpc.h"
-#include "packet-dcom.h"
+#include <epan/dissectors/packet-dcerpc.h>
+#include <epan/dissectors/packet-dcom.h>
#include "packet-dcom-cba-acco.h"
static int hf_cba_acco_opnum = -1;
@@ -4737,7 +4737,8 @@ proto_register_dcom_cba_acco (void)
{ &hf_cba_acco_cdb_cookie,
{ "CDBCookie", "cba.acco.cdb_cookie", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
{ &hf_cba_acco_conn_error_state,
- { "ConnErrorState", "cba.acco.conn_error_state", FT_UINT32, BASE_HEX, VALS(dcom_hresult_vals), 0x0, "", HFILL }},
+ /* XXX - find out, why VALS doesn't work here! */
+ { "ConnErrorState", "cba.acco.conn_error_state", FT_UINT32, BASE_HEX, NULL /*VALS(dcom_hresult_vals)*/, 0x0, "", HFILL }},
{ &hf_cba_acco_diag_req,
{ "Request", "cba.acco.diag_req", FT_UINT32, BASE_HEX, VALS(cba_acco_diag_req_vals), 0x0, "", HFILL }},
{ &hf_cba_acco_diag_in_length,
@@ -4770,10 +4771,11 @@ proto_register_dcom_cba_acco (void)
{ "CRLength", "cba.acco.serversrt_cr_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_cba_acco_serversrt_cr_flags,
{ "Flags", "cba.acco.serversrt_cr_flags", FT_UINT32, BASE_HEX, 0, 0x0, "", HFILL }},
+ /* XXX - find out, why TFS doesn't work here! */
{ &hf_cba_acco_serversrt_cr_flags_timestamped,
- { "Timestamped", "cba.acco.serversrt_cr_flags_timestamped", FT_BOOLEAN, 32, TFS (&flags_set_truth), 0x1, "", HFILL }},
+ { "Timestamped", "cba.acco.serversrt_cr_flags_timestamped", FT_BOOLEAN, 32, NULL /*TFS (&flags_set_truth)*/, 0x1, "", HFILL }},
{ &hf_cba_acco_serversrt_cr_flags_reconfigure,
- { "Reconfigure", "cba.acco.serversrt_cr_flags_reconfigure", FT_BOOLEAN, 32, TFS (&flags_set_truth), 0x2, "", HFILL }},
+ { "Reconfigure", "cba.acco.serversrt_cr_flags_reconfigure", FT_BOOLEAN, 32, NULL /*TFS (&flags_set_truth)*/, 0x2, "", HFILL }},
{ &hf_cba_type_desc_len,
{ "TypeDescLen", "cba.acco.type_desc_len", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_cba_acco_serversrt_record_length,
diff --git a/epan/dissectors/packet-dcom-cba-acco.h b/plugins/profinet/packet-dcom-cba-acco.h
index d7d2438a0a..d7d2438a0a 100644
--- a/epan/dissectors/packet-dcom-cba-acco.h
+++ b/plugins/profinet/packet-dcom-cba-acco.h
diff --git a/epan/dissectors/packet-dcom-cba.c b/plugins/profinet/packet-dcom-cba.c
index 36c0334ba8..a0079ddd35 100644
--- a/epan/dissectors/packet-dcom-cba.c
+++ b/plugins/profinet/packet-dcom-cba.c
@@ -35,9 +35,9 @@
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/expert.h>
-#include "packet-dcerpc.h"
-#include "packet-dcom.h"
-#include "packet-dcom-dispatch.h"
+#include <epan/dissectors/packet-dcerpc.h>
+#include <epan/dissectors/packet-dcom.h>
+#include <epan/dissectors/packet-dcom-dispatch.h>
#include "packet-dcom-cba-acco.h"
diff --git a/plugins/profinet/packet-pn-dcp.c b/plugins/profinet/packet-pn-dcp.c
index 4eeb24642a..919067e59e 100644
--- a/plugins/profinet/packet-pn-dcp.c
+++ b/plugins/profinet/packet-pn-dcp.c
@@ -38,7 +38,10 @@
#include <epan/packet.h>
#include <epan/emem.h>
#include <epan/dissectors/packet-dcerpc.h>
-#include <epan/expert.h>
+
+#include "packet-pn.h"
+
+
static int proto_pn_dcp = -1;
@@ -60,10 +63,10 @@ static int hf_pn_dcp_result = -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_res_status = -1;
+static int hf_pn_dcp_block_info = -1;
static int hf_pn_dcp_suboption_ip = -1;
-static int hf_pn_dcp_suboption_ip_status = -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;
@@ -83,33 +86,33 @@ 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_deviceinitiative = -1;
+static int hf_pn_dcp_deviceinitiative_value = -1;
+
static int hf_pn_dcp_suboption_all = -1;
static int hf_pn_dcp_suboption_manuf = -1;
-static int hf_pn_dcp_data = -1;
-
static gint ett_pn_dcp = -1;
static gint ett_pn_dcp_block = -1;
-#define FRAME_ID_UC 0xfefd
-#define FRAME_ID_MC 0xfefe
-#define FRAME_ID_MC_RESP 0xfeff
#define PNDCP_SERVICE_ID_GET 0x03
#define PNDCP_SERVICE_ID_SET 0x04
#define PNDCP_SERVICE_ID_IDENTIFY 0x05
+#define PNDCP_SERVICE_ID_HELLO 0x06
static const value_string pn_dcp_service_id[] = {
- { 0x00, "reserved" },
- { 0x01, "Manufacturer specific" },
- { 0x02, "Manufacturer specific" },
- { PNDCP_SERVICE_ID_GET, "Get" },
- { PNDCP_SERVICE_ID_SET, "Set" },
- { PNDCP_SERVICE_ID_IDENTIFY, "Identify" },
- /* 0x06 - 0xff reserved */
+ { 0x00, "reserved" },
+ { 0x01, "Manufacturer specific" },
+ { 0x02, "Manufacturer specific" },
+ { PNDCP_SERVICE_ID_GET, "Get" },
+ { PNDCP_SERVICE_ID_SET, "Set" },
+ { PNDCP_SERVICE_ID_IDENTIFY,"Identify" },
+ { PNDCP_SERVICE_ID_HELLO, "Hello" },
+ /* 0x07 - 0xff reserved */
{ 0, NULL }
};
@@ -145,37 +148,39 @@ 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_CONTROL 0x05
-#define PNDCP_OPTION_MANUF_X80 0x80
-#define PNDCP_OPTION_MANUF_X81 0x81
-#define PNDCP_OPTION_MANUF_X82 0x82
-#define PNDCP_OPTION_MANUF_X83 0x83
-#define PNDCP_OPTION_MANUF_X84 0x84
-#define PNDCP_OPTION_MANUF_X85 0x85
-#define PNDCP_OPTION_MANUF_X86 0x86
-#define PNDCP_OPTION_ALLSELECTOR 0xff
+#define PNDCP_OPTION_IP 0x01
+#define PNDCP_OPTION_DEVICE 0x02
+#define PNDCP_OPTION_DHCP 0x03
+#define PNDCP_OPTION_LLDP 0x04
+#define PNDCP_OPTION_CONTROL 0x05
+#define PNDCP_OPTION_DEVICEINITIATIVE 0x06
+#define PNDCP_OPTION_MANUF_X80 0x80
+#define PNDCP_OPTION_MANUF_X81 0x81
+#define PNDCP_OPTION_MANUF_X82 0x82
+#define PNDCP_OPTION_MANUF_X83 0x83
+#define PNDCP_OPTION_MANUF_X84 0x84
+#define PNDCP_OPTION_MANUF_X85 0x85
+#define PNDCP_OPTION_MANUF_X86 0x86
+#define PNDCP_OPTION_ALLSELECTOR 0xff
static const value_string pn_dcp_option[] = {
{ 0x00, "reserved" },
- { PNDCP_OPTION_IP, "IP" },
- { PNDCP_OPTION_DEVICE, "Device properties" },
- { PNDCP_OPTION_DHCP, "DHCP" },
- { PNDCP_OPTION_LLDP, "LLDP" },
- { PNDCP_OPTION_CONTROL, "Control" },
- /*0x06 - 0x7f reserved */
+ { PNDCP_OPTION_IP, "IP" },
+ { PNDCP_OPTION_DEVICE, "Device properties" },
+ { PNDCP_OPTION_DHCP, "DHCP" },
+ { PNDCP_OPTION_LLDP, "LLDP" },
+ { PNDCP_OPTION_CONTROL, "Control" },
+ { PNDCP_OPTION_DEVICEINITIATIVE, "Device Initiative" },
+ /*0x07 - 0x7f reserved */
/*0x80 - 0xfe manufacturer specific */
- { PNDCP_OPTION_MANUF_X80, "Manufacturer specific" },
- { PNDCP_OPTION_MANUF_X81, "Manufacturer specific" },
- { PNDCP_OPTION_MANUF_X82, "Manufacturer specific" },
- { PNDCP_OPTION_MANUF_X83, "Manufacturer specific" },
- { PNDCP_OPTION_MANUF_X84, "Manufacturer specific" },
- { PNDCP_OPTION_MANUF_X85, "Manufacturer specific" },
- { PNDCP_OPTION_MANUF_X86, "Manufacturer specific" },
- { PNDCP_OPTION_ALLSELECTOR, "All Selector" },
+ { PNDCP_OPTION_MANUF_X80, "Manufacturer specific" },
+ { PNDCP_OPTION_MANUF_X81, "Manufacturer specific" },
+ { PNDCP_OPTION_MANUF_X82, "Manufacturer specific" },
+ { PNDCP_OPTION_MANUF_X83, "Manufacturer specific" },
+ { PNDCP_OPTION_MANUF_X84, "Manufacturer specific" },
+ { PNDCP_OPTION_MANUF_X85, "Manufacturer specific" },
+ { PNDCP_OPTION_MANUF_X86, "Manufacturer specific" },
+ { PNDCP_OPTION_ALLSELECTOR, "All Selector" },
{ 0, NULL }
};
@@ -190,7 +195,7 @@ static const value_string pn_dcp_suboption_ip[] = {
{ 0, NULL }
};
-static const value_string pn_dcp_suboption_ip_status[] = {
+static const value_string pn_dcp_suboption_ip_block_info[] = {
{ 0x0000, "IP not set" },
{ 0x0001, "IP set" },
{ 0x0002, "IP set by DHCP" },
@@ -251,6 +256,22 @@ static const value_string pn_dcp_suboption_control[] = {
{ 0, NULL }
};
+#define PNDCP_SUBOPTION_DEVICEINITIATIVE 0x01
+
+static const value_string pn_dcp_suboption_deviceinitiative[] = {
+ { 0x00, "Reserved" },
+ { PNDCP_SUBOPTION_DEVICEINITIATIVE, "Device Initiative" },
+ /*0x00 - 0xff reserved */
+ { 0, NULL }
+};
+
+static const value_string pn_dcp_deviceinitiative_value[] = {
+ { 0x00, "Device does not issue a DCP-Hello-ReqPDU after power on" },
+ { 0x01, "Device does issue a DCP-Hello-ReqPDU after power on" },
+ /*0x02 - 0xff reserved */
+ { 0, NULL }
+};
+
static const value_string pn_dcp_suboption_all[] = {
{ 0xff, "ALL Selector" },
/* all other reserved */
@@ -264,93 +285,6 @@ static const value_string pn_dcp_suboption_manuf[] = {
-/* dissect an 8 bit unsigned integer */
-static int
-dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint8 *pdata)
-{
- guint8 data;
-
- data = tvb_get_guint8 (tvb, offset);
- if (tree) {
- proto_tree_add_uint(tree, hfindex, tvb, offset, 1, data);
- }
- if (pdata)
- *pdata = data;
- return offset + 1;
-}
-
-/* dissect a 16 bit unsigned integer */
-static int
-dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint16 *pdata)
-{
- guint16 data;
-
- data = tvb_get_ntohs (tvb, offset);
-
- if (tree) {
- proto_tree_add_uint(tree, hfindex, tvb, offset, 2, data);
- }
- if (pdata)
- *pdata = data;
- return offset + 2;
-}
-
-/* dissect a 32 bit unsigned integer */
-static int
-dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint32 *pdata)
-{
- guint32 data;
-
- data = tvb_get_ntohl (tvb, offset);
-
- if (tree) {
- proto_tree_add_uint(tree, hfindex, tvb, offset, 4, data);
- }
- if (pdata)
- *pdata = data;
- return offset+4;
-}
-
-/* dissect an IPv4 address */
-static int
-dissect_pn_ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint32 *pdata)
-{
- guint32 data;
-
- data = tvb_get_ipv4(tvb, offset);
- if(tree)
- proto_tree_add_ipv4(tree, hfindex, tvb, offset, 4, data);
-
- if (pdata)
- *pdata = data;
-
- return offset + 4;
-}
-
-/* dissect some padding data (with the given length) */
-static int
-dissect_pn_padding(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int length)
-{
- proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, length, "data",
- "Padding: %u byte", length);
-
- return offset + length;
-}
-
-/* append the given info text */
-static void
-pn_append_info(packet_info *pinfo, proto_item *dcp_item, const char *text)
-{
- if (check_col(pinfo->cinfo, COL_INFO))
- col_append_fstr(pinfo->cinfo, COL_INFO, text);
-
- proto_item_append_text(dcp_item, "%s", text);
-}
/* dissect the option field */
@@ -384,6 +318,10 @@ dissect_PNDCP_Option(tvbuff_t *tvb, int offset, packet_info *pinfo,
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption);
val_str = pn_dcp_suboption_control;
break;
+ case(PNDCP_OPTION_DEVICEINITIATIVE):
+ offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_deviceinitiative, &suboption);
+ val_str = pn_dcp_suboption_deviceinitiative;
+ break;
case(PNDCP_OPTION_ALLSELECTOR):
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_all, &suboption);
val_str = pn_dcp_suboption_all;
@@ -416,7 +354,6 @@ dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo,
guint16 status;
guint16 req_status;
guint32 ip;
- proto_item *item;
offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_suboption_ip, &suboption);
@@ -427,18 +364,15 @@ dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo,
pn_append_info(pinfo, dcp_item, ", MAC");
proto_item_append_text(block_item, "IP/MAC");
- /* XXX - improve this */
- proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_IP, suboption, block_length);
- offset += block_length;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
break;
case(PNDCP_SUBOPTION_IP_IP):
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_status, &status);
- proto_item_append_text(block_item, ", Status: %s", val_to_str(status, pn_dcp_suboption_ip_status, "Unknown"));
+ 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"));
@@ -457,12 +391,7 @@ dissect_PNDCP_Suboption_IP(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_item_append_text(block_item, ", Router: %s", ip_to_str((guint8*)&ip));
break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_IP, suboption, block_length);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded suboption %u, %u bytes",
- suboption, block_length);
- offset += block_length;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
}
return offset;
@@ -484,12 +413,12 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
char *typeofstation;
char *nameofstation;
guint16 status=0;
- proto_item *item;
+
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_device, &suboption);
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_res_status, &status);
+ offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
block_length -= 2;
}
@@ -556,12 +485,7 @@ dissect_PNDCP_Suboption_Device(tvbuff_t *tvb, int offset, packet_info *pinfo,
}
break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_DEVICE, suboption, block_length);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded suboption %u, %u bytes",
- suboption, block_length);
- offset += block_length;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
}
return offset;
@@ -576,7 +500,6 @@ dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo,
{
guint8 suboption;
guint16 block_length;
- proto_item *item;
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_dhcp, &suboption);
@@ -590,12 +513,7 @@ dissect_PNDCP_Suboption_DHCP(tvbuff_t *tvb, int offset, packet_info *pinfo,
offset += block_length;
break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_DHCP, suboption, block_length);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded suboption %u, %u bytes",
- suboption, block_length);
- offset += block_length;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
}
return offset;
@@ -610,17 +528,12 @@ dissect_PNDCP_Suboption_LLDP(tvbuff_t *tvb, int offset, packet_info *pinfo,
{
guint8 suboption;
guint16 block_length;
- proto_item *item;
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);
- /* XXX - improve this */
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_LLDP, suboption, block_length);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded suboption %u", suboption);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
return offset;
}
@@ -637,7 +550,6 @@ dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo,
guint16 block_length;
gchar *info_str;
guint16 status;
- proto_item *item;
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_control, &suboption);
@@ -647,23 +559,20 @@ 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_res_status, &status);
+ offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
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_res_status, &status);
+ offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
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_res_status, &status);
+ offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_info, &status);
block_length -= 2;
- /* XXX - improve this */
- proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data: %d bytes", block_length);
- offset += block_length;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
break;
case(PNDCP_SUBOPTION_CONTROL_RESPONSE):
proto_item_append_text(block_item, "Control/Response");
@@ -675,18 +584,44 @@ dissect_PNDCP_Suboption_Control(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_item_append_text(block_item, ", Result: %s", val_to_str(result, pn_dcp_result, "Unknown"));
break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_CONTROL, suboption, block_length);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded suboption %u, %u bytes",
- suboption, block_length);
- offset += block_length;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
}
return offset;
}
+/* dissect the "deviceinitaitve" suboption */
+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 suboption;
+ guint16 block_length;
+ guint16 status;
+ 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);
+ 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;
+}
+
+
/* dissect the "all" suboption */
static int
dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo,
@@ -695,7 +630,7 @@ dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo,
{
guint8 suboption;
guint16 block_length;
- proto_item *item;
+
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_all, &suboption);
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
@@ -706,12 +641,7 @@ dissect_PNDCP_Suboption_All(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_item_append_text(block_item, "All/All");
break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data(0x%x/0x%x): %d bytes", PNDCP_OPTION_ALLSELECTOR, suboption, block_length);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded suboption %u, %u bytes",
- suboption, block_length);
- offset += block_length;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
}
return offset;
@@ -726,7 +656,7 @@ dissect_PNDCP_Suboption_Manuf(tvbuff_t *tvb, int offset, packet_info *pinfo,
{
guint8 suboption;
guint16 block_length;
- proto_item *item;
+
offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_dcp_suboption_manuf, &suboption);
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_dcp_block_length, &block_length);
@@ -735,12 +665,7 @@ dissect_PNDCP_Suboption_Manuf(tvbuff_t *tvb, int offset, packet_info *pinfo,
default:
pn_append_info(pinfo, dcp_item, ", Manufacturer Specific");
proto_item_append_text(block_item, "Manufacturer Specific");
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, block_length, "data",
- "Block data: %d bytes", block_length);
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded suboption %u, %u bytes",
- suboption, block_length);
- offset += block_length;
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, block_length);
}
return offset;
@@ -782,6 +707,9 @@ dissect_PNDCP_Block(tvbuff_t *tvb, int offset, packet_info *pinfo,
case(PNDCP_OPTION_CONTROL):
offset = dissect_PNDCP_Suboption_Control(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
break;
+ case(PNDCP_OPTION_DEVICEINITIATIVE):
+ offset = dissect_PNDCP_Suboption_DeviceInitiative(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
+ break;
case(PNDCP_OPTION_ALLSELECTOR):
offset = dissect_PNDCP_Suboption_All(tvb, offset, pinfo, block_tree, block_item, dcp_item, is_response);
break;
@@ -815,7 +743,6 @@ dissect_PNDCP_PDU(tvbuff_t *tvb,
int offset = 0;
gchar *xid_str;
gboolean is_response = FALSE;
- proto_item *item;
offset = dissect_pn_uint8 (tvb, offset, pinfo, tree, hf_pn_dcp_service_id, &service_id);
@@ -840,12 +767,12 @@ dissect_PNDCP_PDU(tvbuff_t *tvb,
case(PNDCP_SERVICE_ID_IDENTIFY):
pn_append_info(pinfo, dcp_item, "Ident");
break;
+ case(PNDCP_SERVICE_ID_HELLO):
+ pn_append_info(pinfo, dcp_item, "Hello");
+ is_response = TRUE;
+ break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, tvb_length_remaining(tvb, offset), "data",
- "PN-DCP Unknown service ID %u, Data: %d bytes", service_id, tvb_length_remaining(tvb, offset));
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded service ID %u, %u bytes",
- service_id, tvb_length_remaining(tvb, offset));
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset));
return;
}
@@ -862,11 +789,7 @@ dissect_PNDCP_PDU(tvbuff_t *tvb,
is_response = TRUE;
break;
default:
- item = proto_tree_add_string_format(tree, hf_pn_dcp_data, tvb, offset, tvb_length_remaining(tvb, offset), "data",
- "PN-DCP Unknown service type %u, Data: %d bytes", service_type, tvb_length_remaining(tvb, offset));
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
- "Undecoded service type %u, %u bytes",
- service_type, tvb_length_remaining(tvb, offset));
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset));
return;
}
@@ -936,11 +859,11 @@ proto_register_pn_dcp (void)
{ &hf_pn_dcp,
{ "PROFINET DCP", "pn_dcp", FT_NONE, BASE_NONE, NULL, 0x0, "", HFILL }},
{ &hf_pn_dcp_service_id,
- { "Service-ID", "pn_dcp.service_id", FT_UINT8, BASE_DEC, VALS(pn_dcp_service_id), 0x0, "", HFILL }},
+ { "ServiceID", "pn_dcp.service_id", FT_UINT8, BASE_DEC, VALS(pn_dcp_service_id), 0x0, "", HFILL }},
{ &hf_pn_dcp_service_type,
- { "Service-Type", "pn_dcp.service_type", FT_UINT8, BASE_DEC, VALS(pn_dcp_service_type), 0x0, "", HFILL }},
+ { "ServiceType", "pn_dcp.service_type", FT_UINT8, BASE_DEC, VALS(pn_dcp_service_type), 0x0, "", HFILL }},
{ &hf_pn_dcp_xid,
- { "xid", "pn_dcp.xid", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
+ { "Xid", "pn_dcp.xid", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
{ &hf_pn_dcp_reserved8,
{ "Reserved", "pn_dcp.reserved8", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_dcp_reserved16,
@@ -950,7 +873,7 @@ proto_register_pn_dcp (void)
{ &hf_pn_dcp_data_length,
{ "DCPDataLength", "pn_dcp.data_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_dcp_block_length,
- { "DataBlockLength", "pn_dcp.block_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
+ { "DCPBlockLength", "pn_dcp.block_length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_dcp_option,
{ "Option", "pn_dcp.option", FT_UINT8, BASE_DEC, VALS(pn_dcp_option), 0x0, "", HFILL }},
{ &hf_pn_dcp_suboption,
@@ -961,12 +884,12 @@ proto_register_pn_dcp (void)
{ "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_res_status,
- { "ResponseStatus", "pn_dcp.res_status", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
+ { &hf_pn_dcp_block_info,
+ { "BlockInfo", "pn_dcp.block_info", FT_UINT16, BASE_DEC, NULL, 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_status,
- { "Status", "pn_dcp.suboption_ip_status", FT_UINT16, BASE_DEC, VALS(pn_dcp_suboption_ip_status), 0x0, "", HFILL }},
+ { &hf_pn_dcp_suboption_ip_block_info,
+ { "BlockInfo", "pn_dcp.suboption_ip_block_info", FT_UINT16, BASE_DEC, VALS(pn_dcp_suboption_ip_block_info), 0x0, "", HFILL }},
{ &hf_pn_dcp_suboption_ip_ip,
{ "IPaddress", "pn_dcp.subobtion_ip_ip", FT_IPv4, BASE_NONE, NULL, 0x0, "", HFILL }},
{ &hf_pn_dcp_suboption_ip_subnetmask,
@@ -1000,14 +923,16 @@ proto_register_pn_dcp (void)
{ &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_deviceinitiative,
+ { "Suboption", "pn_dcp.suboption_deviceinitiative", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_deviceinitiative), 0x0, "", HFILL }},
+ { &hf_pn_dcp_deviceinitiative_value,
+ { "DeviceInitiativeValue", "pn_dcp.deviceinitiative_value", FT_UINT16, BASE_DEC, VALS(pn_dcp_deviceinitiative_value), 0x0, "", HFILL }},
+
{ &hf_pn_dcp_suboption_all,
{ "Suboption", "pn_dcp.suboption_all", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_all), 0x0, "", HFILL }},
{ &hf_pn_dcp_suboption_manuf,
{ "Suboption", "pn_dcp.suboption_manuf", FT_UINT8, BASE_DEC, VALS(pn_dcp_suboption_manuf), 0x0, "", HFILL }},
-
- { &hf_pn_dcp_data,
- { "Undecoded Data", "pn_dcp.data", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
};
static gint *ett[] = {
diff --git a/plugins/profinet/packet-pn-mrp.c b/plugins/profinet/packet-pn-mrp.c
index 9ac6856410..22ca9972c8 100644
--- a/plugins/profinet/packet-pn-mrp.c
+++ b/plugins/profinet/packet-pn-mrp.c
@@ -39,7 +39,9 @@
#include <epan/dissectors/packet-dcerpc.h>
#include <epan/oui.h>
#include <epan/etypes.h>
-#include <epan/expert.h>
+
+#include "packet-pn.h"
+
static int proto_pn_mrp = -1;
@@ -59,8 +61,6 @@ static int hf_pn_mrp_manufacturer_oui = -1;
static int hf_pn_mrp_domain_uuid = -1;
static int hf_pn_mrp_oui = -1;
-static int hf_pn_mrp_data = -1;
-
static gint ett_pn_mrp = -1;
@@ -112,30 +112,6 @@ static const value_string pn_mrp_prio_vals[] = {
-/* XXX - use include file instead for these helpers */
-extern int dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint8 *pdata);
-
-extern int dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint16 *pdata);
-
-extern int dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint32 *pdata);
-
-extern int dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, gint16 *pdata);
-
-extern int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint32 *pdata);
-
-extern int dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint8 *pdata);
-
-extern int dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, e_uuid_t *uuid);
-
-
-
static int
dissect_PNMRP_Common(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item)
@@ -178,9 +154,7 @@ dissect_PNMRP_LinkUp(tvbuff_t *tvb, int offset,
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_blocked, &blocked);
/* Padding */
- if (offset % 4) {
- offset += 4 - (offset % 4);
- }
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "LinkUp");
@@ -210,9 +184,7 @@ dissect_PNMRP_LinkDown(tvbuff_t *tvb, int offset,
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_blocked, &blocked);
/* Padding */
- if (offset % 4) {
- offset += 4 - (offset % 4);
- }
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "LinkDown");
@@ -254,9 +226,7 @@ dissect_PNMRP_Test(tvbuff_t *tvb, int offset,
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_time_stamp, &time_stamp);
/* Padding */
- if (offset % 4) {
- offset += 4 - (offset % 4);
- }
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Test");
@@ -286,9 +256,7 @@ dissect_PNMRP_TopologyChange(tvbuff_t *tvb, int offset,
offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_mrp_interval, &interval);
/* Padding */
- /*if (offset % 4) {
- offset += 4 - (offset % 4);
- }*/
+ /*offset = dissect_pn_align4(tvb, offset, pinfo, tree);*/
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "TopologyChange");
@@ -303,41 +271,40 @@ static int
dissect_PNMRP_Option(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint8 length)
{
- proto_item *unknown_item;
- guint32 oui;
+ guint32 oui;
- /* OUI (organizational unique id) */
+ /* OUI (organizational unique id) */
offset = dissect_pn_oid(tvb, offset, pinfo,tree, hf_pn_mrp_oui, &oui);
length -= 3;
- switch (oui)
+ switch (oui)
{
case OUI_SIEMENS:
proto_item_append_text(item, "Option(SIEMENS)");
- unknown_item = proto_tree_add_string_format(tree, hf_pn_mrp_data, tvb, offset, length, "data",
- "Undecoded %u bytes of Siemens Option field", length);
- expert_add_info_format(pinfo, unknown_item, PI_UNDECODED, PI_WARN,
- "Undecoded %u bytes of Siemens Option field", length);
+ /* Padding */
+ if (offset % 4) {
+ length -= 4 - (offset % 4);
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
+ }
+ if(length != 0) {
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
+ }
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Option(Siemens)");
break;
default:
proto_item_append_text(item, "Option(Unknown-OUI)");
- unknown_item = proto_tree_add_string_format(tree, hf_pn_mrp_data, tvb, offset, length, "data",
- "Unknown OUI Data: %d bytes", length);
- expert_add_info_format(pinfo, unknown_item, PI_UNDECODED, PI_WARN,
- "Unknown OUI Data %u bytes", length);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
+
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Option");
- }
+ }
offset += length;
/* Padding */
- if (offset % 4) {
- offset += 4 - (offset % 4);
- }
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
return offset;
}
@@ -350,8 +317,7 @@ dissect_PNMRP_PDU(tvbuff_t *tvb, int offset,
guint16 version;
guint8 type;
guint8 length;
- gint i = 0;
- proto_item *unknown_item;
+ gint i;
tvbuff_t *tvb_new;
@@ -363,7 +329,7 @@ dissect_PNMRP_PDU(tvbuff_t *tvb, int offset,
tvb_new = tvb_new_subset(tvb, offset, -1, -1);
offset = 0;
- while(tvb_length_remaining(tvb, offset) > 0) {
+ for(i=0; tvb_length_remaining(tvb, offset) > 0; i++) {
/* MRP_TLVHeader.Type */
offset = dissect_pn_uint8(tvb_new, offset, pinfo, tree, hf_pn_mrp_type, &type);
@@ -377,8 +343,6 @@ dissect_PNMRP_PDU(tvbuff_t *tvb, int offset,
proto_item_append_text(item, ", ");
}
- i++;
-
switch(type) {
case(0x00):
/* no content */
@@ -406,21 +370,14 @@ dissect_PNMRP_PDU(tvbuff_t *tvb, int offset,
offset = dissect_PNMRP_Option(tvb_new, offset, pinfo, tree, item, length);
break;
default:
- unknown_item = proto_tree_add_string_format(tree, hf_pn_mrp_data, tvb_new, offset, length, "data",
- "PN-MRP Unknown TLVType 0x%x, Data: %d bytes", type, length);
- expert_add_info_format(pinfo, unknown_item, PI_UNDECODED, PI_WARN,
- "Unknown TLVType 0x%x, %u bytes",
- type, length);
- if (check_col(pinfo->cinfo, COL_INFO))
- col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
- proto_item_append_text(item, "Unknown TLVType 0x%x", type);
-
- offset += length;
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type);
+ proto_item_append_text(item, "Unknown TLVType 0x%x", type);
}
}
- /* will never be reached */
return offset;
}
@@ -456,9 +413,6 @@ void
proto_register_pn_mrp (void)
{
static hf_register_info hf[] = {
- { &hf_pn_mrp_data,
- { "Undecoded Data", "pn_mrp.data", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
-
{ &hf_pn_mrp_type,
{ "Type", "pn_mrp.type", FT_UINT8, BASE_HEX, VALS(pn_mrp_block_type_vals), 0x0, "", HFILL }},
{ &hf_pn_mrp_length,
diff --git a/plugins/profinet/packet-pn-mrrt.c b/plugins/profinet/packet-pn-mrrt.c
index f46d4e50de..727959a5fe 100644
--- a/plugins/profinet/packet-pn-mrrt.c
+++ b/plugins/profinet/packet-pn-mrrt.c
@@ -38,7 +38,8 @@
#include <epan/packet.h>
#include <epan/dissectors/packet-dcerpc.h>
#include <epan/oui.h>
-#include <epan/expert.h>
+
+#include "packet-pn.h"
static int proto_pn_mrrt = -1;
@@ -49,8 +50,6 @@ static int hf_pn_mrrt_length = -1;
static int hf_pn_mrrt_version = -1;
static int hf_pn_mrrt_sa = -1;
-static int hf_pn_mrrt_data = -1;
-
static gint ett_pn_mrrt = -1;
@@ -66,28 +65,6 @@ static const value_string pn_mrrt_block_type_vals[] = {
};
-/* XXX - use include file instead for these helpers */
-extern int dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint8 *pdata);
-
-extern int dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint16 *pdata);
-
-extern int dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint32 *pdata);
-
-extern int dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, gint16 *pdata);
-
-extern int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint32 *pdata);
-
-extern int dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint8 *pdata);
-
-extern int dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, e_uuid_t *uuid);
-
static int
@@ -124,9 +101,7 @@ dissect_PNMRRT_Test(tvbuff_t *tvb, int offset,
offset = dissect_pn_mac(tvb, offset, pinfo, tree, hf_pn_mrrt_sa, mac);
/* Padding */
- if (offset % 4) {
- offset += 4 - (offset % 4);
- }
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Test");
@@ -144,7 +119,6 @@ dissect_PNMRRT_PDU(tvbuff_t *tvb, int offset,
guint8 type;
guint8 length;
gint i =0;
- proto_item *unknown_item;
/* MRRT_Version */
@@ -182,21 +156,14 @@ dissect_PNMRRT_PDU(tvbuff_t *tvb, int offset,
offset = dissect_PNMRRT_Test(tvb, offset, pinfo, tree, item, length);
break;
default:
- unknown_item = proto_tree_add_string_format(tree, hf_pn_mrrt_data, tvb, offset, length, "data",
- "PN-MRRT Unknown TLVType 0x%x, Data: %d bytes", type, length);
- expert_add_info_format(pinfo, unknown_item, PI_UNDECODED, PI_WARN,
- "Unknown TLVType 0x%x, %u bytes",
- type, length);
- if (check_col(pinfo->cinfo, COL_INFO))
- col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type);
-
- proto_item_append_text(item, "Unknown TLVType 0x%x", type);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
- offset += length;
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_fstr(pinfo->cinfo, COL_INFO, "Unknown TLVType 0x%x", type);
+ proto_item_append_text(item, "Unknown TLVType 0x%x", type);
}
}
- /* will never be reached */
return offset;
}
@@ -244,8 +211,6 @@ void
proto_register_pn_mrrt (void)
{
static hf_register_info hf[] = {
- { &hf_pn_mrrt_data,
- { "Undecoded Data", "pn_mrrt.data", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_mrrt_type,
{ "Type", "pn_mrrt.type", FT_UINT8, BASE_HEX, VALS(pn_mrrt_block_type_vals), 0x0, "", HFILL }},
diff --git a/plugins/profinet/packet-pn-ptcp.c b/plugins/profinet/packet-pn-ptcp.c
index 65641bc1e5..6db442461d 100644
--- a/plugins/profinet/packet-pn-ptcp.c
+++ b/plugins/profinet/packet-pn-ptcp.c
@@ -38,12 +38,14 @@
#include <epan/packet.h>
#include <epan/dissectors/packet-dcerpc.h>
#include <epan/oui.h>
-#include <epan/expert.h>
+
+#include "packet-pn.h"
+
+
static int proto_pn_ptcp = -1;
static int hf_pn_ptcp = -1;
-static int hf_pn_ptcp_data = -1;
static int hf_pn_ptcp_header = -1;
static int hf_pn_ptcp_block = -1;
static int hf_pn_ptcp_block_tlvheader = -1;
@@ -53,8 +55,6 @@ static int hf_pn_ptcp_res2 = -1;
static int hf_pn_ptcp_delay10ns = -1;
static int hf_pn_ptcp_seq_id = -1;
static int hf_pn_ptcp_delay1ns = -1;
-static int hf_pn_ptcp_padding8 = -1;
-static int hf_pn_ptcp_padding16 = -1;
static int hf_pn_ptcp_delay1ps = -1;
static int hf_pn_ptcp_tl_length = -1;
@@ -83,7 +83,6 @@ static int hf_pn_ptcp_clockvariance = -1;
static int hf_pn_ptcp_clockrole = -1;
static int hf_pn_ptcp_oui = -1;
-static int hf_pn_ptcp_unknown_subtype = -1;
static int hf_pn_ptcp_profinet_subtype = -1;
static int hf_pn_ptcp_irdata_uuid = -1;
@@ -143,133 +142,6 @@ static const value_string pn_ptcp_profinet_subtype_vals[] = {
};
-/* XXX - use include file instead for these helpers */
-extern int dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint8 *pdata);
-
-extern int dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint16 *pdata);
-
-extern int dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
- proto_tree *tree, int hfindex, guint32 *pdata);
-
-
-
-/* dissect an 8 bit unsigned integer */
-int
-dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint8 *pdata)
-{
- guint8 data;
-
- data = tvb_get_guint8 (tvb, offset);
- if (tree) {
- proto_tree_add_uint(tree, hfindex, tvb, offset, 1, data);
- }
- if (pdata)
- *pdata = data;
- return offset + 1;
-}
-
-/* dissect a 16 bit unsigned integer */
-int
-dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint16 *pdata)
-{
- guint16 data;
-
- data = tvb_get_ntohs (tvb, offset);
-
- if (tree) {
- proto_tree_add_uint(tree, hfindex, tvb, offset, 2, data);
- }
- if (pdata)
- *pdata = data;
- return offset + 2;
-}
-
-/* dissect a 32 bit unsigned integer */
-int
-dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint32 *pdata)
-{
- guint32 data;
-
- data = tvb_get_ntohl (tvb, offset);
-
- if (tree) {
- proto_tree_add_uint(tree, hfindex, tvb, offset, 4, data);
- }
- if (pdata)
- *pdata = data;
- return offset+4;
-}
-
-/* dissect a 16 bit signed integer */
-int
-dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, gint16 *pdata)
-{
- gint16 data;
-
- data = tvb_get_ntohs (tvb, offset);
-
- if (tree) {
- proto_tree_add_int(tree, hfindex, tvb, offset, 2, data);
- }
- if (pdata)
- *pdata = data;
- return offset + 2;
-}
-
-/* dissect a 24bit OUI (IEC organizational unique id) */
-int
-dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint32 *pdata)
-{
- guint32 data;
-
- data = tvb_get_ntoh24(tvb, offset);
-
- if (tree) {
- proto_tree_add_uint(tree, hfindex, tvb, offset, 3, data);
- }
- if (pdata)
- *pdata = data;
- return offset+3;
-}
-
-/* dissect a 6 byte MAC address */
-int
-dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, guint8 *pdata)
-{
- guint8 data[6];
-
- tvb_memcpy(tvb, data, offset, 6);
- if(tree)
- proto_tree_add_ether(tree, hfindex, tvb, offset, 6, data);
-
- if (pdata)
- memcpy(pdata, data, 6);
-
- return offset + 6;
-}
-
-/* dissect a 12 byte UUID address */
-int
-dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
- proto_tree *tree, int hfindex, e_uuid_t *uuid)
-{
- guint8 drep[2] = { 0,0 };
-
- offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
- hfindex, uuid);
-
- return offset;
-}
-
-
static int
@@ -323,13 +195,12 @@ static int
dissect_PNPTCP_Time(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item)
{
- guint16 padding16;
guint32 Seconds;
guint32 NanoSeconds;
- /* Padding16 */
- offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_ptcp_padding16, &padding16);
+ /* Padding */
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* Seconds */
offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_seconds, &Seconds);
@@ -411,13 +282,12 @@ static int
dissect_PNPTCP_PortParameter(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item)
{
- guint16 padding16;
guint32 t2portrxdelay;
guint32 t3porttxdelay;
- /* Padding16 */
- offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_ptcp_padding16, &padding16);
+ /* Padding */
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* T2PortRxDelay */
offset = dissect_pn_uint32(tvb, offset, pinfo, tree, hf_pn_ptcp_t2portrxdelay, &t2portrxdelay);
@@ -470,9 +340,7 @@ dissect_PNPTCP_Option_PROFINET(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length)
{
guint8 subType;
- guint16 padding16;
e_uuid_t uuid;
- proto_item *unknown_item;
/* OUI already dissected! */
@@ -482,8 +350,8 @@ dissect_PNPTCP_Option_PROFINET(tvbuff_t *tvb, int offset,
switch(subType) {
case 1: /* RTData */
- /* Padding16 */
- offset = dissect_pn_uint16(tvb, offset, pinfo, tree, hf_pn_ptcp_padding16, &padding16);
+ /* Padding */
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* IRDataUUID */
offset = dissect_pn_uuid(tvb, offset, pinfo, tree, hf_pn_ptcp_irdata_uuid, &uuid);
@@ -496,11 +364,7 @@ dissect_PNPTCP_Option_PROFINET(tvbuff_t *tvb, int offset,
break;
default:
- unknown_item = proto_tree_add_string_format(tree, hf_pn_ptcp_data, tvb, offset, length, "data",
- "PROFINET Data: %d bytes", length);
- expert_add_info_format(pinfo, unknown_item, PI_UNDECODED, PI_WARN,
- "Unknown subType %u, %u bytes",
- subType, length);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
break;
}
@@ -513,16 +377,14 @@ dissect_PNPTCP_Option(tvbuff_t *tvb, int offset,
packet_info *pinfo, proto_tree *tree, proto_item *item, guint16 length)
{
guint32 oui;
- guint8 subType;
- proto_item *unknown_item;
/* verify remaining TLV length */
if (length < 4)
{
if (tree) {
- proto_tree_add_string_format(tree, hf_pn_ptcp_data, tvb, offset, length, "data",
- "Length: %u (too short, must be >= 4)", length);
+ /* too short */
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
}
return (offset);
}
@@ -540,12 +402,7 @@ dissect_PNPTCP_Option(tvbuff_t *tvb, int offset,
break;
default:
/* SubType */
- offset = dissect_pn_uint8(tvb, offset, pinfo, tree, hf_pn_ptcp_unknown_subtype, &subType);
- length --;
- unknown_item = proto_tree_add_string_format(tree, hf_pn_ptcp_data, tvb, offset, length, "data",
- "Unknown OUI Data: %d bytes", length);
- expert_add_info_format(pinfo, unknown_item, PI_UNDECODED, PI_WARN,
- "Unknown OUI Data %u bytes", length);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
}
return (offset);
@@ -564,7 +421,6 @@ dissect_PNPTCP_block(tvbuff_t *tvb, int offset,
proto_item *tlvheader_item;
proto_tree *tlvheader_tree;
guint32 u32SubStart;
- proto_item *unknown_item;
*end = FALSE;
@@ -612,10 +468,7 @@ dissect_PNPTCP_block(tvbuff_t *tvb, int offset,
dissect_PNPTCP_Option(tvb, offset, pinfo, sub_tree, sub_item, length);
break;
default:
- unknown_item = proto_tree_add_string_format(sub_tree, hf_pn_ptcp_data, tvb, offset, length, "data",
- "PN-PTCP Unknown BlockType 0x%x, Data: %d bytes", type, length);
- expert_add_info_format(pinfo, unknown_item, PI_UNDECODED, PI_WARN,
- "Unknown BlockType 0x%x, %u bytes", type, length);
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, length);
}
offset += length;
@@ -651,8 +504,6 @@ dissect_PNPTCP_Header(tvbuff_t *tvb, int offset,
guint32 delay10ns;
guint16 seq_id;
guint8 delay1ns;
- guint8 padding8;
- guint16 padding16;
guint16 delay1ps;
guint64 delayns;
guint32 delayms;
@@ -676,14 +527,14 @@ dissect_PNPTCP_Header(tvbuff_t *tvb, int offset,
/* Delay1ns */
offset = dissect_pn_uint8(tvb, offset, pinfo, header_tree, hf_pn_ptcp_delay1ns, &delay1ns);
- /* Padding8 */
- offset = dissect_pn_uint8(tvb, offset, pinfo, header_tree, hf_pn_ptcp_padding8, &padding8);
+ /* Padding */
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
/* Delay1ps */
offset = dissect_pn_uint16(tvb, offset, pinfo, header_tree, hf_pn_ptcp_delay1ps, &delay1ps);
- /* Padding16 */
- offset = dissect_pn_uint16(tvb, offset, pinfo, header_tree, hf_pn_ptcp_padding16, &padding16);
+ /* Padding */
+ offset = dissect_pn_align4(tvb, offset, pinfo, tree);
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO, "Seq=%3u", seq_id);
@@ -979,15 +830,12 @@ dissect_PNPTCP_Data_heur(tvbuff_t *tvb,
break;
/* 0xFF44 - 0xFF5F reserved */
default:
- unknown_item = proto_tree_add_string_format(ptcp_tree, hf_pn_ptcp_data, tvb, offset, tvb_length_remaining(tvb, offset), "data",
- "PN-PTCP Reserved FrameID 0x%04x, Data: %d bytes", u16FrameID, tvb_length_remaining(tvb, offset));
- expert_add_info_format(pinfo, unknown_item, PI_UNDECODED, PI_WARN,
- "Reserved FrameID 0x%04x, %u bytes", u16FrameID, tvb_length_remaining(tvb, offset));
+ offset = dissect_pn_undecoded(tvb, offset, pinfo, tree, tvb_length_remaining(tvb, offset));
- if (check_col(pinfo->cinfo, COL_INFO))
- col_append_fstr(pinfo->cinfo, COL_INFO, "Reserved FrameID 0x%04x", u16FrameID);
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_fstr(pinfo->cinfo, COL_INFO, "Reserved FrameID 0x%04x", u16FrameID);
- proto_item_append_text(item, "Reserved FrameID 0x%04x", u16FrameID);
+ proto_item_append_text(item, "Reserved FrameID 0x%04x", u16FrameID);
offset += tvb_length_remaining(tvb, offset);
}
@@ -1004,8 +852,6 @@ proto_register_pn_ptcp (void)
static hf_register_info hf[] = {
{ &hf_pn_ptcp,
{ "PROFINET PTCP", "pn_ptcp", FT_NONE, BASE_NONE, NULL, 0x0, "", HFILL }},
- { &hf_pn_ptcp_data,
- { "Undecoded Data", "pn_ptcp.data", FT_STRING, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_ptcp_header,
{ "Header", "pn_ptcp.header", FT_NONE, BASE_NONE, NULL, 0x0, "", HFILL }},
{ &hf_pn_ptcp_block,
@@ -1023,10 +869,6 @@ proto_register_pn_ptcp (void)
{ "SequenceID", "pn_ptcp.sequence_id", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_ptcp_delay1ns,
{ "Delay1ns", "pn_ptcp.delay1ns", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
- { &hf_pn_ptcp_padding8,
- { "Padding", "pn_ptcp.padding8", FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
- { &hf_pn_ptcp_padding16,
- { "Padding", "pn_ptcp.padding16", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
{ &hf_pn_ptcp_delay1ps,
{ "Delay1ps", "pn_ptcp.delay1ps", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
@@ -1080,8 +922,6 @@ proto_register_pn_ptcp (void)
{ &hf_pn_ptcp_profinet_subtype,
{ "Subtype", "pn_ptcp.subtype", FT_UINT8, BASE_HEX,
VALS(pn_ptcp_profinet_subtype_vals), 0x0, "PROFINET Subtype", HFILL }},
- { &hf_pn_ptcp_unknown_subtype,
- { "Subtype", "pn_ptcp.subtype", FT_UINT8, BASE_HEX, 0x0, 0x0, "Unkown Subtype", HFILL }},
{ &hf_pn_ptcp_irdata_uuid,
{ "IRDataUUID", "pn_ptcp.irdata_uuid", FT_GUID, BASE_NONE, 0x0, 0x0, "", HFILL }},
diff --git a/epan/dissectors/packet-pn-rt.c b/plugins/profinet/packet-pn-rt.c
index 69799e0df2..585ed0940d 100644
--- a/epan/dissectors/packet-pn-rt.c
+++ b/plugins/profinet/packet-pn-rt.c
@@ -44,9 +44,14 @@
#include <string.h>
#include <epan/packet.h>
#include <epan/addr_resolv.h>
-#include "prefs.h"
+#include <epan/prefs.h>
#include <epan/strutil.h>
-#include <etypes.h>
+#include <epan/etypes.h>
+#include <epan/dissectors/packet-dcerpc.h>
+
+#include "packet-pn.h"
+
+
void proto_reg_handoff_pn_rt(void);
@@ -54,8 +59,7 @@ void proto_reg_handoff_pn_rt(void);
static int proto_pn_rt = -1;
/* Define many header fields for pn-rt */
-static int hf_pn_rt_id = -1;
-static int hf_pn_rt_data = -1;
+static int hf_pn_rt_frame_id = -1;
static int hf_pn_rt_cycle_counter = -1;
static int hf_pn_rt_transfer_status = -1;
static int hf_pn_rt_data_status = -1;
@@ -66,7 +70,6 @@ static int hf_pn_rt_data_status_res3 = -1;
static int hf_pn_rt_data_status_valid = -1;
static int hf_pn_rt_data_status_res1 = -1;
static int hf_pn_rt_data_status_primary = -1;
-static int hf_pn_rt_malformed = -1;
/*
* Define the trees for pn-rt
@@ -85,8 +88,6 @@ static gboolean pn_rt_summary_in_tree = TRUE;
/* heuristic to find the right pn-rt payload dissector */
static heur_dissector_list_t heur_subdissector_list;
-/* the official "we don't know that data" dissector */
-static dissector_handle_t data_handle;
/*
@@ -132,10 +133,8 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_add_str(pinfo->cinfo, COL_INFO, "PROFINET Real-Time");
if (tvb_len < 6) {
- /* packet is too short, mark it as malformed */
- proto_tree_add_bytes(tree, hf_pn_rt_malformed, tvb, 0, 10000,
- tvb_get_ptr(tvb, 0, 10000));
- return;
+ dissect_pn_malformed(tvb, 0, pinfo, tree, tvb_len);
+ return;
}
@@ -301,7 +300,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
pn_rt_tree = proto_item_add_subtree(ti, ett_pn_rt);
/* add frame ID */
- proto_tree_add_uint_format(pn_rt_tree, hf_pn_rt_id, tvb,
+ proto_tree_add_uint_format(pn_rt_tree, hf_pn_rt_frame_id, tvb,
0, 2, u16FrameID, "FrameID: 0x%04x (%s)", u16FrameID, pszProtComment);
if (bCyclic) {
@@ -357,7 +356,7 @@ dissect_pn_rt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown");*/
/* Oh, well, we don't know this; dissect it as data. */
- call_dissector(data_handle, next_tvb, pinfo, tree);
+ dissect_pn_undecoded(next_tvb, 0, pinfo, tree, tvb_length(next_tvb));
}
}
@@ -367,10 +366,8 @@ void
proto_register_pn_rt(void)
{
static hf_register_info hf[] = {
- { &hf_pn_rt_id,
+ { &hf_pn_rt_frame_id,
{ "FrameID", "pn_rt.frame_id", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
- { &hf_pn_rt_data,
- { "Data", "pn_rt.data", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }},
{ &hf_pn_rt_cycle_counter, {
"CycleCounter", "pn_rt.cycle_counter", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
{ &hf_pn_rt_data_status, {
@@ -391,8 +388,6 @@ proto_register_pn_rt(void)
"State (1:Primary/0:Backup)", "pn_rt.ds_primary", FT_UINT8, BASE_HEX, 0, 0x01, "", HFILL }},
{ &hf_pn_rt_transfer_status,
{ "TransferStatus", "pn_rt.transfer_status", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
- { &hf_pn_rt_malformed,
- { "Malformed", "pn_rt.malformed", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }}
};
static gint *ett[] = {
&ett_pn_rt,
@@ -417,6 +412,8 @@ proto_register_pn_rt(void)
/* register heuristics anchor for payload dissectors */
register_heur_dissector_list("pn_rt", &heur_subdissector_list);
+
+ init_pn (proto_pn_rt);
}
@@ -438,8 +435,5 @@ proto_reg_handoff_pn_rt(void)
}
dissector_add("ethertype", ETHERTYPE_PROFINET, pn_rt_handle);
-
- /* the official "we don't know that data" dissector */
- data_handle = find_dissector("data");
}
diff --git a/plugins/profinet/packet-pn.c b/plugins/profinet/packet-pn.c
new file mode 100644
index 0000000000..537cc435a3
--- /dev/null
+++ b/plugins/profinet/packet-pn.c
@@ -0,0 +1,288 @@
+/* packet-pn.c
+ * Common functions for other PROFINET protocols like IO, CBA, DCP, ...
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1999 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
+#ifdef HAVE_SYS_TYPES_H
+/*#include <sys/types.h>*/
+#endif
+
+/*#include <string.h>*/
+
+#include <glib.h>
+#include <epan/packet.h>
+#include <epan/dissectors/packet-dcerpc.h>
+#include <epan/expert.h>
+
+#include "packet-pn.h"
+
+
+
+static int hf_pn_padding = -1;
+static int hf_pn_undecoded_data = -1;
+static int hf_pn_user_data = -1;
+static int hf_pn_malformed = -1;
+
+
+
+/* dissect an 8 bit unsigned integer */
+int
+dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
+ proto_tree *tree, int hfindex, guint8 *pdata)
+{
+ guint8 data;
+
+ data = tvb_get_guint8 (tvb, offset);
+ if (tree) {
+ proto_tree_add_uint(tree, hfindex, tvb, offset, 1, data);
+ }
+ if (pdata)
+ *pdata = data;
+ return offset + 1;
+}
+
+/* dissect a 16 bit unsigned integer */
+int
+dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
+ proto_tree *tree, int hfindex, guint16 *pdata)
+{
+ guint16 data;
+
+ data = tvb_get_ntohs (tvb, offset);
+
+ if (tree) {
+ proto_tree_add_uint(tree, hfindex, tvb, offset, 2, data);
+ }
+ if (pdata)
+ *pdata = data;
+ return offset + 2;
+}
+
+/* dissect a 32 bit unsigned integer */
+int
+dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
+ proto_tree *tree, int hfindex, guint32 *pdata)
+{
+ guint32 data;
+
+ data = tvb_get_ntohl (tvb, offset);
+
+ if (tree) {
+ proto_tree_add_uint(tree, hfindex, tvb, offset, 4, data);
+ }
+ if (pdata)
+ *pdata = data;
+ return offset+4;
+}
+
+/* dissect a 16 bit signed integer */
+int
+dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
+ proto_tree *tree, int hfindex, gint16 *pdata)
+{
+ gint16 data;
+
+ data = tvb_get_ntohs (tvb, offset);
+
+ if (tree) {
+ proto_tree_add_int(tree, hfindex, tvb, offset, 2, data);
+ }
+ if (pdata)
+ *pdata = data;
+ return offset + 2;
+}
+
+/* dissect a 24bit OUI (IEC organizational unique id) */
+int
+dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, int hfindex, guint32 *pdata)
+{
+ guint32 data;
+
+ data = tvb_get_ntoh24(tvb, offset);
+
+ if (tree) {
+ proto_tree_add_uint(tree, hfindex, tvb, offset, 3, data);
+ }
+ if (pdata)
+ *pdata = data;
+ return offset+3;
+}
+
+/* dissect a 6 byte MAC address */
+int
+dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, int hfindex, guint8 *pdata)
+{
+ guint8 data[6];
+
+ tvb_memcpy(tvb, data, offset, 6);
+ if(tree)
+ proto_tree_add_ether(tree, hfindex, tvb, offset, 6, data);
+
+ if (pdata)
+ memcpy(pdata, data, 6);
+
+ return offset + 6;
+}
+
+/* dissect an IPv4 address */
+int
+dissect_pn_ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, int hfindex, guint32 *pdata)
+{
+ guint32 data;
+
+ data = tvb_get_ipv4(tvb, offset);
+ if(tree)
+ proto_tree_add_ipv4(tree, hfindex, tvb, offset, 4, data);
+
+ if (pdata)
+ *pdata = data;
+
+ return offset + 4;
+}
+
+/* dissect a 16 byte UUID address */
+int
+dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, int hfindex, e_uuid_t *uuid)
+{
+ guint8 drep[2] = { 0,0 };
+
+ offset = dissect_dcerpc_uuid_t(tvb, offset, pinfo, tree, drep,
+ hfindex, uuid);
+
+ return offset;
+}
+
+/* "dissect" some bytes still undecoded (with Expert warning) */
+int
+dissect_pn_undecoded(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, guint32 length)
+{
+ proto_item *item;
+
+
+ item = proto_tree_add_string_format(tree, hf_pn_undecoded_data, tvb, offset, length, "data",
+ "Undecoded Data: %d bytes", length);
+
+ expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN,
+ "Undecoded Data, %u bytes", length);
+
+ return offset + length;
+}
+
+/* "dissect" some user bytes */
+int
+dissect_pn_user_data(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, guint32 length, const char *text)
+{
+ proto_item *item;
+
+
+ item = proto_tree_add_string_format(tree, hf_pn_user_data, tvb, offset, length, "data",
+ "%s: %d bytes", text, length);
+
+ return offset + length;
+}
+
+/* packet is malformed, mark it as such */
+int
+dissect_pn_malformed(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, guint32 length)
+{
+ proto_tree_add_bytes(tree, hf_pn_malformed, tvb, 0, 10000,
+ tvb_get_ptr(tvb, 0, 10000));
+
+ return offset + length;
+}
+
+
+/* dissect some padding data (with the given length) */
+int
+dissect_pn_padding(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, int length)
+{
+ proto_tree_add_string_format(tree, hf_pn_padding, tvb, offset, length, "data",
+ "Padding: %u byte", length);
+
+ return offset + length;
+}
+
+/* align offset to 4 */
+int
+dissect_pn_align4(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
+{
+ guint padding = 0;
+
+
+ if (offset % 4) {
+ padding = 4 - (offset % 4);
+
+ proto_tree_add_string_format(tree, hf_pn_padding, tvb, offset, padding, "data",
+ "Padding: %u byte", padding);
+ }
+
+ return offset + padding;
+}
+
+/* append the given info text to item and column */
+void
+pn_append_info(packet_info *pinfo, proto_item *dcp_item, const char *text)
+{
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_append_fstr(pinfo->cinfo, COL_INFO, text);
+
+ proto_item_append_text(dcp_item, "%s", text);
+}
+
+
+
+void
+init_pn (int proto)
+{
+ static hf_register_info hf[] = {
+ { &hf_pn_padding,
+ { "Padding", "pn.padding", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
+ { &hf_pn_undecoded_data,
+ { "Undecoded Data", "pn.undecoded", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
+ { &hf_pn_user_data,
+ { "User Data", "pn.user_data", FT_STRING, BASE_NONE, NULL, 0x0, "", HFILL }},
+ { &hf_pn_malformed,
+ { "Malformed", "pn_rt.malformed", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }}
+ };
+
+
+ /*static gint *ett[] = {
+ };*/
+
+ proto_register_field_array (proto, hf, array_length (hf));
+ /*proto_register_subtree_array (ett, array_length (ett));*/
+}
+
diff --git a/plugins/profinet/packet-pn.h b/plugins/profinet/packet-pn.h
new file mode 100644
index 0000000000..a2ff2013bd
--- /dev/null
+++ b/plugins/profinet/packet-pn.h
@@ -0,0 +1,70 @@
+/* packet-pn.h
+ * Common functions for other PROFINET protocols like DCP, MRP, ...
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1999 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#define FRAME_ID_UC 0xfefd
+#define FRAME_ID_MC 0xfefe
+#define FRAME_ID_MC_RESP 0xfeff
+
+
+extern void init_pn(int proto);
+
+extern int dissect_pn_uint8(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, int hfindex, guint8 *pdata);
+
+extern int dissect_pn_uint16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, int hfindex, guint16 *pdata);
+
+extern int dissect_pn_uint32(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, int hfindex, guint32 *pdata);
+
+extern int dissect_pn_int16(tvbuff_t *tvb, gint offset, packet_info *pinfo,
+ proto_tree *tree, int hfindex, gint16 *pdata);
+
+extern int dissect_pn_oid(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, int hfindex, guint32 *pdata);
+
+extern int dissect_pn_mac(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, int hfindex, guint8 *pdata);
+
+extern int dissect_pn_ipv4(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, int hfindex, guint32 *pdata);
+
+extern int dissect_pn_uuid(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, int hfindex, e_uuid_t *uuid);
+
+extern int dissect_pn_undecoded(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 length);
+
+extern int dissect_pn_user_data(tvbuff_t *tvb, int offset, packet_info *pinfo _U_,
+ proto_tree *tree, guint32 length, const char *text);
+
+extern int dissect_pn_malformed(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, guint32 length);
+
+extern int dissect_pn_padding(tvbuff_t *tvb, int offset, packet_info *pinfo,
+ proto_tree *tree, int length);
+
+extern int dissect_pn_align4(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
+
+extern void pn_append_info(packet_info *pinfo, proto_item *dcp_item, const char *text);