2 * Routines for DNP dissection
3 * Copyright 2003, 2006, 2007, Graham Bloice <graham.bloice@trihedral.com>
5 * DNP3.0 Application Layer Object dissection added by Chris Bontje (chrisbontje@shaw.ca)
8 * Major updates: tcp and application layer defragmentation, more object dissections by Graham Bloice
12 * Wireshark - Network traffic analyzer
13 * By Gerald Combs <gerald@wireshark.org>
14 * Copyright 1998 Gerald Combs
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version 2
19 * of the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42 #include <epan/packet.h>
43 #include <epan/prefs.h>
44 #include <epan/reassemble.h>
45 #include <epan/emem.h>
46 #include <epan/dissectors/packet-tcp.h>
47 #include <epan/conversation.h>
48 #include <epan/expert.h>
55 * although note that you have to join the DNP organization to get to
56 * see the protocol specs online - otherwise, you have to buy a
59 * ...Application Layer Notes...
61 * Application Layer Decoding based on information available in
62 * DNP3 Basic 4 Documentation Set, specifically the document:
63 * "DNP V3.00 Application Layer" v0.03 P009-0PD.APP & Technical Bulletins
66 /***************************************************************************/
67 /* DNP 3.0 Constants */
68 /***************************************************************************/
69 #define DNP_HDR_LEN 10
70 #define TCP_PORT_DNP 20000
71 #define UDP_PORT_DNP 20000
73 /***************************************************************************/
74 /* Datalink and Transport Layer Bit-Masks */
75 /***************************************************************************/
76 #define DNP3_CTL_DIR 0x80
77 #define DNP3_CTL_PRM 0x40
78 #define DNP3_CTL_FCB 0x20
79 #define DNP3_CTL_FCV 0x10
80 #define DNP3_CTL_RES 0x20
81 #define DNP3_CTL_DFC 0x10
82 #define DNP3_CTL_FUNC 0x0f
84 #define DNP3_TR_FIR 0x40
85 #define DNP3_TR_FIN 0x80
86 #define DNP3_TR_SEQ 0x3f
88 #define AL_MAX_CHUNK_SIZE 16
90 /***************************************************************************/
91 /* Data Link Function codes */
92 /***************************************************************************/
93 /* Primary to Secondary */
94 #define DL_FUNC_RESET_LINK 0x00
95 #define DL_FUNC_RESET_PROC 0x01
96 #define DL_FUNC_TEST_LINK 0x02
97 #define DL_FUNC_USER_DATA 0x03
98 #define DL_FUNC_UNC_DATA 0x04
99 #define DL_FUNC_LINK_STAT 0x09
101 /* Secondary to Primary */
102 #define DL_FUNC_ACK 0x00
103 #define DL_FUNC_NACK 0x01
104 #define DL_FUNC_STAT_LINK 0x0B
105 #define DL_FUNC_NO_FUNC 0x0E
106 #define DL_FUNC_NOT_IMPL 0x0F
108 /***************************************************************************/
109 /* Application Layer Bit-Masks */
110 /***************************************************************************/
111 #define DNP3_AL_CON 0x20
112 #define DNP3_AL_FIN 0x40
113 #define DNP3_AL_FIR 0x80
114 #define DNP3_AL_SEQ 0x1f
115 #define DNP3_AL_FUNC 0xff
117 /***************************************************************************/
118 /* Application Layer Function codes */
119 /***************************************************************************/
120 #define AL_FUNC_CONFIRM 0x00 /* 00 - Confirm */
121 #define AL_FUNC_READ 0x01 /* 01 - Read */
122 #define AL_FUNC_WRITE 0x02 /* 02 - Write */
123 #define AL_FUNC_SELECT 0x03 /* 03 - Select */
124 #define AL_FUNC_OPERATE 0x04 /* 04 - Operate */
125 #define AL_FUNC_DIROP 0x05 /* 05 - Direct Operate */
126 #define AL_FUNC_DIROPNACK 0x06 /* 06 - Direct Operate No ACK */
127 #define AL_FUNC_FRZ 0x07 /* 07 - Immediate Freeze */
128 #define AL_FUNC_FRZNACK 0x08 /* 08 - Immediate Freeze No ACK */
129 #define AL_FUNC_FRZCLR 0x09 /* 09 - Freeze and Clear */
130 #define AL_FUNC_FRZCLRNACK 0x0A /* 10 - Freeze and Clear No ACK */
131 #define AL_FUNC_FRZT 0x0B /* 11 - Freeze With Time */
132 #define AL_FUNC_FRZTNACK 0x0C /* 12 - Freeze With Time No ACK */
133 #define AL_FUNC_COLDRST 0x0D /* 13 - Cold Restart */
134 #define AL_FUNC_WARMRST 0x0E /* 14 - Warm Restart */
135 #define AL_FUNC_INITDATA 0x0F /* 15 - Initialize Data */
136 #define AL_FUNC_INITAPP 0x10 /* 16 - Initialize Application */
137 #define AL_FUNC_STARTAPP 0x11 /* 17 - Start Application */
138 #define AL_FUNC_STOPAPP 0x12 /* 18 - Stop Application */
139 #define AL_FUNC_SAVECFG 0x13 /* 19 - Save Configuration */
140 #define AL_FUNC_ENSPMSG 0x14 /* 20 - Enable Spontaneous Msg */
141 #define AL_FUNC_DISSPMSG 0x15 /* 21 - Disable Spontaneous Msg */
142 #define AL_FUNC_ASSIGNCL 0x16 /* 22 - Assign Classes */
143 #define AL_FUNC_DELAYMST 0x17 /* 23 - Delay Measurement */
144 #define AL_FUNC_RESPON 0x81 /* 129 - Response */
145 #define AL_FUNC_UNSOLI 0x82 /* 130 - Unsolicited Response */
147 /***************************************************************************/
148 /* Application Layer Internal Indication (IIN) bits */
149 /* 2 Bytes, message formatting: [First Octet] | [Second Octet] */
150 /***************************************************************************/
152 #define AL_IIN_BMSG 0x0100 /* Bit 0 - Broadcast message rx'd */
153 #define AL_IIN_CLS1D 0x0200 /* Bit 1 - Class 1 Data Available */
154 #define AL_IIN_CLS2D 0x0400 /* Bit 2 - Class 2 Data Available */
155 #define AL_IIN_CLS3D 0x0800 /* Bit 3 - Class 3 Data Available */
156 #define AL_IIN_TSR 0x1000 /* Bit 4 - Time Sync Req'd from Master */
157 #define AL_IIN_DOL 0x2000 /* Bit 5 - Digital Outputs in Local Mode */
158 #define AL_IIN_DT 0x4000 /* Bit 6 - Device Trouble */
159 #define AL_IIN_RST 0x8000 /* Bit 7 - Device Restart */
162 /* 0x0001 Bit 0 - Reserved */
163 #define AL_IIN_OBJU 0x0002 /* Bit 1 - Requested Objects Unknown */
164 #define AL_IIN_PIOOR 0x0004 /* Bit 2 - Parameters Invalid or Out of Range */
165 #define AL_IIN_EBO 0x0008 /* Bit 3 - Event Buffer Overflow */
166 #define AL_IIN_OAE 0x0010 /* Bit 4 - Operation Already Executing */
167 #define AL_IIN_CC 0x0020 /* Bit 5 - Device Configuration Corrupt */
168 /* 0x0040 Bit 6 - Reserved */
169 /* 0x0080 Bit 7 - Reserved */
171 /***************************************************************************/
172 /* Application Layer Data Object Qualifier */
173 /***************************************************************************/
175 #define AL_OBJQ_INDEX 0x70 /* x111xxxx Masks Index from Qualifier */
176 #define AL_OBJQ_CODE 0x0F /* xxxx1111 Masks Code from Qualifier */
178 /* Index Size (3-bits x111xxxx) */
179 /* When Qualifier Code != 11 */
180 #define AL_OBJQL_IDX_NI 0x00 /* Objects are Packed with no index */
181 #define AL_OBJQL_IDX_1O 0x01 /* Objects are prefixed w/ 1-octet index */
182 #define AL_OBJQL_IDX_2O 0x02 /* Objects are prefixed w/ 2-octet index */
183 #define AL_OBJQL_IDX_4O 0x03 /* Objects are prefixed w/ 4-octet index */
184 #define AL_OBJQL_IDX_1OS 0x04 /* Objects are prefixed w/ 1-octet object size */
185 #define AL_OBJQL_IDX_2OS 0x05 /* Objects are prefixed w/ 2-octet object size */
186 #define AL_OBJQL_IDX_4OS 0x06 /* Objects are prefixed w/ 4-octet object size */
188 /* When Qualifier Code == 11 */
189 #define AL_OBJQL_IDX11_1OIS 0x01 /* 1 octet identifier size */
190 #define AL_OBJQL_IDX11_2OIS 0x02 /* 2 octet identifier size */
191 #define AL_OBJQL_IDX11_4OIS 0x03 /* 4 octet identifier size */
193 /* Qualifier Code (4-bits) */
194 /* 4-bits ( xxxx1111 ) */
195 #define AL_OBJQL_CODE_SSI8 0x00 /* 00 8-bit Start and Stop Indices in Range Field */
196 #define AL_OBJQL_CODE_SSI16 0x01 /* 01 16-bit Start and Stop Indices in Range Field */
197 #define AL_OBJQL_CODE_SSI32 0x02 /* 02 32-bit Start and Stop Indices in Range Field */
198 #define AL_OBJQL_CODE_AA8 0x03 /* 03 8-bit Absolute Address in Range Field */
199 #define AL_OBJQL_CODE_AA16 0x04 /* 04 16-bit Absolute Address in Range Field */
200 #define AL_OBJQL_CODE_AA32 0x05 /* 05 32-bit Absolute Address in Range Field */
201 #define AL_OBJQL_CODE_R0 0x06 /* 06 Length of Range field is 0 (no range field) */
202 #define AL_OBJQL_CODE_SF8 0x07 /* 07 8-bit Single Field Quantity */
203 #define AL_OBJQL_CODE_SF16 0x08 /* 08 16-bit Single Field Quantity */
204 #define AL_OBJQL_CODE_SF32 0x09 /* 09 32-bit Single Field Quantity */
205 /* 0x0A 10 Reserved */
206 #define AL_OBJQL_CODE_FF 0x0B /* 11 Free-format Qualifier */
207 /* 0x0C 12 Reserved */
208 /* 0x0D 13 Reserved */
209 /* 0x0E 14 Reserved */
210 /* 0x0F 15 Reserved */
212 /***************************************************************************/
213 /* Application Layer Data Object Definitions */
214 /***************************************************************************/
215 /* Binary Input Objects */
216 #define AL_OBJ_BI_ALL 0x0100 /* 01 00 Binary Input All Variations */
217 #define AL_OBJ_BI_1BIT 0x0101 /* 01 01 Single-bit Binary Input */
218 #define AL_OBJ_BI_STAT 0x0102 /* 01 02 Binary Input With Status */
219 #define AL_OBJ_BIC_ALL 0x0200 /* 02 00 Binary Input Change All Variations */
220 #define AL_OBJ_BIC_NOTIME 0x0201 /* 02 01 Binary Input Change Without Time */
221 #define AL_OBJ_BIC_TIME 0x0202 /* 02 02 Binary Input Change With Time */
222 #define AL_OBJ_BIC_RTIME 0x0203 /* 02 03 Binary Input Change With Relative Time */
224 /* Double-bit Input Objects */
225 #define AL_OBJ_2BI_ALL 0x0300 /* 03 00 Double-bit Input All Variations */
226 #define AL_OBJ_2BI_NF 0x0301 /* 03 01 Double-bit Input No Flags */
227 #define AL_OBJ_2BI_STAT 0x0302 /* 03 02 Double-bit Input With Status */
228 #define AL_OBJ_2BIC_NOTIME 0x0401 /* 04 01 Double-bit Input Change Without Time */
229 #define AL_OBJ_2BIC_TIME 0x0402 /* 04 02 Double-bit Input Change With Time */
230 #define AL_OBJ_2BIC_RTIME 0x0403 /* 04 03 Double-bit Input Change With Relative Time */
232 /* Binary Input Quality Flags */
233 #define AL_OBJ_BI_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
234 #define AL_OBJ_BI_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
235 #define AL_OBJ_BI_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
236 #define AL_OBJ_BI_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
237 #define AL_OBJ_BI_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
238 #define AL_OBJ_BI_FLAG5 0x0020 /* Chatter Filter (0=Normal; 1=Filter On) */
239 #define AL_OBJ_BI_FLAG6 0x0040 /* Double-bit LSB (0=Off; 1=On) */
240 #define AL_OBJ_BI_FLAG7 0x0080 /* Point State (0=Off; 1=On) or Double-bit MSB */
242 /***************************************************************************/
243 /* Binary Output Objects */
244 #define AL_OBJ_BO 0x0A01 /* 10 01 Binary Output */
245 #define AL_OBJ_BO_STAT 0x0A02 /* 10 02 Binary Output Status */
246 #define AL_OBJ_CTLOP_BLK 0x0C01 /* 12 01 Control Relay Output Block */
247 /* 0x0C02 12 02 Pattern Control Block */
248 /* 0x0C03 12 03 Pattern Mask */
250 #define AL_OBJCTLC_CODE 0x0F /* Bit-Mask xxxx1111 for Control Code 'Code' */
251 #define AL_OBJCTLC_MISC 0x30 /* Bit-Mask xx11xxxx for Control Code Misc Values */
252 #define AL_OBJCTLC_TC 0xC0 /* Bit-Mask 11xxxxxx for Control Code 'Trip/Close' */
254 #define AL_OBJCTLC_CODE0 0x00 /* xxxx0000 NUL Operation; only process R attribute */
255 #define AL_OBJCTLC_CODE1 0x01 /* xxxx0001 Pulse On ^On-Time -> vOff-Time, remain off */
256 #define AL_OBJCTLC_CODE2 0x02 /* xxxx0010 Pulse Off vOff-Time -> ^On-Time, remain on */
257 #define AL_OBJCTLC_CODE3 0x03 /* xxxx0011 Latch On */
258 #define AL_OBJCTLC_CODE4 0x04 /* xxxx0100 Latch Off */
259 /* 0x05-0x15 Reserved */
261 #define AL_OBJCTLC_QUEUE 0x10 /* xxx1xxxx for Control Code 'Queue' */
262 #define AL_OBJCTLC_CLEAR 0x20 /* xx1xxxxx for Control Code 'Clear' */
264 #define AL_OBJCTLC_TC0 0x00 /* 00xxxxxx NUL */
265 #define AL_OBJCTLC_TC1 0x40 /* 01xxxxxx Close */
266 #define AL_OBJCTLC_TC2 0x80 /* 10xxxxxx Trip */
268 #define AL_OBJCTL_STAT0 0x00 /* Request Accepted, Initiated or Queued */
269 #define AL_OBJCTL_STAT1 0x01 /* Request Not Accepted; Arm-timer expired */
270 #define AL_OBJCTL_STAT2 0x02 /* Request Not Accepted; No 'SELECT' rx'd */
271 #define AL_OBJCTL_STAT3 0x03 /* Request Not Accepted; Format errors in ctrl request */
272 #define AL_OBJCTL_STAT4 0x04 /* Control Operation Not Supported for this point */
273 #define AL_OBJCTL_STAT5 0x05 /* Request Not Accepted; Ctrl Queue full or pt. active */
274 #define AL_OBJCTL_STAT6 0x06 /* Request Not Accepted; Ctrl HW Problems */
275 #define AL_OBJCTL_STAT7 0x07 /* Request Not Accepted; Local/Remote switch in Local*/
276 #define AL_OBJCTL_STAT8 0x08 /* Request Not Accepted; Too many operations requested */
277 #define AL_OBJCTL_STAT9 0x09 /* Request Not Accepted; Insufficient authorization */
278 #define AL_OBJCTL_STAT10 0x0A /* Request Not Accepted; Local automation proc active */
280 /* Binary Output Quality Flags */
281 #define AL_OBJ_BO_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
282 #define AL_OBJ_BO_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
283 #define AL_OBJ_BO_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
284 #define AL_OBJ_BO_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
285 #define AL_OBJ_BO_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
286 #define AL_OBJ_BO_FLAG5 0x0020 /* Reserved */
287 #define AL_OBJ_BO_FLAG6 0x0040 /* Reserved */
288 #define AL_OBJ_BO_FLAG7 0x0080 /* Point State (0=Off; 1=On) */
290 /***************************************************************************/
291 /* Counter Objects */
292 #define AL_OBJ_CTR_ALL 0x1400 /* 20 00 Binary Counter All Variations */
293 #define AL_OBJ_CTR_32 0x1401 /* 20 01 32-Bit Binary Counter */
294 #define AL_OBJ_CTR_16 0x1402 /* 20 02 16-Bit Binary Counter */
295 #define AL_OBJ_DCTR_32 0x1403 /* 20 03 32-Bit Delta Counter */
296 #define AL_OBJ_DCTR_16 0x1404 /* 20 04 16-Bit Delta Counter */
297 #define AL_OBJ_CTR_32NF 0x1405 /* 20 05 32-Bit Binary Counter Without Flag */
298 #define AL_OBJ_CTR_16NF 0x1406 /* 20 06 16-Bit Binary Counter Without Flag */
299 #define AL_OBJ_DCTR_32NF 0x1407 /* 20 07 32-Bit Delta Counter Without Flag */
300 #define AL_OBJ_DCTR_16NF 0x1408 /* 20 08 16-Bit Delta Counter Without Flag */
301 #define AL_OBJ_FCTR_ALL 0x1500 /* 21 00 Frozen Binary Counter All Variations */
302 #define AL_OBJ_FCTR_32 0x1501 /* 21 01 32-Bit Frozen Counter */
303 #define AL_OBJ_FCTR_16 0x1502 /* 21 02 16-Bit Frozen Counter */
304 #define AL_OBJ_FDCTR_32 0x1503 /* 21 03 32-Bit Frozen Delta Counter */
305 #define AL_OBJ_FDCTR_16 0x1504 /* 21 04 16-Bit Frozen Delta Counter */
306 #define AL_OBJ_FCTR_32T 0x1505 /* 21 05 32-Bit Frozen Counter w/ Time of Freeze */
307 #define AL_OBJ_FCTR_16T 0x1506 /* 21 06 16-Bit Frozen Counter w/ Time of Freeze */
308 #define AL_OBJ_FDCTR_32T 0x1507 /* 21 07 32-Bit Frozen Delta Counter w/ Time of Freeze */
309 #define AL_OBJ_FDCTR_16T 0x1508 /* 21 08 16-Bit Frozen Delta Counter w/ Time of Freeze */
310 #define AL_OBJ_FCTR_32NF 0x1509 /* 21 09 32-Bit Frozen Counter Without Flag */
311 #define AL_OBJ_FCTR_16NF 0x1510 /* 21 10 16-Bit Frozen Counter Without Flag */
312 #define AL_OBJ_FDCTR_32NF 0x1511 /* 21 11 32-Bit Frozen Delta Counter Without Flag */
313 #define AL_OBJ_FDCTR_16NF 0x1512 /* 21 12 16-Bit Frozen Delta Counter Without Flag */
314 #define AL_OBJ_CTRC_ALL 0x1600 /* 22 00 Counter Change Event All Variations */
315 #define AL_OBJ_CTRC_32 0x1601 /* 22 01 32-Bit Counter Change Event w/o Time */
316 #define AL_OBJ_CTRC_16 0x1602 /* 22 02 16-Bit Counter Change Event w/o Time */
317 #define AL_OBJ_DCTRC_32 0x1603 /* 22 03 32-Bit Delta Counter Change Event w/o Time */
318 #define AL_OBJ_DCTRC_16 0x1604 /* 22 04 16-Bit Delta Counter Change Event w/o Time */
319 #define AL_OBJ_CTRC_32T 0x1605 /* 22 05 32-Bit Counter Change Event with Time */
320 #define AL_OBJ_CTRC_16T 0x1606 /* 22 06 16-Bit Counter Change Event with Time */
321 #define AL_OBJ_DCTRC_32T 0x1607 /* 22 07 32-Bit Delta Counter Change Event with Time */
322 #define AL_OBJ_DCTRC_16T 0x1608 /* 22 08 16-Bit Delta Counter Change Event with Time */
323 #define AL_OBJ_FCTRC_ALL 0x1700 /* 21 00 Frozen Binary Counter Change Event All Variations */
324 #define AL_OBJ_FCTRC_32 0x1701 /* 21 01 32-Bit Frozen Counter Change Event */
325 #define AL_OBJ_FCTRC_16 0x1702 /* 21 02 16-Bit Frozen Counter Change Event */
326 #define AL_OBJ_FDCTRC_32 0x1703 /* 21 03 32-Bit Frozen Delta Counter Change Event */
327 #define AL_OBJ_FDCTRC_16 0x1704 /* 21 04 16-Bit Frozen Delta Counter Change Event */
328 #define AL_OBJ_FCTRC_32T 0x1705 /* 21 05 32-Bit Frozen Counter Change Event w/ Time of Freeze */
329 #define AL_OBJ_FCTRC_16T 0x1706 /* 21 06 16-Bit Frozen Counter Change Event w/ Time of Freeze */
330 #define AL_OBJ_FDCTRC_32T 0x1707 /* 21 07 32-Bit Frozen Delta Counter Change Event w/ Time of Freeze */
331 #define AL_OBJ_FDCTRC_16T 0x1708 /* 21 08 16-Bit Frozen Delta Counter Change Event w/ Time of Freeze */
333 /* Counter Quality Flags */
334 #define AL_OBJ_CTR_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
335 #define AL_OBJ_CTR_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
336 #define AL_OBJ_CTR_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
337 #define AL_OBJ_CTR_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
338 #define AL_OBJ_CTR_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
339 #define AL_OBJ_CTR_FLAG5 0x0020 /* Roll-over (0=Normal; 1=Roll-Over) */
340 #define AL_OBJ_CTR_FLAG6 0x0040 /* Discontinuity (0=Normal; 1=Discontinuity) */
341 #define AL_OBJ_CTR_FLAG7 0x0080 /* Reserved */
343 /***************************************************************************/
344 /* Analog Input Objects */
345 #define AL_OBJ_AI_ALL 0x1E00 /* 30 00 Analog Input All Variations */
346 #define AL_OBJ_AI_32 0x1E01 /* 30 01 32-Bit Analog Input */
347 #define AL_OBJ_AI_16 0x1E02 /* 30 02 16-Bit Analog Input */
348 #define AL_OBJ_AI_32NF 0x1E03 /* 30 03 32-Bit Analog Input Without Flag */
349 #define AL_OBJ_AI_16NF 0x1E04 /* 30 04 16-Bit Analog Input Without Flag */
350 #define AL_OBJ_AI_FLT 0x1E05 /* 30 05 32-Bit Floating Point Input */
351 #define AL_OBJ_AI_DBL 0x1E06 /* 30 06 64-Bit Floating Point Input */
352 /* 0x1F01 31 01 32-Bit Frozen Analog Input */
353 /* 0x1F02 31 02 16-Bit Frozen Analog Input */
354 /* 0x1F03 31 03 32-Bit Frozen Analog Input w/ Time of Freeze */
355 /* 0x1F04 31 04 16-Bit Frozen Analog Input w/ Time of Freeze */
356 /* 0x1F05 31 05 32-Bit Frozen Analog Input Without Flag */
357 /* 0x1F06 31 06 16-Bit Frozen Analog Input Without Flag */
358 #define AL_OBJ_AIF_FLT 0x1F07 /* 31 07 32-Bit Frozen Floating Point Input */
359 #define AL_OBJ_AIF_DBL 0x1F08 /* 31 08 64-Bit Frozen Floating Point Input */
360 #define AL_OBJ_AIC_ALL 0x2000 /* 32 00 Analog Input Change All Variations */
361 #define AL_OBJ_AIC_32NT 0x2001 /* 32 01 32-Bit Analog Change Event w/o Time */
362 #define AL_OBJ_AIC_16NT 0x2002 /* 32 02 16-Bit Analog Change Event w/o Time */
363 #define AL_OBJ_AIC_32T 0x2003 /* 32 03 32-Bit Analog Change Event w/ Time */
364 #define AL_OBJ_AIC_16T 0x2004 /* 32 04 16-Bit Analog Change Event w/ Time */
365 #define AL_OBJ_AIC_FLTNT 0x2005 /* 32 05 32-Bit Floating Point Change Event w/o Time*/
366 #define AL_OBJ_AIC_DBLNT 0x2006 /* 32 06 64-Bit Floating Point Change Event w/o Time*/
367 #define AL_OBJ_AIC_FLTT 0x2007 /* 32 07 32-Bit Floating Point Change Event w/ Time*/
368 #define AL_OBJ_AIC_DBLT 0x2008 /* 32 08 64-Bit Floating Point Change Event w/ Time*/
369 /* 0x2101 33 01 32-Bit Frozen Analog Event w/o Time */
370 /* 0x2102 33 02 16-Bit Frozen Analog Event w/o Time */
371 /* 0x2103 33 03 32-Bit Frozen Analog Event w/ Time */
372 /* 0x2104 33 04 16-Bit Frozen Analog Event w/ Time */
373 #define AL_OBJ_AIFC_FLTNT 0x2105 /* 33 05 32-Bit Floating Point Frozen Change Event w/o Time*/
374 #define AL_OBJ_AIFC_DBLNT 0x2106 /* 33 06 64-Bit Floating Point Frozen Change Event w/o Time*/
375 #define AL_OBJ_AIFC_FLTT 0x2107 /* 33 07 32-Bit Floating Point Frozen Change Event w/ Time*/
376 #define AL_OBJ_AIFC_DBLT 0x2108 /* 33 08 64-Bit Floating Point Frozen Change Event w/ Time*/
379 /* Analog Input Quality Flags */
380 #define AL_OBJ_AI_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
381 #define AL_OBJ_AI_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
382 #define AL_OBJ_AI_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
383 #define AL_OBJ_AI_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
384 #define AL_OBJ_AI_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
385 #define AL_OBJ_AI_FLAG5 0x0020 /* Over-Range (0=Normal; 1=Over-Range) */
386 #define AL_OBJ_AI_FLAG6 0x0040 /* Reference Check (0=Normal; 1=Error) */
387 #define AL_OBJ_AI_FLAG7 0x0080 /* Reserved */
389 /***************************************************************************/
390 /* Analog Output Objects */
391 #define AL_OBJ_AO_32 0x2801 /* 40 01 32-Bit Analog Output Status */
392 #define AL_OBJ_AO_16 0x2802 /* 40 02 16-Bit Analog Output Status */
393 #define AL_OBJ_AO_FLT 0x2803 /* 40 03 32-Bit Floating Point Output Status */
394 #define AL_OBJ_AO_DBL 0x2804 /* 40 04 64-Bit Floating Point Output Status */
395 #define AL_OBJ_AO_32OPB 0x2901 /* 41 01 32-Bit Analog Output Block */
396 #define AL_OBJ_AO_16OPB 0x2902 /* 41 02 16-Bit Analog Output Block */
397 #define AL_OBJ_AO_FLTOPB 0x2903 /* 41 03 32-Bit Floating Point Output Block */
398 #define AL_OBJ_AO_DBLOPB 0x2904 /* 41 04 64-Bit Floating Point Output Block */
400 /* Analog Output Quality Flags */
401 #define AL_OBJ_AO_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
402 #define AL_OBJ_AO_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
403 #define AL_OBJ_AO_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
404 #define AL_OBJ_AO_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
405 #define AL_OBJ_AO_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
406 #define AL_OBJ_AO_FLAG5 0x0020 /* Reserved */
407 #define AL_OBJ_AO_FLAG6 0x0040 /* Reserved */
408 #define AL_OBJ_AO_FLAG7 0x0080 /* Reserved */
410 /***************************************************************************/
412 #define AL_OBJ_TD 0x3201 /* 50 01 Time and Date */
413 #define AL_OBJ_TDI 0x3202 /* 50 02 Time and Date w/ Interval */
414 #define AL_OBJ_TDCTO 0x3301 /* 51 01 Time and Date CTO */
415 #define AL_OBJ_UTDCTO 0x3302 /* 51 02 Unsynchronized Time and Date CTO */
416 #define AL_OBJ_TDELAYC 0x3401 /* 52 01 Time Delay Coarse */
417 #define AL_OBJ_TDELAYF 0x3402 /* 52 02 Time Delay Fine */
419 /***************************************************************************/
420 /* Class Data Objects */
421 #define AL_OBJ_CLASS0 0x3C01 /* 60 01 Class 0 Data */
422 #define AL_OBJ_CLASS1 0x3C02 /* 60 02 Class 1 Data */
423 #define AL_OBJ_CLASS2 0x3C03 /* 60 03 Class 2 Data */
424 #define AL_OBJ_CLASS3 0x3C04 /* 60 04 Class 3 Data */
426 /***************************************************************************/
428 #define AL_OBJ_IIN 0x5001 /* 80 01 Internal Indications */
430 /***************************************************************************/
431 /* Octet String Objects */
432 #define AL_OBJ_OCT 0x6E00 /* 110 xx Octet string */
434 /***************************************************************************/
435 /* End of Application Layer Data Object Definitions */
436 /***************************************************************************/
438 /* Initialize the protocol and registered fields */
439 static int proto_dnp3 = -1;
440 static int hf_dnp3_start = -1;
441 static int hf_dnp3_len = -1;
442 static int hf_dnp3_ctl = -1;
443 static int hf_dnp3_ctl_prifunc = -1;
444 static int hf_dnp3_ctl_secfunc = -1;
445 static int hf_dnp3_ctl_dir = -1;
446 static int hf_dnp3_ctl_prm = -1;
447 static int hf_dnp3_ctl_fcb = -1;
448 static int hf_dnp3_ctl_fcv = -1;
449 static int hf_dnp3_ctl_dfc = -1;
450 static int hf_dnp3_dst = -1;
451 static int hf_dnp3_src = -1;
452 static int hf_dnp_hdr_CRC = -1;
453 static int hf_dnp_hdr_CRC_bad = -1;
454 static int hf_dnp3_tr_ctl = -1;
455 static int hf_dnp3_tr_fin = -1;
456 static int hf_dnp3_tr_fir = -1;
457 static int hf_dnp3_tr_seq = -1;
458 static int hf_dnp3_al_ctl = -1;
459 static int hf_dnp3_al_fir = -1;
460 static int hf_dnp3_al_fin = -1;
461 static int hf_dnp3_al_con = -1;
462 static int hf_dnp3_al_seq = -1;
463 static int hf_dnp3_al_func = -1;
464 /* Added for Application Layer Decoding */
465 static int hf_dnp3_al_iin = -1;
466 static int hf_dnp3_al_iin_bmsg = -1;
467 static int hf_dnp3_al_iin_cls1d = -1;
468 static int hf_dnp3_al_iin_cls2d = -1;
469 static int hf_dnp3_al_iin_cls3d = -1;
470 static int hf_dnp3_al_iin_tsr = -1;
471 static int hf_dnp3_al_iin_dol = -1;
472 static int hf_dnp3_al_iin_dt = -1;
473 static int hf_dnp3_al_iin_rst = -1;
474 static int hf_dnp3_al_iin_obju = -1;
475 static int hf_dnp3_al_iin_pioor = -1;
476 static int hf_dnp3_al_iin_ebo = -1;
477 static int hf_dnp3_al_iin_oae = -1;
478 static int hf_dnp3_al_iin_cc = -1;
479 static int hf_dnp3_al_obj = -1;
480 static int hf_dnp3_al_objq_index = -1;
481 static int hf_dnp3_al_objq_code = -1;
482 static int hf_dnp3_al_range_start8 = -1;
483 static int hf_dnp3_al_range_stop8 = -1;
484 static int hf_dnp3_al_range_start16 = -1;
485 static int hf_dnp3_al_range_stop16 = -1;
486 static int hf_dnp3_al_range_start32 = -1;
487 static int hf_dnp3_al_range_stop32 = -1;
488 static int hf_dnp3_al_range_abs8 = -1;
489 static int hf_dnp3_al_range_abs16 = -1;
490 static int hf_dnp3_al_range_abs32 = -1;
491 static int hf_dnp3_al_range_quant8 = -1;
492 static int hf_dnp3_al_range_quant16 = -1;
493 static int hf_dnp3_al_range_quant32 = -1;
494 static int hf_dnp3_al_index8 = -1;
495 static int hf_dnp3_al_index16 = -1;
496 static int hf_dnp3_al_index32 = -1;
498 /*static int hf_dnp3_al_objq = -1;
499 static int hf_dnp3_al_nobj = -1; */
500 static int hf_dnp3_al_ptnum = -1;
501 static int hf_dnp3_al_biq_b0 = -1;
502 static int hf_dnp3_al_biq_b1 = -1;
503 static int hf_dnp3_al_biq_b2 = -1;
504 static int hf_dnp3_al_biq_b3 = -1;
505 static int hf_dnp3_al_biq_b4 = -1;
506 static int hf_dnp3_al_biq_b5 = -1;
507 static int hf_dnp3_al_biq_b6 = -1;
508 static int hf_dnp3_al_biq_b7 = -1;
509 static int hf_dnp3_al_boq_b0 = -1;
510 static int hf_dnp3_al_boq_b1 = -1;
511 static int hf_dnp3_al_boq_b2 = -1;
512 static int hf_dnp3_al_boq_b3 = -1;
513 static int hf_dnp3_al_boq_b4 = -1;
514 static int hf_dnp3_al_boq_b5 = -1;
515 static int hf_dnp3_al_boq_b6 = -1;
516 static int hf_dnp3_al_boq_b7 = -1;
517 static int hf_dnp3_al_ctrq_b0 = -1;
518 static int hf_dnp3_al_ctrq_b1 = -1;
519 static int hf_dnp3_al_ctrq_b2 = -1;
520 static int hf_dnp3_al_ctrq_b3 = -1;
521 static int hf_dnp3_al_ctrq_b4 = -1;
522 static int hf_dnp3_al_ctrq_b5 = -1;
523 static int hf_dnp3_al_ctrq_b6 = -1;
524 static int hf_dnp3_al_ctrq_b7 = -1;
525 static int hf_dnp3_al_aiq_b0 = -1;
526 static int hf_dnp3_al_aiq_b1 = -1;
527 static int hf_dnp3_al_aiq_b2 = -1;
528 static int hf_dnp3_al_aiq_b3 = -1;
529 static int hf_dnp3_al_aiq_b4 = -1;
530 static int hf_dnp3_al_aiq_b5 = -1;
531 static int hf_dnp3_al_aiq_b6 = -1;
532 static int hf_dnp3_al_aiq_b7 = -1;
533 static int hf_dnp3_al_aoq_b0 = -1;
534 static int hf_dnp3_al_aoq_b1 = -1;
535 static int hf_dnp3_al_aoq_b2 = -1;
536 static int hf_dnp3_al_aoq_b3 = -1;
537 static int hf_dnp3_al_aoq_b4 = -1;
538 static int hf_dnp3_al_aoq_b5 = -1;
539 static int hf_dnp3_al_aoq_b6 = -1;
540 static int hf_dnp3_al_aoq_b7 = -1;
541 static int hf_dnp3_al_timestamp = -1;
542 static int hf_dnp3_al_rel_timestamp = -1;
543 static int hf_dnp3_al_ana16 = -1;
544 static int hf_dnp3_al_ana32 = -1;
545 static int hf_dnp3_al_anaflt = -1;
546 static int hf_dnp3_al_anadbl = -1;
547 static int hf_dnp3_al_bit = -1;
548 static int hf_dnp3_al_2bit = -1;
549 static int hf_dnp3_al_cnt16 = -1;
550 static int hf_dnp3_al_cnt32 = -1;
551 static int hf_dnp3_al_ctrlstatus = -1;
552 static int hf_dnp3_al_anaout16 = -1;
553 static int hf_dnp3_al_anaout32 = -1;
554 static int hf_dnp3_al_anaoutflt = -1;
555 static int hf_dnp3_al_anaoutdbl = -1;
557 /***************************************************************************/
558 /* Value String Look-Ups */
559 /***************************************************************************/
560 static const value_string dnp3_ctl_func_pri_vals[] = {
561 { DL_FUNC_RESET_LINK, "Reset of Remote Link" },
562 { DL_FUNC_RESET_PROC, "Reset of User Process" },
563 { DL_FUNC_TEST_LINK, "Test Function For Link" },
564 { DL_FUNC_USER_DATA, "User Data" },
565 { DL_FUNC_UNC_DATA, "Unconfirmed User Data" },
566 { DL_FUNC_LINK_STAT, "Request Link Status" },
570 static const value_string dnp3_ctl_func_sec_vals[] = {
571 { DL_FUNC_ACK, "ACK" },
572 { DL_FUNC_NACK, "NACK" },
573 { DL_FUNC_STAT_LINK, "Status of Link" },
574 { DL_FUNC_NO_FUNC, "Link Service Not Functioning" },
575 { DL_FUNC_NOT_IMPL, "Link Service Not Used or Implemented" },
579 static const value_string dnp3_ctl_flags_pri_vals[] _U_ = {
580 { DNP3_CTL_DIR, "DIR" },
581 { DNP3_CTL_PRM, "PRM" },
582 { DNP3_CTL_FCB, "FCB" },
583 { DNP3_CTL_FCV, "FCV" },
587 static const value_string dnp3_ctl_flags_sec_vals[] _U_ = {
588 { DNP3_CTL_DIR, "DIR" },
589 { DNP3_CTL_PRM, "PRM" },
590 { DNP3_CTL_RES, "RES" },
591 { DNP3_CTL_DFC, "DFC" },
595 static const value_string dnp3_tr_flags_vals[] _U_ = {
596 { DNP3_TR_FIN, "FIN" },
597 { DNP3_TR_FIR, "FIR" },
601 static const value_string dnp3_al_flags_vals[] _U_ = {
602 { DNP3_AL_FIR, "FIR" },
603 { DNP3_AL_FIN, "FIN" },
604 { DNP3_AL_CON, "CON" },
608 /* Application Layer Function Code Values */
609 static const value_string dnp3_al_func_vals[] = {
610 { AL_FUNC_CONFIRM, "Confirm" },
611 { AL_FUNC_READ, "Read" },
612 { AL_FUNC_WRITE, "Write" },
613 { AL_FUNC_SELECT, "Select" },
614 { AL_FUNC_OPERATE, "Operate" },
615 { AL_FUNC_DIROP, "Direct Operate" },
616 { AL_FUNC_DIROPNACK, "Direct Operate No Ack" },
617 { AL_FUNC_FRZ, "Immediate Freeze" },
618 { AL_FUNC_FRZNACK, "Immediate Freeze No Ack" },
619 { AL_FUNC_FRZCLR, "Freeze and Clear" },
620 { AL_FUNC_FRZCLRNACK, "Freeze and Clear No ACK" },
621 { AL_FUNC_FRZT, "Freeze With Time" },
622 { AL_FUNC_FRZTNACK, "Freeze With Time No ACK" },
623 { AL_FUNC_COLDRST, "Cold Restart" },
624 { AL_FUNC_WARMRST, "Warm Restart" },
625 { AL_FUNC_INITDATA, "Initialize Data" },
626 { AL_FUNC_INITAPP, "Initialize Application" },
627 { AL_FUNC_STARTAPP, "Start Application" },
628 { AL_FUNC_STOPAPP, "Stop Application" },
629 { AL_FUNC_SAVECFG, "Save Configuration" },
630 { AL_FUNC_ENSPMSG, "Enable Spontaneous Messages" },
631 { AL_FUNC_DISSPMSG, "Disable Spontaneous Messages" },
632 { AL_FUNC_ASSIGNCL, "Assign Classes" },
633 { AL_FUNC_DELAYMST, "Delay Measurement" },
634 { AL_FUNC_RESPON, "Response" },
635 { AL_FUNC_UNSOLI, "Unsolicited Response" },
639 /* Application Layer Internal Indication (IIN) bit Values */
640 static const value_string dnp3_al_iin_vals[] _U_ = {
641 { AL_IIN_BMSG, "Broadcast message Rx'd" },
642 { AL_IIN_CLS1D, "Class 1 Data Available" },
643 { AL_IIN_CLS2D, "Class 2 Data Available" },
644 { AL_IIN_CLS3D, "Class 3 Data Available" },
645 { AL_IIN_TSR, "Time Sync Required from Master" },
646 { AL_IIN_DOL, "Digital Outputs in Local Mode" },
647 { AL_IIN_DT, "Device Trouble" },
648 { AL_IIN_RST, "Device Restart" },
649 { AL_IIN_OBJU, "Requested Objects Unknown" },
650 { AL_IIN_PIOOR, "Parameters Invalid or Out of Range" },
651 { AL_IIN_EBO, "Event Buffer Overflow" },
652 { AL_IIN_OAE, "Operation Already Executing" },
653 { AL_IIN_CC, "Device Configuration Corrupt" },
657 /* Application Layer Object Qualifier Index Values When Qualifier Code != 11 */
658 static const value_string dnp3_al_objq_index_vals[] = {
659 { AL_OBJQL_IDX_NI, "None" },
660 { AL_OBJQL_IDX_1O, "1-Octet Indexing" },
661 { AL_OBJQL_IDX_2O, "2-Octet Indexing" },
662 { AL_OBJQL_IDX_4O, "4-Octet Indexing" },
663 { AL_OBJQL_IDX_1OS, "1-Octet Object Size" },
664 { AL_OBJQL_IDX_2OS, "2-Octet Object Size" },
665 { AL_OBJQL_IDX_4OS, "4-Octet Object Size" },
669 /* Application Layer Object Qualifier Code Values */
670 static const value_string dnp3_al_objq_code_vals[] = {
671 { AL_OBJQL_CODE_SSI8, "8-bit Start and Stop Indices" },
672 { AL_OBJQL_CODE_SSI16, "16-bit Start and Stop Indices" },
673 { AL_OBJQL_CODE_SSI32, "32-bit Start and Stop Indices" },
674 { AL_OBJQL_CODE_AA8, "8-bit Absolute Address in Range Field" },
675 { AL_OBJQL_CODE_AA16, "16-bit Absolute Address in Range Field" },
676 { AL_OBJQL_CODE_AA32, "32-bit Absolute Address in Range Field" },
677 { AL_OBJQL_CODE_R0, "No Range Field" },
678 { AL_OBJQL_CODE_SF8, "8-bit Single Field Quantity" },
679 { AL_OBJQL_CODE_SF16, "16-bit Single Field Quantity" },
680 { AL_OBJQL_CODE_SF32, "32-bit Single Field Quantity" },
681 { AL_OBJQL_CODE_FF, "Free-format Qualifier" },
685 /* Application Layer Data Object Values */
686 static const value_string dnp3_al_obj_vals[] = {
687 { AL_OBJ_BI_ALL, "Binary Input All Variations (Obj:01, Var:All)" },
688 { AL_OBJ_BI_1BIT, "Single-Bit Binary Input (Obj:01, Var:01)" },
689 { AL_OBJ_BI_STAT, "Binary Input With Status (Obj:01, Var:02)" },
690 { AL_OBJ_BIC_ALL, "Binary Input Change All Variations (Obj:02, Var:All)" },
691 { AL_OBJ_BIC_NOTIME, "Binary Input Change Without Time (Obj:02, Var:01)" },
692 { AL_OBJ_BIC_TIME, "Binary Input Change With Time (Obj:02, Var:02)" },
693 { AL_OBJ_BIC_RTIME, "Binary Input Change With Relative Time (Obj:02, Var:03)" },
694 { AL_OBJ_2BI_ALL, "Double-bit Input All Variations (Obj:03, Var:All)" },
695 { AL_OBJ_2BI_NF, "Double-bit Input No Flags (Obj:03, Var:01)" },
696 { AL_OBJ_2BI_STAT, "Double-bit Input With Status (Obj:03, Var:02)" },
697 { AL_OBJ_2BIC_NOTIME, "Double-bit Input Change Without Time (Obj:04, Var:01)" },
698 { AL_OBJ_2BIC_TIME, "Double-bit Input Change With Time (Obj:04, Var:02)" },
699 { AL_OBJ_2BIC_RTIME, "Double-bit Input Change With Relative Time (Obj:04, Var:03)" },
700 { AL_OBJ_BO, "Binary Output (Obj:10, Var:01)" },
701 { AL_OBJ_BO_STAT, "Binary Output Status (Obj:10, Var:02)" },
702 { AL_OBJ_CTLOP_BLK, "Control Relay Output Block (Obj:12, Var:01)" },
703 { AL_OBJ_CTR_ALL, "Binary Counter All Variations (Obj:20, Var:All)" },
704 { AL_OBJ_CTR_32, "32-Bit Binary Counter (Obj:20, Var:01)" },
705 { AL_OBJ_CTR_16, "16-Bit Binary Counter (Obj:20, Var:02)" },
706 { AL_OBJ_DCTR_32, "32-Bit Binary Delta Counter (Obj:20, Var:03)" },
707 { AL_OBJ_DCTR_16, "16-Bit Binary Delta Counter (Obj:20, Var:04)" },
708 { AL_OBJ_CTR_32NF, "32-Bit Binary Counter Without Flag (Obj:20, Var:05)" },
709 { AL_OBJ_CTR_16NF, "16-Bit Binary Counter Without Flag (Obj:20, Var:06)" },
710 { AL_OBJ_DCTR_32NF, "32-Bit Binary Delta Counter Without Flag (Obj:20, Var:07)" },
711 { AL_OBJ_DCTR_16NF, "16-Bit Binary Delta Counter Without Flag (Obj:20, Var:08)" },
712 { AL_OBJ_FCTR_ALL, "Frozen Binary Counter All Variations (Obj:21, Var:All)" },
713 { AL_OBJ_FCTR_32, "32-Bit Frozen Binary Counter (Obj:21, Var:01)" },
714 { AL_OBJ_FCTR_16, "16-Bit Frozen Binary Counter (Obj:21, Var:02)" },
715 { AL_OBJ_FDCTR_32, "32-Bit Frozen Binary Delta Counter (Obj:21, Var:03)" },
716 { AL_OBJ_FDCTR_16, "16-Bit Frozen Binary Delta Counter (Obj:21, Var:04)" },
717 { AL_OBJ_FCTR_32T, "32-Bit Frozen Binary Counter (Obj:21, Var:01)" },
718 { AL_OBJ_FCTR_16T, "16-Bit Frozen Binary Counter (Obj:21, Var:02)" },
719 { AL_OBJ_FDCTR_32T, "32-Bit Frozen Binary Delta Counter (Obj:21, Var:03)" },
720 { AL_OBJ_FDCTR_16T, "16-Bit Frozen Binary Delta Counter (Obj:21, Var:04)" },
721 { AL_OBJ_FCTR_32NF, "32-Bit Frozen Binary Counter Without Flag (Obj:21, Var:05)" },
722 { AL_OBJ_FCTR_16NF, "16-Bit Frozen Binary Counter Without Flag (Obj:21, Var:06)" },
723 { AL_OBJ_FDCTR_32NF, "32-Bit Frozen Binary Delta Counter Without Flag (Obj:21, Var:07)" },
724 { AL_OBJ_FDCTR_16NF, "16-Bit Frozen Binary Delta Counter Without Flag (Obj:21, Var:08)" },
725 { AL_OBJ_CTRC_ALL, "Binary Counter Change All Variations (Obj:22, Var:All)" },
726 { AL_OBJ_CTRC_32, "32-Bit Counter Change Event w/o Time (Obj:22, Var:01)" },
727 { AL_OBJ_CTRC_16, "16-Bit Counter Change Event w/o Time (Obj:22, Var:02)" },
728 { AL_OBJ_DCTRC_32, "32-Bit Delta Counter Change Event w/o Time (Obj:22, Var:03)" },
729 { AL_OBJ_DCTRC_16, "16-Bit Delta Counter Change Event w/o Time (Obj:22, Var:04)" },
730 { AL_OBJ_CTRC_32T, "32-Bit Counter Change Event with Time (Obj:22, Var:05)" },
731 { AL_OBJ_CTRC_16T, "16-Bit Counter Change Event with Time (Obj:22, Var:06)" },
732 { AL_OBJ_DCTRC_32T, "32-Bit Delta Counter Change Event with Time (Obj:22, Var:07)" },
733 { AL_OBJ_DCTRC_16T, "16-Bit Delta Counter Change Event with Time (Obj:22, Var:08)" },
734 { AL_OBJ_FCTRC_ALL, "Frozen Binary Counter Change All Variations (Obj:23, Var:All)" },
735 { AL_OBJ_FCTRC_32, "32-Bit Frozen Counter Change Event w/o Time (Obj:23, Var:01)" },
736 { AL_OBJ_FCTRC_16, "16-Bit Frozen Counter Change Event w/o Time (Obj:23, Var:02)" },
737 { AL_OBJ_FDCTRC_32, "32-Bit Frozen Delta Counter Change Event w/o Time (Obj:23, Var:03)" },
738 { AL_OBJ_FDCTRC_16, "16-Bit Frozen Delta Counter Change Event w/o Time (Obj:23, Var:04)" },
739 { AL_OBJ_FCTRC_32T, "32-Bit Frozen Counter Change Event with Time (Obj:23, Var:05)" },
740 { AL_OBJ_FCTRC_16T, "16-Bit Frozen Counter Change Event with Time (Obj:23, Var:06)" },
741 { AL_OBJ_FDCTRC_32T, "32-Bit Frozen Delta Counter Change Event with Time (Obj:23, Var:07)" },
742 { AL_OBJ_FDCTRC_16T, "16-Bit Frozen Delta Counter Change Event with Time (Obj:23, Var:08)" },
743 { AL_OBJ_AI_ALL, "Analog Input All Variations (Obj:30, Var:All)" },
744 { AL_OBJ_AI_32, "32-Bit Analog Input (Obj:30, Var:01)" },
745 { AL_OBJ_AI_16, "16-Bit Analog Input (Obj:30, Var:02)" },
746 { AL_OBJ_AI_32NF, "32-Bit Analog Input Without Flag (Obj:30, Var:03)" },
747 { AL_OBJ_AI_16NF, "16-Bit Analog Input Without Flag (Obj:30, Var:04)" },
748 { AL_OBJ_AI_FLT, "32-Bit Floating Point Input (Obj:30, Var:05)" },
749 { AL_OBJ_AI_DBL, "64-Bit Floating Point Input (Obj:30, Var:06)" },
750 { AL_OBJ_AIF_FLT, "32-Bit Frozen Floating Point Input (Obj:31, Var:07)" },
751 { AL_OBJ_AIF_DBL, "64-Bit Frozen Floating Point Input (Obj:31, Var:08)" },
752 { AL_OBJ_AIC_ALL, "Analog Input Change All Variations (Obj:32, Var:All)" },
753 { AL_OBJ_AIC_32NT, "32-Bit Analog Change Event w/o Time (Obj:32, Var:01)" },
754 { AL_OBJ_AIC_16NT, "16-Bit Analog Change Event w/o Time (Obj:32, Var:02)" },
755 { AL_OBJ_AIC_32T, "32-Bit Analog Change Event with Time (Obj:32, Var:03)" },
756 { AL_OBJ_AIC_16T, "16-Bit Analog Change Event with Time (Obj:32, Var:04)" },
757 { AL_OBJ_AIC_FLTNT, "32-Bit Floating Point Change Event w/o Time (Obj:32, Var:05)" },
758 { AL_OBJ_AIC_DBLNT, "64-Bit Floating Point Change Event w/o Time (Obj:32, Var:06)" },
759 { AL_OBJ_AIC_FLTT, "32-Bit Floating Point Change Event w/ Time (Obj:32, Var:07)" },
760 { AL_OBJ_AIC_DBLT, "64-Bit Floating Point Change Event w/ Time (Obj:32, Var:08)" },
761 { AL_OBJ_AIFC_FLTNT, "32-Bit Floating Point Frozen Change Event w/o Time (Obj:33, Var:05)" },
762 { AL_OBJ_AIFC_DBLNT, "64-Bit Floating Point Frozen Change Event w/o Time (Obj:33, Var:06)" },
763 { AL_OBJ_AIFC_FLTT, "32-Bit Floating Point Frozen Change Event w/ Time (Obj:33, Var:07)" },
764 { AL_OBJ_AIFC_DBLT, "64-Bit Floating Point Frozen Change Event w/ Time (Obj:33, Var:08)" },
765 { AL_OBJ_AO_32, "32-Bit Analog Output Status (Obj:40, Var:01)" },
766 { AL_OBJ_AO_16, "16-Bit Analog Output Status (Obj:40, Var:02)" },
767 { AL_OBJ_AO_FLT, "32-Bit Floating Point Output Status (Obj:40, Var:03)" },
768 { AL_OBJ_AO_DBL, "64-Bit Floating Point Output Status (Obj:40, Var:04)" },
769 { AL_OBJ_AO_32OPB, "32-Bit Analog Output Block (Obj:41, Var:01)" },
770 { AL_OBJ_AO_16OPB, "16-Bit Analog Output Block (Obj:41, Var:02)" },
771 { AL_OBJ_AO_FLTOPB, "32-Bit Floating Point Output Block (Obj:41, Var:03)" },
772 { AL_OBJ_AO_DBLOPB, "64-Bit Floating Point Output Block (Obj:41, Var:04)" },
773 { AL_OBJ_TD, "Time and Date (Obj:50, Var:01)" },
774 { AL_OBJ_TDCTO, "Time and Date CTO (Obj:51, Var:01)" },
775 { AL_OBJ_TDELAYF, "Time Delay - Fine (Obj:52, Var:02)" },
776 { AL_OBJ_CLASS0, "Class 0 Data (Obj:60, Var:01)" },
777 { AL_OBJ_CLASS1, "Class 1 Data (Obj:60, Var:02)" },
778 { AL_OBJ_CLASS2, "Class 2 Data (Obj:60, Var:03)" },
779 { AL_OBJ_CLASS3, "Class 3 Data (Obj:60, Var:04)" },
780 { AL_OBJ_IIN, "Internal Indications (Obj:80, Var:01)" },
781 { AL_OBJ_OCT, "Octet String (Obj:110)" },
785 /* Application Layer Control Code 'Code' Values */
786 static const value_string dnp3_al_ctlc_code_vals[] = {
787 { AL_OBJCTLC_CODE0, "NUL Operation" },
788 { AL_OBJCTLC_CODE1, "Pulse On" },
789 { AL_OBJCTLC_CODE2, "Pulse Off" },
790 { AL_OBJCTLC_CODE3, "Latch On" },
791 { AL_OBJCTLC_CODE4, "Latch Off" },
795 /* Application Layer Control Code 'Misc' Values */
796 static const value_string dnp3_al_ctlc_misc_vals[] = {
797 { AL_OBJCTLC_QUEUE, "Queue" },
798 { AL_OBJCTLC_CLEAR, "Clear" },
802 /* Application Layer Control Code 'Trip/Close' Values */
803 static const value_string dnp3_al_ctlc_tc_vals[] = {
804 { AL_OBJCTLC_TC0, "NUL" },
805 { AL_OBJCTLC_TC1, "Close" },
806 { AL_OBJCTLC_TC2, "Trip" },
810 /* Application Layer Control Status Values */
811 static const value_string dnp3_al_ctl_status_vals[] = {
812 { AL_OBJCTL_STAT0, "Req. Accepted/Init/Queued" },
813 { AL_OBJCTL_STAT1, "Req. Not Accepted; Arm-Timer Expired" },
814 { AL_OBJCTL_STAT2, "Req. Not Accepted; No 'SELECT' Received" },
815 { AL_OBJCTL_STAT3, "Req. Not Accepted; Format Err. in Ctl Req." },
816 { AL_OBJCTL_STAT4, "Ctl Oper. Not Supported For This Point" },
817 { AL_OBJCTL_STAT5, "Req. Not Accepted; Ctrl Queue Full/Point Active" },
818 { AL_OBJCTL_STAT6, "Req. Not Accepted; Ctrl Hardware Problems" },
819 { AL_OBJCTL_STAT7, "Req. Not Accepted; Local/Remote switch in Local" },
820 { AL_OBJCTL_STAT8, "Req. Not Accepted; Too many operations" },
821 { AL_OBJCTL_STAT9, "Req. Not Accepted; Insufficient authorization" },
822 { AL_OBJCTL_STAT10, "Req. Not Accepted; Local automation proc active" },
826 /* Application Layer Binary Input Quality Flag Values */
827 static const value_string dnp3_al_biflag_vals[] _U_ = {
828 { AL_OBJ_BI_FLAG0, "Online" },
829 { AL_OBJ_BI_FLAG1, "Restart" },
830 { AL_OBJ_BI_FLAG2, "Comm Fail" },
831 { AL_OBJ_BI_FLAG3, "Remote Forced" },
832 { AL_OBJ_BI_FLAG4, "Locally Forced" },
833 { AL_OBJ_BI_FLAG5, "Chatter Filter" },
837 /* Application Layer Counter Quality Flag Values */
838 static const value_string dnp3_al_ctrflag_vals[] _U_ = {
839 { AL_OBJ_CTR_FLAG0, "Online" },
840 { AL_OBJ_CTR_FLAG1, "Restart" },
841 { AL_OBJ_CTR_FLAG2, "Comm Fail" },
842 { AL_OBJ_CTR_FLAG3, "Remote Forced" },
843 { AL_OBJ_CTR_FLAG4, "Locally Forced" },
844 { AL_OBJ_CTR_FLAG5, "Roll-Over" },
845 { AL_OBJ_CTR_FLAG6, "Discontinuity" },
849 /* Application Layer Analog Input Quality Flag Values */
850 static const value_string dnp3_al_aiflag_vals[] _U_ = {
851 { AL_OBJ_AI_FLAG0, "Online" },
852 { AL_OBJ_AI_FLAG1, "Restart" },
853 { AL_OBJ_AI_FLAG2, "Comm Fail" },
854 { AL_OBJ_AI_FLAG3, "Remote Forced" },
855 { AL_OBJ_AI_FLAG4, "Locally Forced" },
856 { AL_OBJ_AI_FLAG5, "Over-Range" },
857 { AL_OBJ_AI_FLAG6, "Ref. Error" },
861 /* Initialize the subtree pointers */
862 static gint ett_dnp3 = -1;
863 static gint ett_dnp3_dl = -1;
864 static gint ett_dnp3_dl_ctl = -1;
865 static gint ett_dnp3_tr_ctl = -1;
866 static gint ett_dnp3_al_data = -1;
867 static gint ett_dnp3_al = -1;
868 static gint ett_dnp3_al_ctl = -1;
870 /* Added for Application Layer Decoding */
871 static gint ett_dnp3_al_iin = -1;
872 static gint ett_dnp3_al_obj = -1;
873 static gint ett_dnp3_al_obj_qualifier = -1;
874 static gint ett_dnp3_al_obj_range = -1;
875 static gint ett_dnp3_al_objdet = -1;
876 static gint ett_dnp3_al_obj_quality = -1;
877 static gint ett_dnp3_al_obj_point = -1;
879 /* Tables for reassembly of fragments. */
880 static GHashTable *al_fragment_table = NULL;
881 static GHashTable *al_reassembled_table = NULL;
883 /* ************************************************************************* */
884 /* Header values for reassembly */
885 /* ************************************************************************* */
886 static int hf_dnp3_fragment = -1;
887 static int hf_dnp3_fragments = -1;
888 static int hf_dnp3_fragment_overlap = -1;
889 static int hf_dnp3_fragment_overlap_conflict = -1;
890 static int hf_dnp3_fragment_multiple_tails = -1;
891 static int hf_dnp3_fragment_too_long_fragment = -1;
892 static int hf_dnp3_fragment_error = -1;
893 static int hf_dnp3_fragment_reassembled_in = -1;
894 static gint ett_dnp3_fragment = -1;
895 static gint ett_dnp3_fragments = -1;
897 static const fragment_items dnp3_frag_items = {
902 &hf_dnp3_fragment_overlap,
903 &hf_dnp3_fragment_overlap_conflict,
904 &hf_dnp3_fragment_multiple_tails,
905 &hf_dnp3_fragment_too_long_fragment,
906 &hf_dnp3_fragment_error,
907 &hf_dnp3_fragment_reassembled_in,
911 /* Conversation stuff, used for tracking application message fragments */
912 /* the number of entries in the memory chunk array */
913 #define dnp3_conv_init_count 50
915 /* Conversation structure */
917 guint conv_seq_number;
920 /* The conversation sequence number */
921 static guint seq_number = 0;
923 /* desegmentation of DNP3 over TCP */
924 static gboolean dnp3_desegment = TRUE;
926 /* Enum for different quality type fields */
935 /*****************************************************************/
937 /* CRC LOOKUP TABLE */
938 /* ================ */
939 /* The following CRC lookup table was generated automagically */
940 /* by the Rocksoft^tm Model CRC Algorithm Table Generation */
941 /* Program V1.0 using the following model parameters: */
943 /* Width : 2 bytes. */
945 /* Reverse : TRUE. */
947 /* For more information on the Rocksoft^tm Model CRC Algorithm, */
948 /* see the document titled "A Painless Guide to CRC Error */
949 /* Detection Algorithms" by Ross Williams */
950 /* (ross@guest.adelaide.edu.au.). This document is likely to be */
951 /* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */
953 /*****************************************************************/
955 static guint16 crctable[256] =
957 0x0000, 0x365E, 0x6CBC, 0x5AE2, 0xD978, 0xEF26, 0xB5C4, 0x839A,
958 0xFF89, 0xC9D7, 0x9335, 0xA56B, 0x26F1, 0x10AF, 0x4A4D, 0x7C13,
959 0xB26B, 0x8435, 0xDED7, 0xE889, 0x6B13, 0x5D4D, 0x07AF, 0x31F1,
960 0x4DE2, 0x7BBC, 0x215E, 0x1700, 0x949A, 0xA2C4, 0xF826, 0xCE78,
961 0x29AF, 0x1FF1, 0x4513, 0x734D, 0xF0D7, 0xC689, 0x9C6B, 0xAA35,
962 0xD626, 0xE078, 0xBA9A, 0x8CC4, 0x0F5E, 0x3900, 0x63E2, 0x55BC,
963 0x9BC4, 0xAD9A, 0xF778, 0xC126, 0x42BC, 0x74E2, 0x2E00, 0x185E,
964 0x644D, 0x5213, 0x08F1, 0x3EAF, 0xBD35, 0x8B6B, 0xD189, 0xE7D7,
965 0x535E, 0x6500, 0x3FE2, 0x09BC, 0x8A26, 0xBC78, 0xE69A, 0xD0C4,
966 0xACD7, 0x9A89, 0xC06B, 0xF635, 0x75AF, 0x43F1, 0x1913, 0x2F4D,
967 0xE135, 0xD76B, 0x8D89, 0xBBD7, 0x384D, 0x0E13, 0x54F1, 0x62AF,
968 0x1EBC, 0x28E2, 0x7200, 0x445E, 0xC7C4, 0xF19A, 0xAB78, 0x9D26,
969 0x7AF1, 0x4CAF, 0x164D, 0x2013, 0xA389, 0x95D7, 0xCF35, 0xF96B,
970 0x8578, 0xB326, 0xE9C4, 0xDF9A, 0x5C00, 0x6A5E, 0x30BC, 0x06E2,
971 0xC89A, 0xFEC4, 0xA426, 0x9278, 0x11E2, 0x27BC, 0x7D5E, 0x4B00,
972 0x3713, 0x014D, 0x5BAF, 0x6DF1, 0xEE6B, 0xD835, 0x82D7, 0xB489,
973 0xA6BC, 0x90E2, 0xCA00, 0xFC5E, 0x7FC4, 0x499A, 0x1378, 0x2526,
974 0x5935, 0x6F6B, 0x3589, 0x03D7, 0x804D, 0xB613, 0xECF1, 0xDAAF,
975 0x14D7, 0x2289, 0x786B, 0x4E35, 0xCDAF, 0xFBF1, 0xA113, 0x974D,
976 0xEB5E, 0xDD00, 0x87E2, 0xB1BC, 0x3226, 0x0478, 0x5E9A, 0x68C4,
977 0x8F13, 0xB94D, 0xE3AF, 0xD5F1, 0x566B, 0x6035, 0x3AD7, 0x0C89,
978 0x709A, 0x46C4, 0x1C26, 0x2A78, 0xA9E2, 0x9FBC, 0xC55E, 0xF300,
979 0x3D78, 0x0B26, 0x51C4, 0x679A, 0xE400, 0xD25E, 0x88BC, 0xBEE2,
980 0xC2F1, 0xF4AF, 0xAE4D, 0x9813, 0x1B89, 0x2DD7, 0x7735, 0x416B,
981 0xF5E2, 0xC3BC, 0x995E, 0xAF00, 0x2C9A, 0x1AC4, 0x4026, 0x7678,
982 0x0A6B, 0x3C35, 0x66D7, 0x5089, 0xD313, 0xE54D, 0xBFAF, 0x89F1,
983 0x4789, 0x71D7, 0x2B35, 0x1D6B, 0x9EF1, 0xA8AF, 0xF24D, 0xC413,
984 0xB800, 0x8E5E, 0xD4BC, 0xE2E2, 0x6178, 0x5726, 0x0DC4, 0x3B9A,
985 0xDC4D, 0xEA13, 0xB0F1, 0x86AF, 0x0535, 0x336B, 0x6989, 0x5FD7,
986 0x23C4, 0x159A, 0x4F78, 0x7926, 0xFABC, 0xCCE2, 0x9600, 0xA05E,
987 0x6E26, 0x5878, 0x029A, 0x34C4, 0xB75E, 0x8100, 0xDBE2, 0xEDBC,
988 0x91AF, 0xA7F1, 0xFD13, 0xCB4D, 0x48D7, 0x7E89, 0x246B, 0x1235
991 /*****************************************************************/
992 /* End of CRC Lookup Table */
993 /*****************************************************************/
995 /* calculates crc given a buffer of characters and a length of buffer */
997 calculateCRC(const void *buf, guint len) {
999 const guint8 *p = (const guint8 *)buf;
1001 crc = crctable[(crc ^ *p++) & 0xff] ^ (crc >> 8);
1005 /*****************************************************************/
1006 /* Adds text to item, with trailing "," if required */
1007 /*****************************************************************/
1009 add_item_text(proto_item *item, const gchar *text, gboolean comma_needed)
1012 proto_item_append_text(item, ", ");
1014 proto_item_append_text(item, text);
1018 /*****************************************************************/
1019 /* Application Layer Process Internal Indications (IIN) */
1020 /*****************************************************************/
1022 dnp3_al_process_iin(tvbuff_t *tvb, int offset, proto_tree *al_tree)
1027 proto_tree *iin_tree = NULL;
1028 gboolean comma_needed = FALSE;
1030 al_iin = tvb_get_ntohs(tvb, offset);
1032 tiin = proto_tree_add_uint_format(al_tree, hf_dnp3_al_iin, tvb, offset, 2, al_iin,
1033 "Internal Indications: ");
1034 if (al_iin & AL_IIN_RST) comma_needed = add_item_text(tiin, "Device Restart", comma_needed);
1035 if (al_iin & AL_IIN_DOL) comma_needed = add_item_text(tiin, "Digital Outputs in Local", comma_needed);
1036 if (al_iin & AL_IIN_DT) comma_needed = add_item_text(tiin, "Device Trouble", comma_needed);
1037 if (al_iin & AL_IIN_TSR) comma_needed = add_item_text(tiin, "Time Sync Required", comma_needed);
1038 if (al_iin & AL_IIN_CLS3D) comma_needed = add_item_text(tiin, "Class 3 Data Available", comma_needed);
1039 if (al_iin & AL_IIN_CLS2D) comma_needed = add_item_text(tiin, "Class 2 Data Available", comma_needed);
1040 if (al_iin & AL_IIN_CLS1D) comma_needed = add_item_text(tiin, "Class 1 Data Available", comma_needed);
1041 if (al_iin & AL_IIN_BMSG) comma_needed = add_item_text(tiin, "Broadcast Message Rx'd", comma_needed);
1042 if (al_iin & AL_IIN_CC) comma_needed = add_item_text(tiin, "Device Configuration Corrupt", comma_needed);
1043 if (al_iin & AL_IIN_OAE) comma_needed = add_item_text(tiin, "Operation Already Executing", comma_needed);
1044 if (al_iin & AL_IIN_EBO) comma_needed = add_item_text(tiin, "Event Buffer Overflow", comma_needed);
1045 if (al_iin & AL_IIN_PIOOR) comma_needed = add_item_text(tiin, "Parameters Invalid or Out of Range", comma_needed);
1046 if (al_iin & AL_IIN_OBJU) comma_needed = add_item_text(tiin, "Requested Objects Unknown", comma_needed);
1047 proto_item_append_text(tiin, " (0x%04x)", al_iin);
1049 iin_tree = proto_item_add_subtree(tiin, ett_dnp3_al_iin);
1050 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_rst, tvb, offset, 2, FALSE);
1051 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_dt, tvb, offset, 2, FALSE);
1052 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_dol, tvb, offset, 2, FALSE);
1053 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_tsr, tvb, offset, 2, FALSE);
1054 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_cls3d, tvb, offset, 2, FALSE);
1055 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_cls2d, tvb, offset, 2, FALSE);
1056 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_cls1d, tvb, offset, 2, FALSE);
1057 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_bmsg, tvb, offset, 2, FALSE);
1058 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_cc, tvb, offset, 2, FALSE);
1059 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_oae, tvb, offset, 2, FALSE);
1060 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_ebo, tvb, offset, 2, FALSE);
1061 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_pioor, tvb, offset, 2, FALSE);
1062 proto_tree_add_item(iin_tree, hf_dnp3_al_iin_obju, tvb, offset, 2, FALSE);
1065 /*****************************************************************/
1066 /* Function to determine Application Layer Object Index size and */
1067 /* Point address. */
1068 /*****************************************************************/
1070 dnp3_al_obj_procindex(tvbuff_t *tvb, int offset, guint8 al_objq_index, guint32 *al_ptaddr, proto_tree *item_tree)
1073 proto_item *index_item;
1075 switch (al_objq_index)
1077 case AL_OBJQL_IDX_NI: /* No Index */
1079 index_item = proto_tree_add_text(item_tree, tvb, offset, 0, "Point Index: %u", *al_ptaddr);
1080 PROTO_ITEM_SET_GENERATED(index_item);
1082 case AL_OBJQL_IDX_1O:
1083 *al_ptaddr = tvb_get_guint8(tvb, offset);
1084 proto_tree_add_item(item_tree, hf_dnp3_al_index8, tvb, offset, 1, TRUE);
1087 case AL_OBJQL_IDX_2O:
1088 *al_ptaddr = tvb_get_letohs(tvb, offset);
1089 proto_tree_add_item(item_tree, hf_dnp3_al_index16, tvb, offset, 2, TRUE);
1092 case AL_OBJQL_IDX_4O:
1093 *al_ptaddr = tvb_get_letohl(tvb, offset);
1094 proto_tree_add_item(item_tree, hf_dnp3_al_index32, tvb, offset, 4, TRUE);
1101 /*****************************************************************/
1102 /* Function to add the same string to two separate tree items */
1103 /*****************************************************************/
1105 dnp3_append_2item_text(proto_item *item1, proto_item *item2, const gchar *text)
1107 proto_item_append_text(item1, text);
1108 proto_item_append_text(item2, text);
1111 /*****************************************************************/
1112 /* Function to Determine Application Layer Point Quality Flags & */
1113 /* add Point Quality Flag Sub-Tree */
1114 /*****************************************************************/
1116 dnp3_al_obj_quality(tvbuff_t *tvb, int offset, guint8 al_ptflags, proto_tree *point_tree, proto_item *point_item, enum QUALITY_TYPE type)
1119 proto_tree *quality_tree = NULL;
1120 proto_item *quality_item;
1121 int hf0 = 0, hf1 = 0, hf2 = 0, hf3 = 0, hf4 = 0, hf5 = 0, hf6 = 0, hf7 = 0;
1124 proto_item_append_text(point_item, " (Quality: ");
1125 quality_item = proto_tree_add_text(point_tree, tvb, offset, 1, "Quality: ");
1126 quality_tree = proto_item_add_subtree(quality_item, ett_dnp3_al_obj_quality);
1128 if (al_ptflags & AL_OBJ_BI_FLAG0) {
1129 dnp3_append_2item_text(point_item, quality_item, "Online");
1132 dnp3_append_2item_text(point_item, quality_item, "Offline");
1134 if (al_ptflags & AL_OBJ_BI_FLAG1) dnp3_append_2item_text(point_item, quality_item, ", Restart");
1135 if (al_ptflags & AL_OBJ_BI_FLAG2) dnp3_append_2item_text(point_item, quality_item, ", Comm Fail");
1136 if (al_ptflags & AL_OBJ_BI_FLAG3) dnp3_append_2item_text(point_item, quality_item, ", Remote Force");
1137 if (al_ptflags & AL_OBJ_BI_FLAG4) dnp3_append_2item_text(point_item, quality_item, ", Local Force");
1140 case BIN_IN: /* Binary Input Quality flags */
1141 if (al_ptflags & AL_OBJ_BI_FLAG5) dnp3_append_2item_text(point_item, quality_item, ", Chatter Filter");
1143 hf0 = hf_dnp3_al_biq_b0;
1144 hf1 = hf_dnp3_al_biq_b1;
1145 hf2 = hf_dnp3_al_biq_b2;
1146 hf3 = hf_dnp3_al_biq_b3;
1147 hf4 = hf_dnp3_al_biq_b4;
1148 hf5 = hf_dnp3_al_biq_b5;
1149 hf6 = hf_dnp3_al_biq_b6;
1150 hf7 = hf_dnp3_al_biq_b7;
1153 case BIN_OUT: /* Binary Output Quality flags */
1154 hf0 = hf_dnp3_al_boq_b0;
1155 hf1 = hf_dnp3_al_boq_b1;
1156 hf2 = hf_dnp3_al_boq_b2;
1157 hf3 = hf_dnp3_al_boq_b3;
1158 hf4 = hf_dnp3_al_boq_b4;
1159 hf5 = hf_dnp3_al_boq_b5;
1160 hf6 = hf_dnp3_al_boq_b6;
1161 hf7 = hf_dnp3_al_boq_b7;
1164 case ANA_IN: /* Analog Input Quality flags */
1165 if (al_ptflags & AL_OBJ_AI_FLAG5) dnp3_append_2item_text(point_item, quality_item, ", Over-Range");
1166 if (al_ptflags & AL_OBJ_AI_FLAG6) dnp3_append_2item_text(point_item, quality_item, ", Reference Check");
1168 hf0 = hf_dnp3_al_aiq_b0;
1169 hf1 = hf_dnp3_al_aiq_b1;
1170 hf2 = hf_dnp3_al_aiq_b2;
1171 hf3 = hf_dnp3_al_aiq_b3;
1172 hf4 = hf_dnp3_al_aiq_b4;
1173 hf5 = hf_dnp3_al_aiq_b5;
1174 hf6 = hf_dnp3_al_aiq_b6;
1175 hf7 = hf_dnp3_al_aiq_b7;
1178 case ANA_OUT: /* Analog Output Quality flags */
1179 hf0 = hf_dnp3_al_aoq_b0;
1180 hf1 = hf_dnp3_al_aoq_b1;
1181 hf2 = hf_dnp3_al_aoq_b2;
1182 hf3 = hf_dnp3_al_aoq_b3;
1183 hf4 = hf_dnp3_al_aoq_b4;
1184 hf5 = hf_dnp3_al_aoq_b5;
1185 hf6 = hf_dnp3_al_aoq_b6;
1186 hf7 = hf_dnp3_al_aoq_b7;
1189 case COUNTER: /* Counter Quality flags */
1190 if (al_ptflags & AL_OBJ_CTR_FLAG5) dnp3_append_2item_text(point_item, quality_item, ", Roll-over");
1191 if (al_ptflags & AL_OBJ_CTR_FLAG6) dnp3_append_2item_text(point_item, quality_item, ", Discontinuity");
1193 hf0 = hf_dnp3_al_ctrq_b0;
1194 hf1 = hf_dnp3_al_ctrq_b1;
1195 hf2 = hf_dnp3_al_ctrq_b2;
1196 hf3 = hf_dnp3_al_ctrq_b3;
1197 hf4 = hf_dnp3_al_ctrq_b4;
1198 hf5 = hf_dnp3_al_ctrq_b5;
1199 hf6 = hf_dnp3_al_ctrq_b6;
1200 hf7 = hf_dnp3_al_ctrq_b7;
1204 if (quality_tree != NULL) {
1205 proto_tree_add_item(quality_tree, hf7, tvb, offset, 1, TRUE);
1206 proto_tree_add_item(quality_tree, hf6, tvb, offset, 1, TRUE);
1207 proto_tree_add_item(quality_tree, hf5, tvb, offset, 1, TRUE);
1208 proto_tree_add_item(quality_tree, hf4, tvb, offset, 1, TRUE);
1209 proto_tree_add_item(quality_tree, hf3, tvb, offset, 1, TRUE);
1210 proto_tree_add_item(quality_tree, hf2, tvb, offset, 1, TRUE);
1211 proto_tree_add_item(quality_tree, hf1, tvb, offset, 1, TRUE);
1212 proto_tree_add_item(quality_tree, hf0, tvb, offset, 1, TRUE);
1214 proto_item_append_text(point_item, ")");
1217 /**********************************************************************/
1218 /* Function to convert DNP3 timestamp to nstime_t value */
1219 /**********************************************************************/
1220 /* 48-bit Time Format */
1221 /* MSB FF EE DD CC BB AA LSB */
1222 /* ffffffff eeeeeeee dddddddd cccccccc bbbbbbbb aaaaaaaa */
1223 /* 47 40 39 32 31 24 23 16 15 8 7 0 */
1225 /* Value is ms since 00:00 on 1/1/1970 */
1226 /**********************************************************************/
1228 dnp3_al_get_timestamp(nstime_t *timestamp, tvbuff_t *tvb, int data_pos)
1234 lo = tvb_get_letohs(tvb, data_pos);
1235 hi = tvb_get_letohl(tvb, data_pos + 2);
1237 time_ms = (guint64)hi * 0x10000 + lo;
1239 timestamp->secs = (long)(time_ms / 1000);
1240 timestamp->nsecs = (long)(time_ms % 1000) * 1000000;
1243 /*****************************************************************/
1244 /* Desc: Application Layer Process Object Details */
1245 /* Returns: New offset pointer into tvb */
1246 /*****************************************************************/
1248 dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *robj_tree, gboolean header_only, guint16 *al_objtype)
1251 guint8 al_2bit, al_objq, al_objq_index, al_objq_code, al_ptflags, al_ctlobj_code, al_oct_len,
1252 al_ctlobj_code_c, al_ctlobj_code_m, al_ctlobj_code_tc, al_ctlobj_count, al_bi_val, bitindex=0;
1253 guint16 al_obj, al_val16=0, al_ctlobj_stat, al_relms;
1254 guint32 al_val32, al_ptaddr=0, al_ctlobj_on, al_ctlobj_off;
1255 nstime_t al_cto, al_reltime, al_abstime;
1260 int item_num, num_items=0;
1261 int orig_offset, start_offset, rangebytes=0, indexbytes=0;
1262 proto_item *object_item = NULL, *point_item = NULL, *qualifier_item = NULL, *range_item = NULL;
1263 proto_tree *object_tree = NULL, *point_tree, *qualifier_tree, *range_tree;
1264 const gchar *ctl_code_str, *ctl_misc_str, *ctl_tc_str, *ctl_status_str;
1266 orig_offset = offset;
1268 /* Application Layer Objects in this Message */
1270 al_obj = tvb_get_ntohs(tvb, offset);
1272 /* Special handling for Octet string objects as the variation is the length of the string */
1273 if ((al_obj & 0xFF00) == AL_OBJ_OCT) {
1274 al_oct_len = al_obj & 0xFF;
1275 al_obj = AL_OBJ_OCT;
1278 /* Create Data Objects Detail Tree */
1279 object_item = proto_tree_add_uint_format(robj_tree, hf_dnp3_al_obj, tvb, offset, 2, al_obj,
1280 "Object(s): %s (0x%04x)", val_to_str(al_obj, dnp3_al_obj_vals, "Unknown Object - Abort Decoding..."), al_obj);
1281 object_tree = proto_item_add_subtree(object_item, ett_dnp3_al_obj);
1285 /* Object Qualifier */
1286 al_objq = tvb_get_guint8(tvb, offset);
1287 al_objq_index = al_objq & AL_OBJQ_INDEX;
1288 al_objq_index = al_objq_index >> 4;
1289 al_objq_code = al_objq & AL_OBJQ_CODE;
1291 qualifier_item = proto_tree_add_text(object_tree, tvb, offset, 1, "Qualifier Field, Prefix: %s, Code: %s",
1292 val_to_str(al_objq_index, dnp3_al_objq_index_vals, "Unknown Index Type"),
1293 val_to_str(al_objq_code, dnp3_al_objq_code_vals, "Unknown Code Type"));
1294 qualifier_tree = proto_item_add_subtree(qualifier_item, ett_dnp3_al_obj_qualifier);
1295 proto_tree_add_item(qualifier_tree, hf_dnp3_al_objq_index, tvb, offset, 1, FALSE);
1296 proto_tree_add_item(qualifier_tree, hf_dnp3_al_objq_code, tvb, offset, 1, FALSE);
1300 /* Create (possibly synthesized) number of items and range field tree */
1301 range_item = proto_tree_add_text(object_tree, tvb, offset, 0, "Number of Items: ");
1302 range_tree = proto_item_add_subtree(range_item, ett_dnp3_al_obj_range);
1304 switch (al_objq_code)
1306 case AL_OBJQL_CODE_SSI8: /* 8-bit Start and Stop Indices in Range Field */
1307 num_items = ( tvb_get_guint8(tvb, offset+1) - tvb_get_guint8(tvb, offset) + 1);
1308 PROTO_ITEM_SET_GENERATED(range_item);
1309 al_ptaddr = tvb_get_guint8(tvb, offset);
1310 proto_tree_add_item(range_tree, hf_dnp3_al_range_start8, tvb, offset, 1, TRUE);
1311 proto_tree_add_item(range_tree, hf_dnp3_al_range_stop8, tvb, offset + 1, 1, TRUE);
1314 case AL_OBJQL_CODE_SSI16: /* 16-bit Start and Stop Indices in Range Field */
1315 num_items = ( tvb_get_letohs(tvb, offset+2) - tvb_get_letohs(tvb, (offset)) + 1);
1316 PROTO_ITEM_SET_GENERATED(range_item);
1317 al_ptaddr = tvb_get_letohs(tvb, offset);
1318 proto_tree_add_item(range_tree, hf_dnp3_al_range_start16, tvb, offset, 2, TRUE);
1319 proto_tree_add_item(range_tree, hf_dnp3_al_range_stop16, tvb, offset + 2, 2, TRUE);
1322 case AL_OBJQL_CODE_SSI32: /* 32-bit Start and Stop Indices in Range Field */
1323 num_items = ( tvb_get_letohl(tvb, offset+4) - tvb_get_letohl(tvb, offset) + 1);
1324 PROTO_ITEM_SET_GENERATED(range_item);
1325 al_ptaddr = tvb_get_letohl(tvb, offset);
1326 proto_tree_add_item(range_tree, hf_dnp3_al_range_start32, tvb, offset, 4, TRUE);
1327 proto_tree_add_item(range_tree, hf_dnp3_al_range_stop32, tvb, offset + 4, 4, TRUE);
1330 case AL_OBJQL_CODE_AA8: /* 8-bit Absolute Address in Range Field */
1332 PROTO_ITEM_SET_GENERATED(range_item);
1333 al_ptaddr = tvb_get_guint8(tvb, offset);
1334 proto_tree_add_item(range_tree, hf_dnp3_al_range_abs8, tvb, offset, 1, TRUE);
1337 case AL_OBJQL_CODE_AA16: /* 16-bit Absolute Address in Range Field */
1339 PROTO_ITEM_SET_GENERATED(range_item);
1340 al_ptaddr = tvb_get_letohs(tvb, offset);
1341 proto_tree_add_item(range_tree, hf_dnp3_al_range_abs16, tvb, offset, 2, TRUE);
1344 case AL_OBJQL_CODE_AA32: /* 32-bit Absolute Address in Range Field */
1346 PROTO_ITEM_SET_GENERATED(range_item);
1347 al_ptaddr = tvb_get_letohl(tvb, offset);
1348 proto_tree_add_item(range_tree, hf_dnp3_al_range_abs32, tvb, offset, 4, TRUE);
1351 case AL_OBJQL_CODE_SF8: /* 8-bit Single Field Quantity in Range Field */
1352 num_items = tvb_get_guint8(tvb, offset);
1353 proto_tree_add_item(range_tree, hf_dnp3_al_range_quant8, tvb, offset, 1, TRUE);
1355 proto_item_set_len(range_item, rangebytes);
1357 case AL_OBJQL_CODE_SF16: /* 16-bit Single Field Quantity in Range Field */
1358 num_items = tvb_get_letohs(tvb, offset);
1359 proto_tree_add_item(range_tree, hf_dnp3_al_range_quant16, tvb, offset, 2, TRUE);
1361 proto_item_set_len(range_item, rangebytes);
1363 case AL_OBJQL_CODE_SF32: /* 32-bit Single Field Quantity in Range Field */
1364 num_items = tvb_get_letohl(tvb, offset);
1365 proto_tree_add_item(range_tree, hf_dnp3_al_range_quant32, tvb, offset, 4, TRUE);
1367 proto_item_set_len(range_item, rangebytes);
1370 if (num_items > 0) {
1371 proto_item_append_text(object_item, ", %d point%s", num_items, plurality(num_items, "", "s"));
1373 proto_item_append_text(range_item, "%d", num_items);
1375 if (num_items < 0) {
1376 proto_item_append_text(range_item, " (bogus)");
1377 expert_add_info_format(pinfo, range_item, PI_MALFORMED, PI_ERROR, "Negative number of items");
1378 return tvb_length(tvb);
1382 offset += rangebytes;
1384 bitindex = 0; /* Temp variable for cycling through points when object values are encoded into
1385 bits; primarily objects 0x0101, 0x0301 & 0x1001 */
1387 /* Only process the point information for replies or items with point index lists */
1388 if (!header_only || al_objq_index > 0) {
1389 start_offset = offset;
1390 for (item_num = 0; item_num < num_items; item_num++)
1392 /* Create Point item and Process Index */
1393 point_item = proto_tree_add_text(object_tree, tvb, offset, 0, "Point Number");
1394 point_tree = proto_item_add_subtree(point_item, ett_dnp3_al_obj_point);
1397 indexbytes = dnp3_al_obj_procindex(tvb, offset, al_objq_index, &al_ptaddr, point_tree);
1398 proto_item_append_text(point_item, " %u", al_ptaddr);
1399 data_pos += indexbytes;
1405 case AL_OBJ_BI_ALL: /* Binary Input All Var (Obj:01, Var:All) */
1406 case AL_OBJ_BIC_ALL: /* Binary Input Change All Var (Obj:02, Var:All) */
1407 case AL_OBJ_2BI_ALL: /* Double-bit Input All Var (Obj:03, Var:All) */
1408 case AL_OBJ_CTR_ALL: /* Binary Counter All Var (Obj:20, Var:All) */
1409 case AL_OBJ_CTRC_ALL: /* Binary Counter Change All Var (Obj:22 Var:All) */
1410 case AL_OBJ_AI_ALL: /* Analog Input All Var (Obj:30, Var:All) */
1411 case AL_OBJ_AIC_ALL: /* Analog Input Change All Var (Obj:32 Var:All) */
1416 case AL_OBJ_BI_1BIT: /* Single-Bit Binary Input (Obj:01, Var:01) */
1417 case AL_OBJ_BO: /* Binary Output (Obj:10, Var:01) */
1419 /* Reset bit index if we've gone onto the next byte */
1423 offset += (indexbytes + 1);
1426 /* Extract the bit from the packed byte */
1427 al_bi_val = tvb_get_guint8(tvb, offset);
1428 al_bit = (al_bi_val & (1 << bitindex)) > 0;
1430 proto_item_append_text(point_item, ", Value: %u", al_bit);
1431 proto_tree_add_boolean(point_tree, hf_dnp3_al_bit, tvb, offset, 1, al_bit);
1432 proto_item_set_len(point_item, indexbytes + 1);
1434 /* If we've read the last item, then move the offset past this byte */
1435 if (item_num == (num_items-1))
1437 offset += (indexbytes + 1);
1442 case AL_OBJ_2BI_NF: /* Double-bit Input No Flags (Obj:03, Var:01) */
1447 offset += (indexbytes + 1);
1450 /* Extract the Double-bit from the packed byte */
1451 al_bi_val = tvb_get_guint8(tvb, offset);
1452 al_2bit = ((al_bi_val >> (bitindex << 1)) & 3);
1454 proto_item_append_text(point_item, ", Value: %u", al_2bit);
1455 proto_tree_add_uint(point_tree, hf_dnp3_al_2bit, tvb, offset, 1, al_2bit);
1456 proto_item_set_len(point_item, indexbytes + 1);
1458 /* If we've read the last item, then move the offset past this byte */
1459 if (item_num == (num_items-1))
1461 offset += (indexbytes + 1);
1467 case AL_OBJ_BI_STAT: /* Binary Input With Status (Obj:01, Var:02) */
1468 case AL_OBJ_BIC_NOTIME: /* Binary Input Change Without Time (Obj:02, Var:01) */
1469 case AL_OBJ_BO_STAT: /* Binary Output Status (Obj:10, Var:02) */
1471 /* Get Point Flags */
1472 al_ptflags = tvb_get_guint8(tvb, data_pos);
1475 case AL_OBJ_BI_STAT:
1476 case AL_OBJ_BIC_NOTIME:
1477 dnp3_al_obj_quality(tvb, data_pos, al_ptflags, point_tree, point_item, BIN_IN);
1479 case AL_OBJ_BO_STAT:
1480 dnp3_al_obj_quality(tvb, data_pos, al_ptflags, point_tree, point_item, BIN_OUT);
1485 al_bit = (al_ptflags & AL_OBJ_BI_FLAG7) > 0;
1486 proto_item_append_text(point_item, ", Value: %u", al_bit);
1488 proto_item_set_len(point_item, data_pos - offset);
1493 case AL_OBJ_2BI_STAT: /* Double-bit Input With Status (Obj:03, Var:02) */
1494 case AL_OBJ_2BIC_NOTIME: /* Double-bit Input Change Without Time (Obj:04, Var:01) */
1496 /* Get Point Flags */
1497 al_ptflags = tvb_get_guint8(tvb, data_pos);
1498 dnp3_al_obj_quality(tvb, data_pos, al_ptflags, point_tree, point_item, BIN_IN);
1501 al_2bit = (al_ptflags >> 6) & 3;
1502 proto_item_append_text(point_item, ", Value: %u", al_2bit);
1503 proto_item_set_len(point_item, data_pos - offset);
1508 case AL_OBJ_BIC_TIME: /* Binary Input Change w/ Time (Obj:02, Var:02) */
1510 /* Get Point Flags */
1511 al_ptflags = tvb_get_guint8(tvb, data_pos);
1512 dnp3_al_obj_quality(tvb, data_pos, al_ptflags, point_tree, point_item, BIN_IN);
1517 dnp3_al_get_timestamp(&al_abstime, tvb, data_pos);
1518 proto_tree_add_time(point_tree, hf_dnp3_al_timestamp, tvb, data_pos, 6, &al_abstime);
1521 al_bit = (al_ptflags & AL_OBJ_BI_FLAG7) >> 7; /* bit shift 1xxxxxxx -> xxxxxxx1 */
1522 proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_bit, abs_time_to_str(&al_abstime));
1523 proto_item_set_len(point_item, data_pos - offset);
1528 case AL_OBJ_2BIC_TIME: /* Double-bit Input Change w/ Time (Obj:04, Var:02) */
1530 /* Get Point Flags */
1531 al_ptflags = tvb_get_guint8(tvb, data_pos);
1532 dnp3_al_obj_quality(tvb, (offset+indexbytes), al_ptflags, point_tree, point_item, BIN_IN);
1537 dnp3_al_get_timestamp(&al_abstime, tvb, data_pos);
1538 proto_tree_add_time(point_tree, hf_dnp3_al_timestamp, tvb, data_pos, 6, &al_abstime);
1541 al_2bit = (al_ptflags >> 6) & 3; /* bit shift 11xxxxxx -> 00000011 */
1542 proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_2bit, abs_time_to_str(&al_abstime));
1543 proto_item_set_len(point_item, data_pos - offset);
1548 case AL_OBJ_BIC_RTIME: /* Binary Input Change w/ Relative Time (Obj:02, Var:03) */
1550 /* Get Point Flags */
1551 al_ptflags = tvb_get_guint8(tvb, data_pos);
1552 dnp3_al_obj_quality(tvb, data_pos, al_ptflags, point_tree, point_item, BIN_IN);
1555 /* Get relative time, and convert to ns_time */
1556 al_relms = tvb_get_letohs(tvb, data_pos);
1557 al_reltime.secs = al_relms / 1000;
1558 al_reltime.nsecs = (al_relms % 1000) * 1000;
1559 /* Now add to CTO time */
1560 nstime_sum(&al_abstime, &al_cto, &al_reltime);
1561 proto_tree_add_time(point_tree, hf_dnp3_al_rel_timestamp, tvb, data_pos, 2, &al_reltime);
1564 al_bit = (al_ptflags & AL_OBJ_BI_FLAG7) >> 7; /* bit shift 1xxxxxxx -> xxxxxxx1 */
1565 proto_item_append_text(point_item, ", Value: %u, Timestamp: %s", al_bit, abs_time_to_str(&al_abstime));
1566 proto_item_set_len(point_item, data_pos - offset);
1571 case AL_OBJ_CTLOP_BLK: /* Control Relay Output Block (Obj:12, Var:01) */
1573 al_ctlobj_code = tvb_get_guint8(tvb, data_pos);
1576 /* Bit-Mask xxxx1111 for Control Code 'Code' */
1577 al_ctlobj_code_c = al_ctlobj_code & AL_OBJCTLC_CODE;
1578 ctl_code_str = val_to_str(al_ctlobj_code_c, dnp3_al_ctlc_code_vals, "Ctrl Code Invalid (0x%02x)");
1580 /* Bit-Mask xx11xxxx for Control Code Misc Values */
1581 al_ctlobj_code_m = al_ctlobj_code & AL_OBJCTLC_MISC;
1582 ctl_misc_str = val_to_str(al_ctlobj_code_m, dnp3_al_ctlc_misc_vals, "");
1584 /* Bit-Mask 11xxxxxx for Control Code 'Trip/Close' */
1585 al_ctlobj_code_tc = al_ctlobj_code & AL_OBJCTLC_TC;
1586 ctl_tc_str = val_to_str(al_ctlobj_code_tc, dnp3_al_ctlc_tc_vals, "");
1588 /* Get "Count" Field */
1589 al_ctlobj_count = tvb_get_guint8(tvb, data_pos);
1592 /* Get "On Time" Field */
1593 al_ctlobj_on = tvb_get_letohl(tvb, data_pos);
1596 /* Get "Off Time" Field */
1597 al_ctlobj_off = tvb_get_letohl(tvb, data_pos);
1600 al_ctlobj_stat = tvb_get_guint8(tvb, data_pos);
1601 proto_tree_add_item(point_item, hf_dnp3_al_ctrlstatus, tvb, data_pos, 1, TRUE);
1602 ctl_status_str = val_to_str(al_ctlobj_stat, dnp3_al_ctl_status_vals, "Invalid Status (0x%02x)");
1605 proto_item_append_text(point_item, ", Control Code: [%s,%s,%s (0x%02x)]",
1606 ctl_code_str, ctl_misc_str, ctl_tc_str, al_ctlobj_code);
1608 proto_tree_add_text(point_tree, tvb, data_pos - 11, 11,
1609 " [Count: %u] [On-Time: %u] [Off-Time: %u] [Status: %s (0x%02x)]",
1610 al_ctlobj_count, al_ctlobj_on, al_ctlobj_off, ctl_status_str, al_ctlobj_stat);
1612 proto_item_set_len(point_item, data_pos - offset);
1617 case AL_OBJ_AO_32OPB: /* 32-Bit Analog Output Block (Obj:41, Var:01) */
1618 case AL_OBJ_AO_16OPB: /* 16-Bit Analog Output Block (Obj:41, Var:02) */
1619 case AL_OBJ_AO_FLTOPB: /* 32-Bit Floating Point Output Block (Obj:41, Var:03) */
1620 case AL_OBJ_AO_DBLOPB: /* 64-Bit Floating Point Output Block (Obj:41, Var:04) */
1624 case AL_OBJ_AO_32OPB:
1625 al_val32 = tvb_get_letohl(tvb, data_pos);
1626 proto_item_append_text(point_item, ", Value: %u", al_val32);
1627 proto_tree_add_item(point_tree, hf_dnp3_al_anaout32, tvb, data_pos, 4, TRUE);
1630 case AL_OBJ_AO_16OPB:
1631 al_val32 = tvb_get_letohs(tvb, data_pos);
1632 proto_item_append_text(point_item, ", Value: %u", al_val32);
1633 proto_tree_add_item(point_tree, hf_dnp3_al_anaout16, tvb, data_pos, 2, TRUE);
1636 case AL_OBJ_AO_FLTOPB:
1637 al_valflt = tvb_get_letohieee_float(tvb, data_pos);
1638 proto_item_append_text(point_item, ", Value: %g", al_valflt);
1639 proto_tree_add_item(point_tree, hf_dnp3_al_anaoutflt, tvb, data_pos, 4, TRUE);
1642 case AL_OBJ_AO_DBLOPB:
1643 al_valdbl = tvb_get_letohieee_double(tvb, data_pos);
1644 proto_item_append_text(point_item, ", Value: %lg", al_valdbl);
1645 proto_tree_add_item(point_tree, hf_dnp3_al_anaoutdbl, tvb, data_pos, 8, TRUE);
1650 /* Get control status */
1651 al_ctlobj_stat = tvb_get_guint8(tvb, data_pos);
1652 ctl_status_str = val_to_str(al_ctlobj_stat, dnp3_al_ctl_status_vals, "Invalid Status (0x%02x)");
1653 proto_item_append_text(point_item, " [Status: %s (0x%02x)]", ctl_status_str, al_ctlobj_stat);
1654 proto_tree_add_item(point_tree, hf_dnp3_al_ctrlstatus, tvb, data_pos, 1, TRUE);
1657 proto_item_set_len(point_item, data_pos - offset);
1662 case AL_OBJ_CTR_32: /* 32-Bit Binary Counter (Obj:20, Var:01) */
1663 case AL_OBJ_CTR_16: /* 16-Bit Binary Counter (Obj:20, Var:02) */
1664 case AL_OBJ_DCTR_32: /* 32-Bit Binary Delta Counter (Obj:20, Var:03) */
1665 case AL_OBJ_DCTR_16: /* 16-Bit Binary Delta Counter (Obj:20, Var:04) */
1666 case AL_OBJ_CTR_32NF: /* 32-Bit Binary Counter Without Flag (Obj:20, Var:05) */
1667 case AL_OBJ_CTR_16NF: /* 16-Bit Binary Counter Without Flag (Obj:20, Var:06) */
1668 case AL_OBJ_DCTR_32NF: /* 32-Bit Binary Delta Counter Without Flag (Obj:20, Var:07) */
1669 case AL_OBJ_DCTR_16NF: /* 16-Bit Binary Delta Counter Without Flag (Obj:20, Var:08) */
1670 case AL_OBJ_FCTR_32: /* 32-Bit Frozen Counter (Obj:21, Var:01) */
1671 case AL_OBJ_FCTR_16: /* 16-Bit Frozen Counter (Obj:21, Var:02) */
1672 case AL_OBJ_FDCTR_32: /* 21 03 32-Bit Frozen Delta Counter */
1673 case AL_OBJ_FDCTR_16: /* 21 04 16-Bit Frozen Delta Counter */
1674 case AL_OBJ_FCTR_32T: /* 21 05 32-Bit Frozen Counter w/ Time of Freeze */
1675 case AL_OBJ_FCTR_16T: /* 21 06 16-Bit Frozen Counter w/ Time of Freeze */
1676 case AL_OBJ_FDCTR_32T: /* 21 07 32-Bit Frozen Delta Counter w/ Time of Freeze */
1677 case AL_OBJ_FDCTR_16T: /* 21 08 16-Bit Frozen Delta Counter w/ Time of Freeze */
1678 case AL_OBJ_FCTR_32NF: /* 21 09 32-Bit Frozen Counter Without Flag */
1679 case AL_OBJ_FCTR_16NF: /* 21 10 16-Bit Frozen Counter Without Flag */
1680 case AL_OBJ_FDCTR_32NF: /* 21 11 32-Bit Frozen Delta Counter Without Flag */
1681 case AL_OBJ_FDCTR_16NF: /* 21 12 16-Bit Frozen Delta Counter Without Flag */
1682 case AL_OBJ_CTRC_32: /* 32-Bit Counter Change Event w/o Time (Obj:22, Var:01) */
1683 case AL_OBJ_CTRC_16: /* 16-Bit Counter Change Event w/o Time (Obj:22, Var:02) */
1684 case AL_OBJ_DCTRC_32: /* 32-Bit Delta Counter Change Event w/o Time (Obj:22, Var:03) */
1685 case AL_OBJ_DCTRC_16: /* 16-Bit Delta Counter Change Event w/o Time (Obj:22, Var:04) */
1686 case AL_OBJ_CTRC_32T: /* 32-Bit Counter Change Event with Time (Obj:22, Var:05) */
1687 case AL_OBJ_CTRC_16T: /* 16-Bit Counter Change Event with Time (Obj:22, Var:06) */
1688 case AL_OBJ_DCTRC_32T: /* 32-Bit Delta Counter Change Event with Time (Obj:22, Var:07) */
1689 case AL_OBJ_DCTRC_16T: /* 16-Bit Delta Counter Change Event with Time (Obj:22, Var:08) */
1690 case AL_OBJ_FCTRC_32: /* 21 01 32-Bit Frozen Counter Change Event */
1691 case AL_OBJ_FCTRC_16: /* 21 02 16-Bit Frozen Counter Change Event */
1692 case AL_OBJ_FDCTRC_32: /* 21 03 32-Bit Frozen Delta Counter Change Event */
1693 case AL_OBJ_FDCTRC_16: /* 21 04 16-Bit Frozen Delta Counter Change Event */
1694 case AL_OBJ_FCTRC_32T: /* 21 05 32-Bit Frozen Counter Change Event w/ Time of Freeze */
1695 case AL_OBJ_FCTRC_16T: /* 21 06 16-Bit Frozen Counter Change Event w/ Time of Freeze */
1696 case AL_OBJ_FDCTRC_32T: /* 21 07 32-Bit Frozen Delta Counter Change Event w/ Time of Freeze */
1697 case AL_OBJ_FDCTRC_16T: /* 21 08 16-Bit Frozen Delta Counter Change Event w/ Time of Freeze */
1699 /* Get Point Flags for those types that have them, it's easier to block out those that don't have flags */
1702 case AL_OBJ_CTR_32NF:
1703 case AL_OBJ_CTR_16NF:
1704 case AL_OBJ_DCTR_32NF:
1705 case AL_OBJ_DCTR_16NF:
1706 case AL_OBJ_FCTR_32NF:
1707 case AL_OBJ_FCTR_16NF:
1708 case AL_OBJ_FDCTR_32NF:
1709 case AL_OBJ_FDCTR_16NF:
1713 al_ptflags = tvb_get_guint8(tvb, data_pos);
1714 dnp3_al_obj_quality(tvb, data_pos, al_ptflags, point_tree, point_item, COUNTER);
1719 /* Get Counter values */
1723 case AL_OBJ_DCTR_32:
1724 case AL_OBJ_CTR_32NF:
1725 case AL_OBJ_DCTR_32NF:
1726 case AL_OBJ_FCTR_32:
1727 case AL_OBJ_FDCTR_32:
1728 case AL_OBJ_FCTR_32T:
1729 case AL_OBJ_FDCTR_32T:
1730 case AL_OBJ_FCTR_32NF:
1731 case AL_OBJ_FDCTR_32NF:
1732 case AL_OBJ_CTRC_32:
1733 case AL_OBJ_DCTRC_32:
1734 case AL_OBJ_CTRC_32T:
1735 case AL_OBJ_DCTRC_32T:
1736 case AL_OBJ_FCTRC_32:
1737 case AL_OBJ_FDCTRC_32:
1738 case AL_OBJ_FCTRC_32T:
1739 case AL_OBJ_FDCTRC_32T:
1741 al_val32 = tvb_get_letohl(tvb, data_pos);
1742 proto_item_append_text(point_item, ", Count: %u", al_val32);
1743 proto_tree_add_item(point_tree, hf_dnp3_al_cnt32, tvb, data_pos, 4, TRUE);
1748 case AL_OBJ_DCTR_16:
1749 case AL_OBJ_CTR_16NF:
1750 case AL_OBJ_DCTR_16NF:
1751 case AL_OBJ_FCTR_16:
1752 case AL_OBJ_FDCTR_16:
1753 case AL_OBJ_FCTR_16T:
1754 case AL_OBJ_FDCTR_16T:
1755 case AL_OBJ_FCTR_16NF:
1756 case AL_OBJ_FDCTR_16NF:
1757 case AL_OBJ_CTRC_16:
1758 case AL_OBJ_DCTRC_16:
1759 case AL_OBJ_CTRC_16T:
1760 case AL_OBJ_DCTRC_16T:
1761 case AL_OBJ_FCTRC_16:
1762 case AL_OBJ_FDCTRC_16:
1763 case AL_OBJ_FCTRC_16T:
1764 case AL_OBJ_FDCTRC_16T:
1766 al_val16 = tvb_get_letohs(tvb, data_pos);
1767 proto_item_append_text(point_item, ", Count: %u", al_val16);
1768 proto_tree_add_item(point_tree, hf_dnp3_al_cnt16, tvb, data_pos, 2, TRUE);
1773 /* Get the time for those points that have it */
1776 case AL_OBJ_FCTR_32T:
1777 case AL_OBJ_FCTR_16T:
1778 case AL_OBJ_FDCTR_32T:
1779 case AL_OBJ_FDCTR_16T:
1780 case AL_OBJ_CTRC_32T:
1781 case AL_OBJ_CTRC_16T:
1782 case AL_OBJ_DCTRC_32T:
1783 case AL_OBJ_DCTRC_16T:
1784 case AL_OBJ_FCTRC_32T:
1785 case AL_OBJ_FCTRC_16T:
1786 case AL_OBJ_FDCTRC_32T:
1787 case AL_OBJ_FDCTRC_16T:
1788 dnp3_al_get_timestamp(&al_abstime, tvb, data_pos);
1789 proto_item_append_text(point_item, ", Timestamp: %s", abs_time_to_str(&al_abstime));
1790 proto_tree_add_time(point_tree, hf_dnp3_al_timestamp, tvb, data_pos, 6, &al_abstime);
1795 proto_item_set_len(point_item, data_pos - offset);
1800 case AL_OBJ_AI_32: /* 32-Bit Analog Input (Obj:30, Var:01) */
1801 case AL_OBJ_AI_16: /* 16-Bit Analog Input (Obj:30, Var:02) */
1802 case AL_OBJ_AI_32NF: /* 32-Bit Analog Input Without Flag (Obj:30, Var:03) */
1803 case AL_OBJ_AI_16NF: /* 16-Bit Analog Input Without Flag (Obj:30, Var:04) */
1804 case AL_OBJ_AI_FLT: /* 32-Bit Floating Point Input (Obj:30, Var:05) */
1805 case AL_OBJ_AI_DBL: /* 64-Bit Floating Point Input (Obj:30, Var:06) */
1806 case AL_OBJ_AIF_FLT: /* 32-Bit Frozen Floating Point Input (Obj:31, Var:07) */
1807 case AL_OBJ_AIF_DBL: /* 64-Bit Frozen Floating Point Input (Obj:31, Var:08) */
1808 case AL_OBJ_AIC_32NT: /* 32-Bit Analog Change Event w/o Time (Obj:32, Var:01) */
1809 case AL_OBJ_AIC_16NT: /* 16-Bit Analog Change Event w/o Time (Obj:32, Var:02) */
1810 case AL_OBJ_AIC_32T: /* 32-Bit Analog Change Event with Time (Obj:32, Var:03) */
1811 case AL_OBJ_AIC_16T: /* 16-Bit Analog Change Event with Time (Obj:32, Var:04) */
1812 case AL_OBJ_AIC_FLTNT: /* 32-Bit Floating Point Change Event w/o Time (Obj:32, Var:05) */
1813 case AL_OBJ_AIC_DBLNT: /* 64-Bit Floating Point Change Event w/o Time (Obj:32, Var:06) */
1814 case AL_OBJ_AIC_FLTT: /* 32-Bit Floating Point Change Event w/ Time (Obj:32, Var:07) */
1815 case AL_OBJ_AIC_DBLT: /* 64-Bit Floating Point Change Event w/ Time (Obj:32, Var:08) */
1816 case AL_OBJ_AIFC_FLTNT: /* 32-Bit Floating Point Frozen Change Event w/o Time (Obj:33, Var:05) */
1817 case AL_OBJ_AIFC_DBLNT: /* 64-Bit Floating Point Frozen Change Event w/o Time (Obj:33, Var:06) */
1818 case AL_OBJ_AIFC_FLTT: /* 32-Bit Floating Point Frozen Change Event w/ Time (Obj:33, Var:07) */
1819 case AL_OBJ_AIFC_DBLT: /* 64-Bit Floating Point Frozen Change Event w/ Time (Obj:33, Var:08) */
1821 /* Get Point Flags for those types that have them */
1824 case AL_OBJ_AI_32NF:
1825 case AL_OBJ_AI_16NF:
1829 al_ptflags = tvb_get_guint8(tvb, data_pos);
1830 dnp3_al_obj_quality(tvb, data_pos, al_ptflags, point_tree, point_item, ANA_IN);
1838 case AL_OBJ_AI_32NF:
1839 case AL_OBJ_AIC_32NT:
1840 case AL_OBJ_AIC_32T:
1842 al_val32 = tvb_get_letohl(tvb, data_pos);
1843 proto_item_append_text(point_item, ", Value: %u", al_val32);
1844 proto_tree_add_item(point_tree, hf_dnp3_al_ana32, tvb, data_pos, 4, TRUE);
1849 case AL_OBJ_AI_16NF:
1850 case AL_OBJ_AIC_16NT:
1851 case AL_OBJ_AIC_16T:
1853 al_val16 = tvb_get_letohs(tvb, data_pos);
1854 proto_item_append_text(point_item, ", Value: %u", al_val16);
1855 proto_tree_add_item(point_tree, hf_dnp3_al_ana16, tvb, data_pos, 2, TRUE);
1860 case AL_OBJ_AIF_FLT:
1861 case AL_OBJ_AIC_FLTNT:
1862 case AL_OBJ_AIC_FLTT:
1863 case AL_OBJ_AIFC_FLTNT:
1864 case AL_OBJ_AIFC_FLTT:
1866 al_valflt = tvb_get_letohieee_float(tvb, data_pos);
1867 proto_item_append_text(point_item, ", Value: %g", al_valflt);
1868 proto_tree_add_item(point_tree, hf_dnp3_al_anaflt, tvb, data_pos, 4, TRUE);
1873 case AL_OBJ_AIF_DBL:
1874 case AL_OBJ_AIC_DBLNT:
1875 case AL_OBJ_AIC_DBLT:
1876 case AL_OBJ_AIFC_DBLNT:
1877 case AL_OBJ_AIFC_DBLT:
1879 al_valdbl = tvb_get_letohieee_double(tvb, data_pos);
1880 proto_item_append_text(point_item, ", Value: %lg", al_valdbl);
1881 proto_tree_add_item(point_tree, hf_dnp3_al_anadbl, tvb, data_pos, 8, TRUE);
1889 case AL_OBJ_AIC_32T:
1890 case AL_OBJ_AIC_16T:
1891 case AL_OBJ_AIC_FLTT:
1892 case AL_OBJ_AIC_DBLT:
1893 case AL_OBJ_AIFC_FLTT:
1894 case AL_OBJ_AIFC_DBLT:
1895 dnp3_al_get_timestamp(&al_abstime, tvb, data_pos);
1896 proto_item_append_text(point_item, ", Timestamp: %s", abs_time_to_str(&al_abstime));
1897 proto_tree_add_time(point_tree, hf_dnp3_al_timestamp, tvb, data_pos, 6, &al_abstime);
1902 proto_item_set_len(point_item, data_pos - offset);
1907 case AL_OBJ_AO_32: /* 32-Bit Analog Output Status (Obj:40, Var:01) */
1908 case AL_OBJ_AO_16: /* 16-Bit Analog Output Status (Obj:40, Var:02) */
1909 case AL_OBJ_AO_FLT: /* 32-Bit Floating Point Output Status (Obj:40, Var:03) */
1910 case AL_OBJ_AO_DBL: /* 64-Bit Floating Point Output Status (Obj:40, Var:04) */
1912 /* Get Point Flags */
1913 al_ptflags = tvb_get_guint8(tvb, data_pos);
1914 dnp3_al_obj_quality(tvb, data_pos, al_ptflags, point_tree, point_item, ANA_OUT);
1919 case AL_OBJ_AO_32: /* 32-Bit Analog Output Status (Obj:40, Var:01) */
1921 al_val32 = tvb_get_letohl(tvb, data_pos);
1922 proto_item_append_text(point_item, ", Value: %u", al_val32);
1923 proto_tree_add_item(point_tree, hf_dnp3_al_anaout32, tvb, data_pos, 4, TRUE);
1927 case AL_OBJ_AO_16: /* 16-Bit Analog Output Status (Obj:40, Var:02) */
1929 al_val16 = tvb_get_letohs(tvb, data_pos);
1930 proto_item_append_text(point_item, ", Value: %u", al_val16);
1931 proto_tree_add_item(point_tree, hf_dnp3_al_anaout16, tvb, data_pos, 2, TRUE);
1935 case AL_OBJ_AO_FLT: /* 32-Bit Floating Point Output Status (Obj:40, Var:03) */
1937 al_valflt = tvb_get_letohieee_float(tvb, data_pos);
1938 proto_item_append_text(point_item, ", Value: %g", al_valflt);
1939 proto_tree_add_item(point_tree, hf_dnp3_al_anaoutflt, tvb, data_pos, 4, TRUE);
1943 case AL_OBJ_AO_DBL: /* 64-Bit Floating Point Output Status (Obj:40, Var:04) */
1945 al_valdbl = tvb_get_letohieee_double(tvb, data_pos);
1946 proto_item_append_text(point_item, ", Value: %lg", al_valdbl);
1947 proto_tree_add_item(point_tree, hf_dnp3_al_anaoutdbl, tvb, data_pos, 8, TRUE);
1952 proto_item_set_len(point_item, data_pos - offset);
1957 case AL_OBJ_TD: /* Time and Date (Obj:50, Var:01) */
1958 case AL_OBJ_TDCTO: /* Time and Date CTO (Obj:51, Var:01) */
1960 dnp3_al_get_timestamp(&al_cto, tvb, data_pos);
1961 proto_tree_add_time(object_tree, hf_dnp3_al_timestamp, tvb, data_pos, 6, &al_cto);
1963 proto_item_set_len(point_item, data_pos - offset);
1968 case AL_OBJ_TDELAYF: /* Time Delay - Fine (Obj:52, Var:02) */
1970 al_val16 = tvb_get_letohs(tvb, data_pos);
1971 proto_tree_add_text(object_tree, tvb, data_pos, 2, "Time Delay: %u ms", al_val16);
1973 proto_item_set_len(point_item, data_pos - offset);
1978 case AL_OBJ_CLASS0: /* Class Data Objects */
1987 case AL_OBJ_IIN: /* IIN Data Object */
1989 /* Single byte of data here */
1990 proto_tree_add_text(object_tree, tvb, data_pos, 1, "Value: %u", tvb_get_guint8(tvb, data_pos));
1992 proto_item_set_len(point_item, data_pos - offset);
1997 case AL_OBJ_OCT: /* Octet string */
1999 /* read the number of bytes defined by the variation */
2000 if (al_oct_len > 0) {
2001 proto_tree_add_text(object_tree, tvb, data_pos, al_oct_len, "Octet String (%u bytes)", al_oct_len);
2002 data_pos += al_oct_len;
2003 proto_item_set_len(point_item, data_pos - offset);
2009 default: /* In case of unknown object */
2011 proto_tree_add_text(object_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset),
2012 "Unknown Data Chunk, %u Bytes", tvb_reported_length_remaining(tvb, offset));
2013 offset = tvb_length(tvb); /* Finish decoding if unknown object is encountered... */
2016 /* Increment the bit index for next time */
2019 /* And increment the point address, may be overwritten by an index value */
2022 if (start_offset > offset) {
2023 expert_add_info_format(pinfo, point_item, PI_MALFORMED, PI_ERROR, "Invalid length");
2024 offset = tvb_length(tvb); /* Finish decoding if unknown object is encountered... */
2028 proto_item_set_len(object_item, offset - orig_offset);
2033 /*****************************************************************/
2034 /* Application Layer Dissector */
2035 /*****************************************************************/
2037 dissect_dnp3_al(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2039 guint8 al_ctl, al_seq, al_func, al_class = 0, i;
2040 guint16 bytes, obj_type;
2041 gboolean al_fir, al_fin, al_con;
2042 guint data_len = 0, offset = 0;
2043 proto_item *ti = NULL, *tc, *t_robj;
2044 proto_tree *al_tree = NULL, *field_tree = NULL, *robj_tree = NULL;
2045 const gchar *func_code_str;
2047 data_len = tvb_length(tvb);
2049 /* Handle the control byte and function code */
2050 al_ctl = tvb_get_guint8(tvb, offset);
2051 al_seq = al_ctl & DNP3_AL_SEQ;
2052 al_fir = al_ctl & DNP3_AL_FIR;
2053 al_fin = al_ctl & DNP3_AL_FIN;
2054 al_con = al_ctl & DNP3_AL_CON;
2055 al_func = tvb_get_guint8(tvb, (offset+1));
2056 func_code_str = val_to_str(al_func, dnp3_al_func_vals, "Unknown function (0x%02x)");
2058 if (check_col(pinfo->cinfo, COL_INFO))
2059 col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "%s", func_code_str);
2060 col_set_fence(pinfo->cinfo, COL_INFO);
2062 /* format up the text representation */
2063 ti = proto_tree_add_text(tree, tvb, offset, data_len, "Application Layer: (");
2064 if (al_ctl & DNP3_AL_FIR) proto_item_append_text(ti, "FIR, ");
2065 if (al_ctl & DNP3_AL_FIN) proto_item_append_text(ti, "FIN, ");
2066 if (al_ctl & DNP3_AL_CON) proto_item_append_text(ti, "CON, ");
2067 proto_item_append_text(ti, "Sequence %u, %s)", al_seq, func_code_str);
2069 /* Add the al tree branch */
2070 al_tree = proto_item_add_subtree(ti, ett_dnp3_al);
2072 /* Application Layer control byte subtree */
2073 tc = proto_tree_add_uint_format(al_tree, hf_dnp3_al_ctl, tvb, offset, 1, al_ctl,
2074 "Control: 0x%02x (", al_ctl);
2075 if (al_ctl & DNP3_AL_FIR) proto_item_append_text(tc, "FIR, ");
2076 if (al_ctl & DNP3_AL_FIN) proto_item_append_text(tc, "FIN, ");
2077 if (al_ctl & DNP3_AL_CON) proto_item_append_text(tc, "CON, ");
2078 proto_item_append_text(tc, "Sequence %u)", al_seq);
2080 field_tree = proto_item_add_subtree(tc, ett_dnp3_al_ctl);
2081 proto_tree_add_boolean(field_tree, hf_dnp3_al_fir, tvb, offset, 1, al_ctl);
2082 proto_tree_add_boolean(field_tree, hf_dnp3_al_fin, tvb, offset, 1, al_ctl);
2083 proto_tree_add_boolean(field_tree, hf_dnp3_al_con, tvb, offset, 1, al_ctl);
2084 proto_tree_add_item(field_tree, hf_dnp3_al_seq, tvb, offset, 1, FALSE);
2087 /* If this packet is NOT the final Application Layer Message, exit and continue
2088 processing the remaining data in the fragment.
2091 t_robj = proto_tree_add_text(al_tree, tvb, offset, -1, "Buffering User Data Until Final Frame is Received..");
2095 /* Application Layer Function Code Byte */
2096 proto_tree_add_uint_format(al_tree, hf_dnp3_al_func, tvb, offset, 1, al_func,
2097 "Function Code: %s (0x%02x)", func_code_str, al_func);
2102 case AL_FUNC_READ: /* Read Function Code 0x01 */
2104 /* Create Read Request Data Objects Tree */
2105 t_robj = proto_tree_add_text(al_tree, tvb, offset, -1, "READ Request Data Objects");
2106 robj_tree = proto_item_add_subtree(t_robj, ett_dnp3_al_objdet);
2108 /* Process Data Object Details */
2109 while (offset <= (data_len-2)) { /* 2 octet object code + CRC32 */
2110 offset = dnp3_al_process_object(tvb, pinfo, offset, robj_tree, TRUE, &obj_type);
2112 /* Update class type for each object that was a class read */
2118 al_class |= (1 << ((obj_type & 0x0f) - 1));
2125 /* Update the col info if there were class reads */
2126 if (check_col(pinfo->cinfo, COL_INFO) && (al_class > 0)) {
2127 col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Class ");
2128 for (i = 0; i < 4; i++) {
2129 if (al_class & (1 << i)) {
2130 col_append_fstr(pinfo->cinfo, COL_INFO, "%u", i);
2137 case AL_FUNC_WRITE: /* Write Function Code 0x02 */
2139 /* Create Write Request Data Objects Tree */
2140 t_robj = proto_tree_add_text(al_tree, tvb, offset, -1, "WRITE Request Data Objects");
2141 robj_tree = proto_item_add_subtree(t_robj, ett_dnp3_al_objdet);
2143 /* Process Data Object Details */
2144 while (offset <= (data_len-2)) { /* 2 octet object code + CRC32 */
2145 offset = dnp3_al_process_object(tvb, pinfo, offset, robj_tree, FALSE, &obj_type);
2150 case AL_FUNC_SELECT: /* Select Function Code 0x03 */
2152 /* Create Select Request Data Objects Tree */
2153 t_robj = proto_tree_add_text(al_tree, tvb, offset, -1, "SELECT Request Data Objects");
2154 robj_tree = proto_item_add_subtree(t_robj, ett_dnp3_al_objdet);
2156 /* Process Data Object Details */
2157 while (offset <= (data_len-2)) { /* 2 octet object code + CRC32 */
2158 offset = dnp3_al_process_object(tvb, pinfo, offset, robj_tree, FALSE, &obj_type);
2163 case AL_FUNC_OPERATE: /* Operate Function Code 0x04 */
2164 /* Functionally identical to 'SELECT' Function Code */
2166 /* Create Operate Request Data Objects Tree */
2167 t_robj = proto_tree_add_text(al_tree, tvb, offset, -1, "OPERATE Request Data Objects");
2168 robj_tree = proto_item_add_subtree(t_robj, ett_dnp3_al_objdet);
2170 /* Process Data Object Details */
2171 while (offset <= (data_len-2)) { /* 2 octet object code + CRC32 */
2172 offset = dnp3_al_process_object(tvb, pinfo, offset, robj_tree, FALSE, &obj_type);
2177 case AL_FUNC_DIROP: /* Direct Operate Function Code 0x05 */
2178 /* Functionally identical to 'SELECT' Function Code */
2180 /* Create Direct Operate Request Data Objects Tree */
2181 t_robj = proto_tree_add_text(al_tree, tvb, offset, -1, "DIRECT OPERATE Request Data Objects");
2182 robj_tree = proto_item_add_subtree(t_robj, ett_dnp3_al_objdet);
2184 /* Process Data Object Details */
2185 while (offset <= (data_len-2)) { /* 2 octet object code + CRC32 */
2186 offset = dnp3_al_process_object(tvb, pinfo, offset, robj_tree, FALSE, &obj_type);
2191 case AL_FUNC_ENSPMSG: /* Enable Spontaneous Messages Function Code 0x14 */
2193 /* Create Enable Spontaneous Messages Data Objects Tree */
2194 t_robj = proto_tree_add_text(al_tree, tvb, offset, -1, "Enable Spontaneous Msg's Data Objects");
2195 robj_tree = proto_item_add_subtree(t_robj, ett_dnp3_al_objdet);
2197 /* Process Data Object Details */
2198 while (offset <= (data_len-2)) { /* 2 octet object code + CRC32 */
2199 offset = dnp3_al_process_object(tvb, pinfo, offset, robj_tree, FALSE, &obj_type);
2204 case AL_FUNC_DELAYMST: /* Delay Measurement Function Code 0x17 */
2208 case AL_FUNC_RESPON: /* Response Function Code 0x81 */
2209 case AL_FUNC_UNSOLI: /* Unsolicited Response Function Code 0x82 */
2211 /* Application Layer IIN bits req'd if message is a response */
2212 dnp3_al_process_iin(tvb, offset, al_tree);
2215 /* Ensure there is actual data remaining in the message.
2216 A response will not contain data following the IIN bits,
2217 if there is none available */
2218 bytes = tvb_reported_length_remaining(tvb, offset);
2221 /* Create Response Data Objects Tree */
2222 t_robj = proto_tree_add_text(al_tree, tvb, offset, -1,"RESPONSE Data Objects");
2223 robj_tree = proto_item_add_subtree(t_robj, ett_dnp3_al_objdet);
2225 /* Process Data Object Details */
2226 while (offset <= (data_len-2)) { /* 2 octet object code + CRC32 */
2227 offset = dnp3_al_process_object(tvb, pinfo, offset, robj_tree, FALSE, &obj_type);
2233 default: /* Unknown Function */
2241 /*****************************************************************/
2242 /* Data Link and Transport layer dissector */
2243 /*****************************************************************/
2245 dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2248 /* Set up structures needed to add the protocol subtree and manage it */
2249 proto_item *ti = NULL, *tdl, *tc, *al_chunks, *hidden_item;
2250 proto_tree *dnp3_tree = NULL, *dl_tree = NULL, *tr_tree = NULL, *field_tree = NULL, *al_tree = NULL;
2251 int offset = 0, temp_offset = 0, al_result = 0;
2252 gboolean dl_prm, tr_fir, tr_fin;
2253 guint8 dl_len, dl_ctl, dl_func, tr_ctl, tr_seq;
2254 const gchar *func_code_str;
2255 guint16 dl_dst, dl_src, dl_crc, calc_dl_crc;
2256 guint8 *tmp = NULL, *tmp_ptr;
2259 gboolean crc_OK = FALSE;
2260 tvbuff_t *al_tvb = NULL, *next_tvb;
2262 guint conv_seq_number;
2263 gboolean save_fragmented;
2264 fragment_data *frag_msg;
2265 gboolean update_col_info = TRUE;
2266 conversation_t *conversation;
2267 dnp3_conv_t *conv_data_ptr;
2271 /* Make entries in Protocol column and Info column on summary display */
2272 if (check_col(pinfo->cinfo, COL_PROTOCOL))
2273 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DNP 3.0");
2275 if (check_col(pinfo->cinfo, COL_INFO))
2276 col_clear(pinfo->cinfo, COL_INFO);
2278 /* Skip "0x0564" header bytes */
2281 dl_len = tvb_get_guint8(tvb, temp_offset);
2284 dl_ctl = tvb_get_guint8(tvb, temp_offset);
2287 dl_dst = tvb_get_letohs(tvb, temp_offset);
2290 dl_src = tvb_get_letohs(tvb, temp_offset);
2292 dl_func = dl_ctl & DNP3_CTL_FUNC;
2293 dl_prm = dl_ctl & DNP3_CTL_PRM;
2294 func_code_str = val_to_str(dl_func, dl_prm ? dnp3_ctl_func_pri_vals : dnp3_ctl_func_sec_vals,
2295 "Unknown function (0x%02x)");
2297 if (check_col(pinfo->cinfo, COL_INFO))
2298 col_append_fstr(pinfo->cinfo, COL_INFO, "len=%u, from %u to %u, %s",
2299 dl_len, dl_src, dl_dst, func_code_str);
2301 /* create display subtree for the protocol */
2302 ti = proto_tree_add_item(tree, proto_dnp3, tvb, offset, -1, FALSE);
2303 dnp3_tree = proto_item_add_subtree(ti, ett_dnp3);
2305 /* Create Subtree for Data Link Layer */
2306 tdl = proto_tree_add_text(dnp3_tree, tvb, offset, DNP_HDR_LEN,
2307 "Data Link Layer, Len: %u, From: %u, To: %u, ", dl_len, dl_src, dl_dst);
2309 if (dl_ctl & DNP3_CTL_DIR) proto_item_append_text(tdl, "DIR, ");
2310 if (dl_ctl & DNP3_CTL_PRM) proto_item_append_text(tdl, "PRM, ");
2311 if (dl_ctl & DNP3_CTL_FCB) proto_item_append_text(tdl, "FCB, ");
2312 if (dl_ctl & DNP3_CTL_FCV) proto_item_append_text(tdl, "FCV, ");
2315 if (dl_ctl & DNP3_CTL_DIR) proto_item_append_text(tdl, "DIR, ");
2316 if (dl_ctl & DNP3_CTL_PRM) proto_item_append_text(tdl, "PRM, ");
2317 if (dl_ctl & DNP3_CTL_RES) proto_item_append_text(tdl, "RES, ");
2318 if (dl_ctl & DNP3_CTL_DFC) proto_item_append_text(tdl, "DFC, ");
2320 proto_item_append_text(tdl, func_code_str);
2321 dl_tree = proto_item_add_subtree(tdl, ett_dnp3_dl);
2324 proto_tree_add_item(dl_tree, hf_dnp3_start, tvb, offset, 2, FALSE);
2327 /* add length field */
2328 proto_tree_add_item(dl_tree, hf_dnp3_len, tvb, offset, 1, FALSE);
2331 /* Add Control Byte Subtree */
2332 tc = proto_tree_add_uint_format(dl_tree, hf_dnp3_ctl, tvb, offset, 1, dl_ctl,
2333 "Control: 0x%02x (", dl_ctl);
2334 /* Add Text to Control Byte Subtree Header */
2336 if (dl_ctl & DNP3_CTL_DIR) proto_item_append_text(tc, "DIR, ");
2337 if (dl_ctl & DNP3_CTL_PRM) proto_item_append_text(tc, "PRM, ");
2338 if (dl_ctl & DNP3_CTL_FCB) proto_item_append_text(tc, "FCB, ");
2339 if (dl_ctl & DNP3_CTL_FCV) proto_item_append_text(tc, "FCV, ");
2342 if (dl_ctl & DNP3_CTL_DIR) proto_item_append_text(tc, "DIR, ");
2343 if (dl_ctl & DNP3_CTL_PRM) proto_item_append_text(tc, "PRM, ");
2344 if (dl_ctl & DNP3_CTL_RES) proto_item_append_text(tc, "RES, ");
2345 if (dl_ctl & DNP3_CTL_DFC) proto_item_append_text(tc, "DFC, ");
2347 proto_item_append_text(tc, "%s)", func_code_str );
2348 field_tree = proto_item_add_subtree(tc, ett_dnp3_dl_ctl);
2350 /* Add Control Byte Subtree Items */
2352 proto_tree_add_item(field_tree, hf_dnp3_ctl_dir, tvb, offset, 1, TRUE);
2353 proto_tree_add_item(field_tree, hf_dnp3_ctl_prm, tvb, offset, 1, TRUE);
2354 proto_tree_add_item(field_tree, hf_dnp3_ctl_fcb, tvb, offset, 1, TRUE);
2355 proto_tree_add_item(field_tree, hf_dnp3_ctl_fcv, tvb, offset, 1, TRUE);
2356 proto_tree_add_item(field_tree, hf_dnp3_ctl_prifunc, tvb, offset, 1, FALSE);
2359 proto_tree_add_item(field_tree, hf_dnp3_ctl_dir, tvb, offset, 1, TRUE);
2360 proto_tree_add_item(field_tree, hf_dnp3_ctl_prm, tvb, offset, 1, TRUE);
2361 proto_tree_add_item(field_tree, hf_dnp3_ctl_dfc, tvb, offset, 1, TRUE);
2362 proto_tree_add_item(field_tree, hf_dnp3_ctl_secfunc, tvb, offset, 1, FALSE);
2366 /* add destination and source addresses */
2367 proto_tree_add_item(dl_tree, hf_dnp3_dst, tvb, offset, 2, TRUE);
2369 proto_tree_add_item(dl_tree, hf_dnp3_src, tvb, offset, 2, TRUE);
2372 /* and header CRC */
2373 dl_crc = tvb_get_letohs(tvb, offset);
2374 calc_dl_crc = calculateCRC(tvb_get_ptr(tvb, 0, DNP_HDR_LEN - 2), DNP_HDR_LEN - 2);
2375 if (dl_crc == calc_dl_crc)
2376 proto_tree_add_uint_format(dl_tree, hf_dnp_hdr_CRC, tvb, offset, 2,
2377 dl_crc, "CRC: 0x%04x [correct]", dl_crc);
2380 hidden_item = proto_tree_add_boolean(dl_tree, hf_dnp_hdr_CRC_bad, tvb,
2382 PROTO_ITEM_SET_HIDDEN(hidden_item);
2383 proto_tree_add_uint_format(dl_tree, hf_dnp_hdr_CRC, tvb, offset, 2,
2384 dl_crc, "CRC: 0x%04x [incorrect, should be 0x%04x]",
2385 dl_crc, calc_dl_crc);
2389 /* If the DataLink function is 'Request Link Status' or 'Status of Link',
2390 or 'Reset Link' we don't expect any Transport or Application Layer Data
2391 NOTE: This code should probably check what DOES have TR or AL data */
2392 if ((dl_func != DL_FUNC_LINK_STAT) && (dl_func != DL_FUNC_STAT_LINK) &&
2393 (dl_func != DL_FUNC_RESET_LINK) && (dl_func != DL_FUNC_ACK))
2396 /* get the transport layer byte */
2397 tr_ctl = tvb_get_guint8(tvb, offset);
2398 tr_seq = tr_ctl & DNP3_TR_SEQ;
2399 tr_fir = tr_ctl & DNP3_TR_FIR;
2400 tr_fin = tr_ctl & DNP3_TR_FIN;
2402 /* Add Transport Layer Tree */
2403 tc = proto_tree_add_uint_format(dnp3_tree, hf_dnp3_tr_ctl, tvb, offset, 1, tr_ctl,
2404 "Transport Layer: 0x%02x (", tr_ctl);
2405 if (tr_fir) proto_item_append_text(tc, "FIR, ");
2406 if (tr_fin) proto_item_append_text(tc, "FIN, ");
2407 proto_item_append_text(tc, "Sequence %u)", tr_seq);
2409 tr_tree = proto_item_add_subtree(tc, ett_dnp3_tr_ctl);
2410 proto_tree_add_boolean(tr_tree, hf_dnp3_tr_fin, tvb, offset, 1, tr_ctl);
2411 proto_tree_add_boolean(tr_tree, hf_dnp3_tr_fir, tvb, offset, 1, tr_ctl);
2412 proto_tree_add_item(tr_tree, hf_dnp3_tr_seq, tvb, offset, 1, FALSE);
2414 /* Allocate AL chunk tree */
2415 al_chunks = proto_tree_add_text(tr_tree, tvb, offset + 1, -1, "Application data chunks");
2416 al_tree = proto_item_add_subtree(al_chunks, ett_dnp3_al_data);
2418 /* extract the application layer data, validating the CRCs */
2420 /* XXX - check for dl_len <= 5 */
2421 data_len = dl_len - 5;
2422 tmp = ep_alloc(data_len);
2425 data_offset = 1; /* skip the transport layer byte when assembling chunks */
2429 const guint8 *chk_ptr;
2430 guint16 calc_crc, act_crc;
2432 chk_size = MIN(data_len, AL_MAX_CHUNK_SIZE);
2433 chk_ptr = tvb_get_ptr(tvb, offset, chk_size);
2434 memcpy(tmp_ptr, chk_ptr + data_offset, chk_size - data_offset);
2435 calc_crc = calculateCRC(chk_ptr, chk_size);
2437 tmp_ptr += chk_size - data_offset;
2438 act_crc = tvb_get_letohs(tvb, offset);
2440 crc_OK = calc_crc == act_crc;
2443 proto_tree_add_text(al_tree, tvb, offset - (chk_size + 2), chk_size + 2,
2444 "Application Chunk %u Len: %u CRC 0x%04x",
2445 i, chk_size, act_crc);
2446 data_len -= chk_size;
2450 proto_tree_add_text(al_tree, tvb, offset - (chk_size + 2), chk_size + 2,
2451 "Application Chunk %u Len: %u Bad CRC got 0x%04x expected 0x%04x",
2452 i, chk_size, act_crc, calc_crc);
2457 data_offset = 0; /* copy all of the rest of the chunks */
2460 /* if all crc OK, set up new tvb */
2463 al_tvb = tvb_new_real_data(tmp, tmp_ptr-tmp, tmp_ptr-tmp);
2464 tvb_set_child_real_data_tvbuff(tvb, al_tvb);
2466 /* Check for fragmented packet */
2467 save_fragmented = pinfo->fragmented;
2468 if (! (tr_fir && tr_fin))
2470 /* A fragmented packet */
2471 pinfo->fragmented = TRUE;
2473 /* Look up the conversation to get the fragment reassembly id */
2474 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
2475 pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
2477 if (conversation == NULL) {
2478 /* No conversation yet, so make one */
2479 conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
2480 pinfo->srcport, pinfo->destport, 0);
2483 conv_data_ptr = (dnp3_conv_t*)conversation_get_proto_data(conversation, proto_dnp3);
2485 if (conv_data_ptr == NULL) {
2486 /* New data structure required */
2487 conv_data_ptr = se_alloc(sizeof(dnp3_conv_t));
2489 /*** Increment static global fragment reassembly id ***/
2490 conv_data_ptr->conv_seq_number = seq_number++;
2492 conversation_add_proto_data(conversation, proto_dnp3, (void *)conv_data_ptr);
2494 conv_seq_number = conv_data_ptr->conv_seq_number;
2498 * whatever reassembly is in progress, if any, and see
2502 frag_msg = fragment_add_seq_next(al_tvb, 0, pinfo, conv_seq_number,
2504 al_reassembled_table,
2505 tvb_reported_length(al_tvb), /* As this is a constructed tvb, all of it is ok */
2508 next_tvb = process_reassembled_data(al_tvb, 0, pinfo,
2509 "Reassembled DNP 3.0 Application Layer message", frag_msg, &dnp3_frag_items,
2510 &update_col_info, tr_tree);
2512 if (next_tvb) { /* Reassembled */
2513 /* We have the complete payload */
2514 if (check_col (pinfo->cinfo, COL_INFO))
2515 col_add_str (pinfo->cinfo, COL_INFO,
2516 "Reassembled Application Layer");
2517 col_set_fence(pinfo->cinfo, COL_INFO);
2521 /* We don't have the complete reassembled payload. */
2522 if (check_col (pinfo->cinfo, COL_INFO))
2523 col_add_fstr (pinfo->cinfo, COL_INFO,
2524 "Application Layer fragment %u", tr_seq);
2525 col_set_fence(pinfo->cinfo, COL_INFO);
2531 /* No reassembly required */
2533 add_new_data_source(pinfo, next_tvb, "DNP 3.0 Application Layer message");
2534 if (check_col (pinfo->cinfo, COL_INFO))
2535 col_clear (pinfo->cinfo, COL_INFO);
2537 pinfo->fragmented = save_fragmented;
2541 /* CRC error - throw away the data. */
2543 proto_tree_add_text(dnp3_tree, tvb, 11, -1, "CRC failed, %u chunks", i);
2548 al_result = dissect_dnp3_al(next_tvb, pinfo, dnp3_tree);
2554 get_dnp3_message_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
2556 guint16 message_len; /* need 16 bits as total can exceed 255 */
2557 guint16 data_crc; /* No. of user data CRC bytes */
2558 message_len = tvb_get_guint8(tvb, offset + 2);
2560 /* Add in 2 bytes for header start octets,
2561 1 byte for len itself,
2562 2 bytes for header CRC
2563 data CRC bytes (2 bytes per 16 bytes of data
2566 data_crc = (guint16)(ceil((message_len - 5) / 16.0)) * 2;
2567 message_len += 2 + 1 + 2 + data_crc;
2572 dissect_dnp3_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2574 gint length = tvb_length(tvb);
2576 /* Check for a dnp packet. It should begin with 0x0564 */
2577 if(length < DNP_HDR_LEN || tvb_get_ntohs(tvb, 0) != 0x0564) {
2578 /* Not a DNP 3.0 packet, just happened to use the same port */
2582 tcp_dissect_pdus(tvb, pinfo, tree, TRUE, DNP_HDR_LEN,
2583 get_dnp3_message_len, dissect_dnp3_message);
2585 return tvb_length(tvb);
2589 dissect_dnp3_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2591 gint length = tvb_length(tvb);
2592 /* Check for a dnp packet. It should begin with 0x0564 */
2593 if(length < DNP_HDR_LEN || tvb_get_ntohs(tvb, 0) != 0x0564) {
2594 /* Not a DNP 3.0 packet, just happened to use the same port */
2598 dissect_dnp3_message(tvb, pinfo, tree);
2608 al_defragment_init(void)
2610 fragment_table_init(&al_fragment_table);
2611 reassembled_table_init(&al_reassembled_table);
2614 /* Register the protocol with Wireshark */
2617 proto_register_dnp3(void)
2620 /* Setup list of header fields */
2621 static hf_register_info hf[] = {
2623 { "Start Bytes", "dnp3.start", FT_UINT16, BASE_HEX, NULL, 0x0, "Start Bytes", HFILL }},
2626 { "Length", "dnp3.len", FT_UINT8, BASE_DEC, NULL, 0x0, "Frame Data Length", HFILL }},
2629 { "Control", "dnp3.ctl", FT_UINT8, BASE_HEX, NULL, 0x0, "Frame Control Byte", HFILL }},
2631 { &hf_dnp3_ctl_prifunc,
2632 { "Control Function Code", "dnp3.ctl.prifunc", FT_UINT8, BASE_DEC,
2633 VALS(dnp3_ctl_func_pri_vals), DNP3_CTL_FUNC, "Frame Control Function Code", HFILL }},
2635 { &hf_dnp3_ctl_secfunc,
2636 { "Control Function Code", "dnp3.ctl.secfunc", FT_UINT8, BASE_DEC,
2637 VALS(dnp3_ctl_func_sec_vals), DNP3_CTL_FUNC, "Frame Control Function Code", HFILL }},
2640 { "Direction", "dnp3.ctl.dir", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_CTL_DIR, "", HFILL }},
2643 { "Primary", "dnp3.ctl.prm", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_CTL_PRM, "", HFILL }},
2646 { "Frame Count Bit", "dnp3.ctl.fcb", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_CTL_FCB, "", HFILL }},
2649 { "Frame Count Valid", "dnp3.ctl.fcv", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_CTL_FCV, "", HFILL }},
2652 { "Data Flow Control", "dnp3.ctl.dfc", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_CTL_DFC, "", HFILL }},
2655 { "Destination", "dnp3.dst", FT_UINT16, BASE_DEC, NULL, 0x0, "Destination Address", HFILL }},
2658 { "Source", "dnp3.src", FT_UINT16, BASE_DEC, NULL, 0x0, "Source Address", HFILL }},
2661 { "CRC", "dnp3.hdr.CRC", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL }},
2663 { &hf_dnp_hdr_CRC_bad,
2664 { "Bad CRC", "dnp3.hdr.CRC_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "", HFILL }},
2667 { "Transport Control", "dnp3.tr.ctl", FT_UINT8, BASE_HEX, NULL, 0x0, "Tranport Layer Control Byte", HFILL }},
2670 { "Final", "dnp3.tr.fin", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_TR_FIN, "", HFILL }},
2673 { "First", "dnp3.tr.fir", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_TR_FIR, "", HFILL }},
2676 { "Sequence", "dnp3.tr.seq", FT_UINT8, BASE_DEC, NULL, DNP3_TR_SEQ, "Frame Sequence Number", HFILL }},
2679 { "Application Control", "dnp3.al.ctl", FT_UINT8, BASE_HEX, NULL, 0x0, "Application Layer Control Byte", HFILL }},
2682 { "First", "dnp3.al.fir", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_AL_FIR, "", HFILL }},
2685 { "Final", "dnp3.al.fin", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_AL_FIN, "", HFILL }},
2688 { "Confirm", "dnp3.al.con", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DNP3_AL_CON, "", HFILL }},
2691 { "Sequence", "dnp3.al.seq", FT_UINT8, BASE_DEC, NULL, DNP3_AL_SEQ, "Frame Sequence Number", HFILL }},
2694 { "Application Layer Function Code", "dnp3.al.func", FT_UINT8, BASE_DEC,
2695 VALS(dnp3_al_func_vals), DNP3_AL_FUNC, "Application Function Code", HFILL }},
2698 { "Application Layer IIN bits", "dnp3.al.iin", FT_UINT16, BASE_DEC, NULL, 0x0, "Application Layer IIN", HFILL }},
2700 { &hf_dnp3_al_iin_bmsg,
2701 { "Broadcast Msg Rx", "dnp3.al.iin.bmsg", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_BMSG, "", HFILL }},
2703 { &hf_dnp3_al_iin_cls1d,
2704 { "Class 1 Data Available", "dnp3.al.iin.cls1d", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_CLS1D, "", HFILL }},
2706 { &hf_dnp3_al_iin_cls2d,
2707 { "Class 2 Data Available", "dnp3.al.iin.cls2d", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_CLS2D, "", HFILL }},
2709 { &hf_dnp3_al_iin_cls3d,
2710 { "Class 3 Data Available", "dnp3.al.iin.cls3d", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_CLS3D, "", HFILL }},
2712 { &hf_dnp3_al_iin_tsr,
2713 { "Time Sync Required", "dnp3.al.iin.tsr", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_TSR, "", HFILL }},
2715 { &hf_dnp3_al_iin_dol,
2716 { "Digital Outputs in Local", "dnp3.al.iin.dol", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_DOL, "", HFILL }},
2718 { &hf_dnp3_al_iin_dt,
2719 { "Device Trouble", "dnp3.al.iin.dt", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_DT, "", HFILL }},
2721 { &hf_dnp3_al_iin_rst,
2722 { "Device Restart", "dnp3.al.iin.rst", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_RST, "", HFILL }},
2724 { &hf_dnp3_al_iin_obju,
2725 { "Requested Objects Unknown", "dnp3.al.iin.obju", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_OBJU, "", HFILL }},
2727 { &hf_dnp3_al_iin_pioor,
2728 { "Parameters Invalid or Out of Range", "dnp3.al.iin.pioor", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_PIOOR, "", HFILL }},
2730 { &hf_dnp3_al_iin_ebo,
2731 { "Event Buffer Overflow", "dnp3.al.iin.ebo", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_EBO, "", HFILL }},
2733 { &hf_dnp3_al_iin_oae,
2734 { "Operation Already Executing", "dnp3.al.iin.oae", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_OAE, "", HFILL }},
2736 { &hf_dnp3_al_iin_cc,
2737 { "Configuration Corrupt", "dnp3.al.iin.cc", FT_BOOLEAN, 16, TFS(&tfs_set_notset), AL_IIN_CC, "", HFILL }},
2740 { "Object", "dnp3.al.obj", FT_UINT16, BASE_HEX, VALS(dnp3_al_obj_vals), 0x0, "Application Layer Object", HFILL }},
2742 { &hf_dnp3_al_objq_index,
2743 { "Index Prefix", "dnp3.al.objq.index", FT_UINT8, BASE_DEC, VALS(dnp3_al_objq_index_vals), AL_OBJQ_INDEX, "Object Index Prefixing", HFILL }},
2745 { &hf_dnp3_al_objq_code,
2746 { "Qualifier Code", "dnp3.al.objq.code", FT_UINT8, BASE_DEC, VALS(dnp3_al_objq_code_vals), AL_OBJQ_CODE, "Object Qualifier Code", HFILL }},
2748 { &hf_dnp3_al_range_start8,
2749 { "Start (8 bit)", "dnp3.al.range.start", FT_UINT8, BASE_DEC, NULL, 0x0, "Object Start Index", HFILL }},
2751 { &hf_dnp3_al_range_stop8,
2752 { "Stop (8 bit)", "dnp3.al.range.stop", FT_UINT8, BASE_DEC, NULL, 0x0, "Object Stop Index", HFILL }},
2754 { &hf_dnp3_al_range_start16,
2755 { "Start (16 bit)", "dnp3.al.range.start", FT_UINT16, BASE_DEC, NULL, 0x0, "Object Start Index", HFILL }},
2757 { &hf_dnp3_al_range_stop16,
2758 { "Stop (16 bit)", "dnp3.al.range.stop", FT_UINT16, BASE_DEC, NULL, 0x0, "Object Stop Index", HFILL }},
2760 { &hf_dnp3_al_range_start32,
2761 { "Start (32 bit)", "dnp3.al.range.start", FT_UINT32, BASE_DEC, NULL, 0x0, "Object Start Index", HFILL }},
2763 { &hf_dnp3_al_range_stop32,
2764 { "Stop (32 bit)", "dnp3.al.range.stop", FT_UINT32, BASE_DEC, NULL, 0x0, "Object Stop Index", HFILL }},
2766 { &hf_dnp3_al_range_abs8,
2767 { "Address (8 bit)", "dnp3.al.range.abs", FT_UINT8, BASE_DEC, NULL, 0x0, "Object Absolute Address", HFILL }},
2769 { &hf_dnp3_al_range_abs16,
2770 { "Address (16 bit)", "dnp3.al.range.abs", FT_UINT16, BASE_DEC, NULL, 0x0, "Object Absolute Address", HFILL }},
2772 { &hf_dnp3_al_range_abs32,
2773 { "Address (32 bit)", "dnp3.al.range.abs", FT_UINT32, BASE_DEC, NULL, 0x0, "Object Absolute Address", HFILL }},
2775 { &hf_dnp3_al_range_quant8,
2776 { "Quantity (8 bit)", "dnp3.al.range.quantity", FT_UINT8, BASE_DEC, NULL, 0x0, "Object Quantity", HFILL }},
2778 { &hf_dnp3_al_range_quant16,
2779 { "Quantity (16 bit)", "dnp3.al.range.quantity", FT_UINT16, BASE_DEC, NULL, 0x0, "Object Quantity", HFILL }},
2781 { &hf_dnp3_al_range_quant32,
2782 { "Quantity (32 bit)", "dnp3.al.range.quantity", FT_UINT32, BASE_DEC, NULL, 0x0, "Object Quantity", HFILL }},
2784 { &hf_dnp3_al_index8,
2785 { "Index (8 bit)", "dnp3.al.index", FT_UINT8, BASE_DEC, NULL, 0x0, "Object Index", HFILL }},
2787 { &hf_dnp3_al_index16,
2788 { "Index (16 bit)", "dnp3.al.index", FT_UINT16, BASE_DEC, NULL, 0x0, "Object Index", HFILL }},
2790 { &hf_dnp3_al_index32,
2791 { "Index (32 bit)", "dnp3.al.index", FT_UINT32, BASE_DEC, NULL, 0x0, "Object Index", HFILL }},
2793 { &hf_dnp3_al_ptnum,
2794 { "Object Point Number", "dnp3.al.ptnum", FT_UINT16, BASE_DEC, NULL, 0x0, "Object Point Number", HFILL }},
2797 { "Value (bit)", "dnp3.al.bit", FT_BOOLEAN, BASE_NONE, TFS(&tfs_on_off), 0x1, "Digital Value (1 bit)", HFILL }},
2800 { "Value (two bit)", "dnp3.al.2bit", FT_UINT8, BASE_DEC, NULL, 0x0, "Digital Value (2 bit)", HFILL }},
2802 { &hf_dnp3_al_ana16,
2803 { "Value (16 bit)", "dnp3.al.ana", FT_UINT16, BASE_DEC, NULL, 0x0, "Analog Value (16 bit)", HFILL }},
2805 { &hf_dnp3_al_ana32,
2806 { "Value (32 bit)", "dnp3.al.ana", FT_UINT32, BASE_DEC, NULL, 0x0, "Analog Value (32 bit)", HFILL }},
2808 { &hf_dnp3_al_anaflt,
2809 { "Value (float)", "dnp3.al.ana", FT_FLOAT, BASE_DEC, NULL, 0x0, "Analog Value (float)", HFILL }},
2811 { &hf_dnp3_al_anadbl,
2812 { "Value (double)", "dnp3.al.ana", FT_DOUBLE, BASE_DEC, NULL, 0x0, "Analog Value (double)", HFILL }},
2814 { &hf_dnp3_al_anaout16,
2815 { "Output Value (16 bit)", "dnp3.al.anaout", FT_UINT16, BASE_DEC, NULL, 0x0, "Output Value (16 bit)", HFILL }},
2817 { &hf_dnp3_al_anaout32,
2818 { "Output Value (32 bit)", "dnp3.al.anaout", FT_UINT32, BASE_DEC, NULL, 0x0, "Output Value (32 bit)", HFILL }},
2820 { &hf_dnp3_al_anaoutflt,
2821 { "Output Value (float)", "dnp3.al.anaout", FT_FLOAT, BASE_DEC, NULL, 0x0, "Output Value (float)", HFILL }},
2823 { &hf_dnp3_al_anaoutdbl,
2824 { "Output (double)", "dnp3.al.anaout", FT_DOUBLE, BASE_DEC, NULL, 0x0, "Output Value (double)", HFILL }},
2826 { &hf_dnp3_al_cnt16,
2827 { "Counter (16 bit)", "dnp3.al.cnt", FT_UINT16, BASE_DEC, NULL, 0x0, "Counter Value (16 bit)", HFILL }},
2829 { &hf_dnp3_al_cnt32,
2830 { "Counter (32 bit)", "dnp3.al.cnt", FT_UINT32, BASE_DEC, NULL, 0x0, "Counter Value (32 bit)", HFILL }},
2832 { &hf_dnp3_al_ctrlstatus,
2833 { "Control Status", "dnp3.al.ctrlstatus", FT_UINT8, BASE_DEC, dnp3_al_ctl_status_vals, 0xff, "Control Status", HFILL }},
2835 { &hf_dnp3_al_biq_b0,
2836 { "Online", "dnp3.al.biq.b0", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BI_FLAG0, "", HFILL }},
2838 { &hf_dnp3_al_biq_b1,
2839 { "Restart", "dnp3.al.biq.b1", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BI_FLAG1, "", HFILL }},
2841 { &hf_dnp3_al_biq_b2,
2842 { "Comm Fail", "dnp3.al.biq.b2", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BI_FLAG2, "", HFILL }},
2844 { &hf_dnp3_al_biq_b3,
2845 { "Remote Force", "dnp3.al.biq.b3", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BI_FLAG3, "", HFILL }},
2847 { &hf_dnp3_al_biq_b4,
2848 { "Local Force", "dnp3.al.biq.b4", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BI_FLAG4, "", HFILL }},
2850 { &hf_dnp3_al_biq_b5,
2851 { "Chatter Filter", "dnp3.al.biq.b5", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BI_FLAG5, "", HFILL }},
2853 { &hf_dnp3_al_biq_b6,
2854 { "Reserved", "dnp3.al.biq.b6", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BI_FLAG6, "", HFILL }},
2856 { &hf_dnp3_al_biq_b7,
2857 { "Point Value", "dnp3.al.biq.b7", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BI_FLAG7, "", HFILL }},
2859 { &hf_dnp3_al_boq_b0,
2860 { "Online", "dnp3.al.boq.b0", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BO_FLAG0, "", HFILL }},
2862 { &hf_dnp3_al_boq_b1,
2863 { "Restart", "dnp3.al.boq.b1", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BO_FLAG1, "", HFILL }},
2865 { &hf_dnp3_al_boq_b2,
2866 { "Comm Fail", "dnp3.al.boq.b2", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BO_FLAG2, "", HFILL }},
2868 { &hf_dnp3_al_boq_b3,
2869 { "Remote Force", "dnp3.al.boq.b3", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BO_FLAG3, "", HFILL }},
2871 { &hf_dnp3_al_boq_b4,
2872 { "Local Force", "dnp3.al.boq.b4", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BO_FLAG4, "", HFILL }},
2874 { &hf_dnp3_al_boq_b5,
2875 { "Reserved", "dnp3.al.boq.b5", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BO_FLAG5, "", HFILL }},
2877 { &hf_dnp3_al_boq_b6,
2878 { "Reserved", "dnp3.al.boq.b6", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BO_FLAG6, "", HFILL }},
2880 { &hf_dnp3_al_boq_b7,
2881 { "Point Value", "dnp3.al.boq.b7", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_BO_FLAG7, "", HFILL }},
2883 { &hf_dnp3_al_ctrq_b0,
2884 { "Online", "dnp3.al.ctrq.b0", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_CTR_FLAG0, "", HFILL }},
2886 { &hf_dnp3_al_ctrq_b1,
2887 { "Restart", "dnp3.al.ctrq.b1", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_CTR_FLAG1, "", HFILL }},
2889 { &hf_dnp3_al_ctrq_b2,
2890 { "Comm Fail", "dnp3.al.ctrq.b2", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_CTR_FLAG2, "", HFILL }},
2892 { &hf_dnp3_al_ctrq_b3,
2893 { "Remote Force", "dnp3.al.ctrq.b3", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_CTR_FLAG3, "", HFILL }},
2895 { &hf_dnp3_al_ctrq_b4,
2896 { "Local Force", "dnp3.al.ctrq.b4", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_CTR_FLAG4, "", HFILL }},
2898 { &hf_dnp3_al_ctrq_b5,
2899 { "Roll-Over", "dnp3.al.ctrq.b5", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_CTR_FLAG5, "", HFILL }},
2901 { &hf_dnp3_al_ctrq_b6,
2902 { "Discontinuity", "dnp3.al.ctrq.b6", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_CTR_FLAG6, "", HFILL }},
2904 { &hf_dnp3_al_ctrq_b7,
2905 { "Reserved", "dnp3.al.ctrq.b7", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_CTR_FLAG7, "", HFILL }},
2907 { &hf_dnp3_al_aiq_b0,
2908 { "Online", "dnp3.al.aiq.b0", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AI_FLAG0, "", HFILL }},
2910 { &hf_dnp3_al_aiq_b1,
2911 { "Restart", "dnp3.al.aiq.b1", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AI_FLAG1, "", HFILL }},
2913 { &hf_dnp3_al_aiq_b2,
2914 { "Comm Fail", "dnp3.al.aiq.b2", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AI_FLAG2, "", HFILL }},
2916 { &hf_dnp3_al_aiq_b3,
2917 { "Remote Force", "dnp3.al.aiq.b3", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AI_FLAG3, "", HFILL }},
2919 { &hf_dnp3_al_aiq_b4,
2920 { "Local Force", "dnp3.al.aiq.b4", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AI_FLAG4, "", HFILL }},
2922 { &hf_dnp3_al_aiq_b5,
2923 { "Over-Range", "dnp3.al.aiq.b5", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AI_FLAG5, "", HFILL }},
2925 { &hf_dnp3_al_aiq_b6,
2926 { "Reference Check", "dnp3.al.aiq.b6", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AI_FLAG6, "", HFILL }},
2928 { &hf_dnp3_al_aiq_b7,
2929 { "Reserved", "dnp3.al.aiq.b7", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AI_FLAG7, "", HFILL }},
2931 { &hf_dnp3_al_aoq_b0,
2932 { "Online", "dnp3.al.aoq.b0", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AO_FLAG0, "", HFILL }},
2934 { &hf_dnp3_al_aoq_b1,
2935 { "Restart", "dnp3.al.aoq.b1", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AO_FLAG1, "", HFILL }},
2937 { &hf_dnp3_al_aoq_b2,
2938 { "Comm Fail", "dnp3.al.aoq.b2", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AO_FLAG2, "", HFILL }},
2940 { &hf_dnp3_al_aoq_b3,
2941 { "Remote Force", "dnp3.al.aoq.b3", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AO_FLAG3, "", HFILL }},
2943 { &hf_dnp3_al_aoq_b4,
2944 { "Local Force", "dnp3.al.aoq.b4", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AO_FLAG4, "", HFILL }},
2946 { &hf_dnp3_al_aoq_b5,
2947 { "Reserved", "dnp3.al.aoq.b5", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AO_FLAG5, "", HFILL }},
2949 { &hf_dnp3_al_aoq_b6,
2950 { "Reserved", "dnp3.al.aoq.b6", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AO_FLAG6, "", HFILL }},
2952 { &hf_dnp3_al_aoq_b7,
2953 { "Reserved", "dnp3.al.aoq.b7", FT_BOOLEAN, 8, TFS(&tfs_set_notset), AL_OBJ_AO_FLAG7, "", HFILL }},
2955 { &hf_dnp3_al_timestamp,
2956 { "Timestamp", "dnp3.al.timestamp", FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0, "Object Timestamp", HFILL }},
2958 { &hf_dnp3_al_rel_timestamp,
2959 { "Relative Timestamp", "dnp3.al.reltimestamp", FT_RELATIVE_TIME, BASE_NONE, NULL, 0, "Object Relative Timestamp", HFILL }},
2961 { &hf_dnp3_fragment,
2962 { "DNP 3.0 AL Fragment", "dnp3.al.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0x0, "DNP 3.0 Application Layer Fragment", HFILL }},
2964 { &hf_dnp3_fragments,
2965 { "DNP 3.0 AL Fragments", "dnp3.al.fragments", FT_NONE, BASE_NONE, NULL, 0x0, "DNP 3.0 Application Layer Fragments", HFILL }},
2967 { &hf_dnp3_fragment_overlap,
2968 { "Fragment overlap", "dnp3.al.fragment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "Fragment overlaps with other fragments", HFILL }},
2970 { &hf_dnp3_fragment_overlap_conflict,
2971 { "Conflicting data in fragment overlap", "dnp3.al.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2972 "Overlapping fragments contained conflicting data", HFILL }},
2974 { &hf_dnp3_fragment_multiple_tails,
2975 { "Multiple tail fragments found", "dnp3.al.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2976 "Several tails were found when defragmenting the packet", HFILL }},
2978 { &hf_dnp3_fragment_too_long_fragment,
2979 { "Fragment too long", "dnp3.al.fragment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2980 "Fragment contained data past end of packet", HFILL }},
2982 { &hf_dnp3_fragment_error,
2983 { "Defragmentation error", "dnp3.al.fragment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
2984 "Defragmentation error due to illegal fragments", HFILL }},
2986 { &hf_dnp3_fragment_reassembled_in,
2987 { "Reassembled PDU In Frame", "dnp3.al.fragment.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
2988 "This PDU is reassembled in this frame", HFILL }}
2991 /* Setup protocol subtree array */
2992 static gint *ett[] = {
3002 &ett_dnp3_al_obj_qualifier,
3003 &ett_dnp3_al_obj_range,
3004 &ett_dnp3_al_objdet,
3005 &ett_dnp3_al_obj_quality,
3006 &ett_dnp3_al_obj_point,
3010 module_t *dnp3_module;
3012 /* Register protocol init routine */
3013 register_init_routine(&dnp3_init);
3015 /* Register the protocol name and description */
3016 proto_dnp3 = proto_register_protocol("Distributed Network Protocol 3.0",
3019 /* Required function calls to register the header fields and subtrees used */
3020 proto_register_field_array(proto_dnp3, hf, array_length(hf));
3021 proto_register_subtree_array(ett, array_length(ett));
3023 dnp3_module = prefs_register_protocol(proto_dnp3, NULL);
3024 prefs_register_bool_preference(dnp3_module, "desegment",
3025 "Reassemble DNP3 messages spanning multiple TCP segments",
3026 "Whether the DNP3 dissector should reassemble messages spanning multiple TCP segments."
3027 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
3030 al_defragment_init();
3034 /* If this dissector uses sub-dissector registration add a registration routine.
3035 This format is required because a script is used to find these routines and
3036 create the code that calls these routines.
3039 proto_reg_handoff_dnp3(void)
3041 dissector_handle_t dnp3_tcp_handle;
3042 dissector_handle_t dnp3_udp_handle;
3044 dnp3_tcp_handle = new_create_dissector_handle(dissect_dnp3_tcp, proto_dnp3);
3045 dnp3_udp_handle = new_create_dissector_handle(dissect_dnp3_udp, proto_dnp3);
3046 dissector_add("tcp.port", TCP_PORT_DNP, dnp3_tcp_handle);
3047 dissector_add("udp.port", UDP_PORT_DNP, dnp3_udp_handle);
3056 * indent-tabs-mode: tabs
3059 * ex: set shiftwidth=2 tabstop=8 noexpandtab
3060 * :indentSize=2:tabSize=8:noTabs=false: