forked from osmocom/wireshark
synphasor: General cleanup
- col_...() shouldn't be under 'if (tree)'; - remove dead initializers; - use proto_tree_add_subtree() in place of ..._add_text()/...add_subtree() in one more instance; - tvb_length() --> tvb_reported_length(); - use 'proto tree *' variable instead of incorrect 'proto_item *' var in one instance; - use SYNP_... for a few macro names to prevent any possible namespace collisions; - fix some long-lines, indentation and whitespace. Change-Id: I4e0a2e5d0b5e13b72a14ec6dd3779a7104534445 Reviewed-on: https://code.wireshark.org/review/6720 Reviewed-by: Bill Meier <wmeier@newsguy.com>
This commit is contained in:
parent
009ca9fa5e
commit
32ab59f8e9
|
@ -307,7 +307,7 @@ static const value_string command_names[] = {
|
|||
*
|
||||
* use 'config_frame_free()' to free the config_frame again
|
||||
*/
|
||||
static config_frame* config_frame_fast(tvbuff_t *tvb)
|
||||
static config_frame *config_frame_fast(tvbuff_t *tvb)
|
||||
{
|
||||
guint16 idcode, num_pmu;
|
||||
gint offset;
|
||||
|
@ -437,11 +437,11 @@ static gint dissect_header(tvbuff_t *, proto_tree *);
|
|||
/* Dissects the header (common to all types of frames) and then calls
|
||||
* one of the subdissectors (declared above) for the rest of the frame.
|
||||
*/
|
||||
static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
||||
static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
||||
{
|
||||
guint8 frame_type;
|
||||
guint16 crc;
|
||||
guint tvbsize = tvb_length(tvb);
|
||||
guint tvbsize = tvb_reported_length(tvb);
|
||||
|
||||
/* some heuristics */
|
||||
if (tvbsize < 17 /* 17 bytes = header frame with only a
|
||||
|
@ -471,7 +471,7 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
|
|||
config_frame *frame = config_frame_fast(tvb);
|
||||
frame->fnum = pinfo->fd->num;
|
||||
|
||||
/* find a conversation, create a new if no one exists */
|
||||
/* find a conversation, create a new one if none exists */
|
||||
conversation = find_or_create_conversation(pinfo);
|
||||
|
||||
/* remove data from a previous CFG-2 frame, only
|
||||
|
@ -496,14 +496,14 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
|
|||
}
|
||||
} /* if (!visited) */
|
||||
|
||||
if (tree) { /* we are being asked for details */
|
||||
proto_tree *synphasor_tree = NULL;
|
||||
proto_item *temp_item = NULL;
|
||||
proto_item *sub_item = NULL;
|
||||
{
|
||||
proto_tree *synphasor_tree;
|
||||
proto_item *temp_item;
|
||||
proto_item *sub_item;
|
||||
|
||||
gint offset;
|
||||
guint16 framesize;
|
||||
tvbuff_t *sub_tvb;
|
||||
gint offset;
|
||||
guint16 framesize;
|
||||
tvbuff_t *sub_tvb;
|
||||
|
||||
temp_item = proto_tree_add_item(tree, proto_synphasor, tvb, 0, -1, ENC_NA);
|
||||
proto_item_append_text(temp_item, ", %s", val_to_str_const(frame_type, typenames,
|
||||
|
@ -550,9 +550,9 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
|
|||
}
|
||||
|
||||
/*offset += 2;*/ /* CRC */
|
||||
} /* if (tree) */
|
||||
}
|
||||
|
||||
return tvb_length(tvb);
|
||||
return tvb_reported_length(tvb);
|
||||
} /* dissect_synphasor() */
|
||||
|
||||
/* called for synchrophasors over UDP */
|
||||
|
@ -571,7 +571,7 @@ static int dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
|
|||
{
|
||||
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_pdu_length, dissect_common, data);
|
||||
|
||||
return tvb_length(tvb);
|
||||
return tvb_reported_length(tvb);
|
||||
}
|
||||
|
||||
|
||||
|
@ -591,8 +591,8 @@ static gint dissect_header(tvbuff_t *tvb, proto_tree *tree)
|
|||
/* SYNC and flags */
|
||||
temp_item = proto_tree_add_item(tree, hf_sync, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
temp_tree = proto_item_add_subtree(temp_item, ett_frtype);
|
||||
proto_tree_add_item(temp_tree, hf_sync_frtype, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_sync_version, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_sync_frtype, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_sync_version, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
offset += 2;
|
||||
|
||||
/* FRAMESIZE */
|
||||
|
@ -609,12 +609,11 @@ static gint dissect_header(tvbuff_t *tvb, proto_tree *tree)
|
|||
|
||||
/* FRACSEC */
|
||||
/* time quality flags */
|
||||
temp_item = proto_tree_add_text(tree, tvb, offset, 1, "Time quality flags");
|
||||
temp_tree = proto_item_add_subtree(temp_item, ett_timequal);
|
||||
proto_tree_add_item(temp_tree, hf_timeqal_lsdir, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_timeqal_lsocc, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_timeqal_lspend, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_timeqal_timequalindic, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
temp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_timequal, NULL, "Time quality flags");
|
||||
proto_tree_add_item(temp_tree, hf_timeqal_lsdir, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_timeqal_lsocc, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_timeqal_lspend, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_timeqal_timequalindic, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||
offset += 1;
|
||||
|
||||
proto_tree_add_item(tree, hf_fracsec, tvb, offset, 3, ENC_BIG_ENDIAN);
|
||||
|
@ -632,11 +631,9 @@ static gint dissect_DIGUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint c
|
|||
/* dissects a configuration frame (type 1 and 2) and adds fields to 'config_item' */
|
||||
static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
|
||||
{
|
||||
proto_tree *config_tree = NULL;
|
||||
proto_item *temp_item = NULL;
|
||||
proto_tree *temp_tree = NULL;
|
||||
gint offset = 0, j;
|
||||
guint16 num_pmu;
|
||||
proto_tree *config_tree;
|
||||
gint offset = 0, j;
|
||||
guint16 num_pmu;
|
||||
|
||||
proto_item_set_text (config_item, "Configuration data");
|
||||
config_tree = proto_item_add_subtree(config_item, ett_conf);
|
||||
|
@ -651,29 +648,31 @@ static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
|
|||
|
||||
/* dissect the repeating PMU blocks */
|
||||
for (j = 0; j < num_pmu; j++) {
|
||||
guint16 num_ph, num_an, num_dg;
|
||||
proto_item *station_item = NULL;
|
||||
proto_tree *station_tree = NULL;
|
||||
char *str;
|
||||
guint16 num_ph, num_an, num_dg;
|
||||
proto_item *station_item;
|
||||
proto_tree *station_tree;
|
||||
proto_tree *temp_tree;
|
||||
char *str;
|
||||
|
||||
gint oldoffset = offset; /* to calculate the length of the whole PMU block later */
|
||||
|
||||
/* STN with new tree to add the rest of the PMU block */
|
||||
str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, CHNAM_LEN, ENC_ASCII);
|
||||
station_tree = proto_tree_add_subtree_format(config_tree, tvb, offset, CHNAM_LEN,
|
||||
ett_conf_station, &station_item, "Station #%i: \"%s\"", j + 1, str);
|
||||
ett_conf_station, &station_item,
|
||||
"Station #%i: \"%s\"", j + 1, str);
|
||||
offset += CHNAM_LEN;
|
||||
|
||||
/* IDCODE */
|
||||
proto_tree_add_item(station_tree, hf_idcode, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
|
||||
|
||||
/* FORMAT */
|
||||
temp_item = proto_tree_add_text(station_tree, tvb, offset, 2, "Data format in data frame");
|
||||
temp_tree = proto_item_add_subtree(temp_item, ett_conf_format);
|
||||
proto_tree_add_item(temp_tree, hf_conf_formatb3, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_conf_formatb2, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_conf_formatb1, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_conf_formatb0, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
temp_tree = proto_tree_add_subtree(station_tree, tvb, offset, 2, ett_conf_format, NULL,
|
||||
"Data format in data frame");
|
||||
proto_tree_add_item(temp_tree, hf_conf_formatb3, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_conf_formatb2, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_conf_formatb1, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_conf_formatb0, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
offset += 2;
|
||||
|
||||
/* PHNMR, ANNMR, DGNMR */
|
||||
|
@ -705,6 +704,7 @@ static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
|
|||
|
||||
/* DATA_RATE */
|
||||
{
|
||||
proto_item *temp_item;
|
||||
gint16 tmp = tvb_get_ntohs(tvb, offset);
|
||||
temp_item = proto_tree_add_text(config_tree, tvb, offset, 2, "Rate of transmission: "); offset += 2;
|
||||
if (tmp > 0)
|
||||
|
@ -721,8 +721,9 @@ static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block
|
|||
static gint dissect_DFREQ (tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
||||
static gint dissect_ANALOG (tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
||||
static gint dissect_DIGITAL(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
||||
|
||||
/* calculates the size (in bytes) of a data frame that the config_block describes */
|
||||
#define BLOCKSIZE(x) (2 /* STAT */ \
|
||||
#define SYNP_BLOCKSIZE(x) (2 /* STAT */ \
|
||||
+ wmem_array_get_count((x).phasors) * (integer == (x).format_ph ? 4 : 8) /* PHASORS */ \
|
||||
+ (integer == (x).format_fr ? 4 : 8) /* (D)FREQ */ \
|
||||
+ wmem_array_get_count((x).analogs) * (integer == (x).format_an ? 2 : 4) /* ANALOG */ \
|
||||
|
@ -733,7 +734,7 @@ static int dissect_data_frame(tvbuff_t *tvb,
|
|||
proto_item *data_item, /* all items are placed beneath this item */
|
||||
packet_info *pinfo) /* used to find the data from a CFG-2 frame */
|
||||
{
|
||||
proto_tree *data_tree = NULL;
|
||||
proto_tree *data_tree;
|
||||
gint offset = 0;
|
||||
guint i;
|
||||
config_frame *conf;
|
||||
|
@ -752,10 +753,10 @@ static int dissect_data_frame(tvbuff_t *tvb,
|
|||
size_t reported_size = 0;
|
||||
for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
|
||||
config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
|
||||
reported_size += BLOCKSIZE(*block);
|
||||
reported_size += SYNP_BLOCKSIZE(*block);
|
||||
}
|
||||
|
||||
if (tvb_length(tvb) == reported_size) {
|
||||
if (tvb_reported_length(tvb) == reported_size) {
|
||||
proto_item_append_text(data_item, ", using frame number %"G_GUINT32_FORMAT" as configuration frame",
|
||||
conf->fnum);
|
||||
config_found = TRUE;
|
||||
|
@ -772,28 +773,28 @@ static int dissect_data_frame(tvbuff_t *tvb,
|
|||
for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
|
||||
config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
|
||||
|
||||
proto_item *block_item;
|
||||
proto_tree *block_tree = proto_tree_add_subtree_format(data_tree, tvb, offset, BLOCKSIZE(*block),
|
||||
ett_data_block, &block_item, "Station: \"%s\"", block->name);
|
||||
proto_tree *block_tree = proto_tree_add_subtree_format(data_tree, tvb, offset, SYNP_BLOCKSIZE(*block),
|
||||
ett_data_block, NULL,
|
||||
"Station: \"%s\"", block->name);
|
||||
|
||||
/* STAT */
|
||||
proto_item *temp_item = proto_tree_add_text(block_tree, tvb, offset, 2, "Flags");
|
||||
proto_tree *temp_tree = proto_item_add_subtree(temp_item, ett_data_stat);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb15, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb14, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb13, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb12, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb11, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb10, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb05to04, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb03to00, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree *temp_tree = proto_tree_add_subtree(block_tree, tvb, offset, 2, ett_data_stat, NULL, "Flags");
|
||||
|
||||
proto_tree_add_item(temp_tree, hf_data_statb15, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb14, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb13, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb12, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb11, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb10, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb05to04, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
proto_tree_add_item(temp_tree, hf_data_statb03to00, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||
offset += 2;
|
||||
|
||||
/* PHASORS, (D)FREQ, ANALOG, and DIGITAL */
|
||||
offset = dissect_PHASORS(tvb, block_item, block, offset);
|
||||
offset = dissect_DFREQ (tvb, block_item, block, offset);
|
||||
offset = dissect_ANALOG (tvb, block_item, block, offset);
|
||||
offset = dissect_DIGITAL(tvb, block_item, block, offset);
|
||||
offset = dissect_PHASORS(tvb, block_tree, block, offset);
|
||||
offset = dissect_DFREQ (tvb, block_tree, block, offset);
|
||||
offset = dissect_ANALOG (tvb, block_tree, block, offset);
|
||||
offset = dissect_DIGITAL(tvb, block_tree, block, offset);
|
||||
}
|
||||
return offset;
|
||||
} /* dissect_data_frame() */
|
||||
|
@ -807,8 +808,8 @@ static int dissect_command_frame(tvbuff_t *tvb,
|
|||
proto_item *command_item,
|
||||
packet_info *pinfo)
|
||||
{
|
||||
proto_tree *command_tree = NULL;
|
||||
guint tvbsize = tvb_length(tvb);
|
||||
proto_tree *command_tree;
|
||||
guint tvbsize = tvb_reported_length(tvb);
|
||||
const char *s;
|
||||
|
||||
proto_item_set_text(command_item, "Command data");
|
||||
|
@ -824,9 +825,9 @@ static int dissect_command_frame(tvbuff_t *tvb,
|
|||
if (tvbsize > 2) {
|
||||
if (tvb_get_ntohs(tvb, 0) == 0x0008) {
|
||||
/* Command: Extended Frame, the extra data is ok */
|
||||
proto_item* i = proto_tree_add_text(command_tree, tvb, 2, tvbsize - 2, "Extended frame data");
|
||||
if (tvbsize % 2)
|
||||
proto_item_append_text(i, ", but size not multiple of 16-bit word");
|
||||
proto_item *ti = proto_tree_add_text(command_tree, tvb, 2, tvbsize - 2, "Extended frame data");
|
||||
if (tvbsize % 2)
|
||||
proto_item_append_text(ti, ", but size not multiple of 16-bit word");
|
||||
}
|
||||
else
|
||||
proto_tree_add_text(command_tree, tvb, 2, tvbsize - 2, "Unknown data");
|
||||
|
@ -841,9 +842,9 @@ static int dissect_command_frame(tvbuff_t *tvb,
|
|||
|
||||
/* Dissects a single phasor for 'dissect_PHASORS()' */
|
||||
static int dissect_single_phasor(tvbuff_t *tvb, int offset,
|
||||
double* mag, double* phase, /* returns the resulting values here */
|
||||
double *mag, double *phase, /* returns the resulting values here */
|
||||
data_format format, /* information needed to... */
|
||||
phasor_notation_e notation) /* ...dissect the phasor */
|
||||
phasor_notation_e notation) /* ...dissect the phasor */
|
||||
{
|
||||
if (floating_point == format) {
|
||||
if (polar == notation) {
|
||||
|
@ -885,24 +886,25 @@ static int dissect_single_phasor(tvbuff_t *tvb, int offset,
|
|||
/* used by 'dissect_data_frame()' to dissect the PHASORS field */
|
||||
static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
||||
{
|
||||
proto_item *temp_item = NULL;
|
||||
proto_tree *phasor_tree = NULL;
|
||||
proto_tree *phasor_tree;
|
||||
guint length;
|
||||
gint j,
|
||||
cnt = wmem_array_get_count(block->phasors); /* number of phasors to dissect */
|
||||
gint j;
|
||||
gint cnt = wmem_array_get_count(block->phasors); /* number of phasors to dissect */
|
||||
|
||||
if (0 == cnt)
|
||||
return offset;
|
||||
|
||||
length = wmem_array_get_count(block->phasors) * (floating_point == block->format_ph ? 8 : 4);
|
||||
phasor_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_phasors, NULL, "Phasors (%u)", cnt);
|
||||
phasor_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_phasors, NULL,
|
||||
"Phasors (%u)", cnt);
|
||||
|
||||
/* dissect a phasor for every phasor_info saved in the config_block */
|
||||
for (j = 0; j < cnt; j++) {
|
||||
proto_item *temp_item;
|
||||
double mag, phase;
|
||||
phasor_info *pi;
|
||||
|
||||
pi = (phasor_info*)wmem_array_index(block->phasors, j);
|
||||
pi = (phasor_info *)wmem_array_index(block->phasors, j);
|
||||
temp_item = proto_tree_add_text(phasor_tree, tvb, offset,
|
||||
floating_point == block->format_ph ? 8 : 4,
|
||||
"Phasor #%u: \"%s\"", j + 1, pi->name);
|
||||
|
@ -916,15 +918,15 @@ static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block
|
|||
if (integer == block->format_ph)
|
||||
mag = (mag * pi->conv) * 0.00001;
|
||||
|
||||
#define ANGLE "/_"
|
||||
#define DEGREE "\xC2\xB0" /* DEGREE signs in UTF-8 */
|
||||
#define SYNP_ANGLE "/_"
|
||||
#define SYNP_DEGREE "\xC2\xB0" /* DEGREE signs in UTF-8 */
|
||||
|
||||
proto_item_append_text(temp_item, ", %10.2f%c" ANGLE "%7.2f" DEGREE,
|
||||
proto_item_append_text(temp_item, ", %10.2f%c" SYNP_ANGLE "%7.2f" SYNP_DEGREE,
|
||||
mag,
|
||||
V == pi->unit ? 'V' : 'A',
|
||||
phase *180.0/G_PI);
|
||||
#undef ANGLE
|
||||
#undef DEGREE
|
||||
#undef SYNP_ANGLE
|
||||
#undef SYNP_DEGREE
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
@ -963,19 +965,20 @@ static gint dissect_DFREQ(tvbuff_t *tvb, proto_tree *tree, config_block *block,
|
|||
/* used by 'dissect_data_frame()' to dissect the ANALOG field */
|
||||
static gint dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
||||
{
|
||||
proto_tree *analog_tree = NULL;
|
||||
proto_item *temp_item = NULL;
|
||||
proto_tree *analog_tree;
|
||||
guint length;
|
||||
gint j,
|
||||
cnt = wmem_array_get_count(block->analogs); /* number of analog values to dissect */
|
||||
gint j;
|
||||
gint cnt = wmem_array_get_count(block->analogs); /* number of analog values to dissect */
|
||||
|
||||
if (0 == cnt)
|
||||
return offset;
|
||||
|
||||
length = wmem_array_get_count(block->analogs) * (floating_point == block->format_an ? 4 : 2);
|
||||
analog_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_analog, NULL, "Analog values (%u)", cnt);
|
||||
analog_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_analog, NULL,
|
||||
"Analog values (%u)", cnt);
|
||||
|
||||
for (j = 0; j < cnt; j++) {
|
||||
proto_item *temp_item;
|
||||
analog_info *ai = (analog_info *)wmem_array_index(block->analogs, j);
|
||||
|
||||
temp_item = proto_tree_add_text(analog_tree, tvb, offset,
|
||||
|
@ -988,7 +991,7 @@ static gint dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block,
|
|||
}
|
||||
else {
|
||||
/* the "standard" doesn't say if this is signed or unsigned,
|
||||
* so I just use gint16, the scaling of the conversation factor
|
||||
* so I just use gint16; the scaling of the conversation factor
|
||||
* is also "user defined", so I just write it after the analog value */
|
||||
gint16 tmp = tvb_get_ntohs(tvb, offset); offset += 2;
|
||||
proto_item_append_text(temp_item, ", %" G_GINT16_FORMAT " (conversation factor: %#06x)",
|
||||
|
@ -1001,13 +1004,14 @@ static gint dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block,
|
|||
/* used by 'dissect_data_frame()' to dissect the DIGITAL field */
|
||||
static gint dissect_DIGITAL(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
||||
{
|
||||
gint j,
|
||||
cnt = block->num_dg; /* number of digital status words to dissect */
|
||||
gint j;
|
||||
gint cnt = block->num_dg; /* number of digital status words to dissect */
|
||||
|
||||
if (0 == cnt)
|
||||
return offset;
|
||||
|
||||
tree = proto_tree_add_subtree_format(tree, tvb, offset, cnt * 2, ett_data_digital, NULL, "Digital status words (%u)", cnt);
|
||||
tree = proto_tree_add_subtree_format(tree, tvb, offset, cnt * 2, ett_data_digital, NULL,
|
||||
"Digital status words (%u)", cnt);
|
||||
|
||||
for (j = 0; j < cnt; j++) {
|
||||
guint16 tmp = tvb_get_ntohs(tvb, offset);
|
||||
|
@ -1030,7 +1034,8 @@ static gint dissect_PHUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cn
|
|||
if (0 == cnt)
|
||||
return offset;
|
||||
|
||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_phconv, NULL, "Phasor conversation factors (%u)", cnt);
|
||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_phconv, NULL,
|
||||
"Phasor conversation factors (%u)", cnt);
|
||||
|
||||
/* Conversion factor for phasor channels. Four bytes for each phasor.
|
||||
* MSB: 0 = voltage, 1 = current
|
||||
|
@ -1059,7 +1064,8 @@ static gint dissect_ANUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cn
|
|||
if (0 == cnt)
|
||||
return offset;
|
||||
|
||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_anconv, NULL, "Analog values conversation factors (%u)", cnt);
|
||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_anconv, NULL,
|
||||
"Analog values conversation factors (%u)", cnt);
|
||||
|
||||
/* Conversation factor for analog channels. Four bytes for each analog value.
|
||||
* MSB: see 'synphasor_conf_anconvnames' in 'synphasor_strings.c'
|
||||
|
@ -1072,7 +1078,7 @@ static gint dissect_ANUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cn
|
|||
i + 1,
|
||||
try_rval_to_str((tmp >> 24) & 0x000000FF, conf_anconvnames));
|
||||
|
||||
tmp &= 0x00FFFFFF;
|
||||
tmp &= 0x00FFFFFF;
|
||||
if ( tmp & 0x00800000) /* sign bit set */
|
||||
tmp |= 0xFF000000;
|
||||
|
||||
|
@ -1094,7 +1100,8 @@ static gint dissect_DIGUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint c
|
|||
if (0 == cnt)
|
||||
return offset;
|
||||
|
||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_dgmask, NULL, "Masks for digital status words (%u)", cnt);
|
||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_dgmask, NULL,
|
||||
"Masks for digital status words (%u)", cnt);
|
||||
|
||||
/* Mask words for digital status words. Two 16-bit words for each digital word. The first
|
||||
* inidcates the normal status of the inputs, the second indicated the valid bits in
|
||||
|
@ -1122,7 +1129,8 @@ static gint dissect_CHNAM(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt
|
|||
if (0 == cnt)
|
||||
return offset;
|
||||
|
||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, CHNAM_LEN * cnt, ett_conf_phnam, NULL, "%ss (%u)", prefix, cnt);
|
||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, CHNAM_LEN * cnt, ett_conf_phnam, NULL,
|
||||
"%ss (%u)", prefix, cnt);
|
||||
|
||||
/* dissect the 'cnt' channel names */
|
||||
for (i = 0; i < cnt; i++) {
|
||||
|
@ -1143,7 +1151,8 @@ void proto_register_synphasor(void)
|
|||
{ &hf_sync,
|
||||
{ "Synchronization word", "synphasor.sync", FT_UINT16, BASE_HEX,
|
||||
NULL, 0x0, NULL, HFILL }},
|
||||
/* Flags in the Sync word */
|
||||
|
||||
/* Flags in the Sync word */
|
||||
{ &hf_sync_frtype,
|
||||
{ "Frame Type", "synphasor.frtype", FT_UINT16, BASE_HEX,
|
||||
VALS(typenames), 0x0070, NULL, HFILL }},
|
||||
|
|
Loading…
Reference in New Issue