Coverage Report

Created: 2025-12-27 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-goose.c
Line
Count
Source
1
/* Do not modify this file. Changes will be overwritten.                      */
2
/* Generated automatically by the ASN.1 to Wireshark dissector compiler       */
3
/* packet-goose.c                                                             */
4
/* asn2wrs.py -b -q -L -p goose -c ./goose.cnf -s ./packet-goose-template -D . -O ../.. goose.asn */
5
6
/* packet-goose.c
7
 * Routines for IEC 61850 GOOSE packet dissection
8
 * Martin Lutz 2008
9
 *
10
 * Routines for IEC 61850 R-GOOSE packet dissection
11
 * Dordije Manojlovic 2020
12
 *
13
 * Wireshark - Network traffic analyzer
14
 * By Gerald Combs <gerald@wireshark.org>
15
 * Copyright 1998 Gerald Combs
16
 *
17
 * SPDX-License-Identifier: GPL-2.0-or-later
18
 */
19
20
#include "config.h"
21
22
#include <epan/packet.h>
23
#include <epan/asn1.h>
24
#include <epan/proto_data.h>
25
#include <epan/etypes.h>
26
#include <epan/expert.h>
27
#include <wsutil/array.h>
28
29
#include "packet-ber.h"
30
#include "packet-acse.h"
31
32
37
#define GOOSE_PNAME  "GOOSE"
33
14
#define GOOSE_PSNAME "GOOSE"
34
14
#define GOOSE_PFNAME "goose"
35
36
16
#define R_GOOSE_PNAME  "R-GOOSE"
37
14
#define R_GOOSE_PSNAME "R-GOOSE"
38
14
#define R_GOOSE_PFNAME "r-goose"
39
40
void proto_register_goose(void);
41
void proto_reg_handoff_goose(void);
42
43
/* Initialize the protocol and registered fields */
44
static int proto_goose;
45
static int proto_r_goose;
46
47
static int hf_goose_session_header;
48
static int hf_goose_spdu_id;
49
static int hf_goose_session_hdr_length;
50
static int hf_goose_hdr_length;
51
static int hf_goose_content_id;
52
static int hf_goose_spdu_lenth;
53
static int hf_goose_spdu_num;
54
static int hf_goose_version;
55
static int hf_goose_security_info;
56
static int hf_goose_current_key_t;
57
static int hf_goose_next_key_t;
58
static int hf_goose_key_id;
59
static int hf_goose_init_vec_length;
60
static int hf_goose_init_vec;
61
static int hf_goose_session_user_info;
62
static int hf_goose_payload;
63
static int hf_goose_payload_length;
64
static int hf_goose_apdu_tag;
65
static int hf_goose_apdu_simulation;
66
static int hf_goose_apdu_appid;
67
static int hf_goose_apdu_length;
68
static int hf_goose_padding_tag;
69
static int hf_goose_padding_length;
70
static int hf_goose_padding;
71
static int hf_goose_hmac;
72
static int hf_goose_appid;
73
static int hf_goose_length;
74
static int hf_goose_reserve1;
75
static int hf_goose_reserve1_s_bit;
76
static int hf_goose_reserve2;
77
static int hf_goose_float_value;
78
79
80
/* Bit fields in the Reserved fields */
81
30
#define F_RESERVE1_S_BIT  0x8000
82
83
/* GOOSE stored data for expert info verifications */
84
typedef struct _goose_chk_data{
85
  bool s_bit;
86
}goose_chk_data_t;
87
25
#define GOOSE_CHK_DATA_LEN  (sizeof(goose_chk_data_t))
88
89
static expert_field ei_goose_mal_utctime;
90
static expert_field ei_goose_zero_pdu;
91
static expert_field ei_goose_invalid_sim;
92
static expert_field ei_goose_bogus_length;
93
94
0
#define SINGLE_FLOAT_EXP_BITS 8
95
0
#define FLOAT_ENC_LENGTH    5
96
97
static int hf_goose_gseMngtPdu;                   /* GSEMngtPdu */
98
static int hf_goose_goosePdu;                     /* IECGoosePdu */
99
static int hf_goose_stateID;                      /* INTEGER */
100
static int hf_goose_requestResp;                  /* RequestResponse */
101
static int hf_goose_requests;                     /* GSEMngtRequests */
102
static int hf_goose_responses;                    /* GSEMngtResponses */
103
static int hf_goose_getGoReference;               /* GetReferenceRequestPdu */
104
static int hf_goose_getGOOSEElementNumber;        /* GetElementRequestPdu */
105
static int hf_goose_getGsReference;               /* GetReferenceRequestPdu */
106
static int hf_goose_getGSSEDataOffset;            /* GetElementRequestPdu */
107
static int hf_goose_gseMngtNotSupported;          /* NULL */
108
static int hf_goose_gseMngtResponses_GetGOReference;  /* GSEMngtResponsePdu */
109
static int hf_goose_gseMngtResponses_GetGOOSEElementNumber;  /* GSEMngtResponsePdu */
110
static int hf_goose_gseMngtResponses_GetGSReference;  /* GSEMngtResponsePdu */
111
static int hf_goose_gseMngtResponses_GetGSSEDataOffset;  /* GSEMngtResponsePdu */
112
static int hf_goose_ident;                        /* VisibleString */
113
static int hf_goose_getReferenceRequest_offset;   /* T_getReferenceRequest_offset */
114
static int hf_goose_getReferenceRequest_offset_item;  /* INTEGER */
115
static int hf_goose_references;                   /* T_references */
116
static int hf_goose_references_item;              /* VisibleString */
117
static int hf_goose_confRev;                      /* INTEGER */
118
static int hf_goose_posNeg;                       /* PositiveNegative */
119
static int hf_goose_responsePositive;             /* T_responsePositive */
120
static int hf_goose_datSet;                       /* VisibleString */
121
static int hf_goose_result;                       /* SEQUENCE_OF_RequestResults */
122
static int hf_goose_result_item;                  /* RequestResults */
123
static int hf_goose_responseNegative;             /* GlbErrors */
124
static int hf_goose_offset;                       /* INTEGER */
125
static int hf_goose_reference;                    /* IA5String */
126
static int hf_goose_error;                        /* ErrorReason */
127
static int hf_goose_gocbRef;                      /* VisibleString */
128
static int hf_goose_timeAllowedtoLive;            /* INTEGER */
129
static int hf_goose_goID;                         /* VisibleString */
130
static int hf_goose_t;                            /* UtcTime */
131
static int hf_goose_stNum;                        /* INTEGER */
132
static int hf_goose_sqNum;                        /* INTEGER */
133
static int hf_goose_simulation;                   /* T_simulation */
134
static int hf_goose_ndsCom;                       /* BOOLEAN */
135
static int hf_goose_numDatSetEntries;             /* INTEGER */
136
static int hf_goose_allData;                      /* SEQUENCE_OF_Data */
137
static int hf_goose_allData_item;                 /* Data */
138
static int hf_goose_array;                        /* SEQUENCE_OF_Data */
139
static int hf_goose_array_item;                   /* Data */
140
static int hf_goose_structure;                    /* SEQUENCE_OF_Data */
141
static int hf_goose_structure_item;               /* Data */
142
static int hf_goose_boolean;                      /* BOOLEAN */
143
static int hf_goose_bit_string;                   /* BIT_STRING */
144
static int hf_goose_integer;                      /* INTEGER */
145
static int hf_goose_unsigned;                     /* INTEGER */
146
static int hf_goose_floating_point;               /* FloatingPoint */
147
static int hf_goose_real;                         /* REAL */
148
static int hf_goose_octet_string;                 /* OCTET_STRING */
149
static int hf_goose_visible_string;               /* VisibleString */
150
static int hf_goose_binary_time;                  /* TimeOfDay */
151
static int hf_goose_bcd;                          /* INTEGER */
152
static int hf_goose_booleanArray;                 /* BIT_STRING */
153
static int hf_goose_objId;                        /* OBJECT_IDENTIFIER */
154
static int hf_goose_mMSString;                    /* MMSString */
155
static int hf_goose_utc_time;                     /* UtcTime */
156
157
/* Initialize the subtree pointers */
158
static int ett_r_goose;
159
static int ett_session_header;
160
static int ett_security_info;
161
static int ett_session_user_info;
162
static int ett_payload;
163
static int ett_padding;
164
static int ett_goose;
165
static int ett_reserve1;
166
static int ett_expert_inf_sim;
167
168
static int ett_goose_GOOSEpdu;
169
static int ett_goose_GSEMngtPdu;
170
static int ett_goose_RequestResponse;
171
static int ett_goose_GSEMngtRequests;
172
static int ett_goose_GSEMngtResponses;
173
static int ett_goose_GetReferenceRequestPdu;
174
static int ett_goose_T_getReferenceRequest_offset;
175
static int ett_goose_GetElementRequestPdu;
176
static int ett_goose_T_references;
177
static int ett_goose_GSEMngtResponsePdu;
178
static int ett_goose_PositiveNegative;
179
static int ett_goose_T_responsePositive;
180
static int ett_goose_SEQUENCE_OF_RequestResults;
181
static int ett_goose_RequestResults;
182
static int ett_goose_IECGoosePdu;
183
static int ett_goose_SEQUENCE_OF_Data;
184
static int ett_goose_Data;
185
186
/*--- Cyclic dependencies ---*/
187
188
/* Data -> Data/array -> Data */
189
static unsigned dissect_goose_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
190
191
192
193
194
static unsigned
195
0
dissect_goose_INTEGER(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
196
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
197
0
                                                NULL);
198
199
0
  return offset;
200
0
}
201
202
203
204
static unsigned
205
0
dissect_goose_VisibleString(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
206
0
  offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_VisibleString,
207
0
                                            actx, tree, tvb, offset, hf_index,
208
0
                                            NULL);
209
210
0
  return offset;
211
0
}
212
213
214
static const ber_sequence_t T_getReferenceRequest_offset_sequence_of[1] = {
215
  { &hf_goose_getReferenceRequest_offset_item, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_goose_INTEGER },
216
};
217
218
static unsigned
219
0
dissect_goose_T_getReferenceRequest_offset(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
220
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
221
0
                                      T_getReferenceRequest_offset_sequence_of, hf_index, ett_goose_T_getReferenceRequest_offset);
222
223
0
  return offset;
224
0
}
225
226
227
static const ber_sequence_t GetReferenceRequestPdu_sequence[] = {
228
  { &hf_goose_ident         , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_goose_VisibleString },
229
  { &hf_goose_getReferenceRequest_offset, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_T_getReferenceRequest_offset },
230
  { NULL, 0, 0, 0, NULL }
231
};
232
233
static unsigned
234
0
dissect_goose_GetReferenceRequestPdu(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
235
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
236
0
                                   GetReferenceRequestPdu_sequence, hf_index, ett_goose_GetReferenceRequestPdu);
237
238
0
  return offset;
239
0
}
240
241
242
static const ber_sequence_t T_references_sequence_of[1] = {
243
  { &hf_goose_references_item, BER_CLASS_UNI, BER_UNI_TAG_VisibleString, BER_FLAGS_NOOWNTAG, dissect_goose_VisibleString },
244
};
245
246
static unsigned
247
0
dissect_goose_T_references(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
248
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
249
0
                                      T_references_sequence_of, hf_index, ett_goose_T_references);
250
251
0
  return offset;
252
0
}
253
254
255
static const ber_sequence_t GetElementRequestPdu_sequence[] = {
256
  { &hf_goose_ident         , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_goose_VisibleString },
257
  { &hf_goose_references    , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_T_references },
258
  { NULL, 0, 0, 0, NULL }
259
};
260
261
static unsigned
262
0
dissect_goose_GetElementRequestPdu(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
263
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
264
0
                                   GetElementRequestPdu_sequence, hf_index, ett_goose_GetElementRequestPdu);
265
266
0
  return offset;
267
0
}
268
269
270
static const value_string goose_GSEMngtRequests_vals[] = {
271
  {   1, "getGoReference" },
272
  {   2, "getGOOSEElementNumber" },
273
  {   3, "getGsReference" },
274
  {   4, "getGSSEDataOffset" },
275
  { 0, NULL }
276
};
277
278
static const ber_choice_t GSEMngtRequests_choice[] = {
279
  {   1, &hf_goose_getGoReference, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_GetReferenceRequestPdu },
280
  {   2, &hf_goose_getGOOSEElementNumber, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_goose_GetElementRequestPdu },
281
  {   3, &hf_goose_getGsReference, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_goose_GetReferenceRequestPdu },
282
  {   4, &hf_goose_getGSSEDataOffset, BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_goose_GetElementRequestPdu },
283
  { 0, NULL, 0, 0, 0, NULL }
284
};
285
286
static unsigned
287
0
dissect_goose_GSEMngtRequests(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
288
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
289
0
                                 GSEMngtRequests_choice, hf_index, ett_goose_GSEMngtRequests,
290
0
                                 NULL);
291
292
0
  return offset;
293
0
}
294
295
296
297
static unsigned
298
0
dissect_goose_NULL(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
299
0
  offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
300
301
0
  return offset;
302
0
}
303
304
305
306
static unsigned
307
0
dissect_goose_IA5String(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
308
0
  offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_IA5String,
309
0
                                            actx, tree, tvb, offset, hf_index,
310
0
                                            NULL);
311
312
0
  return offset;
313
0
}
314
315
316
static const value_string goose_ErrorReason_vals[] = {
317
  {   0, "other" },
318
  {   1, "notFound" },
319
  { 0, NULL }
320
};
321
322
323
static unsigned
324
0
dissect_goose_ErrorReason(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
325
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
326
0
                                                NULL);
327
328
0
  return offset;
329
0
}
330
331
332
static const value_string goose_RequestResults_vals[] = {
333
  {   0, "offset" },
334
  {   1, "reference" },
335
  {   2, "error" },
336
  { 0, NULL }
337
};
338
339
static const ber_choice_t RequestResults_choice[] = {
340
  {   0, &hf_goose_offset        , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
341
  {   1, &hf_goose_reference     , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_IA5String },
342
  {   2, &hf_goose_error         , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_goose_ErrorReason },
343
  { 0, NULL, 0, 0, 0, NULL }
344
};
345
346
static unsigned
347
0
dissect_goose_RequestResults(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
348
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
349
0
                                 RequestResults_choice, hf_index, ett_goose_RequestResults,
350
0
                                 NULL);
351
352
0
  return offset;
353
0
}
354
355
356
static const ber_sequence_t SEQUENCE_OF_RequestResults_sequence_of[1] = {
357
  { &hf_goose_result_item   , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_goose_RequestResults },
358
};
359
360
static unsigned
361
0
dissect_goose_SEQUENCE_OF_RequestResults(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
362
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
363
0
                                      SEQUENCE_OF_RequestResults_sequence_of, hf_index, ett_goose_SEQUENCE_OF_RequestResults);
364
365
0
  return offset;
366
0
}
367
368
369
static const ber_sequence_t T_responsePositive_sequence[] = {
370
  { &hf_goose_datSet        , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_goose_VisibleString },
371
  { &hf_goose_result        , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_SEQUENCE_OF_RequestResults },
372
  { NULL, 0, 0, 0, NULL }
373
};
374
375
static unsigned
376
0
dissect_goose_T_responsePositive(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
377
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
378
0
                                   T_responsePositive_sequence, hf_index, ett_goose_T_responsePositive);
379
380
0
  return offset;
381
0
}
382
383
384
static const value_string goose_GlbErrors_vals[] = {
385
  {   0, "other" },
386
  {   1, "unknownControlBlock" },
387
  {   2, "responseTooLarge" },
388
  {   3, "controlBlockConfigurationError" },
389
  { 0, NULL }
390
};
391
392
393
static unsigned
394
0
dissect_goose_GlbErrors(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
395
0
  offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
396
0
                                                NULL);
397
398
0
  return offset;
399
0
}
400
401
402
static const value_string goose_PositiveNegative_vals[] = {
403
  {   2, "responsePositive" },
404
  {   3, "responseNegative" },
405
  { 0, NULL }
406
};
407
408
static const ber_choice_t PositiveNegative_choice[] = {
409
  {   2, &hf_goose_responsePositive, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_goose_T_responsePositive },
410
  {   3, &hf_goose_responseNegative, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_goose_GlbErrors },
411
  { 0, NULL, 0, 0, 0, NULL }
412
};
413
414
static unsigned
415
0
dissect_goose_PositiveNegative(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
416
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
417
0
                                 PositiveNegative_choice, hf_index, ett_goose_PositiveNegative,
418
0
                                 NULL);
419
420
0
  return offset;
421
0
}
422
423
424
static const ber_sequence_t GSEMngtResponsePdu_sequence[] = {
425
  { &hf_goose_ident         , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_goose_VisibleString },
426
  { &hf_goose_confRev       , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
427
  { &hf_goose_posNeg        , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_goose_PositiveNegative },
428
  { NULL, 0, 0, 0, NULL }
429
};
430
431
static unsigned
432
0
dissect_goose_GSEMngtResponsePdu(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
433
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
434
0
                                   GSEMngtResponsePdu_sequence, hf_index, ett_goose_GSEMngtResponsePdu);
435
436
0
  return offset;
437
0
}
438
439
440
static const value_string goose_GSEMngtResponses_vals[] = {
441
  {   0, "gseMngtNotSupported" },
442
  {   1, "getGoReference" },
443
  {   2, "getGOOSEElementNumber" },
444
  {   3, "getGsReference" },
445
  {   4, "getGSSEDataOffset" },
446
  { 0, NULL }
447
};
448
449
static const ber_choice_t GSEMngtResponses_choice[] = {
450
  {   0, &hf_goose_gseMngtNotSupported, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_goose_NULL },
451
  {   1, &hf_goose_gseMngtResponses_GetGOReference, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_GSEMngtResponsePdu },
452
  {   2, &hf_goose_gseMngtResponses_GetGOOSEElementNumber, BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_goose_GSEMngtResponsePdu },
453
  {   3, &hf_goose_gseMngtResponses_GetGSReference, BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_goose_GSEMngtResponsePdu },
454
  {   4, &hf_goose_gseMngtResponses_GetGSSEDataOffset, BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_goose_GSEMngtResponsePdu },
455
  { 0, NULL, 0, 0, 0, NULL }
456
};
457
458
static unsigned
459
0
dissect_goose_GSEMngtResponses(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
460
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
461
0
                                 GSEMngtResponses_choice, hf_index, ett_goose_GSEMngtResponses,
462
0
                                 NULL);
463
464
0
  return offset;
465
0
}
466
467
468
static const value_string goose_RequestResponse_vals[] = {
469
  {   1, "requests" },
470
  {   2, "responses" },
471
  { 0, NULL }
472
};
473
474
static const ber_choice_t RequestResponse_choice[] = {
475
  {   1, &hf_goose_requests      , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_GSEMngtRequests },
476
  {   2, &hf_goose_responses     , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_goose_GSEMngtResponses },
477
  { 0, NULL, 0, 0, 0, NULL }
478
};
479
480
static unsigned
481
0
dissect_goose_RequestResponse(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
482
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
483
0
                                 RequestResponse_choice, hf_index, ett_goose_RequestResponse,
484
0
                                 NULL);
485
486
0
  return offset;
487
0
}
488
489
490
static const ber_sequence_t GSEMngtPdu_sequence[] = {
491
  { &hf_goose_stateID       , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
492
  { &hf_goose_requestResp   , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_goose_RequestResponse },
493
  { NULL, 0, 0, 0, NULL }
494
};
495
496
static unsigned
497
0
dissect_goose_GSEMngtPdu(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
498
0
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
499
0
                                   GSEMngtPdu_sequence, hf_index, ett_goose_GSEMngtPdu);
500
501
0
  return offset;
502
0
}
503
504
505
506
static unsigned
507
0
dissect_goose_UtcTime(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
508
509
0
  uint32_t len;
510
0
  uint32_t seconds;
511
0
  uint32_t  fraction;
512
0
  uint32_t nanoseconds;
513
0
  nstime_t ts;
514
0
  char *  ptime;
515
516
0
  len = tvb_reported_length_remaining(tvb, offset);
517
518
0
  if(len != 8)
519
0
  {
520
0
    proto_tree_add_expert(tree, actx->pinfo, &ei_goose_mal_utctime, tvb, offset, len);
521
0
    if(hf_index > 0)
522
0
    {
523
0
      proto_tree_add_string(tree, hf_index, tvb, offset, len, "????");
524
0
    }
525
0
    return offset;
526
0
  }
527
528
0
  seconds = tvb_get_ntohl(tvb, offset);
529
0
  fraction = tvb_get_ntoh24(tvb, offset+4) * 0x100; /* Only 3 bytes are recommended */
530
0
  nanoseconds = (uint32_t)( ((uint64_t)fraction * UINT64_C(1000000000)) / UINT64_C(0x100000000) ) ;
531
532
0
  ts.secs = seconds;
533
0
  ts.nsecs = nanoseconds;
534
535
0
  ptime = abs_time_to_str(actx->pinfo->pool, &ts, ABSOLUTE_TIME_UTC, true);
536
537
0
  if(hf_index > 0)
538
0
  {
539
0
    proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime);
540
0
  }
541
542
543
0
  return offset;
544
0
}
545
546
547
548
static unsigned
549
0
dissect_goose_T_simulation(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
550
0
  bool value;
551
0
  uint32_t len = tvb_reported_length_remaining(tvb, offset);
552
0
  int origin_offset = offset;
553
0
  offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &value);
554
555
0
  if((actx->private_data) && (actx->created_item)){
556
0
    goose_chk_data_t *data_chk = (goose_chk_data_t *)actx->private_data;
557
0
    proto_tree *expert_inf_tree = NULL;
558
    /* S bit set and Simulation attribute clear: reject as invalid GOOSE */
559
0
    if((data_chk->s_bit == true) && (value == false)){
560
      /* It really looks better showed as a new subtree */
561
0
      expert_inf_tree = proto_item_add_subtree(actx->created_item, ett_expert_inf_sim);
562
0
      proto_tree_add_expert(expert_inf_tree, actx->pinfo, &ei_goose_invalid_sim, tvb, origin_offset, len);
563
0
    }
564
0
  }
565
566
0
  return offset;
567
0
}
568
569
570
571
static unsigned
572
0
dissect_goose_BOOLEAN(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
573
0
  offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
574
575
0
  return offset;
576
0
}
577
578
579
static const ber_sequence_t SEQUENCE_OF_Data_sequence_of[1] = {
580
  { &hf_goose_allData_item  , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_goose_Data },
581
};
582
583
static unsigned
584
0
dissect_goose_SEQUENCE_OF_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
585
0
  offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
586
0
                                      SEQUENCE_OF_Data_sequence_of, hf_index, ett_goose_SEQUENCE_OF_Data);
587
588
0
  return offset;
589
0
}
590
591
592
593
static unsigned
594
0
dissect_goose_BIT_STRING(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
595
0
  offset = dissect_ber_bitstring(implicit_tag, actx, tree, tvb, offset,
596
0
                                    NULL, 0, hf_index, -1,
597
0
                                    NULL);
598
599
0
  return offset;
600
0
}
601
602
603
604
static unsigned
605
0
dissect_goose_FloatingPoint(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
606
607
0
  int len = tvb_reported_length_remaining(tvb, offset);
608
609
0
    offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
610
0
                                       NULL);
611
612
0
  if ((len == FLOAT_ENC_LENGTH) && (tvb_get_uint8(tvb,0) == SINGLE_FLOAT_EXP_BITS) ){
613
    /* IEEE 754 single precision floating point */
614
0
    proto_item_set_hidden(actx->created_item);
615
0
    proto_tree_add_item(tree, hf_goose_float_value, tvb, 1, (FLOAT_ENC_LENGTH-1), ENC_BIG_ENDIAN);
616
0
  }
617
618
619
0
  return offset;
620
0
}
621
622
623
624
static unsigned
625
0
dissect_goose_REAL(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
626
0
  offset = dissect_ber_real(implicit_tag, actx, tree, tvb, offset, hf_index,
627
0
                               NULL);
628
629
0
  return offset;
630
0
}
631
632
633
634
static unsigned
635
0
dissect_goose_OCTET_STRING(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
636
0
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
637
0
                                       NULL);
638
639
0
  return offset;
640
0
}
641
642
643
644
static unsigned
645
0
dissect_goose_TimeOfDay(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
646
0
  offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
647
0
                                       NULL);
648
649
0
  return offset;
650
0
}
651
652
653
654
static unsigned
655
0
dissect_goose_OBJECT_IDENTIFIER(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
656
0
  offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
657
658
0
  return offset;
659
0
}
660
661
662
663
static unsigned
664
0
dissect_goose_MMSString(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
665
0
  offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_UTF8String,
666
0
                                            actx, tree, tvb, offset, hf_index,
667
0
                                            NULL);
668
669
0
  return offset;
670
0
}
671
672
673
static const value_string goose_Data_vals[] = {
674
  {   1, "array" },
675
  {   2, "structure" },
676
  {   3, "boolean" },
677
  {   4, "bit-string" },
678
  {   5, "integer" },
679
  {   6, "unsigned" },
680
  {   7, "floating-point" },
681
  {   8, "real" },
682
  {   9, "octet-string" },
683
  {  10, "visible-string" },
684
  {  12, "binary-time" },
685
  {  13, "bcd" },
686
  {  14, "booleanArray" },
687
  {  15, "objId" },
688
  {  16, "mMSString" },
689
  {  17, "utc-time" },
690
  { 0, NULL }
691
};
692
693
static const ber_choice_t Data_choice[] = {
694
  {   1, &hf_goose_array         , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_SEQUENCE_OF_Data },
695
  {   2, &hf_goose_structure     , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_goose_SEQUENCE_OF_Data },
696
  {   3, &hf_goose_boolean       , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_goose_BOOLEAN },
697
  {   4, &hf_goose_bit_string    , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_goose_BIT_STRING },
698
  {   5, &hf_goose_integer       , BER_CLASS_CON, 5, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
699
  {   6, &hf_goose_unsigned      , BER_CLASS_CON, 6, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
700
  {   7, &hf_goose_floating_point, BER_CLASS_CON, 7, BER_FLAGS_IMPLTAG, dissect_goose_FloatingPoint },
701
  {   8, &hf_goose_real          , BER_CLASS_CON, 8, BER_FLAGS_IMPLTAG, dissect_goose_REAL },
702
  {   9, &hf_goose_octet_string  , BER_CLASS_CON, 9, BER_FLAGS_IMPLTAG, dissect_goose_OCTET_STRING },
703
  {  10, &hf_goose_visible_string, BER_CLASS_CON, 10, BER_FLAGS_IMPLTAG, dissect_goose_VisibleString },
704
  {  12, &hf_goose_binary_time   , BER_CLASS_CON, 12, BER_FLAGS_IMPLTAG, dissect_goose_TimeOfDay },
705
  {  13, &hf_goose_bcd           , BER_CLASS_CON, 13, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
706
  {  14, &hf_goose_booleanArray  , BER_CLASS_CON, 14, BER_FLAGS_IMPLTAG, dissect_goose_BIT_STRING },
707
  {  15, &hf_goose_objId         , BER_CLASS_CON, 15, BER_FLAGS_IMPLTAG, dissect_goose_OBJECT_IDENTIFIER },
708
  {  16, &hf_goose_mMSString     , BER_CLASS_CON, 16, BER_FLAGS_IMPLTAG, dissect_goose_MMSString },
709
  {  17, &hf_goose_utc_time      , BER_CLASS_CON, 17, BER_FLAGS_IMPLTAG, dissect_goose_UtcTime },
710
  { 0, NULL, 0, 0, 0, NULL }
711
};
712
713
static unsigned
714
0
dissect_goose_Data(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
715
  // Data -> Data/array -> Data
716
0
  actx->pinfo->dissection_depth += 2;
717
0
  increment_dissection_depth(actx->pinfo);
718
0
  offset = dissect_ber_choice(actx, tree, tvb, offset,
719
0
                                 Data_choice, hf_index, ett_goose_Data,
720
0
                                 NULL);
721
722
0
  actx->pinfo->dissection_depth -= 2;
723
0
  decrement_dissection_depth(actx->pinfo);
724
0
  return offset;
725
0
}
726
727
728
static const ber_sequence_t IECGoosePdu_sequence[] = {
729
  { &hf_goose_gocbRef       , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_goose_VisibleString },
730
  { &hf_goose_timeAllowedtoLive, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
731
  { &hf_goose_datSet        , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_goose_VisibleString },
732
  { &hf_goose_goID          , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_goose_VisibleString },
733
  { &hf_goose_t             , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_goose_UtcTime },
734
  { &hf_goose_stNum         , BER_CLASS_CON, 5, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
735
  { &hf_goose_sqNum         , BER_CLASS_CON, 6, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
736
  { &hf_goose_simulation    , BER_CLASS_CON, 7, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_goose_T_simulation },
737
  { &hf_goose_confRev       , BER_CLASS_CON, 8, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
738
  { &hf_goose_ndsCom        , BER_CLASS_CON, 9, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_goose_BOOLEAN },
739
  { &hf_goose_numDatSetEntries, BER_CLASS_CON, 10, BER_FLAGS_IMPLTAG, dissect_goose_INTEGER },
740
  { &hf_goose_allData       , BER_CLASS_CON, 11, BER_FLAGS_IMPLTAG, dissect_goose_SEQUENCE_OF_Data },
741
  { NULL, 0, 0, 0, NULL }
742
};
743
744
static unsigned
745
1
dissect_goose_IECGoosePdu(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
746
1
  offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
747
1
                                   IECGoosePdu_sequence, hf_index, ett_goose_IECGoosePdu);
748
749
1
  return offset;
750
1
}
751
752
753
static const ber_choice_t GOOSEpdu_choice[] = {
754
  {   0, &hf_goose_gseMngtPdu    , BER_CLASS_APP, 0, BER_FLAGS_IMPLTAG, dissect_goose_GSEMngtPdu },
755
  {   1, &hf_goose_goosePdu      , BER_CLASS_APP, 1, BER_FLAGS_IMPLTAG, dissect_goose_IECGoosePdu },
756
  { 0, NULL, 0, 0, 0, NULL }
757
};
758
759
static unsigned
760
16
dissect_goose_GOOSEpdu(bool implicit_tag _U_, tvbuff_t *tvb _U_, unsigned offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
761
16
  offset = dissect_ber_choice(actx, tree, tvb, offset,
762
16
                                 GOOSEpdu_choice, hf_index, ett_goose_GOOSEpdu,
763
16
                                 NULL);
764
765
16
  return offset;
766
16
}
767
768
769
static dissector_handle_t goose_handle;
770
771
772
#define OSI_SPDU_TUNNELED 0xA0 /* Tunneled */
773
30
#define OSI_SPDU_GOOSE    0xA1 /* GOOSE */
774
#define OSI_SPDU_SV       0xA2 /* Sample Value */
775
#define OSI_SPDU_MNGT     0xA3 /* Management */
776
777
static const value_string ositp_spdu_id[] = {
778
  { OSI_SPDU_TUNNELED, "Tunneled" },
779
  { OSI_SPDU_GOOSE,    "GOOSE" },
780
  { OSI_SPDU_SV,       "Sample value" },
781
  { OSI_SPDU_MNGT,     "Management" },
782
  { 0,       NULL }
783
};
784
785
2
#define OSI_PDU_GOOSE     0x81
786
#define OSI_PDU_SV        0x82
787
#define OSI_PDU_TUNNELED  0x83
788
#define OSI_PDU_MNGT      0x84
789
790
static const value_string ositp_pdu_id[] = {
791
  { OSI_PDU_GOOSE,     "GOOSE" },
792
  { OSI_PDU_SV,        "SV" },
793
  { OSI_PDU_TUNNELED,  "Tunnel" },
794
  { OSI_PDU_MNGT,      "MNGT" },
795
  { 0,       NULL }
796
};
797
798
0
#define APDU_HEADER_SIZE 6
799
800
/*
801
* Dissect GOOSE PDUs inside a PPDU.
802
*/
803
static int
804
dissect_goose(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
805
        void* data _U_)
806
23
{
807
23
  uint32_t offset = 0;
808
23
  uint32_t old_offset;
809
23
  uint32_t length;
810
23
  uint32_t reserve1_val;
811
23
  proto_item *item = NULL;
812
23
  proto_item *tree_item = NULL;
813
23
  proto_tree *tree = NULL;
814
23
  goose_chk_data_t *data_chk = NULL;
815
23
  asn1_ctx_t asn1_ctx;
816
23
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
817
818
23
  static int * const reserve1_flags[] = {
819
23
    &hf_goose_reserve1_s_bit,
820
23
    NULL
821
23
  };
822
823
23
  asn1_ctx.private_data = wmem_alloc(pinfo->pool, GOOSE_CHK_DATA_LEN);
824
23
  data_chk = (goose_chk_data_t *)asn1_ctx.private_data;
825
826
23
  col_set_str(pinfo->cinfo, COL_PROTOCOL, GOOSE_PNAME);
827
23
  col_clear(pinfo->cinfo, COL_INFO);
828
829
23
  tree_item = proto_tree_add_item(parent_tree, proto_goose, tvb, 0, -1, ENC_NA);
830
23
  tree = proto_item_add_subtree(tree_item, ett_goose);
831
23
  add_ber_encoded_label(tvb, pinfo, parent_tree);
832
833
834
  /* APPID */
835
23
  proto_tree_add_item(tree, hf_goose_appid, tvb, offset, 2, ENC_BIG_ENDIAN);
836
837
  /* Length */
838
23
  item = proto_tree_add_item_ret_uint(tree, hf_goose_length, tvb, offset + 2, 2,
839
23
                                            ENC_BIG_ENDIAN, &length);
840
23
        if (length < 8) {
841
7
            expert_add_info(pinfo, item, &ei_goose_bogus_length);
842
7
        }
843
23
        set_actual_length(tvb, length);
844
23
        proto_item_set_len(tree_item, length);
845
846
  /* Reserved 1 */
847
23
  reserve1_val = tvb_get_uint16(tvb, offset + 4, ENC_BIG_ENDIAN);
848
23
  proto_tree_add_bitmask_value(tree, tvb, offset + 4, hf_goose_reserve1, ett_reserve1,
849
23
            reserve1_flags, reserve1_val);
850
851
  /* Store the header sim value for later expert info checks */
852
23
  if(data_chk){
853
16
    if(reserve1_val & F_RESERVE1_S_BIT){
854
12
      data_chk->s_bit = true;
855
12
    }else{
856
4
      data_chk->s_bit = false;
857
4
    }
858
16
  }
859
860
861
  /* Reserved 2 */
862
23
  proto_tree_add_item(tree, hf_goose_reserve2, tvb, offset + 6, 2,
863
23
            ENC_BIG_ENDIAN);
864
865
23
  offset = 8;
866
28
  while (offset < length){
867
16
    old_offset = offset;
868
16
    offset = dissect_goose_GOOSEpdu(false, tvb, offset, &asn1_ctx , tree, -1);
869
16
    if (offset == old_offset) {
870
11
      proto_tree_add_expert(tree, pinfo, &ei_goose_zero_pdu, tvb, offset, -1);
871
11
      break;
872
11
    }
873
16
  }
874
875
23
  return tvb_captured_length(tvb);
876
23
}
877
878
/*
879
* Dissect RGOOSE PDUs inside ISO 8602/X.234 CLTP ConnectionLess
880
* Transport Protocol.
881
*/
882
static int
883
dissect_rgoose(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
884
         void* data _U_)
885
2
{
886
2
  unsigned offset = 0, old_offset = 0;
887
2
  uint32_t init_v_length, payload_tag, padding_length, length;
888
2
  uint32_t payload_length, apdu_offset = 0, apdu_length, apdu_simulation;
889
2
  proto_item *item = NULL;
890
2
  proto_tree *tree = NULL, *r_goose_tree = NULL, *sess_user_info_tree = NULL;
891
2
  goose_chk_data_t *data_chk = NULL;
892
2
  asn1_ctx_t asn1_ctx;
893
2
  asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, true, pinfo);
894
895
2
  asn1_ctx.private_data = wmem_alloc(pinfo->pool, GOOSE_CHK_DATA_LEN);
896
2
  data_chk = (goose_chk_data_t *)asn1_ctx.private_data;
897
898
2
  col_set_str(pinfo->cinfo, COL_PROTOCOL, R_GOOSE_PNAME);
899
2
  col_clear(pinfo->cinfo, COL_INFO);
900
901
2
  item = proto_tree_add_item(parent_tree, proto_r_goose, tvb, 0, -1, ENC_NA);
902
2
  r_goose_tree = proto_item_add_subtree(item, ett_r_goose);
903
904
  /* Session header subtree */
905
2
  item = proto_tree_add_item(r_goose_tree, hf_goose_session_header, tvb, 0,
906
2
                 -1, ENC_NA);
907
2
  tree = proto_item_add_subtree(item, ett_session_header);
908
909
  /* SPDU ID */
910
2
  proto_tree_add_item(tree, hf_goose_spdu_id, tvb, offset++, 1,
911
2
            ENC_BIG_ENDIAN);
912
  /* Session header length */
913
2
  proto_tree_add_item_ret_uint(tree, hf_goose_session_hdr_length, tvb, offset++, 1,
914
2
            ENC_BIG_ENDIAN, &length);
915
2
  proto_item_set_len(item, length + 2);
916
917
  /* Header content indicator */
918
2
  proto_tree_add_item(tree, hf_goose_content_id, tvb, offset++, 1,
919
2
            ENC_BIG_ENDIAN);
920
  /* Length */
921
2
  proto_tree_add_item(tree, hf_goose_hdr_length, tvb, offset++, 1,
922
2
            ENC_BIG_ENDIAN);
923
  /* SPDU length */
924
2
  proto_tree_add_item(tree, hf_goose_spdu_lenth, tvb, offset, 4,
925
2
            ENC_BIG_ENDIAN);
926
2
  offset += 4;
927
  /* SPDU number */
928
2
  proto_tree_add_item(tree, hf_goose_spdu_num, tvb, offset, 4,
929
2
            ENC_BIG_ENDIAN);
930
2
  offset += 4;
931
  /* Version */
932
2
  proto_tree_add_item(tree, hf_goose_version, tvb, offset, 2, ENC_BIG_ENDIAN);
933
2
  offset += 2;
934
935
  /* Security information subtree */
936
2
  item = proto_tree_add_item(tree, hf_goose_security_info, tvb, offset, -1,
937
2
                 ENC_NA);
938
2
  tree = proto_item_add_subtree(item, ett_security_info);
939
  /* Time of current key */
940
2
  proto_tree_add_item(tree, hf_goose_current_key_t, tvb, offset, 4,
941
2
            ENC_BIG_ENDIAN);
942
2
  offset += 4;
943
  /* Time of next key */
944
2
  proto_tree_add_item(tree, hf_goose_next_key_t, tvb, offset, 2,
945
2
            ENC_BIG_ENDIAN);
946
2
  offset += 2;
947
  /* Key ID */
948
2
  proto_tree_add_item(tree, hf_goose_key_id, tvb, offset, 4, ENC_BIG_ENDIAN);
949
2
  offset += 4;
950
  /* Initialization vector length */
951
2
  proto_tree_add_item_ret_uint(tree, hf_goose_init_vec_length, tvb, offset++, 1,
952
2
            ENC_BIG_ENDIAN, &init_v_length);
953
2
  proto_item_set_len(item, init_v_length + 11);
954
955
2
  if (init_v_length > 0) {
956
    /* Initialization vector bytes */
957
1
    proto_tree_add_item(tree, hf_goose_init_vec, tvb, offset, init_v_length,
958
1
              ENC_NA);
959
1
  }
960
2
  offset += init_v_length;
961
962
  /* Session user information subtree */
963
2
  item = proto_tree_add_item(r_goose_tree, hf_goose_session_user_info, tvb,
964
2
                 offset, -1, ENC_NA);
965
2
  sess_user_info_tree = proto_item_add_subtree(item, ett_payload);
966
967
  /* Payload subtree */
968
2
  item = proto_tree_add_item(sess_user_info_tree, hf_goose_payload, tvb,
969
2
                 offset, -1, ENC_NA);
970
2
  tree = proto_item_add_subtree(item, ett_payload);
971
  /* Payload length */
972
2
  proto_tree_add_item_ret_uint(tree, hf_goose_payload_length, tvb, offset, 4,
973
2
            ENC_BIG_ENDIAN, &payload_length);
974
2
  offset += 4;
975
976
2
  while (apdu_offset < payload_length){
977
    /* APDU tag */
978
2
    proto_tree_add_item_ret_uint(tree, hf_goose_apdu_tag, tvb, offset++, 1,
979
2
              ENC_BIG_ENDIAN, &payload_tag);
980
    /* Simulation flag */
981
2
    proto_tree_add_item_ret_uint(tree, hf_goose_apdu_simulation, tvb, offset++,
982
2
              1, ENC_BIG_ENDIAN, &apdu_simulation);
983
    /* APPID */
984
2
    proto_tree_add_item(tree, hf_goose_apdu_appid, tvb, offset, 2,
985
2
              ENC_BIG_ENDIAN);
986
2
    offset += 2;
987
988
2
    if (payload_tag != OSI_PDU_GOOSE) {
989
2
      return tvb_captured_length(tvb);
990
2
    }
991
992
    /* Store the header sim value for later expert info checks */
993
0
    if(data_chk){
994
0
      if(apdu_simulation){
995
0
        data_chk->s_bit = true;
996
0
      }else{
997
0
        data_chk->s_bit = false;
998
0
      }
999
0
    }
1000
1001
    /* APDU length */
1002
0
    proto_tree_add_item_ret_uint(tree, hf_goose_apdu_length, tvb, offset, 2,
1003
0
              ENC_BIG_ENDIAN, &apdu_length);
1004
1005
0
    apdu_offset += (APDU_HEADER_SIZE + apdu_length);
1006
0
    offset += 2;
1007
1008
0
    old_offset = offset;
1009
0
    offset = dissect_goose_GOOSEpdu(false, tvb, offset, &asn1_ctx , tree, -1);
1010
0
    if (offset == old_offset) {
1011
0
      proto_tree_add_expert(tree, pinfo, &ei_goose_zero_pdu, tvb, offset, -1);
1012
0
      break;
1013
0
    }
1014
0
  }
1015
1016
  /* Check do we have padding bytes */
1017
0
  if ((tvb_captured_length(tvb) > offset) &&
1018
0
    (tvb_get_uint8(tvb, offset) == 0xAF)) {
1019
    /* Padding subtree */
1020
0
    item = proto_tree_add_item(sess_user_info_tree, hf_goose_padding, tvb,
1021
0
                   offset, -1, ENC_NA);
1022
0
    tree = proto_item_add_subtree(item, ett_padding);
1023
1024
    /* Padding tag */
1025
0
    proto_tree_add_item(tree, hf_goose_padding_tag, tvb, offset++, 1,
1026
0
              ENC_NA);
1027
    /* Padding length */
1028
0
    proto_tree_add_item_ret_uint(tree, hf_goose_padding_length, tvb, offset++, 1,
1029
0
              ENC_BIG_ENDIAN, &padding_length);
1030
0
    proto_item_set_len(item, padding_length + 1);
1031
1032
    /* Padding bytes */
1033
0
    proto_tree_add_item(tree, hf_goose_padding, tvb, offset, padding_length,
1034
0
              ENC_NA);
1035
0
    offset += padding_length;
1036
0
  }
1037
1038
  /* Check do we have HMAC bytes */
1039
0
  if (tvb_captured_length(tvb) > offset) {
1040
    /* HMAC bytes */
1041
0
    proto_tree_add_item(sess_user_info_tree, hf_goose_hmac, tvb, offset,
1042
0
      tvb_captured_length(tvb) - offset, ENC_NA);
1043
0
  }
1044
1045
0
  return tvb_captured_length(tvb);
1046
2
}
1047
1048
static bool
1049
dissect_rgoose_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
1050
          void *data)
1051
42
{
1052
42
  uint8_t spdu;
1053
1054
  /* Check do we have at least min size of Session header bytes */
1055
42
  if (tvb_captured_length(tvb) < 27) {
1056
12
    return false;
1057
12
  }
1058
1059
  /* Is it R-GOOSE? */
1060
30
  spdu = tvb_get_uint8(tvb, 0);
1061
30
  if (spdu != OSI_SPDU_GOOSE) {
1062
28
    return false;
1063
28
  }
1064
1065
2
  dissect_rgoose(tvb, pinfo, parent_tree, data);
1066
2
  return true;
1067
30
}
1068
1069
/*--- proto_register_goose -------------------------------------------*/
1070
14
void proto_register_goose(void) {
1071
1072
  /* List of fields */
1073
14
  static hf_register_info hf[] =
1074
14
  {
1075
14
    { &hf_goose_session_header,
1076
14
    { "Session header", "rgoose.session_hdr",
1077
14
      FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1078
1079
14
    { &hf_goose_spdu_id,
1080
14
    { "Session identifier", "rgoose.spdu_id",
1081
14
      FT_UINT8, BASE_HEX_DEC, VALS(ositp_spdu_id), 0x0, NULL, HFILL }},
1082
1083
14
    { &hf_goose_session_hdr_length,
1084
14
    { "Session header length", "rgoose.session_hdr_len",
1085
14
      FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1086
1087
14
    { &hf_goose_content_id,
1088
14
    { "Common session header identifier", "rgoose.common_session_id",
1089
14
      FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1090
1091
14
    { &hf_goose_hdr_length,
1092
14
    { "Header length", "rgoose.hdr_len",
1093
14
      FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1094
1095
14
    { &hf_goose_spdu_lenth,
1096
14
    { "SPDU length", "rgoose.spdu_len",
1097
14
      FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1098
1099
14
    { &hf_goose_spdu_num,
1100
14
    { "SPDU number", "rgoose.spdu_num",
1101
14
      FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1102
1103
14
    { &hf_goose_version,
1104
14
    { "Version", "rgoose.version",
1105
14
      FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1106
1107
14
    { &hf_goose_security_info,
1108
14
    { "Security information", "rgoose.sec_info",
1109
14
      FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1110
1111
14
    { &hf_goose_current_key_t,
1112
14
    { "Time of current key", "rgoose.curr_key_t",
1113
14
       FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1114
1115
14
    { &hf_goose_next_key_t,
1116
14
    { "Time of next key", "rgoose.next_key_t",
1117
14
      FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1118
1119
14
    { &hf_goose_key_id,
1120
14
    { "Key ID", "rgoose.key_id",
1121
14
      FT_UINT32, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1122
1123
14
    { &hf_goose_init_vec_length,
1124
14
    { "Initialization vector length", "rgoose.init_v_len",
1125
14
      FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1126
1127
14
    { &hf_goose_init_vec,
1128
14
    { "Initialization vector", "rgoose.init_v",
1129
14
      FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1130
1131
14
    { &hf_goose_session_user_info,
1132
14
    { "Session user information", "rgoose.session_user_info",
1133
14
      FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1134
1135
14
    { &hf_goose_payload,
1136
14
    { "Payload", "rgoose.payload",
1137
14
      FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1138
1139
14
    { &hf_goose_payload_length,
1140
14
    { "Payload length", "rgoose.payload_len",
1141
14
      FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1142
1143
14
    { &hf_goose_apdu_tag,
1144
14
    { "Payload type tag", "rgoose.pdu_tag",
1145
14
      FT_UINT8, BASE_HEX_DEC, VALS(ositp_pdu_id), 0x0, NULL, HFILL }},
1146
1147
14
    { &hf_goose_apdu_simulation,
1148
14
    { "Simulation flag", "rgoose.simulation",
1149
14
      FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1150
1151
14
    { &hf_goose_apdu_appid,
1152
14
    { "APPID", "rgoose.appid",
1153
14
      FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1154
1155
14
    { &hf_goose_apdu_length,
1156
14
    { "APDU length", "rgoose.apdu_len",
1157
14
      FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1158
1159
14
    { &hf_goose_padding_tag,
1160
14
    { "Padding", "rgoose.padding_tag",
1161
14
      FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1162
1163
14
    { &hf_goose_padding_length,
1164
14
    { "Padding length", "rgoose.padding_len",
1165
14
      FT_UINT8, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1166
1167
14
    { &hf_goose_padding,
1168
14
    { "Padding", "rgoose.padding",
1169
14
      FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1170
1171
14
    { &hf_goose_hmac,
1172
14
    { "HMAC", "rgoose.hmac",
1173
14
      FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1174
1175
14
    { &hf_goose_appid,
1176
14
    { "APPID", "goose.appid",
1177
14
      FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1178
1179
14
    { &hf_goose_length,
1180
14
    { "Length", "goose.length",
1181
14
      FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
1182
1183
14
    { &hf_goose_reserve1,
1184
14
    { "Reserved 1", "goose.reserve1",
1185
14
      FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1186
1187
14
    { &hf_goose_reserve1_s_bit,
1188
14
    { "Simulated",  "goose.reserve1.s_bit",
1189
14
      FT_BOOLEAN, 16, NULL, F_RESERVE1_S_BIT, NULL, HFILL } },
1190
1191
14
    { &hf_goose_reserve2,
1192
14
    { "Reserved 2", "goose.reserve2",
1193
14
      FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
1194
1195
14
    { &hf_goose_float_value,
1196
14
    { "float value", "goose.float_value",
1197
14
      FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
1198
1199
14
    { &hf_goose_gseMngtPdu,
1200
14
      { "gseMngtPdu", "goose.gseMngtPdu_element",
1201
14
        FT_NONE, BASE_NONE, NULL, 0,
1202
14
        NULL, HFILL }},
1203
14
    { &hf_goose_goosePdu,
1204
14
      { "goosePdu", "goose.goosePdu_element",
1205
14
        FT_NONE, BASE_NONE, NULL, 0,
1206
14
        "IECGoosePdu", HFILL }},
1207
14
    { &hf_goose_stateID,
1208
14
      { "stateID", "goose.stateID",
1209
14
        FT_INT32, BASE_DEC, NULL, 0,
1210
14
        "INTEGER", HFILL }},
1211
14
    { &hf_goose_requestResp,
1212
14
      { "requestResp", "goose.requestResp",
1213
14
        FT_UINT32, BASE_DEC, VALS(goose_RequestResponse_vals), 0,
1214
14
        "RequestResponse", HFILL }},
1215
14
    { &hf_goose_requests,
1216
14
      { "requests", "goose.requests",
1217
14
        FT_UINT32, BASE_DEC, VALS(goose_GSEMngtRequests_vals), 0,
1218
14
        "GSEMngtRequests", HFILL }},
1219
14
    { &hf_goose_responses,
1220
14
      { "responses", "goose.responses",
1221
14
        FT_UINT32, BASE_DEC, VALS(goose_GSEMngtResponses_vals), 0,
1222
14
        "GSEMngtResponses", HFILL }},
1223
14
    { &hf_goose_getGoReference,
1224
14
      { "getGoReference", "goose.getGoReference_element",
1225
14
        FT_NONE, BASE_NONE, NULL, 0,
1226
14
        "GetReferenceRequestPdu", HFILL }},
1227
14
    { &hf_goose_getGOOSEElementNumber,
1228
14
      { "getGOOSEElementNumber", "goose.getGOOSEElementNumber_element",
1229
14
        FT_NONE, BASE_NONE, NULL, 0,
1230
14
        "GetElementRequestPdu", HFILL }},
1231
14
    { &hf_goose_getGsReference,
1232
14
      { "getGsReference", "goose.getGsReference_element",
1233
14
        FT_NONE, BASE_NONE, NULL, 0,
1234
14
        "GetReferenceRequestPdu", HFILL }},
1235
14
    { &hf_goose_getGSSEDataOffset,
1236
14
      { "getGSSEDataOffset", "goose.getGSSEDataOffset_element",
1237
14
        FT_NONE, BASE_NONE, NULL, 0,
1238
14
        "GetElementRequestPdu", HFILL }},
1239
14
    { &hf_goose_gseMngtNotSupported,
1240
14
      { "gseMngtNotSupported", "goose.gseMngtNotSupported_element",
1241
14
        FT_NONE, BASE_NONE, NULL, 0,
1242
14
        NULL, HFILL }},
1243
14
    { &hf_goose_gseMngtResponses_GetGOReference,
1244
14
      { "getGoReference", "goose.gseMngtResponses_GetGOReference_element",
1245
14
        FT_NONE, BASE_NONE, NULL, 0,
1246
14
        "GSEMngtResponsePdu", HFILL }},
1247
14
    { &hf_goose_gseMngtResponses_GetGOOSEElementNumber,
1248
14
      { "getGOOSEElementNumber", "goose.gseMngtResponses_GetGOOSEElementNumber_element",
1249
14
        FT_NONE, BASE_NONE, NULL, 0,
1250
14
        "GSEMngtResponsePdu", HFILL }},
1251
14
    { &hf_goose_gseMngtResponses_GetGSReference,
1252
14
      { "getGsReference", "goose.gseMngtResponses_GetGSReference_element",
1253
14
        FT_NONE, BASE_NONE, NULL, 0,
1254
14
        "GSEMngtResponsePdu", HFILL }},
1255
14
    { &hf_goose_gseMngtResponses_GetGSSEDataOffset,
1256
14
      { "getGSSEDataOffset", "goose.gseMngtResponses_GetGSSEDataOffset_element",
1257
14
        FT_NONE, BASE_NONE, NULL, 0,
1258
14
        "GSEMngtResponsePdu", HFILL }},
1259
14
    { &hf_goose_ident,
1260
14
      { "ident", "goose.ident",
1261
14
        FT_STRING, BASE_NONE, NULL, 0,
1262
14
        "VisibleString", HFILL }},
1263
14
    { &hf_goose_getReferenceRequest_offset,
1264
14
      { "offset", "goose.getReferenceRequest.offset",
1265
14
        FT_UINT32, BASE_DEC, NULL, 0,
1266
14
        "T_getReferenceRequest_offset", HFILL }},
1267
14
    { &hf_goose_getReferenceRequest_offset_item,
1268
14
      { "offset item", "goose.getReferenceRequest_offset_item",
1269
14
        FT_INT32, BASE_DEC, NULL, 0,
1270
14
        "INTEGER", HFILL }},
1271
14
    { &hf_goose_references,
1272
14
      { "references", "goose.references",
1273
14
        FT_UINT32, BASE_DEC, NULL, 0,
1274
14
        NULL, HFILL }},
1275
14
    { &hf_goose_references_item,
1276
14
      { "references item", "goose.references_item",
1277
14
        FT_STRING, BASE_NONE, NULL, 0,
1278
14
        "VisibleString", HFILL }},
1279
14
    { &hf_goose_confRev,
1280
14
      { "confRev", "goose.confRev",
1281
14
        FT_INT32, BASE_DEC, NULL, 0,
1282
14
        "INTEGER", HFILL }},
1283
14
    { &hf_goose_posNeg,
1284
14
      { "posNeg", "goose.posNeg",
1285
14
        FT_UINT32, BASE_DEC, VALS(goose_PositiveNegative_vals), 0,
1286
14
        "PositiveNegative", HFILL }},
1287
14
    { &hf_goose_responsePositive,
1288
14
      { "responsePositive", "goose.responsePositive_element",
1289
14
        FT_NONE, BASE_NONE, NULL, 0,
1290
14
        NULL, HFILL }},
1291
14
    { &hf_goose_datSet,
1292
14
      { "datSet", "goose.datSet",
1293
14
        FT_STRING, BASE_NONE, NULL, 0,
1294
14
        "VisibleString", HFILL }},
1295
14
    { &hf_goose_result,
1296
14
      { "result", "goose.result",
1297
14
        FT_UINT32, BASE_DEC, NULL, 0,
1298
14
        "SEQUENCE_OF_RequestResults", HFILL }},
1299
14
    { &hf_goose_result_item,
1300
14
      { "RequestResults", "goose.RequestResults",
1301
14
        FT_UINT32, BASE_DEC, VALS(goose_RequestResults_vals), 0,
1302
14
        NULL, HFILL }},
1303
14
    { &hf_goose_responseNegative,
1304
14
      { "responseNegative", "goose.responseNegative",
1305
14
        FT_INT32, BASE_DEC, VALS(goose_GlbErrors_vals), 0,
1306
14
        "GlbErrors", HFILL }},
1307
14
    { &hf_goose_offset,
1308
14
      { "offset", "goose.offset",
1309
14
        FT_INT32, BASE_DEC, NULL, 0,
1310
14
        "INTEGER", HFILL }},
1311
14
    { &hf_goose_reference,
1312
14
      { "reference", "goose.reference",
1313
14
        FT_STRING, BASE_NONE, NULL, 0,
1314
14
        "IA5String", HFILL }},
1315
14
    { &hf_goose_error,
1316
14
      { "error", "goose.error",
1317
14
        FT_INT32, BASE_DEC, VALS(goose_ErrorReason_vals), 0,
1318
14
        "ErrorReason", HFILL }},
1319
14
    { &hf_goose_gocbRef,
1320
14
      { "gocbRef", "goose.gocbRef",
1321
14
        FT_STRING, BASE_NONE, NULL, 0,
1322
14
        "VisibleString", HFILL }},
1323
14
    { &hf_goose_timeAllowedtoLive,
1324
14
      { "timeAllowedtoLive", "goose.timeAllowedtoLive",
1325
14
        FT_INT32, BASE_DEC, NULL, 0,
1326
14
        "INTEGER", HFILL }},
1327
14
    { &hf_goose_goID,
1328
14
      { "goID", "goose.goID",
1329
14
        FT_STRING, BASE_NONE, NULL, 0,
1330
14
        "VisibleString", HFILL }},
1331
14
    { &hf_goose_t,
1332
14
      { "t", "goose.t",
1333
14
        FT_STRING, BASE_NONE, NULL, 0,
1334
14
        "UtcTime", HFILL }},
1335
14
    { &hf_goose_stNum,
1336
14
      { "stNum", "goose.stNum",
1337
14
        FT_UINT32, BASE_DEC, NULL, 0,
1338
14
        "INTEGER", HFILL }},
1339
14
    { &hf_goose_sqNum,
1340
14
      { "sqNum", "goose.sqNum",
1341
14
        FT_UINT32, BASE_DEC, NULL, 0,
1342
14
        "INTEGER", HFILL }},
1343
14
    { &hf_goose_simulation,
1344
14
      { "simulation", "goose.simulation",
1345
14
        FT_BOOLEAN, BASE_NONE, NULL, 0,
1346
14
        "BOOLEAN", HFILL }},
1347
14
    { &hf_goose_ndsCom,
1348
14
      { "ndsCom", "goose.ndsCom",
1349
14
        FT_BOOLEAN, BASE_NONE, NULL, 0,
1350
14
        "BOOLEAN", HFILL }},
1351
14
    { &hf_goose_numDatSetEntries,
1352
14
      { "numDatSetEntries", "goose.numDatSetEntries",
1353
14
        FT_INT32, BASE_DEC, NULL, 0,
1354
14
        "INTEGER", HFILL }},
1355
14
    { &hf_goose_allData,
1356
14
      { "allData", "goose.allData",
1357
14
        FT_UINT32, BASE_DEC, NULL, 0,
1358
14
        "SEQUENCE_OF_Data", HFILL }},
1359
14
    { &hf_goose_allData_item,
1360
14
      { "Data", "goose.Data",
1361
14
        FT_UINT32, BASE_DEC, VALS(goose_Data_vals), 0,
1362
14
        NULL, HFILL }},
1363
14
    { &hf_goose_array,
1364
14
      { "array", "goose.array",
1365
14
        FT_UINT32, BASE_DEC, NULL, 0,
1366
14
        "SEQUENCE_OF_Data", HFILL }},
1367
14
    { &hf_goose_array_item,
1368
14
      { "Data", "goose.Data",
1369
14
        FT_UINT32, BASE_DEC, VALS(goose_Data_vals), 0,
1370
14
        NULL, HFILL }},
1371
14
    { &hf_goose_structure,
1372
14
      { "structure", "goose.structure",
1373
14
        FT_UINT32, BASE_DEC, NULL, 0,
1374
14
        "SEQUENCE_OF_Data", HFILL }},
1375
14
    { &hf_goose_structure_item,
1376
14
      { "Data", "goose.Data",
1377
14
        FT_UINT32, BASE_DEC, VALS(goose_Data_vals), 0,
1378
14
        NULL, HFILL }},
1379
14
    { &hf_goose_boolean,
1380
14
      { "boolean", "goose.boolean",
1381
14
        FT_BOOLEAN, BASE_NONE, NULL, 0,
1382
14
        NULL, HFILL }},
1383
14
    { &hf_goose_bit_string,
1384
14
      { "bit-string", "goose.bit_string",
1385
14
        FT_BYTES, BASE_NONE, NULL, 0,
1386
14
        NULL, HFILL }},
1387
14
    { &hf_goose_integer,
1388
14
      { "integer", "goose.integer",
1389
14
        FT_INT32, BASE_DEC, NULL, 0,
1390
14
        NULL, HFILL }},
1391
14
    { &hf_goose_unsigned,
1392
14
      { "unsigned", "goose.unsigned",
1393
14
        FT_INT32, BASE_DEC, NULL, 0,
1394
14
        "INTEGER", HFILL }},
1395
14
    { &hf_goose_floating_point,
1396
14
      { "floating-point", "goose.floating_point",
1397
14
        FT_BYTES, BASE_NONE, NULL, 0,
1398
14
        "FloatingPoint", HFILL }},
1399
14
    { &hf_goose_real,
1400
14
      { "real", "goose.real",
1401
14
        FT_DOUBLE, BASE_NONE, NULL, 0,
1402
14
        NULL, HFILL }},
1403
14
    { &hf_goose_octet_string,
1404
14
      { "octet-string", "goose.octet_string",
1405
14
        FT_BYTES, BASE_NONE, NULL, 0,
1406
14
        NULL, HFILL }},
1407
14
    { &hf_goose_visible_string,
1408
14
      { "visible-string", "goose.visible_string",
1409
14
        FT_STRING, BASE_NONE, NULL, 0,
1410
14
        "VisibleString", HFILL }},
1411
14
    { &hf_goose_binary_time,
1412
14
      { "binary-time", "goose.binary_time",
1413
14
        FT_BYTES, BASE_NONE, NULL, 0,
1414
14
        "TimeOfDay", HFILL }},
1415
14
    { &hf_goose_bcd,
1416
14
      { "bcd", "goose.bcd",
1417
14
        FT_INT32, BASE_DEC, NULL, 0,
1418
14
        "INTEGER", HFILL }},
1419
14
    { &hf_goose_booleanArray,
1420
14
      { "booleanArray", "goose.booleanArray",
1421
14
        FT_BYTES, BASE_NONE, NULL, 0,
1422
14
        "BIT_STRING", HFILL }},
1423
14
    { &hf_goose_objId,
1424
14
      { "objId", "goose.objId",
1425
14
        FT_OID, BASE_NONE, NULL, 0,
1426
14
        "OBJECT_IDENTIFIER", HFILL }},
1427
14
    { &hf_goose_mMSString,
1428
14
      { "mMSString", "goose.mMSString",
1429
14
        FT_STRING, BASE_NONE, NULL, 0,
1430
14
        NULL, HFILL }},
1431
14
    { &hf_goose_utc_time,
1432
14
      { "utc-time", "goose.utc_time",
1433
14
        FT_STRING, BASE_NONE, NULL, 0,
1434
14
        "UtcTime", HFILL }},
1435
14
  };
1436
1437
  /* List of subtrees */
1438
14
  static int *ett[] = {
1439
14
    &ett_r_goose,
1440
14
    &ett_session_header,
1441
14
    &ett_security_info,
1442
14
    &ett_session_user_info,
1443
14
    &ett_payload,
1444
14
    &ett_padding,
1445
14
    &ett_goose,
1446
14
    &ett_reserve1,
1447
14
    &ett_expert_inf_sim,
1448
14
    &ett_goose_GOOSEpdu,
1449
14
    &ett_goose_GSEMngtPdu,
1450
14
    &ett_goose_RequestResponse,
1451
14
    &ett_goose_GSEMngtRequests,
1452
14
    &ett_goose_GSEMngtResponses,
1453
14
    &ett_goose_GetReferenceRequestPdu,
1454
14
    &ett_goose_T_getReferenceRequest_offset,
1455
14
    &ett_goose_GetElementRequestPdu,
1456
14
    &ett_goose_T_references,
1457
14
    &ett_goose_GSEMngtResponsePdu,
1458
14
    &ett_goose_PositiveNegative,
1459
14
    &ett_goose_T_responsePositive,
1460
14
    &ett_goose_SEQUENCE_OF_RequestResults,
1461
14
    &ett_goose_RequestResults,
1462
14
    &ett_goose_IECGoosePdu,
1463
14
    &ett_goose_SEQUENCE_OF_Data,
1464
14
    &ett_goose_Data,
1465
14
  };
1466
1467
14
  static ei_register_info ei[] = {
1468
14
    { &ei_goose_mal_utctime,
1469
14
    { "goose.malformed.utctime", PI_MALFORMED, PI_WARN,
1470
14
      "BER Error: malformed UTCTime encoding", EXPFILL }},
1471
14
    { &ei_goose_zero_pdu,
1472
14
    { "goose.zero_pdu", PI_PROTOCOL, PI_ERROR,
1473
14
      "Internal error, zero-byte GOOSE PDU", EXPFILL }},
1474
14
    { &ei_goose_invalid_sim,
1475
14
    { "goose.invalid_sim", PI_PROTOCOL, PI_WARN,
1476
14
      "Invalid GOOSE: S bit set and Simulation attribute clear", EXPFILL }},
1477
14
    { &ei_goose_bogus_length,
1478
14
    { "goose.bogus_length", PI_PROTOCOL, PI_ERROR,
1479
14
      "GOOSE length must be at least 8 (includes header)", EXPFILL }},
1480
14
  };
1481
1482
14
  expert_module_t* expert_goose;
1483
1484
  /* Register protocol */
1485
14
  proto_goose = proto_register_protocol(GOOSE_PNAME, GOOSE_PSNAME, GOOSE_PFNAME);
1486
14
  proto_r_goose = proto_register_protocol(R_GOOSE_PNAME, R_GOOSE_PSNAME, R_GOOSE_PFNAME);
1487
1488
14
  goose_handle = register_dissector("goose", dissect_goose, proto_goose);
1489
1490
  /* Register fields and subtrees */
1491
14
  proto_register_field_array(proto_goose, hf, array_length(hf));
1492
14
  proto_register_subtree_array(ett, array_length(ett));
1493
14
  expert_goose = expert_register_protocol(proto_goose);
1494
14
  expert_register_field_array(expert_goose, ei, array_length(ei));
1495
1496
14
}
1497
1498
/*--- proto_reg_handoff_goose --- */
1499
14
void proto_reg_handoff_goose(void) {
1500
1501
14
  dissector_add_uint("ethertype", ETHERTYPE_IEC61850_GOOSE, goose_handle);
1502
1503
14
  heur_dissector_add("cltp", dissect_rgoose_heur,
1504
14
    "R-GOOSE (GOOSE over CLTP)", "rgoose_cltp", proto_goose, HEURISTIC_ENABLE);
1505
14
}