2 * Routines for Schweitzer Engineering Laboratories (SEL) Protocols Dissection
3 * By Chris Bontje (cbontje[AT]gmail.com
6 ************************************************************************************************
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
13 ************************************************************************************************
14 * Schweitzer Engineering Labs ("SEL") manufactures and sells digital protective relay equipment
15 * for use in industrial high-voltage installations. SEL Protocol evolved over time as a
16 * (semi)proprietary method for auto-configuration of connected SEL devices for retrieval of
17 * analog and digital status data. The protocol itself supports embedded binary messages
18 * (which are what this dissector looks for) slip-streamed in the data stream with normal
19 * ASCII text data. A combination of both are used for full auto-configuration of devices,
20 * but a wealth of information can be extracted from the binary messages alone.
22 * 'SEL Protocol' encompasses several message types, including
28 * Documentation on Fast Meter and Fast Message standards available from www.selinc.com in
29 * SEL Application Guides AG95-10_20091109.pdf and AG_200214.pdf
30 ************************************************************************************************
33 * 1) All SEL Protocol messages over TCP are normally tunneled via a Telnet connection. As Telnet
34 * has special handling for the 0xFF character ("IAC"), normally a pair of 0xFF's are inserted
35 * to represent an actual payload byte of 0xFF. A function from the packet-telnet.c dissector has
36 * been borrowed to automatically pre-process any Ethernet-based packet and remove these 'extra'
37 * 0xFF bytes. Wireshark Notes on Telnet 0xFF doubling are discussed here:
38 * https://lists.wireshark.org/archives/wireshark-bugs/201204/msg00198.html
40 * 2) The auto-configuration process for Fast Meter will exchange several "configuration" messages
41 * that describe various data regions (METER, DEMAND, PEAK, etc) that will later have corresponding
42 * "data" messages. This dissector code will currently save and accurately retrieve the 3 sets
44 * 0xA5C1, 0xA5D1, "METER" region
45 * 0xA5C2, 0xA5D2, "DEMAND" region
46 * 0xA5C3, 0xA5D3, "PEAK" region
47 * The configuration messages are stored in structs that are managed using the wmem library and
48 * the Wireshark conversation functionality.
53 #include <epan/packet.h>
54 #include "packet-tcp.h"
55 #include <epan/prefs.h>
56 #include <epan/to_str.h>
57 #include <epan/strutil.h>
58 #include <epan/reassemble.h>
59 #include <epan/expert.h>
60 #include <epan/crc16-tvb.h>
61 #include <epan/proto_data.h>
63 void proto_register_selfm(void);
65 /* Initialize the protocol and registered fields */
66 static int proto_selfm
;
67 static int hf_selfm_msgtype
;
68 static int hf_selfm_padbyte
;
69 static int hf_selfm_checksum
;
70 static int hf_selfm_relaydef_len
;
71 static int hf_selfm_relaydef_numproto
;
72 static int hf_selfm_relaydef_numfm
;
73 static int hf_selfm_relaydef_numflags
;
74 static int hf_selfm_relaydef_fmcfg_cmd
;
75 static int hf_selfm_relaydef_fmdata_cmd
;
76 static int hf_selfm_relaydef_statbit
;
77 static int hf_selfm_relaydef_statbit_cmd
;
78 static int hf_selfm_relaydef_proto
;
79 static int hf_selfm_fmconfig_len
;
80 static int hf_selfm_fmconfig_numflags
;
81 static int hf_selfm_fmconfig_loc_sf
;
82 static int hf_selfm_fmconfig_num_sf
;
83 static int hf_selfm_fmconfig_num_ai
;
84 static int hf_selfm_fmconfig_num_samp
;
85 static int hf_selfm_fmconfig_num_dig
;
86 static int hf_selfm_fmconfig_num_calc
;
87 static int hf_selfm_fmconfig_ofs_ai
;
88 static int hf_selfm_fmconfig_ofs_ts
;
89 static int hf_selfm_fmconfig_ofs_dig
;
90 static int hf_selfm_fmconfig_ai_type
;
91 static int hf_selfm_fmconfig_ai_sf_type
;
92 static int hf_selfm_fmconfig_ai_sf_ofs
;
93 static int hf_selfm_fmconfig_cblk_rot
;
94 static int hf_selfm_fmconfig_cblk_vconn
;
95 static int hf_selfm_fmconfig_cblk_iconn
;
96 static int hf_selfm_fmconfig_cblk_ctype
;
97 static int hf_selfm_fmconfig_cblk_deskew_ofs
;
98 static int hf_selfm_fmconfig_cblk_rs_ofs
;
99 static int hf_selfm_fmconfig_cblk_xs_ofs
;
100 static int hf_selfm_fmconfig_cblk_ia_idx
;
101 static int hf_selfm_fmconfig_cblk_ib_idx
;
102 static int hf_selfm_fmconfig_cblk_ic_idx
;
103 static int hf_selfm_fmconfig_cblk_va_idx
;
104 static int hf_selfm_fmconfig_cblk_vb_idx
;
105 static int hf_selfm_fmconfig_cblk_vc_idx
;
106 static int hf_selfm_fmconfig_ai_sf_float
;
107 static int hf_selfm_fmdata_len
;
108 static int hf_selfm_fmdata_flagbyte
;
109 static int hf_selfm_fmdata_dig_b0
;
110 static int hf_selfm_fmdata_dig_b1
;
111 static int hf_selfm_fmdata_dig_b2
;
112 static int hf_selfm_fmdata_dig_b3
;
113 static int hf_selfm_fmdata_dig_b4
;
114 static int hf_selfm_fmdata_dig_b5
;
115 static int hf_selfm_fmdata_dig_b6
;
116 static int hf_selfm_fmdata_dig_b7
;
117 static int hf_selfm_fmdata_ai_sf_fp
;
118 static int hf_selfm_foconfig_len
;
119 static int hf_selfm_foconfig_num_brkr
;
120 static int hf_selfm_foconfig_num_rb
;
121 static int hf_selfm_foconfig_prb_supp
;
122 static int hf_selfm_foconfig_reserved
;
123 static int hf_selfm_foconfig_brkr_open
;
124 static int hf_selfm_foconfig_brkr_close
;
125 static int hf_selfm_foconfig_rb_cmd
;
126 static int hf_selfm_fastop_len
;
127 static int hf_selfm_fastop_rb_code
;
128 static int hf_selfm_fastop_br_code
;
129 static int hf_selfm_fastop_valid
;
130 static int hf_selfm_alt_foconfig_len
;
131 static int hf_selfm_alt_foconfig_num_ports
;
132 static int hf_selfm_alt_foconfig_num_brkr
;
133 static int hf_selfm_alt_foconfig_num_rb
;
134 static int hf_selfm_alt_foconfig_funccode
;
135 static int hf_selfm_alt_fastop_len
;
136 static int hf_selfm_alt_fastop_code
;
137 static int hf_selfm_alt_fastop_valid
;
139 static int hf_selfm_fastmsg_len
;
140 static int hf_selfm_fastmsg_routing_addr
;
141 static int hf_selfm_fastmsg_status
;
142 static int hf_selfm_fastmsg_funccode
;
143 static int hf_selfm_fastmsg_response_code
;
144 static int hf_selfm_fastmsg_seq
;
145 static int hf_selfm_fastmsg_seq_fir
;
146 static int hf_selfm_fastmsg_seq_fin
;
147 static int hf_selfm_fastmsg_seq_cnt
;
148 static int hf_selfm_fastmsg_resp_num
;
149 static int hf_selfm_fastmsg_crc16
;
150 static int hf_selfm_fastmsg_def_route_sup
;
151 static int hf_selfm_fastmsg_def_rx_stat
;
152 static int hf_selfm_fastmsg_def_tx_stat
;
153 static int hf_selfm_fastmsg_def_rx_maxfr
;
154 static int hf_selfm_fastmsg_def_tx_maxfr
;
155 static int hf_selfm_fastmsg_def_rx_num_fc
;
156 static int hf_selfm_fastmsg_def_rx_fc
;
157 static int hf_selfm_fastmsg_def_tx_num_fc
;
158 static int hf_selfm_fastmsg_def_tx_fc
;
159 static int hf_selfm_fastmsg_uns_en_fc
;
160 static int hf_selfm_fastmsg_uns_en_fc_data
;
161 static int hf_selfm_fastmsg_uns_dis_fc
;
162 static int hf_selfm_fastmsg_uns_dis_fc_data
;
163 static int hf_selfm_fastmsg_baseaddr
;
164 static int hf_selfm_fastmsg_numwords
;
165 static int hf_selfm_fastmsg_flags
;
166 static int hf_selfm_fastmsg_datafmt_resp_numitem
;
167 static int hf_selfm_fastmsg_dataitem_qty
;
168 static int hf_selfm_fastmsg_dataitem_type
;
169 static int hf_selfm_fastmsg_dataitem_uint16
;
170 static int hf_selfm_fastmsg_dataitem_int16
;
171 static int hf_selfm_fastmsg_dataitem_uint32
;
172 static int hf_selfm_fastmsg_dataitem_int32
;
173 static int hf_selfm_fastmsg_dataitem_float
;
174 static int hf_selfm_fastmsg_devdesc_num_region
;
175 static int hf_selfm_fastmsg_devdesc_num_ctrl
;
176 static int hf_selfm_fastmsg_unsresp_orig
;
177 static int hf_selfm_fastmsg_unsresp_doy
;
178 static int hf_selfm_fastmsg_unsresp_year
;
179 static int hf_selfm_fastmsg_unsresp_todms
;
180 static int hf_selfm_fastmsg_unsresp_num_elmt
;
181 static int hf_selfm_fastmsg_unsresp_elmt_idx
;
182 static int hf_selfm_fastmsg_unsresp_elmt_ts_ofs
;
183 static int hf_selfm_fastmsg_unsresp_elmt_status
;
184 static int hf_selfm_fastmsg_unsresp_eor
;
185 static int hf_selfm_fastmsg_unsresp_elmt_statword
;
186 static int hf_selfm_fastmsg_unswrite_addr1
;
187 static int hf_selfm_fastmsg_unswrite_addr2
;
188 static int hf_selfm_fastmsg_unswrite_num_reg
;
189 static int hf_selfm_fastmsg_unswrite_reg_val
;
190 static int hf_selfm_fastmsg_soe_req_orig
;
191 static int hf_selfm_fastmsg_soe_resp_numblks
;
192 static int hf_selfm_fastmsg_soe_resp_orig
;
193 static int hf_selfm_fastmsg_soe_resp_numbits
;
194 static int hf_selfm_fastmsg_soe_resp_pad
;
195 static int hf_selfm_fastmsg_soe_resp_doy
;
196 static int hf_selfm_fastmsg_soe_resp_year
;
197 static int hf_selfm_fastmsg_soe_resp_tod
;
198 static int hf_selfm_fastmsg_soe_resp_data
;
199 /* Generated from convert_proto_tree_add_text.pl */
200 static int hf_selfm_fmconfig_ai_channel
;
201 static int hf_selfm_fmdata_ai_value16
;
202 static int hf_selfm_fmdata_ai_scale_factor
;
203 static int hf_selfm_fmdata_ai_value_float
;
204 static int hf_selfm_fmdata_ai_value_double
;
205 static int hf_selfm_fmdata_data_type
;
206 static int hf_selfm_fmdata_quantity
;
207 static int hf_selfm_fmdata_ai_value_string
;
208 static int hf_selfm_fastmsg_unsresp_elmt_ts_ofs_decoded
;
209 static int hf_selfm_fid
;
210 static int hf_selfm_rid
;
211 static int hf_selfm_fastmsg_data_region_name
;
212 static int hf_selfm_fmdata_timestamp
;
213 static int hf_selfm_fmdata_frame_data_format_reference
;
214 static int hf_selfm_fastmsg_bit_label_name
;
216 /* Initialize the subtree pointers */
217 static int ett_selfm
;
218 static int ett_selfm_relaydef
;
219 static int ett_selfm_relaydef_fm
;
220 static int ett_selfm_relaydef_proto
;
221 static int ett_selfm_relaydef_flags
;
222 static int ett_selfm_fmconfig
;
223 static int ett_selfm_fmconfig_ai
;
224 static int ett_selfm_fmconfig_calc
;
225 static int ett_selfm_foconfig
;
226 static int ett_selfm_foconfig_brkr
;
227 static int ett_selfm_foconfig_rb
;
228 static int ett_selfm_fastop
;
229 static int ett_selfm_fmdata
;
230 static int ett_selfm_fmdata_ai
;
231 static int ett_selfm_fmdata_dig
;
232 static int ett_selfm_fmdata_ai_ch
;
233 static int ett_selfm_fmdata_dig_ch
;
234 static int ett_selfm_fastmsg
;
235 static int ett_selfm_fastmsg_seq
;
236 static int ett_selfm_fastmsg_def_fc
;
237 static int ett_selfm_fastmsg_datareg
;
238 static int ett_selfm_fastmsg_soeblk
;
239 static int ett_selfm_fastmsg_tag
;
240 static int ett_selfm_fastmsg_element_list
;
241 static int ett_selfm_fastmsg_element
;
244 static expert_field ei_selfm_crc16_incorrect
;
246 static dissector_handle_t selfm_handle
;
248 #define CMD_FAST_MSG 0xA546
249 #define CMD_CLEAR_STATBIT 0xA5B9
250 #define CMD_RELAY_DEF 0xA5C0
251 #define CMD_FM_CONFIG 0xA5C1
252 #define CMD_DFM_CONFIG 0xA5C2
253 #define CMD_PDFM_CONFIG 0xA5C3
254 #define CMD_FASTOP_RESETDEF 0xA5CD
255 #define CMD_FASTOP_CONFIG 0xA5CE
256 #define CMD_ALT_FASTOP_CONFIG 0xA5CF
257 #define CMD_FM_DATA 0xA5D1
258 #define CMD_DFM_DATA 0xA5D2
259 #define CMD_PDFM_DATA 0xA5D3
260 #define CMD_FASTOP_RB_CTRL 0xA5E0
261 #define CMD_FASTOP_BR_CTRL 0xA5E3
262 #define CMD_ALT_FASTOP_OPEN 0xA5E5
263 #define CMD_ALT_FASTOP_CLOSE 0xA5E6
264 #define CMD_ALT_FASTOP_SET 0xA5E7
265 #define CMD_ALT_FASTOP_CLEAR 0xA5E8
266 #define CMD_ALT_FASTOP_PULSE 0xA5E9
267 #define CMD_FASTOP_RESET 0xA5ED
269 #define FM_CONFIG_SF_LOC_FM 0
270 #define FM_CONFIG_SF_LOC_CFG 1
272 #define FM_CONFIG_ANA_CHNAME_LEN 6
273 #define FM_CONFIG_ANA_CHTYPE_INT16 0x00
274 #define FM_CONFIG_ANA_CHTYPE_FP 0x01
275 #define FM_CONFIG_ANA_CHTYPE_FPD 0x02
276 #define FM_CONFIG_ANA_CHTYPE_TS 0x03
277 #define FM_CONFIG_ANA_CHTYPE_TS_LEN 8
279 #define FM_CONFIG_ANA_SFTYPE_INT16 0x00
280 #define FM_CONFIG_ANA_SFTYPE_FP 0x01
281 #define FM_CONFIG_ANA_SFTYPE_FPD 0x02
282 #define FM_CONFIG_ANA_SFTYPE_TS 0x03
283 #define FM_CONFIG_ANA_SFTYPE_NONE 0xFF
286 /* Fast Message Function Codes, "response" or "ACK" messages are the same as the request, but have the MSB set */
287 #define FAST_MSG_CFG_BLOCK 0x00
288 #define FAST_MSG_EN_UNS_DATA 0x01
289 #define FAST_MSG_DIS_UNS_DATA 0x02
290 #define FAST_MSG_PING 0x05
291 #define FAST_MSG_READ_REQ 0x10
292 #define FAST_MSG_GEN_UNS_DATA 0x12
293 #define FAST_MSG_SOE_STATE_REQ 0x16
294 #define FAST_MSG_UNS_RESP 0x18
295 #define FAST_MSG_UNS_WRITE 0x20
296 #define FAST_MSG_UNS_WRITE_REQ 0x21
297 #define FAST_MSG_DEVDESC_REQ 0x30
298 #define FAST_MSG_DATAFMT_REQ 0x31
299 #define FAST_MSG_UNS_DATAFMT_RESP 0x32
300 #define FAST_MSG_BITLABEL_REQ 0x33
301 #define FAST_MSG_MGMT_REQ 0x40
302 #define FAST_MSG_CFG_BLOCK_RESP 0x80
303 #define FAST_MSG_EN_UNS_DATA_ACK 0x81
304 #define FAST_MSG_DIS_UNS_DATA_ACK 0x82
305 #define FAST_MSG_PING_ACK 0x85
306 #define FAST_MSG_READ_RESP 0x90
307 #define FAST_MSG_SOE_STATE_RESP 0x96
308 #define FAST_MSG_UNS_RESP_ACK 0x98
309 #define FAST_MSG_DEVDESC_RESP 0xB0
310 #define FAST_MSG_DATAFMT_RESP 0xB1
311 #define FAST_MSG_BITLABEL_RESP 0xB3
314 /* Fast Message Sequence Byte Masks */
315 #define FAST_MSG_SEQ_FIR 0x80
316 #define FAST_MSG_SEQ_FIN 0x40
317 #define FAST_MSG_SEQ_CNT 0x3f
319 /* Fast Message Tag Data Types */
320 #define FAST_MSG_TAGTYPE_CHAR8 0x0011 /* 1 x 8-bit character per item */
321 #define FAST_MSG_TAGTYPE_CHAR16 0x0012 /* 2 x 8-bit characters per item */
322 #define FAST_MSG_TAGTYPE_DIGWORD8_BL 0x0021 /* 8-bit binary item, with labels */
323 #define FAST_MSG_TAGTYPE_DIGWORD8 0x0022 /* 8-bit binary item, without labels */
324 #define FAST_MSG_TAGTYPE_DIGWORD16_BL 0x0023 /* 16-bit binary item, with labels */
325 #define FAST_MSG_TAGTYPE_DIGWORD16 0x0024 /* 16-bit binary item, without labels */
326 #define FAST_MSG_TAGTYPE_INT16 0x0031 /* 16-bit signed integer */
327 #define FAST_MSG_TAGTYPE_UINT16 0x0032 /* 16-bit unsigned integer */
328 #define FAST_MSG_TAGTYPE_INT32 0x0033 /* 32-bit signed integer */
329 #define FAST_MSG_TAGTYPE_UINT32 0x0034 /* 32-bit unsigned integer */
330 #define FAST_MSG_TAGTYPE_FLOAT 0x0041 /* 32-bit floating point */
333 /* Globals for SEL Protocol Preferences */
334 static bool selfm_desegment
= true;
335 static bool selfm_telnet_clean
= true;
336 static bool selfm_crc16
; /* Default CRC16 validation to false */
337 static const char *selfm_ser_list
;
339 /***************************************************************************************/
340 /* Fast Meter Message structs */
341 /***************************************************************************************/
342 /* Holds Configuration Information required to decode a Fast Meter analog value */
344 char name
[FM_CONFIG_ANA_CHNAME_LEN
+1]; /* Name of Analog Channel, 6 char + a null */
345 uint8_t type
; /* Analog Channel Type, Int, FP, etc */
346 uint8_t sf_type
; /* Analog Scale Factor Type, none, etc */
347 uint16_t sf_offset
; /* Analog Scale Factor Offset */
348 float sf_fp
; /* Scale factor, if present in Cfg message */
352 /* Holds Information from a single "Fast Meter Configuration" frame. Required to dissect subsequent "Data" frames. */
354 uint32_t fnum
; /* frame number */
355 uint16_t cfg_cmd
; /* holds ID of config command, ie: 0xa5c1 */
356 uint8_t num_flags
; /* Number of Flag Bytes */
357 uint8_t sf_loc
; /* Scale Factor Location */
358 uint8_t sf_num
; /* Number of Scale Factors */
359 uint8_t num_ai
; /* Number of Analog Inputs */
360 uint8_t num_ai_samples
; /* Number samples per Analog Input */
361 uint16_t offset_ai
; /* Start Offset of Analog Inputs */
362 uint8_t num_dig
; /* Number of Digital Input Blocks */
363 uint16_t offset_dig
; /* Start Offset of Digital Inputs */
364 uint16_t offset_ts
; /* Start Offset of Time Stamp */
365 uint8_t num_calc
; /* Number of Calculations */
366 fm_analog_info
*analogs
; /* Array of fm_analog_infos */
369 /**************************************************************************************/
370 /* Fast Message Data Item struct */
371 /**************************************************************************************/
372 /* Holds Configuration Information required to decode a Fast Message Data Item */
373 /* Each data region format is returned as a sequential list of tags, w/o reference to */
374 /* an absolute address. The format information will consist of a name, a data type */
375 /* and a quantity of values contained within the data item. We will retrieve this */
376 /* format information later while attempting to dissect Read Response frames */
378 uint32_t fnum
; /* frame number */
379 uint32_t base_address
; /* Base address of Data Item Region */
380 uint8_t index_pos
; /* Index Offset Position within data format message (1-16) */
381 char name
[10+1]; /* Name of Data Item, 10 chars, null-terminated */
382 uint16_t quantity
; /* Quantity of values within Data Item */
383 uint16_t data_type
; /* Data Item Type, Char, Int, FP, etc */
386 /**************************************************************************************/
387 /* Fast Message Data Region struct */
388 /**************************************************************************************/
389 /* Holds Configuration Information required to decode a Fast Message Data Region */
390 /* Each data region format is returned as a sequential list of tags, w/o reference to */
392 char name
[10+1]; /* Name of Data Region, 10 chars, null-terminated */
393 } fastmsg_dataregion
;
395 /**************************************************************************************/
396 /* Fast Unsolicited SER Index Lookup */
397 /**************************************************************************************/
398 /* Holds user-configurable naming information for Unsolicited Fast SER word bits */
399 /* that will later be present in an 0xA546 msg with only an index position reference */
401 char *name
; /* Name of Word Bit, 8 chars, null-terminated */
402 } fastser_uns_wordbit
;
405 /**************************************************************************************/
406 /* Fast Message Conversation struct */
407 /**************************************************************************************/
409 wmem_list_t
*fm_config_frames
; /* List contains a fm_config_data struct for each Fast Meter configuration frame */
410 wmem_list_t
*fastmsg_dataitems
; /* List contains a fastmsg_dataitem struct for each Fast Message Data Item */
411 wmem_tree_t
*fastmsg_dataregions
; /* Tree contains a fastmsg_dataregion struct for each Fast Message Data Region */
412 wmem_tree_t
*fastser_uns_wordbits
; /* Tree contains a fastser_uns_wordbit struct for each comma-separated entry in the 'SER List' User Preference */
416 static const value_string selfm_msgtype_vals
[] = {
417 { CMD_FAST_MSG
, "Fast Message Block" }, /* 0xA546 */
418 { CMD_CLEAR_STATBIT
, "Clear Status Bits Command" }, /* 0xA5B9 */
419 { CMD_RELAY_DEF
, "Relay Definition Block" }, /* 0xA5C0 */
420 { CMD_FM_CONFIG
, "Fast Meter Configuration Block" }, /* 0xA5C1 */
421 { CMD_DFM_CONFIG
, "Demand Fast Meter Configuration Block" }, /* 0xA5C2 */
422 { CMD_PDFM_CONFIG
, "Peak Demand Fast Meter Configuration Block" }, /* 0xA5C3 */
423 { CMD_FASTOP_RESETDEF
, "Fast Operate Reset Definition" }, /* 0xA5CD */
424 { CMD_FASTOP_CONFIG
, "Fast Operate Configuration" }, /* 0xA5CE */
425 { CMD_ALT_FASTOP_CONFIG
, "Alternate Fast Operate Configuration" }, /* 0xA5CF */
426 { CMD_FM_DATA
, "Fast Meter Data Block" }, /* 0xA5D1 */
427 { CMD_DFM_DATA
, "Demand Fast Meter Data Block" }, /* 0xA5D2 */
428 { CMD_PDFM_DATA
, "Peak Demand Fast Meter Data Block" }, /* 0xA5D3 */
429 { CMD_FASTOP_RB_CTRL
, "Fast Operate Remote Bit Control" }, /* 0xA5E0 */
430 { CMD_FASTOP_BR_CTRL
, "Fast Operate Breaker Bit Control" }, /* 0xA5E3 */
431 { CMD_ALT_FASTOP_OPEN
, "Alternate Fast Operate Open Breaker Control" }, /* 0xA5E5 */
432 { CMD_ALT_FASTOP_CLOSE
, "Alternate Fast Operate Close Breaker Control" }, /* 0xA5E6 */
433 { CMD_ALT_FASTOP_SET
, "Alternate Fast Operate Set Remote Bit Control" }, /* 0xA5E7 */
434 { CMD_ALT_FASTOP_CLEAR
, "Alternate Fast Operate Clear Remote Bit Control" }, /* 0xA5E8 */
435 { CMD_ALT_FASTOP_PULSE
, "Alternate Fast Operate Pulse Remote Bit Control" }, /* 0xA5E9 */
436 { CMD_FASTOP_RESET
, "Fast Operate Reset" }, /* 0xA5ED */
439 static value_string_ext selfm_msgtype_vals_ext
= VALUE_STRING_EXT_INIT(selfm_msgtype_vals
);
441 static const value_string selfm_relaydef_proto_vals
[] = {
442 { 0x0000, "SEL Fast Meter" },
443 { 0x0001, "SEL Limited Multidrop (LMD)" },
444 { 0x0002, "Modbus" },
445 { 0x0003, "SY/MAX" },
446 { 0x0004, "SEL Relay-to-Relay" },
447 { 0x0005, "DNP 3.0" },
448 { 0x0006, "SEL Mirrored Bits" },
449 { 0x0007, "IEEE 37.118 Synchrophasors" },
450 { 0x0008, "IEC 61850" },
451 { 0x0100, "SEL Fast Meter w/ Fast Operate" },
452 { 0x0101, "SEL Limited Multidrop (LMD) w/ Fast Operate" },
453 { 0x0200, "SEL Fast Meter w/ Fast Message" },
454 { 0x0300, "SEL Fast Meter w/ Fast Operate and Fast Message" },
455 { 0x0301, "SEL Limited Multidrop (LMD) w/ Fast Operate and Fast Message" },
458 static value_string_ext selfm_relaydef_proto_vals_ext
= VALUE_STRING_EXT_INIT(selfm_relaydef_proto_vals
);
460 static const value_string selfm_fmconfig_ai_chtype_vals
[] = {
461 { FM_CONFIG_ANA_CHTYPE_INT16
, "16-Bit Integer" },
462 { FM_CONFIG_ANA_CHTYPE_FP
, "IEEE Floating Point" },
463 { FM_CONFIG_ANA_CHTYPE_FPD
, "IEEE Floating Point (Double)" },
464 { FM_CONFIG_ANA_CHTYPE_TS
, "8-byte Time Stamp" },
468 static const value_string selfm_fmconfig_ai_sftype_vals
[] = {
469 { FM_CONFIG_ANA_SFTYPE_INT16
, "16-Bit Integer" },
470 { FM_CONFIG_ANA_SFTYPE_FP
, "IEEE Floating Point" },
471 { FM_CONFIG_ANA_SFTYPE_FPD
, "IEEE Floating Point (Double)" },
472 { FM_CONFIG_ANA_SFTYPE_TS
, "8-byte Time Stamp" },
473 { FM_CONFIG_ANA_SFTYPE_NONE
, "None" },
477 static const value_string selfm_fmconfig_sfloc_vals
[] = {
478 { FM_CONFIG_SF_LOC_FM
, "In Fast Meter Message" },
479 { FM_CONFIG_SF_LOC_CFG
, "In Configuration Message" },
483 /* Depending on number of analog samples present in Fast Meter Messages, identification of data will change */
484 static const value_string selfm_fmconfig_numsamples1_vals
[] = {
485 { 1, "Magnitudes Only" },
489 static const value_string selfm_fmconfig_numsamples2_vals
[] = {
490 { 1, "Imaginary Components" },
491 { 2, "Real Components" },
495 static const value_string selfm_fmconfig_numsamples4_vals
[] = {
496 { 1, "1st Quarter Cycle Data" },
497 { 2, "2nd Quarter Cycle Data" },
498 { 3, "5th Quarter-Cycle Data" },
499 { 4, "6th Quarter-Cycle Data" },
503 /* Calculation Block lookup values */
504 static const value_string selfm_fmconfig_cblk_rot_vals
[] = {
505 { 0x00, "ABC Rotation" },
506 { 0x01, "ACB Rotation" },
510 static const value_string selfm_fmconfig_cblk_vconn_vals
[] = {
511 { 0x00, "Y-Connected" },
512 { 0x01, "Delta-Connected (in seq. Vab, Vbc, Vca)" },
513 { 0x02, "Delta-Connected (in seq. Vac, Vba, Vcb)" },
517 static const value_string selfm_fmconfig_cblk_iconn_vals
[] = {
518 { 0x00, "Y-Connected" },
519 { 0x01, "Delta-Connected (in seq. Iab, Ibc, Ica)" },
520 { 0x02, "Delta-Connected (in seq. Iac, Iba, Icb)" },
524 static const value_string selfm_fmconfig_cblk_ctype_vals
[] = {
525 { 0, "Standard Power Calculations" },
526 { 1, "2-1/2 Element Delta Power Calculation" },
527 { 2, "Voltages-Only" },
528 { 3, "Currents-Only" },
529 { 4, "Single-Phase Ia and Va Only" },
530 { 5, "Standard Power Calcs with 2 sets of Currents" },
531 { 6, "2-1/2 Element Delta Power Calcs with 2 sets of Currents" },
535 /* Fast Operate Remote Bit 'Pulse Supported' Lookup */
536 static const value_string selfm_foconfig_prb_supp_vals
[] = {
542 /* SER Status Value Lookup */
543 static const value_string selfm_ser_status_vals
[] = {
544 { 0x00, "Deasserted" },
545 { 0x01, "Asserted" },
549 /* Fast Operate Remote Bit Lookup */
550 static const value_string selfm_fo_rb_vals
[] = {
551 { 0x00, "RB01 Clear" },
552 { 0x01, "RB02 Clear" },
553 { 0x02, "RB03 Clear" },
554 { 0x03, "RB04 Clear" },
555 { 0x04, "RB05 Clear" },
556 { 0x05, "RB06 Clear" },
557 { 0x06, "RB07 Clear" },
558 { 0x07, "RB08 Clear" },
559 { 0x08, "RB09 Clear" },
560 { 0x09, "RB10 Clear" },
561 { 0x0A, "RB11 Clear" },
562 { 0x0B, "RB12 Clear" },
563 { 0x0C, "RB13 Clear" },
564 { 0x0D, "RB14 Clear" },
565 { 0x0E, "RB15 Clear" },
566 { 0x0F, "RB16 Clear" },
567 { 0x10, "RB17 Clear" },
568 { 0x11, "RB18 Clear" },
569 { 0x12, "RB19 Clear" },
570 { 0x13, "RB20 Clear" },
571 { 0x14, "RB21 Clear" },
572 { 0x15, "RB22 Clear" },
573 { 0x16, "RB23 Clear" },
574 { 0x17, "RB24 Clear" },
575 { 0x18, "RB25 Clear" },
576 { 0x19, "RB26 Clear" },
577 { 0x1A, "RB27 Clear" },
578 { 0x1B, "RB28 Clear" },
579 { 0x1C, "RB29 Clear" },
580 { 0x1D, "RB30 Clear" },
581 { 0x1E, "RB31 Clear" },
582 { 0x1F, "RB32 Clear" },
583 { 0x20, "RB01 Set" },
584 { 0x21, "RB02 Set" },
585 { 0x22, "RB03 Set" },
586 { 0x23, "RB04 Set" },
587 { 0x24, "RB05 Set" },
588 { 0x25, "RB06 Set" },
589 { 0x26, "RB07 Set" },
590 { 0x27, "RB08 Set" },
591 { 0x28, "RB09 Set" },
592 { 0x29, "RB10 Set" },
593 { 0x2A, "RB11 Set" },
594 { 0x2B, "RB12 Set" },
595 { 0x2C, "RB13 Set" },
596 { 0x2D, "RB14 Set" },
597 { 0x2E, "RB15 Set" },
598 { 0x2F, "RB16 Set" },
599 { 0x30, "RB17 Set" },
600 { 0x31, "RB18 Set" },
601 { 0x32, "RB19 Set" },
602 { 0x33, "RB20 Set" },
603 { 0x34, "RB21 Set" },
604 { 0x35, "RB22 Set" },
605 { 0x36, "RB23 Set" },
606 { 0x37, "RB24 Set" },
607 { 0x38, "RB25 Set" },
608 { 0x39, "RB26 Set" },
609 { 0x3A, "RB27 Set" },
610 { 0x3B, "RB28 Set" },
611 { 0x3C, "RB29 Set" },
612 { 0x3D, "RB30 Set" },
613 { 0x3E, "RB31 Set" },
614 { 0x3F, "RB32 Set" },
615 { 0x40, "RB01 Pulse" },
616 { 0x41, "RB02 Pulse" },
617 { 0x42, "RB03 Pulse" },
618 { 0x43, "RB04 Pulse" },
619 { 0x44, "RB05 Pulse" },
620 { 0x45, "RB06 Pulse" },
621 { 0x46, "RB07 Pulse" },
622 { 0x47, "RB08 Pulse" },
623 { 0x48, "RB09 Pulse" },
624 { 0x49, "RB10 Pulse" },
625 { 0x4A, "RB11 Pulse" },
626 { 0x4B, "RB12 Pulse" },
627 { 0x4C, "RB13 Pulse" },
628 { 0x4D, "RB14 Pulse" },
629 { 0x4E, "RB15 Pulse" },
630 { 0x4F, "RB16 Pulse" },
631 { 0x50, "RB17 Pulse" },
632 { 0x51, "RB18 Pulse" },
633 { 0x52, "RB19 Pulse" },
634 { 0x53, "RB20 Pulse" },
635 { 0x54, "RB21 Pulse" },
636 { 0x55, "RB22 Pulse" },
637 { 0x56, "RB23 Pulse" },
638 { 0x57, "RB24 Pulse" },
639 { 0x58, "RB25 Pulse" },
640 { 0x59, "RB26 Pulse" },
641 { 0x5A, "RB27 Pulse" },
642 { 0x5B, "RB28 Pulse" },
643 { 0x5C, "RB29 Pulse" },
644 { 0x5D, "RB30 Pulse" },
645 { 0x5E, "RB31 Pulse" },
646 { 0x5F, "RB32 Pulse" },
649 static value_string_ext selfm_fo_rb_vals_ext
= VALUE_STRING_EXT_INIT(selfm_fo_rb_vals
);
651 /* Fast Operate Breaker Bit Lookup */
652 static const value_string selfm_fo_br_vals
[] = {
653 { 0x11, "Breaker Bit 1 Close (CC/CC1)" },
654 { 0x12, "Breaker Bit 2 Close (CC2)" },
655 { 0x13, "Breaker Bit 3 Close (CC3)" },
656 { 0x14, "Breaker Bit 4 Close (CC4)" },
657 { 0x15, "Breaker Bit 5 Close (CC5)" },
658 { 0x16, "Breaker Bit 6 Close (CC6)" },
659 { 0x17, "Breaker Bit 7 Close (CC7)" },
660 { 0x18, "Breaker Bit 8 Close (CC8)" },
661 { 0x19, "Breaker Bit 9 Close (CC9)" },
662 { 0x1A, "Breaker Bit 10 Close (CC10)" },
663 { 0x1B, "Breaker Bit 11 Close (CC11)" },
664 { 0x1C, "Breaker Bit 12 Close (CC12)" },
665 { 0x1D, "Breaker Bit 13 Close (CC13)" },
666 { 0x1E, "Breaker Bit 14 Close (CC14)" },
667 { 0x1F, "Breaker Bit 15 Close (CC15)" },
668 { 0x20, "Breaker Bit 16 Close (CC16)" },
669 { 0x21, "Breaker Bit 17 Close (CC17)" },
670 { 0x22, "Breaker Bit 18 Close (CC18)" },
671 { 0x31, "Breaker Bit 1 Open (OC/OC1)" },
672 { 0x32, "Breaker Bit 2 Open (OC2)" },
673 { 0x33, "Breaker Bit 3 Open (OC3)" },
674 { 0x34, "Breaker Bit 4 Open (OC4)" },
675 { 0x35, "Breaker Bit 5 Open (OC5)" },
676 { 0x36, "Breaker Bit 6 Open (OC6)" },
677 { 0x37, "Breaker Bit 7 Open (OC7)" },
678 { 0x38, "Breaker Bit 8 Open (OC8)" },
679 { 0x39, "Breaker Bit 9 Open (OC9)" },
680 { 0x3A, "Breaker Bit 10 Open (OC10)" },
681 { 0x3B, "Breaker Bit 11 Open (OC11)" },
682 { 0x3C, "Breaker Bit 12 Open (OC12)" },
683 { 0x3D, "Breaker Bit 13 Open (OC13)" },
684 { 0x3E, "Breaker Bit 14 Open (OC14)" },
685 { 0x3F, "Breaker Bit 15 Open (OC15)" },
686 { 0x40, "Breaker Bit 16 Open (OC16)" },
687 { 0x41, "Breaker Bit 17 Open (OC17)" },
688 { 0x42, "Breaker Bit 18 Open (OC18)" },
691 static value_string_ext selfm_fo_br_vals_ext
= VALUE_STRING_EXT_INIT(selfm_fo_br_vals
);
693 /* Alternate Fast Operate Function Code Lookup */
694 static const value_string selfm_foconfig_alt_funccode_vals
[] = {
695 { 0xE5, "Open Breaker Bit" },
696 { 0xE6, "Close Breaker Bit" },
697 { 0xE7, "Set Remote Bit" },
698 { 0xE8, "Clear Remote Bit" },
699 { 0xE9, "Pulse Remote Bit" },
700 { 0x00, "Unsupported" },
704 /* Fast Message Function Codes */
705 static const value_string selfm_fastmsg_func_code_vals
[] = {
706 { FAST_MSG_CFG_BLOCK
, "Fast Message Configuration Block Request" },
707 { FAST_MSG_EN_UNS_DATA
, "Enable Unsolicited Data" },
708 { FAST_MSG_DIS_UNS_DATA
, "Disable Unsolicited Data" },
709 { FAST_MSG_PING
, "Ping Message" },
710 { FAST_MSG_READ_REQ
, "Read Request" },
711 { FAST_MSG_GEN_UNS_DATA
, "Generic Unsolicited Data" },
712 { FAST_MSG_SOE_STATE_REQ
, "SOE Present State Request" },
713 { FAST_MSG_UNS_RESP
, "Unsolicited Fast SER Data Response" },
714 { FAST_MSG_UNS_WRITE
, "Unsolicited Write" },
715 { FAST_MSG_UNS_WRITE_REQ
, "Unsolicited Write Request" },
716 { FAST_MSG_DEVDESC_REQ
, "Device Description Request" },
717 { FAST_MSG_DATAFMT_REQ
, "Data Format Request" },
718 { FAST_MSG_UNS_DATAFMT_RESP
, "Unsolicited Data Format Response" },
719 { FAST_MSG_BITLABEL_REQ
, "Bit Label Request" },
720 { FAST_MSG_MGMT_REQ
, "Management Request" },
721 { FAST_MSG_CFG_BLOCK_RESP
, "Fast Message Configuration Block Response" },
722 { FAST_MSG_EN_UNS_DATA_ACK
, "Enable Unsolicited Data ACK" },
723 { FAST_MSG_DIS_UNS_DATA_ACK
, "Disable Unsolicited Data ACK" },
724 { FAST_MSG_PING_ACK
, "Ping Message ACK" },
725 { FAST_MSG_READ_RESP
, "Read Response" },
726 { FAST_MSG_SOE_STATE_RESP
, "SOE Present State Response" },
727 { FAST_MSG_UNS_RESP_ACK
, "Unsolicited Fast SER Data Response ACK" },
728 { FAST_MSG_DEVDESC_RESP
, "Device Description Response" },
729 { FAST_MSG_DATAFMT_RESP
, "Data Format Response" },
730 { FAST_MSG_BITLABEL_RESP
, "Bit Label Response" },
733 static value_string_ext selfm_fastmsg_func_code_vals_ext
=
734 VALUE_STRING_EXT_INIT(selfm_fastmsg_func_code_vals
);
736 static const value_string selfm_fastmsg_tagtype_vals
[] = {
737 { FAST_MSG_TAGTYPE_CHAR8
, "1 x 8-bit character per item" },
738 { FAST_MSG_TAGTYPE_CHAR16
, "2 x 8-bit characters per item" },
739 { FAST_MSG_TAGTYPE_DIGWORD8_BL
, "8-bit binary item, with labels" },
740 { FAST_MSG_TAGTYPE_DIGWORD8
, "8-bit binary item, without labels" },
741 { FAST_MSG_TAGTYPE_DIGWORD16_BL
, "16-bit binary item, with labels" },
742 { FAST_MSG_TAGTYPE_DIGWORD16
, "16-bit binary item, without labels" },
743 { FAST_MSG_TAGTYPE_INT16
, "16-bit Signed Integer" },
744 { FAST_MSG_TAGTYPE_UINT16
, "16-bit Unsigned Integer" },
745 { FAST_MSG_TAGTYPE_INT32
, "32-bit Signed Integer" },
746 { FAST_MSG_TAGTYPE_UINT32
, "32-bit Unsigned Integer" },
747 { FAST_MSG_TAGTYPE_FLOAT
, "IEEE Floating Point" },
751 /* Fast Message ACK Response Codes */
752 static const value_string selfm_fastmsg_ack_responsecode_vals
[] = {
754 { 0x1, "Function code not recognized" },
755 { 0x2, "Function code supported but disabled" },
756 { 0x3, "Invalid Data Address" },
758 { 0x5, "Insufficient Memory" },
763 static value_string_ext selfm_fastmsg_ack_responsecode_vals_ext
=
764 VALUE_STRING_EXT_INIT(selfm_fastmsg_ack_responsecode_vals
);
766 /* Fast Message Unsolicited Write COM Port Codes */
767 static const value_string selfm_fastmsg_unswrite_com_vals
[] = {
785 static value_string_ext selfm_fastmsg_unswrite_com_vals_ext
=
786 VALUE_STRING_EXT_INIT(selfm_fastmsg_unswrite_com_vals
);
788 /* Tables for reassembly of fragments. */
789 static reassembly_table selfm_reassembly_table
;
791 /* ************************************************************************* */
792 /* Header values for reassembly */
793 /* ************************************************************************* */
794 static int hf_selfm_fragment
;
795 static int hf_selfm_fragments
;
796 static int hf_selfm_fragment_overlap
;
797 static int hf_selfm_fragment_overlap_conflict
;
798 static int hf_selfm_fragment_multiple_tails
;
799 static int hf_selfm_fragment_too_long_fragment
;
800 static int hf_selfm_fragment_error
;
801 static int hf_selfm_fragment_count
;
802 static int hf_selfm_fragment_reassembled_in
;
803 static int hf_selfm_fragment_reassembled_length
;
804 static int ett_selfm_fragment
;
805 static int ett_selfm_fragments
;
807 static const fragment_items selfm_frag_items
= {
809 &ett_selfm_fragments
,
812 &hf_selfm_fragment_overlap
,
813 &hf_selfm_fragment_overlap_conflict
,
814 &hf_selfm_fragment_multiple_tails
,
815 &hf_selfm_fragment_too_long_fragment
,
816 &hf_selfm_fragment_error
,
817 &hf_selfm_fragment_count
,
818 &hf_selfm_fragment_reassembled_in
,
819 &hf_selfm_fragment_reassembled_length
,
820 /* Reassembled data field */
822 "SEL Fast Message fragments"
825 /**********************************************************************************************************/
826 /* Clean all instances of 0xFFFF from Telnet payload to compensate for IAC control code (replace w/ 0xFF) */
827 /* Function Duplicated from packet-telnet.c (unescape_and_tvbuffify_telnet_option) */
828 /**********************************************************************************************************/
830 clean_telnet_iac(packet_info
*pinfo
, tvbuff_t
*tvb
, int offset
, int len
, int *num_skip_byte
)
832 tvbuff_t
*telnet_tvb
;
836 int len_remaining
, skip_byte
= 0;
838 spos
=tvb_get_ptr(tvb
, offset
, len
);
839 buf
=(uint8_t *)wmem_alloc(pinfo
->pool
, len
);
842 while(len_remaining
> 0){
844 /* Only analyze two sequential bytes of source tvb if we have at least two bytes left */
845 if (len_remaining
> 1) {
846 /* If two sequential 0xFF's exist, increment skip_byte counter, decrement */
847 /* len_remaining by 2 and copy a single 0xFF to dest tvb. */
848 if((spos
[0]==0xff) && (spos
[1]==0xff)){
856 /* If we only have a single byte left, or there were no sequential 0xFF's, copy byte from src tvb to dest tvb */
860 telnet_tvb
= tvb_new_child_real_data(tvb
, buf
, len
-skip_byte
, len
-skip_byte
);
861 add_new_data_source(pinfo
, telnet_tvb
, "Processed Telnet Data");
863 *num_skip_byte
= skip_byte
;
868 /******************************************************************************************************/
869 /* Execute dissection of Fast Meter configuration frames independent of any GUI access of said frames */
870 /* Load configuration information into fm_config_frame struct */
871 /******************************************************************************************************/
872 static fm_config_frame
* fmconfig_frame_fast(tvbuff_t
*tvb
)
874 /* Set up structures needed to add the protocol subtree and manage it */
875 unsigned count
, offset
= 0;
876 fm_config_frame
*frame
;
878 /* get a new frame and initialize it */
879 frame
= wmem_new(wmem_file_scope(), fm_config_frame
);
881 /* Get data packet setup information from config message and copy into ai_info (if required) */
882 frame
->cfg_cmd
= tvb_get_ntohs(tvb
, offset
);
883 /* skip length byte, position offset+2 */
884 frame
->num_flags
= tvb_get_uint8(tvb
, offset
+3);
885 frame
->sf_loc
= tvb_get_uint8(tvb
, offset
+4);
886 frame
->sf_num
= tvb_get_uint8(tvb
, offset
+5);
887 frame
->num_ai
= tvb_get_uint8(tvb
, offset
+6);
888 frame
->num_ai_samples
= tvb_get_uint8(tvb
, offset
+7);
889 frame
->num_dig
= tvb_get_uint8(tvb
, offset
+8);
890 frame
->num_calc
= tvb_get_uint8(tvb
, offset
+9);
892 /* Update offset pointer */
895 /* Get data packet analog/timestamp/digital offsets and copy into ai_info */
896 frame
->offset_ai
= tvb_get_ntohs(tvb
, offset
);
897 frame
->offset_ts
= tvb_get_ntohs(tvb
, offset
+2);
898 frame
->offset_dig
= tvb_get_ntohs(tvb
, offset
+4);
900 /* Update offset pointer */
903 frame
->analogs
= (fm_analog_info
*)wmem_alloc(wmem_file_scope(), frame
->num_ai
* sizeof(fm_analog_info
));
905 /* Get AI Channel Details and copy into ai_info */
906 for (count
= 0; count
< frame
->num_ai
; count
++) {
907 fm_analog_info
*analog
= &(frame
->analogs
[count
]);
908 tvb_memcpy(tvb
, analog
->name
, offset
, FM_CONFIG_ANA_CHNAME_LEN
);
909 analog
->name
[FM_CONFIG_ANA_CHNAME_LEN
] = '\0'; /* Put a terminating null onto the end of the AI Channel name */
910 analog
->type
= tvb_get_uint8(tvb
, offset
+6);
911 analog
->sf_type
= tvb_get_uint8(tvb
, offset
+7);
912 analog
->sf_offset
= tvb_get_ntohs(tvb
, offset
+8);
914 /* If Scale Factors are present in the cfg message, retrieve and store them per analog */
915 /* Otherwise, default to Scale Factor of 1 for now */
916 if (frame
->sf_loc
== FM_CONFIG_SF_LOC_CFG
) {
917 analog
->sf_fp
= tvb_get_ntohieee_float(tvb
, analog
->sf_offset
);
930 /******************************************************************************************************/
931 /* Execute dissection of Data Item definition info before loading GUI tree */
932 /* Load configuration information into fastmsg_dataitem struct */
933 /******************************************************************************************************/
934 static fastmsg_dataitem
* fastmsg_dataitem_save(tvbuff_t
*tvb
, int offset
)
936 fastmsg_dataitem
*dataitem
;
938 /* get a new dataitem and initialize it */
939 dataitem
= wmem_new(wmem_file_scope(), fastmsg_dataitem
);
941 /* retrieve data item name and terminate with a null */
942 tvb_memcpy(tvb
, dataitem
->name
, offset
, 10);
943 dataitem
->name
[10] = '\0'; /* Put a terminating null onto the end of the string */
945 /* retrieve data item quantity and type */
946 dataitem
->quantity
= tvb_get_ntohs(tvb
, offset
+10);
947 dataitem
->data_type
= tvb_get_ntohs(tvb
, offset
+12);
953 /******************************************************************************************************/
954 /* Execute dissection of Data Region definition info before loading GUI tree */
955 /* Load configuration information into fastmsg_dataregion struct */
956 /******************************************************************************************************/
957 static fastmsg_dataregion
* fastmsg_dataregion_save(tvbuff_t
*tvb
, int offset
)
959 fastmsg_dataregion
*dataregion
;
961 /* get a new dataregion and initialize it */
962 dataregion
= wmem_new(wmem_file_scope(), fastmsg_dataregion
);
964 /* retrieve data region name and terminate with a null */
965 tvb_memcpy(tvb
, dataregion
->name
, offset
, 10);
966 dataregion
->name
[10] = '\0'; /* Put a terminating null onto the end of the string */
972 /********************************************************************************************************/
973 /* Lookup region name using current base address & saved conversation data. Return ptr to char string */
974 /********************************************************************************************************/
976 region_lookup(packet_info
*pinfo
, uint32_t base_addr
)
978 fm_conversation
*conv
;
979 fastmsg_dataregion
*dataregion
= NULL
;
981 conv
= (fm_conversation
*)p_get_proto_data(wmem_file_scope(), pinfo
, proto_selfm
, 0);
983 dataregion
= (fastmsg_dataregion
*)wmem_tree_lookup32(conv
->fastmsg_dataregions
, base_addr
);
987 return dataregion
->name
;
990 /* If we couldn't identify the region using the current base address, return a default string */
991 return "Unknown Region";
994 /***********************************************************************************************************/
995 /* Create Fast SER Unsolicited Word Bit item. Return item to calling function. 'index' parameter */
996 /* will be used to store 'name' parameter in lookup tree. Index 254 and 255 are special (hardcoded) cases */
997 /***********************************************************************************************************/
998 static fastser_uns_wordbit
* fastser_uns_wordbit_save(uint8_t idx
, const char *name
)
1000 fastser_uns_wordbit
*wordbit_item
;
1002 /* get a new wordbit_item and initialize it */
1003 wordbit_item
= wmem_new(wmem_file_scope(), fastser_uns_wordbit
);
1006 wordbit_item
->name
= wmem_strdup(wmem_file_scope(), name
);
1010 wordbit_item
->name
= wmem_strdup(wmem_file_scope(), "POWER_UP");
1014 wordbit_item
->name
= wmem_strdup(wmem_file_scope(), "SET_CHNG");
1017 return wordbit_item
;
1021 /***************************************************************************************************************/
1022 /* Lookup uns wordbit name using current index position & saved conversation data. Return ptr to char string */
1023 /***************************************************************************************************************/
1025 fastser_uns_wordbit_lookup(packet_info
*pinfo
, uint8_t idx
)
1027 fm_conversation
*conv
;
1028 fastser_uns_wordbit
*wordbit
= NULL
;
1030 conv
= (fm_conversation
*)p_get_proto_data(wmem_file_scope(), pinfo
, proto_selfm
, 0);
1033 wordbit
= (fastser_uns_wordbit
*)wmem_tree_lookup32(conv
->fastser_uns_wordbits
, idx
);
1037 return wordbit
->name
;
1040 /* If we couldn't identify the bit using the index, return a default string */
1045 /******************************************************************************************************/
1046 /* Code to Dissect Relay Definition Frames */
1047 /******************************************************************************************************/
1049 dissect_relaydef_frame(tvbuff_t
*tvb
, proto_tree
*tree
, int offset
)
1051 /* Set up structures needed to add the protocol subtree and manage it */
1052 proto_item
*relaydef_fm_item
, *relaydef_flags_item
, *relaydef_proto_item
;
1053 proto_tree
*relaydef_tree
, *relaydef_fm_tree
, *relaydef_flags_tree
, *relaydef_proto_tree
;
1054 uint8_t len
, num_proto
, num_fm
, num_flags
;
1057 len
= tvb_get_uint8(tvb
, offset
);
1058 num_proto
= tvb_get_uint8(tvb
, offset
+1);
1059 num_fm
= tvb_get_uint8(tvb
, offset
+2);
1060 num_flags
= tvb_get_uint8(tvb
, offset
+3);
1062 /* Add items to protocol tree specific to Relay Definition Block */
1063 relaydef_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, len
-2, ett_selfm_relaydef
, NULL
, "Relay Definition Block Details");
1065 /* Reported length */
1066 proto_tree_add_item(relaydef_tree
, hf_selfm_relaydef_len
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1068 /* Reported Number of Protocols Supported */
1069 relaydef_proto_item
= proto_tree_add_item(relaydef_tree
, hf_selfm_relaydef_numproto
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
1070 relaydef_proto_tree
= proto_item_add_subtree(relaydef_proto_item
, ett_selfm_relaydef_proto
);
1072 /* Reported Number of Fast Meter Commands Supported */
1073 relaydef_fm_item
= proto_tree_add_item(relaydef_tree
, hf_selfm_relaydef_numfm
, tvb
, offset
+2, 1, ENC_BIG_ENDIAN
);
1074 relaydef_fm_tree
= proto_item_add_subtree(relaydef_fm_item
, ett_selfm_relaydef_fm
);
1076 /* Reported Number of Status Bit Flags Supported */
1077 relaydef_flags_item
= proto_tree_add_item(relaydef_tree
, hf_selfm_relaydef_numflags
, tvb
, offset
+3, 1, ENC_BIG_ENDIAN
);
1078 relaydef_flags_tree
= proto_item_add_subtree(relaydef_flags_item
, ett_selfm_relaydef_flags
);
1080 /* Get our offset up-to-date */
1083 /* Add each reported Fast Meter cfg/data message */
1084 for (count
= 1; count
<= num_fm
; count
++) {
1085 proto_tree_add_item(relaydef_fm_tree
, hf_selfm_relaydef_fmcfg_cmd
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1086 proto_tree_add_item(relaydef_fm_tree
, hf_selfm_relaydef_fmdata_cmd
, tvb
, offset
+2, 2, ENC_BIG_ENDIAN
);
1090 /* Add each reported status bit flag, along with corresponding response command */
1091 for (count
= 1; count
<= num_flags
; count
++) {
1092 proto_tree_add_item(relaydef_flags_tree
, hf_selfm_relaydef_statbit
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1093 proto_tree_add_item(relaydef_flags_tree
, hf_selfm_relaydef_statbit_cmd
, tvb
, offset
+2, 6, ENC_NA
);
1097 /* Add each supported protocol */
1098 for (count
= 1; count
<= num_proto
; count
++) {
1099 proto_tree_add_item(relaydef_proto_tree
, hf_selfm_relaydef_proto
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1103 /* Add Pad byte (if present) and checksum */
1104 if (tvb_reported_length_remaining(tvb
, offset
) > 1) {
1105 proto_tree_add_item(relaydef_tree
, hf_selfm_padbyte
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1109 proto_tree_add_checksum(relaydef_tree
, tvb
, offset
, hf_selfm_checksum
, -1, NULL
, NULL
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
1115 /******************************************************************************************************/
1116 /* Code to dissect Fast Meter Configuration Frames */
1117 /******************************************************************************************************/
1119 dissect_fmconfig_frame(tvbuff_t
*tvb
, proto_tree
*tree
, packet_info
*pinfo
, int offset
)
1121 /* Set up structures needed to add the protocol subtree and manage it */
1122 proto_tree
*fmconfig_tree
, *fmconfig_ai_tree
=NULL
, *fmconfig_calc_tree
=NULL
;
1124 uint8_t len
, sf_loc
, num_sf
, num_ai
, num_calc
;
1127 len
= tvb_get_uint8(tvb
, offset
);
1128 /* skip num_flags, position offset+1 */
1129 sf_loc
= tvb_get_uint8(tvb
, offset
+2);
1130 num_sf
= tvb_get_uint8(tvb
, offset
+3);
1131 num_ai
= tvb_get_uint8(tvb
, offset
+4);
1132 /* skip num_samp, position offset+5 */
1133 /* skip num_dig, position offset+6 */
1134 num_calc
= tvb_get_uint8(tvb
, offset
+7);
1136 fmconfig_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, len
-2, ett_selfm_fmconfig
, NULL
, "Fast Meter Configuration Details");
1138 /* Add items to protocol tree specific to Fast Meter Configuration Block */
1140 /* Get Setup Information for FM Config Block */
1141 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_len
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1142 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_numflags
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
1143 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_loc_sf
, tvb
, offset
+2, 1, ENC_BIG_ENDIAN
);
1144 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_num_sf
, tvb
, offset
+3, 1, ENC_BIG_ENDIAN
);
1145 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_num_ai
, tvb
, offset
+4, 1, ENC_BIG_ENDIAN
);
1146 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_num_samp
, tvb
, offset
+5, 1, ENC_BIG_ENDIAN
);
1147 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_num_dig
, tvb
, offset
+6, 1, ENC_BIG_ENDIAN
);
1148 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_num_calc
, tvb
, offset
+7, 1, ENC_BIG_ENDIAN
);
1150 /* Update offset pointer */
1153 /* Add data packet offsets to tree and update offset pointer */
1154 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_ofs_ai
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1155 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_ofs_ts
, tvb
, offset
+2, 2, ENC_BIG_ENDIAN
);
1156 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_ofs_dig
, tvb
, offset
+4, 2, ENC_BIG_ENDIAN
);
1159 /* Get AI Channel Details */
1160 for (count
= 0; count
< num_ai
; count
++) {
1161 ai_name
= tvb_get_string_enc(pinfo
->pool
, tvb
, offset
, 6, ENC_ASCII
);
1163 fmconfig_ai_tree
= proto_tree_add_subtree_format(fmconfig_tree
, tvb
, offset
, 10,
1164 ett_selfm_fmconfig_ai
, NULL
, "Analog Channel: %s", ai_name
);
1166 /* Add Channel Name, Channel Data Type, Scale Factor Type and Scale Factor Offset to tree */
1167 proto_tree_add_item(fmconfig_ai_tree
, hf_selfm_fmconfig_ai_channel
, tvb
, offset
, 6, ENC_ASCII
);
1168 proto_tree_add_item(fmconfig_ai_tree
, hf_selfm_fmconfig_ai_type
, tvb
, offset
+6, 1, ENC_BIG_ENDIAN
);
1169 proto_tree_add_item(fmconfig_ai_tree
, hf_selfm_fmconfig_ai_sf_type
, tvb
, offset
+7, 1, ENC_BIG_ENDIAN
);
1170 proto_tree_add_item(fmconfig_ai_tree
, hf_selfm_fmconfig_ai_sf_ofs
, tvb
, offset
+8, 2, ENC_BIG_ENDIAN
);
1172 /* Update Offset Pointer */
1176 /* 14-byte Calculation block instances based on num_calc */
1177 for (count
= 0; count
< num_calc
; count
++) {
1178 fmconfig_calc_tree
= proto_tree_add_subtree_format(fmconfig_tree
, tvb
, offset
, 14,
1179 ett_selfm_fmconfig_calc
, NULL
, "Calculation Block: %d", count
+1);
1181 /* Rotation, Voltage Connection and Current Connection are all bit-masked on the same byte */
1182 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_rot
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1183 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_vconn
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1184 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_iconn
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1186 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_ctype
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
1187 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_deskew_ofs
, tvb
, offset
+2, 2, ENC_BIG_ENDIAN
);
1188 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_rs_ofs
, tvb
, offset
+4, 2, ENC_BIG_ENDIAN
);
1189 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_xs_ofs
, tvb
, offset
+6, 2, ENC_BIG_ENDIAN
);
1190 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_ia_idx
, tvb
, offset
+8, 1, ENC_BIG_ENDIAN
);
1191 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_ib_idx
, tvb
, offset
+9, 1, ENC_BIG_ENDIAN
);
1192 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_ic_idx
, tvb
, offset
+10, 1, ENC_BIG_ENDIAN
);
1193 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_va_idx
, tvb
, offset
+11, 1, ENC_BIG_ENDIAN
);
1194 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_vb_idx
, tvb
, offset
+12, 1, ENC_BIG_ENDIAN
);
1195 proto_tree_add_item(fmconfig_calc_tree
, hf_selfm_fmconfig_cblk_vc_idx
, tvb
, offset
+13, 1, ENC_BIG_ENDIAN
);
1200 /* Add Config Message Scale Factor(s) (if present) */
1201 if ((num_sf
!= 0) && (sf_loc
== FM_CONFIG_SF_LOC_CFG
)) {
1202 for (count
= 0; count
< num_sf
; count
++) {
1203 proto_tree_add_item(fmconfig_tree
, hf_selfm_fmconfig_ai_sf_float
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
1208 /* Add Pad byte (if present) and checksum */
1209 if (tvb_reported_length_remaining(tvb
, offset
) > 1) {
1210 proto_tree_add_item(fmconfig_tree
, hf_selfm_padbyte
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1214 proto_tree_add_checksum(fmconfig_tree
, tvb
, offset
, hf_selfm_checksum
, -1, NULL
, NULL
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
1221 /******************************************************************************************************/
1222 /* Code to dissect Fast Meter Data Frames */
1223 /* Formatting depends heavily on previously-encountered Configuration Frames so search array instances for them */
1224 /******************************************************************************************************/
1226 dissect_fmdata_frame(tvbuff_t
*tvb
, proto_tree
*tree
, packet_info
*pinfo
, int offset
, uint16_t config_cmd_match
)
1228 /* Set up structures needed to add the protocol subtree and manage it */
1229 proto_item
*fmdata_item
, *fmdata_dig_ch_item
;
1230 proto_item
*fmdata_ai_sf_item
;
1231 proto_tree
*fmdata_tree
, *fmdata_ai_tree
=NULL
, *fmdata_dig_tree
=NULL
, *fmdata_ai_ch_tree
=NULL
, *fmdata_dig_ch_tree
=NULL
;
1232 uint8_t len
, idx
=0, j
=0;
1233 uint16_t config_cmd
;
1234 int16_t ai_int16val
;
1235 int cnt
= 0, ch_size
=0;
1237 bool config_found
= false;
1238 fm_conversation
*conv
;
1239 fm_config_frame
*cfg_data
= NULL
;
1243 len
= tvb_get_uint8(tvb
, offset
);
1245 fmdata_tree
= proto_tree_add_subtree_format(tree
, tvb
, offset
, len
-2, ett_selfm_fmdata
, &fmdata_item
, "Fast Meter Data Details");
1247 /* Reported length */
1248 proto_tree_add_item(fmdata_tree
, hf_selfm_fmdata_len
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1251 /* Search for previously-encountered Configuration information to dissect the frame */
1253 conv
= (fm_conversation
*)p_get_proto_data(wmem_file_scope(), pinfo
, proto_selfm
, 0);
1256 wmem_list_frame_t
*frame
= wmem_list_head(conv
->fm_config_frames
);
1257 /* Cycle through possible instances of multiple fm_config_data_blocks, looking for match */
1258 while (frame
&& !config_found
) {
1259 cfg_data
= (fm_config_frame
*)wmem_list_frame_data(frame
);
1260 config_cmd
= cfg_data
->cfg_cmd
;
1262 /* If the stored config_cmd matches the expected one we are looking for, mark that the config data was found */
1263 if (config_cmd
== config_cmd_match
) {
1264 proto_item_append_text(fmdata_item
, ", using frame number %"PRIu32
" as Configuration Frame",
1266 config_found
= true;
1269 frame
= wmem_list_frame_next(frame
);
1274 /* Retrieve number of Status Flag bytes and setup tree */
1275 if (cfg_data
->num_flags
== 1){
1276 proto_tree_add_item(fmdata_tree
, hf_selfm_fmdata_flagbyte
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1280 cnt
= cfg_data
->num_ai
; /* actual number of analog values to available to dissect */
1282 /* Update our current tvb offset to the actual AI offset saved from the Configuration message */
1283 offset
= cfg_data
->offset_ai
;
1285 /* Check that we actually have analog data to dissect */
1288 /* Include decoding for each Sample provided for the Analog Channels */
1289 for (j
=0; j
< cfg_data
->num_ai_samples
; j
++) {
1291 /* Use different lookup strings, depending on how many samples are available per Analog Channel */
1292 if (cfg_data
->num_ai_samples
== 1) {
1293 fmdata_ai_tree
= proto_tree_add_subtree_format(fmdata_tree
, tvb
, offset
, ((cfg_data
->offset_ts
- cfg_data
->offset_ai
)/cfg_data
->num_ai_samples
),
1294 ett_selfm_fmdata_ai
, NULL
, "Analog Channels (%d), Sample: %d (%s)",
1295 cfg_data
->num_ai
, j
+1, val_to_str_const(j
+1, selfm_fmconfig_numsamples1_vals
, "Unknown"));
1297 else if (cfg_data
->num_ai_samples
== 2) {
1298 fmdata_ai_tree
= proto_tree_add_subtree_format(fmdata_tree
, tvb
, offset
, ((cfg_data
->offset_ts
- cfg_data
->offset_ai
)/cfg_data
->num_ai_samples
),
1299 ett_selfm_fmdata_ai
, NULL
, "Analog Channels (%d), Sample: %d (%s)",
1300 cfg_data
->num_ai
, j
+1, val_to_str_const(j
+1, selfm_fmconfig_numsamples2_vals
, "Unknown"));
1302 else if (cfg_data
->num_ai_samples
== 4) {
1303 fmdata_ai_tree
= proto_tree_add_subtree_format(fmdata_tree
, tvb
, offset
, ((cfg_data
->offset_ts
- cfg_data
->offset_ai
)/cfg_data
->num_ai_samples
),
1304 ett_selfm_fmdata_ai
, NULL
, "Analog Channels (%d), Sample: %d (%s)",
1305 cfg_data
->num_ai
, j
+1, val_to_str_const(j
+1, selfm_fmconfig_numsamples4_vals
, "Unknown"));
1308 /* For each analog channel we encounter... */
1309 for (idx
= 0; idx
< cnt
; idx
++) {
1311 fm_analog_info
*ai
= &(cfg_data
->analogs
[idx
]);
1313 /* Channel size (in bytes) determined by data type */
1315 case FM_CONFIG_ANA_CHTYPE_INT16
:
1316 ch_size
= 2; /* 2 bytes */
1318 case FM_CONFIG_ANA_CHTYPE_FP
:
1319 ch_size
= 4; /* 4 bytes */
1321 case FM_CONFIG_ANA_CHTYPE_FPD
:
1322 ch_size
= 8; /* 8 bytes */
1328 /* Build sub-tree for each Analog Channel */
1329 fmdata_ai_ch_tree
= proto_tree_add_subtree_format(fmdata_ai_tree
, tvb
, offset
, ch_size
,
1330 ett_selfm_fmdata_ai_ch
, NULL
, "Analog Channel %d: %s", idx
+1, ai
->name
);
1332 /* XXX - Need more decoding options here for different data types, but I need packet capture examples first */
1333 /* Decode analog value appropriately, according to data type */
1335 /* Channel type is 16-bit Integer */
1336 case FM_CONFIG_ANA_CHTYPE_INT16
:
1337 ai_int16val
= tvb_get_ntohs(tvb
, offset
);
1339 /* If we've got a scale factor, apply it before printing the analog */
1340 /* For scale factors present in the Fast Meter Data message... */
1341 if ((ai
->sf_offset
!= 0) && (ai
->sf_type
== FM_CONFIG_ANA_SFTYPE_FP
) && (cfg_data
->sf_loc
== FM_CONFIG_SF_LOC_FM
)) {
1342 ai_sf_fp
= tvb_get_ntohieee_float(tvb
, ai
->sf_offset
);
1343 proto_tree_add_float(fmdata_ai_ch_tree
, hf_selfm_fmdata_ai_sf_fp
, tvb
, ai
->sf_offset
, 4, ai_sf_fp
);
1345 /* For scale factors present in the Fast Meter Configuration Message... */
1346 else if (cfg_data
->sf_loc
== FM_CONFIG_SF_LOC_CFG
) {
1347 ai_sf_fp
= ai
->sf_fp
;
1348 fmdata_ai_sf_item
= proto_tree_add_float(fmdata_ai_ch_tree
, hf_selfm_fmdata_ai_sf_fp
, tvb
, offset
, ch_size
, ai_sf_fp
);
1349 proto_item_set_generated(fmdata_ai_sf_item
);
1351 /* If there was no scale factor, default value to 1 */
1356 proto_tree_add_uint(fmdata_ai_ch_tree
, hf_selfm_fmdata_ai_value16
, tvb
, offset
, ch_size
, ai_int16val
);
1357 proto_tree_add_float(fmdata_ai_ch_tree
, hf_selfm_fmdata_ai_scale_factor
, tvb
, offset
, ch_size
, ((float)ai_int16val
*ai_sf_fp
));
1360 /* Channel type is IEEE Floating point */
1361 case FM_CONFIG_ANA_CHTYPE_FP
:
1362 proto_tree_add_item(fmdata_ai_ch_tree
, hf_selfm_fmdata_ai_value_float
, tvb
, offset
, ch_size
, ENC_BIG_ENDIAN
);
1365 /* Channel type is Double IEEE Floating point */
1366 case FM_CONFIG_ANA_CHTYPE_FPD
:
1367 proto_tree_add_item(fmdata_ai_ch_tree
, hf_selfm_fmdata_ai_value_double
, tvb
, offset
, ch_size
, ENC_BIG_ENDIAN
);
1371 } /* channel type */
1373 } /* number of analog channels */
1375 } /* number of samples */
1377 } /* there were analogs */
1379 /* Check if we have a time-stamp in this message */
1380 if (cfg_data
->offset_ts
!= 0xFFFF) {
1381 /* Retrieve timestamp from 8-byte format */
1382 /* Stored as: month, day, year (xx), hr, min, sec, msec (16-bit) */
1383 tm
.tm_mon
= tvb_get_uint8(tvb
, offset
) - 1;
1384 tm
.tm_mday
= tvb_get_uint8(tvb
, offset
+1);
1385 tm
.tm_year
= tvb_get_uint8(tvb
, offset
+2) + 100;
1386 tm
.tm_hour
= tvb_get_uint8(tvb
, offset
+3);
1387 tm
.tm_min
= tvb_get_uint8(tvb
, offset
+4);
1388 tm
.tm_sec
= tvb_get_uint8(tvb
, offset
+5);
1391 datetime
.nsecs
= (tvb_get_ntohs(tvb
, offset
+6) % 1000) * 1000000;
1392 datetime
.secs
= mktime(&tm
);
1394 proto_tree_add_time(fmdata_tree
, hf_selfm_fmdata_timestamp
, tvb
, offset
, 8, &datetime
);
1399 /* Check that we actually have digital data */
1400 if (cfg_data
->num_dig
> 0) {
1402 fmdata_dig_tree
= proto_tree_add_subtree_format(fmdata_tree
, tvb
, offset
, cfg_data
->num_dig
,
1403 ett_selfm_fmdata_dig
, NULL
, "Digital Channels (%d)", cfg_data
->num_dig
);
1405 for (idx
=0; idx
< cfg_data
->num_dig
; idx
++) {
1407 fmdata_dig_ch_tree
= proto_tree_add_subtree_format(fmdata_dig_tree
, tvb
, offset
, 1, ett_selfm_fmdata_dig_ch
, &fmdata_dig_ch_item
, "Digital Word Bit Row: %2d", idx
+1);
1409 /* Display the bit pattern on the digital channel proto_item */
1410 proto_item_append_text(fmdata_dig_ch_item
, " [ %d %d %d %d %d %d %d %d ]",
1411 ((tvb_get_uint8(tvb
, offset
) & 0x80) >> 7), ((tvb_get_uint8(tvb
, offset
) & 0x40) >> 6),
1412 ((tvb_get_uint8(tvb
, offset
) & 0x20) >> 5), ((tvb_get_uint8(tvb
, offset
) & 0x10) >> 4),
1413 ((tvb_get_uint8(tvb
, offset
) & 0x08) >> 3), ((tvb_get_uint8(tvb
, offset
) & 0x04) >> 2),
1414 ((tvb_get_uint8(tvb
, offset
) & 0x02) >> 1), (tvb_get_uint8(tvb
, offset
) & 0x01));
1416 proto_tree_add_item(fmdata_dig_ch_tree
, hf_selfm_fmdata_dig_b0
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1417 proto_tree_add_item(fmdata_dig_ch_tree
, hf_selfm_fmdata_dig_b1
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1418 proto_tree_add_item(fmdata_dig_ch_tree
, hf_selfm_fmdata_dig_b2
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1419 proto_tree_add_item(fmdata_dig_ch_tree
, hf_selfm_fmdata_dig_b3
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1420 proto_tree_add_item(fmdata_dig_ch_tree
, hf_selfm_fmdata_dig_b4
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1421 proto_tree_add_item(fmdata_dig_ch_tree
, hf_selfm_fmdata_dig_b5
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1422 proto_tree_add_item(fmdata_dig_ch_tree
, hf_selfm_fmdata_dig_b6
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1423 proto_tree_add_item(fmdata_dig_ch_tree
, hf_selfm_fmdata_dig_b7
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1428 } /* digital data was available */
1430 /* Add Pad byte (if present) and checksum */
1431 if (tvb_reported_length_remaining(tvb
, offset
) > 1) {
1432 proto_tree_add_item(fmdata_tree
, hf_selfm_padbyte
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1436 proto_tree_add_checksum(fmdata_tree
, tvb
, offset
, hf_selfm_checksum
, -1, NULL
, pinfo
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
1439 } /* matching config frame message was found */
1441 } /* config data found */
1443 if (!config_found
) {
1444 proto_item_append_text(fmdata_item
, ", No Fast Meter Configuration frame found");
1445 offset
+= (len
-3); /* Don't include the 2 header bytes or 1 length byte, those are already in the offset */
1454 /******************************************************************************************************/
1455 /* Code to Dissect Fast Operate Configuration Frames */
1456 /******************************************************************************************************/
1458 dissect_foconfig_frame(tvbuff_t
*tvb
, proto_tree
*tree
, int offset
)
1460 /* Set up structures needed to add the protocol subtree and manage it */
1461 proto_item
*foconfig_brkr_item
, *foconfig_rb_item
;
1462 proto_tree
*foconfig_tree
, *foconfig_brkr_tree
=NULL
, *foconfig_rb_tree
=NULL
;
1464 uint8_t len
, num_brkr
, prb_supp
;
1467 len
= tvb_get_uint8(tvb
, offset
);
1468 num_brkr
= tvb_get_uint8(tvb
, offset
+1);
1469 num_rb
= tvb_get_ntohs(tvb
, offset
+2);
1470 prb_supp
= tvb_get_uint8(tvb
, offset
+4);
1472 foconfig_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, len
-2, ett_selfm_foconfig
, NULL
, "Fast Operate Configuration Details");
1474 /* Add items to protocol tree specific to Fast Operate Configuration Block */
1476 /* Reported length */
1477 proto_tree_add_item(foconfig_tree
, hf_selfm_foconfig_len
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1479 /* Supported Breaker Bits */
1480 foconfig_brkr_item
= proto_tree_add_item(foconfig_tree
, hf_selfm_foconfig_num_brkr
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
1482 /* Supported Remote Bits */
1483 foconfig_rb_item
= proto_tree_add_item(foconfig_tree
, hf_selfm_foconfig_num_rb
, tvb
, offset
+2, 2, ENC_BIG_ENDIAN
);
1485 /* Add "Remote Bit Pulse Supported?" and "Reserved Bit" to Tree */
1486 proto_tree_add_item(foconfig_tree
, hf_selfm_foconfig_prb_supp
, tvb
, offset
+4, 1, ENC_BIG_ENDIAN
);
1487 proto_tree_add_item(foconfig_tree
, hf_selfm_foconfig_reserved
, tvb
, offset
+5, 1, ENC_BIG_ENDIAN
);
1489 /* Update offset pointer */
1492 /* Get Breaker Bit Command Details */
1493 for (count
= 1; count
<= num_brkr
; count
++) {
1495 foconfig_brkr_tree
= proto_item_add_subtree(foconfig_brkr_item
, ett_selfm_foconfig_brkr
);
1497 /* Add Breaker Open/Close commands to tree */
1498 proto_tree_add_item(foconfig_brkr_tree
, hf_selfm_foconfig_brkr_open
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1499 proto_tree_add_item(foconfig_brkr_tree
, hf_selfm_foconfig_brkr_close
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
1504 /* Get Remote Bit Command Details */
1505 for (count
= 1; count
<= num_rb
; count
++) {
1507 foconfig_rb_tree
= proto_item_add_subtree(foconfig_rb_item
, ett_selfm_foconfig_rb
);
1509 /* Add "Remote Bit Set" command to tree */
1510 proto_tree_add_item(foconfig_rb_tree
, hf_selfm_foconfig_rb_cmd
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1512 /* Print "Remote Bit Clear" command to tree */
1513 proto_tree_add_item(foconfig_rb_tree
, hf_selfm_foconfig_rb_cmd
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
1515 /* If Remote Bit "pulse" is supported, retrieve that command as well */
1517 proto_tree_add_item(foconfig_rb_tree
, hf_selfm_foconfig_rb_cmd
, tvb
, offset
+2, 1, ENC_BIG_ENDIAN
);
1525 /* Add Pad byte (if present) and checksum */
1526 if (tvb_reported_length_remaining(tvb
, offset
) > 1) {
1527 proto_tree_add_item(foconfig_tree
, hf_selfm_padbyte
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1531 proto_tree_add_checksum(foconfig_tree
, tvb
, offset
, hf_selfm_checksum
, -1, NULL
, NULL
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
1538 /******************************************************************************************************/
1539 /* Code to Dissect Alternate Fast Operate (AFO) Configuration Frames */
1540 /******************************************************************************************************/
1542 dissect_alt_fastop_config_frame(tvbuff_t
*tvb
, proto_tree
*tree
, int offset
)
1544 /* Set up structures needed to add the protocol subtree and manage it */
1545 proto_tree
*foconfig_tree
;
1548 len
= tvb_get_uint8(tvb
, offset
);
1550 foconfig_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, len
-2,
1551 ett_selfm_foconfig
, NULL
, "Alternate Fast Operate Configuration Details");
1553 /* Add items to protocol tree specific to Fast Operate Configuration Block */
1555 /* Reported length */
1556 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_len
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1558 /* Number of Ports */
1559 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_num_ports
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
1561 /* Number of Breaker Bits */
1562 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_num_brkr
, tvb
, offset
+2, 1, ENC_BIG_ENDIAN
);
1564 /* Number of Remote Bits */
1565 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_num_rb
, tvb
, offset
+3, 1, ENC_BIG_ENDIAN
);
1567 /* Function Code(s) Supported */
1568 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_funccode
, tvb
, offset
+4, 1, ENC_BIG_ENDIAN
);
1569 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_funccode
, tvb
, offset
+5, 1, ENC_BIG_ENDIAN
);
1570 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_funccode
, tvb
, offset
+6, 1, ENC_BIG_ENDIAN
);
1571 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_funccode
, tvb
, offset
+7, 1, ENC_BIG_ENDIAN
);
1572 proto_tree_add_item(foconfig_tree
, hf_selfm_alt_foconfig_funccode
, tvb
, offset
+8, 1, ENC_BIG_ENDIAN
);
1574 offset
+= (len
- 2);
1580 /******************************************************************************************************/
1581 /* Code to Dissect Fast Operate (Remote Bit or Breaker Bit) Frames */
1582 /******************************************************************************************************/
1584 dissect_fastop_frame(tvbuff_t
*tvb
, proto_tree
*tree
, packet_info
*pinfo
, int offset
)
1586 /* Set up structures needed to add the protocol subtree and manage it */
1587 proto_tree
*fastop_tree
;
1588 uint8_t len
, opcode
;
1591 msg_type
= tvb_get_ntohs(tvb
, offset
-2);
1592 len
= tvb_get_uint8(tvb
, offset
);
1594 fastop_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, len
-2, ett_selfm_fastop
, NULL
, "Fast Operate Details");
1596 /* Add Reported length to tree*/
1597 proto_tree_add_item(fastop_tree
, hf_selfm_fastop_len
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1601 opcode
= tvb_get_uint8(tvb
, offset
);
1603 /* Use different lookup table for different msg_type */
1604 if (msg_type
== CMD_FASTOP_RB_CTRL
) {
1605 proto_tree_add_item(fastop_tree
, hf_selfm_fastop_rb_code
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1607 /* Append Column Info w/ Control Code Code */
1608 col_append_sep_str(pinfo
->cinfo
, COL_INFO
, NULL
, val_to_str_ext_const(opcode
, &selfm_fo_rb_vals_ext
, "Unknown Control Code"));
1610 else if (msg_type
== CMD_FASTOP_BR_CTRL
) {
1611 proto_tree_add_item(fastop_tree
, hf_selfm_fastop_br_code
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1613 /* Append Column Info w/ Control Code Code */
1614 col_append_sep_str(pinfo
->cinfo
, COL_INFO
, NULL
, val_to_str_ext_const(opcode
, &selfm_fo_br_vals_ext
, "Unknown Control Code"));
1618 /* Operate Code Validation */
1619 proto_tree_add_item(fastop_tree
, hf_selfm_fastop_valid
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1623 proto_tree_add_checksum(fastop_tree
, tvb
, offset
, hf_selfm_checksum
, -1, NULL
, pinfo
, 0, ENC_BIG_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
1630 /******************************************************************************************************/
1631 /* Code to Dissect Alternate Fast Operate (AFO) Command Frames */
1632 /******************************************************************************************************/
1634 dissect_alt_fastop_frame(tvbuff_t
*tvb
, proto_tree
*tree
, packet_info
*pinfo
, int offset
)
1636 /* Set up structures needed to add the protocol subtree and manage it */
1637 proto_tree
*fastop_tree
;
1641 len
= tvb_get_uint8(tvb
, offset
);
1643 fastop_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, len
-2, ett_selfm_fastop
, NULL
, "Alternate Fast Operate Details");
1645 /* Add Reported length to tree */
1646 proto_tree_add_item(fastop_tree
, hf_selfm_alt_fastop_len
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1650 opcode
= tvb_get_ntohs(tvb
, offset
);
1652 /* Append Column Info w/ Control Code Code */
1653 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "%#x", opcode
);
1655 proto_tree_add_item(fastop_tree
, hf_selfm_alt_fastop_code
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1659 /* Operate Code Validation */
1660 proto_tree_add_item(fastop_tree
, hf_selfm_alt_fastop_valid
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
1667 /************************************************************************************************************************/
1668 /* Code to dissect Fast Message Read Response Messages */
1669 /************************************************************************************************************************/
1670 /* Each Read Response frame can have a maximum data size of 117 x 16-bit words (or 234 bytes) - this is due to the 20 */
1671 /* bytes of overhead and 254 max frame size. In the event of a larger data payload than 234 bytes, the FIR and FIN */
1672 /* bits will be used to indicate either the first frame, last frame, or a neither/middle frame. */
1673 /* We can use the FIN bit to attempt a reassembly of the data payload since all messages will arrive sequentially. */
1674 /************************************************************************************************************************/
1677 dissect_fastmsg_readresp_frame(tvbuff_t
*tvb
, proto_tree
*fastmsg_tree
, packet_info
*pinfo
, int offset
, uint8_t seq_byte
)
1679 proto_item
*fastmsg_tag_value_item
=NULL
, *fmdata_dig_item
=NULL
;
1680 proto_item
*pi_baseaddr
=NULL
, *pi_fnum
=NULL
, *pi_type
=NULL
, *pi_qty
=NULL
;
1681 proto_tree
*fastmsg_tag_tree
=NULL
, *fmdata_dig_tree
=NULL
;
1683 uint16_t data_size
, num_addr
, cnt
;
1685 bool seq_fir
, seq_fin
, save_fragmented
;
1686 int payload_offset
=0;
1687 fm_conversation
*conv
;
1688 fastmsg_dataitem
*dataitem
;
1689 tvbuff_t
*data_tvb
, *payload_tvb
;
1691 /* Decode sequence byte components */
1692 seq_cnt
= seq_byte
& FAST_MSG_SEQ_CNT
;
1693 seq_fir
= ((seq_byte
& FAST_MSG_SEQ_FIR
) >> 7);
1694 seq_fin
= ((seq_byte
& FAST_MSG_SEQ_FIN
) >> 6);
1696 base_addr
= tvb_get_ntohl(tvb
, offset
); /* 32-bit field with base address to read */
1697 num_addr
= tvb_get_ntohs(tvb
, offset
+4); /* 16-bit field with number of 16-bit addresses to read */
1699 /* Append Column Info w/ Base Address */
1700 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "%#x [%s]", base_addr
, region_lookup(pinfo
, base_addr
));
1702 pi_baseaddr
= proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_baseaddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
1703 proto_item_append_text(pi_baseaddr
, " [%s]", region_lookup(pinfo
, base_addr
));
1705 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_numwords
, tvb
, offset
+4, 2, ENC_BIG_ENDIAN
);
1708 /* Setup a new tvb representing just the data payload of this particular message */
1709 data_tvb
= tvb_new_subset_length(tvb
, offset
, (tvb_reported_length_remaining(tvb
, offset
)-2));
1711 save_fragmented
= pinfo
->fragmented
;
1713 /* Check for fragmented packet by looking at the FIR and FIN bits */
1714 if (! (seq_fir
&& seq_fin
)) {
1715 fragment_head
*frag_msg
;
1717 /* This is a fragmented packet, mark it as such */
1718 pinfo
->fragmented
= true;
1720 frag_msg
= fragment_add_seq_next(&selfm_reassembly_table
,
1721 data_tvb
, 0, pinfo
, 0, NULL
,
1722 tvb_reported_length(data_tvb
),
1725 payload_tvb
= process_reassembled_data(data_tvb
, 0, pinfo
,
1726 "Reassembled Data Response Payload", frag_msg
, &selfm_frag_items
,
1727 NULL
, fastmsg_tree
);
1729 if (payload_tvb
) { /* Reassembled */
1730 /* We have the complete payload */
1731 col_append_sep_str(pinfo
->cinfo
, COL_INFO
, NULL
, "Reassembled Data Response");
1735 /* We don't have the complete reassembled payload. */
1736 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "Response Data Fragment %u" , seq_cnt
);
1741 /* No re-assembly required, setup the payload_tvb based on the single-frame data payload tvb */
1743 payload_tvb
= data_tvb
;
1744 add_new_data_source(pinfo
, payload_tvb
, "Data Response Payload");
1747 pinfo
->fragmented
= save_fragmented
;
1749 /* If we had no need to re-assemble or this is the final packet of a reassembly, let's attempt to dissect the */
1750 /* data payload using any previously-captured data format information */
1753 /* Search for previously-encountered data format reference information to dissect the frame */
1754 conv
= (fm_conversation
*)p_get_proto_data(wmem_file_scope(), pinfo
, proto_selfm
, 0);
1757 /* Start at front of list and cycle through possible instances of multiple fastmsg_dataitem frames, looking for match */
1758 wmem_list_frame_t
*frame
= wmem_list_head(conv
->fastmsg_dataitems
);
1760 while (frame
&& (tvb_reported_length_remaining(payload_tvb
, payload_offset
) > 0)) {
1761 dataitem
= (fastmsg_dataitem
*)wmem_list_frame_data(frame
);
1763 /* If the stored base address of the current data item matches the current base address of this response frame */
1764 /* mark that the config data was found and attempt further dissection */
1765 if (dataitem
->base_address
== base_addr
) {
1767 /* Data Item size (in bytes) determined by data type and quantity within item */
1768 switch (dataitem
->data_type
) {
1769 case FAST_MSG_TAGTYPE_CHAR8
:
1770 case FAST_MSG_TAGTYPE_DIGWORD8_BL
:
1771 case FAST_MSG_TAGTYPE_DIGWORD8
:
1772 data_size
= 1 * dataitem
->quantity
; /* 1 byte per qty */
1774 case FAST_MSG_TAGTYPE_CHAR16
:
1775 case FAST_MSG_TAGTYPE_DIGWORD16_BL
:
1776 case FAST_MSG_TAGTYPE_DIGWORD16
:
1777 case FAST_MSG_TAGTYPE_INT16
:
1778 case FAST_MSG_TAGTYPE_UINT16
:
1779 data_size
= 2 * dataitem
->quantity
; /* 2 bytes per qty */
1781 case FAST_MSG_TAGTYPE_INT32
:
1782 case FAST_MSG_TAGTYPE_UINT32
:
1783 case FAST_MSG_TAGTYPE_FLOAT
:
1784 data_size
= 4 * dataitem
->quantity
; /* 4 bytes per qty */
1792 fastmsg_tag_tree
= proto_tree_add_subtree_format(fastmsg_tree
, payload_tvb
, payload_offset
, data_size
,
1793 ett_selfm_fastmsg_tag
, NULL
, "Data Item Name: %s", dataitem
->name
);
1795 /* Load some information from the stored Data Format Response message into the tree for reference */
1796 pi_fnum
= proto_tree_add_uint_format(fastmsg_tag_tree
, hf_selfm_fmdata_frame_data_format_reference
, payload_tvb
, payload_offset
, data_size
,
1797 dataitem
->fnum
, "Using frame number %d (Index Pos: %d) as Data Format Reference",dataitem
->fnum
, dataitem
->index_pos
);
1798 pi_type
= proto_tree_add_uint(fastmsg_tag_tree
, hf_selfm_fmdata_data_type
, payload_tvb
, payload_offset
, 0, dataitem
->data_type
);
1799 pi_qty
= proto_tree_add_uint(fastmsg_tag_tree
, hf_selfm_fmdata_quantity
, payload_tvb
, payload_offset
, 0, dataitem
->quantity
);
1801 proto_item_set_generated(pi_fnum
);
1802 proto_item_set_generated(pi_type
);
1803 proto_item_set_len(pi_type
, data_size
);
1804 proto_item_set_generated(pi_qty
);
1805 proto_item_set_len(pi_qty
, data_size
);
1807 /* Data Item Type determines how to decode */
1808 switch (dataitem
->data_type
) {
1810 case FAST_MSG_TAGTYPE_DIGWORD8_BL
:
1811 case FAST_MSG_TAGTYPE_DIGWORD8
:
1813 for (cnt
=1; cnt
<= dataitem
->quantity
; cnt
++) {
1815 fmdata_dig_tree
= proto_tree_add_subtree_format(fastmsg_tag_tree
, payload_tvb
, payload_offset
, 1,
1816 ett_selfm_fmdata_dig
, &fmdata_dig_item
, "8-bit Binary Items (Row: %2d)", cnt
);
1818 /* Display the bit pattern on the digital channel proto_item */
1819 proto_item_append_text(fmdata_dig_item
, " [ %d %d %d %d %d %d %d %d ]",
1820 ((tvb_get_uint8(payload_tvb
, payload_offset
) & 0x80) >> 7), ((tvb_get_uint8(payload_tvb
, payload_offset
) & 0x40) >> 6),
1821 ((tvb_get_uint8(payload_tvb
, payload_offset
) & 0x20) >> 5), ((tvb_get_uint8(payload_tvb
, payload_offset
) & 0x10) >> 4),
1822 ((tvb_get_uint8(payload_tvb
, payload_offset
) & 0x08) >> 3), ((tvb_get_uint8(payload_tvb
, payload_offset
) & 0x04) >> 2),
1823 ((tvb_get_uint8(payload_tvb
, payload_offset
) & 0x02) >> 1), (tvb_get_uint8(payload_tvb
, payload_offset
) & 0x01));
1825 proto_tree_add_item(fmdata_dig_tree
, hf_selfm_fmdata_dig_b0
, payload_tvb
, payload_offset
, 1, ENC_BIG_ENDIAN
);
1826 proto_tree_add_item(fmdata_dig_tree
, hf_selfm_fmdata_dig_b1
, payload_tvb
, payload_offset
, 1, ENC_BIG_ENDIAN
);
1827 proto_tree_add_item(fmdata_dig_tree
, hf_selfm_fmdata_dig_b2
, payload_tvb
, payload_offset
, 1, ENC_BIG_ENDIAN
);
1828 proto_tree_add_item(fmdata_dig_tree
, hf_selfm_fmdata_dig_b3
, payload_tvb
, payload_offset
, 1, ENC_BIG_ENDIAN
);
1829 proto_tree_add_item(fmdata_dig_tree
, hf_selfm_fmdata_dig_b4
, payload_tvb
, payload_offset
, 1, ENC_BIG_ENDIAN
);
1830 proto_tree_add_item(fmdata_dig_tree
, hf_selfm_fmdata_dig_b5
, payload_tvb
, payload_offset
, 1, ENC_BIG_ENDIAN
);
1831 proto_tree_add_item(fmdata_dig_tree
, hf_selfm_fmdata_dig_b6
, payload_tvb
, payload_offset
, 1, ENC_BIG_ENDIAN
);
1832 proto_tree_add_item(fmdata_dig_tree
, hf_selfm_fmdata_dig_b7
, payload_tvb
, payload_offset
, 1, ENC_BIG_ENDIAN
);
1834 payload_offset
+= 1;
1840 case FAST_MSG_TAGTYPE_CHAR8
:
1841 case FAST_MSG_TAGTYPE_CHAR16
:
1842 proto_tree_add_item(fastmsg_tag_tree
, hf_selfm_fmdata_ai_value_string
, payload_tvb
, payload_offset
, data_size
, ENC_ASCII
);
1843 payload_offset
+= data_size
;
1846 case FAST_MSG_TAGTYPE_INT16
:
1847 for (cnt
=1; cnt
<= dataitem
->quantity
; cnt
++) {
1848 fastmsg_tag_value_item
= proto_tree_add_item(fastmsg_tag_tree
, hf_selfm_fastmsg_dataitem_int16
, payload_tvb
, payload_offset
, data_size
/dataitem
->quantity
, ENC_BIG_ENDIAN
);
1849 proto_item_prepend_text(fastmsg_tag_value_item
, "Value %d ", cnt
);
1850 payload_offset
+= data_size
/dataitem
->quantity
;
1854 case FAST_MSG_TAGTYPE_UINT16
:
1855 for (cnt
=1; cnt
<= dataitem
->quantity
; cnt
++) {
1856 fastmsg_tag_value_item
= proto_tree_add_item(fastmsg_tag_tree
, hf_selfm_fastmsg_dataitem_uint16
, payload_tvb
, payload_offset
, data_size
/dataitem
->quantity
, ENC_BIG_ENDIAN
);
1857 proto_item_prepend_text(fastmsg_tag_value_item
, "Value %d ", cnt
);
1858 payload_offset
+= data_size
/dataitem
->quantity
;
1862 case FAST_MSG_TAGTYPE_INT32
:
1863 for (cnt
=1; cnt
<= dataitem
->quantity
; cnt
++) {
1864 fastmsg_tag_value_item
= proto_tree_add_item(fastmsg_tag_tree
, hf_selfm_fastmsg_dataitem_int32
, payload_tvb
, payload_offset
, data_size
/dataitem
->quantity
, ENC_BIG_ENDIAN
);
1865 proto_item_prepend_text(fastmsg_tag_value_item
, "Value %d ", cnt
);
1866 payload_offset
+= data_size
/dataitem
->quantity
;
1870 case FAST_MSG_TAGTYPE_UINT32
:
1871 for (cnt
=1; cnt
<= dataitem
->quantity
; cnt
++) {
1872 fastmsg_tag_value_item
= proto_tree_add_item(fastmsg_tag_tree
, hf_selfm_fastmsg_dataitem_uint32
, payload_tvb
, payload_offset
, data_size
/dataitem
->quantity
, ENC_BIG_ENDIAN
);
1873 proto_item_prepend_text(fastmsg_tag_value_item
, "Value %d ", cnt
);
1874 payload_offset
+= data_size
/dataitem
->quantity
;
1878 case FAST_MSG_TAGTYPE_FLOAT
:
1879 for (cnt
=1; cnt
<= dataitem
->quantity
; cnt
++) {
1880 fastmsg_tag_value_item
= proto_tree_add_item(fastmsg_tag_tree
, hf_selfm_fastmsg_dataitem_float
, payload_tvb
, payload_offset
, data_size
/dataitem
->quantity
, ENC_BIG_ENDIAN
);
1881 proto_item_prepend_text(fastmsg_tag_value_item
, "Value %d ", cnt
);
1882 payload_offset
+= data_size
/dataitem
->quantity
;
1888 } /* data item type switch */
1890 } /* base address is correct */
1892 /* After processing this frame/data item, proceed to the next */
1893 frame
= wmem_list_frame_next(frame
);
1895 } /* while (frame) */
1897 } /* if (conv) found */
1899 } /* if payload_tvb */
1901 /* Update the offset field before we leave this frame */
1902 offset
+= num_addr
*2;
1909 /******************************************************************************************************/
1910 /* Code to dissect Fast Message Frames */
1911 /******************************************************************************************************/
1913 dissect_fastmsg_frame(tvbuff_t
*tvb
, proto_tree
*tree
, packet_info
*pinfo
, int offset
)
1915 /* Set up structures needed to add the protocol subtree and manage it */
1916 proto_item
*fastmsg_def_fc_item
, *fastmsg_elementlist_item
;
1917 proto_item
*pi_baseaddr
, *fastmsg_crc16_item
;
1918 proto_tree
*fastmsg_tree
, *fastmsg_def_fc_tree
=NULL
, *fastmsg_elementlist_tree
=NULL
;
1919 proto_tree
*fastmsg_element_tree
=NULL
, *fastmsg_datareg_tree
=NULL
, *fastmsg_tag_tree
=NULL
, *fastmsg_soeblk_tree
=NULL
;
1920 int cnt
, cnt1
, num_elements
, elmt_status32_ofs
=0, elmt_status
, null_offset
;
1921 uint8_t len
, funccode
, seq
=0, rx_num_fc
, tx_num_fc
;
1922 uint8_t seq_cnt
=0, elmt_idx
, fc_enable
, soe_num_reg
;
1923 uint8_t *tag_name_ptr
;
1924 uint16_t base_addr
, num_addr
, num_reg
, addr1
, addr2
, crc16
, crc16_calc
, soe_num_blks
;
1925 uint32_t tod_ms
, elmt_status32
, elmt_ts_offset
;
1926 static int * const seq_fields
[] = {
1927 &hf_selfm_fastmsg_seq_fir
,
1928 &hf_selfm_fastmsg_seq_fin
,
1929 &hf_selfm_fastmsg_seq_cnt
,
1933 len
= tvb_get_uint8(tvb
, offset
);
1935 fastmsg_tree
= proto_tree_add_subtree(tree
, tvb
, offset
, len
-2, ett_selfm_fastmsg
, NULL
, "Fast Message Details");
1937 /* Reported length */
1938 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_len
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1940 /* 5-byte Future Routing Address */
1941 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_routing_addr
, tvb
, offset
+1, 5, ENC_NA
);
1944 /* Add Status Byte to tree */
1945 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_status
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1948 /* Get Function Code, add to tree */
1949 funccode
= tvb_get_uint8(tvb
, offset
);
1950 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_funccode
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1952 /* Append Column Info w/ Function Code */
1953 col_append_sep_str(pinfo
->cinfo
, COL_INFO
, NULL
, val_to_str_ext_const(funccode
, &selfm_fastmsg_func_code_vals_ext
, "Unknown Function Code"));
1957 /* If this is an ACK message, process this byte as a Response Code. */
1958 if ((funccode
== FAST_MSG_EN_UNS_DATA_ACK
) ||
1959 (funccode
== FAST_MSG_DIS_UNS_DATA_ACK
) ||
1960 (funccode
== FAST_MSG_UNS_RESP_ACK
)) {
1961 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_response_code
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1965 /* Otherwise, it is the sequence byte, add to Tree */
1966 seq
= tvb_get_uint8(tvb
, offset
);
1967 seq_cnt
= seq
& FAST_MSG_SEQ_CNT
;
1968 proto_tree_add_bitmask_with_flags(fastmsg_tree
, tvb
, offset
, hf_selfm_fastmsg_seq
, ett_selfm_fastmsg_seq
,
1969 seq_fields
, ENC_NA
, BMT_NO_APPEND
);
1974 /* Add Response Number to tree */
1975 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_resp_num
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1978 /* Depending on Function Code used, remaining section of packet will be handled differently. */
1981 case FAST_MSG_EN_UNS_DATA
: /* 0x01 - Enabled Unsolicited Data Transfers */
1983 /* Function code to enable */
1984 fc_enable
= tvb_get_uint8(tvb
, offset
);
1985 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_uns_en_fc
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
1987 /* Append Column Info w/ "Enable" Function Code */
1988 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "Function to Enable (%#x)", fc_enable
);
1990 /* 3-byte Function Code data */
1991 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_uns_en_fc_data
, tvb
, offset
+1, 3, ENC_NA
);
1997 case FAST_MSG_DIS_UNS_DATA
: /* 0x02 - Disable Unsolicited Data Transfers */
1999 /* Function code to disable */
2000 fc_enable
= tvb_get_uint8(tvb
, offset
);
2001 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_uns_dis_fc
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2003 /* Append Column Info w/ "Disable" Function Code */
2004 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "Function to Disable (%#x)", fc_enable
);
2006 /* 1-byte Function Code data */
2007 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_uns_dis_fc_data
, tvb
, offset
+1, 1, ENC_NA
);
2014 case FAST_MSG_READ_REQ
: /* 0x10 - Read Request */
2016 base_addr
= tvb_get_ntohl(tvb
, offset
); /* 32-bit field with base address to read */
2018 /* Append Column Info w/ Base Address */
2019 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "%#x [%s]", base_addr
, region_lookup(pinfo
, base_addr
));
2021 pi_baseaddr
= proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_baseaddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
2022 proto_item_append_text(pi_baseaddr
, " [%s]", region_lookup(pinfo
, base_addr
));
2024 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_numwords
, tvb
, offset
+4, 2, ENC_BIG_ENDIAN
);
2028 case FAST_MSG_GEN_UNS_DATA
: /* 0x12 - Generic Unsolicited Data */
2030 num_addr
= len
- 14; /* 12 header bytes + 2-byte CRC, whatever is left is the data portion of this message */
2031 num_reg
= num_addr
/ 2;
2033 /* For the number of registers, step through and retrieve/print each 16-bit component */
2034 for (cnt
=0; cnt
< num_reg
; cnt
++) {
2035 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unswrite_reg_val
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2041 case FAST_MSG_SOE_STATE_REQ
: /* 0x16 - SOE Present State Request */
2043 /* 4 bytes - "Origination Path" */
2044 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_soe_req_orig
, tvb
, offset
, 4, ENC_NA
);
2049 case FAST_MSG_UNS_RESP
: /* 0x18 - Unsolicited Fast SER Data Response */
2051 /* 4 bytes - "Origination Path" */
2052 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unsresp_orig
, tvb
, offset
, 4, ENC_NA
);
2055 /* Timestamp: 2-byte day-of-year, 2-byte year, 4-byte time-of-day in milliseconds */
2056 /* XXX - We can use a built-in function to convert the tod_ms to a readable time format, is there anything for day_of_year? */
2057 tod_ms
= tvb_get_ntohl(tvb
, offset
+4);
2059 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unsresp_doy
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2060 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unsresp_year
, tvb
, offset
+2, 2, ENC_BIG_ENDIAN
);
2061 proto_tree_add_uint_format_value(fastmsg_tree
, hf_selfm_fastmsg_unsresp_todms
, tvb
, offset
+4, 4,
2062 tod_ms
, "%s", signed_time_msecs_to_str(pinfo
->pool
, tod_ms
));
2065 /* Build element tree */
2066 /* Determine the number of elements returned in this unsolicited message */
2067 /* The general formula is: (Length - 34) / 4 */
2068 num_elements
= (len
-34) / 4;
2070 fastmsg_elementlist_item
= proto_tree_add_uint(fastmsg_tree
, hf_selfm_fastmsg_unsresp_num_elmt
, tvb
, offset
, (4*num_elements
), num_elements
);
2071 fastmsg_elementlist_tree
= proto_item_add_subtree(fastmsg_elementlist_item
, ett_selfm_fastmsg_element_list
);
2073 /* "Reported New Status" word for up to 32 index elements is following the upcoming 0xFFFFFFFE End-of-record indicator
2074 Search for that indicator and use the detected tvb offset+4 to retrieve the proper 32-bit status word.
2075 Save this word for use in the element index printing but don't print the word itself until the end of the tree dissection */
2076 for (cnt
= offset
; cnt
< len
; cnt
++) {
2078 if (tvb_memeql(tvb
, cnt
, (const uint8_t*)"\xFF\xFF\xFF\xFE", 4) == 0) {
2079 elmt_status32_ofs
= cnt
+4;
2082 elmt_status32
= tvb_get_ntohl(tvb
, elmt_status32_ofs
);
2084 /* Cycle through each element we have detected that exists in the SER record */
2085 for (cnt
=0; cnt
<num_elements
; cnt
++) {
2087 /* Get Element Index and Timestamp Offset (in uSec) */
2088 elmt_idx
= tvb_get_uint8(tvb
, offset
);
2089 elmt_ts_offset
= (uint32_t)((tvb_get_uint8(tvb
, offset
+1) << 16) | (tvb_get_uint8(tvb
, offset
+2) << 8) | (tvb_get_uint8(tvb
, offset
+3)));
2091 /* Bit shift the appropriate element from the 32-bit elmt_status word to position 0 and get the bit state for use in the tree */
2092 elmt_status
= ((elmt_status32
>> cnt
) & 0x01);
2094 /* Build the tree */
2095 fastmsg_element_tree
= proto_tree_add_subtree_format(fastmsg_elementlist_tree
, tvb
, offset
, 4, ett_selfm_fastmsg_element
, NULL
,
2096 "Reported Event %d (Index: %d [%s], New State: %s)", cnt
+1, elmt_idx
, fastser_uns_wordbit_lookup(pinfo
, elmt_idx
),
2097 val_to_str_const(elmt_status
, selfm_ser_status_vals
, "Unknown"));
2099 /* Add Index Number and Timestamp offset to tree */
2100 proto_tree_add_item(fastmsg_element_tree
, hf_selfm_fastmsg_unsresp_elmt_idx
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2101 proto_tree_add_item(fastmsg_element_tree
, hf_selfm_fastmsg_unsresp_elmt_ts_ofs
, tvb
, offset
+1, 3, ENC_BIG_ENDIAN
);
2102 proto_tree_add_uint_format_value(fastmsg_element_tree
, hf_selfm_fastmsg_unsresp_elmt_ts_ofs_decoded
, tvb
, offset
+1, 3,
2103 tod_ms
+ (elmt_ts_offset
/1000), "%s", signed_time_msecs_to_str(pinfo
->pool
, tod_ms
+ (elmt_ts_offset
/1000)));
2104 proto_tree_add_uint(fastmsg_element_tree
, hf_selfm_fastmsg_unsresp_elmt_status
, tvb
, elmt_status32_ofs
, 4, elmt_status
);
2110 /* 4-byte End-of-Record Terminator 0xFFFFFFFE */
2111 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unsresp_eor
, tvb
, offset
, 4, ENC_NA
);
2114 /* 4-byte Element Status word */
2115 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unsresp_elmt_statword
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
2121 case FAST_MSG_UNS_WRITE
: /* 0x20 - Unsolicited Write */
2123 /* Write Address Region #1 and #2, along with number of 16-bit registers */
2124 addr1
= tvb_get_ntohs(tvb
, offset
);
2125 addr2
= tvb_get_ntohs(tvb
, offset
+2);
2126 num_reg
= tvb_get_ntohs(tvb
, offset
+4);
2128 /* Append Column Info w/ Address Information */
2129 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "%#x, %#x", addr1
, addr2
);
2131 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unswrite_addr1
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2132 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unswrite_addr2
, tvb
, offset
+2, 2, ENC_BIG_ENDIAN
);
2133 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unswrite_num_reg
, tvb
, offset
+4, 2, ENC_BIG_ENDIAN
);
2137 /* For the number of registers, step through and retrieve/print each 16-bit component */
2138 for (cnt
=0; cnt
< num_reg
; cnt
++) {
2139 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_unswrite_reg_val
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2145 case FAST_MSG_DATAFMT_REQ
: /* 0x31 - Data Format Request */
2147 base_addr
= tvb_get_ntohl(tvb
, offset
); /* 32-bit field with base address to read */
2149 /* Append Column Info w/ Base Address */
2150 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "%#x [%s]", base_addr
, region_lookup(pinfo
, base_addr
));
2152 /* Add Base Address to Tree */
2153 pi_baseaddr
= proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_baseaddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
2154 proto_item_append_text(pi_baseaddr
, " [%s]", region_lookup(pinfo
, base_addr
));
2160 case FAST_MSG_BITLABEL_REQ
: /* 0x33 - Bit Label Request */
2162 base_addr
= tvb_get_ntohl(tvb
, offset
); /* 32-bit field with base address to read */
2163 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_baseaddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
2166 /* Append Column Info w/ Base Address */
2167 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "%#x", base_addr
);
2172 case FAST_MSG_CFG_BLOCK_RESP
: /* 0x80 (resp to 0x00) - Fast Message Configuration Block Response */
2174 /* Routing Support */
2175 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_def_route_sup
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2178 /* RX / TX Status */
2179 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_def_rx_stat
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2180 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_def_tx_stat
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
2183 /* Max Frames RX/TX */
2184 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_def_rx_maxfr
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2185 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_def_tx_maxfr
, tvb
, offset
+1, 1, ENC_BIG_ENDIAN
);
2188 /* 6 bytes of reserved space */
2191 /* Number of Supported RX Function Codes */
2192 rx_num_fc
= tvb_get_uint8(tvb
, offset
);
2193 fastmsg_def_fc_item
= proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_def_rx_num_fc
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2194 fastmsg_def_fc_tree
= proto_item_add_subtree(fastmsg_def_fc_item
, ett_selfm_fastmsg_def_fc
);
2197 /* Add Supported RX Function Codes to tree */
2198 for (cnt
=0; cnt
<rx_num_fc
; cnt
++) {
2199 proto_tree_add_item(fastmsg_def_fc_tree
, hf_selfm_fastmsg_def_rx_fc
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2203 /* Number of Supported TX Function Codes */
2204 tx_num_fc
= tvb_get_uint8(tvb
, offset
);
2205 fastmsg_def_fc_item
= proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_def_tx_num_fc
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2206 fastmsg_def_fc_tree
= proto_item_add_subtree(fastmsg_def_fc_item
, ett_selfm_fastmsg_def_fc
);
2209 /* Add Supported TX Function Codes to tree */
2210 for (cnt
=0; cnt
<tx_num_fc
; cnt
++) {
2211 proto_tree_add_item(fastmsg_def_fc_tree
, hf_selfm_fastmsg_def_tx_fc
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
2217 case FAST_MSG_READ_RESP
: /* 0x90 (resp to 0x10) - Read Response */
2219 offset
= dissect_fastmsg_readresp_frame( tvb
, fastmsg_tree
, pinfo
, offset
, seq
);
2223 case FAST_MSG_SOE_STATE_RESP
: /* 0x96 - (resp to 0x16) SOE Present State Response */
2225 /* 16-bit field with number of blocks of present state data */
2226 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_soe_resp_numblks
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2227 soe_num_blks
= tvb_get_ntohs(tvb
, offset
);
2230 /* Loop through each one of these block based on the num_blocks */
2231 for (cnt
=0; cnt
<soe_num_blks
; cnt
++) {
2233 /* Blocks of 16 bits are packed into 16-bit registers, with any remainder into a final 16-bit register */
2234 if ((tvb_get_uint8(tvb
, offset
+4) % 16) == 0) {
2235 soe_num_reg
= (tvb_get_uint8(tvb
, offset
+4) / 16);
2238 soe_num_reg
= (tvb_get_uint8(tvb
, offset
+4) / 16) + 1;
2241 fastmsg_soeblk_tree
= proto_tree_add_subtree_format(fastmsg_tree
, tvb
, offset
, 14 + soe_num_reg
*2,
2242 ett_selfm_fastmsg_soeblk
, NULL
, "Data Block #%d", cnt
+1);
2244 proto_tree_add_item(fastmsg_soeblk_tree
, hf_selfm_fastmsg_soe_resp_orig
, tvb
, offset
, 4, ENC_NA
);
2245 proto_tree_add_item(fastmsg_soeblk_tree
, hf_selfm_fastmsg_soe_resp_numbits
, tvb
, offset
+4, 1, ENC_BIG_ENDIAN
);
2246 proto_tree_add_item(fastmsg_soeblk_tree
, hf_selfm_fastmsg_soe_resp_pad
, tvb
, offset
+5, 1, ENC_BIG_ENDIAN
);
2247 proto_tree_add_item(fastmsg_soeblk_tree
, hf_selfm_fastmsg_soe_resp_doy
, tvb
, offset
+6, 2, ENC_BIG_ENDIAN
);
2248 proto_tree_add_item(fastmsg_soeblk_tree
, hf_selfm_fastmsg_soe_resp_year
, tvb
, offset
+8, 2, ENC_BIG_ENDIAN
);
2249 proto_tree_add_item(fastmsg_soeblk_tree
, hf_selfm_fastmsg_soe_resp_tod
, tvb
, offset
+10, 4, ENC_BIG_ENDIAN
);
2252 for (cnt1
=0; cnt1
<soe_num_reg
; cnt1
++) {
2253 proto_tree_add_item(fastmsg_soeblk_tree
, hf_selfm_fastmsg_soe_resp_data
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2260 case FAST_MSG_DEVDESC_RESP
: /* 0xB0 (resp to 0x30) - Device Description Response */
2262 /* Add FID / RID ASCII data to tree */
2263 proto_tree_add_item(fastmsg_tree
, hf_selfm_fid
, tvb
, offset
, 50, ENC_ASCII
);
2264 proto_tree_add_item(fastmsg_tree
, hf_selfm_rid
, tvb
, offset
+50, 40, ENC_ASCII
);
2267 /* 16-bit field with number of data areas */
2268 num_reg
= tvb_get_ntohs(tvb
, offset
);
2269 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_devdesc_num_region
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2272 /* Maximum size of 7 regions per message, check the seq_cnt to determine if we have stepped into
2273 the next sequential message where the remaining regions would be described */
2274 if ((num_reg
>= 8) && (seq_cnt
== 0)) {
2278 num_reg
= num_reg
- (seq_cnt
* 7);
2281 /* 16-bit field with number of control areas */
2282 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_devdesc_num_ctrl
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2285 /* Each 18-byte data area description has a 10 byte region name, followed by 32-bit base, */
2286 /* 16-bit message word count and 16-bit flag field */
2287 for (cnt
=0; cnt
<num_reg
; cnt
++) {
2289 fastmsg_datareg_tree
= proto_tree_add_subtree_format(fastmsg_tree
, tvb
, offset
, 18,
2290 ett_selfm_fastmsg_datareg
, NULL
, "Fast Message Data Region #%d", cnt
+1);
2292 /* 10-Byte Region description */
2293 proto_tree_add_item(fastmsg_datareg_tree
, hf_selfm_fastmsg_data_region_name
, tvb
, offset
, 10, ENC_ASCII
);
2296 /* 32-bit field with base address of data region */
2297 proto_tree_add_item(fastmsg_datareg_tree
, hf_selfm_fastmsg_baseaddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
2300 /* 16-bit field with number of 16-bit words in region */
2301 proto_tree_add_item(fastmsg_datareg_tree
, hf_selfm_fastmsg_numwords
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2304 /* 16-bit flag field */
2305 proto_tree_add_item(fastmsg_datareg_tree
, hf_selfm_fastmsg_flags
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2310 /* Some relays (4xx) don't follow the standard here and include an 8-byte sequence of all 0x00's to represent */
2311 /* 'reserved' space for the control regions. Detect these and skip if they are present */
2312 if (tvb_reported_length_remaining(tvb
, offset
) > 2) {
2314 if (tvb_memeql(tvb
, offset
, (const uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00", 8) == 0) {
2321 case FAST_MSG_DATAFMT_RESP
: /* 0xB1 (resp to 0x31) - Data Format Response */
2323 base_addr
= tvb_get_ntohl(tvb
, offset
); /* 32-bit field with base address to read */
2325 /* Add Base Address to Tree */
2326 pi_baseaddr
= proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_baseaddr
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
2327 proto_item_append_text(pi_baseaddr
, " [%s]", region_lookup(pinfo
, base_addr
));
2331 /* Append Column Info w/ Base Address */
2332 col_append_sep_fstr(pinfo
->cinfo
, COL_INFO
, NULL
, "%#x [%s]", base_addr
, region_lookup(pinfo
, base_addr
));
2334 /* 16-bit field with number of data items to follow */
2335 proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_datafmt_resp_numitem
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2338 while ((tvb_reported_length_remaining(tvb
, offset
)) > 2) {
2339 /* Data Item record name 10 bytes */
2340 tag_name_ptr
= tvb_get_string_enc(pinfo
->pool
, tvb
, offset
, 10, ENC_ASCII
);
2341 fastmsg_tag_tree
= proto_tree_add_subtree_format(fastmsg_tree
, tvb
, offset
, 14, ett_selfm_fastmsg_tag
, NULL
, "Data Item Record Name: %s", tag_name_ptr
);
2343 /* Data item qty and type */
2344 proto_tree_add_item(fastmsg_tag_tree
, hf_selfm_fastmsg_dataitem_qty
, tvb
, offset
+10, 2, ENC_BIG_ENDIAN
);
2345 proto_tree_add_item(fastmsg_tag_tree
, hf_selfm_fastmsg_dataitem_type
, tvb
, offset
+12, 2, ENC_BIG_ENDIAN
);
2351 case FAST_MSG_BITLABEL_RESP
: /* 0xB3 (resp to 0x33) - Bit Label Response */
2353 /* The data in this response is a variable length string containing the names of 8 digital bits. */
2354 /* Each name is max 8 chars and each is null-separated */
2357 /* find the null separators and add the bit label text strings to the tree */
2358 for (null_offset
= offset
; null_offset
< len
; null_offset
++) {
2359 if ((tvb_memeql(tvb
, null_offset
, (const uint8_t*)"\x00", 1) == 0) && (tvb_reported_length_remaining(tvb
, offset
) > 2)) {
2360 char* str
= tvb_format_text(pinfo
->pool
, tvb
, offset
, (null_offset
-offset
));
2361 proto_tree_add_string_format(fastmsg_tree
, hf_selfm_fastmsg_bit_label_name
, tvb
, offset
, (null_offset
-offset
), str
,
2362 "Bit Label #%d Name: %s", cnt
, str
);
2363 offset
= null_offset
+1; /* skip the null */
2374 /* Add CRC16 to Tree */
2375 fastmsg_crc16_item
= proto_tree_add_item(fastmsg_tree
, hf_selfm_fastmsg_crc16
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2376 crc16
= tvb_get_ntohs(tvb
, offset
);
2379 /* If option is enabled, validate the CRC16 */
2381 crc16_calc
= crc16_plain_tvb_offset_seed(tvb
, 0, len
-2, 0xFFFF);
2382 if (crc16_calc
!= crc16
) {
2383 expert_add_info_format(pinfo
, fastmsg_crc16_item
, &ei_selfm_crc16_incorrect
, "Incorrect CRC - should be 0x%04x", crc16_calc
);
2386 proto_item_append_text(fastmsg_crc16_item
, " [OK]");
2396 /******************************************************************************************************/
2397 /* Code to dissect SEL Fast Message Protocol packets */
2398 /* Will call other sub-dissectors, as needed */
2399 /******************************************************************************************************/
2401 dissect_selfm(tvbuff_t
*selfm_tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
2403 /* Set up structures needed to add the protocol subtree and manage it */
2404 proto_item
*selfm_item
=NULL
;
2405 proto_tree
*selfm_tree
=NULL
;
2406 int offset
=0, cnt
=0, consumed_bytes
=0;
2408 uint16_t msg_type
, len
, num_items
;
2409 uint8_t seq
, seq_cnt
;
2410 char **uns_ser_split_str
;
2412 /* Make entries in Protocol column on summary display */
2413 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "SEL Protocol");
2414 col_clear(pinfo
->cinfo
, COL_INFO
);
2416 len
= tvb_reported_length(selfm_tvb
);
2418 msg_type
= tvb_get_ntohs(selfm_tvb
, offset
);
2420 /* On first pass through the packets we have 4 tasks to complete - they are each noted below */
2421 if (!pinfo
->fd
->visited
) {
2422 conversation_t
*conversation
;
2423 fm_conversation
*fm_conv_data
;
2425 /* Find a conversation, create a new if no one exists */
2426 conversation
= find_or_create_conversation(pinfo
);
2428 fm_conv_data
= (fm_conversation
*)conversation_get_proto_data(conversation
, proto_selfm
);
2430 if (fm_conv_data
== NULL
) {
2431 fm_conv_data
= wmem_new(wmem_file_scope(), fm_conversation
);
2432 fm_conv_data
->fm_config_frames
= wmem_list_new(wmem_file_scope());
2433 fm_conv_data
->fastmsg_dataitems
= wmem_list_new(wmem_file_scope());
2434 fm_conv_data
->fastmsg_dataregions
= wmem_tree_new(wmem_file_scope());
2435 fm_conv_data
->fastser_uns_wordbits
= wmem_tree_new(wmem_file_scope());
2436 conversation_add_proto_data(conversation
, proto_selfm
, (void *)fm_conv_data
);
2438 uns_ser_split_str
= wmem_strsplit(pinfo
->pool
, selfm_ser_list
, ",", -1);
2440 for (cnt
= 0; (uns_ser_split_str
[cnt
] != NULL
); cnt
++) {
2441 fastser_uns_wordbit
*wordbit_ptr
= fastser_uns_wordbit_save(cnt
, uns_ser_split_str
[cnt
]);
2442 wmem_tree_insert32(fm_conv_data
->fastser_uns_wordbits
, cnt
, wordbit_ptr
);
2445 /* Power Up (254) and Settings Changed (255) Indexes */
2446 for (cnt
= 254; (cnt
<= 255); cnt
++) {
2447 fastser_uns_wordbit
*wordbit_ptr
= fastser_uns_wordbit_save(cnt
, "unused");
2448 wmem_tree_insert32(fm_conv_data
->fastser_uns_wordbits
, cnt
, wordbit_ptr
);
2452 p_add_proto_data(wmem_file_scope(), pinfo
, proto_selfm
, 0, fm_conv_data
);
2454 /* 1. Configuration frames (0xA5C1, 0xA5C2, 0xA5C3) need special treatment during the first run */
2455 /* For each Fast Meter Configuration frame (0xA5Cx), a 'fm_config_frame' struct is created to hold the */
2456 /* information necessary to decode subsequent matching Fast Meter Data frames (0xA5Dx). A pointer to */
2457 /* this struct is saved in the conversation and is copied to the per-packet information if a */
2458 /* Fast Meter Data frame is dissected. */
2459 if ((CMD_FM_CONFIG
== msg_type
) || (CMD_DFM_CONFIG
== msg_type
) || (CMD_PDFM_CONFIG
== msg_type
)) {
2460 /* Fill the fm_config_frame */
2461 fm_config_frame
*frame_ptr
= fmconfig_frame_fast(selfm_tvb
);
2462 frame_ptr
->fnum
= pinfo
->num
;
2463 wmem_list_prepend(fm_conv_data
->fm_config_frames
, frame_ptr
);
2466 /* 2. Fill conversation data array with Fast Msg Data Item info from Data Format Response Messages. */
2467 /* These format definitions will later be retrieved to decode Read Response messages. */
2468 if ((CMD_FAST_MSG
== msg_type
) && (tvb_get_uint8(selfm_tvb
, offset
+9) == FAST_MSG_DATAFMT_RESP
)) {
2470 seq
= tvb_get_uint8(selfm_tvb
, offset
+10);
2471 seq_cnt
= seq
& FAST_MSG_SEQ_CNT
;
2473 base_addr
= tvb_get_ntohl(selfm_tvb
, offset
+12); /* 32-bit field with base address to read */
2474 num_items
= tvb_get_ntohs(selfm_tvb
, offset
+16);
2476 /* When dealing with Data Format Response messages, there are a maximum of 16 items per frame */
2477 /* Use the sequence count if we have more 16 items to determine how many to expect in each frame */
2478 if ((num_items
> 16) && (seq_cnt
== 0)) {
2482 num_items
= num_items
- (seq_cnt
* 16);
2485 /* Set offset to start of data items */
2488 /* Enter the single frame multiple times, retrieving a single dataitem per entry */
2489 for (cnt
= 1; (cnt
<= num_items
); cnt
++) {
2490 fastmsg_dataitem
*dataitem_ptr
= fastmsg_dataitem_save(selfm_tvb
, offset
);
2491 dataitem_ptr
->fnum
= pinfo
->num
;
2492 dataitem_ptr
->base_address
= base_addr
;
2493 dataitem_ptr
->index_pos
= cnt
;
2495 /* Store the data item configuration info in the fastmsg_dataitems list */
2496 wmem_list_append(fm_conv_data
->fastmsg_dataitems
, dataitem_ptr
);
2501 /* 3. Attempt re-assembly during first pass with Read Response Messages data payloads that span multiple */
2502 /* packets. The final data payload will be assembled on the packet with the seq_fin bit set. */
2503 if ((CMD_FAST_MSG
== msg_type
) && (tvb_get_uint8(selfm_tvb
, offset
+9) == FAST_MSG_READ_RESP
)) {
2505 seq
= tvb_get_uint8(selfm_tvb
, offset
+10);
2507 /* Set offset to where the dissect_fastmsg_readresp_frame function would normally be called, */
2508 /* right before base address & num_items */
2511 /* Call the same read response function that will be called during GUI dissection */
2512 offset
= dissect_fastmsg_readresp_frame( selfm_tvb
, tree
, pinfo
, offset
, seq
);
2519 /* 4. Fill conversation data array with Fast Message Data Region info from Device Desc Response Messages. This */
2520 /* will retrieve a data region name (associated to an address) that can later be displayed in the tree. */
2521 if ((CMD_FAST_MSG
== msg_type
) && (tvb_get_uint8(selfm_tvb
, offset
+9) == FAST_MSG_DEVDESC_RESP
)) {
2523 seq
= tvb_get_uint8(selfm_tvb
, offset
+10);
2524 seq_cnt
= seq
& FAST_MSG_SEQ_CNT
;
2526 num_items
= tvb_get_ntohs(selfm_tvb
, offset
+102);
2528 /* When dealing with Device Description Response messages, there are a maximum of 7 regions per frame */
2529 /* Use the sequence count if we have more 7 items to determine how many to expect in each frame */
2530 if ((num_items
>= 8) && (seq_cnt
== 0)) {
2534 num_items
= num_items
- (seq_cnt
* 7);
2537 /* Set offset to start of data regions */
2540 /* Enter the single frame multiple times, retrieving a single data region per entry */
2541 for (cnt
= 1; (cnt
<= num_items
); cnt
++) {
2542 uint32_t base_address
= tvb_get_ntohl(selfm_tvb
, offset
+10);
2543 fastmsg_dataregion
*dataregion_ptr
= fastmsg_dataregion_save(selfm_tvb
, offset
);
2545 /* Store the data region info in the fastmsg_dataregions tree */
2546 wmem_tree_insert32(fm_conv_data
->fastmsg_dataregions
, base_address
, dataregion_ptr
);
2552 } /* if (!visited) */
2556 selfm_item
= proto_tree_add_protocol_format(tree
, proto_selfm
, selfm_tvb
, 0, len
, "SEL Protocol");
2557 selfm_tree
= proto_item_add_subtree(selfm_item
, ett_selfm
);
2559 /* Set INFO column with SEL Protocol Message Type */
2560 col_set_str(pinfo
->cinfo
, COL_INFO
, val_to_str_ext_const(msg_type
, &selfm_msgtype_vals_ext
, "Unknown Message Type"));
2562 /* Add Message Type to Protocol Tree */
2563 proto_tree_add_item(selfm_tree
, hf_selfm_msgtype
, selfm_tvb
, offset
, 2, ENC_BIG_ENDIAN
);
2565 consumed_bytes
+= 2;
2567 /* Determine correct message type and call appropriate dissector */
2568 if (tvb_reported_length_remaining(selfm_tvb
, offset
) > 0) {
2571 consumed_bytes
= dissect_relaydef_frame(selfm_tvb
, selfm_tree
, offset
);
2574 case CMD_DFM_CONFIG
:
2575 case CMD_PDFM_CONFIG
:
2576 consumed_bytes
= dissect_fmconfig_frame(selfm_tvb
, selfm_tree
, pinfo
, offset
);
2579 consumed_bytes
= dissect_fmdata_frame(selfm_tvb
, selfm_tree
, pinfo
, offset
, CMD_FM_CONFIG
);
2582 consumed_bytes
= dissect_fmdata_frame(selfm_tvb
, selfm_tree
, pinfo
, offset
, CMD_DFM_CONFIG
);
2585 consumed_bytes
= dissect_fmdata_frame(selfm_tvb
, selfm_tree
, pinfo
, offset
, CMD_PDFM_CONFIG
);
2587 case CMD_FASTOP_CONFIG
:
2588 consumed_bytes
= dissect_foconfig_frame(selfm_tvb
, selfm_tree
, offset
);
2591 consumed_bytes
= dissect_fastmsg_frame(selfm_tvb
, selfm_tree
, pinfo
, offset
);
2593 case CMD_FASTOP_RB_CTRL
:
2594 case CMD_FASTOP_BR_CTRL
:
2595 consumed_bytes
= dissect_fastop_frame(selfm_tvb
, selfm_tree
, pinfo
, offset
);
2597 case CMD_ALT_FASTOP_CONFIG
:
2598 consumed_bytes
= dissect_alt_fastop_config_frame(selfm_tvb
, selfm_tree
, offset
);
2600 case CMD_ALT_FASTOP_OPEN
:
2601 case CMD_ALT_FASTOP_CLOSE
:
2602 case CMD_ALT_FASTOP_SET
:
2603 case CMD_ALT_FASTOP_CLEAR
:
2604 case CMD_ALT_FASTOP_PULSE
:
2605 consumed_bytes
= dissect_alt_fastop_frame(selfm_tvb
, selfm_tree
, pinfo
, offset
);
2610 } /* remaining length > 0 */
2613 return consumed_bytes
;
2616 /******************************************************************************************************/
2617 /* Dissect (and possibly re-assemble) SEL protocol payload data */
2618 /******************************************************************************************************/
2619 /* Since we are dealing with (usually) Telnet-encapsulated data with possible extra IAC bytes present,*/
2620 /* we cannot know the 'true' length of re-assembled TCP messages by just looking at the protocol PDU */
2621 /* header and it's included length byte. This precludes the use of tcp_dissect_pdus() and requires */
2622 /* us to do the reassembly efforts here. */
2623 /* The tvb structure is as follows: */
2624 /* tvb = original data tvb from TCP dissector */
2625 /* selfm_tvb = 'IAC-sanitized' (0xFF) version of tvb */
2626 /* selfm_pdu_tvb = with multiple PDUs in a single selfm_tvb, split them out for separate dissection */
2628 /* tvb -> selfm_tvb -> selfm_pdu_tvb */
2629 /* -> selfm_pdu_tvb */
2630 /******************************************************************************************************/
2632 dissect_selfm_tcp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
2635 tvbuff_t
*selfm_tvb
, *selfm_pdu_tvb
;
2636 int skip_byte
= 0, selfm_tvb_len
, offset
= 0;
2637 uint8_t selfm_PDU_len
=0, new_selfm_PDU_len
=0;
2638 int length
= tvb_reported_length(tvb
);
2640 /* Check for a SEL Protocol packet. It should begin with 0xA5 */
2641 if(length
< 2 || tvb_get_uint8(tvb
, 0) != 0xA5) {
2642 /* Not a SEL Protocol packet, just happened to use the same port */
2646 /* If the length of this packet is only 2 bytes, it's a scan message so just do a simple dissection */
2648 return dissect_selfm(tvb
, pinfo
, tree
, data
);
2651 selfm_PDU_len
= tvb_get_uint8(tvb
,2);
2653 /* If the reported selfm PDU length is greater than the present tvb length, request more data */
2654 if (length
< selfm_PDU_len
) {
2655 pinfo
->desegment_offset
= 0;
2656 pinfo
->desegment_len
= DESEGMENT_ONE_MORE_SEGMENT
;
2657 return tvb_captured_length(tvb
);
2660 /* If this is a Telnet-encapsulated Ethernet packet, let's clean out the IAC 0xFF instances */
2661 /* before we attempt any kind of re-assembly of the message */
2662 if ((pinfo
->srcport
) && selfm_telnet_clean
) {
2663 selfm_tvb
= clean_telnet_iac(pinfo
, tvb
, 0, length
, &skip_byte
);
2666 selfm_tvb
= tvb_new_subset_length( tvb
, 0, length
);
2669 selfm_tvb_len
= tvb_reported_length(selfm_tvb
);
2671 /* If sanitized selfm_tvb length is still less than the reported selfm PDU length, there is more segment data to follow */
2672 if (selfm_tvb_len
< selfm_PDU_len
) {
2673 pinfo
->desegment_offset
= 0;
2674 pinfo
->desegment_len
= DESEGMENT_ONE_MORE_SEGMENT
;
2675 return tvb_captured_length(tvb
);
2678 /* If the available selfm_tvb length is greater than the reported selfm PDU length, */
2679 /* there is possibly a second PDU to follow so let's dig deeper... */
2680 if (selfm_tvb_len
> selfm_PDU_len
) {
2681 /* Check if additional data is actually selfm PDU data */
2682 if (tvb_get_uint8(selfm_tvb
, selfm_PDU_len
) == 0xA5) {
2683 new_selfm_PDU_len
= tvb_get_uint8(selfm_tvb
, selfm_PDU_len
+2);
2684 /* If we still don't have enough data to accommodate the 2 PDUs... */
2685 if (selfm_tvb_len
< (selfm_PDU_len
+ new_selfm_PDU_len
)) {
2687 fprintf(stderr
, "On Packet: %d, continuing to desegment. PDU: %d NewPDU: %d Still need %d bytes.. \n", pinfo
->fd
->num
, selfm_PDU_len
, new_selfm_PDU_len
, (selfm_PDU_len
+ new_selfm_PDU_len
) - selfm_tvb_len
);
2689 /* If the current selfm_tvb length is less than the combined reported selfm length of the 2 PDUs, continue TCP desegmentation */
2690 /* The desegment_len field will be used to report how many additional bytes remain to be reassembled */
2691 pinfo
->desegment_offset
= 0;
2692 pinfo
->desegment_len
= (selfm_PDU_len
+ new_selfm_PDU_len
) - selfm_tvb_len
;
2693 return tvb_captured_length(tvb
);
2698 /* If multiple SEL protocol PDUs exist within a single tvb, dissect each of them sequentially */
2699 while (offset
< selfm_tvb_len
) {
2700 /* If random ASCII data makes its way onto the end of an SEL protocol PDU, ignore it */
2701 if (tvb_get_uint8(selfm_tvb
, offset
) != 0xA5) {
2703 fprintf(stderr
, "On Packet: %d, extraneous data (starts with: %x).. \n", pinfo
->fd
->num
, tvb_get_uint8(selfm_tvb
, offset
));
2707 /* Create new selfm_pdu_tvb that contains only a single PDU worth of data */
2708 selfm_pdu_tvb
= tvb_new_subset_length( selfm_tvb
, offset
, tvb_get_uint8(selfm_tvb
, offset
+2));
2709 offset
+= dissect_selfm(selfm_pdu_tvb
, pinfo
, tree
, data
);
2712 /* Return the completed selfm_tvb dissected length + the count of any IAC skip bytes that were removed from the tvb payload */
2713 return selfm_tvb_len
+ skip_byte
;
2716 /******************************************************************************************************/
2717 /* Register the protocol with Wireshark */
2718 /******************************************************************************************************/
2719 void proto_reg_handoff_selfm(void);
2722 proto_register_selfm(void)
2724 /* SEL Protocol header fields */
2725 static hf_register_info selfm_hf
[] = {
2726 { &hf_selfm_msgtype
,
2727 { "Message Type", "selfm.msgtype", FT_UINT16
, BASE_HEX
|BASE_EXT_STRING
, &selfm_msgtype_vals_ext
, 0x0, NULL
, HFILL
}},
2728 { &hf_selfm_padbyte
,
2729 { "Pad Byte", "selfm.padbyte", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2730 { &hf_selfm_checksum
,
2731 { "Checksum", "selfm.checksum", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2732 /* "Relay Definition" specific fields */
2733 { &hf_selfm_relaydef_len
,
2734 { "Length", "selfm.relaydef.len", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2735 { &hf_selfm_relaydef_numproto
,
2736 { "Number of Protocols", "selfm.relaydef.numproto", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2737 { &hf_selfm_relaydef_numfm
,
2738 { "Number of Fast Meter Messages", "selfm.relaydef.numfm", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2739 { &hf_selfm_relaydef_numflags
,
2740 { "Number of Status Flags", "selfm.relaydef.numflags", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2741 { &hf_selfm_relaydef_fmcfg_cmd
,
2742 { "Fast Meter Config Command", "selfm.relaydef.fmcfg_cmd", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2743 { &hf_selfm_relaydef_fmdata_cmd
,
2744 { "Fast Meter Data Command", "selfm.relaydef.fmdata_cmd", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2745 { &hf_selfm_relaydef_statbit
,
2746 { "Status Flag Bit", "selfm.relaydef.status_bit", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2747 { &hf_selfm_relaydef_statbit_cmd
,
2748 { "Status Flag Bit Response Command", "selfm.relaydef.status_bit_cmd", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2749 { &hf_selfm_relaydef_proto
,
2750 { "Supported Protocol", "selfm.relaydef.proto", FT_UINT16
, BASE_HEX
|BASE_EXT_STRING
, &selfm_relaydef_proto_vals_ext
, 0x0, NULL
, HFILL
}},
2751 /* "Fast Meter Configuration" specific fields */
2752 { &hf_selfm_fmconfig_len
,
2753 { "Length", "selfm.fmconfig.len", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2754 { &hf_selfm_fmconfig_numflags
,
2755 { "Number of Status Flags", "selfm.fmconfig.numflags", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2756 { &hf_selfm_fmconfig_loc_sf
,
2757 { "Location of Scale Factor", "selfm.fmconfig.loc_sf", FT_UINT8
, BASE_DEC
, VALS(selfm_fmconfig_sfloc_vals
), 0x0, NULL
, HFILL
}},
2758 { &hf_selfm_fmconfig_num_sf
,
2759 { "Number of Scale Factors", "selfm.fmconfig.num_sf", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2760 { &hf_selfm_fmconfig_num_ai
,
2761 { "Number of Analog Input Channels", "selfm.fmconfig.num_ai", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2762 { &hf_selfm_fmconfig_num_samp
,
2763 { "Number of Samples per AI Channel", "selfm.fmconfig.num_samp", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2764 { &hf_selfm_fmconfig_num_dig
,
2765 { "Number of Digital Banks", "selfm.fmconfig.num_dig", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2766 { &hf_selfm_fmconfig_num_calc
,
2767 { "Number of Calculation Blocks", "selfm.fmconfig.num_calc", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2768 { &hf_selfm_fmconfig_ofs_ai
,
2769 { "First Analog Channel Offset", "selfm.fmconfig.ofs_ai", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2770 { &hf_selfm_fmconfig_ofs_ts
,
2771 { "Timestamp Offset", "selfm.fmconfig.ofs_ts", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2772 { &hf_selfm_fmconfig_ofs_dig
,
2773 { "First Digital Bank Offset", "selfm.fmconfig.ofs_dig", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2774 { &hf_selfm_fmconfig_ai_type
,
2775 { "Analog Channel Type", "selfm.fmconfig.ai_type", FT_UINT8
, BASE_DEC
, VALS(selfm_fmconfig_ai_chtype_vals
), 0x0, NULL
, HFILL
}},
2776 { &hf_selfm_fmconfig_ai_sf_type
,
2777 { "Analog Channel Scale Factor Type", "selfm.fmconfig.ai_sf_type", FT_UINT8
, BASE_DEC
, VALS(selfm_fmconfig_ai_sftype_vals
), 0x0, NULL
, HFILL
}},
2778 { &hf_selfm_fmconfig_ai_sf_ofs
,
2779 { "Analog Channel Scale Factor Offset", "selfm.fmconfig.ai_sf_ofs", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2780 { &hf_selfm_fmconfig_cblk_rot
,
2781 { "Rotation", "selfm.fmconfig.cblk_rot", FT_UINT8
, BASE_HEX
, VALS(selfm_fmconfig_cblk_rot_vals
), 0x01, NULL
, HFILL
}},
2782 { &hf_selfm_fmconfig_cblk_vconn
,
2783 { "Voltage Connection", "selfm.fmconfig.cblk_vconn", FT_UINT8
, BASE_HEX
, VALS(selfm_fmconfig_cblk_vconn_vals
), 0x06, NULL
, HFILL
}},
2784 { &hf_selfm_fmconfig_cblk_iconn
,
2785 { "Current Connection", "selfm.fmconfig.cblk_iconn", FT_UINT8
, BASE_HEX
, VALS(selfm_fmconfig_cblk_iconn_vals
), 0x18, NULL
, HFILL
}},
2786 { &hf_selfm_fmconfig_cblk_ctype
,
2787 { "Calculation Type", "selfm.fmconfig.cblk_ctype", FT_UINT8
, BASE_DEC
, VALS(selfm_fmconfig_cblk_ctype_vals
), 0x0, NULL
, HFILL
}},
2788 { &hf_selfm_fmconfig_cblk_deskew_ofs
,
2789 { "Skew Correction Offset", "selfm.fmconfig.cblk_deskew_ofs", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2790 { &hf_selfm_fmconfig_cblk_rs_ofs
,
2791 { "Rs Offset", "selfm.fmconfig.cblk_rs_ofs", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2792 { &hf_selfm_fmconfig_cblk_xs_ofs
,
2793 { "Xs Offset", "selfm.fmconfig.cblk_xs_ofs", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2794 { &hf_selfm_fmconfig_cblk_ia_idx
,
2795 { "Analog Record Ia Index Position", "selfm.fmconfig.cblk_ia_idx", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2796 { &hf_selfm_fmconfig_cblk_ib_idx
,
2797 { "Analog Record Ib Index Position", "selfm.fmconfig.cblk_ib_idx", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2798 { &hf_selfm_fmconfig_cblk_ic_idx
,
2799 { "Analog Record Ic Index Position", "selfm.fmconfig.cblk_ic_idx", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2800 { &hf_selfm_fmconfig_cblk_va_idx
,
2801 { "Analog Record Va/Vab Index Position", "selfm.fmconfig.cblk_va_idx", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2802 { &hf_selfm_fmconfig_cblk_vb_idx
,
2803 { "Analog Record Vb/Vbc Index Position", "selfm.fmconfig.cblk_vb_idx", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2804 { &hf_selfm_fmconfig_cblk_vc_idx
,
2805 { "Analog Record Vc/Vca Index Position", "selfm.fmconfig.cblk_vc_idx", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2806 { &hf_selfm_fmconfig_ai_sf_float
,
2807 { "AI Scale Factor (float)", "selfm.fmconfig.ai_sf_float", FT_FLOAT
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2808 /* "Fast Meter Data" specific fields */
2809 { &hf_selfm_fmdata_len
,
2810 { "Length", "selfm.fmdata.len", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2811 { &hf_selfm_fmdata_flagbyte
,
2812 { "Status Flags Byte", "selfm.fmdata.flagbyte", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2813 { &hf_selfm_fmdata_ai_sf_fp
,
2814 { "Using IEEE FP Format Scale Factor", "selfm.fmdata.ai.sf_fp",FT_FLOAT
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2815 { &hf_selfm_fmdata_dig_b0
,
2816 { "Bit 0", "selfm.fmdata.dig_b0", FT_BOOLEAN
, 8, NULL
, 0x01, NULL
, HFILL
}},
2817 { &hf_selfm_fmdata_dig_b1
,
2818 { "Bit 1", "selfm.fmdata.dig_b1", FT_BOOLEAN
, 8, NULL
, 0x02, NULL
, HFILL
}},
2819 { &hf_selfm_fmdata_dig_b2
,
2820 { "Bit 2", "selfm.fmdata.dig_b2", FT_BOOLEAN
, 8, NULL
, 0x04, NULL
, HFILL
}},
2821 { &hf_selfm_fmdata_dig_b3
,
2822 { "Bit 3", "selfm.fmdata.dig_b3", FT_BOOLEAN
, 8, NULL
, 0x08, NULL
, HFILL
}},
2823 { &hf_selfm_fmdata_dig_b4
,
2824 { "Bit 4", "selfm.fmdata.dig_b4", FT_BOOLEAN
, 8, NULL
, 0x10, NULL
, HFILL
}},
2825 { &hf_selfm_fmdata_dig_b5
,
2826 { "Bit 5", "selfm.fmdata.dig_b5", FT_BOOLEAN
, 8, NULL
, 0x20, NULL
, HFILL
}},
2827 { &hf_selfm_fmdata_dig_b6
,
2828 { "Bit 6", "selfm.fmdata.dig_b6", FT_BOOLEAN
, 8, NULL
, 0x40, NULL
, HFILL
}},
2829 { &hf_selfm_fmdata_dig_b7
,
2830 { "Bit 7", "selfm.fmdata.dig_b7", FT_BOOLEAN
, 8, NULL
, 0x80, NULL
, HFILL
}},
2831 /* "Fast Operate Configuration" specific fields */
2832 { &hf_selfm_foconfig_len
,
2833 { "Length", "selfm.foconfig.len", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2834 { &hf_selfm_foconfig_num_brkr
,
2835 { "Number of Breaker Bits", "selfm.foconfig.num_brkr", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2836 { &hf_selfm_foconfig_num_rb
,
2837 { "Number of Remote Bits", "selfm.foconfig.num_rb", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2838 { &hf_selfm_foconfig_prb_supp
,
2839 { "Remote Bit Pulse Supported", "selfm.foconfig.prb_supp", FT_UINT8
, BASE_DEC
, VALS(selfm_foconfig_prb_supp_vals
), 0x0, NULL
, HFILL
}},
2840 { &hf_selfm_foconfig_reserved
,
2841 { "Reserved Bit (Future)", "selfm.foconfig.reserved", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2842 { &hf_selfm_foconfig_brkr_open
,
2843 { "Breaker Bit Open Command", "selfm.foconfig.brkr_open", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fo_br_vals_ext
, 0x0, NULL
, HFILL
}},
2844 { &hf_selfm_foconfig_brkr_close
,
2845 { "Breaker Bit Close Command", "selfm.foconfig.brkr_close", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fo_br_vals_ext
, 0x0, NULL
, HFILL
}},
2846 { &hf_selfm_foconfig_rb_cmd
,
2847 { "Remote Bit Command", "selfm.foconfig.rb_cmd", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fo_rb_vals_ext
, 0x0, NULL
, HFILL
}},
2848 /* "Alternate Fast Operate Configuration" specific fields */
2849 { &hf_selfm_alt_foconfig_len
,
2850 { "Length", "selfm.alt_foconfig.len", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2851 { &hf_selfm_alt_foconfig_num_ports
,
2852 { "Number of Ports Available", "selfm.alt_foconfig.num_ports", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2853 { &hf_selfm_alt_foconfig_num_brkr
,
2854 { "Number of Breaker Bits per Port", "selfm.alt_foconfig.num_brkr", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2855 { &hf_selfm_alt_foconfig_num_rb
,
2856 { "Number of Remote Bits per Port", "selfm.alt_foconfig.num_rb", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2857 { &hf_selfm_alt_foconfig_funccode
,
2858 { "Supported Function Code", "selfm.alt_foconfig.funccode", FT_UINT8
, BASE_HEX
, VALS(selfm_foconfig_alt_funccode_vals
), 0x0, NULL
, HFILL
}},
2859 /* "Fast Operate Command" specific fields */
2860 { &hf_selfm_fastop_len
,
2861 { "Length", "selfm.fastop.len", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2862 { &hf_selfm_fastop_rb_code
,
2863 { "Remote Bit Operate Code", "selfm.fastop.rb_code", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fo_rb_vals_ext
, 0x0, NULL
, HFILL
}},
2864 { &hf_selfm_fastop_br_code
,
2865 { "Breaker Bit Operate Code", "selfm.fastop.br_code", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fo_br_vals_ext
, 0x0, NULL
, HFILL
}},
2866 { &hf_selfm_fastop_valid
,
2867 { "Operate Code Validation", "selfm.fastop.valid", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2868 /* "Alternate Fast Operate Command" specific fields */
2869 { &hf_selfm_alt_fastop_len
,
2870 { "Length", "selfm.alt_fastop.len", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2871 { &hf_selfm_alt_fastop_code
,
2872 { "Operate Code", "selfm.alt_fastop.code", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2873 { &hf_selfm_alt_fastop_valid
,
2874 { "Operate Code Validation", "selfm.alt_fastop.valid", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2875 /* "Fast Message" specific fields */
2876 { &hf_selfm_fastmsg_len
,
2877 { "Length", "selfm.fastmsg.len", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2878 { &hf_selfm_fastmsg_routing_addr
,
2879 { "Routing Address (future)", "selfm.fastmsg.routing_addr", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2880 { &hf_selfm_fastmsg_status
,
2881 { "Status Byte", "selfm.fastmsg.status", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2882 { &hf_selfm_fastmsg_funccode
,
2883 { "Function Code", "selfm.fastmsg.funccode", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fastmsg_func_code_vals_ext
, 0x0, NULL
, HFILL
}},
2884 { &hf_selfm_fastmsg_response_code
,
2885 { "Response Code", "selfm.fastmsg.responsecode", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fastmsg_ack_responsecode_vals_ext
, 0x0, NULL
, HFILL
}},
2886 { &hf_selfm_fastmsg_seq
,
2887 { "Sequence Byte", "selfm.fastmsg.seq", FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2888 { &hf_selfm_fastmsg_seq_fir
,
2889 { "FIR", "selfm.fastmsg.seq_fir", FT_BOOLEAN
, 8, NULL
, FAST_MSG_SEQ_FIR
, NULL
, HFILL
}},
2890 { &hf_selfm_fastmsg_seq_fin
,
2891 { "FIN", "selfm.fastmsg.seq_fin", FT_BOOLEAN
, 8, NULL
, FAST_MSG_SEQ_FIN
, NULL
, HFILL
}},
2892 { &hf_selfm_fastmsg_seq_cnt
,
2893 { "Count", "selfm.fastmsg.seq_cnt", FT_UINT8
, BASE_DEC
, NULL
, FAST_MSG_SEQ_CNT
, "Frame Count Number", HFILL
}},
2894 { &hf_selfm_fastmsg_resp_num
,
2895 { "Response Number", "selfm.fastmsg.resp_num", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2896 { &hf_selfm_fastmsg_crc16
,
2897 { "CRC-16", "selfm.fastmsg.crc16", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2898 { &hf_selfm_fastmsg_def_route_sup
,
2899 { "Routing Support", "selfm.fastmsg.def_route_sup", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2900 { &hf_selfm_fastmsg_def_rx_stat
,
2901 { "Status RX", "selfm.fastmsg.def_rx_stat", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2902 { &hf_selfm_fastmsg_def_tx_stat
,
2903 { "Status TX", "selfm.fastmsg.def_tx_stat", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2904 { &hf_selfm_fastmsg_def_rx_maxfr
,
2905 { "Max Frames RX", "selfm.fastmsg.def_rx_maxfr", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2906 { &hf_selfm_fastmsg_def_tx_maxfr
,
2907 { "Max Frames TX", "selfm.fastmsg.def_tx_maxfr", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2908 { &hf_selfm_fastmsg_def_rx_num_fc
,
2909 { "Number of Supported RX Function Codes", "selfm.fastmsg.def_rx_num_fc", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2910 { &hf_selfm_fastmsg_def_rx_fc
,
2911 { "Receive Function Code", "selfm.fastmsg.def_rx_fc", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fastmsg_func_code_vals_ext
, 0x0, NULL
, HFILL
}},
2912 { &hf_selfm_fastmsg_def_tx_num_fc
,
2913 { "Number of Supported TX Function Codes", "selfm.fastmsg.def_tx_num_fc", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2914 { &hf_selfm_fastmsg_def_tx_fc
,
2915 { "Transmit Function Code", "selfm.fastmsg.def_tx_fc", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fastmsg_func_code_vals_ext
, 0x0, NULL
, HFILL
}},
2916 { &hf_selfm_fastmsg_uns_en_fc
,
2917 { "Function Code to Enable", "selfm.fastmsg.uns_en_fc", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fastmsg_func_code_vals_ext
, 0x0, NULL
, HFILL
}},
2918 { &hf_selfm_fastmsg_uns_en_fc_data
,
2919 { "Function Code Data", "selfm.fastmsg.uns_en_fc_data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2920 { &hf_selfm_fastmsg_uns_dis_fc
,
2921 { "Function Code to Disable", "selfm.fastmsg.uns_dis_fc", FT_UINT8
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fastmsg_func_code_vals_ext
, 0x0, NULL
, HFILL
}},
2922 { &hf_selfm_fastmsg_uns_dis_fc_data
,
2923 { "Function Code Data", "selfm.fastmsg.uns_dis_fc_data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2924 { &hf_selfm_fastmsg_unsresp_orig
,
2925 { "Origination path", "selfm.fastmsg.unsresp_orig", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2926 { &hf_selfm_fastmsg_unsresp_doy
,
2927 { "Day of Year", "selfm.fastmsg.unsresp_doy", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2928 { &hf_selfm_fastmsg_unsresp_year
,
2929 { "Year", "selfm.fastmsg.unsresp_year", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2930 { &hf_selfm_fastmsg_unsresp_todms
,
2931 { "Time of Day (in ms)", "selfm.fastmsg.unsresp_todms", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2932 { &hf_selfm_fastmsg_unsresp_num_elmt
,
2933 { "Number of SER Elements", "selfm.fastmsg.unsresp_num_elmt", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2934 { &hf_selfm_fastmsg_unsresp_elmt_idx
,
2935 { "SER Element Index", "selfm.fastmsg.unsresp_elmt_idx", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2936 { &hf_selfm_fastmsg_unsresp_elmt_ts_ofs
,
2937 { "SER Element Timestamp Offset (us)", "selfm.fastmsg.unsresp_elmt_ts_ofs", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2938 { &hf_selfm_fastmsg_unsresp_elmt_status
,
2939 { "SER Element Status", "selfm.fastmsg.unsresp_elmt_status", FT_UINT8
, BASE_DEC
, VALS(selfm_ser_status_vals
), 0x0, NULL
, HFILL
}},
2940 { &hf_selfm_fastmsg_unsresp_eor
,
2941 { "End of Record Indicator", "selfm.fastmsg.unsresp_eor", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2942 { &hf_selfm_fastmsg_unsresp_elmt_statword
,
2943 { "SER Element Status Word", "selfm.fastmsg.unsresp_elmt_statword", FT_UINT32
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2944 { &hf_selfm_fastmsg_unswrite_addr1
,
2945 { "Write Address Region #1", "selfm.fastmsg.unswrite_addr1", FT_UINT16
, BASE_HEX
| BASE_EXT_STRING
, &selfm_fastmsg_unswrite_com_vals_ext
, 0x0, NULL
, HFILL
}},
2946 { &hf_selfm_fastmsg_unswrite_addr2
,
2947 { "Write Address Region #2", "selfm.fastmsg.unswrite_addr2", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2948 { &hf_selfm_fastmsg_unswrite_num_reg
,
2949 { "Number of Registers", "selfm.fastmsg.unswrite_num_reg", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2950 { &hf_selfm_fastmsg_unswrite_reg_val
,
2951 { "Register Value", "selfm.fastmsg.unswrite_reg_val", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2952 { &hf_selfm_fastmsg_baseaddr
,
2953 { "Base Address", "selfm.fastmsg.baseaddr", FT_UINT32
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2954 { &hf_selfm_fastmsg_numwords
,
2955 { "Number of 16-bit Words", "selfm.fastmsg.numwords", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2956 { &hf_selfm_fastmsg_flags
,
2957 { "Flag Word", "selfm.fastmsg.flags", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2958 { &hf_selfm_fastmsg_datafmt_resp_numitem
,
2959 { "Number of Data Items Records", "selfm.fastmsg.datafmt_resp_numitem", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2960 { &hf_selfm_fastmsg_dataitem_qty
,
2961 { "Data Item Quantity", "selfm.fastmsg.dataitem_qty", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2962 { &hf_selfm_fastmsg_dataitem_type
,
2963 { "Data Item Type", "selfm.fastmsg.dataitem_type", FT_UINT16
, BASE_HEX
, VALS(selfm_fastmsg_tagtype_vals
), 0x0, NULL
, HFILL
}},
2964 { &hf_selfm_fastmsg_dataitem_uint16
,
2965 { "(uint16)", "selfm.fastmsg.dataitem_uint16", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2966 { &hf_selfm_fastmsg_dataitem_int16
,
2967 { "(int16)", "selfm.fastmsg.dataitem_int16", FT_INT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2968 { &hf_selfm_fastmsg_dataitem_uint32
,
2969 { "(uint32)", "selfm.fastmsg.dataitem_uint32", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2970 { &hf_selfm_fastmsg_dataitem_int32
,
2971 { "(int32)", "selfm.fastmsg.dataitem_int32", FT_INT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2972 { &hf_selfm_fastmsg_dataitem_float
,
2973 { "(float)", "selfm.fastmsg.dataitem_float", FT_FLOAT
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2974 { &hf_selfm_fastmsg_devdesc_num_region
,
2975 { "Number of Data Regions", "selfm.fastmsg.devdesc_num_region", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2976 { &hf_selfm_fastmsg_devdesc_num_ctrl
,
2977 { "Number of Control Regions", "selfm.fastmsg.devdesc_num_ctrl", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2978 { &hf_selfm_fastmsg_soe_req_orig
,
2979 { "Origination path", "selfm.fastmsg.soe_req_orig", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2980 { &hf_selfm_fastmsg_soe_resp_numblks
,
2981 { "Number of Blocks", "selfm.fastmsg.soe_resp_numblks", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2982 { &hf_selfm_fastmsg_soe_resp_orig
,
2983 { "Origination path", "selfm.fastmsg.soe_resp_orig", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
2984 { &hf_selfm_fastmsg_soe_resp_numbits
,
2985 { "Number of Bits", "selfm.fastmsg.soe_resp_numbits", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2986 { &hf_selfm_fastmsg_soe_resp_pad
,
2987 { "Pad Byte", "selfm.fastmsg.soe_resp_pad", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2988 { &hf_selfm_fastmsg_soe_resp_doy
,
2989 { "Day of Year", "selfm.fastmsg.soe_resp_doy", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2990 { &hf_selfm_fastmsg_soe_resp_year
,
2991 { "Year", "selfm.fastmsg.soe_resp_year", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2992 { &hf_selfm_fastmsg_soe_resp_tod
,
2993 { "Time of Day (ms)", "selfm.fastmsg.soe_resp_tod", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
2994 { &hf_selfm_fastmsg_soe_resp_data
,
2995 { "Packed Binary State Data", "selfm.fastmsg.soe_resp_data", FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
2997 /* "Fast Message" Re-assembly header fields */
2998 { &hf_selfm_fragment
,
2999 { "SEL Fast Msg Response Data Fragment", "selfm.respdata.fragment", FT_FRAMENUM
, BASE_NONE
, NULL
, 0x0, "SEL Fast Message Response Data Fragment", HFILL
}},
3000 { &hf_selfm_fragments
,
3001 { "SEL Fast Msg Response Data Fragments", "selfm.respdata.fragments", FT_NONE
, BASE_NONE
, NULL
, 0x0, "SEL Fast Message Response Data Fragments", HFILL
}},
3002 { &hf_selfm_fragment_overlap
,
3003 { "Fragment overlap", "selfm.respdata.fragment.overlap", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0, "Fragment overlaps with other fragments", HFILL
}},
3004 { &hf_selfm_fragment_overlap_conflict
,
3005 { "Conflicting data in fragment overlap", "selfm.respdata.fragment.overlap.conflict", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0, "Overlapping fragments contained conflicting data", HFILL
}},
3006 { &hf_selfm_fragment_multiple_tails
,
3007 { "Multiple tail fragments found", "selfm.respdata.fragment.multipletails", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0, "Several tails were found when defragmenting the packet", HFILL
}},
3008 { &hf_selfm_fragment_too_long_fragment
,
3009 { "Fragment too long", "selfm.respdata.fragment.toolongfragment", FT_BOOLEAN
, BASE_NONE
, NULL
, 0x0, "Fragment contained data past end of packet", HFILL
}},
3010 { &hf_selfm_fragment_error
,
3011 { "Defragmentation error", "selfm.respdata.fragment.error", FT_FRAMENUM
, BASE_NONE
, NULL
, 0x0, "Defragmentation error due to illegal fragments", HFILL
}},
3012 { &hf_selfm_fragment_count
,
3013 { "Fragment count", "selfm.respdata.fragment.count", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
3014 { &hf_selfm_fragment_reassembled_in
,
3015 { "Reassembled PDU In Frame", "selfm.respdata.fragment.reassembled_in", FT_FRAMENUM
, BASE_NONE
, NULL
, 0x0, "This PDU is reassembled in this frame", HFILL
}},
3016 { &hf_selfm_fragment_reassembled_length
,
3017 { "Reassembled SEL Fast Msg length", "selfm.respdata.fragment.reassembled.length", FT_UINT32
, BASE_DEC
, NULL
, 0x0, "The total length of the reassembled payload", HFILL
}},
3018 /* Generated from convert_proto_tree_add_text.pl */
3019 { &hf_selfm_fmconfig_ai_channel
, { "Analog Channel Name", "selfm.fmconfig.ai_channel", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3020 { &hf_selfm_fmdata_ai_value16
, { "Value (Raw)", "selfm.fmdata.ai.value16", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
3021 { &hf_selfm_fmdata_ai_scale_factor
, { "Value (w/ Scale Factor)", "selfm.fmdata.ai.value_scale_factor", FT_FLOAT
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3022 { &hf_selfm_fmdata_ai_value_float
, { "Value", "selfm.fmdata.ai.value_float", FT_FLOAT
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3023 { &hf_selfm_fmdata_ai_value_double
, { "Value", "selfm.fmdata.ai.value_double", FT_DOUBLE
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3024 { &hf_selfm_fmdata_data_type
, { "Data_Type", "selfm.fmdata.data_type", FT_UINT32
, BASE_DEC
, VALS(selfm_fastmsg_tagtype_vals
), 0x0, NULL
, HFILL
}},
3025 { &hf_selfm_fmdata_quantity
, { "Quantity", "selfm.fmdata.quantity", FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
3026 { &hf_selfm_fmdata_ai_value_string
, { "Value", "selfm.fmdata.ai.value_string", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3027 { &hf_selfm_fastmsg_unsresp_elmt_ts_ofs_decoded
, { "SER Element Timestamp Offset (decoded)", "selfm.fastmsg.unsresp_elmt_ts_ofs.decoded", FT_UINT24
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
3028 { &hf_selfm_fid
, { "FID", "selfm.fid", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3029 { &hf_selfm_rid
, { "RID", "selfm.rid", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3030 { &hf_selfm_fastmsg_data_region_name
, { "Data Region Name", "selfm.fastmsg.data_region_name", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3031 { &hf_selfm_fmdata_timestamp
, { "Timestamp", "selfm.fmdata.timestamp", FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0x0, NULL
, HFILL
}},
3032 { &hf_selfm_fmdata_frame_data_format_reference
, { "Frame Data Format Reference", "selfm.fmdata.frame_data_format_reference", FT_FRAMENUM
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3033 { &hf_selfm_fastmsg_bit_label_name
, { "Bit Label Name", "selfm.fastmsg.bit_label_name", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
3036 /* Register expert fields */
3037 static ei_register_info selfm_ei
[] = {
3038 { &ei_selfm_crc16_incorrect
, { "selfm.crc16.incorrect", PI_CHECKSUM
, PI_WARN
, "Incorrect CRC", EXPFILL
}}
3041 /* Setup protocol subtree array */
3042 static int *ett
[] = {
3044 &ett_selfm_relaydef
,
3045 &ett_selfm_relaydef_fm
,
3046 &ett_selfm_relaydef_proto
,
3047 &ett_selfm_relaydef_flags
,
3048 &ett_selfm_fmconfig
,
3049 &ett_selfm_fmconfig_ai
,
3050 &ett_selfm_fmconfig_calc
,
3051 &ett_selfm_foconfig
,
3052 &ett_selfm_foconfig_brkr
,
3053 &ett_selfm_foconfig_rb
,
3056 &ett_selfm_fmdata_ai
,
3057 &ett_selfm_fmdata_dig
,
3058 &ett_selfm_fmdata_ai_ch
,
3059 &ett_selfm_fmdata_dig_ch
,
3061 &ett_selfm_fastmsg_seq
,
3062 &ett_selfm_fastmsg_def_fc
,
3063 &ett_selfm_fastmsg_tag
,
3064 &ett_selfm_fastmsg_element_list
,
3065 &ett_selfm_fastmsg_element
,
3066 &ett_selfm_fastmsg_datareg
,
3067 &ett_selfm_fastmsg_soeblk
,
3068 &ett_selfm_fragment
,
3069 &ett_selfm_fragments
3073 module_t
*selfm_module
;
3074 expert_module_t
* expert_selfm
;
3076 reassembly_table_register(&selfm_reassembly_table
,
3077 &addresses_reassembly_table_functions
);
3079 /* Register the protocol name and description */
3080 proto_selfm
= proto_register_protocol("SEL Protocol", "SEL Protocol", "selfm");
3082 /* Registering protocol to be called by another dissector */
3083 selfm_handle
= register_dissector("selfm", dissect_selfm_tcp
, proto_selfm
);
3085 /* Required function calls to register the header fields and subtrees used */
3086 proto_register_field_array(proto_selfm
, selfm_hf
, array_length(selfm_hf
));
3087 proto_register_subtree_array(ett
, array_length(ett
));
3088 expert_selfm
= expert_register_protocol(proto_selfm
);
3089 expert_register_field_array(expert_selfm
, selfm_ei
, array_length(selfm_ei
));
3092 /* Register required preferences for SEL Protocol register decoding */
3093 selfm_module
= prefs_register_protocol(proto_selfm
, NULL
);
3095 /* SEL Protocol - Desegmentmentation; defaults to true for TCP desegmentation*/
3096 prefs_register_bool_preference(selfm_module
, "desegment",
3097 "Desegment packets spanning multiple TCP segments",
3098 "Whether the SEL Protocol dissector should desegment all messages spanning multiple TCP segments",
3101 /* SEL Protocol - Telnet protocol IAC (0xFF) processing; defaults to true to allow Telnet Encapsulated Data */
3102 prefs_register_bool_preference(selfm_module
, "telnetclean",
3103 "Remove extra 0xFF (Telnet IAC) bytes",
3104 "Whether the SEL Protocol dissector should automatically pre-process Telnet data to remove duplicate 0xFF IAC bytes",
3105 &selfm_telnet_clean
);
3107 /* SEL Protocol Preference - Disable/Enable CRC verification, */
3108 prefs_register_bool_preference(selfm_module
, "crc_verification", "Validate Fast Message CRC16",
3109 "Perform CRC16 validation on Fast Messages",
3112 prefs_register_string_preference(selfm_module
, "ser_list",
3113 "SER Index List", "List of word bits contained in SER equations (Comma-separated, no Quotes or Checksums)", &selfm_ser_list
);
3118 /******************************************************************************************************/
3119 /* If this dissector uses sub-dissector registration add a registration routine.
3120 This format is required because a script is used to find these routines and
3121 create the code that calls these routines.
3123 /******************************************************************************************************/
3125 proto_reg_handoff_selfm(void)
3127 dissector_add_for_decode_as_with_preference("tcp.port", selfm_handle
);
3128 dissector_add_for_decode_as("rtacser.data", selfm_handle
);
3132 * Editor modelines - https://www.wireshark.org/tools/modelines.html
3137 * indent-tabs-mode: nil
3140 * vi: set shiftwidth=4 tabstop=8 expandtab:
3141 * :indentSize=4:tabSize=8:noTabs=true: