Coverage Report

Created: 2026-07-12 07:10

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