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-gbcs.c
Line
Count
Source
1
/* packet-gbcs.c
2
 *
3
 * Dissector for Great Britain Companion Specification (GBCS) used in the Smart Metering Equipment Technical Specifications (SMETS)
4
 *
5
 * The Smart Metering Equipment Technical Specifications (SMETS) requires that Gas Smart Metering Equipment (GSME), and Electricity
6
 * Smart Metering Equipment (ESME) including variants, meet the requirements described in
7
 * the Great Britain Companion Specification (GBCS).
8
 *
9
 * GBCS messages are end-to-end and contains ZigBee, DLMS or ASN.1 formatted payloads. The GBCS messages are transported via IP
10
 * or via the ZigBee Tunneling cluster.
11
 *
12
 * https://smartenergycodecompany.co.uk/document-download-centre/download-info/gbcs-v2-1/
13
 *
14
 * Sample capture is attached in Bug 15381
15
 *
16
 * Wireshark - Network traffic analyzer
17
 * By Gerald Combs <gerald@wireshark.org>
18
 * Copyright 1998 Gerald Combs
19
 *
20
 * SPDX-License-Identifier: GPL-2.0-or-later
21
 */
22
23
#include "config.h"
24
#include <epan/packet.h>
25
#include <epan/expert.h>
26
#include <epan/reassemble.h>
27
#include "packet-ber.h"
28
#include "packet-zbee.h"
29
#include "packet-zbee-nwk.h"
30
#include "packet-zbee-zcl.h"
31
#include "packet-zbee-aps.h"
32
#include <wsutil/epochs.h>
33
#include <wsutil/time_util.h>
34
35
#define gbcs_message_code_names_VALUE_STRING_LIST(XXX) \
36
    XXX(GBCS_MESSAGE_CCS01,      0x0001, "CCS01 Add Device to CHF device log") \
37
    XXX(GBCS_MESSAGE_CCS02,      0x0002, "CCS02 Remove device from CHF device log") \
38
    XXX(GBCS_MESSAGE_CCS03,      0x0003, "CCS03 Restore CHF Device Log") \
39
    XXX(GBCS_MESSAGE_CCS05CCS04, 0x0004, "CCS05/CCS04 Read CHF device log / Check HAN communications (by reading the CHF Communications Store)") \
40
    XXX(GBCS_MESSAGE_CS01A,      0x0007, "CS01a Apply Pre-payment Top Up to an ESME") \
41
    XXX(GBCS_MESSAGE_CS02A,      0x0008, "CS02a Provide Security Credentials Details") \
42
    XXX(GBCS_MESSAGE_CS02C,      0x000A, "CS02c Issue Security Credentials ") \
43
    XXX(GBCS_MESSAGE_CS02D,      0x000B, "CS02d Update Device Certificates on Device") \
44
    XXX(GBCS_MESSAGE_CS02E,      0x000C, "CS02e Provide Device Certificates from Device ") \
45
    XXX(GBCS_MESSAGE_CS03A1,     0x000D, "CS03a1 Method A Join (Meter)") \
46
    XXX(GBCS_MESSAGE_CS03B,      0x000E, "CS03b Method B Join") \
47
    XXX(GBCS_MESSAGE_CS04AC,     0x000F, "CS04ac Method A or C Unjoin") \
48
    XXX(GBCS_MESSAGE_CS04B,      0x0010, "CS04b Method B Unjoin") \
49
    XXX(GBCS_MESSAGE_CS06,       0x0012, "CS06 Activate Firmware") \
50
    XXX(GBCS_MESSAGE_CS07,       0x0013, "CS07 Read Device Join Details") \
51
    XXX(GBCS_MESSAGE_CS10A,      0x0014, "CS10a Read ZigBee Device Event Log") \
52
    XXX(GBCS_MESSAGE_CS11,       0x0015, "CS11 Clear ZigBee Device Event Log") \
53
    XXX(GBCS_MESSAGE_CS14,       0x0018, "CS14 Device Addition To / Removal From HAN Whitelist Alerts") \
54
    XXX(GBCS_MESSAGE_ECS01A,     0x0019, "ECS01a Set Tariff and Price on ESME") \
55
    XXX(GBCS_MESSAGE_ECS02,      0x001A, "ECS02 Set ESME Payment Mode to Credit") \
56
    XXX(GBCS_MESSAGE_ECS03,      0x001B, "ECS03 Set ESME Payment Mode to Pre-payment") \
57
    XXX(GBCS_MESSAGE_ECS04A,     0x001C, "ECS04a Adjust Meter Balance on the ESME") \
58
    XXX(GBCS_MESSAGE_ECS05,      0x001D, "ECS05 Reset Tariff Block Counter Matrix") \
59
    XXX(GBCS_MESSAGE_ECS07,      0x001E, "ECS07 Manage Debt on the ESME") \
60
    XXX(GBCS_MESSAGE_ECS08,      0x001F, "ECS08 Update Pre-payment Configuration on ESME") \
61
    XXX(GBCS_MESSAGE_ECS09,      0x0020, "ECS09 Activate Emergency Credit Remotely on ESME") \
62
    XXX(GBCS_MESSAGE_ECS10,      0x0021, "ECS10 Send Message to ESME") \
63
    XXX(GBCS_MESSAGE_ECS12,      0x0022, "ECS12 Set Change of Tenancy date on ESME") \
64
    XXX(GBCS_MESSAGE_ECS14,      0x0023, "ECS14 Disable Privacy PIN Protection on ESME") \
65
    XXX(GBCS_MESSAGE_ECS15A,     0x0024, "ECS15a Clear ESME Event Log") \
66
    XXX(GBCS_MESSAGE_ECS16,      0x0025, "ECS16 Write Supplier Contact Details on ESME") \
67
    XXX(GBCS_MESSAGE_ECS17A,     0x0026, "ECS17a Read ESME Energy Registers (Export Energy)") \
68
    XXX(GBCS_MESSAGE_ECS17B,     0x0027, "ECS17b Read ESME Energy Registers (Import Energy)") \
69
    XXX(GBCS_MESSAGE_ECS17C,     0x0028, "ECS17c Read ESME Energy Registers (Power)") \
70
    XXX(GBCS_MESSAGE_ECS17D,     0x0029, "ECS17d Read ESME Energy Register (TOU)") \
71
    XXX(GBCS_MESSAGE_ECS17E,     0x002A, "ECS17e Read ESME Energy Register (TOU with Blocks)") \
72
    XXX(GBCS_MESSAGE_ECS18A,     0x002B, "ECS18a Read Maximum Demand Registers (export)") \
73
    XXX(GBCS_MESSAGE_ECS18B,     0x002C, "ECS18b Read Maximum Demand Registers (import)") \
74
    XXX(GBCS_MESSAGE_ECS19,      0x002D, "ECS19 Read ESME Pre-payment Registers") \
75
    XXX(GBCS_MESSAGE_ECS20A,     0x002E, "ECS20a Read ESME Billing Data Log (payment based debt payments)") \
76
    XXX(GBCS_MESSAGE_ECS20B,     0x002F, "ECS20b Read ESME Billing Data Log (change of mode / tariff triggered exc export)") \
77
    XXX(GBCS_MESSAGE_ECS20C,     0x0030, "ECS20c Read ESME Billing Data Log (billing calendar triggered exc export)") \
78
    XXX(GBCS_MESSAGE_ECS21A,     0x0033, "ECS21a Read Electricity Daily Read Log (exc export)") \
79
    XXX(GBCS_MESSAGE_ECS21B,     0x0034, "ECS21b Read Electricity (Pre-payment) Daily Read Log") \
80
    XXX(GBCS_MESSAGE_ECS21C,     0x0035, "ECS21c Read Electricity Daily Read Log (export only)") \
81
    XXX(GBCS_MESSAGE_ECS22A,     0x0036, "ECS22a Read Electricity Half Hour Profile Data (export)") \
82
    XXX(GBCS_MESSAGE_ECS22B,     0x0037, "ECS22b Read Electricity Half Hour Profile Data (active import)") \
83
    XXX(GBCS_MESSAGE_ECS22C,     0x0038, "ECS22c Read Electricity Half Hour Profile Data (reactive import)") \
84
    XXX(GBCS_MESSAGE_ECS23,      0x0039, "ECS23 Read Voltage Operational Data") \
85
    XXX(GBCS_MESSAGE_ECS24,      0x003A, "ECS24 Read ESME Tariff Data") \
86
    XXX(GBCS_MESSAGE_ECS26A,     0x003B, "ECS26a Read ESME Configuration Data Pre-payment") \
87
    XXX(GBCS_MESSAGE_ECS26B,     0x003C, "ECS26b Read ESME Configuration Voltage Data") \
88
    XXX(GBCS_MESSAGE_ECS26C,     0x003D, "ECS26c Read ESME Configuration Data Device Information  (randomisation)") \
89
    XXX(GBCS_MESSAGE_ECS26D,     0x003E, "ECS26d Read ESME Configuration Data Device Information (Billing Calendar)") \
90
    XXX(GBCS_MESSAGE_ECS26E,     0x003F, "ECS26e Read ESME Configuration Data Device Information (device identity exc MPAN)") \
91
    XXX(GBCS_MESSAGE_ECS26F,     0x0040, "ECS26f Read ESME Configuration Data Device Information (instantaneous power thresholds)") \
92
    XXX(GBCS_MESSAGE_ECS27,      0x0042, "ECS27 Read ESME Load Limit Data") \
93
    XXX(GBCS_MESSAGE_ECS28A,     0x0043, "ECS28a Set Load Limit Configurations - General Settings") \
94
    XXX(GBCS_MESSAGE_ECS28B,     0x0044, "ECS28b Set Load Limit Configuration Counter Reset") \
95
    XXX(GBCS_MESSAGE_ECS29A,     0x0045, "ECS29a Set Voltage Configurations on ESME") \
96
    XXX(GBCS_MESSAGE_ECS30,      0x0046, "ECS30 Set Billing Calendar on the ESME") \
97
    XXX(GBCS_MESSAGE_ECS34,      0x0047, "ECS34 Set Instantaneous Power Threshold Configuration") \
98
    XXX(GBCS_MESSAGE_ECS35A,     0x0048, "ECS35a Read ESME Event Log") \
99
    XXX(GBCS_MESSAGE_ECS35B,     0x0049, "ECS35b Read ESME Security Log") \
100
    XXX(GBCS_MESSAGE_ECS37,      0x004A, "ECS37 Set Maximum Demand Configurable Time Period") \
101
    XXX(GBCS_MESSAGE_ECS38,      0x004B, "ECS38 Update Randomised Offset Limit") \
102
    XXX(GBCS_MESSAGE_ECS39A,     0x004C, "ECS39a Set MPAN Value on the ESME") \
103
    XXX(GBCS_MESSAGE_ECS39B,     0x004D, "ECS39b Set Export MPAN Value on the ESME") \
104
    XXX(GBCS_MESSAGE_ECS40,      0x004E, "ECS40 Read MPAN Value on the ESME") \
105
    XXX(GBCS_MESSAGE_ECS42,      0x004F, "ECS42 Remotely Close the Load Switch on the ESME") \
106
    XXX(GBCS_MESSAGE_ECS43,      0x0050, "ECS43 Remotely Open the Load Switch on the ESME") \
107
    XXX(GBCS_MESSAGE_ECS44,      0x0051, "ECS44 Arm Load Switch in ESME") \
108
    XXX(GBCS_MESSAGE_ECS45,      0x0052, "ECS45 Read Status of Load Switch in the ESME") \
109
    XXX(GBCS_MESSAGE_ECS46A,     0x0053, "ECS46a Set HC ALCS or ALCS Labels in ESME") \
110
    XXX(GBCS_MESSAGE_ECS46C,     0x0054, "ECS46c Set HC ALCS and ALCS configuration in ESME (excluding labels)") \
111
    XXX(GBCS_MESSAGE_ECS47,      0x0055, "ECS47 Set or Reset HC ALCS or ALCS State") \
112
    XXX(GBCS_MESSAGE_ECS50,      0x0058, "ECS50 Send CIN to ESME") \
113
    XXX(GBCS_MESSAGE_ECS52,      0x0059, "ECS52 Read ESME/Comms Hub Firmware Version") \
114
    XXX(GBCS_MESSAGE_ECS57,      0x005A, "ECS57 Reset ESME Maximum Demand Registers") \
115
    XXX(GBCS_MESSAGE_ECS61C,     0x005E, "ECS61c Read Boost Button Data from ESME") \
116
    XXX(GBCS_MESSAGE_ECS62,      0x005F, "ECS62 Set ALCS and Boost Button Association") \
117
    XXX(GBCS_MESSAGE_ECS66,      0x0060, "ECS66 Read ESME Daily Consumption Log") \
118
    XXX(GBCS_MESSAGE_ECS68,      0x0061, "ECS68 ESME Critical Sensitive Alert (Billing Data Log)") \
119
    XXX(GBCS_MESSAGE_ECS70,      0x0062, "ECS70 Set Clock on ESME") \
120
    XXX(GBCS_MESSAGE_ECS80,      0x0067, "ECS80 Supply Outage Restore Alert from ESME") \
121
    XXX(GBCS_MESSAGE_ECS81,      0x0068, "ECS81 Set Supply Tamper State on ESME") \
122
    XXX(GBCS_MESSAGE_ECS82,      0x0069, "ECS82 Read Meter Balance for ESME") \
123
    XXX(GBCS_MESSAGE_GCS01A,     0x006B, "GCS01a Set Tariff and Price on GSME") \
124
    XXX(GBCS_MESSAGE_GCS02,      0x006C, "GCS02 Set GSME Payment Mode to Credit") \
125
    XXX(GBCS_MESSAGE_GCS03,      0x006D, "GCS03 Set GSME Payment Mode to Pre-payment") \
126
    XXX(GBCS_MESSAGE_GCS04,      0x006E, "GCS04 Manage Debt on the GSME") \
127
    XXX(GBCS_MESSAGE_GCS05,      0x006F, "GCS05 Update Pre-payment Configurations on GSME") \
128
    XXX(GBCS_MESSAGE_GCS06,      0x0070, "GCS06 Activate Emergency Credit Remotely on GSME") \
129
    XXX(GBCS_MESSAGE_GCS07,      0x0071, "GCS07 Send Message to GSME") \
130
    XXX(GBCS_MESSAGE_GCS09,      0x0072, "GCS09 Set Change of Tenancy date on GPF") \
131
    XXX(GBCS_MESSAGE_GCS11,      0x0073, "GCS11 Disable Privacy PIN Protection on GSME") \
132
    XXX(GBCS_MESSAGE_GCS13A,     0x0074, "GCS13a Read GSME Consumption Register") \
133
    XXX(GBCS_MESSAGE_GCS14,      0x0075, "GCS14 Read GSME Pre-payment Register(s)") \
134
    XXX(GBCS_MESSAGE_GCS15C,     0x0076, "GCS15c Read GSME Billing Data Log (billing calendar triggered)") \
135
    XXX(GBCS_MESSAGE_GCS16A,     0x0077, "GCS16a Read GSME Daily Read log(s)") \
136
    XXX(GBCS_MESSAGE_GCS17,      0x0078, "GCS17 Read GSME Profile Data Log") \
137
    XXX(GBCS_MESSAGE_GCS18,      0x0079, "GCS18 Read Gas Network Data Log") \
138
    XXX(GBCS_MESSAGE_GCS21A,     0x007B, "GCS21a Read Gas Configuration Data Device Information") \
139
    XXX(GBCS_MESSAGE_GCS23,      0x007C, "GCS23 Set CV and Conversion Factor Value(s) on the GSME") \
140
    XXX(GBCS_MESSAGE_GCS24,      0x007D, "GCS24 Set Uncontrolled Gas Flow Rate and Supply Tamper State on the GSME") \
141
    XXX(GBCS_MESSAGE_GCS25,      0x007E, "GCS25 Set Billing Calendar on the GSME") \
142
    XXX(GBCS_MESSAGE_GCS28,      0x007F, "GCS28 Set Clock on GSME") \
143
    XXX(GBCS_MESSAGE_GCS31,      0x0080, "GCS31 Start Network Data Log on GSME") \
144
    XXX(GBCS_MESSAGE_GCS32,      0x0081, "GCS32 Remotely close the valve in the GSME") \
145
    XXX(GBCS_MESSAGE_GCS33,      0x0082, "GCS33 Read GSME Valve Status") \
146
    XXX(GBCS_MESSAGE_GCS36,      0x0083, "GCS36 Send CIN to GSME") \
147
    XXX(GBCS_MESSAGE_GCS38,      0x0084, "GCS38 Read GSME Firmware Version") \
148
    XXX(GBCS_MESSAGE_GCS39,      0x0085, "GCS39 Arm Valve in GSME") \
149
    XXX(GBCS_MESSAGE_GCS40A,     0x0086, "GCS40a Adjust Pre-payment Mode Meter Balance on the GSME") \
150
    XXX(GBCS_MESSAGE_GCS41,      0x0087, "GCS41 Set MPRN Value on the GSME") \
151
    XXX(GBCS_MESSAGE_GCS44,      0x0088, "GCS44 Write Contact Details on GSME") \
152
    XXX(GBCS_MESSAGE_GCS46,      0x0089, "GCS46 Read MPRN on the GSME") \
153
    XXX(GBCS_MESSAGE_GCS53,      0x008B, "GCS53 Push Billing Data Log as an Alert") \
154
    XXX(GBCS_MESSAGE_GCS59,      0x008C, "GCS59 Restore GPF Device Log") \
155
    XXX(GBCS_MESSAGE_GCS60,      0x008D, "GCS60 Read Meter Balance for GSME") \
156
    XXX(GBCS_MESSAGE_PCS02,      0x0090, "PCS02 Activate Emergency Credit on GSME from PPMID") \
157
    XXX(GBCS_MESSAGE_ECS26I,     0x0092, "ECS26i Read Configuration Data Device Information (CHF identity)") \
158
    XXX(GBCS_MESSAGE_ECS35C,     0x0093, "ECS35c Read CHF Event Log") \
159
    XXX(GBCS_MESSAGE_ECS35D,     0x0094, "ECS35d Read CHF Security Log") \
160
    XXX(GBCS_MESSAGE_GCS16B,     0x0096, "GCS16b Read GSME Daily Read log(s) (pre-payment)") \
161
    XXX(GBCS_MESSAGE_CS01B,      0x0097, "CS01b Apply Pre-payment Top Up to a GSME") \
162
    XXX(GBCS_MESSAGE_PCS01,      0x009B, "PCS01 Apply Pre-payment Top Up to a GSME using PPMID") \
163
    XXX(GBCS_MESSAGE_GCS21D,     0x009D, "GCS21d Read GSME Configuration Data Device Information (BillingCalendar)") \
164
    XXX(GBCS_MESSAGE_GCS21E,     0x009E, "GCS21e Read GSME/GPF Configuration Data Device Information (device identity)") \
165
    XXX(GBCS_MESSAGE_GCS21F,     0x009F, "GCS21f Read GSME Tariff Data") \
166
    XXX(GBCS_MESSAGE_GCS61,      0x00A0, "GCS61 Read gas Daily Consumption Log") \
167
    XXX(GBCS_MESSAGE_CS10B,      0x00A1, "CS10b Read ZigBee Device Security Log") \
168
    XXX(GBCS_MESSAGE_ECS01B,     0x00A2, "ECS01b Set Price on ESME") \
169
    XXX(GBCS_MESSAGE_GCS01B,     0x00A3, "GCS01b Set Price on GSME") \
170
    XXX(GBCS_MESSAGE_CS03A2,     0x00AB, "CS03a2 Method A Join (non Meter)") \
171
    XXX(GBCS_MESSAGE_ECS25A,     0x00AC, "ECS25a Set Alert Behaviours - ESME - Supplier") \
172
    XXX(GBCS_MESSAGE_GCS20,      0x00AD, "GCS20 Set Alert Behaviours - GSME") \
173
    XXX(GBCS_MESSAGE_ECS29B,     0x00AE, "ECS29b Set Voltage Configurations on ESME - 3ph") \
174
    XXX(GBCS_MESSAGE_CS03C,      0x00AF, "CS03c Method C Join") \
175
    XXX(GBCS_MESSAGE_ECS25B,     0x00B0, "ECS25b Set Alert Behaviours - ESME - Network Operator") \
176
    XXX(GBCS_MESSAGE_GCS62,      0x00B2, "GCS62 Backup GPF Device Log") \
177
    XXX(GBCS_MESSAGE_ECS04B,     0x00B3, "ECS04b Reset Meter Balance on the ESME") \
178
    XXX(GBCS_MESSAGE_GCS40B,     0x00B4, "GCS40b Reset Pre-payment Mode Meter Balance on the GSME") \
179
    XXX(GBCS_MESSAGE_GCS21B,     0x00B5, "GCS21b Read GSME Configuration Data Pre-payment") \
180
    XXX(GBCS_MESSAGE_GCS13C,     0x00B6, "GCS13c Read GSME Register (TOU)") \
181
    XXX(GBCS_MESSAGE_ECS01C,     0x00B7, "ECS01c Set Tariff and Price on ESME secondary") \
182
    XXX(GBCS_MESSAGE_GCS13B,     0x00B8, "GCS13b Read GSME Block Counters") \
183
    XXX(GBCS_MESSAGE_ECS35E,     0x00B9, "ECS35e Read ESME Power Event Log") \
184
    XXX(GBCS_MESSAGE_ECS35F,     0x00BA, "ECS35f Read ALCS Event Log") \
185
    XXX(GBCS_MESSAGE_ECS61A,     0x00BB, "ECS61a Read HC ALCS and ALCS Data from ESME") \
186
    XXX(GBCS_MESSAGE_ECS23B,     0x00BC, "ECS23b Read Voltage Operational Data -3 Phase") \
187
    XXX(GBCS_MESSAGE_ECS24B,     0x00BD, "ECS24b Read ESME Tariff Data - second element") \
188
    XXX(GBCS_MESSAGE_ECS26J,     0x00BE, "ECS26j Read ESME Configuration Data Device Information (Payment Mode)") \
189
    XXX(GBCS_MESSAGE_GCS21J,     0x00BF, "GCS21j Read GSME Configuration Data Device Information (Payment Mode)") \
190
    XXX(GBCS_MESSAGE_GCS40C,     0x00C0, "GCS40c Adjust Credit Mode Meter Balance on the GSME") \
191
    XXX(GBCS_MESSAGE_ECS15C,     0x00C1, "ECS15c Clear ALCS Event Log") \
192
    XXX(GBCS_MESSAGE_GCS40D,     0x00C2, "GCS40d Reset Credit Mode Meter Balance on the GSME") \
193
    XXX(GBCS_MESSAGE_GCS15B,     0x00C3, "GCS15b Read GSME Billing Data Log (change of mode / tariff triggered)") \
194
    XXX(GBCS_MESSAGE_GCS15D,     0x00C4, "GCS15d Read GSME Billing Data Log (payment-based debt payments) ") \
195
    XXX(GBCS_MESSAGE_GCS15E,     0x00C5, "GCS15e Read GSME Billing Data Log (pre-payment credits)") \
196
    XXX(GBCS_MESSAGE_ECS26K,     0x00C6, "ECS26k Read ESME Configuration Voltage Data - 3 phase") \
197
    XXX(GBCS_MESSAGE_ECS01D,     0x00C7, "ECS01d Set Price on ESME secondary") \
198
    XXX(GBCS_MESSAGE_ECS20D,     0x00C9, "ECS20d Read ESME Billing Data Log (pre-payment credits)") \
199
    XXX(GBCS_MESSAGE_ALERT_00CA, 0x00CA, "Futured Dated Firmware Activation Alert") \
200
    XXX(GBCS_MESSAGE_ALERT_00CB, 0x00CB, "Futured Dated Updated Security Credentials Alert") \
201
    XXX(GBCS_MESSAGE_ALERT_00CC, 0x00CC, "Future Dated Execution Of Instruction Alert (DLMS COSEM)") \
202
    XXX(GBCS_MESSAGE_ALERT_00CD, 0x00CD, "Future Dated Execution Of Instruction Alert (GBZ)") \
203
    XXX(GBCS_MESSAGE_ALERT_00CE, 0x00CE, "Firmware Distribution Receipt Alert (ESME or Comms Hub)") \
204
    XXX(GBCS_MESSAGE_ALERT_00CF, 0x00CF, "Firmware Distribution Receipt Alert (GSME)") \
205
    XXX(GBCS_MESSAGE_ECS29C,     0x00D1, "ECS29c Set Voltage Configurations on ESME without counter reset") \
206
    XXX(GBCS_MESSAGE_ECS29D,     0x00D2, "ECS29d Set Voltage Configurations on polyphase ESME without counter reset") \
207
    XXX(GBCS_MESSAGE_ECS29E,     0x00D3, "ECS29e Reset RMS Voltage Counters on ESME") \
208
    XXX(GBCS_MESSAGE_ECS29F,     0x00D4, "ECS29f Reset RMS Voltage Counters on polyphase ESME") \
209
    XXX(GBCS_MESSAGE_ALERT_00D5, 0x00D5, "Failure to Deliver Remote Party Message to ESME Alert") \
210
    XXX(GBCS_MESSAGE_ECS30A,     0x00D7, "ECS30a Set Billing Calendar on the ESME - all periodicities") \
211
    XXX(GBCS_MESSAGE_GCS25A,     0x00D8, "GCS25a Set Billing Calendar on the GSME - all periodicities") \
212
    XXX(GBCS_MESSAGE_ECS26L,     0x00D9, "ECS26l Read ESME Configuration Data Device Information (Billing Calendar - all periodicities)") \
213
    XXX(GBCS_MESSAGE_GCS21K,     0x00DA, "GCS21k Read GSME Configuration Data Device Information (BillingCalendar - all periodicities)") \
214
    XXX(GBCS_MESSAGE_ECS48,      0x00DB, "ECS48 Configure daily resetting of Tariff Block Counter Matrix") \
215
    XXX(GBCS_MESSAGE_ECS08A,     0x00DE, "ECS08a Update Pre-payment Configuration on ESME") \
216
    XXX(GBCS_MESSAGE_ECS25A1,    0x00EA, "ECS25a1 Set Event Behaviours - ESME to HAN Device - Supplier") \
217
    XXX(GBCS_MESSAGE_ECS25A2,    0x00EB, "ECS25a2 Set Event Behaviours - ESME audible alarm - Supplier") \
218
    XXX(GBCS_MESSAGE_ECS25A3,    0x00EC, "ECS25a3 Set Event Behaviours - ESME logging - Supplier") \
219
    XXX(GBCS_MESSAGE_ECS25B3,    0x00ED, "ECS25b3 Set Event Behaviours - ESME logging - Network Operator") \
220
    XXX(GBCS_MESSAGE_ECS25R1,    0x00EE, "ECS25r1 Read non-critical event and alert behaviours - ESME-  Supplier") \
221
    XXX(GBCS_MESSAGE_ECS25R2,    0x00EF, "ECS25r2 Read non-critical event and alert behaviours - ESME-  Network Operator") \
222
    XXX(GBCS_MESSAGE_ALERT_00F0, 0x00F0, "Meter Integrity Issue Warning Alert - ESME") \
223
    XXX(GBCS_MESSAGE_GCS20R,     0x00F1, "GCS20r Read non-critical event and alert behaviours - GSME-  Supplier") \
224
    XXX(GBCS_MESSAGE_ALERT_00F2, 0x00F2, "Meter Integrity Issue Warning Alert - GSME") \
225
    XXX(GBCS_MESSAGE_ECS26M,     0x00F9, "ECS26m Read ESME Configuration Data Device Information (identity, type and supply tamper state)") \
226
    XXX(GBCS_MESSAGE_ECS26N,     0x00FA, "ECS26n Read CHF Configuration Data Device Information (CH identity and type)") \
227
    XXX(GBCS_MESSAGE_GCS21M,     0x00FB, "GCS21m Read GSME Configuration Data Device Information (identity, type and supply tamper / depletion state)") \
228
    XXX(GBCS_USECASE_GCS24A,     0x00FC, "GCS24a Set Uncontrolled Gas Flow Rate at greater resolution and Supply Tamper State on the GSME") \
229
    XXX(GBCS_MESSAGE_CS02B0,     0x0100, "CS02b Update Security Credentials - rootBySupplier") \
230
    XXX(GBCS_MESSAGE_CS02B1,     0x0101, "CS02b Update Security Credentials - rootByWanProvider") \
231
    XXX(GBCS_MESSAGE_CS02B2,     0x0102, "CS02b Update Security Credentials - supplierBySupplier") \
232
    XXX(GBCS_MESSAGE_CS02B3,     0x0103, "CS02b Update Security Credentials - networkOperatorByNetworkOperator") \
233
    XXX(GBCS_MESSAGE_CS02B4,     0x0104, "CS02b Update Security Credentials - accessControlBrokerByACB") \
234
    XXX(GBCS_MESSAGE_CS02B5,     0x0105, "CS02b Update Security Credentials - wanProviderByWanProvider") \
235
    XXX(GBCS_MESSAGE_CS02B6,     0x0106, "CS02b Update Security Credentials - transCoSByTransCoS") \
236
    XXX(GBCS_MESSAGE_CS02B7,     0x0107, "CS02b Update Security Credentials - supplierByTransCoS") \
237
    XXX(GBCS_MESSAGE_CS02B8,     0x0108, "CS02b Update Security Credentials - anyExceptAbnormalRootByRecovery") \
238
    XXX(GBCS_MESSAGE_CS02B9,     0x0109, "CS02b Update Security Credentials - anyByContingency") \
239
    XXX(GBCS_MESSAGE_DBCH01,     0x010A, "DBCH01 Read CHF Sub GHz Channel") \
240
    XXX(GBCS_MESSAGE_DBCH02,     0x010B, "DBCH02 Read CHF Sub GHz Channel Log") \
241
    XXX(GBCS_MESSAGE_DBCH03,     0x010C, "DBCH03 Read CHF Sub GHz Configuration") \
242
    XXX(GBCS_MESSAGE_DBCH04,     0x010D, "DBCH04 Set CHF Sub GHz Configuration") \
243
    XXX(GBCS_MESSAGE_DBCH05,     0x010E, "DBCH05 Request CHF Sub GHz Channel Scan") \
244
    XXX(GBCS_MESSAGE_CCS06,      0x010F, "CCS06 Read CHF device log and check HAN communications") \
245
    XXX(GBCS_MESSAGE_DBCH06,     0x0110, "DBCH06 Limited Duty Cycle Action Taken Sub GHz Alert") \
246
    XXX(GBCS_MESSAGE_DBCH07,     0x0111, "DBCH07 Sub GHz Sub GHz Channel Changed Sub GHz Alert") \
247
    XXX(GBCS_MESSAGE_DBCH08,     0x0112, "DBCH08 Sub GHz Channel Scan Request Assessment Outcome Sub GHz Alert") \
248
    XXX(GBCS_MESSAGE_DBCH09,     0x0113, "DBCH09 Sub GHz Configuration Changed Sub GHz Alert") \
249
    XXX(GBCS_MESSAGE_DBCH10,     0x0114, "DBCH10 Message Discarded Due to Duty Cycle Management Sub GHz Alert") \
250
    XXX(GBCS_MESSAGE_DBCH11,     0x0115, "DBCH11 No More Sub GHz Device Capacity Sub GHz Alert") \
251
    XXX(GBCS_MESSAGE_PECS01,     0x0116, "PECS01 Apply Pre-payment Top Up to an ESME using PPMID") \
252
    XXX(GBCS_MESSAGE_PECS02,     0x0117, "PECS02 Activate Emergency Credit on ESME from PPMID") \
253
    XXX(GBCS_MESSAGE_PECS03,     0x0118, "PECS03 Request to Enable ESME Supply from PPMID") \
254
    XXX(GBCS_MESSAGE_HECS01,     0x0119, "HECS01 Request Control of a HAN Connected Auxiliary Load Control Switch from HCALCS") \
255
    XXX(GBCS_MESSAGE_ALERT_1000, 0x1000, "Generic Critical Alert") \
256
    XXX(GBCS_MESSAGE_ALERT_1001, 0x1001, "Generic Non Critical Alert")
257
258
VALUE_STRING_ARRAY(gbcs_message_code_names);
259
static value_string_ext gbcs_message_code_names_ext = VALUE_STRING_EXT_INIT(gbcs_message_code_names);
260
261
#define gbcs_message_cra_names_VALUE_STRING_LIST(XXX) \
262
    XXX(GBCS_MESSAGE_CRA_COMMAND,                               0x01, "Command" ) \
263
    XXX(GBCS_MESSAGE_CRA_RESPONSE,                              0x02, "Response" ) \
264
    XXX(GBCS_MESSAGE_CRA_ALERT,                                 0x03, "Alert" )
265
266
VALUE_STRING_ENUM(gbcs_message_cra_names);
267
VALUE_STRING_ARRAY(gbcs_message_cra_names);
268
269
static void
270
dlms_date_time(tvbuff_t *tvb, unsigned offset, nstime_t *date_time)
271
0
{
272
    //TODO Handle DLMS date never
273
0
    struct tm tm;
274
275
0
    tm.tm_wday = 0;
276
0
    tm.tm_yday = 0;
277
0
    tm.tm_isdst = -1;
278
279
0
    tm.tm_year = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN) - 1900;
280
0
    offset += 2;
281
282
0
    tm.tm_mon = tvb_get_uint8(tvb, offset) - 1; // tm.tm_mon [0-11]
283
0
    offset += 1;
284
285
0
    tm.tm_mday = tvb_get_uint8(tvb, offset);
286
0
    offset += 1;
287
288
0
    offset += 1; //Skip week day
289
290
0
    tm.tm_hour = tvb_get_uint8(tvb, offset);
291
0
    offset += 1;
292
293
0
    tm.tm_min = tvb_get_uint8(tvb, offset);
294
0
    offset += 1;
295
296
0
    tm.tm_sec = tvb_get_uint8(tvb, offset);
297
298
0
    date_time->secs = mktime_utc(&tm);
299
0
    date_time->nsecs = 0;
300
0
}
301
302
/* ########################################################################## */
303
/* #### GBCS GBZ ############################################################ */
304
/* ########################################################################## */
305
306
480
#define GBCS_GBZ_MAX_COMPONENTS                                         31 // GCS16a
307
0
#define GBCS_GBZ_MAC_LENGTH                                             12
308
309
0
#define GBCS_GBZ_EXTENDED_HEADER_CONTROL_FROM_DATE_TIME_PRESENT         0x10
310
#define GBCS_GBZ_EXTENDED_HEADER_CONTROL_LAST_COMPONENT                 0x01
311
0
#define GBCS_GBZ_EXTENDED_HEADER_CONTROL_ENCRYPTED_COMPONENT            0x02
312
313
#define gbcs_gbz_alert_code_names_VALUE_STRING_LIST(XXX) \
314
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_ABOVE_AVERAGE_RMS_OVER_VOL_1,0x8002, "Average RMS Voltage above Average RMS Over Voltage Threshold (current value above threshold; previous value below threshold)") \
315
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_ABOVE_AVERAGE_RMS_OVER_VOL_2,0x8003, "Average RMS Voltage above Average RMS Over Voltage Threshold  on Phase 1 (current value above threshold; previous value below threshold)") \
316
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_ABOVE_AVERAGE_RMS_OVER_VOL_3,0x8004, "Average RMS Voltage above Average RMS Over Voltage Threshold  on Phase 2 (current value above threshold; previous value below threshold)") \
317
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_ABOVE_AVERAGE_RMS_OVER_VOL_4,0x8005, "Average RMS Voltage above Average RMS Over Voltage Threshold  on Phase 3 (current value above threshold; previous value below threshold)") \
318
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_BELOW_AVERAGE_RMS_UNDER_VO_1,0x8006, "Average RMS Voltage below Average RMS Under Voltage Threshold (current value below threshold; previous value above threshold)") \
319
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_BELOW_AVERAGE_RMS_UNDER_VO_2,0x8007, "Average RMS Voltage below Average RMS Under Voltage Threshold on Phase 1 (current value below threshold; previous value above threshold)") \
320
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_BELOW_AVERAGE_RMS_UNDER_VO_3,0x8008, "Average RMS Voltage below Average RMS Under Voltage Threshold on Phase 2 (current value below threshold; previous value above threshold)") \
321
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_BELOW_AVERAGE_RMS_UNDER_VO_4,0x8009, "Average RMS Voltage below Average RMS Under Voltage Threshold on Phase 3 (current value below threshold; previous value above threshold)") \
322
    XXX(GBCS_GBZ_ALERT_OVER_CURRENT,                                    0x8010, "Over Current") \
323
    XXX(GBCS_GBZ_ALERT_OVER_CURRENT_L1,                                 0x8011, "Over Current L1") \
324
    XXX(GBCS_GBZ_ALERT_OVER_CURRENT_L3,                                 0x8013, "Over Current L3") \
325
    XXX(GBCS_GBZ_ALERT_POWER_FACTOR_THRESHOLD_BELOW,                    0x8014, "Power Factor Threshold Below") \
326
    XXX(GBCS_GBZ_ALERT_POWER_FACTOR_THRESHOLD_OK,                       0x8015, "Power Factor Threshold Ok") \
327
    XXX(GBCS_GBZ_ALERT_OVER_CURRENT_L2,                                 0x8016, "Over Current L2") \
328
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_EXTREME_OVER_VOLTAGE_THRESHO_1,0x8020, "RMS Voltage above Extreme Over Voltage Threshold (voltage rises above for longer than the configurable period)") \
329
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_EXTREME_OVER_VOLTAGE_THRESHO_2,0x8021, "RMS Voltage above Extreme Over Voltage Threshold on Phase 1 (voltage rises above for longer than the configurable period)") \
330
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_EXTREME_OVER_VOLTAGE_THRESHO_3,0x8022, "RMS Voltage above Extreme Over Voltage Threshold on Phase 2 (voltage rises above for longer than the configurable period)") \
331
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_EXTREME_OVER_VOLTAGE_THRESHO_4,0x8023, "RMS Voltage above Extreme Over Voltage Threshold on Phase 3 (voltage rises above for longer than the configurable period)") \
332
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_VOLTAGE_SWELL_THRESHOLD_VOLT_1,0x8024, "RMS Voltage above Voltage Swell Threshold (voltage rises above for longer than the configurable period)") \
333
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_VOLTAGE_SWELL_THRESHOLD_ON_P_2,0x8025, "RMS Voltage above Voltage Swell Threshold on Phase 1 (voltage rises above for longer than the configurable period)") \
334
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_VOLTAGE_SWELL_THRESHOLD_ON_P_3,0x8026, "RMS Voltage above Voltage Swell Threshold on Phase 2 (voltage rises above for longer than the configurable period)") \
335
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_VOLTAGE_SWELL_THRESHOLD_ON_P_4,0x8027, "RMS Voltage above Voltage Swell Threshold on Phase 3 (voltage rises above for longer than the configurable period)") \
336
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_EXTREME_UNDER_VOLTAGE_THRESH_1,0x8028, "RMS Voltage below Extreme Under Voltage Threshold (voltage falls below for longer than the configurable period)") \
337
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_EXTREME_UNDER_VOLTAGE_THRESH_2,0x8029, "RMS Voltage below Extreme Under Voltage Threshold on Phase 1 (voltage falls below for longer than the configurable period)") \
338
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_EXTREME_UNDER_VOLTAGE_THRESH_3,0x802A, "RMS Voltage below Extreme Under Voltage Threshold on Phase 2 (voltage falls below for longer than the configurable period)") \
339
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_EXTREME_UNDER_VOLTAGE_THRESH_4,0x802B, "RMS Voltage below Extreme Under Voltage Threshold on Phase 3 (voltage falls below for longer than the configurable period)") \
340
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_VOLTAGE_SAG_THRESHOLD_VOLTA_1, 0x802C, "RMS Voltage below Voltage Sag Threshold (voltage falls below for longer than the configurable period)") \
341
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_VOLTAGE_SAG_THRESHOLD_ON_PHA_1,0x802D, "RMS Voltage below Voltage Sag Threshold on Phase 1 (voltage falls below for longer than the configurable period)") \
342
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_VOLTAGE_SAG_THRESHOLD_ON_PHA_2,0x802E, "RMS Voltage below Voltage Sag Threshold on Phase 2 (voltage falls below for longer than the configurable period)") \
343
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_VOLTAGE_SAG_THRESHOLD_ON_PHA_3,0x802F, "RMS Voltage below Voltage Sag Threshold on Phase 3 (voltage falls below for longer than the configurable period)") \
344
    XXX(GBCS_GBZ_ALERT_GPF_DEVICE_LOG_CHANGED,                          0x8071, "GPF Device Log Changed") \
345
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_BELOW_AVERAGE_RMS_OVER_VOL_1,0x8085, "Average RMS Voltage below Average RMS Over Voltage Threshold (current value below threshold; previous value above threshold)") \
346
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_BELOW_AVERAGE_RMS_OVER_VOL_2,0x8086, "Average RMS Voltage below Average RMS Over Voltage Threshold on Phase 1 (current value below threshold; previous value above threshold)") \
347
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_BELOW_AVERAGE_RMS_OVER_VOL_3,0x8087, "Average RMS Voltage below Average RMS Over Voltage Threshold on Phase 2 (current value below threshold; previous value above threshold)") \
348
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_BELOW_AVERAGE_RMS_OVER_VOL_4,0x8088, "Average RMS Voltage below Average RMS Over Voltage Threshold on Phase 3 (current value below threshold; previous value above threshold)") \
349
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_ABOVE_AVERAGE_RMS_UNDER_VO_1,0x8089, "Average RMS Voltage above Average RMS Under Voltage Threshold (current value above threshold; previous value below threshold)") \
350
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_ABOVE_AVERAGE_RMS_UNDER_VO_2,0x808A, "Average RMS Voltage above Average RMS Under Voltage Threshold on Phase 1 (current value above threshold; previous value below threshold)") \
351
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_ABOVE_AVERAGE_RMS_UNDER_VO_3,0x808B, "Average RMS Voltage above Average RMS Under Voltage Threshold on Phase 2 (current value above threshold; previous value below threshold)") \
352
    XXX(GBCS_GBZ_ALERT_AVERAGE_RMS_VOLTAGE_ABOVE_AVERAGE_RMS_UNDER_VO_4,0x808C, "Average RMS Voltage above Average RMS Under Voltage Threshold on Phase 3 (current value above threshold; previous value below threshold)") \
353
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_EXTREME_OVER_VOLTAGE_THRESHO_5,0x808D, "RMS Voltage above Extreme Over Voltage Threshold (voltage returns below for longer than the configurable period)") \
354
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_EXTREME_OVER_VOLTAGE_THRESHO_6,0x808E, "RMS Voltage above Extreme Over Voltage Threshold on Phase 1 (voltage returns below for longer than the configurable period)") \
355
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_EXTREME_OVER_VOLTAGE_THRESHO_7,0x808F, "RMS Voltage above Extreme Over Voltage Threshold on Phase 2 (voltage returns below for longer than the configurable period)") \
356
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_EXTREME_OVER_VOLTAGE_THRESHO_8,0x8090, "RMS Voltage above Extreme Over Voltage Threshold on Phase 3 (voltage returns below for longer than the configurable period)") \
357
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_VOLTAGE_SWELL_THRESHOLD_VOLT_2,0x8091, "RMS Voltage above Voltage Swell Threshold (voltage returns below for longer than the configurable period)") \
358
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_VOLTAGE_SWELL_THRESHOLD_ON_P_1,0x8092, "RMS Voltage above Voltage Swell Threshold on Phase 1 (voltage returns below for longer than the configurable period)") \
359
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_VOLTAGE_SWELL_THRESHOLD_ON_P_5,0x8093, "RMS Voltage above Voltage Swell Threshold on Phase 2 (voltage returns below for longer than the configurable period)") \
360
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_ABOVE_VOLTAGE_SWELL_THRESHOLD_ON_P_6,0x8094, "RMS Voltage above Voltage Swell Threshold on Phase 3 (voltage returns below for longer than the configurable period)") \
361
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_EXTREME_UNDER_VOLTAGE_THRESH_5,0x8095, "RMS Voltage below Extreme Under Voltage Threshold (voltage returns above for longer than the configurable period)") \
362
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_EXTREME_UNDER_VOLTAGE_THRESH_6,0x8096, "RMS Voltage below Extreme Under Voltage Threshold on Phase 1 (voltage returns above for longer than the configurable period)") \
363
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_EXTREME_UNDER_VOLTAGE_THRESH_7,0x8097, "RMS Voltage below Extreme Under Voltage Threshold on Phase 2 (voltage returns above for longer than the configurable period)") \
364
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_EXTREME_UNDER_VOLTAGE_THRESH_8,0x8098, "RMS Voltage below Extreme Under Voltage Threshold on Phase 3 (voltage returns above for longer than the configurable period)") \
365
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_VOLTAGE_SAG_THRESHOLD_VOLTA_2, 0x8099, "RMS Voltage below Voltage Sag Threshold (voltage returns above for longer than the configurable period)") \
366
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_VOLTAGE_SAG_THRESHOLD_ON_PHA_4,0x809A, "RMS Voltage below Voltage Sag Threshold on Phase 1 (voltage returns above for longer than the configurable period)") \
367
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_VOLTAGE_SAG_THRESHOLD_ON_PHA_5,0x809B, "RMS Voltage below Voltage Sag Threshold on Phase 2 (voltage returns above for longer than the configurable period)") \
368
    XXX(GBCS_GBZ_ALERT_RMS_VOLTAGE_BELOW_VOLTAGE_SAG_THRESHOLD_ON_PHA_6,0x809C, "RMS Voltage below Voltage Sag Threshold on Phase 3 (voltage returns above for longer than the configurable period)") \
369
    XXX(GBCS_GBZ_ALERT_COMBINED_CREDIT_BELOW_LOW_CREDIT_THRESHOLD_PREPA,0x810D, "Combined Credit Below Low Credit Threshold (prepayment mode)") \
370
    XXX(GBCS_GBZ_ALERT_CREDIT_ADDED_LOCALLY,                            0x810E, "Credit Added Locally") \
371
    XXX(GBCS_GBZ_ALERT_EMERGENCY_CREDIT_HAS_BECOME_AVAILABLE_PREPAYMENT,0x8119, "Emergency Credit Has Become Available (prepayment mode)") \
372
    XXX(GBCS_GBZ_ALERT_FAILURE_IN_CHANGING_OR_MAINTAINING_HCALCS_OR_A_1,0x811A, "Failure in changing or maintaining HCALCS or ALCS state") \
373
    XXX(GBCS_GBZ_ALERT_SUCCESS_IN_CHANGING_OR_MAINTAINING_HCALCS_OR_A_2,0x8131, "Success in changing or maintaining HCALCS or ALCS state") \
374
    XXX(GBCS_GBZ_ALERT_CLOCK_ADJUSTED_WITHIN_TOLERANCE,                 0x8145, "Clock adjusted (within tolerance)") \
375
    XXX(GBCS_GBZ_ALERT_IMMEDIATE_HAN_INTERFACE_COMMAND_RECEIVED_AND_SUC,0x8154, "Immediate HAN Interface Command Received and Successfully Actioned") \
376
    XXX(GBCS_GBZ_ALERT_IMMEDIATE_HAN_INTERFACE_COMMAND_RECEIVED_BUT_NOT,0x8155, "Immediate HAN Interface Command Received but not Successfully Actioned") \
377
    XXX(GBCS_GBZ_ALERT_USER_INTERFACE_COMMAND_INPUT_AND_SUCCESSFULLY_AC,0x8161, "User Interface Command Input and Successfully Actioned") \
378
    XXX(GBCS_GBZ_ALERT_USER_INTERFACE_COMMAND_INPUT_BUT_NOT_SUCCESSFULL,0x8162, "User Interface Command Input but not Successfully Actioned") \
379
    XXX(GBCS_GBZ_ALERT_SUPPLY_DISABLED_THEN_ARMED_ACTIVATE_EMERGENCY,   0x8168, "Supply Disabled then Armed - Activate Emergency Credit triggered") \
380
    XXX(GBCS_GBZ_ALERT_DEVICE_JOINED_SMHAN,                             0x8183, "Device joined SMHAN") \
381
    XXX(GBCS_GBZ_ALERT_VALVE_TESTED,                                    0x8184, "Valve tested") \
382
    XXX(GBCS_GBZ_ALERT_GSME_COMMAND_NOT_RETRIEVED,                      0x819D, "GSME Command Not Retrieved") \
383
    XXX(GBCS_GBZ_ALERT_TAP_OFF_MESSAGE_RESPONSE_OR_ALERT_FAILURE,       0x819E, "Tap Off Message Response or Alert Failure") \
384
    XXX(GBCS_GBZ_ALERT_SMART_METER_INTEGRITY_ISSUE_WARNING,             0x81A0, "Smart Meter Integrity Issue Warning") \
385
    XXX(GBCS_GBZ_ALERT_BATTERY_COVER_CLOSED,                            0x81A1, "Battery Cover Closed") \
386
    XXX(GBCS_GBZ_ALERT_CH_CONNECTED_TO_ESME,                            0x81A2, "CH Connected to ESME") \
387
    XXX(GBCS_GBZ_ALERT_CH_DISCONNECTED_FROM_ESME,                       0x81A3, "CH Disconnected from ESME") \
388
    XXX(GBCS_GBZ_ALERT_CLOSE_TUNNEL_COMMAND_REJECTED,                   0x81A4, "Close Tunnel Command Rejected") \
389
    XXX(GBCS_GBZ_ALERT_COMMUNICATION_FROM_LOCAL_PORT_EG_OPTICAL,        0x81A5, "Communication From Local Port (e.g. Optical)") \
390
    XXX(GBCS_GBZ_ALERT_CUSTOMER_ACKNOWLEDGED_MESSAGE_ON_HAN_DEVICE,     0x81A6, "Customer Acknowledged Message on HAN Device") \
391
    XXX(GBCS_GBZ_ALERT_DEBT_COLLECTION_COMPLETED_TIME_DEBT_1,           0x81A7, "Debt Collection Completed - Time Debt 1") \
392
    XXX(GBCS_GBZ_ALERT_DEBT_COLLECTION_COMPLETED_TIME_DEBT_2,           0x81A8, "Debt Collection Completed - Time Debt 2") \
393
    XXX(GBCS_GBZ_ALERT_DEBT_COLLECTION_COMPLETED_PAYMENT_DEBT,          0x81A9, "Debt Collection Completed - Payment Debt") \
394
    XXX(GBCS_GBZ_ALERT_EMERGENCY_CREDIT_EXHAUSTED,                      0x81AA, "Emergency Credit Exhausted") \
395
    XXX(GBCS_GBZ_ALERT_EMERGENCY_CREDIT_ACTIVATED,                      0x81AB, "Emergency Credit Activated") \
396
    XXX(GBCS_GBZ_ALERT_ERROR_MEASUREMENT_FAULT,                         0x81AC, "Error Measurement Fault") \
397
    XXX(GBCS_GBZ_ALERT_ERROR_METROLOGY_FIRMWARE_VERIFICATION_FAILURE,   0x81AD, "Error Metrology Firmware Verification Failure") \
398
    XXX(GBCS_GBZ_ALERT_ERROR_NON_VOLATILE_MEMORY,                       0x81AE, "Error Non Volatile Memory") \
399
    XXX(GBCS_GBZ_ALERT_ERROR_PROGRAM_EXECUTION,                         0x81AF, "Error Program Execution") \
400
    XXX(GBCS_GBZ_ALERT_ERROR_PROGRAM_STORAGE,                           0x81B0, "Error Program Storage") \
401
    XXX(GBCS_GBZ_ALERT_ERROR_RAM,                                       0x81B1, "Error RAM") \
402
    XXX(GBCS_GBZ_ALERT_ERROR_UNEXPECTED_HARDWARE_RESET,                 0x81B2, "Error Unexpected Hardware Reset") \
403
    XXX(GBCS_GBZ_ALERT_ERROR_WATCHDOG,                                  0x81B3, "Error Watchdog ") \
404
    XXX(GBCS_GBZ_ALERT_EXCESS_GAS_FLOW_BEYOND_METER_CAPACITY,           0x81B4, "Excess Gas Flow Beyond Meter Capacity") \
405
    XXX(GBCS_GBZ_ALERT_FLOW_SENSOR_DETECTS_AIR_IN_GAS_FLOW,             0x81B5, "Flow Sensor Detects Air in Gas Flow") \
406
    XXX(GBCS_GBZ_ALERT_FLOW_SENSOR_DETECTS_REVERSE_FLOW_OF_GAS,         0x81B6, "Flow Sensor Detects Reverse Flow of Gas") \
407
    XXX(GBCS_GBZ_ALERT_INCORRECT_PHASE_SEQUENCING,                      0x81B7, "Incorrect phase sequencing") \
408
    XXX(GBCS_GBZ_ALERT_INCORRECT_POLARITY,                              0x81B8, "Incorrect Polarity") \
409
    XXX(GBCS_GBZ_ALERT_METER_COVER_CLOSED,                              0x81B9, "Meter Cover Closed") \
410
    XXX(GBCS_GBZ_ALERT_REQUEST_TUNNEL_COMMAND_REJECTED,                 0x81BA, "Request Tunnel Command Rejected") \
411
    XXX(GBCS_GBZ_ALERT_REVERSE_CURRENT,                                 0x81BB, "Reverse Current") \
412
    XXX(GBCS_GBZ_ALERT_STRONG_MAGNETIC_FIELD_REMOVED,                   0x81BC, "Strong Magnetic Field Removed") \
413
    XXX(GBCS_GBZ_ALERT_SUPPLY_CONNECT_FAILURE_VALVE_OR_LOAD_SWITCH,     0x81BD, "Supply Connect Failure (Valve or Load Switch)") \
414
    XXX(GBCS_GBZ_ALERT_SUPPLY_DISABLED_THEN_LOCKED_SUPPLY_TAMPER_STATE, 0x81BE, "Supply Disabled Then Locked - Supply Tamper State Cause") \
415
    XXX(GBCS_GBZ_ALERT_SUPPLY_DISABLED_THEN_ARMED_UNCONTROLLED_GAS_FLOW,0x81BF, "Supply Disabled Then Armed - Uncontrolled Gas Flow Rate") \
416
    XXX(GBCS_GBZ_ALERT_SUPPLY_DISCONNECT_FAILURE_VALVE_OR_LOAD_SWITCH,  0x81C0, "Supply Disconnect Failure (Valve or Load Switch)") \
417
    XXX(GBCS_GBZ_ALERT_TERMINAL_COVER_CLOSED,                           0x81C1, "Terminal Cover Closed") \
418
    XXX(GBCS_GBZ_ALERT_TILT_TAMPER_ENDED,                               0x81C2, "Tilt Tamper Ended") \
419
    XXX(GBCS_GBZ_ALERT_TILT_TAMPER,                                     0x81C3, "Tilt Tamper") \
420
    XXX(GBCS_GBZ_ALERT_UTRN_MANUAL_ENTRY_SUSPENDED,                     0x81C4, "UTRN Manual Entry Suspended") \
421
    XXX(GBCS_GBZ_ALERT_UTRN_REJECTED_AS_LOCKED_OUT,                     0x81C5, "UTRN rejected as locked out") \
422
    XXX(GBCS_GBZ_ALERT_CLOCK_NOT_ADJUSTED_OUTSIDE_TOLERANCE,            0x81C6, "Clock not adjusted (outside tolerance)") \
423
    XXX(GBCS_GBZ_ALERT_ACTIVE_POWER_IMPORT_ABOVE_LOAD_LIMIT_THRESHOLD,  0x8F01, "Active Power Import above Load Limit Threshold") \
424
    XXX(GBCS_GBZ_ALERT_BILLING_DATA_LOG_UPDATED,                        0x8F0A, "Billing Data Log Updated") \
425
    XXX(GBCS_GBZ_ALERT_CLOCK_NOT_ADJUSTED_ADJUSTMENT_GREATER_THAN_10_SE,0x8F0C, "Clock not adjusted (adjustment greater than 10 seconds)") \
426
    XXX(GBCS_GBZ_ALERT_CREDIT_BELOW_DISABLEMENT_THRESHOLD_PREPAYMENT_MO,0x8F0F, "Credit Below Disablement Threshold (prepayment mode)") \
427
    XXX(GBCS_GBZ_ALERT_CHF_DEVICE_LOG_CHANGED,                          0x8F12, "CHF Device Log Changed") \
428
    XXX(GBCS_GBZ_ALERT_FIRMWARE_VERIFICATION_FAILED_AT_POWER_ON,        0x8F1B, "Firmware Verification Failed At Power On") \
429
    XXX(GBCS_GBZ_ALERT_FIRMWARE_VERIFICATION_FAILED,                    0x8F1C, "Firmware Verification Failed") \
430
    XXX(GBCS_GBZ_ALERT_GSME_POWER_SUPPLY_LOSS,                          0x8F1D, "GSME Power Supply Loss") \
431
    XXX(GBCS_GBZ_ALERT_INTEGRITY_CHECK_OF_CONTENT_OR_FORMAT_OF_COMMAND, 0x8F1E, "Integrity check of content or format of command failed") \
432
    XXX(GBCS_GBZ_ALERT_LOW_BATTERY_CAPACITY,                            0x8F1F, "Low Battery Capacity") \
433
    XXX(GBCS_GBZ_ALERT_LIMITED_DUTY_CYCLE_ACTION_TAKEN,                 0x8F20, "Limited Duty Cycle Action Taken") \
434
    XXX(GBCS_GBZ_ALERT_DUTY_CYCLE_FALL_BELOW_NORMAL_LIMITED,            0x8F21, "Duty Cycle fallen below Normal-Limited Duty Cycle Threshold") \
435
    XXX(GBCS_GBZ_ALERT_CRITICAL_DUTY_CYCLE_ACTION_TAKEN,                0x8F22, "Critical Duty Cycle Action Taken") \
436
    XXX(GBCS_GBZ_ALERT_DUTY_CYCLE_FALL_BELOW_LIMITED_CRITICAL,          0x8F23, "Duty Cycle fallen below Limited-Critical Duty Cycle Threshold") \
437
    XXX(GBCS_GBZ_ALERT_REGULATED_DUTY_CYCLE_ACTION_TAKEN,               0x8F24, "Regulated Duty Cycle Action Taken") \
438
    XXX(GBCS_GBZ_ALERT_DUTY_CYCLE_FALL_BELOW_CRITICAL_REGULATED,        0x8F25, "Duty Cycle fallen below Critical-Regulated Duty Cycle Threshold") \
439
    XXX(GBCS_GBZ_ALERT_SUB_GHZ_CHANNEL_CHANGED,                         0x8F26, "Sub GHz Channel Changed") \
440
    XXX(GBCS_GBZ_ALERT_SUB_GHZ_CHANNEL_SCAN_INITIATED,                  0x8F27, "Sub GHz Channel Scan initiated") \
441
    XXX(GBCS_GBZ_ALERT_SUB_GHZ_CHANNEL_SCAN_REQUEST_ASSESSMENT_OUTCOME, 0x8F28, "Sub GHz Channel Scan Request Assessment Outcome") \
442
    XXX(GBCS_GBZ_ALERT_THREE_LOST_GSME_SEARCHES_FAILED,                 0x8F29, "Three Lost GSME Searches Failed") \
443
    XXX(GBCS_GBZ_ALERT_SUB_GHZ_CONFIGURATION_CHANGED,                   0x8F2A, "Sub GHz Configuration Changed") \
444
    XXX(GBCS_GBZ_ALERT_SUB_GHZ_CHANNEL_NOT_CHANGED_DUE_TO_FREQUENCY_AGI,0x8F2B, "Sub GHz Channel not changed due to Frequency Agility Parameters") \
445
    XXX(GBCS_GBZ_ALERT_MESSAGE_DISCARDED_DUE_TO_DUTY_CYCLE_MANAGEMENT,  0x8F2C, "Message Discarded Due to Duty Cycle Management") \
446
    XXX(GBCS_GBZ_ALERT_NO_MORE_SUB_GHZ_DEVICE_CAPACITY,                 0x8F2D, "No More Sub GHz Device Capacity") \
447
    XXX(GBCS_GBZ_ALERT_SOURCE_DOES_NOT_HAVE_AUTHORITY_FOR_COMMAND,      0x8F30, "Source Does not have Authority for Command") \
448
    XXX(GBCS_GBZ_ALERT_SUPPLY_ARMED,                                    0x8F32, "Supply Armed") \
449
    XXX(GBCS_GBZ_ALERT_SUPPLY_DISABLED_THEN_ARMED_LOAD_LIMIT_TRIGGERED, 0x8F33, "Supply Disabled then Armed - Load Limit triggered") \
450
    XXX(GBCS_GBZ_ALERT_SUPPLY_ENABLED_AFTER_LOAD_LIMIT_RESTORATION_PERI,0x8F34, "Supply Enabled after Load Limit Restoration Period (Load Limit triggered)") \
451
    XXX(GBCS_GBZ_ALERT_SUPPLY_OUTAGE_RESTORED,                          0x8F35, "Supply Outage Restored") \
452
    XXX(GBCS_GBZ_ALERT_SUPPLY_OUTAGE_RESTORED_OUTAGE_3_MINUTES,         0x8F36, "Supply Outage Restored - Outage >= 3 minutes") \
453
    XXX(GBCS_GBZ_ALERT_SUPPLY_OUTAGE_RESTORED_ON_PHASE_1,               0x8F37, "Supply Outage Restored on Phase 1") \
454
    XXX(GBCS_GBZ_ALERT_SUPPLY_OUTAGE_RESTORED_ON_PHASE_1_RESTORED_OUTAG,0x8F38, "Supply Outage Restored on Phase 1 Restored - Outage >= 3 minutes") \
455
    XXX(GBCS_GBZ_ALERT_SUPPLY_OUTAGE_RESTORED_ON_PHASE_2_RESTORED,      0x8F39, "Supply Outage Restored on Phase 2 Restored") \
456
    XXX(GBCS_GBZ_ALERT_SUPPLY_OUTAGE_RESTORED_ON_PHASE_2_RESTORED_OUTAG,0x8F3A, "Supply Outage Restored on Phase 2 Restored - Outage >= 3 minutes") \
457
    XXX(GBCS_GBZ_ALERT_SUPPLY_OUTAGE_RESTORED_ON_PHASE_3_RESTORED,      0x8F3B, "Supply Outage Restored on Phase 3 Restored") \
458
    XXX(GBCS_GBZ_ALERT_SUPPLY_OUTAGE_RESTORED_ON_PHASE_3_RESTORED_OUTAG,0x8F3C, "Supply Outage Restored on Phase 3 Restored - Outage >= 3 minutes") \
459
    XXX(GBCS_GBZ_ALERT_TRUSTED_SOURCE_AUTHENTICATION_FAILURE,           0x8F3D, "Trusted Source Authentication Failure") \
460
    XXX(GBCS_GBZ_ALERT_UNAUTHORISED_COMMUNICATION_ACCESS_ATTEMPTED,     0x8F3E, "Unauthorised Communication Access attempted") \
461
    XXX(GBCS_GBZ_ALERT_UNAUTHORISED_PHYSICAL_ACCESS_TAMPER_DETECT,      0x8F3F, "Unauthorised Physical Access - Tamper Detect") \
462
    XXX(GBCS_GBZ_ALERT_CHANGE_IN_THE_EXECUTING_FIRMWARE_VERSION,        0x8F43, "Change in the executing Firmware version") \
463
    XXX(GBCS_GBZ_ALERT_CREDIT_WOULD_CAUSE_METER_BALANCE_TO_EXCEED_MAXIM,0x8F47, "Credit would cause Meter Balance to exceed  Maximum Meter Balance Threshold") \
464
    XXX(GBCS_GBZ_ALERT_DEVICE_JOINING_FAILED,                           0x8F48, "Device joining failed") \
465
    XXX(GBCS_GBZ_ALERT_DEVICE_JOINING_SUCCEEDED,                        0x8F49, "Device joining succeeded ") \
466
    XXX(GBCS_GBZ_ALERT_DEVICE_UNJOINING_FAILED,                         0x8F4A, "Device Unjoining failed ") \
467
    XXX(GBCS_GBZ_ALERT_DEVICE_UNJOINING_SUCCEEDED,                      0x8F4B, "Device Unjoining succeeded ") \
468
    XXX(GBCS_GBZ_ALERT_DEVICE_OWN_DIGITAL_SIGNING_CERT_REPLACEME_FAILED,0x8F4C, "Device's own Digital Signing Certificate replacement failed") \
469
    XXX(GBCS_GBZ_ALERT_DEVICE_OWN_DIGITAL_SIGNING_CERT_REPLACEME_SUCCES,0x8F4D, "Device's own Digital Signing Certificate replacement succeeded") \
470
    XXX(GBCS_GBZ_ALERT_DEVICE_OWN_KEY_AGREEMENT_CERTIFICATE_REP_FAILED, 0x8F4E, "Device's own Key Agreement Certificate replacement failed") \
471
    XXX(GBCS_GBZ_ALERT_DEVICE_OWN_KEY_AGREEMENT_CERTIFICATE_REP_SUCCEED,0x8F4F, "Device's own Key Agreement Certificate replacement succeeded") \
472
    XXX(GBCS_GBZ_ALERT_DUPLICATE_UTRN_ENTERED,                          0x8F51, "Duplicate UTRN entered") \
473
    XXX(GBCS_GBZ_ALERT_EVENT_LOG_CLEARED,                               0x8F52, "Event Log Cleared") \
474
    XXX(GBCS_GBZ_ALERT_FAILED_AUTHENTICATION_OR_AUTHORISATION_NOT_COVER,0x8F53, "Failed Authentication or Authorisation not covered by other codes") \
475
    XXX(GBCS_GBZ_ALERT_SUPPLY_INTERRUPTED,                              0x8F57, "Supply interrupted") \
476
    XXX(GBCS_GBZ_ALERT_SUPPLY_INTERRUPTED_ON_PHASE_1,                   0x8F58, "Supply interrupted on Phase 1") \
477
    XXX(GBCS_GBZ_ALERT_SUPPLY_INTERRUPTED_ON_PHASE_2,                   0x8F59, "Supply interrupted on Phase 2") \
478
    XXX(GBCS_GBZ_ALERT_SUPPLY_INTERRUPTED_ON_PHASE_3,                   0x8F5A, "Supply interrupted on Phase 3") \
479
    XXX(GBCS_GBZ_ALERT_UTRN_EXCEEDS_MAXIMUM_CREDIT_THRESHOLD,           0x8F5B, "UTRN exceeds Maximum Credit Threshold") \
480
    XXX(GBCS_GBZ_ALERT_UNUSUAL_NUMBERS_OF_MALFORMED_OUT_OF_ORDER_OR_UNE,0x8F60, "Unusual numbers of malformed, out-of-order or unexpected Commands received") \
481
    XXX(GBCS_GBZ_ALERT_UTRN_NOT_AUTHENTIC,                              0x8F63, "UTRN not Authentic") \
482
    XXX(GBCS_GBZ_ALERT_UTRN_NOT_FOR_THIS_DEVICE,                        0x8F64, "UTRN not for this Device") \
483
    XXX(GBCS_GBZ_ALERT_FUTURE_DATE_HAN_INTERFACE_CMD_SUCCESS_ACTIONED,  0x8F66, "Future date HAN Interface Command Successfully Actioned") \
484
    XXX(GBCS_GBZ_ALERT_FUTURE_DATE_HAN_INTERFACE_CMD_NOT_SUCCESS_ACTION,0x8F67, "Future date HAN Interface Command not Successfully Actioned") \
485
    XXX(GBCS_GBZ_ALERT_DEVICE_COMMISSIONED,                             0x8F69, "Device commissioned") \
486
    XXX(GBCS_GBZ_ALERT_UPDATE_SECURITY_CREDENTIALS,                     0x8F70, "Update Security Credentials") \
487
    XXX(GBCS_GBZ_ALERT_FIRMWARE_VERIFICATION_SUCCESSFUL,                0x8F72, "Firmware Verification Successful") \
488
    XXX(GBCS_GBZ_ALERT_UNAUTHORISED_PHYSICAL_ACCESS_BATTERY_COVER_REMOV,0x8F73, "Unauthorised Physical Access - Battery Cover Removed") \
489
    XXX(GBCS_GBZ_ALERT_UNAUTHORISED_PHYSICAL_ACCESS_METER_COVER_REMOVED,0x8F74, "Unauthorised Physical Access - Meter Cover Removed") \
490
    XXX(GBCS_GBZ_ALERT_UNAUTHORISED_PHYSICAL_ACCESS_STRONG_MAGNETIC_FIE,0x8F75, "Unauthorised Physical Access - Strong Magnetic field") \
491
    XXX(GBCS_GBZ_ALERT_UNAUTHORISED_PHYSICAL_ACCESS_TERMINAL_COVER_REMO,0x8F76, "Unauthorised Physical Access - Terminal Cover Removed") \
492
    XXX(GBCS_GBZ_ALERT_UNAUTHORISED_PHYSICAL_ACCESS_SECOND_TERMINAL_COV,0x8F77, "Unauthorised Physical Access - Second Terminal Cover Removed") \
493
    XXX(GBCS_GBZ_ALERT_UNAUTHORISED_PHYSICAL_ACCESS_OTHER,              0x8F78, "Unauthorised Physical Access - Other") \
494
    XXX(GBCS_GBZ_ALERT_REMAINING_BATTERY_CAPACITY_RESET,                0x8F82, "Remaining Battery Capacity reset") \
495
    XXX(GBCS_GBZ_ALERT_DISABLEMENT_OF_SUPPLY_INS_CREDIT_SUSPENDED,      0x8F83, "Disablement of Supply due to insufficient credit has been suspended") \
496
    XXX(GBCS_GBZ_ALERT_FAILURE_TO_DELIVER_REMOTE_PARTY_MESSAGE_TO_ESME, 0x8F84, "Failure to Deliver Remote Party Message to ESME")
497
498
VALUE_STRING_ENUM(gbcs_gbz_alert_code_names);
499
VALUE_STRING_ARRAY(gbcs_gbz_alert_code_names);
500
static value_string_ext gbcs_gbz_alert_code_names_ext = VALUE_STRING_EXT_INIT(gbcs_gbz_alert_code_names);
501
502
#define gbcs_gbz_integrity_issue_warning_names_VALUE_STRING_LIST(XXX) \
503
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_OTHER,                         0x0000, "Other" ) \
504
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_ERROR_NON_VOLATILE_MEMORY,     0x0001, "Error Non Volatile Memory" ) \
505
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_ERROR_PROGRAM_EXECUTION,       0x0002, "Error Program Execution" ) \
506
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_ERROR_PROGRAM_STORAGE,         0x0003, "Error Program Storage" ) \
507
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_ERROR_RAM,                     0x0004, "Error RAM" ) \
508
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_ERROR_UNEXPECTED_HW_RESET,     0x0005, "Error Unexpected Hardware Reset" ) \
509
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_ERROR_WATCHDOG,                0x0006, "Error Watchdog" ) \
510
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_ERROR_MET_FW_VERIFICATION_FAIL,0x0007, "Error Metrology Firmware Verification Failure" ) \
511
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_ERROR_MEASUREMENT_FAULT,       0x0008, "Error Measurement Fault" ) \
512
    XXX(GBCS_GBZ_INTEGRITY_ISSUE_WARNING_UNSPEC_SMART_METER_OP_INT_ERR, 0x0009, "Unspecified Smart Meter Operational Integrity Error" )
513
514
VALUE_STRING_ENUM(gbcs_gbz_integrity_issue_warning_names);
515
VALUE_STRING_ARRAY(gbcs_gbz_integrity_issue_warning_names);
516
517
static dissector_handle_t zcl_handle;
518
519
static int proto_gbcs_gbz;
520
521
static int hf_gbcs_gbz_profile_id;
522
static int hf_gbcs_gbz_components;
523
static int hf_gbcs_gbz_extended_header_control;
524
static int hf_gbcs_gbz_extended_header_cluster;
525
static int hf_gbcs_gbz_extended_header_length;
526
static int hf_gbcs_gbz_alert_code;
527
static int hf_gbcs_gbz_timestamp;
528
static int hf_gbcs_gbz_firmware_alert_start;
529
static int hf_gbcs_gbz_firmware_hash;
530
static int hf_gbcs_gbz_future_alert_start;
531
static int hf_gbcs_gbz_message_code;
532
static int hf_gbcs_gbz_originator_counter;
533
static int hf_gbcs_gbz_frame_control;
534
static int hf_gbcs_gbz_command_id;
535
static int hf_gbcs_gbz_integrity_issue_warning;
536
static int hf_gbcs_gbz_from_date_time;
537
static int hf_gbcs_gbz_additional_header_control;
538
static int hf_gbcs_gbz_additional_frame_counter;
539
static int hf_gbcs_gbz_transaction;
540
static int hf_gbcs_gbz_length_of_ciphered_information;
541
static int hf_gbcs_gbz_security_control;
542
static int hf_gbcs_gbz_invocation_counter;
543
static int hf_gbcs_gbz_encrypted_payload;
544
static int hf_gbcs_gbz_mac;
545
546
static int ett_gbcs_gbz;
547
static int ett_gbcs_gbz_components[GBCS_GBZ_MAX_COMPONENTS];
548
549
static expert_field ei_gbcs_gbz_invalid_length;
550
551
void proto_register_gbcs_gbz(void);
552
void proto_reg_handoff_gbcs_gbz(void);
553
554
static void dissect_gbcs_gbz_component(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned *offset, unsigned component_index)
555
0
{
556
0
    proto_item *ti;
557
0
    proto_tree *component_tree;
558
0
    uint32_t component_len;
559
0
    uint32_t cluster;
560
0
    bool fromdatetime_present;
561
0
    bool encryption_present;
562
0
    uint32_t extended_header_control;
563
564
0
    if (component_index > GBCS_GBZ_MAX_COMPONENTS - 1) {
565
0
        component_index = GBCS_GBZ_MAX_COMPONENTS - 1;
566
0
    }
567
568
0
    component_tree = proto_tree_add_subtree(tree, tvb, *offset, 1, ett_gbcs_gbz_components[component_index], &ti, "Use Case Component");
569
570
0
    proto_tree_add_item_ret_uint(component_tree, hf_gbcs_gbz_extended_header_control, tvb, *offset, 1, ENC_NA, &extended_header_control);
571
0
    fromdatetime_present = extended_header_control & GBCS_GBZ_EXTENDED_HEADER_CONTROL_FROM_DATE_TIME_PRESENT;
572
0
    encryption_present = extended_header_control & GBCS_GBZ_EXTENDED_HEADER_CONTROL_ENCRYPTED_COMPONENT;
573
0
    *offset += 1;
574
575
0
    proto_tree_add_item_ret_uint(component_tree, hf_gbcs_gbz_extended_header_cluster, tvb, *offset, 2, ENC_BIG_ENDIAN, &cluster);
576
0
    *offset += 2;
577
578
0
    proto_tree_add_item_ret_uint(component_tree, hf_gbcs_gbz_extended_header_length, tvb, *offset, 2, ENC_BIG_ENDIAN, &component_len);
579
0
    *offset += 2;
580
581
0
    if (component_len > tvb_reported_length_remaining(tvb, *offset)) {
582
0
        expert_add_info(pinfo, tree, &ei_gbcs_gbz_invalid_length);
583
0
    }
584
585
0
    if (fromdatetime_present) {
586
0
        proto_tree_add_item(component_tree, hf_gbcs_gbz_from_date_time, tvb, *offset, 4, ENC_TIME_ZBEE_ZCL|ENC_BIG_ENDIAN);
587
0
        *offset += 4;
588
0
        component_len -= 4;
589
0
    }
590
0
    if (encryption_present) {
591
0
        proto_tree_add_item(component_tree, hf_gbcs_gbz_additional_header_control, tvb, *offset, 1, ENC_NA);
592
0
        *offset += 1;
593
0
        component_len -= 1;
594
595
0
        proto_tree_add_item(component_tree, hf_gbcs_gbz_additional_frame_counter, tvb, *offset, 1, ENC_NA);
596
0
        *offset += 1;
597
0
        component_len -= 1;
598
0
    }
599
0
    proto_tree_add_item(component_tree, hf_gbcs_gbz_frame_control, tvb, *offset, 1, ENC_NA);
600
0
    *offset += 1;
601
0
    component_len -= 1;
602
603
0
    proto_tree_add_item(component_tree, hf_gbcs_gbz_transaction, tvb, *offset, 1, ENC_NA);
604
0
    *offset += 1;
605
0
    component_len -= 1;
606
607
0
    proto_tree_add_item(component_tree, hf_gbcs_gbz_command_id, tvb, *offset, 1, ENC_NA);
608
0
    *offset += 1;
609
0
    component_len -= 1;
610
611
0
    if (encryption_present) {
612
0
        proto_tree_add_item(component_tree, hf_gbcs_gbz_length_of_ciphered_information, tvb, *offset, 2, ENC_BIG_ENDIAN);
613
0
        *offset += 2;
614
0
        component_len -= 2;
615
616
0
        proto_tree_add_item(component_tree, hf_gbcs_gbz_security_control, tvb, *offset, 1, ENC_NA);
617
0
        *offset += 1;
618
0
        component_len -= 1;
619
620
0
        proto_tree_add_item(component_tree, hf_gbcs_gbz_invocation_counter, tvb, *offset, 4, ENC_BIG_ENDIAN);
621
0
        *offset += 4;
622
0
        component_len -= 4;
623
624
0
        if (component_len < GBCS_GBZ_MAC_LENGTH) {
625
0
            expert_add_info(pinfo, tree, &ei_gbcs_gbz_invalid_length);
626
0
        }
627
628
0
        proto_tree_add_item(component_tree, hf_gbcs_gbz_encrypted_payload, tvb, *offset, component_len - GBCS_GBZ_MAC_LENGTH, ENC_NA);
629
0
        *offset += component_len - GBCS_GBZ_MAC_LENGTH;
630
631
0
        proto_tree_add_item(component_tree, hf_gbcs_gbz_mac, tvb, *offset, GBCS_GBZ_MAC_LENGTH, ENC_NA);
632
0
        *offset += GBCS_GBZ_MAC_LENGTH;
633
0
    }
634
0
    else if (zcl_handle) {
635
0
        zbee_nwk_packet nwk;
636
0
        tvbuff_t *payload_tvb;
637
0
        const char *text;
638
0
        wmem_strbuf_t *strbuf;
639
640
0
        text = col_get_text(pinfo->cinfo, COL_INFO);
641
0
        if (text) {
642
0
            strbuf = wmem_strbuf_new(pinfo->pool, text);
643
0
        }
644
0
        nwk.cluster_id = cluster;
645
0
        payload_tvb = tvb_new_subset_length(tvb, *offset - 3, component_len + 3);
646
0
        call_dissector_with_data(zcl_handle, payload_tvb, pinfo, component_tree, &nwk);
647
0
        if (text) {
648
0
            col_add_str(pinfo->cinfo, COL_INFO, wmem_strbuf_get_str(strbuf));
649
0
        }
650
0
        *offset += component_len;
651
0
    }
652
0
    proto_item_set_end(ti, tvb, *offset);
653
0
}
654
655
static int dissect_gbcs_gbz(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
656
0
{
657
0
    proto_item *ti;
658
0
    proto_tree *gbz_tree;
659
0
    unsigned offset = 0;
660
0
    uint8_t cra = *(uint8_t*)data;
661
662
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "GBCS GBZ");
663
664
0
    ti = proto_tree_add_item(tree, proto_gbcs_gbz, tvb, 0, -1, ENC_NA);
665
0
    gbz_tree = proto_item_add_subtree(ti, ett_gbcs_gbz);
666
667
0
    proto_tree_add_item(gbz_tree, hf_gbcs_gbz_profile_id, tvb, offset, 2, ENC_BIG_ENDIAN);
668
0
    offset += 2;
669
670
0
    proto_tree_add_item(gbz_tree, hf_gbcs_gbz_components, tvb, offset, 1, ENC_NA);
671
0
    offset += 1;
672
673
0
    if (cra == GBCS_MESSAGE_CRA_ALERT) {
674
0
        uint32_t alert_code;
675
676
0
        proto_tree_add_item_ret_uint(gbz_tree, hf_gbcs_gbz_alert_code, tvb, offset, 2, ENC_BIG_ENDIAN, &alert_code);
677
0
        col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str_ext_const(alert_code, &gbcs_gbz_alert_code_names_ext, "Unknown alert"));
678
0
        offset += 2;
679
680
0
        proto_tree_add_item(gbz_tree, hf_gbcs_gbz_timestamp, tvb, offset, 4, ENC_TIME_ZBEE_ZCL|ENC_BIG_ENDIAN);
681
0
        offset += 4;
682
683
0
        switch (alert_code) {
684
0
        case GBCS_GBZ_ALERT_FIRMWARE_VERIFICATION_FAILED:
685
0
        case GBCS_GBZ_ALERT_FIRMWARE_VERIFICATION_SUCCESSFUL:
686
0
            proto_tree_add_item(gbz_tree, hf_gbcs_gbz_firmware_alert_start, tvb, offset, 2, ENC_BIG_ENDIAN);
687
0
            offset += 2;
688
689
0
            proto_tree_add_item(gbz_tree, hf_gbcs_gbz_firmware_hash, tvb, offset, 32, ENC_NA);
690
0
            offset += 32;
691
0
            break;
692
0
        case GBCS_GBZ_ALERT_FUTURE_DATE_HAN_INTERFACE_CMD_SUCCESS_ACTIONED:
693
0
        case GBCS_GBZ_ALERT_FUTURE_DATE_HAN_INTERFACE_CMD_NOT_SUCCESS_ACTION:
694
0
            if (tvb_get_uint8(tvb, offset) == 0x0E) {
695
0
                proto_tree_add_item(gbz_tree, hf_gbcs_gbz_future_alert_start, tvb, offset, 1, ENC_NA);
696
0
                offset += 1;
697
698
0
                proto_tree_add_item(gbz_tree, hf_gbcs_gbz_message_code, tvb, offset, 2, ENC_BIG_ENDIAN);
699
0
                offset += 2;
700
701
0
                proto_tree_add_item(gbz_tree, hf_gbcs_gbz_originator_counter, tvb, offset, 8, ENC_BIG_ENDIAN);
702
0
                offset += 8;
703
704
0
                proto_tree_add_item(gbz_tree, hf_gbcs_gbz_extended_header_cluster, tvb, offset, 2, ENC_BIG_ENDIAN);
705
0
                offset += 2;
706
707
0
                proto_tree_add_item(gbz_tree, hf_gbcs_gbz_frame_control, tvb, offset, 1, ENC_NA);
708
0
                offset += 1;
709
710
0
                proto_tree_add_item(gbz_tree, hf_gbcs_gbz_command_id, tvb, offset, 1, ENC_NA);
711
0
                offset += 1;
712
0
            }
713
0
            break;
714
0
        case GBCS_GBZ_ALERT_BILLING_DATA_LOG_UPDATED:
715
0
            dissect_gbcs_gbz_component(tvb, pinfo, gbz_tree, &offset, 0);
716
0
            break;
717
0
        case GBCS_GBZ_ALERT_SMART_METER_INTEGRITY_ISSUE_WARNING:
718
0
            proto_tree_add_item(gbz_tree, hf_gbcs_gbz_integrity_issue_warning, tvb, offset, 2, ENC_BIG_ENDIAN);
719
0
            offset += 2;
720
0
            break;
721
0
        default:
722
0
            break;
723
0
        }
724
0
    }
725
0
    else {
726
0
        unsigned component_index = 0;
727
728
0
        while (tvb_reported_length_remaining(tvb, offset) > 0) {
729
0
            dissect_gbcs_gbz_component(tvb, pinfo, gbz_tree, &offset, component_index++);
730
0
        }
731
0
    }
732
733
0
    return tvb_captured_length(tvb);
734
0
}
735
736
void proto_register_gbcs_gbz(void)
737
15
{
738
15
    static hf_register_info hf[] = {
739
15
        {&hf_gbcs_gbz_profile_id,
740
15
            {"Profile ID", "gbcs_gbz.profile_id",
741
15
             FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
742
15
        },
743
15
        {&hf_gbcs_gbz_components,
744
15
            {"Total number of GBZ Use Case Specific Component(s)", "gbcs_gbz.components",
745
15
              FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
746
15
        },
747
15
        {&hf_gbcs_gbz_extended_header_control,
748
15
            {"Extended Header Control Field", "gbcs_gbz.extended_header_control",
749
15
              FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
750
15
        },
751
15
        {&hf_gbcs_gbz_extended_header_cluster,
752
15
            {"Extended Header Cluster ID", "gbcs_gbz.extended_header_cluster",
753
15
              FT_UINT16, BASE_HEX | BASE_RANGE_STRING, RVALS(zbee_aps_cid_names), 0x0, NULL, HFILL}
754
15
        },
755
15
        {&hf_gbcs_gbz_extended_header_length,
756
15
            {"Extended Header Length", "gbcs_gbz.extended_header_length",
757
15
              FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
758
15
        },
759
15
        {&hf_gbcs_gbz_alert_code,
760
15
            {"Alert Code", "gbcs_gbz.alert_code",
761
15
              FT_UINT16, BASE_HEX | BASE_EXT_STRING, &gbcs_gbz_alert_code_names_ext, 0x0, NULL, HFILL}
762
15
        },
763
15
        {&hf_gbcs_gbz_timestamp,
764
15
            {"Timestamp", "gbcs_gbz.timestamp",
765
15
             FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL}
766
15
        },
767
15
        {&hf_gbcs_gbz_firmware_alert_start,
768
15
            {"Firmware Alert Start", "gbcs_gbz.firmware_alert_start",
769
15
             FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}
770
15
        },
771
15
        {&hf_gbcs_gbz_firmware_hash,
772
15
            {"Calculated Manufacture Image Hash", "gbcs_gbz.firmware_hash",
773
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
774
15
        },
775
15
        {&hf_gbcs_gbz_future_alert_start,
776
15
            {"Future Dated Command Alert Start", "gbcs_gbz.future_alert_start",
777
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
778
15
        },
779
15
        {&hf_gbcs_gbz_message_code,
780
15
            {"Message Code", "gbcs_gbz.message_code",
781
15
             FT_UINT16, BASE_HEX | BASE_EXT_STRING, &gbcs_message_code_names_ext, 0x0, NULL, HFILL}
782
15
        },
783
15
        {&hf_gbcs_gbz_originator_counter,
784
15
            {"Originator Counter", "gbcs_gbz.originator_counter",
785
15
             FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
786
15
        },
787
15
        {&hf_gbcs_gbz_frame_control,
788
15
            {"Frame Control", "gbcs_gbz.frame_control",
789
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
790
15
        },
791
15
        {&hf_gbcs_gbz_command_id,
792
15
            {"Command Identifier", "gbcs_gbz.command_id",
793
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
794
15
        },
795
15
        {&hf_gbcs_gbz_integrity_issue_warning,
796
15
            {"Integrity Issue Warning", "gbcs_gbz.integrity_issue_warning",
797
15
             FT_UINT16, BASE_HEX, VALS(gbcs_gbz_integrity_issue_warning_names), 0x0, NULL, HFILL}
798
15
        },
799
15
        {&hf_gbcs_gbz_from_date_time,
800
15
            {"From Date Time", "gbcs_gbz.from_date_time",
801
15
             FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL}
802
15
        },
803
15
        {&hf_gbcs_gbz_additional_header_control,
804
15
            {"Additional Header Control", "gbcs_gbz.additional_header_control",
805
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
806
15
        },
807
15
        {&hf_gbcs_gbz_additional_frame_counter,
808
15
            {"Additional Header Frame Counter", "gbcs_gbz.additional_frame_counter",
809
15
             FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
810
15
        },
811
15
        {&hf_gbcs_gbz_transaction,
812
15
            {"Transaction Sequence Number", "gbcs_gbz.transaction",
813
15
             FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
814
15
        },
815
15
        {&hf_gbcs_gbz_length_of_ciphered_information,
816
15
            {"Length of Ciphered Information", "gbcs_gbz.length_of_ciphered_information",
817
15
             FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
818
15
        },
819
15
        {&hf_gbcs_gbz_security_control,
820
15
            {"Security Control", "gbcs_gbz.security_control",
821
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
822
15
        },
823
15
        {&hf_gbcs_gbz_invocation_counter,
824
15
            {"Invocation Counter", "gbcs_gbz.invocation_counter",
825
15
             FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
826
15
        },
827
15
        {&hf_gbcs_gbz_encrypted_payload,
828
15
            {"Encrypted ZCL Payload", "gbcs_gbz.encrypted_payload",
829
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
830
15
        },
831
15
        {&hf_gbcs_gbz_mac,
832
15
            {"Encrypted ZCL MAC", "gbcs_gbz.mac",
833
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
834
15
        }
835
15
    };
836
837
15
    static int *ett[1 + GBCS_GBZ_MAX_COMPONENTS];
838
839
15
    int j = 0;
840
15
    ett[j++] = &ett_gbcs_gbz;
841
480
    for (int i = 0; i < GBCS_GBZ_MAX_COMPONENTS; i++, j++) {
842
465
        ett[j] = &ett_gbcs_gbz_components[i];
843
465
    }
844
845
15
    expert_module_t* expert_gbcs_gbz;
846
15
    static ei_register_info ei[] = {
847
15
        { &ei_gbcs_gbz_invalid_length,
848
15
            { "gbcs_gbz.invalid_length", PI_PROTOCOL, PI_WARN, "Invalid length", EXPFILL }}
849
15
    };
850
851
15
    proto_gbcs_gbz = proto_register_protocol("GBCS GBZ", "GBCS GBZ", "gbcs_gbz");
852
15
    register_dissector("gbcs_gbz", dissect_gbcs_gbz, proto_gbcs_gbz);
853
15
    proto_register_field_array(proto_gbcs_gbz, hf, array_length(hf));
854
15
    proto_register_subtree_array(ett, array_length(ett));
855
856
15
    expert_gbcs_gbz = expert_register_protocol(proto_gbcs_gbz);
857
15
    expert_register_field_array(expert_gbcs_gbz, ei, array_length(ei));
858
15
}
859
860
void proto_reg_handoff_gbcs_gbz(void)
861
15
{
862
15
    zcl_handle = find_dissector(ZBEE_PROTOABBREV_ZCL);
863
15
}
864
865
/* ########################################################################## */
866
/* #### GBCS Tunnel ######################################################### */
867
/* ########################################################################## */
868
869
#define gbcs_tunnel_command_names_VALUE_STRING_LIST(XXX) \
870
    XXX(GBCS_TUNNEL_COMMAND_GET,                                0x01, "GET" ) \
871
    XXX(GBCS_TUNNEL_COMMAND_GET_RESPONSE,                       0x02, "GET-RESPONSE" ) \
872
    XXX(GBCS_TUNNEL_COMMAND_PUT,                                0x03, "PUT" )
873
874
VALUE_STRING_ENUM(gbcs_tunnel_command_names);
875
VALUE_STRING_ARRAY(gbcs_tunnel_command_names);
876
877
static dissector_handle_t gbcs_message_handle;
878
879
static int proto_gbcs_tunnel;
880
881
static int hf_gbcs_tunnel_command;
882
static int hf_gbcs_tunnel_remaining;
883
884
static int ett_gbcs_tunnel;
885
886
void proto_register_gbcs_tunnel(void);
887
void proto_reg_handoff_gbcs_tunnel(void);
888
889
static int dissect_gbcs_tunnel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
890
0
{
891
0
    unsigned offset = 0;
892
0
    uint8_t command;
893
894
0
    command = tvb_get_uint8(tvb, offset);
895
0
    switch (command) {
896
0
        case GBCS_TUNNEL_COMMAND_GET:
897
0
        case GBCS_TUNNEL_COMMAND_GET_RESPONSE:
898
0
        case GBCS_TUNNEL_COMMAND_PUT: {
899
0
            proto_item *ti;
900
0
            proto_tree *tunnel_tree;
901
902
0
            col_set_str(pinfo->cinfo, COL_PROTOCOL, "GBCS Tunnel");
903
904
0
            ti = proto_tree_add_item(tree, proto_gbcs_tunnel, tvb, offset, -1, ENC_NA);
905
0
            tunnel_tree = proto_item_add_subtree(ti, ett_gbcs_tunnel);
906
907
0
            col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(command, gbcs_tunnel_command_names, "Unknown Command"));
908
0
            proto_tree_add_item(tunnel_tree, hf_gbcs_tunnel_command, tvb, offset, 1, ENC_NA);
909
0
            offset += 1;
910
911
0
            if (command == GBCS_TUNNEL_COMMAND_GET_RESPONSE) {
912
0
                proto_tree_add_item(tunnel_tree, hf_gbcs_tunnel_remaining, tvb, offset, 1, ENC_NA);
913
0
                offset += 1;
914
0
            }
915
0
            break;
916
0
        }
917
918
0
        default:
919
            /* No tunnel header */
920
0
            col_clear(pinfo->cinfo, COL_INFO);
921
0
            break;
922
0
    }
923
924
0
    if (command != GBCS_TUNNEL_COMMAND_GET && tvb_reported_length_remaining(tvb, offset) > 0) {
925
0
        tvbuff_t *payload_tvb = tvb_new_subset_remaining(tvb, offset);
926
927
0
        if (gbcs_message_handle != NULL) {
928
0
            call_dissector_with_data(gbcs_message_handle, payload_tvb, pinfo, tree, NULL);
929
0
        }
930
0
        else {
931
0
            call_data_dissector(payload_tvb, pinfo, tree);
932
0
        }
933
0
    }
934
935
0
    return tvb_captured_length(tvb);
936
0
}
937
938
static bool
939
dissect_gbcs_tunnel_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
940
2
{
941
2
    switch (tvb_get_uint8(tvb, 0)) {
942
0
        case GBCS_TUNNEL_COMMAND_GET:
943
0
        case GBCS_TUNNEL_COMMAND_PUT:
944
0
        case GBCS_TUNNEL_COMMAND_GET_RESPONSE:
945
0
        case 0xDD:
946
0
        case 0xDF:
947
0
            dissect_gbcs_tunnel(tvb, pinfo, tree, data);
948
0
            return true;
949
950
2
        default:
951
2
            return false;
952
2
    }
953
2
}
954
955
void proto_register_gbcs_tunnel(void)
956
15
{
957
15
    static hf_register_info hf[] = {
958
15
        {&hf_gbcs_tunnel_command,
959
15
            {"Transfer data command", "gbcs_tunnel.command",
960
15
             FT_UINT8, BASE_HEX, VALS(gbcs_tunnel_command_names), 0x0, NULL, HFILL}
961
15
        },
962
15
        {&hf_gbcs_tunnel_remaining,
963
15
            {"Remaining messages", "gbcs_tunnel.remaining",
964
15
             FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
965
15
        }
966
15
    };
967
968
15
    static int *ett[] = {
969
15
        &ett_gbcs_tunnel,
970
15
    };
971
972
15
    proto_gbcs_tunnel = proto_register_protocol("GBCS Tunnel", "GBCS Tunnel", "gbcs_tunnel");
973
15
    register_dissector("gbcs_tunnel", dissect_gbcs_tunnel, proto_gbcs_tunnel);
974
15
    proto_register_field_array(proto_gbcs_tunnel, hf, array_length(hf));
975
15
    proto_register_subtree_array(ett, array_length(ett));
976
15
}
977
978
void proto_reg_handoff_gbcs_tunnel(void)
979
15
{
980
15
    gbcs_message_handle = find_dissector("gbcs_message");
981
15
    heur_dissector_add("zbee_zcl_se.tun", dissect_gbcs_tunnel_heur, "GBCS over ZigBee SE Tunneling", "gbcs_zbee_zcl_se.tun", proto_gbcs_tunnel, HEURISTIC_ENABLE);
982
15
}
983
984
/* ########################################################################## */
985
/* #### GBCS Message ######################################################### */
986
/* ########################################################################## */
987
988
0
#define GBCS_MESSAGE_GENERAL_CIPHERING                          0xDD
989
0
#define GBCS_MESSAGE_GENERAL_SIGNING                            0xDF
990
0
#define GBCS_MESSAGE_ACCESS_REQUEST                             0xD9
991
0
#define GBCS_MESSAGE_ACCESS_RESPONSE                            0xDA
992
0
#define GBCS_MESSAGE_DATA_NOTIFICATION                          0x0F
993
#define GBCS_MESSAGE_GENERAL_BLOCK_TRANSFER                     0xE0
994
995
#define GBCS_MESSAGE_TRANSACTION_ID_LENGTH                      9
996
0
#define GBCS_MESSAGE_DLMS_DATE_TIME_LENGTH                      12
997
#define GBCS_MESSAGE_KRP_LENGTH                                 64
998
0
#define GBCS_MESSAGE_MAC_LENGTH                                 12
999
1000
15
#define GBCS_MESSAGE_GBT_BLOCK_CONTROL_LAST_BLOCK               0x80
1001
15
#define GBCS_MESSAGE_GBT_BLOCK_CONTROL_STREAMING                0x40
1002
15
#define GBCS_MESSAGE_GBT_BLOCK_CONTROL_WINDOW                   0x3F
1003
1004
static dissector_handle_t gbcs_gbcs_handle;
1005
static dissector_handle_t gbcs_gbz_handle;
1006
static dissector_handle_t gbcs_ber_handle;
1007
1008
static int proto_gbcs_message;
1009
1010
static int hf_gbcs_message_element_length;
1011
static int hf_gbcs_message_mac_header_general_ciphering;
1012
static int hf_gbcs_message_mac_header_cra_flag;
1013
static int hf_gbcs_message_mac_header_originator_counter;
1014
static int hf_gbcs_message_mac_header_business_originator_id;
1015
static int hf_gbcs_message_mac_header_business_target_id;
1016
static int hf_gbcs_message_mac_header_date_time;
1017
static int hf_gbcs_message_mac_header_other_info;
1018
static int hf_gbcs_message_mac_header_key_info;
1019
static int hf_gbcs_message_mac_header_security_control_byte;
1020
static int hf_gbcs_message_mac_header_invocation_counter;
1021
static int hf_gbcs_message_grouping_header_general_signing;
1022
static int hf_gbcs_message_grouping_header_cra_flag;
1023
static int hf_gbcs_message_grouping_header_originator_counter;
1024
static int hf_gbcs_message_grouping_header_business_originator_id;
1025
static int hf_gbcs_message_grouping_header_business_target_id;
1026
static int hf_gbcs_message_grouping_header_date_time;
1027
static int hf_gbcs_message_grouping_header_message_code;
1028
static int hf_gbcs_message_grouping_header_supplementary_remote_party_id;
1029
static int hf_gbcs_message_grouping_header_supplementary_remote_party_counter;
1030
static int hf_gbcs_message_grouping_header_supplementary_originator_counter;
1031
static int hf_gbcs_message_grouping_header_supplementary_remote_party_ka_certificate;
1032
static int hf_gbcs_message_krp;
1033
static int hf_gbcs_message_mac;
1034
static int hf_gbcs_message_routing_header_general_ciphering;
1035
static int hf_gbcs_message_routing_header_cra_flag;
1036
static int hf_gbcs_message_routing_header_originator_counter;
1037
static int hf_gbcs_message_routing_header_business_originator_id;
1038
static int hf_gbcs_message_routing_header_business_target_id;
1039
static int hf_gbcs_message_routing_header_date_time;
1040
static int hf_gbcs_message_routing_header_message_code;
1041
static int hf_gbcs_message_routing_header_key_info;
1042
static int hf_gbcs_message_routing_header_security_control_byte;
1043
static int hf_gbcs_message_routing_header_invocation_counter;
1044
static int hf_gbcs_message_gbt_header_general_block_transfer;
1045
static int hf_gbcs_message_gbt_header_block_control;
1046
static int hf_gbcs_message_gbt_header_block_control_last_block;
1047
static int hf_gbcs_message_gbt_header_block_control_streaming;
1048
static int hf_gbcs_message_gbt_header_block_control_window;
1049
static int hf_gbcs_message_gbt_header_block_number;
1050
static int hf_gbcs_message_gbt_header_block_number_ack;
1051
static int hf_gbcs_message_gbt_blocks;
1052
static int hf_gbcs_message_gbt_block;
1053
static int hf_gbcs_message_gbt_block_overlap;
1054
static int hf_gbcs_message_gbt_block_overlap_conflicts;
1055
static int hf_gbcs_message_gbt_block_multiple_tails;
1056
static int hf_gbcs_message_gbt_block_too_long_fragment;
1057
static int hf_gbcs_message_gbt_block_error;
1058
static int hf_gbcs_message_gbt_block_count;
1059
static int hf_gbcs_message_gbt_reassembled_in;
1060
static int hf_gbcs_message_gbt_reassembled_length;
1061
1062
static int ett_gbcs_message;
1063
static int ett_gbcs_message_element;
1064
static int ett_gbcs_message_mac_header;
1065
static int ett_gbcs_message_grouping_header;
1066
static int ett_gbcs_message_grouping_header_other_info;
1067
static int ett_gbcs_message_routing_header;
1068
static int ett_gbcs_message_routing_header_other_info;
1069
static int ett_gbcs_message_gbt_header;
1070
static int ett_gbcs_message_gbt_header_block_control;
1071
static int ett_gbcs_message_gbt_fragment;
1072
static int ett_gbcs_message_gbt_fragments;
1073
static int ett_gbcs_message_asn1;
1074
static int ett_gbcs_message_dlms;
1075
1076
static reassembly_table gbcs_message_gbt_reassembly_table;
1077
1078
static const fragment_items gbcs_message_gbt_frag_items = {
1079
    /* Fragment subtrees */
1080
    &ett_gbcs_message_gbt_fragment,
1081
    &ett_gbcs_message_gbt_fragments,
1082
    /* Fragment fields */
1083
    &hf_gbcs_message_gbt_blocks,
1084
    &hf_gbcs_message_gbt_block,
1085
    &hf_gbcs_message_gbt_block_overlap,
1086
    &hf_gbcs_message_gbt_block_overlap_conflicts,
1087
    &hf_gbcs_message_gbt_block_multiple_tails,
1088
    &hf_gbcs_message_gbt_block_too_long_fragment,
1089
    &hf_gbcs_message_gbt_block_error,
1090
    &hf_gbcs_message_gbt_block_count,
1091
    /* Reassembled in field */
1092
    &hf_gbcs_message_gbt_reassembled_in,
1093
    /* Reassembled length field */
1094
    &hf_gbcs_message_gbt_reassembled_length,
1095
    /* Reassembled data field */
1096
    NULL,
1097
    /* Tag */
1098
    "GBT fragments"
1099
};
1100
1101
void proto_register_gbcs_message(void);
1102
void proto_reg_handoff_gbcs_message(void);
1103
1104
/* Make a subtree with an element (to show length + element value) and show value at top of subtree */
1105
static void
1106
dissect_gbcs_message_element(proto_tree *tree, packet_info* pinfo, int hfindex, tvbuff_t *tvb, unsigned *offset)
1107
0
{
1108
0
    proto_tree *element_tree;
1109
0
    proto_item *tree_ti, *value_ti;
1110
0
    unsigned len;
1111
1112
0
    element_tree = proto_tree_add_subtree(tree, tvb, *offset, 1, ett_gbcs_message_element, &tree_ti, proto_registrar_get_name(hfindex));
1113
1114
0
    proto_tree_add_item_ret_uint(element_tree, hf_gbcs_message_element_length, tvb, *offset, 1, ENC_NA, &len);
1115
0
    *offset += 1;
1116
0
    proto_item_set_len(tree_ti, len+1);
1117
1118
0
    if (len > 0) {
1119
0
        value_ti = proto_tree_add_item(element_tree, hfindex, tvb, *offset, len, ENC_BIG_ENDIAN);
1120
0
        proto_item_append_text(tree_ti, ": %s", proto_item_get_display_repr(pinfo->pool, value_ti));
1121
0
    }
1122
0
    else {
1123
0
        proto_item_append_text(tree_ti, ": <none>");
1124
0
    }
1125
0
    *offset += len;
1126
0
}
1127
1128
/* Make a subtree with an transaction ID and show flag and value at top of subtree */
1129
static void
1130
dissect_gbcs_message_element_transaction_id(proto_tree *tree, packet_info* pinfo, int hfindex_cra_flag, int hfindex_originator_counter, tvbuff_t *tvb, unsigned *offset)
1131
0
{
1132
0
    proto_tree *element_tree;
1133
0
    proto_item *tree_ti, *value_ti;
1134
0
    unsigned len;
1135
1136
0
    element_tree = proto_tree_add_subtree(tree, tvb, *offset, 1, ett_gbcs_message_element, &tree_ti, "Transaction ID");
1137
1138
0
    proto_tree_add_item_ret_uint(element_tree, hf_gbcs_message_element_length, tvb, *offset, 1, ENC_NA, &len);
1139
0
    *offset += 1;
1140
0
    proto_item_set_len(tree_ti, len + 1);
1141
1142
0
    if (len > 0) {
1143
0
        uint32_t flag;
1144
0
        proto_tree_add_item_ret_uint(element_tree, hfindex_cra_flag, tvb, *offset, 1, ENC_BIG_ENDIAN, &flag);
1145
0
        proto_item_append_text(tree_ti, ": %s (0x%02x)", val_to_str_const(flag, gbcs_message_cra_names, "Unknown CRA"), flag);
1146
0
        *offset += 1;
1147
1148
0
        value_ti = proto_tree_add_item(element_tree, hfindex_originator_counter, tvb, *offset, 8, ENC_BIG_ENDIAN);
1149
0
        proto_item_append_text(tree_ti, ", %s", proto_item_get_display_repr(pinfo->pool, value_ti));
1150
1151
0
        *offset += 8;
1152
0
    }
1153
0
    else {
1154
0
        proto_item_append_text(tree_ti, ": <none>");
1155
0
    }
1156
0
}
1157
1158
/* Make a subtree with a date/time field (to show length + value) and show value at top of subtree */
1159
static void
1160
dissect_gbcs_message_element_date_time(proto_tree *tree, packet_info* pinfo, int hfindex, tvbuff_t *tvb, unsigned *offset)
1161
0
{
1162
0
    proto_tree *element_tree;
1163
0
    proto_item *tree_ti, *value_ti;
1164
0
    unsigned len;
1165
1166
0
    element_tree = proto_tree_add_subtree(tree, tvb, *offset, 1, ett_gbcs_message_element, &tree_ti, proto_registrar_get_name(hfindex));
1167
1168
0
    proto_tree_add_item_ret_uint(element_tree, hf_gbcs_message_element_length, tvb, *offset, 1, ENC_NA, &len);
1169
0
    *offset += 1;
1170
1171
0
    if (len > 0) {
1172
0
        nstime_t date_time;
1173
1174
0
        dlms_date_time(tvb, *offset, &date_time);
1175
0
        value_ti = proto_tree_add_time(element_tree, hfindex, tvb, *offset, GBCS_MESSAGE_DLMS_DATE_TIME_LENGTH, &date_time);
1176
0
        proto_item_append_text(tree_ti, ": %s", proto_item_get_display_repr(pinfo->pool, value_ti));
1177
0
        *offset += GBCS_MESSAGE_DLMS_DATE_TIME_LENGTH;
1178
1179
0
        proto_item_set_end(tree_ti, tvb, *offset);
1180
0
    }
1181
0
    else {
1182
0
        proto_item_append_text(tree_ti, ": <none>");
1183
0
    }
1184
0
}
1185
1186
static void
1187
dissect_gbcs_message_mac_header(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, unsigned *offset)
1188
0
{
1189
0
    proto_item *ti;
1190
0
    proto_tree *mac_header_tree;
1191
0
    unsigned len, offset_start;
1192
1193
0
    mac_header_tree = proto_tree_add_subtree(tree, tvb, *offset, 1, ett_gbcs_message_mac_header, &ti, "MAC Header");
1194
1195
0
    proto_tree_add_item(mac_header_tree, hf_gbcs_message_mac_header_general_ciphering, tvb, *offset, 1, ENC_NA);
1196
0
    *offset += 1;
1197
1198
0
    dissect_gbcs_message_element_transaction_id(mac_header_tree, pinfo, hf_gbcs_message_mac_header_cra_flag,
1199
0
                                                hf_gbcs_message_mac_header_originator_counter, tvb, offset); // transaction-id - always none
1200
0
    dissect_gbcs_message_element(mac_header_tree, pinfo, hf_gbcs_message_mac_header_business_originator_id, tvb, offset); // originator-system-title - always none
1201
0
    dissect_gbcs_message_element(mac_header_tree, pinfo, hf_gbcs_message_mac_header_business_target_id, tvb, offset); // recipient-system-title - always none
1202
0
    dissect_gbcs_message_element_date_time(mac_header_tree, pinfo, hf_gbcs_message_mac_header_date_time, tvb, offset); // date-time - always none
1203
0
    dissect_gbcs_message_element(mac_header_tree, pinfo, hf_gbcs_message_mac_header_other_info, tvb, offset); // other-information - always none
1204
0
    dissect_gbcs_message_element(mac_header_tree, pinfo, hf_gbcs_message_mac_header_key_info, tvb, offset); // key-info - always none
1205
1206
0
    offset_start = *offset;
1207
0
    *offset = get_ber_length(tvb, *offset, &len, NULL);
1208
0
    proto_tree_add_uint(mac_header_tree, hf_gbcs_message_element_length, tvb, offset_start, *offset - offset_start, len);
1209
1210
0
    proto_tree_add_item(mac_header_tree, hf_gbcs_message_mac_header_security_control_byte, tvb, *offset, 1, ENC_NA);
1211
0
    *offset += 1;
1212
1213
0
    proto_tree_add_item(mac_header_tree, hf_gbcs_message_mac_header_invocation_counter, tvb, *offset, 4, ENC_BIG_ENDIAN);
1214
0
    *offset += 4;
1215
1216
0
    proto_item_set_end(ti, tvb, *offset);
1217
0
}
1218
1219
static void
1220
dissect_gbcs_message_grouping_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned *offset, unsigned *len, uint8_t *cra)
1221
0
{
1222
0
    proto_item *grouping_header_ti, *other_info_ti;
1223
0
    proto_tree *grouping_header_tree, *other_info_tree;
1224
0
    unsigned other_info_len;
1225
0
    unsigned offset_start;
1226
0
    uint32_t message_code;
1227
1228
0
    grouping_header_tree = proto_tree_add_subtree(tree, tvb, *offset, 1, ett_gbcs_message_grouping_header, &grouping_header_ti, "Grouping Header");
1229
1230
0
    proto_tree_add_item(grouping_header_tree, hf_gbcs_message_grouping_header_general_signing, tvb, *offset, 1, ENC_NA);
1231
0
    *offset += 1;
1232
1233
0
    *cra = tvb_get_uint8(tvb, *offset + 1);
1234
0
    col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str_const(*cra, gbcs_message_cra_names, "Unknown CRA"));
1235
0
    dissect_gbcs_message_element_transaction_id(grouping_header_tree, pinfo,
1236
0
            hf_gbcs_message_grouping_header_cra_flag, hf_gbcs_message_grouping_header_originator_counter, tvb, offset);
1237
1238
0
    dissect_gbcs_message_element(grouping_header_tree, pinfo, hf_gbcs_message_grouping_header_business_originator_id, tvb, offset);
1239
1240
0
    dissect_gbcs_message_element(grouping_header_tree, pinfo, hf_gbcs_message_grouping_header_business_target_id, tvb, offset);
1241
1242
0
    dissect_gbcs_message_element_date_time(grouping_header_tree, pinfo, hf_gbcs_message_grouping_header_date_time, tvb, offset);
1243
1244
0
    other_info_tree = proto_tree_add_subtree(grouping_header_tree, tvb,
1245
0
            *offset, 1, ett_gbcs_message_grouping_header_other_info, &other_info_ti, "Other Information");
1246
1247
0
    offset_start = *offset;
1248
0
    *offset = get_ber_length(tvb, *offset, &other_info_len, NULL);
1249
0
    proto_tree_add_uint(other_info_tree, hf_gbcs_message_element_length, tvb, offset_start, *offset - offset_start, other_info_len);
1250
1251
0
    proto_tree_add_item_ret_uint(other_info_tree, hf_gbcs_message_grouping_header_message_code,
1252
0
            tvb, *offset, 2, ENC_BIG_ENDIAN, &message_code);
1253
0
    col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, val_to_str_ext_const(message_code, &gbcs_message_code_names_ext, "Unknown Use Case"));
1254
0
    *offset += 2;
1255
0
    other_info_len -= 2;
1256
1257
0
    if (other_info_len > 0) {
1258
0
        proto_tree_add_item(other_info_tree, hf_gbcs_message_grouping_header_supplementary_remote_party_id,
1259
0
                tvb, *offset, 8, ENC_BIG_ENDIAN);
1260
0
        *offset += 8;
1261
0
        other_info_len -= 8;
1262
0
    }
1263
1264
0
    if (other_info_len > 0) {
1265
0
        proto_tree_add_item(other_info_tree, hf_gbcs_message_grouping_header_supplementary_remote_party_counter,
1266
0
                tvb, *offset, 8, ENC_BIG_ENDIAN);
1267
0
        *offset += 8;
1268
0
        other_info_len -= 8;
1269
0
    }
1270
1271
0
    if (other_info_len > 0) {
1272
0
        proto_tree_add_item(other_info_tree, hf_gbcs_message_grouping_header_supplementary_originator_counter,
1273
0
                tvb, *offset, 8, ENC_BIG_ENDIAN);
1274
0
        *offset += 8;
1275
0
        other_info_len -= 8;
1276
0
    }
1277
1278
0
    if (other_info_len > 0) {
1279
0
        proto_tree_add_item(other_info_tree, hf_gbcs_message_grouping_header_supplementary_remote_party_ka_certificate,
1280
0
                tvb, *offset, other_info_len, ENC_NA);
1281
0
        *offset += other_info_len;
1282
0
    }
1283
1284
0
    proto_item_set_end(other_info_ti, tvb, *offset);
1285
1286
0
    offset_start = *offset;
1287
0
    *offset = get_ber_length(tvb, *offset, len, NULL);
1288
0
    proto_tree_add_uint(grouping_header_tree, hf_gbcs_message_element_length, tvb, offset_start, *offset - offset_start, *len);
1289
1290
0
    proto_item_set_end(grouping_header_ti, tvb, *offset);
1291
0
}
1292
1293
static void
1294
dissect_gbcs_message_routing_header(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, unsigned *offset,
1295
        uint64_t *business_originator, uint64_t *originator_counter)
1296
0
{
1297
0
    proto_item *routing_header_ti, *other_info_ti;
1298
0
    proto_tree *routing_header_tree, *other_info_tree;
1299
0
    unsigned other_info_len;
1300
0
    unsigned len, offset_start;
1301
1302
0
    routing_header_tree = proto_tree_add_subtree(tree, tvb, *offset, 1, ett_gbcs_message_routing_header, &routing_header_ti, "Routing Header");
1303
1304
0
    proto_tree_add_item(routing_header_tree, hf_gbcs_message_routing_header_general_ciphering, tvb, *offset, 1, ENC_NA);
1305
0
    *offset += 1;
1306
1307
0
    *originator_counter = tvb_get_uint64(tvb, *offset + 2, ENC_BIG_ENDIAN);
1308
0
    dissect_gbcs_message_element_transaction_id(routing_header_tree, pinfo,
1309
0
            hf_gbcs_message_routing_header_cra_flag, hf_gbcs_message_routing_header_originator_counter, tvb, offset);
1310
1311
0
    *business_originator = tvb_get_uint64(tvb, *offset + 1, ENC_BIG_ENDIAN);
1312
0
    dissect_gbcs_message_element(routing_header_tree, pinfo, hf_gbcs_message_routing_header_business_originator_id, tvb, offset);
1313
1314
0
    dissect_gbcs_message_element(routing_header_tree, pinfo, hf_gbcs_message_routing_header_business_target_id, tvb, offset);
1315
1316
0
    dissect_gbcs_message_element_date_time(routing_header_tree, pinfo, hf_gbcs_message_routing_header_date_time, tvb, offset); // date-time - always none
1317
1318
0
    other_info_tree = proto_tree_add_subtree(routing_header_tree, tvb,
1319
0
            *offset, 1, ett_gbcs_message_routing_header_other_info, &other_info_ti, "Other Information");
1320
1321
0
    offset_start = *offset;
1322
0
    *offset = get_ber_length(tvb, *offset, &other_info_len, NULL);
1323
0
    proto_tree_add_uint(other_info_tree, hf_gbcs_message_element_length, tvb, offset_start, *offset - offset_start, other_info_len);
1324
1325
0
    proto_tree_add_item(other_info_tree, hf_gbcs_message_routing_header_message_code, tvb, *offset, 2, ENC_BIG_ENDIAN);
1326
0
    *offset += 2;
1327
1328
0
    dissect_gbcs_message_element(routing_header_tree, pinfo, hf_gbcs_message_routing_header_key_info, tvb, offset); // key-info - always none
1329
1330
0
    offset_start = *offset;
1331
0
    *offset = get_ber_length(tvb, *offset, &len, NULL);
1332
0
    proto_tree_add_uint(routing_header_tree, hf_gbcs_message_element_length, tvb, offset_start, *offset - offset_start, len);
1333
1334
0
    proto_tree_add_item(routing_header_tree, hf_gbcs_message_routing_header_security_control_byte, tvb, *offset, 1, ENC_NA);
1335
0
    *offset += 1;
1336
1337
0
    proto_tree_add_item(routing_header_tree, hf_gbcs_message_routing_header_invocation_counter, tvb, *offset, 4, ENC_BIG_ENDIAN);
1338
0
    *offset += 4;
1339
1340
0
    proto_item_set_end(routing_header_ti, tvb, *offset);
1341
0
}
1342
1343
static void
1344
dissect_gbcs_message_gbt_header(tvbuff_t *tvb, proto_tree *tree, unsigned *offset,
1345
        unsigned *len, uint16_t *block_number, bool *last)
1346
0
{
1347
0
    proto_item *ti;
1348
0
    proto_tree *gbt_header_tree;
1349
0
    unsigned offset_start;
1350
1351
0
    gbt_header_tree = proto_tree_add_subtree(tree, tvb, *offset, 1, ett_gbcs_message_gbt_header, &ti, "GBT Header");
1352
1353
0
    proto_tree_add_item(gbt_header_tree, hf_gbcs_message_gbt_header_general_block_transfer, tvb, *offset, 1, ENC_NA);
1354
0
    *offset += 1;
1355
1356
0
    static int* const block_control[] = {
1357
0
            &hf_gbcs_message_gbt_header_block_control_last_block,
1358
0
            &hf_gbcs_message_gbt_header_block_control_streaming,
1359
0
            &hf_gbcs_message_gbt_header_block_control_window,
1360
0
            NULL
1361
0
    };
1362
1363
0
    *last = tvb_get_uint8(tvb, *offset) & GBCS_MESSAGE_GBT_BLOCK_CONTROL_LAST_BLOCK;
1364
0
    proto_tree_add_bitmask(gbt_header_tree, tvb, *offset, hf_gbcs_message_gbt_header_block_control,
1365
0
            ett_gbcs_message_gbt_header_block_control, block_control, ENC_BIG_ENDIAN);
1366
0
    *offset += 1;
1367
1368
0
    *block_number = tvb_get_uint16(tvb, *offset, ENC_BIG_ENDIAN);
1369
0
    proto_tree_add_item(gbt_header_tree, hf_gbcs_message_gbt_header_block_number, tvb, *offset, 2, ENC_BIG_ENDIAN);
1370
0
    *offset += 2;
1371
1372
0
    proto_tree_add_item(gbt_header_tree, hf_gbcs_message_gbt_header_block_number_ack, tvb, *offset, 2, ENC_BIG_ENDIAN);
1373
0
    *offset += 2;
1374
1375
0
    offset_start = *offset;
1376
0
    *offset = get_ber_length(tvb, *offset, len, NULL);
1377
0
    proto_tree_add_uint(gbt_header_tree, hf_gbcs_message_element_length, tvb, offset_start, *offset - offset_start, *len);
1378
1379
0
    proto_item_set_end(ti, tvb, *offset);
1380
0
}
1381
1382
static void
1383
dissect_gbcs_gbt_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned *offset, unsigned len, uint64_t business_originator,
1384
        uint64_t originator_counter, uint16_t block_number, bool last)
1385
0
{
1386
0
    uint32_t msg_id;
1387
0
    fragment_head *frag_msg = NULL;
1388
0
    tvbuff_t *new_tvb;
1389
1390
0
    pinfo->fragmented = true;
1391
1392
0
    msg_id = ((uint32_t)business_originator << 8) | ((uint32_t)originator_counter & 0xFF);
1393
1394
0
    frag_msg = fragment_add_seq_check(&gbcs_message_gbt_reassembly_table,
1395
0
            tvb, *offset, pinfo, msg_id, NULL, block_number - 1, len, !last);
1396
1397
0
    new_tvb = process_reassembled_data(tvb, *offset, pinfo,
1398
0
            "Reassembled GBT", frag_msg, &gbcs_message_gbt_frag_items, NULL, tree);
1399
1400
0
    if (new_tvb) {
1401
        /* The reassembly handler defragmented the message, and created a new tvbuff */
1402
0
        call_dissector_with_data(gbcs_gbcs_handle, new_tvb, pinfo, proto_tree_get_parent_tree(tree), NULL);
1403
0
    }
1404
0
    else {
1405
        /* The reassembly handler could not defragment the message yet */
1406
0
        col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "GBT block %d", block_number);
1407
0
        call_data_dissector(tvb_new_subset_length(tvb, *offset, len), pinfo, proto_tree_get_parent_tree(tree));
1408
0
    }
1409
1410
0
    *offset += len;
1411
0
}
1412
1413
static void
1414
dissect_gbcs_message_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, unsigned *offset, unsigned len, uint8_t cra)
1415
0
{
1416
0
    tvbuff_t *payload_tvb = tvb_new_subset_length(tvb, *offset, len);
1417
1418
0
    if (gbcs_gbz_handle != NULL && tvb_get_ntohs(payload_tvb, 0) == ZBEE_PROFILE_SE) {
1419
        // Dissect GBZ payload
1420
0
        call_dissector_with_data(gbcs_gbz_handle, payload_tvb, pinfo, tree, &cra);
1421
0
    }
1422
0
    else if (tvb_get_uint8(payload_tvb, 0) == GBCS_MESSAGE_ACCESS_REQUEST
1423
0
            || tvb_get_uint8(payload_tvb, 0) == GBCS_MESSAGE_ACCESS_RESPONSE
1424
0
            || tvb_get_uint8(payload_tvb, 0) == GBCS_MESSAGE_DATA_NOTIFICATION) {
1425
        //TODO Dissect DLMS payload
1426
0
        proto_tree *dlms_tree;
1427
1428
0
        dlms_tree = proto_tree_add_subtree(tree, payload_tvb, 0, len, ett_gbcs_message_dlms, NULL, "GBCS DLMS");
1429
0
        call_data_dissector(payload_tvb, pinfo, dlms_tree);
1430
0
    }
1431
0
    else {
1432
        // If it isn't GBZ or DLMS, then it is ASN.1
1433
0
        const char *text;
1434
0
        wmem_strbuf_t *strbuf;
1435
0
        proto_tree *asn1_tree;
1436
1437
0
        text = col_get_text(pinfo->cinfo, COL_INFO);
1438
0
        if (text) {
1439
0
            strbuf = wmem_strbuf_new(pinfo->pool, text);
1440
0
        }
1441
0
        asn1_tree = proto_tree_add_subtree(tree, payload_tvb, 0, len, ett_gbcs_message_asn1, NULL, "GBCS ASN.1");
1442
0
        call_dissector(gbcs_ber_handle, payload_tvb, pinfo, asn1_tree);
1443
0
        if (text) {
1444
0
            col_add_str(pinfo->cinfo, COL_INFO, wmem_strbuf_get_str(strbuf));
1445
0
        }
1446
0
    }
1447
1448
0
    *offset += len;
1449
0
}
1450
1451
static void
1452
dissect_gbcs_message_krp(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, unsigned *offset)
1453
0
{
1454
0
    dissect_gbcs_message_element(tree, pinfo, hf_gbcs_message_krp, tvb, offset);
1455
0
}
1456
1457
static void
1458
dissect_gbcs_message_mac(tvbuff_t *tvb, proto_tree *tree, unsigned *offset)
1459
0
{
1460
0
    proto_tree_add_item(tree, hf_gbcs_message_mac, tvb, *offset, GBCS_MESSAGE_MAC_LENGTH, ENC_NA);
1461
0
    *offset += GBCS_MESSAGE_MAC_LENGTH;
1462
0
}
1463
1464
static int
1465
dissect_gbcs_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1466
0
{
1467
0
    proto_item *ti;
1468
0
    proto_tree *gbcs_message_tree;
1469
0
    unsigned offset = 0;
1470
0
    uint8_t message, submessage;
1471
1472
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "GBCS Message");
1473
1474
0
    ti = proto_tree_add_item(tree, proto_gbcs_message, tvb, offset, -1, ENC_NA);
1475
0
    gbcs_message_tree = proto_item_add_subtree(ti, ett_gbcs_message);
1476
1477
0
    message = tvb_get_uint8(tvb, offset);
1478
0
    submessage = tvb_get_uint8(tvb, offset + 1);
1479
0
    if ((message == GBCS_MESSAGE_GENERAL_CIPHERING && submessage == 0)
1480
0
            || message == GBCS_MESSAGE_GENERAL_SIGNING) {
1481
        // Normal GBCS message
1482
0
        bool mac = tvb_get_uint8(tvb, offset) == GBCS_MESSAGE_GENERAL_CIPHERING;
1483
0
        unsigned grouping_len;
1484
0
        uint8_t grouping_cra;
1485
1486
0
        if (mac) {
1487
0
            dissect_gbcs_message_mac_header(tvb, pinfo, gbcs_message_tree, &offset);
1488
0
        }
1489
1490
0
        dissect_gbcs_message_grouping_header(tvb, pinfo, gbcs_message_tree, &offset, &grouping_len, &grouping_cra);
1491
1492
0
        dissect_gbcs_message_payload(tvb, pinfo, tree, &offset, grouping_len, grouping_cra);
1493
1494
0
        dissect_gbcs_message_krp(tvb, pinfo, gbcs_message_tree, &offset);
1495
1496
0
        if (mac) {
1497
0
            dissect_gbcs_message_mac(tvb, gbcs_message_tree, &offset);
1498
0
        }
1499
0
    }
1500
0
    else if (message == GBCS_MESSAGE_GENERAL_CIPHERING && submessage == 0x09) {
1501
        // GBCS General Block Transfer
1502
0
        unsigned gbt_len;
1503
0
        uint64_t business_originator;
1504
0
        uint64_t originator_counter;
1505
0
        uint16_t block_number;
1506
0
        bool last;
1507
1508
0
        dissect_gbcs_message_routing_header(tvb, pinfo, gbcs_message_tree, &offset, &business_originator, &originator_counter);
1509
1510
0
        dissect_gbcs_message_gbt_header(tvb, gbcs_message_tree, &offset, &gbt_len, &block_number, &last);
1511
1512
0
        if (gbt_len > 0) { // GBT Ack contains no data
1513
0
            dissect_gbcs_gbt_payload(tvb, pinfo, gbcs_message_tree, &offset, gbt_len, business_originator, originator_counter, block_number, last);
1514
0
        }
1515
0
    }
1516
1517
0
    proto_item_set_end(ti, tvb, offset);
1518
1519
0
    return tvb_captured_length(tvb);
1520
0
}
1521
1522
void proto_register_gbcs_message(void)
1523
15
{
1524
15
    static hf_register_info hf[] = {
1525
15
        {&hf_gbcs_message_element_length,
1526
15
            {"Length", "gbcs_message.element_length",
1527
15
             FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
1528
15
        },
1529
15
        {&hf_gbcs_message_mac_header_general_ciphering,
1530
15
            {"General Ciphering", "gbcs_message.mac_header.general_ciphering",
1531
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1532
15
        },
1533
15
        {&hf_gbcs_message_mac_header_cra_flag,
1534
15
            {"CRA Flag", "gbcs_message.mac_header.cra_flag",
1535
15
             FT_UINT8, BASE_HEX, VALS(gbcs_message_cra_names), 0x0, NULL, HFILL}
1536
15
        },
1537
15
        {&hf_gbcs_message_mac_header_originator_counter,
1538
15
            {"Originator Counter", "gbcs_message.mac_header.originator_counter",
1539
15
             FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
1540
15
        },
1541
15
        {&hf_gbcs_message_mac_header_business_originator_id,
1542
15
            {"Business Originator ID", "gbcs_message.mac_header.business_originator_id",
1543
15
             FT_EUI64, BASE_NONE, NULL, 0x0, NULL, HFILL}
1544
15
        },
1545
15
        {&hf_gbcs_message_mac_header_business_target_id,
1546
15
            {"Business Target ID", "gbcs_message.mac_header.business_target_id",
1547
15
             FT_EUI64, BASE_NONE, NULL, 0x0, NULL, HFILL}
1548
15
        },
1549
15
        {&hf_gbcs_message_mac_header_date_time,
1550
15
            {"Date Time", "gbcs_message.mac_header.date_time",
1551
15
             FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL}
1552
15
        },
1553
15
        {&hf_gbcs_message_mac_header_other_info,
1554
15
            {"Other-Information", "gbcs_message.mac_header.other_info",
1555
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1556
15
        },
1557
15
        {&hf_gbcs_message_mac_header_key_info,
1558
15
            {"Key-Info", "gbcs_message.mac_header.key_info",
1559
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1560
15
        },
1561
15
        {&hf_gbcs_message_mac_header_security_control_byte,
1562
15
            {"Security Control Byte", "gbcs_message.mac_header.security_control_byte",
1563
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1564
15
        },
1565
15
        {&hf_gbcs_message_mac_header_invocation_counter,
1566
15
            {"Invocation Counter", "gbcs_message.mac_header.invocation_counter",
1567
15
             FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
1568
15
        },
1569
15
        {&hf_gbcs_message_grouping_header_general_signing,
1570
15
            {"General Signing", "gbcs_message.grouping_header.general_signing",
1571
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1572
15
        },
1573
15
        {&hf_gbcs_message_grouping_header_cra_flag,
1574
15
            {"CRA Flag", "gbcs_message.grouping_header.cra_flag",
1575
15
             FT_UINT8, BASE_HEX, VALS(gbcs_message_cra_names), 0x0, NULL, HFILL}
1576
15
        },
1577
15
        {&hf_gbcs_message_grouping_header_originator_counter,
1578
15
            {"Originator Counter", "gbcs_message.grouping_header.originator_counter",
1579
15
             FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
1580
15
        },
1581
15
        {&hf_gbcs_message_grouping_header_business_originator_id,
1582
15
            {"Business Originator ID", "gbcs_message.grouping_header.business_originator_id",
1583
15
             FT_EUI64, BASE_NONE, NULL, 0x0, NULL, HFILL}
1584
15
        },
1585
15
        {&hf_gbcs_message_grouping_header_business_target_id,
1586
15
            {"Business Target ID", "gbcs_message.grouping_header.business_target_id",
1587
15
             FT_EUI64, BASE_NONE, NULL, 0x0, NULL, HFILL}
1588
15
        },
1589
15
        {&hf_gbcs_message_grouping_header_date_time,
1590
15
            {"Date Time", "gbcs_message.grouping_header.date_time",
1591
15
             FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL}
1592
15
        },
1593
15
        {&hf_gbcs_message_grouping_header_message_code,
1594
15
            {"Message Code", "gbcs_message.grouping_header.message_code",
1595
15
             FT_UINT16, BASE_HEX | BASE_EXT_STRING, &gbcs_message_code_names_ext, 0x0, NULL, HFILL}
1596
15
        },
1597
15
        {&hf_gbcs_message_grouping_header_supplementary_remote_party_id,
1598
15
            {"Supplementary Remote Party ID", "gbcs_message.grouping_header.supplementary_remote_party_id",
1599
15
             FT_EUI64, BASE_NONE, NULL, 0x0, NULL, HFILL}
1600
15
        },
1601
15
        {&hf_gbcs_message_grouping_header_supplementary_remote_party_counter,
1602
15
            {"Supplementary Remote Party Counter", "gbcs_message.grouping_header.supplementary_remote_party_counter",
1603
15
             FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
1604
15
        },
1605
15
        {&hf_gbcs_message_grouping_header_supplementary_originator_counter,
1606
15
            {"Supplementary Originator Counter", "gbcs_message.grouping_header.supplementary_remote_party_originator_counter",
1607
15
             FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
1608
15
        },
1609
15
        {&hf_gbcs_message_grouping_header_supplementary_remote_party_ka_certificate,
1610
15
            {"Certificate", "gbcs_message.grouping_header.supplementary_remote_party_ka_certificate",
1611
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1612
15
        },
1613
15
        {&hf_gbcs_message_krp,
1614
15
            {"KRP", "gbcs_message.krp",
1615
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1616
15
        },
1617
15
        {&hf_gbcs_message_mac,
1618
15
            {"MAC", "gbcs_message.mac",
1619
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1620
15
        },
1621
15
        {&hf_gbcs_message_routing_header_general_ciphering,
1622
15
            {"General Ciphering", "gbcs_message.routing_header.general_ciphering",
1623
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1624
15
        },
1625
15
        {&hf_gbcs_message_routing_header_cra_flag,
1626
15
            {"CRA Flag", "gbcs_message.routing_header.cra_flag",
1627
15
             FT_UINT8, BASE_HEX, VALS(gbcs_message_cra_names), 0x0, NULL, HFILL}
1628
15
        },
1629
15
        {&hf_gbcs_message_routing_header_originator_counter,
1630
15
            {"Originator Counter", "gbcs_message.routing_header.originator_counter",
1631
15
             FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
1632
15
        },
1633
15
        {&hf_gbcs_message_routing_header_business_originator_id,
1634
15
            {"Business Originator ID", "gbcs_message.routing_header.business_originator_id",
1635
15
             FT_EUI64, BASE_NONE, NULL, 0x0, NULL, HFILL}
1636
15
        },
1637
15
        {&hf_gbcs_message_routing_header_business_target_id,
1638
15
            {"Business Target ID", "gbcs_message.routing_header.business_target_id",
1639
15
             FT_EUI64, BASE_NONE, NULL, 0x0, NULL, HFILL}
1640
15
        },
1641
15
        {&hf_gbcs_message_routing_header_date_time,
1642
15
            {"Date Time", "gbcs_message.routing_header.date_time",
1643
15
             FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL}
1644
15
        },
1645
15
        {&hf_gbcs_message_routing_header_key_info,
1646
15
            {"Key-Info", "gbcs_message.routing_header.key_info",
1647
15
             FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
1648
15
        },
1649
15
        {&hf_gbcs_message_routing_header_message_code,
1650
15
            {"Message Code", "gbcs_message.routing_header.message_code",
1651
15
             FT_UINT16, BASE_HEX | BASE_EXT_STRING, &gbcs_message_code_names_ext, 0x0, NULL, HFILL}
1652
15
        },
1653
15
        {&hf_gbcs_message_routing_header_security_control_byte,
1654
15
            {"Security Control Byte", "gbcs_message.routing_header.security_control_byte",
1655
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1656
15
        },
1657
15
        {&hf_gbcs_message_routing_header_invocation_counter,
1658
15
            {"Invocation Counter", "gbcs_message.routing_header.invocation_counter",
1659
15
             FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
1660
15
        },
1661
15
        {&hf_gbcs_message_gbt_header_general_block_transfer,
1662
15
            {"General Block Transfer", "gbcs_message.gbt_header.general_block_transfer",
1663
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1664
15
        },
1665
15
        {&hf_gbcs_message_gbt_header_block_control,
1666
15
            {"Block Control", "gbcs_message.gbt_header.block_control",
1667
15
             FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
1668
15
        },
1669
15
        {&hf_gbcs_message_gbt_header_block_control_last_block,
1670
15
            {"Last Block", "gbcs_message.gbt_header.block_control.last_block",
1671
15
             FT_BOOLEAN, 8, NULL, GBCS_MESSAGE_GBT_BLOCK_CONTROL_LAST_BLOCK, NULL, HFILL }
1672
15
        },
1673
15
        {&hf_gbcs_message_gbt_header_block_control_streaming,
1674
15
            {"Streaming", "gbcs_message.gbt_header.block_control.streaming",
1675
15
             FT_BOOLEAN, 8, NULL, GBCS_MESSAGE_GBT_BLOCK_CONTROL_STREAMING, NULL, HFILL }
1676
15
        },
1677
15
        {&hf_gbcs_message_gbt_header_block_control_window,
1678
15
            {"Window", "gbcs_message.gbt_header.block_control.window",
1679
15
             FT_UINT8, BASE_DEC, NULL, GBCS_MESSAGE_GBT_BLOCK_CONTROL_WINDOW, NULL, HFILL}
1680
15
        },
1681
15
        {&hf_gbcs_message_gbt_header_block_number,
1682
15
            {"Block Number", "gbcs_message.gbt_header.block_number",
1683
15
             FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1684
15
        },
1685
15
        {&hf_gbcs_message_gbt_header_block_number_ack,
1686
15
            {"Block Number Ack", "gbcs_message.gbt_header.block_number_ack",
1687
15
             FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
1688
15
        },
1689
15
        { &hf_gbcs_message_gbt_blocks,
1690
15
            { "Message blocks", "gbcs_message.gbt.blocks",
1691
15
             FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}
1692
15
        },
1693
15
        { &hf_gbcs_message_gbt_block,
1694
15
            { "Message block", "gbcs_message.gbt.block",
1695
15
             FT_FRAMENUM, BASE_NONE, NULL, 0x0,NULL, HFILL}
1696
15
        },
1697
15
        { &hf_gbcs_message_gbt_block_overlap,
1698
15
            { "Message block overlap", "gbcs_message.gbt.block.overlap",
1699
15
             FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}
1700
15
        },
1701
15
        { &hf_gbcs_message_gbt_block_overlap_conflicts,
1702
15
            { "Message block overlapping with conflicting data", "gbcs_message.gbt.block.overlap.conflicts",
1703
15
             FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}
1704
15
        },
1705
15
        { &hf_gbcs_message_gbt_block_multiple_tails,
1706
15
            { "Message has multiple tail blocks", "gbcs_message.gbt.block.multiple_tails",
1707
15
             FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}
1708
15
        },
1709
15
        { &hf_gbcs_message_gbt_block_too_long_fragment,
1710
15
            { "Message block too long", "gbcs_message.gbt.block.too_long_fragment",
1711
15
             FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL}
1712
15
        },
1713
15
        { &hf_gbcs_message_gbt_block_error,
1714
15
            { "Message defragmentation error", "gbcs_message.gbt.block.error",
1715
15
             FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL}
1716
15
        },
1717
15
        { &hf_gbcs_message_gbt_block_count,
1718
15
            { "Message block count", "gbcs_message.gbt.block.count",
1719
15
             FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1720
15
        },
1721
15
        { &hf_gbcs_message_gbt_reassembled_in,
1722
15
            { "Reassembled in", "gbcs_message.gbt.reassembled.in",
1723
15
             FT_FRAMENUM, BASE_NONE, NULL, 0x0, NULL, HFILL}
1724
15
        },
1725
15
        { &hf_gbcs_message_gbt_reassembled_length,
1726
15
            { "Reassembled GBT length", "gbcs_message.gbt.reassembled.length",
1727
15
             FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
1728
15
        }
1729
15
    };
1730
1731
15
    static int *ett[] = {
1732
15
        &ett_gbcs_message,
1733
15
        &ett_gbcs_message_element,
1734
15
        &ett_gbcs_message_mac_header,
1735
15
        &ett_gbcs_message_grouping_header,
1736
15
        &ett_gbcs_message_grouping_header_other_info,
1737
15
        &ett_gbcs_message_routing_header,
1738
15
        &ett_gbcs_message_routing_header_other_info,
1739
15
        &ett_gbcs_message_gbt_header,
1740
15
        &ett_gbcs_message_gbt_header_block_control,
1741
15
        &ett_gbcs_message_gbt_fragment,
1742
15
        &ett_gbcs_message_gbt_fragments,
1743
15
        &ett_gbcs_message_asn1,
1744
15
        &ett_gbcs_message_dlms
1745
15
    };
1746
1747
15
    proto_gbcs_message = proto_register_protocol("GBCS Message", "GBCS Message", "gbcs_message");
1748
15
    gbcs_gbcs_handle = register_dissector("gbcs_message", dissect_gbcs_message, proto_gbcs_message);
1749
15
    proto_register_field_array(proto_gbcs_message, hf, array_length(hf));
1750
15
    proto_register_subtree_array(ett, array_length(ett));
1751
1752
15
    reassembly_table_register(&gbcs_message_gbt_reassembly_table, &addresses_reassembly_table_functions);
1753
15
}
1754
1755
void proto_reg_handoff_gbcs_message(void)
1756
15
{
1757
15
    gbcs_gbz_handle = find_dissector("gbcs_gbz");
1758
15
    gbcs_ber_handle = find_dissector("ber");
1759
15
}
1760
1761
/*
1762
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
1763
 *
1764
 * Local variables:
1765
 * c-basic-offset: 4
1766
 * tab-width: 8
1767
 * indent-tabs-mode: nil
1768
 * End:
1769
 *
1770
 * vi: set shiftwidth=4 tabstop=8 expandtab:
1771
 * :indentSize=4:tabSize=8:noTabs=true:
1772
 */