aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-epl.h
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2017-06-01 11:11:18 +0200
committerPeter Wu <peter@lekensteyn.nl>2017-06-01 22:04:02 +0000
commit9a85e30668d515b2a39e681c901249056cbc5010 (patch)
tree0010d4fcbfa8dd19e8d3a6ba4e74b5022e9135a3 /epan/dissectors/packet-epl.h
parentb2302d7a35e531e7e1de46117f8b475063e23a57 (diff)
packet-epl.c: Enhance dissection by ObjectMappings and device profiles
Cyclic PDOs are setup either by ObjectMappings in the asynchronous SDOs, or by serialized ObjectMappings in device profile files. We now keep track of ObjectMappings transmitted via SDOs or read from XDC files and use those to correctly partition the PDO's payloads. Additionally types and descriptions for Object Directory entries extracted from the EDS and XDD profiles are used to select the correct Wireshark type and a string representation for those partitoned PDOs. Other places where indices and subindices are also enriched by this information. EDS support leverages GKeyFile and is available unconditionally, XDD/XDC parsing support depends on the availabilty of libxml2. A patch for inclusion of the latter as optional dependency was submitted as Change-Id: I13c0a2f408fb5c21bad7ab3d7971e0fa8ed7d783 Electronic Data Sheet (EDS) is the CANopen standard for device profiles, POWERLINK being based on CANopen, is occasionly used with EDS profiles. XML Device Description (XDD) is the Ethernet POWERLINK standard for device profiles. XDC have the same structure but contain actualValues fields which can contain default ObjectMappings. XML Device Descriptions can be 25k+ lines with much duplication, so wmem_iarray_t is leveraged for saving space as well as faster lookups. A side-effect of now organizing the capture in conversations is that POWERLINK over UDP packets are now assigned proper destination and source node IDs, which are displayed in the column view. The Referenced bug where packets where erronously flagged as duplicates because the address wasn't considered is also fixed as a result. Bug: 13604 Bug: 13749 Change-Id: Ic33ff0be8f2eae7c24fe5877ad9258d1e550c227 Reviewed-on: https://code.wireshark.org/review/21112 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/dissectors/packet-epl.h')
-rw-r--r--epan/dissectors/packet-epl.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/epan/dissectors/packet-epl.h b/epan/dissectors/packet-epl.h
index c94e6ddd98..7db6187fa7 100644
--- a/epan/dissectors/packet-epl.h
+++ b/epan/dissectors/packet-epl.h
@@ -30,6 +30,102 @@
#include <epan/wmem/wmem.h>
#include <epan/range.h>
+#ifdef __GNUC__
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#pragma GCC diagnostic ignored "-Wmissing-braces"
+#endif
+
+struct epl_datatype;
+
+struct profile {
+ guint16 id;
+ guint8 nodeid;
+ address node_addr;
+
+ guint32 vendor_id;
+ guint32 product_code;
+
+ wmem_map_t *objects;
+ wmem_allocator_t *scope, *parent_scope;
+ wmem_map_t *parent_map;
+
+ char *name;
+ char *path;
+ void *data;
+ guint cb_id;
+ wmem_array_t *TPDO; /* CN->MN */
+ wmem_array_t *RPDO; /* MN->CN */
+
+ struct profile *next;
+};
+
+enum { OD_ENTRY_SCALAR = 7, OD_ENTRY_ARRAY = 8, OD_ENTRY_RECORD = 9 };
+struct od_entry {
+ guint16 idx;
+ /* This is called the ObjectType in the standard,
+ * but this is too easy to be mistaken with the
+ * DataType.
+ * ObjectType specifies whether it's a scalar or
+ * an aggregate
+ */
+ guint16 type_class;
+ char name[64];
+ /* Called DataType by the standard,
+ * Can be e.g. Unsigned32
+ */
+ const struct epl_datatype *type;
+ guint64 value;
+};
+
+struct subobject {
+ range_admin_t range;
+ struct od_entry info;
+};
+
typedef struct epl_wmem_iarray epl_wmem_iarray_t;
+struct object {
+ struct od_entry info;
+ epl_wmem_iarray_t *subindices;
+};
+
+struct profile;
+
+const struct epl_datatype *epl_type_to_hf(const char *name);
+
+static inline gboolean
+subobject_equal(gconstpointer _a, gconstpointer _b)
+{
+ const struct od_entry *a = &((const struct subobject*)_a)->info;
+ const struct od_entry *b = &((const struct subobject*)_b)->info;
+
+ return a->type_class == b->type_class
+ && a->type == b->type
+ && g_str_equal(a->name, b->name);
+}
+
+void epl_xdd_init(void);
+struct profile *epl_xdd_load(struct profile *profile, const char *xml_file);
+
+void epl_eds_init(void);
+struct profile *epl_eds_load(struct profile *profile, const char *eds_file);
+
+
+struct object *epl_profile_object_add(struct profile *profile, guint16 idx);
+struct object *epl_profile_object_lookup_or_add(struct profile *profile, guint16 idx);
+
+gboolean epl_profile_object_mapping_add(struct profile *profile, guint16 idx, guint8 subindex, guint64 mapping);
+gboolean epl_profile_object_mappings_update(struct profile *profile);
+
+range_admin_t * epl_wmem_iarray_find(epl_wmem_iarray_t *arr, guint32 value);
+gboolean epl_wmem_iarray_is_empty(epl_wmem_iarray_t *iarr);
+gboolean epl_wmem_iarray_is_sorted(epl_wmem_iarray_t *iarr);
+
+#define EPL_OBJECT_MAPPING_SIZE sizeof (guint64)
+
+#define CHECK_OVERLAP_ENDS(x1, x2, y1, y2) ((x1) < (y2) && (y1) < (x2))
+#define CHECK_OVERLAP_LENGTH(x, x_len, y, y_len) \
+ CHECK_OVERLAP_ENDS((x), (x) + (x_len), (y), (y) + (y_len))
+
+
#endif