Coverage Report

Created: 2025-08-04 07:15

/src/wireshark/epan/dissectors/packet-synphasor.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-synphasor.c
2
 * Dissector for IEEE C37.118 synchrophasor frames.
3
 *
4
 * Copyright 2008, Jens Steinhauser <jens.steinhauser@omicron.at>
5
 * Copyright 2019, Dwayne Rich <dwayne_rich@selinc.com>
6
 * Copyright 2020, Dmitriy Eliseev <eliseev_d@ntcees.ru>
7
 * Copyright 2024, Ivan Ugryumov <ugrumov.i@yandex.ru>
8
 *
9
 * Wireshark - Network traffic analyzer
10
 * By Gerald Combs <gerald@wireshark.org>
11
 * Copyright 1998 Gerald Combs
12
 *
13
 * SPDX-License-Identifier: GPL-2.0-or-later
14
 */
15
16
#include "config.h"
17
18
#include <math.h>
19
20
#include <epan/packet.h>
21
#include <epan/crc16-tvb.h>
22
#include <epan/expert.h>
23
#include <epan/proto_data.h>
24
#include <epan/tfs.h>
25
#include <epan/unit_strings.h>
26
27
#include <wsutil/array.h>
28
#include "packet-tcp.h"
29
30
#include <wsutil/utf8_entities.h>
31
32
14
#define PNAME "IEEE C37.118 Synchrophasor Protocol"
33
15
#define PSNAME "SYNCHROPHASOR"
34
14
#define PFNAME "synphasor"
35
36
/* forward references */
37
void proto_register_synphasor(void);
38
void proto_reg_handoff_synphasor(void);
39
40
/* global variables */
41
42
static int proto_synphasor;
43
44
/* user preferences */
45
14
#define SYNPHASOR_TCP_PORT  4712 /* Not IANA registered */
46
14
#define SYNPHASOR_UDP_PORT  4713 /* Not IANA registered */
47
48
/* Config 1 & 2 frames have channel names that are all 16 bytes long */
49
/* Config 3 frame channel names have a variable length with a max of 255 characters */
50
0
#define CHNAM_LEN 16
51
#define MAX_NAME_LEN 255
52
0
#define G_PMU_ID_LEN 16
53
54
/* the ett... variables hold the state (open/close) of the treeview in the GUI */
55
static int ett_synphasor; /* root element for this protocol */
56
/* used in the common header */
57
static int ett_frtype;
58
static int ett_timequal;
59
/* used for config frames */
60
static int ett_conf;
61
static int ett_conf_station;
62
static int ett_conf_format;
63
static int ett_conf_phnam;
64
static int ett_conf_annam;
65
static int ett_conf_dgnam;
66
static int ett_conf_phconv;
67
static int ett_conf_phlist;
68
static int ett_conf_phflags;
69
static int ett_conf_phmod_flags;
70
static int ett_conf_ph_user_flags;
71
static int ett_conf_anconv;
72
static int ett_conf_anlist;
73
static int ett_conf_dgmask;
74
static int ett_conf_chnam;
75
static int ett_conf_wgs84;
76
/* used for data frames */
77
static int ett_data;
78
static int ett_data_block;
79
static int ett_data_stat;
80
static int ett_data_phasors;
81
static int ett_data_analog;
82
static int ett_data_digital;
83
/* used for command frames */
84
static int ett_command;
85
static int ett_status_word_mask;
86
87
/* handles to the header fields hf[] in proto_register_synphasor() */
88
static int hf_sync;
89
static int hf_sync_frtype;
90
static int hf_sync_version;
91
static int hf_station_name_len;
92
static int hf_station_name;
93
static int hf_idcode_stream_source;
94
static int hf_idcode_data_source;
95
static int hf_g_pmu_id;
96
static int hf_frsize;
97
static int hf_soc;
98
static int hf_timeqal_lsdir;
99
static int hf_timeqal_lsocc;
100
static int hf_timeqal_lspend;
101
static int hf_timeqal_timequalindic;
102
static int hf_fracsec_raw;
103
static int hf_fracsec_ms;
104
static int hf_cont_idx;
105
static int hf_conf_timebase;
106
static int hf_conf_numpmu;
107
static int hf_conf_formatb3;
108
static int hf_conf_formatb2;
109
static int hf_conf_formatb1;
110
static int hf_conf_formatb0;
111
static int hf_conf_chnam_len;
112
static int hf_conf_chnam;
113
static int hf_conf_phasor_mod_b15;
114
static int hf_conf_phasor_mod_b10;
115
static int hf_conf_phasor_mod_b09;
116
static int hf_conf_phasor_mod_b08;
117
static int hf_conf_phasor_mod_b07;
118
static int hf_conf_phasor_mod_b06;
119
static int hf_conf_phasor_mod_b05;
120
static int hf_conf_phasor_mod_b04;
121
static int hf_conf_phasor_mod_b03;
122
static int hf_conf_phasor_mod_b02;
123
static int hf_conf_phasor_mod_b01;
124
static int hf_conf_phasor_type_b03;
125
static int hf_conf_phasor_type_b02to00;
126
static int hf_conf_phasor_user_data;
127
static int hf_conf_phasor_scale_factor;
128
static int hf_conf_phasor_angle_offset;
129
static int hf_conf_analog_scale_factor;
130
static int hf_conf_analog_offset;
131
static int hf_conf_pmu_lat;
132
static int hf_conf_pmu_lon;
133
static int hf_conf_pmu_elev;
134
static int hf_conf_pmu_lat_unknown;
135
static int hf_conf_pmu_lon_unknown;
136
static int hf_conf_pmu_elev_unknown;
137
static int hf_conf_svc_class;
138
static int hf_conf_window;
139
static int hf_conf_grp_dly;
140
static int hf_conf_fnom;
141
static int hf_conf_cfgcnt;
142
static int hf_data_statb15to14;
143
static int hf_data_statb13;
144
static int hf_data_statb12;
145
static int hf_data_statb11;
146
static int hf_data_statb10;
147
static int hf_data_statb09;
148
static int hf_data_statb08to06;
149
static int hf_data_statb05to04;
150
static int hf_data_statb03to00;
151
static int hf_command;
152
static int hf_cfg_frame_num;
153
154
/* Generated from convert_proto_tree_add_text.pl */
155
static int hf_synphasor_data;
156
static int hf_synphasor_checksum;
157
static int hf_synphasor_checksum_status;
158
static int hf_synphasor_num_phasors;
159
static int hf_synphasor_num_analog_values;
160
static int hf_synphasor_num_digital_status_words;
161
static int hf_synphasor_rate_of_transmission;
162
static int hf_synphasor_phasor;
163
static int hf_synphasor_actual_frequency_value;
164
static int hf_synphasor_rate_change_frequency;
165
static int hf_synphasor_frequency_deviation_from_nominal;
166
static int hf_synphasor_analog_value;
167
static int hf_synphasor_digital_status_word;
168
static int hf_synphasor_conversion_factor;
169
static int hf_synphasor_factor_for_analog_value;
170
static int hf_synphasor_channel_name;
171
static int hf_synphasor_extended_frame_data;
172
static int hf_synphasor_unknown_data;
173
static int hf_synphasor_status_word_mask_normal_state;
174
static int hf_synphasor_status_word_mask_valid_bits;
175
176
static expert_field ei_synphasor_extended_frame_data;
177
static expert_field ei_synphasor_checksum;
178
static expert_field ei_synphasor_data_error;
179
static expert_field ei_synphasor_pmu_not_sync;
180
181
static dissector_handle_t synphasor_udp_handle;
182
static dissector_handle_t synphasor_tcp_handle;
183
184
/* the different frame types for this protocol */
185
enum FrameType {
186
  DATA = 0,
187
  HEADER,
188
  CFG1,
189
  CFG2,
190
  CMD,
191
  CFG3
192
};
193
194
/* Structures to save CFG frame content. */
195
196
/* type to indicate the format for (D)FREQ/PHASORS/ANALOG in data frame  */
197
typedef enum {
198
  integer,  /* 16-bit signed integer */
199
  floating_point  /* single precision floating point */
200
} data_format;
201
202
typedef enum { rect, polar } phasor_notation_e;
203
204
typedef enum { V, A } unit_e;
205
206
/* holds the information required to dissect a single phasor */
207
typedef struct {
208
  char  name[MAX_NAME_LEN + 1];
209
  unit_e  unit;
210
  uint32_t  conv;     /* cfg-2 conversion factor in 10^-5 scale */
211
  float conv_cfg3;    /* cfg-3 conversion scale factor */
212
  float angle_offset_cfg3;  /* cfg-3 angle offset */
213
} phasor_info;
214
215
/* holds the information for an analog value */
216
typedef struct {
217
  char  name[MAX_NAME_LEN + 1];
218
  uint32_t  conv;   /* cfg-2 conversion scale factor, user defined scaling (so it's pretty useless) */
219
  float conv_cfg3;  /* cfg-3 conversion scale factor */
220
  float offset_cfg3;  /* cfg-3 conversion offset */
221
} analog_info;
222
223
/* holds information required to dissect a single PMU block in a data frame */
224
typedef struct {
225
  uint16_t       id;      /* (Data Source ID) identifies source of block     */
226
  char       name[MAX_NAME_LEN + 1]; /* holds STN       */
227
  uint8_t      cfg_frame_type;  /* Config Frame Type (1,2,3,...)  */
228
  data_format    format_fr;   /* data format of FREQ and DFREQ  */
229
  data_format    format_ph;   /* data format of PHASORS   */
230
  data_format    format_an;   /* data format of ANALOG    */
231
  phasor_notation_e  phasor_notation; /* format of the phasors    */
232
  unsigned       fnom;    /* nominal line frequency   */
233
  unsigned       num_dg;    /* number of digital status words */
234
  wmem_array_t    *phasors;   /* array of phasor_infos    */
235
  wmem_array_t    *analogs;   /* array of analog_infos    */
236
} config_block;
237
238
/* holds the id the configuration comes from an and
239
 * an array of config_block members */
240
typedef struct {
241
  uint32_t    fnum;   /* frame number */
242
  uint16_t    id;   /* (Stream Source ID) identifies source of stream */
243
  uint32_t    time_base;  /* Time base - resolution of FRACSEC time stamp. */
244
  wmem_array_t  *config_blocks; /* Contains a config_block struct for
245
                   * every PMU included in the config frame */
246
} config_frame;
247
248
/* strings for type bits in SYNC */
249
static const value_string typenames[] = {
250
  { 0, "Data Frame"   },
251
  { 1, "Header Frame"   },
252
  { 2, "Configuration Frame 1"  },
253
  { 3, "Configuration Frame 2"  },
254
  { 4, "Command Frame"    },
255
  { 5, "Configuration Frame 3"  },
256
  { 0, NULL     }
257
};
258
259
/* strings for version bits in SYNC */
260
static const value_string versionnames[] = {
261
  { 1, "Defined in IEEE Std C37.118-2005" },
262
  { 2, "Added in IEEE Std C37.118.2-2011" },
263
  { 0, NULL       }
264
};
265
266
/* strings for the time quality flags in FRACSEC */
267
static const true_false_string leapseconddir = {
268
  "Add",
269
  "Delete"
270
};
271
static const value_string timequalcodes[] = {
272
  { 0xF, "Clock failure, time not reliable" },
273
  { 0xB, "Clock unlocked, time within 10 s" },
274
  { 0xA, "Clock unlocked, time within 1 s"  },
275
  { 0x9, "Clock unlocked, time within 10^-1 s"  },
276
  { 0x8, "Clock unlocked, time within 10^-2 s"  },
277
  { 0x7, "Clock unlocked, time within 10^-3 s"  },
278
  { 0x6, "Clock unlocked, time within 10^-4 s"  },
279
  { 0x5, "Clock unlocked, time within 10^-5 s"  },
280
  { 0x4, "Clock unlocked, time within 10^-6 s"  },
281
  { 0x3, "Clock unlocked, time within 10^-7 s"  },
282
  { 0x2, "Clock unlocked, time within 10^-8 s"  },
283
  { 0x1, "Clock unlocked, time within 10^-9 s"  },
284
  { 0x0, "Normal operation, clock locked"   },
285
  {  0 , NULL         }
286
};
287
288
/* strings for flags in the FORMAT word of a configuration frame */
289
static const true_false_string conf_formatb123names = {
290
  "32-bit IEEE floating point",
291
  "16-bit integer"
292
};
293
static const true_false_string conf_formatb0names = {
294
  "polar",
295
  "rectangular"
296
};
297
298
/* strings to decode ANUNIT in configuration frame */
299
static const range_string conf_anconvnames[] = {
300
  {  0, 0, "single point-on-wave" },
301
  {  1, 1, "rms of analog input"  },
302
  {  2, 2, "peak of input"    },
303
  {  3, 4, "undefined"      },
304
  {  5,  64, "reserved"     },
305
  { 65, 255, "user defined"   },
306
  {  0, 0, NULL       }
307
};
308
309
/* strings for the FNOM field */
310
static const true_false_string conf_fnomnames = {
311
  "50Hz",
312
  "60Hz"
313
};
314
315
static const true_false_string conf_phasor_mod_b15 = {
316
  "Modification applied, type not here defined",
317
  "None"
318
};
319
320
static const true_false_string conf_phasor_mod_b10 = {
321
  "Pseudo-phasor value (combined from other phasors)",
322
  "None"
323
};
324
325
static const true_false_string conf_phasor_mod_b09 = {
326
  "Phasor phase adjusted for rotation",
327
  "None"
328
};
329
330
static const true_false_string conf_phasor_mod_b08 = {
331
  "Phasor phase adjusted for calibration",
332
  "None"
333
};
334
335
static const true_false_string conf_phasor_mod_b07 = {
336
  "Phasor magnitude adjusted for calibration",
337
  "None"
338
};
339
340
static const true_false_string conf_phasor_mod_b06 = {
341
  "Filtered without changing sampling",
342
  "None"
343
};
344
345
static const true_false_string conf_phasor_mod_b05 = {
346
  "Down sampled with non-FIR filter",
347
  "None"
348
};
349
350
static const true_false_string conf_phasor_mod_b04 = {
351
  "Down sampled with FIR filter",
352
  "None"
353
};
354
355
static const true_false_string conf_phasor_mod_b03 = {
356
  "Down sampled by reselection",
357
  "None"
358
};
359
360
static const true_false_string conf_phasor_mod_b02 = {
361
  "Up sampled with extrapolation",
362
  "None"
363
};
364
365
static const true_false_string conf_phasor_mod_b01 = {
366
  "Up sampled with interpolation",
367
  "None"
368
};
369
370
static const value_string conf_phasor_type[] = {
371
  { 0, "Voltage, Zero sequence"   },
372
  { 1, "Voltage, Positive sequence" },
373
  { 2, "Voltage, Negative sequence" },
374
  { 3, "Voltage, Reserved"    },
375
  { 4, "Voltage, Phase A"     },
376
  { 5, "Voltage, Phase B"     },
377
  { 6, "Voltage, Phase C"     },
378
  { 7, "Voltage, Reserved"    },
379
  { 8, "Current, Zero sequence"   },
380
  { 9, "Current, Positive sequence" },
381
  { 10, "Current, Negative sequence"  },
382
  { 11, "Current, Reserved"   },
383
  { 12, "Current, Phase A"    },
384
  { 13, "Current, Phase B"    },
385
  { 14, "Current, Phase C"    },
386
  { 15, "Current, Reserved"   },
387
  {  0, NULL        }
388
};
389
390
static const true_false_string conf_phasor_type_b03 = {
391
  "Current",
392
  "Voltage"
393
};
394
395
static const value_string conf_phasor_type_b02to00[] = {
396
  { 0, "Zero sequence"  },
397
  { 1, "Positive sequence"},
398
  { 2, "Negative sequence"},
399
  { 3, "Reserved"   },
400
  { 4, "Phase A"    },
401
  { 5, "Phase B"    },
402
  { 6, "Phase C"    },
403
  { 7, "Reserved"   },
404
  { 0, NULL   }
405
};
406
407
static const true_false_string conf_phasor_user_defined = {
408
  "Flags set",
409
  "No flags set"
410
};
411
412
/* strings for flags in the STAT word of a data frame */
413
static const value_string data_statb15to14names[] = {
414
  { 0, "Good measurement data, no errors"             },
415
  { 1, "PMU error, no information about data"           },
416
  { 2, "PMU in test mode or absent data tags have been inserted (do not use values)"  },
417
  { 3, "PMU error (do not use values)"              },
418
  { 0, NULL                   }
419
};
420
static const true_false_string data_statb13names = {
421
  "Synchronization lost",
422
  "Clock is synchronized"
423
};
424
static const true_false_string data_statb12names = {
425
  "By arrival",
426
  "By timestamp"
427
};
428
static const true_false_string data_statb11names = {
429
  "Trigger detected",
430
  "No trigger"
431
};
432
static const true_false_string data_statb10names = {
433
  "Within 1 minute",
434
  "No"
435
};
436
static const true_false_string data_statb09names = {
437
  "Data modified by a post-processing device",
438
  "Data not modified"
439
};
440
static const value_string      data_statb08to06names[] = {
441
  { 0, "Not used (indicates code from previous version of profile)" },
442
  { 1, "Estimated maximum time error < 100 ns"        },
443
  { 2, "Estimated maximum time error < 1 " UTF8_MICRO_SIGN "s"    },
444
  { 3, "Estimated maximum time error < 10 " UTF8_MICRO_SIGN "s"   },
445
  { 4, "Estimated maximum time error < 100 " UTF8_MICRO_SIGN "s"    },
446
  { 5, "Estimated maximum time error < 1 ms"        },
447
  { 6, "Estimated maximum time error < 10 ms"       },
448
  { 7, "Estimated maximum time error > 10 ms or time error unknown" },
449
  { 0, NULL               }
450
};
451
static const value_string      data_statb05to04names[] = {
452
  { 0, "Locked or unlocked less than 10 s"},
453
  { 1, "Unlocked for 10-100 s"    },
454
  { 2, "Unlocked for 100-1000 s"    },
455
  { 3, "Unlocked for over 1000 s"   },
456
  { 0, NULL       }
457
};
458
static const value_string      data_statb03to00names[] = {
459
  { 0x0, "Manual"       },
460
  { 0x1, "Magnitude low"      },
461
  { 0x2, "Magnitude high"     },
462
  { 0x3, "Phase-angel diff"   },
463
  { 0x4, "Frequency high or low"    },
464
  { 0x5, "df/dt high"     },
465
  { 0x6, "Reserved"     },
466
  { 0x7, "Digital"      },
467
  { 0x8, "User defined"     },
468
  { 0x9, "User defined"     },
469
  { 0xA, "User defined"     },
470
  { 0xB, "User defined"     },
471
  { 0xC, "User defined"     },
472
  { 0xD, "User defined"     },
473
  { 0xE, "User defined"     },
474
  { 0xF, "User defined"     },
475
  {   0, NULL       }
476
};
477
478
/* strings to decode the commands (CMD Field) according Table 15, p.26
479
 *  0000 0000 0000 0001  -  Turn off transmission of data frames
480
 *  0000 0000 0000 0010  -  Turn on transmission of data frames
481
 *  0000 0000 0000 0011  -  Send HDR frame
482
 *  0000 0000 0000 0100  -  Send CFG-1 frame.
483
 *  0000 0000 0000 0101  -  Send CFG-2 frame.
484
 *  0000 0000 0000 0110  -  Send CFG-3 frame (optional command).
485
 *  0000 0000 0000 1000  -  Extended frame.
486
 *  0000 0000 xxxx xxxx  -  All undesignated codes reserved.
487
 *  0000 yyyy xxxx xxxx  -  All codes where yyyy ≠ 0 available for user designation.
488
 *  zzzz xxxx xxxx xxxx  -  All codes where zzzz ≠ 0 reserved.
489
 */
490
static const range_string command_names[] = {
491
  {  0x0000, 0x0000, "reserved codes"   },
492
  {  0x0001, 0x0001, "data transmission off"  },
493
  {  0x0002, 0x0002, "data transmission on" },
494
  {  0x0003, 0x0003, "send HDR frame"   },
495
  {  0x0004, 0x0004, "send CFG-1 frame"   },
496
  {  0x0005, 0x0005, "send CFG-2 frame"   },
497
  {  0x0006, 0x0006, "send CFG-3 frame"   },
498
  {  0x0007, 0x0007, "reserved codes"   },
499
  {  0x0008, 0x0008, "extended frame"   },
500
  {  0x0009, 0x00FF, "reserved codes"   },
501
  {  0x0100, 0x0FFF, "user designation"   },
502
  {  0x1000, 0xFFFF, "reserved codes"   },
503
  {  0x0000, 0x0000, NULL       }
504
};
505
506
507
/******************************************************************************
508
 * functions
509
 ******************************************************************************/
510
511
/* read in the size length for names found in config 3 frames
512
   0 - no name
513
   1-255 - length of name
514
 */
515
static uint8_t get_name_length(tvbuff_t *tvb, int offset)
516
0
{
517
0
  uint8_t name_length;
518
519
  /* read the size of the name */
520
0
  name_length = tvb_get_uint8(tvb, offset);
521
522
0
  return name_length;
523
0
}
524
525
/* Checks the CRC of a synchrophasor frame, 'tvb' has to include the whole
526
 * frame, including CRC, the calculated CRC is returned in '*computedcrc'.
527
 */
528
static bool check_crc(tvbuff_t *tvb, uint16_t *computedcrc)
529
1
{
530
1
  uint16_t crc;
531
1
  unsigned  len = tvb_get_ntohs(tvb, 2);
532
533
1
  crc = tvb_get_ntohs(tvb, len - 2);
534
1
  *computedcrc = crc16_x25_ccitt_tvb(tvb, len - 2);
535
536
1
  if (crc == *computedcrc)
537
0
    return true;
538
539
1
  return false;
540
1
}
541
542
/* Dissects a configuration frame (only the most important stuff, tries
543
 * to be fast, does no GUI stuff) and returns a pointer to a config_frame
544
 * struct that contains all the information from the frame needed to
545
 * dissect a DATA frame.
546
 *
547
 * use 'config_frame_free()' to free the config_frame again
548
 */
549
static config_frame *config_frame_fast(tvbuff_t *tvb)
550
0
{
551
0
  uint16_t    num_pmu;
552
0
  int   offset;
553
0
  config_frame  *frame;
554
555
  /* get a new frame and initialize it */
556
0
  frame = wmem_new(wmem_file_scope(), config_frame);
557
558
0
  frame->config_blocks = wmem_array_new(wmem_file_scope(), sizeof(config_block));
559
560
  // Start with Stream Source ID - identifies source of stream
561
0
  offset = 4;
562
0
  frame->id = tvb_get_ntohs(tvb, offset);
563
564
  /* Skip to time base for FRACSEC */
565
0
  offset += 11; // high 8 bits reserved for flags, so +1 byte
566
0
  frame->time_base = tvb_get_uint24(tvb, offset,ENC_BIG_ENDIAN);
567
568
  /* Next number of PMU blocks */
569
0
  offset += 3;
570
0
  num_pmu = tvb_get_ntohs(tvb, offset);
571
572
  // Start of repeating blocks
573
0
  offset += 2;
574
575
0
  while (num_pmu) {
576
0
    uint16_t  format_flags;
577
0
    uint16_t  i, num_ph, num_an, num_dg;
578
0
    int         phunit, anunit, fnom;
579
0
    config_block block;
580
581
    /* initialize the block */
582
0
    block.phasors = wmem_array_new(wmem_file_scope(), sizeof(phasor_info));
583
0
    block.analogs = wmem_array_new(wmem_file_scope(), sizeof(analog_info));
584
    /* copy the station name from the tvb to block, and add NULL byte */
585
0
    tvb_memcpy(tvb, block.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
586
0
    block.name[CHNAM_LEN] = '\0';
587
0
    block.cfg_frame_type = 2;
588
0
    block.id = tvb_get_ntohs(tvb, offset); offset += 2;
589
590
0
    format_flags        = tvb_get_ntohs(tvb, offset); offset += 2;
591
0
    block.format_fr       = (format_flags & 0x0008) ? floating_point : integer;
592
0
    block.format_an       = (format_flags & 0x0004) ? floating_point : integer;
593
0
    block.format_ph       = (format_flags & 0x0002) ? floating_point : integer;
594
0
    block.phasor_notation = (format_flags & 0x0001) ? polar     : rect;
595
596
0
    num_ph = tvb_get_ntohs(tvb, offset); offset += 2;
597
0
    num_an = tvb_get_ntohs(tvb, offset); offset += 2;
598
0
    num_dg = tvb_get_ntohs(tvb, offset); offset += 2;
599
0
    block.num_dg = num_dg;
600
601
    /* the offset of the PHUNIT, ANUNIT, and FNOM blocks */
602
0
    phunit = offset + (num_ph + num_an + num_dg * CHNAM_LEN) * CHNAM_LEN;
603
0
    anunit = phunit + num_ph * 4;
604
0
    fnom   = anunit + num_an * 4 + num_dg * 4;
605
606
    /* read num_ph phasor names and conversion factors */
607
0
    for (i = 0; i != num_ph; i++) {
608
0
      phasor_info  pi;
609
0
      uint32_t       conv;
610
611
      /* copy the phasor name from the tvb, and add NULL byte */
612
0
      tvb_memcpy(tvb, pi.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
613
0
      pi.name[CHNAM_LEN] = '\0';
614
615
0
      conv = tvb_get_ntohl(tvb, phunit + 4 * i);
616
0
      pi.unit = conv & 0xFF000000 ? A : V;
617
0
      pi.conv = conv & 0x00FFFFFF;
618
0
      pi.conv_cfg3 = 1;
619
0
      pi.angle_offset_cfg3 = 0;
620
621
0
      wmem_array_append_one(block.phasors, pi);
622
0
    }
623
624
    /* read num_an analog value names and conversion factors */
625
0
    for (i = 0; i != num_an; i++) {
626
0
      analog_info ai;
627
0
      uint32_t      conv;
628
629
      /* copy the phasor name from the tvb, and add NULL byte */
630
0
      tvb_memcpy(tvb, ai.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
631
0
      ai.name[CHNAM_LEN] = '\0';
632
633
0
      conv = tvb_get_ntohl(tvb, anunit + 4 * i);
634
0
      ai.conv = conv;
635
0
      ai.conv_cfg3 = 1;
636
0
      ai.offset_cfg3 = 0;
637
638
0
      wmem_array_append_one(block.analogs, ai);
639
0
    }
640
641
    /* the names for the bits in the digital status words aren't saved,
642
       there is no space to display them in the GUI anyway */
643
644
    /* save FNOM */
645
0
    block.fnom = tvb_get_ntohs(tvb, fnom) & 0x0001 ? 50 : 60;
646
0
    offset = fnom + 2;
647
648
    /* skip CFGCNT */
649
0
    offset += 2;
650
651
0
    wmem_array_append_one(frame->config_blocks, block);
652
0
    num_pmu--;
653
0
  }
654
655
0
  return frame;
656
0
} /* config_frame_fast() */
657
658
/* Dissects a configuration 3 frame (only the most important stuff, tries
659
 * to be fast, does no GUI stuff) and returns a pointer to a config_frame
660
 * struct that contains all the information from the frame needed to
661
 * dissect a DATA frame.
662
 *
663
 * use 'config_frame_free()' to free the config_frame again
664
 */
665
static config_frame * config_3_frame_fast(tvbuff_t *tvb)
666
0
{
667
0
  uint16_t        num_pmu;
668
0
  int       offset;
669
0
  config_frame *frame;
670
0
  phasor_info  *pi = NULL;
671
0
  analog_info  *ai = NULL;
672
0
  bool          frame_not_fragmented;
673
674
  /* get a new frame and initialize it */
675
0
  frame = wmem_new(wmem_file_scope(), config_frame);
676
677
0
  frame->config_blocks = wmem_array_new(wmem_file_scope(), sizeof(config_block));
678
679
  // Start with Stream Source ID - identifies source of stream
680
0
  offset = 4;
681
0
  frame->id = tvb_get_ntohs(tvb, offset);
682
683
  /* Skip to CONT_IDX -- Fragmented Frames not supported at this time */
684
0
  offset += 10;
685
0
  frame_not_fragmented = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN) == 0;
686
687
  /* Skip to time base for FRACSEC */
688
0
  offset += 3; // high 8 bits reserved for flags, so +1 byte
689
0
  frame->time_base = tvb_get_uint24(tvb, offset,ENC_BIG_ENDIAN);
690
691
  /* Skip to number of PMU blocks */
692
0
  offset += 3;
693
0
  num_pmu = tvb_get_ntohs(tvb, offset);
694
695
  /* start of repeating blocks */
696
0
  offset += 2;
697
0
  while ((num_pmu) && (frame_not_fragmented)) {
698
0
    uint16_t       format_flags;
699
0
    uint16_t       i, num_ph, num_an, num_dg;
700
0
    uint8_t      name_length;
701
0
    config_block block;
702
703
    /* initialize the block */
704
0
    block.phasors = wmem_array_new(wmem_file_scope(), sizeof(phasor_info));
705
0
    block.analogs = wmem_array_new(wmem_file_scope(), sizeof(analog_info));
706
707
    /* copy the station name from the tvb to block, and add NULL byte */
708
    /* first byte is name size */
709
0
    name_length = get_name_length(tvb, offset);
710
0
    offset += 1;
711
712
0
    tvb_memcpy(tvb, block.name, offset, name_length);
713
0
    offset += name_length;
714
715
0
    block.name[name_length] = '\0';
716
0
    block.cfg_frame_type = 3;
717
718
    /* Block ID and Global PMU ID */
719
0
    block.id = tvb_get_ntohs(tvb, offset);
720
0
    offset += 2;
721
722
    /* skip over Global PMU ID */
723
0
    offset += G_PMU_ID_LEN;
724
725
0
    format_flags        = tvb_get_ntohs(tvb, offset);
726
0
    offset += 2;
727
728
0
    block.format_fr       = (format_flags & 0x0008) ? floating_point : integer;
729
0
    block.format_an       = (format_flags & 0x0004) ? floating_point : integer;
730
0
    block.format_ph       = (format_flags & 0x0002) ? floating_point : integer;
731
0
    block.phasor_notation = (format_flags & 0x0001) ? polar     : rect;
732
733
0
    num_ph = tvb_get_ntohs(tvb, offset);
734
0
    offset += 2;
735
736
0
    num_an = tvb_get_ntohs(tvb, offset);
737
0
    offset += 2;
738
739
0
    num_dg = tvb_get_ntohs(tvb, offset);
740
0
    offset += 2;
741
0
    block.num_dg = num_dg;
742
743
    /* grab phasor names */
744
0
    if (num_ph > 0)
745
0
    {
746
0
      pi = (phasor_info *)wmem_alloc(wmem_file_scope(), sizeof(phasor_info)*num_ph);
747
748
0
      for (i = 0; i != num_ph; i++) {
749
        /* copy the phasor name from the tvb, and add NULL byte */
750
0
        name_length = get_name_length(tvb, offset);
751
0
        offset += 1;
752
753
0
        tvb_memcpy(tvb, pi[i].name, offset, name_length);
754
0
        offset += name_length;
755
756
0
        pi[i].name[name_length] = '\0';
757
0
      }
758
0
    }
759
760
    /* grab analog names */
761
0
    if (num_an > 0)
762
0
    {
763
0
      ai = (analog_info *)wmem_alloc(wmem_file_scope(), sizeof(analog_info)*num_an);
764
765
0
      for (i = 0; i != num_an; i++) {
766
        /* copy the phasor name from the tvb, and add NULL byte */
767
0
        name_length = get_name_length(tvb, offset);
768
0
        offset += 1;
769
770
0
        tvb_memcpy(tvb, ai[i].name, offset, name_length);
771
0
        offset += name_length;
772
773
0
        ai[i].name[name_length] = '\0';
774
0
      }
775
0
    }
776
777
    /* skip digital names */
778
0
    if (num_dg > 0)
779
0
    {
780
0
      for (i = 0; i != num_dg * 16; i++) {
781
0
        name_length = get_name_length(tvb, offset);
782
0
        offset += name_length + 1;
783
0
      }
784
0
    }
785
786
    /* get phasor conversion factors */
787
0
    if (num_ph > 0)
788
0
    {
789
0
      for (i = 0; i != num_ph; i++) {
790
0
        uint32_t phasor_unit;
791
792
        /* get unit */
793
0
        phasor_unit = tvb_get_ntohl(tvb, offset);
794
0
        pi[i].unit = phasor_unit & 0x00000800 ? A : V;
795
0
        pi[i].conv = 1;
796
0
        pi[i].conv_cfg3 = tvb_get_ntohieee_float(tvb, offset + 4);
797
0
        pi[i].angle_offset_cfg3 = tvb_get_ntohieee_float(tvb, offset + 8);
798
799
0
        wmem_array_append_one(block.phasors, pi[i]);
800
801
0
        offset += 12;
802
0
      }
803
0
    }
804
805
    /* get analog conversion factors */
806
0
    if (num_an > 0)
807
0
    {
808
0
      for (i = 0; i != num_an; i++) {
809
0
        ai[i].conv = 1;
810
0
        ai[i].conv_cfg3 = tvb_get_ntohieee_float(tvb, offset);
811
0
        ai[i].offset_cfg3 = tvb_get_ntohieee_float(tvb, offset + 4);
812
813
0
        wmem_array_append_one(block.analogs, ai[i]);
814
815
0
        offset += 8;
816
0
      }
817
0
    }
818
819
    /* skip digital masks */
820
0
    if (num_dg > 0)
821
0
    {
822
0
      for (i = 0; i != num_dg; i++) {
823
0
        offset += 4;
824
0
      }
825
0
    }
826
827
    /* Skip to FNOM */
828
0
    offset += 21;
829
830
    /* save FNOM */
831
0
    block.fnom = tvb_get_ntohs(tvb, offset) & 0x0001 ? 50 : 60;
832
0
    offset += 2;
833
834
    /* skip CFGCNT - offset ready for next PMU */
835
0
    offset += 2;
836
837
0
    wmem_array_append_one(frame->config_blocks, block);
838
0
    num_pmu--;
839
0
  }
840
841
0
  return frame;
842
0
} /* config_3_frame_fast() */
843
844
/* Dissects the common header of frames.
845
 *
846
 * Returns the framesize, in contrast to most
847
 * other helper functions that return the offset.
848
 */
849
static int dissect_header(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo)
850
1
{
851
1
  proto_tree *temp_tree;
852
1
  proto_item *temp_item;
853
1
  config_frame *conf;
854
855
1
  int offset = 0;
856
1
  uint16_t  framesize;
857
858
1
  conf = (config_frame *)p_get_proto_data(wmem_file_scope(), pinfo, proto_synphasor, 0);
859
860
  /* SYNC and flags */
861
1
  temp_item = proto_tree_add_item(tree, hf_sync, tvb, offset, 2, ENC_BIG_ENDIAN);
862
1
  temp_tree = proto_item_add_subtree(temp_item, ett_frtype);
863
1
  proto_tree_add_item(temp_tree, hf_sync_frtype,  tvb, offset, 2, ENC_BIG_ENDIAN);
864
1
  proto_tree_add_item(temp_tree, hf_sync_version, tvb, offset, 2, ENC_BIG_ENDIAN);
865
1
  offset += 2;
866
867
  /* FRAMESIZE */
868
1
  proto_tree_add_item(tree, hf_frsize, tvb, offset, 2, ENC_BIG_ENDIAN);
869
1
  framesize = tvb_get_ntohs(tvb, offset); offset += 2;
870
871
  /* IDCODE */
872
1
  proto_tree_add_item(tree, hf_idcode_stream_source, tvb, offset, 2, ENC_BIG_ENDIAN);
873
1
  offset += 2;
874
875
  /* SOC */
876
1
  proto_tree_add_item(tree, hf_soc, tvb, offset, 4, ENC_TIME_SECS | ENC_BIG_ENDIAN);
877
1
  offset += 4;
878
879
  /* FRACSEC */
880
  /* time quality flags */
881
1
  temp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_timequal, NULL, "Time quality flags");
882
1
  proto_tree_add_item(temp_tree, hf_timeqal_lsdir,   tvb, offset, 1, ENC_BIG_ENDIAN);
883
1
  proto_tree_add_item(temp_tree, hf_timeqal_lsocc,   tvb, offset, 1, ENC_BIG_ENDIAN);
884
1
  proto_tree_add_item(temp_tree, hf_timeqal_lspend,  tvb, offset, 1, ENC_BIG_ENDIAN);
885
1
  proto_tree_add_item(temp_tree, hf_timeqal_timequalindic, tvb, offset, 1, ENC_BIG_ENDIAN);
886
1
  offset += 1;
887
888
  // Add RAW FRACSEC
889
1
  proto_tree_add_item(tree, hf_fracsec_raw,  tvb, offset, 3, ENC_BIG_ENDIAN);
890
891
  // If exist configuration frame, add fracsec in milliseconds
892
1
  if (conf){
893
0
    uint32_t fracsec_raw = tvb_get_uint24(tvb, offset, ENC_BIG_ENDIAN);
894
0
    float fracsec_ms = 1000.0f*fracsec_raw/conf->time_base;
895
0
    proto_tree_add_float(tree, hf_fracsec_ms, tvb, offset, 3, fracsec_ms);
896
0
  } else
897
1
  {
898
1
  }
899
  /*offset += 3;*/
900
901
1
  return framesize;
902
1
}
903
904
/* Dissects a single phasor for 'dissect_PHASORS()' */
905
static int dissect_single_phasor(tvbuff_t *tvb, int offset,
906
          double *mag, double *phase, /* returns the resulting values in polar format here */
907
          double* real, double* imag, /* returns the resulting values in rectangular format here*/
908
          double* mag_real_unscaled, double* phase_imag_unscaled, /* returns unscaled values*/
909
          config_block *block,        /* information needed to... */
910
          phasor_info* pi)        /*  ...dissect the phasor */
911
0
{
912
0
  if (floating_point == block->format_ph) {
913
0
    if (polar == block->phasor_notation) {
914
      /* float, polar */
915
0
      *mag   = tvb_get_ntohieee_float(tvb, offset    );
916
0
      *phase = tvb_get_ntohieee_float(tvb, offset + 4);
917
918
0
      *real = (*mag) * cos(*phase);
919
0
      *imag = (*mag) * sin(*phase);
920
0
    }
921
0
    else {
922
      /* float, rect */
923
0
      *real = tvb_get_ntohieee_float(tvb, offset    );
924
0
      *imag = tvb_get_ntohieee_float(tvb, offset + 4);
925
926
0
      *mag   = sqrt(pow(*real, 2) + pow(*imag, 2));
927
0
      *phase = atan2(*imag, *real);
928
0
    }
929
0
  }
930
0
  else {
931
0
    if (polar == block->phasor_notation) {
932
      /* int, polar */
933
0
      *mag_real_unscaled = tvb_get_ntohs(tvb, offset  );
934
0
      *phase_imag_unscaled = tvb_get_ntohis(tvb, offset + 2);
935
936
      /* For fixed-point data in polar format all values are permissible for the magnitude
937
         field. However, the angle field is restricted to ±31416. A value of 0x8000 (–32768) used in the angle field
938
         will be used to signify absent data.
939
         bullet 6.3.1 page 16 IEEE Std C37.118.2-2011
940
       */
941
0
      if (*phase_imag_unscaled == -32768) {
942
0
        *phase_imag_unscaled = NAN;
943
0
        *mag_real_unscaled = NAN;
944
0
      }
945
946
0
      *phase = *phase_imag_unscaled/10000.0; /* angle is in radians*10^4 */
947
948
      /* for values in integer format, consider conversation factor */
949
0
      if (block->cfg_frame_type == 3){
950
0
        *mag = (*mag_real_unscaled * pi->conv_cfg3);
951
0
        *phase = *phase - pi->angle_offset_cfg3;
952
0
      }
953
0
      else{
954
0
        *mag = (*mag_real_unscaled * pi->conv) * 0.00001;
955
0
      }
956
957
0
      *real = (*mag) * cos(*phase);
958
0
      *imag = (*mag) * sin(*phase);
959
0
    }
960
0
    else {
961
      /* int, rect */
962
0
      *mag_real_unscaled = tvb_get_ntohis(tvb, offset    );
963
0
      *phase_imag_unscaled = tvb_get_ntohis(tvb, offset + 2);
964
965
      /* For fixed-point data in rectangular format the PDC will use
966
         0x8000 (–32768) as the substitute for the absent data.
967
         bullet 6.3.1 page 16 IEEE Std C37.118.2-2011
968
       */
969
0
      if (*mag_real_unscaled == -32768) {
970
0
        *mag_real_unscaled = NAN;
971
0
      }
972
0
      if (*phase_imag_unscaled == -32768) {
973
0
        *phase_imag_unscaled = NAN;
974
0
      }
975
976
0
      *mag = sqrt(pow(*mag_real_unscaled, 2) + pow(*phase_imag_unscaled, 2));
977
0
      *phase = atan2(*phase_imag_unscaled, *mag_real_unscaled);
978
979
      /* for values in integer format, consider conversation factor */
980
0
      if (block->cfg_frame_type == 3) {
981
0
        *mag = (*mag * pi->conv_cfg3);
982
0
        *phase = *phase - pi->angle_offset_cfg3;
983
0
      }
984
0
      else {
985
0
        *mag = (*mag * pi->conv) * 0.00001;
986
0
      }
987
988
0
      *real = (*mag) * cos(*phase);
989
0
      *imag = (*mag) * sin(*phase);
990
0
    }
991
0
  }
992
993
0
  return floating_point == block->format_ph ? 8 : 4;
994
0
}
995
996
/* used by 'dissect_data_frame()' to dissect the PHASORS field */
997
static int dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block, int offset)
998
0
{
999
0
  proto_tree *phasor_tree;
1000
0
  unsigned      length;
1001
0
  int     j;
1002
0
  int     cnt = wmem_array_get_count(block->phasors); /* number of phasors to dissect */
1003
1004
0
  if (0 == cnt)
1005
0
    return offset;
1006
1007
0
  length      = wmem_array_get_count(block->phasors) * (floating_point == block->format_ph ? 8 : 4);
1008
0
  phasor_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_phasors, NULL,
1009
0
                "Phasors (%u), notation: %s, format: %s", cnt,
1010
0
              block->phasor_notation ? "polar" : "rectangular",
1011
0
              block->format_ph ? "floating point" : "integer");
1012
1013
  /* dissect a phasor for every phasor_info saved in the config_block */
1014
0
  for (j = 0; j < cnt; j++) {
1015
0
    proto_item  *temp_item;
1016
0
    double       mag, phase,real, imag;
1017
0
    double       mag_real_unscaled = NAN, phase_imag_unscaled = NAN;
1018
0
    phasor_info *pi;
1019
1020
0
    pi = (phasor_info *)wmem_array_index(block->phasors, j);
1021
0
    temp_item = proto_tree_add_string_format(phasor_tree, hf_synphasor_phasor, tvb, offset,
1022
0
            floating_point == block->format_ph ? 8 : 4, pi->name,
1023
0
            "Phasor #%u: \"%s\"", j + 1, pi->name);
1024
1025
0
    offset += dissect_single_phasor(tvb, offset,
1026
0
            &mag, &phase, &real, &imag,
1027
0
            &mag_real_unscaled, &phase_imag_unscaled,
1028
0
            block,pi);
1029
1030
0
    #define SYNP_ANGLE "\xe2\x88\xa0"      /*   8736 / 0x2220 */
1031
1032
0
    char phasor_unit = V == pi->unit ? 'V' : 'A';
1033
1034
0
    proto_item_append_text(temp_item, ", %10.3F%c " SYNP_ANGLE "%7.3F" UTF8_DEGREE_SIGN " alt %7.3F+j%7.3F%c",
1035
0
      mag, phasor_unit, phase * 180.0 / G_PI,
1036
0
      real, imag, phasor_unit);
1037
0
    if (integer == block->format_ph) {
1038
0
      proto_item_append_text(temp_item, "; unscaled: %5.0F, %5.0F",
1039
0
        mag_real_unscaled, phase_imag_unscaled);
1040
0
    }
1041
0
    #undef SYNP_ANGLE
1042
0
  }
1043
0
  return offset;
1044
0
}
1045
1046
/* used by 'dissect_data_frame()' to dissect the FREQ and DFREQ fields */
1047
static int dissect_DFREQ(tvbuff_t *tvb, proto_tree *tree, config_block *block, int offset)
1048
0
{
1049
0
  if (floating_point == block->format_fr) {
1050
0
    proto_tree_add_item(tree, hf_synphasor_actual_frequency_value, tvb, offset, 4, ENC_BIG_ENDIAN);
1051
0
    offset += 4;
1052
1053
    /* In new version of the standard IEEE Std C37.118.2-2011: "Can be 16-bit integer or IEEE floating point, same as FREQ above."
1054
     * --> no scaling factor is applied to DFREQ
1055
     */
1056
0
    proto_tree_add_item(tree, hf_synphasor_rate_change_frequency, tvb, offset, 4, ENC_BIG_ENDIAN);
1057
0
    offset += 4;
1058
0
  }
1059
0
  else {
1060
0
    int16_t tmp;
1061
1062
0
    tmp = tvb_get_ntohs(tvb, offset);
1063
0
    proto_tree_add_int_format_value(tree, hf_synphasor_frequency_deviation_from_nominal, tvb, offset, 2, tmp,
1064
0
            "%dmHz (actual frequency: %.3fHz)", tmp, block->fnom + (tmp / 1000.0));
1065
0
    offset += 2;
1066
1067
0
    tmp = tvb_get_ntohs(tvb, offset);
1068
0
    proto_tree_add_float_format_value(tree, hf_synphasor_rate_change_frequency, tvb, offset, 2, (float)(tmp / 100.0), "%.3fHz/s", tmp / 100.0); offset += 2;
1069
0
  }
1070
0
  return offset;
1071
0
}
1072
1073
/* used by 'dissect_data_frame()' to dissect the ANALOG field */
1074
static int dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block, int offset)
1075
0
{
1076
0
  proto_tree *analog_tree;
1077
0
  unsigned      length;
1078
0
  int     j;
1079
0
  int     cnt = wmem_array_get_count(block->analogs); /* number of analog values to dissect */
1080
1081
0
  if (0 == cnt)
1082
0
    return offset;
1083
1084
0
  length      = wmem_array_get_count(block->analogs) * (floating_point == block->format_an ? 4 : 2);
1085
0
  analog_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_analog, NULL,
1086
0
                "Analog values (%u)", cnt);
1087
1088
0
  for (j = 0; j < cnt; j++) {
1089
0
    proto_item *temp_item;
1090
0
    analog_info *ai = (analog_info *)wmem_array_index(block->analogs, j);
1091
1092
0
    temp_item = proto_tree_add_string_format(analog_tree, hf_synphasor_analog_value, tvb, offset,
1093
0
            floating_point == block->format_an ? 4 : 2, ai->name,
1094
0
            "Analog value #%u: \"%s\"", j + 1, ai->name);
1095
1096
0
    if (block->cfg_frame_type == 3)
1097
0
    {
1098
0
      if (floating_point == block->format_an) {
1099
0
        float tmp;
1100
1101
0
        tmp = tvb_get_ntohieee_float(tvb, offset);
1102
0
        offset += 4;
1103
1104
0
        proto_item_append_text(temp_item, ", %.3f", tmp);
1105
0
      }
1106
0
      else {
1107
        /* the "standard" doesn't say if this is signed or unsigned,
1108
         * so I just use int16_t */
1109
0
        int16_t tmp_i;
1110
0
        float tmp_f;
1111
1112
0
        tmp_i = tvb_get_ntohs(tvb, offset);
1113
0
        offset += 2;
1114
1115
0
        tmp_f = (tmp_i * ai->conv_cfg3) + ai->offset_cfg3;
1116
1117
0
        proto_item_append_text(temp_item, ", %.3f", tmp_f);
1118
0
      }
1119
0
    }
1120
0
    else
1121
0
    {
1122
0
      if (floating_point == block->format_an) {
1123
0
        float tmp = tvb_get_ntohieee_float(tvb, offset); offset += 4;
1124
0
        proto_item_append_text(temp_item, ", %.3f", tmp);
1125
0
      }
1126
0
      else {
1127
        /* the "standard" doesn't say if this is signed or unsigned,
1128
         * so I just use int16_t; the scaling of the conversion factor
1129
         * is also "user defined", so I just write it after the analog value */
1130
0
        int16_t tmp = tvb_get_ntohs(tvb, offset); offset += 2;
1131
0
        proto_item_append_text(temp_item, ", %" PRId16 " (conversion factor: %#06x)",
1132
0
                   tmp, ai->conv);
1133
0
      }
1134
0
    }
1135
0
  }
1136
0
  return offset;
1137
0
}
1138
1139
/* used by 'dissect_data_frame()' to dissect the DIGITAL field */
1140
static int dissect_DIGITAL(tvbuff_t *tvb, proto_tree *tree, config_block *block, int offset)
1141
0
{
1142
0
  int     j;
1143
0
  int     cnt = block->num_dg; /* number of digital status words to dissect */
1144
1145
0
  if (0 == cnt)
1146
0
    return offset;
1147
1148
0
  tree = proto_tree_add_subtree_format(tree, tvb, offset, cnt * 2, ett_data_digital, NULL,
1149
0
               "Digital status words (%u)", cnt);
1150
1151
0
  for (j = 0; j < cnt; j++) {
1152
0
    uint16_t tmp = tvb_get_ntohs(tvb, offset);
1153
0
    proto_tree_add_uint_format(tree, hf_synphasor_digital_status_word, tvb, offset, 2, tmp, "Digital status word #%u: 0x%04x", j + 1, tmp);
1154
0
    offset += 2;
1155
0
  }
1156
0
  return offset;
1157
0
}
1158
1159
/* used by 'dissect_config_frame()' to dissect the PHUNIT field */
1160
static int dissect_PHUNIT(tvbuff_t *tvb, proto_tree *tree, int offset, int cnt)
1161
0
{
1162
0
  proto_tree *temp_tree;
1163
0
  int i;
1164
1165
0
  if (0 == cnt)
1166
0
    return offset;
1167
1168
0
  temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_phconv, NULL,
1169
0
              "Phasor conversion factors (%u)", cnt);
1170
1171
  /* Conversion factor for phasor channels. Four bytes for each phasor.
1172
   * MSB:     0 = voltage, 1 = current
1173
   * Lower 3 Bytes: unsigned 24-bit word in 10^-5 V or A per bit to scale the phasor value
1174
   */
1175
0
  for (i = 0; i < cnt; i++) {
1176
0
    uint32_t tmp = tvb_get_ntohl(tvb, offset);
1177
0
    proto_tree_add_uint_format(temp_tree, hf_synphasor_conversion_factor, tvb, offset, 4,
1178
0
            tmp, "#%u factor: %u * 10^-5, unit: %s",
1179
0
            i + 1,
1180
0
            tmp & 0x00FFFFFF,
1181
0
            tmp & 0xFF000000 ? "Ampere" : "Volt");
1182
0
    offset += 4;
1183
0
  }
1184
1185
0
  return offset;
1186
0
}
1187
1188
/* used by 'dissect_config_3_frame()' to dissect the PHSCALE field */
1189
static int dissect_PHSCALE(tvbuff_t *tvb, proto_tree *tree, int offset, int cnt)
1190
0
{
1191
0
  proto_tree *temp_tree;
1192
0
  int i;
1193
1194
0
  if (0 == cnt) {
1195
0
    return offset;
1196
0
  }
1197
1198
0
  temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 12 * cnt, ett_conf_phconv, NULL,
1199
0
              "Phasor scaling and data flags (%u)", cnt);
1200
1201
0
  for (i = 0; i < cnt; i++) {
1202
0
    proto_tree *single_phasor_scaling_and_flags_tree;
1203
0
    proto_tree *phasor_flag1_tree;
1204
0
    proto_tree *phasor_flag2_tree;
1205
0
    proto_tree *data_flag_tree;
1206
1207
0
    single_phasor_scaling_and_flags_tree = proto_tree_add_subtree_format(temp_tree, tvb, offset, 12,
1208
0
                         ett_conf_phlist, NULL,
1209
0
                         "Phasor #%u", i + 1);
1210
1211
0
    data_flag_tree = proto_tree_add_subtree_format(single_phasor_scaling_and_flags_tree, tvb, offset, 4,
1212
0
                     ett_conf_phflags, NULL, "Phasor Data flags: %s",
1213
0
                     val_to_str_const(tvb_get_uint8(tvb, offset + 2), conf_phasor_type, "Unknown"));
1214
1215
    /* first and second bytes - phasor modification flags*/
1216
0
    phasor_flag1_tree = proto_tree_add_subtree_format(data_flag_tree, tvb, offset, 2, ett_conf_phmod_flags,
1217
0
                  NULL, "Modification Flags: 0x%04x",
1218
0
                  tvb_get_ntohs(tvb, offset));
1219
1220
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b15, tvb, offset, 2, ENC_BIG_ENDIAN);
1221
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b10, tvb, offset, 2, ENC_BIG_ENDIAN);
1222
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b09, tvb, offset, 2, ENC_BIG_ENDIAN);
1223
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b08, tvb, offset, 2, ENC_BIG_ENDIAN);
1224
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b07, tvb, offset, 2, ENC_BIG_ENDIAN);
1225
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b06, tvb, offset, 2, ENC_BIG_ENDIAN);
1226
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b05, tvb, offset, 2, ENC_BIG_ENDIAN);
1227
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b04, tvb, offset, 2, ENC_BIG_ENDIAN);
1228
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b03, tvb, offset, 2, ENC_BIG_ENDIAN);
1229
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b02, tvb, offset, 2, ENC_BIG_ENDIAN);
1230
0
    proto_tree_add_item(phasor_flag1_tree, hf_conf_phasor_mod_b01, tvb, offset, 2, ENC_BIG_ENDIAN);
1231
0
    offset += 2;
1232
1233
    /* third byte - phasor type*/
1234
0
    proto_tree_add_item(data_flag_tree, hf_conf_phasor_type_b03, tvb, offset, 1, ENC_BIG_ENDIAN);
1235
0
    proto_tree_add_item(data_flag_tree, hf_conf_phasor_type_b02to00, tvb, offset, 1, ENC_BIG_ENDIAN);
1236
0
    offset += 1;
1237
1238
    /* fourth byte - user designation*/
1239
0
    phasor_flag2_tree = proto_tree_add_subtree_format(data_flag_tree, tvb, offset, 1, ett_conf_ph_user_flags,
1240
0
                  NULL, "User designated flags: 0x%02x",
1241
0
                  tvb_get_uint8(tvb, offset));
1242
1243
0
    proto_tree_add_item(phasor_flag2_tree, hf_conf_phasor_user_data, tvb, offset, 1, ENC_BIG_ENDIAN);
1244
0
    offset += 1;
1245
1246
    /* phasor scalefactor */
1247
0
    proto_tree_add_item(single_phasor_scaling_and_flags_tree, hf_conf_phasor_scale_factor,
1248
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
1249
0
    offset += 4;
1250
1251
    /* angle adjustment */
1252
0
    proto_tree_add_item(single_phasor_scaling_and_flags_tree, hf_conf_phasor_angle_offset,
1253
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
1254
0
    offset += 4;
1255
0
  }
1256
1257
0
  return offset;
1258
0
}
1259
1260
/* used by 'dissect_config_frame()' to dissect the ANUNIT field */
1261
static int dissect_ANUNIT(tvbuff_t *tvb, proto_tree *tree, int offset, int cnt)
1262
0
{
1263
0
  proto_item *temp_item;
1264
0
  proto_tree *temp_tree;
1265
0
  int i;
1266
1267
0
  if (0 == cnt)
1268
0
    return offset;
1269
1270
0
  temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_anconv, NULL,
1271
0
              "Analog values conversion factors (%u)", cnt);
1272
1273
  /* Conversion factor for analog channels. Four bytes for each analog value.
1274
   * MSB: see 'synphasor_conf_anconvnames' in 'synphasor_strings.c'
1275
   * Lower 3 Bytes: signed 24-bit word, user-defined scaling
1276
   */
1277
0
  for (i = 0; i < cnt; i++) {
1278
0
    int32_t tmp = tvb_get_ntohl(tvb, offset);
1279
0
    temp_item = proto_tree_add_uint_format(temp_tree, hf_synphasor_factor_for_analog_value, tvb, offset, 4,
1280
0
            tmp, "Factor for analog value #%i: %s",
1281
0
            i + 1,
1282
0
            try_rval_to_str((tmp >> 24) & 0x000000FF, conf_anconvnames));
1283
1284
0
    tmp &= 0x00FFFFFF;
1285
0
    if (  tmp &  0x00800000) /* sign bit set */
1286
0
      tmp |= 0xFF000000;
1287
1288
0
    proto_item_append_text(temp_item, ", value: %" PRId32, tmp);
1289
1290
0
    offset += 4;
1291
0
  }
1292
1293
0
  return offset;
1294
0
}
1295
1296
/* used by 'dissect_config_3_frame()' to dissect the ANSCALE field */
1297
static int dissect_ANSCALE(tvbuff_t *tvb, proto_tree *tree, int offset, int cnt)
1298
0
{
1299
0
  proto_tree *temp_tree;
1300
0
  int i;
1301
1302
0
  if (0 == cnt) {
1303
0
    return offset;
1304
0
  }
1305
1306
0
  temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 8 * cnt, ett_conf_anconv, NULL,
1307
0
              "Analog values conversion factors (%u)", cnt);
1308
1309
  /* Conversion factor for analog channels. Four bytes for each analog value.
1310
   * MSB: see 'synphasor_conf_anconvnames' in 'synphasor_strings.c'
1311
   * Lower 3 Bytes: signed 24-bit word, user-defined scaling
1312
   */
1313
0
  for (i = 0; i < cnt; i++) {
1314
0
    proto_tree *single_analog_scalefactor_tree;
1315
1316
0
    single_analog_scalefactor_tree = proto_tree_add_subtree_format(temp_tree, tvb, offset, 8,
1317
0
                         ett_conf_phlist, NULL,
1318
0
                         "Analog #%u", i + 1);
1319
1320
    /* analog scalefactor */
1321
0
    proto_tree_add_item(single_analog_scalefactor_tree, hf_conf_analog_scale_factor,
1322
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
1323
0
    offset += 4;
1324
1325
    /* angle adjustment */
1326
0
    proto_tree_add_item(single_analog_scalefactor_tree, hf_conf_analog_offset,
1327
0
            tvb, offset, 4, ENC_BIG_ENDIAN);
1328
0
    offset += 4;
1329
0
  }
1330
1331
0
  return offset;
1332
0
}
1333
1334
/* used by 'dissect_config_frame()' to dissect the DIGUNIT field */
1335
static int dissect_DIGUNIT(tvbuff_t *tvb, proto_tree *tree, int offset, int cnt)
1336
0
{
1337
0
  proto_tree *temp_tree, *mask_tree;
1338
0
  int i;
1339
1340
0
  if (0 == cnt)
1341
0
    return offset;
1342
1343
0
  temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_dgmask, NULL,
1344
0
              "Masks for digital status words (%u)", cnt);
1345
1346
  /* Mask words for digital status words. Two 16-bit words for each digital word. The first
1347
   * indicates the normal status of the inputs, the second indicated the valid bits in
1348
   * the status word
1349
   */
1350
0
  for (i = 0; i < cnt; i++) {
1351
1352
0
    mask_tree = proto_tree_add_subtree_format(temp_tree, tvb, offset, 4, ett_status_word_mask, NULL, "Mask for status word #%u: ", i + 1);
1353
0
    proto_tree_add_item(mask_tree, hf_synphasor_status_word_mask_normal_state, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1354
0
    proto_tree_add_item(mask_tree, hf_synphasor_status_word_mask_valid_bits, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1355
0
  }
1356
1357
0
  return offset;
1358
0
}
1359
1360
/* used by 'dissect_config_frame()' to dissect the "channel name"-fields */
1361
static int dissect_CHNAM(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset, int cnt, const char *prefix)
1362
0
{
1363
0
  proto_tree *temp_tree;
1364
0
  int i;
1365
1366
0
  if (0 == cnt)
1367
0
    return offset;
1368
1369
0
  temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, CHNAM_LEN * cnt, ett_conf_phnam, NULL,
1370
0
              "%ss (%u)", prefix, cnt);
1371
1372
  /* dissect the 'cnt' channel names */
1373
0
  for (i = 0; i < cnt; i++) {
1374
0
    char *str;
1375
0
    str = (char *)tvb_get_string_enc(pinfo->pool, tvb, offset, CHNAM_LEN, ENC_ASCII);
1376
0
    proto_tree_add_string_format(temp_tree, hf_synphasor_channel_name, tvb, offset, CHNAM_LEN,
1377
0
            str, "%s #%i: \"%s\"", prefix, i+1, str);
1378
0
    offset += CHNAM_LEN;
1379
0
  }
1380
1381
0
  return offset;
1382
0
}
1383
1384
/* used by 'dissect_config_3_frame()' to dissect the "channel name"-fields */
1385
static int dissect_config_3_CHNAM(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset, int cnt, const char *prefix)
1386
0
{
1387
0
  proto_tree *temp_tree, *chnam_tree;
1388
0
  int i;
1389
0
  uint8_t name_length;
1390
0
  int temp_offset;
1391
0
  int subsection_length = 0;
1392
1393
0
  if (0 == cnt) {
1394
0
    return offset;
1395
0
  }
1396
1397
  /* get the subsection length */
1398
0
  temp_offset = offset;
1399
0
  for (i = 0; i < cnt; i++) {
1400
0
    name_length = get_name_length(tvb, temp_offset);
1401
    /* count the length byte and the actual name */
1402
0
    subsection_length += name_length + 1;
1403
0
    temp_offset += name_length + 1;
1404
0
  }
1405
1406
0
  temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, subsection_length, ett_conf_phnam,
1407
0
              NULL, "%ss (%u)", prefix, cnt);
1408
1409
  /* dissect the 'cnt' channel names */
1410
0
  for (i = 0; i < cnt; i++) {
1411
0
    char *str;
1412
1413
0
    name_length = get_name_length(tvb, offset);
1414
0
    str = (char *)tvb_get_string_enc(pinfo->pool, tvb, offset + 1, name_length, ENC_ASCII);
1415
0
    chnam_tree = proto_tree_add_subtree_format(temp_tree, tvb, offset, name_length + 1, ett_conf,
1416
0
                 NULL, "%s #%i: \"%s\"", prefix, i + 1, str);
1417
1418
0
    proto_tree_add_item(chnam_tree, hf_conf_chnam_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1419
0
    offset += 1;
1420
1421
0
    proto_tree_add_string(chnam_tree, hf_conf_chnam, tvb, offset, 1, str);
1422
0
    offset += name_length;
1423
0
  }
1424
1425
0
  return offset;
1426
0
}
1427
1428
/* dissects a configuration frame (type 1 and 2) and adds fields to 'config_item' */
1429
static int dissect_config_frame(tvbuff_t *tvb, packet_info* pinfo, proto_item *config_item)
1430
0
{
1431
0
  proto_tree *config_tree;
1432
0
  int     offset = 0;
1433
0
  uint16_t      num_pmu, j;
1434
1435
0
  proto_item_set_text   (config_item, "Configuration data");
1436
0
  config_tree = proto_item_add_subtree(config_item, ett_conf);
1437
1438
  /* TIME_BASE and NUM_PMU */
1439
0
  offset += 1; /* skip the reserved byte */
1440
0
  proto_tree_add_item(config_tree, hf_conf_timebase, tvb, offset, 3, ENC_BIG_ENDIAN); offset += 3;
1441
0
  proto_tree_add_item(config_tree, hf_conf_numpmu,   tvb, offset, 2, ENC_BIG_ENDIAN);
1442
  /* add number of included PMUs to the text in the list view  */
1443
0
  num_pmu = tvb_get_ntohs(tvb, offset); offset += 2;
1444
0
  proto_item_append_text(config_item, ", %"PRIu16" PMU(s) included", num_pmu);
1445
1446
  /* dissect the repeating PMU blocks */
1447
0
  for (j = 0; j < num_pmu; j++) {
1448
0
    uint16_t      num_ph, num_an, num_dg;
1449
0
    proto_item *station_item;
1450
0
    proto_tree *station_tree;
1451
0
    proto_tree *temp_tree;
1452
0
    char     *str;
1453
1454
0
    int old_offset = offset; /* to calculate the length of the whole PMU block later */
1455
1456
    /* STN with new tree to add the rest of the PMU block */
1457
0
    str = (char *)tvb_get_string_enc(pinfo->pool, tvb, offset, CHNAM_LEN, ENC_ASCII);
1458
0
    station_tree = proto_tree_add_subtree_format(config_tree, tvb, offset, CHNAM_LEN,
1459
0
                   ett_conf_station, &station_item,
1460
0
                   "Station #%i: \"%s\"", j + 1, str);
1461
0
    offset += CHNAM_LEN;
1462
1463
    /* IDCODE */
1464
0
    proto_tree_add_item(station_tree, hf_idcode_data_source, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1465
1466
    /* FORMAT */
1467
0
    temp_tree = proto_tree_add_subtree(station_tree, tvb, offset, 2, ett_conf_format, NULL,
1468
0
               "Data format in data frame");
1469
0
    proto_tree_add_item(temp_tree, hf_conf_formatb3, tvb, offset, 2, ENC_BIG_ENDIAN);
1470
0
    proto_tree_add_item(temp_tree, hf_conf_formatb2, tvb, offset, 2, ENC_BIG_ENDIAN);
1471
0
    proto_tree_add_item(temp_tree, hf_conf_formatb1, tvb, offset, 2, ENC_BIG_ENDIAN);
1472
0
    proto_tree_add_item(temp_tree, hf_conf_formatb0, tvb, offset, 2, ENC_BIG_ENDIAN);
1473
0
    offset += 2;
1474
1475
    /* PHNMR, ANNMR, DGNMR */
1476
0
    num_ph = tvb_get_ntohs(tvb, offset    );
1477
0
    num_an = tvb_get_ntohs(tvb, offset + 2);
1478
0
    num_dg = tvb_get_ntohs(tvb, offset + 4);
1479
0
    proto_tree_add_uint(station_tree, hf_synphasor_num_phasors, tvb, offset, 2, num_ph);
1480
0
    proto_tree_add_uint(station_tree, hf_synphasor_num_analog_values, tvb, offset + 2, 2, num_an);
1481
0
    proto_tree_add_uint(station_tree, hf_synphasor_num_digital_status_words, tvb, offset + 4, 2, num_dg);
1482
0
    offset += 6;
1483
1484
    /* CHNAM, the channel names */
1485
0
    offset = dissect_CHNAM(tvb, pinfo, station_tree, offset, num_ph     , "Phasor name"      );
1486
0
    offset = dissect_CHNAM(tvb, pinfo, station_tree, offset, num_an     , "Analog value"       );
1487
0
    offset = dissect_CHNAM(tvb, pinfo, station_tree, offset, num_dg * 16, "Digital status label");
1488
1489
    /* PHUNIT, ANUINT and DIGUNIT */
1490
0
    offset = dissect_PHUNIT (tvb, station_tree, offset, num_ph);
1491
0
    offset = dissect_ANUNIT (tvb, station_tree, offset, num_an);
1492
0
    offset = dissect_DIGUNIT(tvb, station_tree, offset, num_dg);
1493
1494
    /* FNOM and CFGCNT */
1495
0
    proto_tree_add_item(station_tree, hf_conf_fnom,   tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1496
0
    proto_tree_add_item(station_tree, hf_conf_cfgcnt, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
1497
1498
    /* set the correct length for the "Station :" item */
1499
0
    proto_item_set_len(station_item, offset - old_offset);
1500
0
  } /* for() PMU blocks */
1501
1502
  /* DATA_RATE */
1503
0
  {
1504
0
    int16_t tmp = tvb_get_ntohis(tvb, offset);
1505
0
    if (tmp > 0)
1506
0
      proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp,
1507
0
                        "%d frame(s) per second", tmp);
1508
0
    else
1509
0
      proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp,
1510
0
                        "1 frame per %d second(s)", (int16_t)-tmp);
1511
0
    offset += 2;
1512
0
  }
1513
1514
0
  return offset;
1515
0
} /* dissect_config_frame() */
1516
1517
/* dissects a configuration frame type 3 and adds fields to 'config_item' */
1518
static int dissect_config_3_frame(tvbuff_t *tvb, packet_info* pinfo, proto_item *config_item)
1519
0
{
1520
0
  proto_tree *config_tree, *wgs84_tree;
1521
0
  int     offset = 0;
1522
0
  uint16_t      num_pmu, j;
1523
1524
0
  proto_item_set_text(config_item, "Configuration data");
1525
0
  config_tree = proto_item_add_subtree(config_item, ett_conf);
1526
1527
  /* CONT_IDX */
1528
0
  proto_tree_add_item(config_tree, hf_cont_idx, tvb, offset, 2, ENC_BIG_ENDIAN);
1529
0
  offset += 2;
1530
1531
  /* TIME_BASE and NUM_PMU */
1532
0
  offset += 1; /* skip the reserved byte */
1533
1534
0
  proto_tree_add_item(config_tree, hf_conf_timebase, tvb, offset, 3, ENC_BIG_ENDIAN);
1535
0
  offset += 3;
1536
1537
0
  proto_tree_add_item(config_tree, hf_conf_numpmu,   tvb, offset, 2, ENC_BIG_ENDIAN);
1538
1539
  /* add number of included PMUs to the text in the list view  */
1540
0
  num_pmu = tvb_get_ntohs(tvb, offset);
1541
0
  offset += 2;
1542
1543
0
  proto_item_append_text(config_item, ", %"PRIu16" PMU(s) included", num_pmu);
1544
1545
  /* dissect the repeating PMU blocks */
1546
0
  for (j = 0; j < num_pmu; j++) {
1547
0
    uint16_t   num_ph, num_an, num_dg, i;
1548
0
    uint8_t    name_length;
1549
0
    int        old_offset;
1550
0
    float      pmu_lat, pmu_long, pmu_elev;
1551
0
    proto_item *station_item;
1552
0
    proto_tree *station_tree;
1553
0
    proto_tree *temp_tree;
1554
0
    char       *str, *service_class;
1555
0
    char       *unspecified_location = "Unspecified Location";
1556
0
    uint8_t    g_pmu_id_array[G_PMU_ID_LEN];
1557
1558
0
    old_offset = offset; /* to calculate the length of the whole PMU block later */
1559
1560
    /* STN with new tree to add the rest of the PMU block */
1561
0
    name_length = get_name_length(tvb, offset);
1562
0
    str = (char *)tvb_get_string_enc(pinfo->pool, tvb, offset + 1, name_length, ENC_ASCII);
1563
0
    station_tree = proto_tree_add_subtree_format(config_tree, tvb, offset, name_length + 1,
1564
0
                   ett_conf_station, &station_item,
1565
0
                   "Station #%i: \"%s\"", j + 1, str);
1566
1567
    /* Station Name Length */
1568
0
    proto_tree_add_item(station_tree, hf_station_name_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1569
0
    offset += 1;
1570
1571
    /* Station Name */
1572
0
    proto_tree_add_string(station_tree, hf_station_name, tvb, offset, 1, str);
1573
0
    offset += name_length;
1574
1575
    /* IDCODE */
1576
0
    proto_tree_add_item(station_tree, hf_idcode_data_source, tvb, offset, 2, ENC_BIG_ENDIAN);
1577
0
    offset += 2;
1578
1579
    /* G_PMU_ID */
1580
    /* A 128 bit display as raw bytes */
1581
0
    for (i = 0; i < G_PMU_ID_LEN; i++) {
1582
0
      g_pmu_id_array[i] = tvb_get_uint8(tvb, offset + i);
1583
0
    }
1584
1585
0
    proto_tree_add_bytes_format(station_tree, hf_g_pmu_id, tvb, offset, G_PMU_ID_LEN, 0,
1586
0
              "Global PMU ID (raw bytes): %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
1587
0
              g_pmu_id_array[0], g_pmu_id_array[1], g_pmu_id_array[2], g_pmu_id_array[3],
1588
0
              g_pmu_id_array[4], g_pmu_id_array[5], g_pmu_id_array[6], g_pmu_id_array[7],
1589
0
              g_pmu_id_array[8], g_pmu_id_array[9], g_pmu_id_array[10], g_pmu_id_array[11],
1590
0
              g_pmu_id_array[12], g_pmu_id_array[13], g_pmu_id_array[14], g_pmu_id_array[15]);
1591
0
    offset += G_PMU_ID_LEN;
1592
1593
    /* FORMAT */
1594
0
    temp_tree = proto_tree_add_subtree(station_tree, tvb, offset, 2, ett_conf_format, NULL,
1595
0
               "Data format in data frame");
1596
0
    proto_tree_add_item(temp_tree, hf_conf_formatb3, tvb, offset, 2, ENC_BIG_ENDIAN);
1597
0
    proto_tree_add_item(temp_tree, hf_conf_formatb2, tvb, offset, 2, ENC_BIG_ENDIAN);
1598
0
    proto_tree_add_item(temp_tree, hf_conf_formatb1, tvb, offset, 2, ENC_BIG_ENDIAN);
1599
0
    proto_tree_add_item(temp_tree, hf_conf_formatb0, tvb, offset, 2, ENC_BIG_ENDIAN);
1600
0
    offset += 2;
1601
1602
    /* PHNMR, ANNMR, DGNMR */
1603
0
    num_ph = tvb_get_ntohs(tvb, offset    );
1604
0
    num_an = tvb_get_ntohs(tvb, offset + 2);
1605
0
    num_dg = tvb_get_ntohs(tvb, offset + 4);
1606
0
    proto_tree_add_uint(station_tree, hf_synphasor_num_phasors, tvb, offset, 2, num_ph);
1607
0
    proto_tree_add_uint(station_tree, hf_synphasor_num_analog_values, tvb, offset + 2, 2, num_an);
1608
0
    proto_tree_add_uint(station_tree, hf_synphasor_num_digital_status_words, tvb, offset + 4, 2, num_dg);
1609
0
    offset += 6;
1610
1611
    /* CHNAM, the channel names */
1612
0
    offset = dissect_config_3_CHNAM(tvb, pinfo, station_tree, offset, num_ph, "Phasor name");
1613
0
    offset = dissect_config_3_CHNAM(tvb, pinfo, station_tree, offset, num_an, "Analog value");
1614
0
    offset = dissect_config_3_CHNAM(tvb, pinfo, station_tree, offset, num_dg * 16, "Digital label");
1615
1616
    /* PHUNIT, ANUINT and DIGUNIT */
1617
0
    offset = dissect_PHSCALE(tvb, station_tree, offset, num_ph);
1618
0
    offset = dissect_ANSCALE(tvb, station_tree, offset, num_an);
1619
1620
0
    offset = dissect_DIGUNIT(tvb, station_tree, offset, num_dg);
1621
1622
    /* subtree for coordinate info*/
1623
0
    wgs84_tree = proto_tree_add_subtree_format(station_tree, tvb, offset, 12, ett_conf_wgs84, NULL,
1624
0
                 "World Geodetic System 84 data");
1625
1626
    /* preview latitude, longitude, and elevation values */
1627
    /* INFINITY is an unspecified location, otherwise use the actual float value */
1628
0
    pmu_lat = tvb_get_ntohieee_float(tvb, offset);
1629
0
    pmu_long = tvb_get_ntohieee_float(tvb, offset + 4);
1630
0
    pmu_elev = tvb_get_ntohieee_float(tvb, offset + 8);
1631
1632
    /* PMU_LAT */
1633
0
    if (isinf(pmu_lat)) {
1634
0
      proto_tree_add_float_format_value(wgs84_tree, hf_conf_pmu_lat_unknown, tvb, offset,
1635
0
                4, INFINITY, "%s", unspecified_location);
1636
0
    }
1637
0
    else {
1638
0
      proto_tree_add_item(wgs84_tree, hf_conf_pmu_lat, tvb, offset, 4, ENC_BIG_ENDIAN);
1639
0
    }
1640
0
    offset += 4;
1641
1642
    /* PMU_LON */
1643
0
    if (isinf(pmu_long)) {
1644
0
      proto_tree_add_float_format_value(wgs84_tree, hf_conf_pmu_lon_unknown, tvb, offset,
1645
0
                4, INFINITY, "%s", unspecified_location);
1646
0
    }
1647
0
    else {
1648
0
      proto_tree_add_item(wgs84_tree, hf_conf_pmu_lon, tvb, offset, 4, ENC_BIG_ENDIAN);
1649
0
    }
1650
0
    offset += 4;
1651
1652
    /* PMU_ELEV */
1653
0
    if (isinf(pmu_elev)) {
1654
0
      proto_tree_add_float_format_value(wgs84_tree, hf_conf_pmu_elev_unknown, tvb, offset,
1655
0
                4, INFINITY, "%s", unspecified_location);
1656
0
    }
1657
0
    else {
1658
0
      proto_tree_add_item(wgs84_tree, hf_conf_pmu_elev, tvb, offset, 4, ENC_BIG_ENDIAN);
1659
0
    }
1660
0
    offset += 4;
1661
1662
    /* SVC_CLASS */
1663
0
    service_class = (char *)tvb_get_string_enc(pinfo->pool, tvb, offset, 1, ENC_ASCII);
1664
0
    if ((strcmp(service_class, "P") == 0) || (strcmp(service_class, "p") == 0)) {
1665
0
      proto_tree_add_string(station_tree, hf_conf_svc_class, tvb, offset, 1, "Protection");
1666
0
    }
1667
0
    else if ((strcmp(service_class, "M") == 0) || (strcmp(service_class, "m") == 0)) {
1668
0
      proto_tree_add_string(station_tree, hf_conf_svc_class, tvb, offset, 1, "Monitoring");
1669
0
    }
1670
0
    else {
1671
0
      proto_tree_add_string(station_tree, hf_conf_svc_class, tvb, offset, 1, "Unknown");
1672
0
    }
1673
0
    offset += 1;
1674
1675
    /* WINDOW */
1676
0
    proto_tree_add_item(station_tree, hf_conf_window, tvb, offset, 4, ENC_BIG_ENDIAN);
1677
0
    offset += 4;
1678
1679
    /*GRP_DLY */
1680
0
    proto_tree_add_item(station_tree, hf_conf_grp_dly, tvb, offset, 4, ENC_BIG_ENDIAN);
1681
0
    offset += 4;
1682
1683
    /* FNOM and CFGCNT */
1684
0
    proto_tree_add_item(station_tree, hf_conf_fnom,   tvb, offset, 2, ENC_BIG_ENDIAN);
1685
0
    offset += 2;
1686
1687
0
    proto_tree_add_item(station_tree, hf_conf_cfgcnt, tvb, offset, 2, ENC_BIG_ENDIAN);
1688
0
    offset += 2;
1689
1690
    /* set the correct length for the "Station :" item */
1691
0
    proto_item_set_len(station_item, offset - old_offset);
1692
0
  } /* for() PMU blocks */
1693
1694
  /* DATA_RATE */
1695
0
  {
1696
0
    int16_t tmp = tvb_get_ntohis(tvb, offset);
1697
0
    if (tmp > 0) {
1698
0
      proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp,
1699
0
              "%d frame(s) per second", tmp);
1700
0
    }
1701
0
    else {
1702
0
      proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp,
1703
0
              "1 frame per %d second(s)", (int16_t)-tmp);
1704
0
    }
1705
0
    offset += 2;
1706
0
  }
1707
1708
0
  return offset;
1709
0
} /* dissect_config_3_frame() */
1710
1711
/* calculates the size (in bytes) of a data frame that the config_block describes */
1712
0
#define SYNP_BLOCKSIZE(x) (2                 /* STAT    */ \
1713
0
       + wmem_array_get_count((x).phasors) * (integer == (x).format_ph ? 4 : 8) /* PHASORS */ \
1714
0
       +                       (integer == (x).format_fr ? 4 : 8) /* (D)FREQ */ \
1715
0
       + wmem_array_get_count((x).analogs) * (integer == (x).format_an ? 2 : 4) /* ANALOG  */ \
1716
0
       + (x).num_dg * 2)             /* DIGITAL */
1717
1718
/* Dissects a data frame */
1719
static int dissect_data_frame(tvbuff_t    *tvb,
1720
            proto_item  *data_item, /* all items are placed beneath this item   */
1721
            packet_info *pinfo)     /* used to find the data from a CFG-2 or CFG-3 frame */
1722
0
{
1723
0
  proto_tree  *data_tree;
1724
0
  int   offset   = 0;
1725
0
  unsigned    i;
1726
0
  config_frame  *conf;
1727
1728
0
  proto_item_set_text(data_item, "Measurement data");
1729
0
  data_tree = proto_item_add_subtree(data_item, ett_data);
1730
1731
  /* search for configuration information to dissect the frame */
1732
0
  {
1733
0
    bool config_found = false;
1734
0
    conf = (config_frame *)p_get_proto_data(wmem_file_scope(), pinfo, proto_synphasor, 0);
1735
1736
0
    if (conf) {
1737
      /* check if the size of the current frame is the
1738
         size of the frame the config_frame describes */
1739
0
      size_t reported_size = 0;
1740
0
      for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
1741
0
        config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
1742
0
        reported_size += SYNP_BLOCKSIZE(*block);
1743
0
      }
1744
1745
0
      if (tvb_reported_length(tvb) == reported_size) {
1746
        // Add link to CFG Frame
1747
0
        proto_item* item = proto_tree_add_uint(data_tree, hf_cfg_frame_num, tvb, 0,0, conf->fnum);
1748
0
        proto_item_set_generated(item);
1749
0
        config_found = true;
1750
0
      }
1751
0
    }
1752
1753
0
    if (!config_found) {
1754
0
      proto_item_append_text(data_item, ", no configuration frame found");
1755
0
      return 0;
1756
0
    }
1757
0
  }
1758
1759
  /* dissect a PMU block for every config_block in the frame */
1760
0
  for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
1761
0
    config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
1762
1763
0
    proto_tree *block_tree = proto_tree_add_subtree_format(data_tree, tvb, offset, SYNP_BLOCKSIZE(*block),
1764
0
                       ett_data_block, NULL,
1765
0
                       "Station: \"%s\"", block->name);
1766
1767
    /* STAT */
1768
0
    proto_tree *temp_tree = proto_tree_add_subtree(block_tree, tvb, offset, 2, ett_data_stat, NULL, "Flags");
1769
1770
0
    proto_item *temp_item = proto_tree_add_item(temp_tree, hf_data_statb15to14, tvb, offset, 2, ENC_BIG_ENDIAN);
1771
0
    uint16_t flag_bits = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN)  >> 14; // Get bits 15-14
1772
0
    if (flag_bits != 0) {
1773
0
      expert_add_info(pinfo, temp_item, &ei_synphasor_data_error);
1774
0
    }
1775
0
    temp_item = proto_tree_add_item(temp_tree, hf_data_statb13,     tvb, offset, 2, ENC_BIG_ENDIAN);
1776
0
    flag_bits = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN); // Get flag bits
1777
0
    if ((flag_bits >> 13)&1) { // Check 13 bit
1778
0
      expert_add_info(pinfo, temp_item, &ei_synphasor_pmu_not_sync);
1779
0
    }
1780
0
    proto_tree_add_item(temp_tree, hf_data_statb12,     tvb, offset, 2, ENC_BIG_ENDIAN);
1781
0
    proto_tree_add_item(temp_tree, hf_data_statb11,     tvb, offset, 2, ENC_BIG_ENDIAN);
1782
0
    proto_tree_add_item(temp_tree, hf_data_statb10,     tvb, offset, 2, ENC_BIG_ENDIAN);
1783
0
    proto_tree_add_item(temp_tree, hf_data_statb09,     tvb, offset, 2, ENC_BIG_ENDIAN);
1784
0
    proto_tree_add_item(temp_tree, hf_data_statb08to06, tvb, offset, 2, ENC_BIG_ENDIAN);
1785
0
    proto_tree_add_item(temp_tree, hf_data_statb05to04, tvb, offset, 2, ENC_BIG_ENDIAN);
1786
0
    proto_tree_add_item(temp_tree, hf_data_statb03to00, tvb, offset, 2, ENC_BIG_ENDIAN);
1787
0
    offset += 2;
1788
1789
    /* PHASORS, (D)FREQ, ANALOG, and DIGITAL */
1790
0
    offset = dissect_PHASORS(tvb, block_tree, block, offset);
1791
0
    offset = dissect_DFREQ  (tvb, block_tree, block, offset);
1792
0
    offset = dissect_ANALOG (tvb, block_tree, block, offset);
1793
0
    offset = dissect_DIGITAL(tvb, block_tree, block, offset);
1794
0
  }
1795
0
  return offset;
1796
0
} /* dissect_data_frame() */
1797
1798
/* Dissects a command frame and adds fields to config_item.
1799
 *
1800
 * 'pinfo' is used to add the type of command
1801
 * to the INFO column in the packet list.
1802
 */
1803
static int dissect_command_frame(tvbuff_t    *tvb,
1804
         proto_item  *command_item,
1805
         packet_info *pinfo)
1806
0
{
1807
0
  proto_tree *command_tree;
1808
0
  unsigned      tvbsize   = tvb_reported_length(tvb);
1809
0
  const char *s;
1810
1811
0
  proto_item_set_text(command_item, "Command data");
1812
0
  command_tree = proto_item_add_subtree(command_item, ett_command);
1813
1814
  /* CMD */
1815
0
  proto_tree_add_item(command_tree, hf_command, tvb, 0, 2, ENC_BIG_ENDIAN);
1816
1817
0
  s = rval_to_str_const(tvb_get_ntohs(tvb, 0), command_names, "invalid command");
1818
0
  col_append_str(pinfo->cinfo, COL_INFO, ", ");
1819
0
  col_append_str(pinfo->cinfo, COL_INFO, s);
1820
1821
0
  if (tvbsize > 2) {
1822
0
    if (tvb_get_ntohs(tvb, 0) == 0x0008) {
1823
      /* Command: Extended Frame, the extra data is ok */
1824
0
      proto_item *ti = proto_tree_add_item(command_tree, hf_synphasor_extended_frame_data, tvb, 2, tvbsize - 2, ENC_NA);
1825
0
      if (tvbsize % 2)
1826
0
        expert_add_info(pinfo, ti, &ei_synphasor_extended_frame_data);
1827
0
    }
1828
0
    else
1829
0
      proto_tree_add_item(command_tree, hf_synphasor_unknown_data, tvb, 2, tvbsize - 2, ENC_NA);
1830
0
  }
1831
1832
0
  return tvbsize;
1833
0
} /* dissect_command_frame() */
1834
1835
/* Dissects the header (common to all types of frames) and then calls
1836
 * one of the subdissectors (declared above) for the rest of the frame.
1837
 */
1838
static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1839
19
{
1840
19
  uint8_t frame_type;
1841
19
  uint16_t crc;
1842
19
  unsigned  tvbsize = tvb_reported_length(tvb);
1843
1844
  /* some heuristics */
1845
19
  if (tvbsize < 17        /* 17 bytes = header frame with only a
1846
                 NULL character, useless but valid */
1847
19
   || tvb_get_uint8(tvb, 0) != 0xAA) /* every synchrophasor frame starts with 0xAA */
1848
18
    return 0;
1849
1850
  /* write the protocol name to the info column */
1851
1
  col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME);
1852
1853
1
  frame_type = tvb_get_uint8(tvb, 1) >> 4;
1854
1855
1
  col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(frame_type, typenames, "invalid packet type"));
1856
1857
  /* CFG-2, CFG3, and DATA frames need special treatment during the first run:
1858
   * For CFG-2 & CFG-3 frames, a 'config_frame' struct is created to hold the
1859
   * information necessary to decode DATA frames. A pointer to this
1860
   * struct is saved in the conversation and is copied to the
1861
   * per-packet information if a DATA frame is dissected.
1862
   */
1863
1
  if (!pinfo->fd->visited) {
1864
1
    if (CFG2 == frame_type &&
1865
1
        check_crc(tvb, &crc)) {
1866
0
      conversation_t *conversation;
1867
1868
      /* fill the config_frame */
1869
0
      config_frame *frame = config_frame_fast(tvb);
1870
0
      frame->fnum = pinfo->num;
1871
1872
      /* find a conversation, create a new one if none exists */
1873
0
      conversation = find_or_create_conversation(pinfo);
1874
1875
      /* remove data from a previous CFG-2 frame, only
1876
       * the most recent configuration frame is relevant */
1877
0
      if (conversation_get_proto_data(conversation, proto_synphasor))
1878
0
        conversation_delete_proto_data(conversation, proto_synphasor);
1879
1880
0
      conversation_add_proto_data(conversation, proto_synphasor, frame);
1881
0
    }
1882
1
    else if ((CFG3 == frame_type) && check_crc(tvb, &crc)) {
1883
0
      conversation_t *conversation;
1884
0
      config_frame *frame;
1885
1886
      /* fill the config_frame */
1887
0
      frame = config_3_frame_fast(tvb);
1888
0
      frame->fnum = pinfo->num;
1889
1890
      /* find a conversation, create a new one if none exists */
1891
0
      conversation = find_or_create_conversation(pinfo);
1892
1893
      /* remove data from a previous CFG-3 frame, only
1894
       * the most recent configuration frame is relevant */
1895
0
      if (conversation_get_proto_data(conversation, proto_synphasor)) {
1896
0
        conversation_delete_proto_data(conversation, proto_synphasor);
1897
0
      }
1898
1899
0
      conversation_add_proto_data(conversation, proto_synphasor, frame);
1900
0
    }
1901
    // Add conf to any frame for dissection fracsec
1902
1
    conversation_t *conversation = find_conversation_pinfo(pinfo, 0);
1903
1
    if (conversation) {
1904
1
      config_frame *conf = (config_frame *)conversation_get_proto_data(conversation, proto_synphasor);
1905
      /* no problem if 'conf' is NULL, the frame dissector checks this again */
1906
1
      p_add_proto_data(wmem_file_scope(), pinfo, proto_synphasor, 0, conf);
1907
1
    }
1908
1
  } /* if (!visited) */
1909
1910
1
  {
1911
1
    proto_tree *synphasor_tree;
1912
1
    proto_item *temp_item;
1913
1
    proto_item *sub_item;
1914
1915
1
    int     offset;
1916
1
    uint16_t      framesize;
1917
1
    tvbuff_t   *sub_tvb;
1918
1
    bool       crc_good;
1919
1920
1
    temp_item = proto_tree_add_item(tree, proto_synphasor, tvb, 0, -1, ENC_NA);
1921
1
    proto_item_append_text(temp_item, ", %s", val_to_str_const(frame_type, typenames,
1922
1
                     ", invalid packet type"));
1923
1924
    /* synphasor_tree is where from now on all new elements for this protocol get added */
1925
1
    synphasor_tree = proto_item_add_subtree(temp_item, ett_synphasor);
1926
    // Add pinfo for dissection fracsec
1927
1
    framesize = dissect_header(tvb, synphasor_tree, pinfo);
1928
1
    offset = 14; /* header is 14 bytes long */
1929
1930
    /* check CRC, call appropriate subdissector for the rest of the frame if CRC is correct*/
1931
1
    sub_item  = proto_tree_add_item(synphasor_tree, hf_synphasor_data, tvb, offset, tvbsize - 16, ENC_NA);
1932
1
    crc_good = check_crc(tvb, &crc);
1933
1
    proto_tree_add_checksum(synphasor_tree, tvb, tvbsize - 2, hf_synphasor_checksum, hf_synphasor_checksum_status, &ei_synphasor_checksum,
1934
1
                pinfo, crc16_x25_ccitt_tvb(tvb, tvb_get_ntohs(tvb, 2) - 2), ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
1935
1
    if (!crc_good) {
1936
0
      proto_item_append_text(sub_item,  ", not dissected because of wrong checksum");
1937
0
    }
1938
1
    else {
1939
      /* create a new tvb to pass to the subdissector
1940
         '-16': length of header + 2 CRC bytes */
1941
1
      sub_tvb = tvb_new_subset_length_caplen(tvb, offset, tvbsize - 16, framesize - 16);
1942
1943
      /* call subdissector */
1944
1
      switch (frame_type) {
1945
0
        case DATA:
1946
0
          dissect_data_frame(sub_tvb, sub_item, pinfo);
1947
0
          break;
1948
0
        case HEADER: /* no further dissection is done/needed */
1949
0
          proto_item_append_text(sub_item, "Header Frame");
1950
0
          break;
1951
0
        case CFG1:
1952
0
        case CFG2:
1953
0
          dissect_config_frame(sub_tvb, pinfo, sub_item);
1954
0
          break;
1955
0
        case CMD:
1956
0
          dissect_command_frame(sub_tvb, sub_item, pinfo);
1957
0
          break;
1958
0
        case CFG3:
1959
          /* Note:  The C37.118-2.2001 standard is vague on how to handle fragmented frames.
1960
             Until further clarification is given, fragmented frames with the CONT_IDX
1961
             are not supported. */
1962
0
          if (tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN) != 0) {
1963
0
            proto_item_append_text(sub_item, ", CFG-3 Fragmented Frame (Not Supported)");
1964
0
          }
1965
0
          else {
1966
0
            dissect_config_3_frame(sub_tvb, pinfo, sub_item);
1967
0
          }
1968
0
          break;
1969
0
        default:
1970
0
          proto_item_append_text(sub_item, " of unknown type");
1971
1
      }
1972
0
      proto_item_append_text(temp_item, " [correct]");
1973
0
    }
1974
1975
    /* remaining 2 bytes are the CRC */
1976
1
  }
1977
1978
0
  return tvb_reported_length(tvb);
1979
1
} /* dissect_common() */
1980
1981
/* called for synchrophasors over UDP */
1982
static int dissect_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1983
15
{
1984
15
  return dissect_common(tvb, pinfo, tree, data);
1985
15
}
1986
1987
/* callback for 'tcp_dissect_pdus()' to give it the length of the frame */
1988
static unsigned get_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb,
1989
                            int offset, void *data _U_)
1990
4
{
1991
4
  return tvb_get_ntohs(tvb, offset + 2);
1992
4
}
1993
1994
static int dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1995
2
{
1996
2
  tcp_dissect_pdus(tvb, pinfo, tree, true, 4, get_pdu_length, dissect_common, data);
1997
1998
2
  return tvb_reported_length(tvb);
1999
2
}
2000
2001
/*******************************************************************/
2002
/* after this line:  Wireshark Register Routines                   */
2003
/*******************************************************************/
2004
2005
/* Register Synchrophasor Protocol with Wireshark*/
2006
void proto_register_synphasor(void)
2007
14
{
2008
14
  static hf_register_info hf[] = {
2009
    /* Sync word */
2010
14
    { &hf_sync,
2011
14
    { "Synchronization word", "synphasor.sync", FT_UINT16, BASE_HEX,
2012
14
      NULL, 0x0, NULL, HFILL }},
2013
2014
    /* Flags in the Sync word */
2015
14
      { &hf_sync_frtype,
2016
14
      { "Frame Type", "synphasor.frtype", FT_UINT16, BASE_HEX,
2017
14
         VALS(typenames), 0x0070, NULL, HFILL }},
2018
2019
14
      { &hf_sync_version,
2020
14
      { "Version",  "synphasor.version", FT_UINT16, BASE_DEC,
2021
14
        VALS(versionnames), 0x000F, NULL, HFILL }},
2022
2023
14
    { &hf_frsize,
2024
14
    { "Framesize", "synphasor.frsize", FT_UINT16, BASE_DEC | BASE_UNIT_STRING,
2025
14
      UNS(&units_byte_bytes), 0x0, NULL, HFILL }},
2026
2027
14
    { &hf_station_name_len,
2028
14
    { "Station name length", "synphasor.station_name_len", FT_UINT8,
2029
14
      BASE_DEC | BASE_UNIT_STRING, UNS(&units_byte_bytes), 0x0, NULL, HFILL }},
2030
2031
14
    { &hf_station_name,
2032
14
    { "Station name", "synphasor.station_name", FT_STRING, BASE_NONE,
2033
14
      NULL, 0x0, NULL, HFILL }},
2034
2035
14
    { &hf_idcode_stream_source,
2036
14
    { "PMU/DC ID number (Stream source ID)", "synphasor.idcode_stream_source", FT_UINT16, BASE_DEC,
2037
14
      NULL, 0x0, NULL, HFILL }},
2038
2039
14
    { &hf_idcode_data_source,
2040
14
    { "PMU/DC ID number (Data source ID)", "synphasor.idcode_data_source", FT_UINT16, BASE_DEC,
2041
14
      NULL, 0x0, NULL, HFILL }},
2042
2043
14
    { &hf_g_pmu_id,
2044
14
    { "Global PMU ID (raw hex bytes)", "synphasor.gpmuid", FT_BYTES, BASE_NONE,
2045
14
      NULL, 0x0, NULL, HFILL }},
2046
2047
14
    { &hf_soc,
2048
14
    { "SOC time stamp", "synphasor.soc", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC,
2049
14
      NULL, 0x0, NULL, HFILL }},
2050
2051
    /* Time quality flags in fracsec */
2052
14
    { &hf_timeqal_lsdir,
2053
14
    { "Leap second direction", "synphasor.timeqal.lsdir", FT_BOOLEAN, 8,
2054
14
      TFS(&leapseconddir), 0x40, NULL, HFILL }},
2055
2056
14
    { &hf_timeqal_lsocc,
2057
14
    { "Leap second occurred", "synphasor.timeqal.lsocc", FT_BOOLEAN, 8,
2058
14
      NULL, 0x20, NULL, HFILL }},
2059
2060
14
    { &hf_timeqal_lspend,
2061
14
    { "Leap second pending", "synphasor.timeqal.lspend", FT_BOOLEAN, 8,
2062
14
      NULL, 0x10, NULL, HFILL }},
2063
2064
14
    { &hf_timeqal_timequalindic,
2065
14
    { "Message Time Quality indicator code", "synphasor.timeqal.timequalindic", FT_UINT8, BASE_HEX,
2066
14
      VALS(timequalcodes), 0x0F, NULL, HFILL }},
2067
2068
    /* Fraction of second */
2069
14
    { &hf_fracsec_raw,
2070
14
    { "Fraction of second (raw)", "synphasor.fracsec_raw", FT_UINT24, BASE_DEC,
2071
14
      NULL, 0x0, NULL, HFILL }},
2072
2073
14
    { &hf_fracsec_ms,
2074
14
    { "Fraction of second", "synphasor.fracsec_ms", FT_FLOAT, BASE_NONE | BASE_UNIT_STRING,
2075
14
      UNS(&units_millisecond_milliseconds), 0x0, NULL, HFILL }},
2076
2077
  /* Data types for configuration frames */
2078
14
    { &hf_cont_idx,
2079
14
    { "Continuation index", "synphasor.conf.contindx", FT_UINT16, BASE_DEC,
2080
14
      NULL, 0x0, NULL, HFILL }},
2081
2082
14
    { &hf_conf_timebase,
2083
14
    { "Resolution of fractional second time stamp", "synphasor.conf.timebase", FT_UINT24, BASE_DEC,
2084
14
      NULL, 0x0, NULL, HFILL }},
2085
2086
14
    { &hf_conf_numpmu,
2087
14
    { "Number of PMU blocks included in the frame", "synphasor.conf.numpmu", FT_UINT16, BASE_DEC,
2088
14
      NULL, 0x0, NULL, HFILL }},
2089
2090
    /* Bits in the FORMAT word */
2091
14
    { &hf_conf_formatb3,
2092
14
    { "FREQ/DFREQ format", "synphasor.conf.dfreq_format", FT_BOOLEAN, 16,
2093
14
      TFS(&conf_formatb123names), 0x8, NULL, HFILL }},
2094
2095
14
    { &hf_conf_formatb2,
2096
14
    { "Analog values format", "synphasor.conf.analog_format", FT_BOOLEAN, 16,
2097
14
      TFS(&conf_formatb123names), 0x4, NULL, HFILL }},
2098
2099
14
    { &hf_conf_formatb1,
2100
14
    { "Phasor format", "synphasor.conf.phasor_format", FT_BOOLEAN, 16,
2101
14
      TFS(&conf_formatb123names), 0x2, NULL, HFILL }},
2102
2103
14
    { &hf_conf_formatb0,
2104
14
    { "Phasor notation", "synphasor.conf.phasor_notation", FT_BOOLEAN, 16,
2105
14
      TFS(&conf_formatb0names), 0x1, NULL, HFILL }},
2106
2107
14
    { &hf_conf_chnam_len,
2108
14
    { "Channel name length", "synphasor.conf.chnam_len", FT_UINT8,
2109
14
      BASE_DEC | BASE_UNIT_STRING, UNS(&units_byte_bytes), 0x0, NULL, HFILL }},
2110
2111
14
    { &hf_conf_chnam,
2112
14
    { "Channel name", "synphasor.conf.chnam", FT_STRING, BASE_NONE,
2113
14
      NULL, 0x0, NULL, HFILL }},
2114
2115
14
    { &hf_conf_phasor_mod_b15,
2116
14
    { "Modification", "synphasor.conf.phasor_mod.type_not_def", FT_BOOLEAN, 16,
2117
14
      TFS(&conf_phasor_mod_b15), 0x8000, NULL, HFILL }},
2118
2119
14
    { &hf_conf_phasor_mod_b10,
2120
14
    { "Modification", "synphasor.conf.phasor_mod.pseudo_phasor", FT_BOOLEAN, 16,
2121
14
      TFS(&conf_phasor_mod_b10), 0x0400, NULL, HFILL }},
2122
2123
14
    { &hf_conf_phasor_mod_b09,
2124
14
    { "Modification", "synphasor.conf.phasor_mod.phase_rotation", FT_BOOLEAN, 16,
2125
14
      TFS(&conf_phasor_mod_b09), 0x0200, NULL, HFILL }},
2126
2127
14
    { &hf_conf_phasor_mod_b08,
2128
14
    { "Modification", "synphasor.conf.phasor_mod.phase_calibration", FT_BOOLEAN, 16,
2129
14
      TFS(&conf_phasor_mod_b08), 0x0100, NULL, HFILL }},
2130
2131
14
    { &hf_conf_phasor_mod_b07,
2132
14
    { "Modification", "synphasor.conf.phasor_mod.mag_calibration", FT_BOOLEAN, 16,
2133
14
      TFS(&conf_phasor_mod_b07), 0x0080, NULL, HFILL }},
2134
2135
14
    { &hf_conf_phasor_mod_b06,
2136
14
    { "Modification", "synphasor.conf.phasor_mod.filtered", FT_BOOLEAN, 16,
2137
14
      TFS(&conf_phasor_mod_b06), 0x0040, NULL, HFILL }},
2138
2139
14
    { &hf_conf_phasor_mod_b05,
2140
14
    { "Modification", "synphasor.conf.phasor_mod.downsampled", FT_BOOLEAN, 16,
2141
14
      TFS(&conf_phasor_mod_b05), 0x0020, NULL, HFILL }},
2142
2143
14
    { &hf_conf_phasor_mod_b04,
2144
14
    { "Modification", "synphasor.conf.phasor_mod.downsampled_fir", FT_BOOLEAN, 16,
2145
14
      TFS(&conf_phasor_mod_b04), 0x0010, NULL, HFILL }},
2146
2147
14
    { &hf_conf_phasor_mod_b03,
2148
14
    { "Modification", "synphasor.conf.phasor_mod.downsampled_reselect", FT_BOOLEAN, 16,
2149
14
      TFS(&conf_phasor_mod_b03), 0x0008, NULL, HFILL }},
2150
2151
14
    { &hf_conf_phasor_mod_b02,
2152
14
    { "Modification", "synphasor.conf.phasor_mod.upsampled_extrapolation", FT_BOOLEAN, 16,
2153
14
      TFS(&conf_phasor_mod_b02), 0x0004, NULL, HFILL }},
2154
2155
14
    { &hf_conf_phasor_mod_b01,
2156
14
    { "Modification", "synphasor.conf.phasor_mod.upsampled_interpolation", FT_BOOLEAN, 16,
2157
14
      TFS(&conf_phasor_mod_b01), 0x0002, NULL, HFILL }},
2158
2159
14
    { &hf_conf_phasor_type_b03,
2160
14
    { "Phasor Type", "synphasor.conf.phasor_type", FT_BOOLEAN, 8,
2161
14
      TFS(&conf_phasor_type_b03), 0x8, NULL, HFILL }},
2162
2163
14
    { &hf_conf_phasor_type_b02to00,
2164
14
    { "Phasor Type", "synphasor.conf.phasor_component", FT_UINT8, BASE_HEX,
2165
14
      VALS(conf_phasor_type_b02to00), 0x7, NULL, HFILL }},
2166
2167
14
    { &hf_conf_phasor_user_data,
2168
14
    { "Binary format", "synphasor.conf.phasor_user_flags", FT_BOOLEAN, 8,
2169
14
      TFS(&conf_phasor_user_defined), 0xff, NULL, HFILL }},
2170
2171
14
    { &hf_conf_phasor_scale_factor,
2172
14
    { "Phasor scale factor", "synphasor.conf.phasor_scale_factor", FT_FLOAT,
2173
14
      BASE_NONE, NULL, 0x0, NULL, HFILL }},
2174
2175
14
    { &hf_conf_phasor_angle_offset,
2176
14
    { "Phasor angle offset", "synphasor.conf.phasor_angle_offset", FT_FLOAT,
2177
14
      BASE_NONE | BASE_UNIT_STRING, UNS(&units_degree_degrees), 0x0, NULL, HFILL }},
2178
2179
14
    { &hf_conf_analog_scale_factor,
2180
14
    { "Analog scale factor", "synphasor.conf.analog_scale_factor", FT_FLOAT,
2181
14
      BASE_NONE, NULL, 0x0, NULL, HFILL }},
2182
2183
14
    { &hf_conf_analog_offset,
2184
14
    { "Analog offset", "synphasor.conf.analog_offset", FT_FLOAT,
2185
14
      BASE_NONE, NULL, 0x0, NULL, HFILL }},
2186
2187
14
    { &hf_conf_pmu_lat,
2188
14
    { "PMU Latitude", "synphasor.conf.pmu_latitude", FT_FLOAT,
2189
14
      BASE_NONE | BASE_UNIT_STRING, UNS(&units_degree_degrees), 0x0, NULL, HFILL }},
2190
2191
14
    { &hf_conf_pmu_lon,
2192
14
    { "PMU Longitude", "synphasor.conf.pmu_longitude", FT_FLOAT,
2193
14
      BASE_NONE | BASE_UNIT_STRING, UNS(&units_degree_degrees), 0x0, NULL, HFILL }},
2194
2195
14
    { &hf_conf_pmu_elev,
2196
14
    { "PMU Elevation", "synphasor.conf.pmu_elevation", FT_FLOAT,
2197
14
      BASE_NONE | BASE_UNIT_STRING, UNS(&units_meter_meters), 0x0, NULL, HFILL }},
2198
2199
14
    { &hf_conf_pmu_lat_unknown,
2200
14
    { "PMU Latitude", "synphasor.conf.pmu_latitude", FT_FLOAT, BASE_NONE,
2201
14
      NULL, 0x0, NULL, HFILL }},
2202
2203
14
    { &hf_conf_pmu_lon_unknown,
2204
14
    { "PMU Longitude", "synphasor.conf.pmu_longitude", FT_FLOAT, BASE_NONE,
2205
14
      NULL, 0x0, NULL, HFILL }},
2206
2207
14
    { &hf_conf_pmu_elev_unknown,
2208
14
    { "PMU Elevation", "synphasor.conf.pmu_elevation", FT_FLOAT, BASE_NONE,
2209
14
      NULL, 0x0, NULL, HFILL }},
2210
2211
14
    { &hf_conf_svc_class,
2212
14
    { "Service class", "synphasor.conf.svc_class", FT_STRING, BASE_NONE,
2213
14
      NULL, 0x0, NULL, HFILL }},
2214
2215
14
    { &hf_conf_window,
2216
14
    { "PM window length", "synphasor.conf.window", FT_UINT32,
2217
14
      BASE_DEC | BASE_UNIT_STRING, UNS(&units_microsecond_microseconds), 0x0, NULL, HFILL }},
2218
2219
14
    { &hf_conf_grp_dly,
2220
14
    { "PM group delay", "synphasor.conf.grp_dly", FT_UINT32,
2221
14
      BASE_DEC | BASE_UNIT_STRING, UNS(&units_microsecond_microseconds), 0x0, NULL, HFILL }},
2222
2223
14
    { &hf_conf_fnom,
2224
14
    { "Nominal line frequency", "synphasor.conf.fnom", FT_BOOLEAN, 16,
2225
14
      TFS(&conf_fnomnames), 0x0001, NULL, HFILL }},
2226
2227
14
    { &hf_conf_cfgcnt,
2228
14
    { "Configuration change count", "synphasor.conf.cfgcnt", FT_UINT16, BASE_DEC,
2229
14
      NULL, 0, NULL, HFILL }},
2230
2231
  /* Data types for data frames */
2232
    /* Link to CFG Frame */
2233
14
    { &hf_cfg_frame_num,
2234
14
    { "Dissected using configuration from frame", "synphasor.data.conf_frame", FT_FRAMENUM, BASE_NONE, NULL, 0x0,"", HFILL }},
2235
2236
    /* Flags in the STAT word */
2237
14
    { &hf_data_statb15to14,
2238
14
    { "Data error", "synphasor.data.status", FT_UINT16, BASE_HEX,
2239
14
      VALS(data_statb15to14names), 0xC000, NULL, HFILL }},
2240
2241
14
    { &hf_data_statb13,
2242
14
    { "Time synchronized", "synphasor.data.sync", FT_BOOLEAN, 16,
2243
14
      TFS(&data_statb13names), 0x2000, NULL, HFILL }},
2244
2245
14
    { &hf_data_statb12,
2246
14
    { "Data sorting", "synphasor.data.sorting", FT_BOOLEAN, 16,
2247
14
      TFS(&data_statb12names), 0x1000, NULL, HFILL }},
2248
2249
14
    { &hf_data_statb11,
2250
14
    { "Trigger detected", "synphasor.data.trigger", FT_BOOLEAN, 16,
2251
14
      TFS(&data_statb11names), 0x0800, NULL, HFILL }},
2252
2253
14
    { &hf_data_statb10,
2254
14
    { "Configuration changed", "synphasor.data.CFGchange", FT_BOOLEAN, 16,
2255
14
      TFS(&data_statb10names), 0x0400, NULL, HFILL }},
2256
2257
14
    { &hf_data_statb09,
2258
14
    { "Data modified indicator", "synphasor.data.data_modified", FT_BOOLEAN, 16,
2259
14
      TFS(&data_statb09names), 0x0200, NULL, HFILL }},
2260
2261
14
    { &hf_data_statb08to06,
2262
14
    { "PMU Time Quality", "synphasor.data.pmu_tq", FT_UINT16, BASE_HEX,
2263
14
      VALS(data_statb08to06names), 0x01C0, NULL, HFILL }},
2264
2265
14
    { &hf_data_statb05to04,
2266
14
    { "Unlocked time", "synphasor.data.t_unlock", FT_UINT16, BASE_HEX,
2267
14
      VALS(data_statb05to04names), 0x0030, NULL, HFILL }},
2268
2269
14
    { &hf_data_statb03to00,
2270
14
    { "Trigger reason", "synphasor.data.trigger_reason", FT_UINT16, BASE_HEX,
2271
14
      VALS(data_statb03to00names), 0x000F, NULL, HFILL }},
2272
2273
  /* Data type for command frame */
2274
14
    { &hf_command,
2275
14
    { "Command", "synphasor.command", FT_UINT16, BASE_HEX|BASE_RANGE_STRING,
2276
14
      RVALS(command_names), 0x0, NULL, HFILL }},
2277
2278
      /* Generated from convert_proto_tree_add_text.pl */
2279
14
      { &hf_synphasor_data, { "Data", "synphasor.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2280
14
      { &hf_synphasor_checksum, { "Checksum", "synphasor.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2281
14
      { &hf_synphasor_checksum_status, { "Checksum Status", "synphasor.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL }},
2282
14
      { &hf_synphasor_num_phasors, { "Number of phasors", "synphasor.num_phasors", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2283
14
      { &hf_synphasor_num_analog_values, { "Number of analog values", "synphasor.num_analog_values", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2284
14
      { &hf_synphasor_num_digital_status_words, { "Number of digital status words", "synphasor.num_digital_status_words", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2285
14
      { &hf_synphasor_rate_of_transmission, { "Rate of transmission", "synphasor.rate_of_transmission", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2286
14
      { &hf_synphasor_phasor, { "Phasor", "synphasor.phasor", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2287
14
      { &hf_synphasor_actual_frequency_value, { "Actual frequency value", "synphasor.actual_frequency_value", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, UNS(&units_hz), 0x0, NULL, HFILL }},
2288
14
      { &hf_synphasor_rate_change_frequency, { "Rate of change of frequency", "synphasor.rate_change_frequency", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, UNS(&units_hz_s), 0x0, NULL, HFILL }},
2289
14
      { &hf_synphasor_frequency_deviation_from_nominal, { "Frequency deviation from nominal", "synphasor.frequency_deviation_from_nominal", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2290
14
      { &hf_synphasor_analog_value, { "Analog value", "synphasor.analog_value", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2291
14
      { &hf_synphasor_digital_status_word, { "Digital status word", "synphasor.digital_status_word", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2292
14
      { &hf_synphasor_conversion_factor, { "conversion factor", "synphasor.conversion_factor", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2293
14
      { &hf_synphasor_factor_for_analog_value, { "Factor for analog value", "synphasor.factor_for_analog_value", FT_UINT32, BASE_DEC, NULL, 0x000000FF, NULL, HFILL }},
2294
14
      { &hf_synphasor_channel_name, { "Channel name", "synphasor.channel_name", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2295
14
      { &hf_synphasor_extended_frame_data, { "Extended frame data", "synphasor.extended_frame_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2296
14
      { &hf_synphasor_unknown_data, { "Unknown data", "synphasor.data.unknown", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2297
14
      { &hf_synphasor_status_word_mask_normal_state, { "Normal state", "synphasor.status_word_mask.normal_state", FT_UINT16, BASE_HEX, NULL, 0xFFFF, NULL, HFILL }},
2298
14
      { &hf_synphasor_status_word_mask_valid_bits, { "Valid bits", "synphasor.status_word_mask.valid_bits", FT_UINT16, BASE_HEX, NULL, 0xFFFF, NULL, HFILL }},
2299
14
  };
2300
2301
  /* protocol subtree array */
2302
14
  static int *ett[] = {
2303
14
    &ett_synphasor,
2304
14
    &ett_frtype,
2305
14
    &ett_timequal,
2306
14
    &ett_conf,
2307
14
    &ett_conf_station,
2308
14
    &ett_conf_format,
2309
14
    &ett_conf_phnam,
2310
14
    &ett_conf_annam,
2311
14
    &ett_conf_dgnam,
2312
14
    &ett_conf_phconv,
2313
14
    &ett_conf_phlist,
2314
14
    &ett_conf_phflags,
2315
14
    &ett_conf_phmod_flags,
2316
14
    &ett_conf_ph_user_flags,
2317
14
    &ett_conf_anconv,
2318
14
    &ett_conf_anlist,
2319
14
    &ett_conf_dgmask,
2320
14
    &ett_conf_chnam,
2321
14
    &ett_conf_wgs84,
2322
14
    &ett_data,
2323
14
    &ett_data_block,
2324
14
    &ett_data_stat,
2325
14
    &ett_data_phasors,
2326
14
    &ett_data_analog,
2327
14
    &ett_data_digital,
2328
14
    &ett_command,
2329
14
    &ett_status_word_mask
2330
14
  };
2331
2332
14
  static ei_register_info ei[] = {
2333
14
    { &ei_synphasor_extended_frame_data, { "synphasor.extended_frame_data.unaligned", PI_PROTOCOL, PI_WARN, "Size not multiple of 16-bit word", EXPFILL }},
2334
14
    { &ei_synphasor_checksum, { "synphasor.bad_checksum", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
2335
14
    { &ei_synphasor_data_error, { "synphasor.data_error", PI_RESPONSE_CODE, PI_NOTE, "Data Error flag set", EXPFILL }},
2336
14
    { &ei_synphasor_pmu_not_sync, { "synphasor.pmu_not_sync", PI_RESPONSE_CODE, PI_NOTE, "PMU not sync flag set", EXPFILL }},
2337
14
  };
2338
2339
14
  expert_module_t* expert_synphasor;
2340
2341
  /* register protocol */
2342
14
  proto_synphasor = proto_register_protocol(PNAME, PSNAME, PFNAME);
2343
2344
  /* Registering protocol to be called by another dissector */
2345
14
  synphasor_udp_handle = register_dissector("synphasor", dissect_udp, proto_synphasor);
2346
14
  synphasor_tcp_handle = register_dissector("synphasor.tcp", dissect_tcp, proto_synphasor);
2347
2348
14
  proto_register_field_array(proto_synphasor, hf, array_length(hf));
2349
14
  proto_register_subtree_array(ett, array_length(ett));
2350
14
  expert_synphasor = expert_register_protocol(proto_synphasor);
2351
14
  expert_register_field_array(expert_synphasor, ei, array_length(ei));
2352
2353
14
} /* proto_register_synphasor() */
2354
2355
/* called at startup and when the preferences change */
2356
void proto_reg_handoff_synphasor(void)
2357
14
{
2358
14
  dissector_add_for_decode_as("rtacser.data", synphasor_udp_handle);
2359
14
  dissector_add_uint_with_preference("udp.port", SYNPHASOR_UDP_PORT, synphasor_udp_handle);
2360
14
  dissector_add_uint_with_preference("tcp.port", SYNPHASOR_TCP_PORT, synphasor_tcp_handle);
2361
14
} /* proto_reg_handoff_synphasor() */
2362
2363
/*
2364
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
2365
 *
2366
 * Local variables:
2367
 * c-basic-offset: 8
2368
 * tab-width: 8
2369
 * indent-tabs-mode: t
2370
 * End:
2371
 *
2372
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
2373
 * :indentSize=8:tabSize=8:noTabs=false:
2374
 */