Wireshark  4.3.0
The Wireshark network protocol analyzer
packet-epl.h
1 /* packet-epl.h
2  * Routines for "Ethernet POWERLINK 2.0" dissection
3  * (Ethernet POWERLINK V2.0 Communication Profile Specification Draft Standard Version 1.2.0)
4  *
5  * A dissector for:
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1999 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12 
13 #ifndef __EPL_H_
14 #define __EPL_H_
15 
16 #include <glib.h>
17 #include <epan/address.h>
18 #include <epan/wmem_scopes.h>
19 #include <epan/range.h>
20 
21 struct epl_datatype;
22 
23 struct profile {
24  guint16 id;
25  guint8 nodeid;
26  address node_addr;
27 
28  guint32 vendor_id;
29  guint32 product_code;
30 
31  wmem_map_t *objects;
32  wmem_allocator_t *scope, *parent_scope;
33  wmem_map_t *parent_map;
34 
35  char *name;
36  char *path;
37  void *data;
38  guint cb_id;
39  wmem_array_t *TPDO; /* CN->MN */
40  wmem_array_t *RPDO; /* MN->CN */
41 
42  struct profile *next;
43 };
44 
45 enum { OD_ENTRY_SCALAR = 7, OD_ENTRY_ARRAY = 8, OD_ENTRY_RECORD = 9 };
46 struct od_entry {
47  guint16 idx;
48  /* This is called the ObjectType in the standard,
49  * but this is too easy to be mistaken with the
50  * DataType.
51  * ObjectType specifies whether it's a scalar or
52  * an aggregate
53  */
54  guint16 type_class;
55  char name[64];
56  /* Called DataType by the standard,
57  * Can be e.g. Unsigned32
58  */
59  const struct epl_datatype *type;
60  guint64 value;
61 };
62 #define OD_ENTRY_INITIALIZER { 0, 0, { 0 }, 0, 0 }
63 
64 struct subobject {
65  range_admin_t range;
66  struct od_entry info;
67 };
68 #define SUBOBJECT_INITIALIZER { RANGE_ADMIN_T_INITIALIZER, OD_ENTRY_INITIALIZER }
69 
70 typedef struct epl_wmem_iarray epl_wmem_iarray_t;
71 
72 struct object {
73  struct od_entry info;
74  epl_wmem_iarray_t *subindices;
75 };
76 
77 struct profile;
78 
79 const struct epl_datatype *epl_type_to_hf(const char *name);
80 
81 static inline gboolean
82 subobject_equal(gconstpointer _a, gconstpointer _b)
83 {
84  const struct od_entry *a = &((const struct subobject*)_a)->info;
85  const struct od_entry *b = &((const struct subobject*)_b)->info;
86 
87  return a->type_class == b->type_class
88  && a->type == b->type
89  && g_str_equal(a->name, b->name);
90 }
91 
92 struct profile *epl_xdd_load(struct profile *profile, const char *xml_file);
93 
94 void epl_eds_init(void);
95 struct profile *epl_eds_load(struct profile *profile, const char *eds_file);
96 
97 
98 struct object *epl_profile_object_add(struct profile *profile, guint16 idx);
99 struct object *epl_profile_object_lookup_or_add(struct profile *profile, guint16 idx);
100 
101 gboolean epl_profile_object_mapping_add(struct profile *profile, guint16 idx, guint8 subindex, guint64 mapping);
102 gboolean epl_profile_object_mappings_update(struct profile *profile);
103 
104 range_admin_t * epl_wmem_iarray_find(epl_wmem_iarray_t *arr, guint32 value);
105 gboolean epl_wmem_iarray_is_empty(epl_wmem_iarray_t *iarr);
106 gboolean epl_wmem_iarray_is_sorted(epl_wmem_iarray_t *iarr);
107 
108 #define EPL_OBJECT_MAPPING_SIZE ((guint)sizeof (guint64))
109 
110 #define CHECK_OVERLAP_ENDS(x1, x2, y1, y2) ((x1) < (y2) && (y1) < (x2))
111 #define CHECK_OVERLAP_LENGTH(x, x_len, y, y_len) \
112  CHECK_OVERLAP_ENDS((x), (x) + (x_len), (y), (y) + (y_len))
113 
114 
115 #endif
Definition: address.h:56
Definition: wmem_allocator.h:27
Definition: wmem_array.c:27
Definition: wmem_map.c:44
Definition: packet-epl-profile-parser.c:126
Definition: file-pcapng.h:57
Definition: packet-epl.h:72
Definition: packet-epl.h:46
Definition: packet-epl.h:23
Definition: range.h:35
Definition: packet-epl.h:64