PageRenderTime 52ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/epan/dissectors/packet-dnp.c

https://github.com/labx-technologies-llc/wireshark
C | 4190 lines | 3199 code | 570 blank | 421 comment | 160 complexity | 7a6f393440ba0f929e503195337d5919 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause

Large files files are truncated, but you can click here to view the full file

  1. /* packet-dnp.c
  2. * Routines for DNP dissection
  3. * Copyright 2003, 2006, 2007, Graham Bloice <graham.bloice@trihedral.com>
  4. *
  5. * DNP3.0 Application Layer Object dissection added by Chris Bontje (chrisbontje@shaw.ca)
  6. * Copyright 2005
  7. *
  8. * Major updates: tcp and application layer defragmentation, more object dissections by Graham Bloice
  9. *
  10. * $Id$
  11. *
  12. * Wireshark - Network traffic analyzer
  13. * By Gerald Combs <gerald@wireshark.org>
  14. * Copyright 1998 Gerald Combs
  15. *
  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.
  20. *
  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.
  25. *
  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  29. */
  30. #include "config.h"
  31. #include <string.h>
  32. #include <math.h>
  33. #include <glib.h>
  34. #include <epan/packet.h>
  35. #include <epan/prefs.h>
  36. #include <epan/reassemble.h>
  37. #include <epan/emem.h>
  38. #include <epan/dissectors/packet-tcp.h>
  39. #include <epan/conversation.h>
  40. #include <epan/expert.h>
  41. /*
  42. * See
  43. *
  44. * http://www.dnp.org/
  45. *
  46. * although note that you have to join the DNP organization to get to
  47. * see the protocol specs online - otherwise, you have to buy a
  48. * dead-tree version.
  49. *
  50. * ...Application Layer Notes...
  51. *
  52. * Application Layer Decoding based on information available in
  53. * DNP3 Basic 4 Documentation Set, specifically the document:
  54. * "DNP V3.00 Application Layer" v0.03 P009-0PD.APP & Technical Bulletins
  55. *
  56. * ---------------------------------------------------------------------------
  57. *
  58. * Several command codes were missing, causing the dissector to abort decoding
  59. * on valid packets. Those commands have been added.
  60. *
  61. * The semantics of Variation 0 have been cleaned up. Variation 0 is the
  62. * "Default Variation". It is used only in Master -> Slave read commands
  63. * to request the data in whatever variation the Slave is configured to use by
  64. * default. Decoder strings have been added to the Binary Output and
  65. * Analog Output objects (10 and 40) so that group read commands will
  66. * decode properly.
  67. *
  68. * Roy M. Silvernail <roy@rant-central.com> 01/05/2009
  69. *
  70. */
  71. /***************************************************************************/
  72. /* DNP 3.0 Constants */
  73. /***************************************************************************/
  74. #define DNP_HDR_LEN 10
  75. #define TCP_PORT_DNP 20000
  76. #define UDP_PORT_DNP 20000
  77. /***************************************************************************/
  78. /* Datalink and Transport Layer Bit-Masks */
  79. /***************************************************************************/
  80. #define DNP3_CTL_DIR 0x80
  81. #define DNP3_CTL_PRM 0x40
  82. #define DNP3_CTL_FCB 0x20
  83. #define DNP3_CTL_FCV 0x10
  84. #define DNP3_CTL_RES 0x20
  85. #define DNP3_CTL_DFC 0x10
  86. #define DNP3_CTL_FUNC 0x0f
  87. #define DNP3_TR_FIR 0x40
  88. #define DNP3_TR_FIN 0x80
  89. #define DNP3_TR_SEQ 0x3f
  90. #define AL_MAX_CHUNK_SIZE 16
  91. /***************************************************************************/
  92. /* Data Link Function codes */
  93. /***************************************************************************/
  94. /* Primary to Secondary */
  95. #define DL_FUNC_RESET_LINK 0x00
  96. #define DL_FUNC_RESET_PROC 0x01
  97. #define DL_FUNC_TEST_LINK 0x02
  98. #define DL_FUNC_USER_DATA 0x03
  99. #define DL_FUNC_UNC_DATA 0x04
  100. #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
  107. /***************************************************************************/
  108. /* Application Layer Bit-Masks */
  109. /***************************************************************************/
  110. #define DNP3_AL_UNS 0x10
  111. #define DNP3_AL_CON 0x20
  112. #define DNP3_AL_FIN 0x40
  113. #define DNP3_AL_FIR 0x80
  114. #define DNP3_AL_SEQ 0x0f
  115. #define DNP3_AL_FUNC 0xff
  116. /***************************************************************************/
  117. /* Application Layer Function codes */
  118. /***************************************************************************/
  119. #define AL_FUNC_CONFIRM 0x00 /* 00 - Confirm */
  120. #define AL_FUNC_READ 0x01 /* 01 - Read */
  121. #define AL_FUNC_WRITE 0x02 /* 02 - Write */
  122. #define AL_FUNC_SELECT 0x03 /* 03 - Select */
  123. #define AL_FUNC_OPERATE 0x04 /* 04 - Operate */
  124. #define AL_FUNC_DIROP 0x05 /* 05 - Direct Operate */
  125. #define AL_FUNC_DIROPNACK 0x06 /* 06 - Direct Operate No ACK */
  126. #define AL_FUNC_FRZ 0x07 /* 07 - Immediate Freeze */
  127. #define AL_FUNC_FRZNACK 0x08 /* 08 - Immediate Freeze No ACK */
  128. #define AL_FUNC_FRZCLR 0x09 /* 09 - Freeze and Clear */
  129. #define AL_FUNC_FRZCLRNACK 0x0A /* 10 - Freeze and Clear No ACK */
  130. #define AL_FUNC_FRZT 0x0B /* 11 - Freeze With Time */
  131. #define AL_FUNC_FRZTNACK 0x0C /* 12 - Freeze With Time No ACK */
  132. #define AL_FUNC_COLDRST 0x0D /* 13 - Cold Restart */
  133. #define AL_FUNC_WARMRST 0x0E /* 14 - Warm Restart */
  134. #define AL_FUNC_INITDATA 0x0F /* 15 - Initialize Data */
  135. #define AL_FUNC_INITAPP 0x10 /* 16 - Initialize Application */
  136. #define AL_FUNC_STARTAPP 0x11 /* 17 - Start Application */
  137. #define AL_FUNC_STOPAPP 0x12 /* 18 - Stop Application */
  138. #define AL_FUNC_SAVECFG 0x13 /* 19 - Save Configuration */
  139. #define AL_FUNC_ENSPMSG 0x14 /* 20 - Enable Spontaneous Msg */
  140. #define AL_FUNC_DISSPMSG 0x15 /* 21 - Disable Spontaneous Msg */
  141. #define AL_FUNC_ASSIGNCL 0x16 /* 22 - Assign Classes */
  142. #define AL_FUNC_DELAYMST 0x17 /* 23 - Delay Measurement */
  143. #define AL_FUNC_RECCT 0x18 /* 24 - Record Current Time */
  144. #define AL_FUNC_OPENFILE 0x19 /* 25 - Open File */
  145. #define AL_FUNC_CLOSEFILE 0x1A /* 26 - Close File */
  146. #define AL_FUNC_DELETEFILE 0x1B /* 27 - Delete File */
  147. #define AL_FUNC_GETFILEINF 0x1C /* 28 - Get File Info */
  148. #define AL_FUNC_AUTHFILE 0x1D /* 29 - Authenticate File */
  149. #define AL_FUNC_ABORTFILE 0x1E /* 30 - Abort File */
  150. #define AL_FUNC_ACTCNF 0x1F /* 31 - Activate Config */
  151. #define AL_FUNC_AUTHREQ 0x20 /* 32 - Authentication Request */
  152. #define AL_FUNC_AUTHERR 0x21 /* 33 - Authentication Error */
  153. #define AL_FUNC_RESPON 0x81 /* 129 - Response */
  154. #define AL_FUNC_UNSOLI 0x82 /* 130 - Unsolicited Response */
  155. #define AL_FUNC_AUTHRESP 0x83 /* 131 - Authentication Response */
  156. /***************************************************************************/
  157. /* Application Layer Internal Indication (IIN) bits */
  158. /* 2 Bytes, message formatting: [First Octet] | [Second Octet] */
  159. /***************************************************************************/
  160. /* Octet 1 */
  161. #define AL_IIN_BMSG 0x0100 /* Bit 0 - Broadcast message rx'd */
  162. #define AL_IIN_CLS1D 0x0200 /* Bit 1 - Class 1 Data Available */
  163. #define AL_IIN_CLS2D 0x0400 /* Bit 2 - Class 2 Data Available */
  164. #define AL_IIN_CLS3D 0x0800 /* Bit 3 - Class 3 Data Available */
  165. #define AL_IIN_TSR 0x1000 /* Bit 4 - Time Sync Req'd from Master */
  166. #define AL_IIN_DOL 0x2000 /* Bit 5 - Outputs in Local Mode */
  167. #define AL_IIN_DT 0x4000 /* Bit 6 - Device Trouble */
  168. #define AL_IIN_RST 0x8000 /* Bit 7 - Device Restart */
  169. /* Octet 2 */
  170. #define AL_IIN_FCNI 0x0001 /* Bit 0 - Function code not implemented */
  171. #define AL_IIN_OBJU 0x0002 /* Bit 1 - Requested Objects Unknown */
  172. #define AL_IIN_PIOOR 0x0004 /* Bit 2 - Parameters Invalid or Out of Range */
  173. #define AL_IIN_EBO 0x0008 /* Bit 3 - Event Buffer Overflow */
  174. #define AL_IIN_OAE 0x0010 /* Bit 4 - Operation Already Executing */
  175. #define AL_IIN_CC 0x0020 /* Bit 5 - Device Configuration Corrupt */
  176. /* 0x0040 Bit 6 - Reserved */
  177. /* 0x0080 Bit 7 - Reserved */
  178. /***************************************************************************/
  179. /* Application Layer Data Object Qualifier */
  180. /***************************************************************************/
  181. /* Bit-Masks */
  182. #define AL_OBJQ_INDEX 0x70 /* x111xxxx Masks Index from Qualifier */
  183. #define AL_OBJQ_CODE 0x0F /* xxxx1111 Masks Code from Qualifier */
  184. /* Index Size (3-bits x111xxxx) */
  185. /* When Qualifier Code != 11 */
  186. #define AL_OBJQL_IDX_NI 0x00 /* Objects are Packed with no index */
  187. #define AL_OBJQL_IDX_1O 0x01 /* Objects are prefixed w/ 1-octet index */
  188. #define AL_OBJQL_IDX_2O 0x02 /* Objects are prefixed w/ 2-octet index */
  189. #define AL_OBJQL_IDX_4O 0x03 /* Objects are prefixed w/ 4-octet index */
  190. #define AL_OBJQL_IDX_1OS 0x04 /* Objects are prefixed w/ 1-octet object size */
  191. #define AL_OBJQL_IDX_2OS 0x05 /* Objects are prefixed w/ 2-octet object size */
  192. #define AL_OBJQL_IDX_4OS 0x06 /* Objects are prefixed w/ 4-octet object size */
  193. /* When Qualifier Code == 11 */
  194. #define AL_OBJQL_IDX11_1OIS 0x01 /* 1 octet identifier size */
  195. #define AL_OBJQL_IDX11_2OIS 0x02 /* 2 octet identifier size */
  196. #define AL_OBJQL_IDX11_4OIS 0x03 /* 4 octet identifier size */
  197. /* Qualifier Code (4-bits) */
  198. /* 4-bits ( xxxx1111 ) */
  199. #define AL_OBJQL_CODE_SSI8 0x00 /* 00 8-bit Start and Stop Indices in Range Field */
  200. #define AL_OBJQL_CODE_SSI16 0x01 /* 01 16-bit Start and Stop Indices in Range Field */
  201. #define AL_OBJQL_CODE_SSI32 0x02 /* 02 32-bit Start and Stop Indices in Range Field */
  202. #define AL_OBJQL_CODE_AA8 0x03 /* 03 8-bit Absolute Address in Range Field */
  203. #define AL_OBJQL_CODE_AA16 0x04 /* 04 16-bit Absolute Address in Range Field */
  204. #define AL_OBJQL_CODE_AA32 0x05 /* 05 32-bit Absolute Address in Range Field */
  205. #define AL_OBJQL_CODE_R0 0x06 /* 06 Length of Range field is 0 (no range field) */
  206. #define AL_OBJQL_CODE_SF8 0x07 /* 07 8-bit Single Field Quantity */
  207. #define AL_OBJQL_CODE_SF16 0x08 /* 08 16-bit Single Field Quantity */
  208. #define AL_OBJQL_CODE_SF32 0x09 /* 09 32-bit Single Field Quantity */
  209. /* 0x0A 10 Reserved */
  210. #define AL_OBJQL_CODE_FF 0x0B /* 11 Free-format Qualifier, range field has 1 octet count of objects */
  211. /* 0x0C 12 Reserved */
  212. /* 0x0D 13 Reserved */
  213. /* 0x0E 14 Reserved */
  214. /* 0x0F 15 Reserved */
  215. /***************************************************************************/
  216. /* Application Layer Data Object Definitions */
  217. /***************************************************************************/
  218. /* Binary Input Objects */
  219. #define AL_OBJ_BI_ALL 0x0100 /* 01 00 Binary Input Default Variation */
  220. #define AL_OBJ_BI_1BIT 0x0101 /* 01 01 Single-bit Binary Input */
  221. #define AL_OBJ_BI_STAT 0x0102 /* 01 02 Binary Input With Status */
  222. #define AL_OBJ_BIC_ALL 0x0200 /* 02 00 Binary Input Change Default Variation */
  223. #define AL_OBJ_BIC_NOTIME 0x0201 /* 02 01 Binary Input Change Without Time */
  224. #define AL_OBJ_BIC_TIME 0x0202 /* 02 02 Binary Input Change With Time */
  225. #define AL_OBJ_BIC_RTIME 0x0203 /* 02 03 Binary Input Change With Relative Time */
  226. /* Double-bit Input Objects */
  227. #define AL_OBJ_2BI_ALL 0x0300 /* 03 00 Double-bit Input Default Variation */
  228. #define AL_OBJ_2BI_NF 0x0301 /* 03 01 Double-bit Input No Flags */
  229. #define AL_OBJ_2BI_STAT 0x0302 /* 03 02 Double-bit Input With Status */
  230. #define AL_OBJ_2BIC_NOTIME 0x0401 /* 04 01 Double-bit Input Change Without Time */
  231. #define AL_OBJ_2BIC_TIME 0x0402 /* 04 02 Double-bit Input Change With Time */
  232. #define AL_OBJ_2BIC_RTIME 0x0403 /* 04 03 Double-bit Input Change With Relative Time */
  233. /* Binary Input Quality Flags */
  234. #define AL_OBJ_BI_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
  235. #define AL_OBJ_BI_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
  236. #define AL_OBJ_BI_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
  237. #define AL_OBJ_BI_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
  238. #define AL_OBJ_BI_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
  239. #define AL_OBJ_BI_FLAG5 0x0020 /* Chatter Filter (0=Normal; 1=Filter On) */
  240. #define AL_OBJ_BI_FLAG6 0x0040 /* Double-bit LSB (0=Off; 1=On) */
  241. #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_ALL 0x0A00 /* 10 00 Binary Output Default Variation */
  245. #define AL_OBJ_BO 0x0A01 /* 10 01 Binary Output */
  246. #define AL_OBJ_BO_STAT 0x0A02 /* 10 02 Binary Output Status */
  247. #define AL_OBJ_BOC_ALL 0x0B00 /* 11 00 Binary Output Change Default Variation */
  248. #define AL_OBJ_BOC_NOTIME 0x0B01 /* 11 01 Binary Output Change Without Time */
  249. #define AL_OBJ_BOC_TIME 0x0B02 /* 11 02 Binary Output Change With Time */
  250. #define AL_OBJ_CTLOP_BLK 0x0C01 /* 12 01 Control Relay Output Block */
  251. /* 0x0C02 12 02 Pattern Control Block */
  252. /* 0x0C03 12 03 Pattern Mask */
  253. #define AL_OBJCTLC_CODE 0x0F /* Bit-Mask xxxx1111 for Control Code 'Code' */
  254. #define AL_OBJCTLC_MISC 0x30 /* Bit-Mask xx11xxxx for Control Code Queue (obsolete) and Clear Fields */
  255. #define AL_OBJCTLC_TC 0xC0 /* Bit-Mask 11xxxxxx for Control Code 'Trip/Close' */
  256. #define AL_OBJCTLC_CODE0 0x00 /* xxxx0000 NUL Operation; only process R attribute */
  257. #define AL_OBJCTLC_CODE1 0x01 /* xxxx0001 Pulse On ^On-Time -> vOff-Time, remain off */
  258. #define AL_OBJCTLC_CODE2 0x02 /* xxxx0010 Pulse Off vOff-Time -> ^On-Time, remain on */
  259. #define AL_OBJCTLC_CODE3 0x03 /* xxxx0011 Latch On */
  260. #define AL_OBJCTLC_CODE4 0x04 /* xxxx0100 Latch Off */
  261. /* 0x05-0x15 Reserved */
  262. #define AL_OBJCTLC_NOTSET 0x00 /* xx00xxxx for Control Code, Clear and Queue not set */
  263. #define AL_OBJCTLC_QUEUE 0x01 /* xxx1xxxx for Control Code, Clear Field 'Queue' */
  264. #define AL_OBJCTLC_CLEAR 0x02 /* xx1xxxxx for Control Code, Clear Field 'Clear' */
  265. #define AL_OBJCTLC_BOTHSET 0x03 /* xx11xxxx for Control Code, Clear and Queue both set */
  266. #define AL_OBJCTLC_TC0 0x00 /* 00xxxxxx NUL */
  267. #define AL_OBJCTLC_TC1 0x01 /* 01xxxxxx Close */
  268. #define AL_OBJCTLC_TC2 0x02 /* 10xxxxxx Trip */
  269. #define AL_OBJCTLC_TC3 0x03 /* 11xxxxxx Reserved */
  270. #define AL_OBJCTL_STAT0 0x00 /* Request Accepted, Initiated or Queued */
  271. #define AL_OBJCTL_STAT1 0x01 /* Request Not Accepted; Arm-timer expired */
  272. #define AL_OBJCTL_STAT2 0x02 /* Request Not Accepted; No 'SELECT' rx'd */
  273. #define AL_OBJCTL_STAT3 0x03 /* Request Not Accepted; Format errors in ctrl request */
  274. #define AL_OBJCTL_STAT4 0x04 /* Control Operation Not Supported for this point */
  275. #define AL_OBJCTL_STAT5 0x05 /* Request Not Accepted; Ctrl Queue full or pt. active */
  276. #define AL_OBJCTL_STAT6 0x06 /* Request Not Accepted; Ctrl HW Problems */
  277. #define AL_OBJCTL_STAT7 0x07 /* Request Not Accepted; Local/Remote switch in Local*/
  278. #define AL_OBJCTL_STAT8 0x08 /* Request Not Accepted; Too many operations requested */
  279. #define AL_OBJCTL_STAT9 0x09 /* Request Not Accepted; Insufficient authorization */
  280. #define AL_OBJCTL_STAT10 0x0A /* Request Not Accepted; Local automation proc active */
  281. /* Binary Output Quality Flags */
  282. #define AL_OBJ_BO_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
  283. #define AL_OBJ_BO_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
  284. #define AL_OBJ_BO_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
  285. #define AL_OBJ_BO_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
  286. #define AL_OBJ_BO_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
  287. #define AL_OBJ_BO_FLAG5 0x0020 /* Reserved */
  288. #define AL_OBJ_BO_FLAG6 0x0040 /* Reserved */
  289. #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 Default Variation */
  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 Default Variation */
  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 0x150A /* 21 10 16-Bit Frozen Counter Without Flag */
  312. #define AL_OBJ_FDCTR_32NF 0x150B /* 21 11 32-Bit Frozen Delta Counter Without Flag */
  313. #define AL_OBJ_FDCTR_16NF 0x150C /* 21 12 16-Bit Frozen Delta Counter Without Flag */
  314. #define AL_OBJ_CTRC_ALL 0x1600 /* 22 00 Counter Change Event Default Variation */
  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 Default Variation */
  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 */
  332. /* Counter Quality Flags */
  333. #define AL_OBJ_CTR_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
  334. #define AL_OBJ_CTR_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
  335. #define AL_OBJ_CTR_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
  336. #define AL_OBJ_CTR_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
  337. #define AL_OBJ_CTR_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
  338. #define AL_OBJ_CTR_FLAG5 0x0020 /* Roll-over (0=Normal; 1=Roll-Over) */
  339. #define AL_OBJ_CTR_FLAG6 0x0040 /* Discontinuity (0=Normal; 1=Discontinuity) */
  340. #define AL_OBJ_CTR_FLAG7 0x0080 /* Reserved */
  341. /***************************************************************************/
  342. /* Analog Input Objects */
  343. #define AL_OBJ_AI_ALL 0x1E00 /* 30 00 Analog Input Default Variation */
  344. #define AL_OBJ_AI_32 0x1E01 /* 30 01 32-Bit Analog Input */
  345. #define AL_OBJ_AI_16 0x1E02 /* 30 02 16-Bit Analog Input */
  346. #define AL_OBJ_AI_32NF 0x1E03 /* 30 03 32-Bit Analog Input Without Flag */
  347. #define AL_OBJ_AI_16NF 0x1E04 /* 30 04 16-Bit Analog Input Without Flag */
  348. #define AL_OBJ_AI_FLT 0x1E05 /* 30 05 32-Bit Floating Point Input */
  349. #define AL_OBJ_AI_DBL 0x1E06 /* 30 06 64-Bit Floating Point Input */
  350. /* 0x1F01 31 01 32-Bit Frozen Analog Input */
  351. /* 0x1F02 31 02 16-Bit Frozen Analog Input */
  352. /* 0x1F03 31 03 32-Bit Frozen Analog Input w/ Time of Freeze */
  353. /* 0x1F04 31 04 16-Bit Frozen Analog Input w/ Time of Freeze */
  354. /* 0x1F05 31 05 32-Bit Frozen Analog Input Without Flag */
  355. /* 0x1F06 31 06 16-Bit Frozen Analog Input Without Flag */
  356. #define AL_OBJ_AIF_FLT 0x1F07 /* 31 07 32-Bit Frozen Floating Point Input */
  357. #define AL_OBJ_AIF_DBL 0x1F08 /* 31 08 64-Bit Frozen Floating Point Input */
  358. #define AL_OBJ_AIC_ALL 0x2000 /* 32 00 Analog Input Change Default Variation */
  359. #define AL_OBJ_AIC_32NT 0x2001 /* 32 01 32-Bit Analog Change Event w/o Time */
  360. #define AL_OBJ_AIC_16NT 0x2002 /* 32 02 16-Bit Analog Change Event w/o Time */
  361. #define AL_OBJ_AIC_32T 0x2003 /* 32 03 32-Bit Analog Change Event w/ Time */
  362. #define AL_OBJ_AIC_16T 0x2004 /* 32 04 16-Bit Analog Change Event w/ Time */
  363. #define AL_OBJ_AIC_FLTNT 0x2005 /* 32 05 32-Bit Floating Point Change Event w/o Time*/
  364. #define AL_OBJ_AIC_DBLNT 0x2006 /* 32 06 64-Bit Floating Point Change Event w/o Time*/
  365. #define AL_OBJ_AIC_FLTT 0x2007 /* 32 07 32-Bit Floating Point Change Event w/ Time*/
  366. #define AL_OBJ_AIC_DBLT 0x2008 /* 32 08 64-Bit Floating Point Change Event w/ Time*/
  367. /* 0x2101 33 01 32-Bit Frozen Analog Event w/o Time */
  368. /* 0x2102 33 02 16-Bit Frozen Analog Event w/o Time */
  369. /* 0x2103 33 03 32-Bit Frozen Analog Event w/ Time */
  370. /* 0x2104 33 04 16-Bit Frozen Analog Event w/ Time */
  371. #define AL_OBJ_AIFC_FLTNT 0x2105 /* 33 05 32-Bit Floating Point Frozen Change Event w/o Time*/
  372. #define AL_OBJ_AIFC_DBLNT 0x2106 /* 33 06 64-Bit Floating Point Frozen Change Event w/o Time*/
  373. #define AL_OBJ_AIFC_FLTT 0x2107 /* 33 07 32-Bit Floating Point Frozen Change Event w/ Time*/
  374. #define AL_OBJ_AIFC_DBLT 0x2108 /* 33 08 64-Bit Floating Point Frozen Change Event w/ Time*/
  375. /* Analog Input Quality Flags */
  376. #define AL_OBJ_AI_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
  377. #define AL_OBJ_AI_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
  378. #define AL_OBJ_AI_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
  379. #define AL_OBJ_AI_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
  380. #define AL_OBJ_AI_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
  381. #define AL_OBJ_AI_FLAG5 0x0020 /* Over-Range (0=Normal; 1=Over-Range) */
  382. #define AL_OBJ_AI_FLAG6 0x0040 /* Reference Check (0=Normal; 1=Error) */
  383. #define AL_OBJ_AI_FLAG7 0x0080 /* Reserved */
  384. #define AL_OBJ_AIDB_ALL 0x2200 /* 34 00 Analog Input Deadband Default Variation */
  385. #define AL_OBJ_AIDB_16 0x2201 /* 34 01 16-Bit Analog Input Deadband */
  386. #define AL_OBJ_AIDB_32 0x2202 /* 34 02 32-Bit Analog Input Deadband */
  387. #define AL_OBJ_AIDB_FLT 0x2203 /* 34 03 Floating Point Analog Input Deadband */
  388. /***************************************************************************/
  389. /* Analog Output Objects */
  390. #define AL_OBJ_AO_ALL 0x2800 /* 40 00 Analog Output Default Variation */
  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 */
  399. #define AL_OBJ_AOC_ALL 0x2A00 /* 42 00 Analog Output Event Default Variation */
  400. #define AL_OBJ_AOC_32NT 0x2A01 /* 42 01 32-Bit Analog Output Event w/o Time */
  401. #define AL_OBJ_AOC_16NT 0x2A02 /* 42 02 16-Bit Analog Output Event w/o Time */
  402. #define AL_OBJ_AOC_32T 0x2A03 /* 42 03 32-Bit Analog Output Event w/ Time */
  403. #define AL_OBJ_AOC_16T 0x2A04 /* 42 04 16-Bit Analog Output Event w/ Time */
  404. #define AL_OBJ_AOC_FLTNT 0x2A05 /* 42 05 32-Bit Floating Point Output Event w/o Time*/
  405. #define AL_OBJ_AOC_DBLNT 0x2A06 /* 42 06 64-Bit Floating Point Output Event w/o Time*/
  406. #define AL_OBJ_AOC_FLTT 0x2A07 /* 42 07 32-Bit Floating Point Output Event w/ Time*/
  407. #define AL_OBJ_AOC_DBLT 0x2A08 /* 42 08 64-Bit Floating Point Output Event w/ Time*/
  408. /* Analog Output Quality Flags */
  409. #define AL_OBJ_AO_FLAG0 0x0001 /* Point Online (0=Offline; 1=Online) */
  410. #define AL_OBJ_AO_FLAG1 0x0002 /* Restart (0=Normal; 1=Restart) */
  411. #define AL_OBJ_AO_FLAG2 0x0004 /* Comms Lost (0=Normal; 1=Lost) */
  412. #define AL_OBJ_AO_FLAG3 0x0008 /* Remote Force (0=Normal; 1=Forced) */
  413. #define AL_OBJ_AO_FLAG4 0x0010 /* Local Force (0=Normal; 1=Forced) */
  414. #define AL_OBJ_AO_FLAG5 0x0020 /* Reserved */
  415. #define AL_OBJ_AO_FLAG6 0x0040 /* Reserved */
  416. #define AL_OBJ_AO_FLAG7 0x0080 /* Reserved */
  417. /***************************************************************************/
  418. /* Time Objects */
  419. #define AL_OBJ_TD_ALL 0x3200 /* 50 00 Time and Date Default Variation */
  420. #define AL_OBJ_TD 0x3201 /* 50 01 Time and Date */
  421. #define AL_OBJ_TDI 0x3202 /* 50 02 Time and Date w/ Interval */
  422. #define AL_OBJ_TDR 0x3203 /* 50 03 Last Recorded Time and Date */
  423. #define AL_OBJ_TDCTO 0x3301 /* 51 01 Time and Date CTO */
  424. #define AL_OBJ_UTDCTO 0x3302 /* 51 02 Unsynchronized Time and Date CTO */
  425. #define AL_OBJ_TDELAYC 0x3401 /* 52 01 Time Delay Coarse */
  426. #define AL_OBJ_TDELAYF 0x3402 /* 52 02 Time Delay Fine */
  427. /***************************************************************************/
  428. /* Class Data Objects */
  429. #define AL_OBJ_CLASS0 0x3C01 /* 60 01 Class 0 Data */
  430. #define AL_OBJ_CLASS1 0x3C02 /* 60 02 Class 1 Data */
  431. #define AL_OBJ_CLASS2 0x3C03 /* 60 03 Class 2 Data */
  432. #define AL_OBJ_CLASS3 0x3C04 /* 60 04 Class 3 Data */
  433. /***************************************************************************/
  434. /* File Objects */
  435. #define AL_OBJ_FILE_CMD 0x4603 /* 70 03 File Control - Command */
  436. #define AL_OBJ_FILE_STAT 0x4604 /* 70 04 File Control - Status */
  437. #define AL_OBJ_FILE_TRANS 0x4605 /* 70 05 File Control - Transport */
  438. #define AL_OBJ_FILE_TRAN_ST 0x4606 /* 70 05 File Control - Transport Status */
  439. /* File Control Mode flags */
  440. #define AL_OBJ_FILE_MODE_NULL 0x00 /* NULL */
  441. #define AL_OBJ_FILE_MODE_READ 0x01 /* READ */
  442. #define AL_OBJ_FILE_MODE_WRITE 0x02 /* WRITE */
  443. #define AL_OBJ_FILE_MODE_APPEND 0x03 /* APPEND */
  444. /***************************************************************************/
  445. /* Device Objects */
  446. #define AL_OBJ_IIN 0x5001 /* 80 01 Internal Indications */
  447. /***************************************************************************/
  448. /* Octet String Objects */
  449. #define AL_OBJ_OCT 0x6E00 /* 110 xx Octet string */
  450. #define AL_OBJ_OCT_EVT 0x6F00 /* 110 xx Octet string event */
  451. /***************************************************************************/
  452. /* End of Application Layer Data Object Definitions */
  453. /***************************************************************************/
  454. void proto_register_dnp3(void);
  455. void proto_reg_handoff_dnp3(void);
  456. /* Initialize the protocol and registered fields */
  457. static int proto_dnp3 = -1;
  458. static int hf_dnp3_start = -1;
  459. static int hf_dnp3_len = -1;
  460. static int hf_dnp3_ctl = -1;
  461. static int hf_dnp3_ctl_prifunc = -1;
  462. static int hf_dnp3_ctl_secfunc = -1;
  463. static int hf_dnp3_ctl_dir = -1;
  464. static int hf_dnp3_ctl_prm = -1;
  465. static int hf_dnp3_ctl_fcb = -1;
  466. static int hf_dnp3_ctl_fcv = -1;
  467. static int hf_dnp3_ctl_dfc = -1;
  468. static int hf_dnp3_dst = -1;
  469. static int hf_dnp3_src = -1;
  470. static int hf_dnp_hdr_CRC = -1;
  471. static int hf_dnp_hdr_CRC_bad = -1;
  472. static int hf_dnp3_tr_ctl = -1;
  473. static int hf_dnp3_tr_fin = -1;
  474. static int hf_dnp3_tr_fir = -1;
  475. static int hf_dnp3_tr_seq = -1;
  476. static int hf_dnp3_al_ctl = -1;
  477. static int hf_dnp3_al_fir = -1;
  478. static int hf_dnp3_al_fin = -1;
  479. static int hf_dnp3_al_con = -1;
  480. static int hf_dnp3_al_uns = -1;
  481. static int hf_dnp3_al_seq = -1;
  482. static int hf_dnp3_al_func = -1;
  483. /* Added for Application Layer Decoding */
  484. static int hf_dnp3_al_iin = -1;
  485. static int hf_dnp3_al_iin_bmsg = -1;
  486. static int hf_dnp3_al_iin_cls1d = -1;
  487. static int hf_dnp3_al_iin_cls2d = -1;
  488. static int hf_dnp3_al_iin_cls3d = -1;
  489. static int hf_dnp3_al_iin_tsr = -1;
  490. static int hf_dnp3_al_iin_dol = -1;
  491. static int hf_dnp3_al_iin_dt = -1;
  492. static int hf_dnp3_al_iin_rst = -1;
  493. static int hf_dnp3_al_iin_fcni = -1;
  494. static int hf_dnp3_al_iin_obju = -1;
  495. static int hf_dnp3_al_iin_pioor = -1;
  496. static int hf_dnp3_al_iin_ebo = -1;
  497. static int hf_dnp3_al_iin_oae = -1;
  498. static int hf_dnp3_al_iin_cc = -1;
  499. static int hf_dnp3_al_obj = -1;
  500. static int hf_dnp3_al_objq_index = -1;
  501. static int hf_dnp3_al_objq_code = -1;
  502. static int hf_dnp3_al_range_start8 = -1;
  503. static int hf_dnp3_al_range_stop8 = -1;
  504. static int hf_dnp3_al_range_start16 = -1;
  505. static int hf_dnp3_al_range_stop16 = -1;
  506. static int hf_dnp3_al_range_start32 = -1;
  507. static int hf_dnp3_al_range_stop32 = -1;
  508. static int hf_dnp3_al_range_abs8 = -1;
  509. static int hf_dnp3_al_range_abs16 = -1;
  510. static int hf_dnp3_al_range_abs32 = -1;
  511. static int hf_dnp3_al_range_quant8 = -1;
  512. static int hf_dnp3_al_range_quant16 = -1;
  513. static int hf_dnp3_al_range_quant32 = -1;
  514. static int hf_dnp3_al_index8 = -1;
  515. static int hf_dnp3_al_index16 = -1;
  516. static int hf_dnp3_al_index32 = -1;
  517. static int hf_dnp3_al_size8 = -1;
  518. static int hf_dnp3_al_size16 = -1;
  519. static int hf_dnp3_al_size32 = -1;
  520. /*static int hf_dnp3_al_objq = -1;
  521. static int hf_dnp3_al_nobj = -1; */
  522. /* XXX - unused
  523. static int hf_dnp3_al_ptnum = -1; */
  524. static int hf_dnp3_al_biq_b0 = -1;
  525. static int hf_dnp3_al_biq_b1 = -1;
  526. static int hf_dnp3_al_biq_b2 = -1;
  527. static int hf_dnp3_al_biq_b3 = -1;
  528. static int hf_dnp3_al_biq_b4 = -1;
  529. static int hf_dnp3_al_biq_b5 = -1;
  530. static int hf_dnp3_al_biq_b6 = -1;
  531. static int hf_dnp3_al_biq_b7 = -1;
  532. static int hf_dnp3_al_boq_b0 = -1;
  533. static int hf_dnp3_al_boq_b1 = -1;
  534. static int hf_dnp3_al_boq_b2 = -1;
  535. static int hf_dnp3_al_boq_b3 = -1;
  536. static int hf_dnp3_al_boq_b4 = -1;
  537. static int hf_dnp3_al_boq_b5 = -1;
  538. static int hf_dnp3_al_boq_b6 = -1;
  539. static int hf_dnp3_al_boq_b7 = -1;
  540. static int hf_dnp3_al_ctrq_b0 = -1;
  541. static int hf_dnp3_al_ctrq_b1 = -1;
  542. static int hf_dnp3_al_ctrq_b2 = -1;
  543. static int hf_dnp3_al_ctrq_b3 = -1;
  544. static int hf_dnp3_al_ctrq_b4 = -1;
  545. static int hf_dnp3_al_ctrq_b5 = -1;
  546. static int hf_dnp3_al_ctrq_b6 = -1;
  547. static int hf_dnp3_al_ctrq_b7 = -1;
  548. static int hf_dnp3_al_aiq_b0 = -1;
  549. static int hf_dnp3_al_aiq_b1 = -1;
  550. static int hf_dnp3_al_aiq_b2 = -1;
  551. static int hf_dnp3_al_aiq_b3 = -1;
  552. static int hf_dnp3_al_aiq_b4 = -1;
  553. static int hf_dnp3_al_aiq_b5 = -1;
  554. static int hf_dnp3_al_aiq_b6 = -1;
  555. static int hf_dnp3_al_aiq_b7 = -1;
  556. static int hf_dnp3_al_aoq_b0 = -1;
  557. static int hf_dnp3_al_aoq_b1 = -1;
  558. static int hf_dnp3_al_aoq_b2 = -1;
  559. static int hf_dnp3_al_aoq_b3 = -1;
  560. static int hf_dnp3_al_aoq_b4 = -1;
  561. static int hf_dnp3_al_aoq_b5 = -1;
  562. static int hf_dnp3_al_aoq_b6 = -1;
  563. static int hf_dnp3_al_aoq_b7 = -1;
  564. static int hf_dnp3_al_timestamp = -1;
  565. static int hf_dnp3_al_file_perms = -1;
  566. static int hf_dnp3_al_file_perms_read_owner = -1;
  567. static int hf_dnp3_al_file_perms_write_owner = -1;
  568. static int hf_dnp3_al_file_perms_exec_owner = -1;
  569. static int hf_dnp3_al_file_perms_read_group = -1;
  570. static int hf_dnp3_al_file_perms_write_group = -1;
  571. static int hf_dnp3_al_file_perms_exec_group = -1;
  572. static int hf_dnp3_al_file_perms_read_world = -1;
  573. static int hf_dnp3_al_file_perms_write_world = -1;
  574. static int hf_dnp3_al_file_perms_exec_world = -1;
  575. static int hf_dnp3_al_rel_timestamp = -1;
  576. static int hf_dnp3_al_ana16 = -1;
  577. static int hf_dnp3_al_ana32 = -1;
  578. static int hf_dnp3_al_anaflt = -1;
  579. static int hf_dnp3_al_anadbl = -1;
  580. static int hf_dnp3_al_bit = -1;
  581. static int hf_dnp3_al_2bit = -1;
  582. static int hf_dnp3_al_cnt16 = -1;
  583. static int hf_dnp3_al_cnt32 = -1;
  584. static int hf_dnp3_al_ctrlstatus = -1;
  585. static int hf_dnp3_al_anaout16 = -1;
  586. static int hf_dnp3_al_anaout32 = -1;
  587. static int hf_dnp3_al_anaoutflt = -1;
  588. static int hf_dnp3_al_anaoutdbl = -1;
  589. static int hf_dnp3_al_file_mode = -1;
  590. static int hf_dnp3_al_file_auth = -1;
  591. static int hf_dnp3_al_file_size = -1;
  592. static int hf_dnp3_al_file_maxblk = -1;
  593. static int hf_dnp3_al_file_reqID = -1;
  594. static int hf_dnp3_al_file_handle = -1;
  595. static int hf_dnp3_al_file_status = -1;
  596. static int hf_dnp3_al_file_blocknum = -1;
  597. static int hf_dnp3_al_file_lastblock = -1;
  598. static int hf_dnp3_al_file_data = -1;
  599. static int hf_dnp3_ctlobj_code_c = -1;
  600. static int hf_dnp3_ctlobj_code_m = -1;
  601. static int hf_dnp3_ctlobj_code_tc = -1;
  602. /***************************************************************************/
  603. /* Value String Look-Ups */
  604. /***************************************************************************/
  605. static const value_string dnp3_ctl_func_pri_vals[] = {
  606. { DL_FUNC_RESET_LINK, "Reset of Remote Link" },
  607. { DL_FUNC_RESET_PROC, "Reset of User Process" },
  608. { DL_FUNC_TEST_LINK, "Test Function For Link" },
  609. { DL_FUNC_USER_DATA, "User Data" },
  610. { DL_FUNC_UNC_DATA, "Unconfirmed User Data" },
  611. { DL_FUNC_LINK_STAT, "Request Link Status" },
  612. { 0, NULL }
  613. };
  614. static const value_string dnp3_ctl_func_sec_vals[] = {
  615. { DL_FUNC_ACK, "ACK" },
  616. { DL_FUNC_NACK, "NACK" },
  617. { DL_FUNC_STAT_LINK, "Status of Link" },
  618. { DL_FUNC_NO_FUNC, "Link Service Not Functioning" },
  619. { DL_FUNC_NOT_IMPL, "Link Service Not Used or Implemented" },
  620. { 0, NULL }
  621. };
  622. #if 0
  623. static const value_string dnp3_ctl_flags_pri_vals[] = {
  624. { DNP3_CTL_DIR, "DIR" },
  625. { DNP3_CTL_PRM, "PRM" },
  626. { DNP3_CTL_FCB, "FCB" },
  627. { DNP3_CTL_FCV, "FCV" },
  628. { 0, NULL }
  629. };
  630. #endif
  631. #if 0
  632. static const value_string dnp3_ctl_flags_sec_vals[]= {
  633. { DNP3_CTL_DIR, "DIR" },
  634. { DNP3_CTL_PRM, "PRM" },
  635. { DNP3_CTL_RES, "RES" },
  636. { DNP3_CTL_DFC, "DFC" },
  637. { 0, NULL }
  638. };
  639. #endif
  640. #if 0
  641. static const value_string dnp3_tr_flags_vals[] = {
  642. { DNP3_TR_FIN, "FIN" },
  643. { DNP3_TR_FIR, "FIR" },
  644. { 0, NULL }
  645. };
  646. #endif
  647. #if 0
  648. static const value_string dnp3_al_flags_vals[] = {
  649. { DNP3_AL_FIR, "FIR" },
  650. { DNP3_AL_FIN, "FIN" },
  651. { DNP3_AL_CON, "CON" },
  652. { DNP3_AL_UNS, "UNS" },
  653. { 0, NULL }
  654. };
  655. #endif
  656. /* Application Layer Function Code Values */
  657. static const value_string dnp3_al_func_vals[] = {
  658. { AL_FUNC_CONFIRM, "Confirm" },
  659. { AL_FUNC_READ, "Read" },
  660. { AL_FUNC_WRITE, "Write" },
  661. { AL_FUNC_SELECT, "Select" },
  662. { AL_FUNC_OPERATE, "Operate" },
  663. { AL_FUNC_DIROP, "Direct Operate" },
  664. { AL_FUNC_DIROPNACK, "Direct Operate No Ack" },
  665. { AL_FUNC_FRZ, "Immediate Freeze" },
  666. { AL_FUNC_FRZNACK, "Immediate Freeze No Ack" },
  667. { AL_FUNC_FRZCLR, "Freeze and Clear" },
  668. { AL_FUNC_FRZCLRNACK, "Freeze and Clear No ACK" },
  669. { AL_FUNC_FRZT, "Freeze With Time" },
  670. { AL_FUNC_FRZTNACK, "Freeze With Time No ACK" },
  671. { AL_FUNC_COLDRST, "Cold Restart" },
  672. { AL_FUNC_WARMRST, "Warm Restart" },
  673. { AL_FUNC_INITDATA, "Initialize Data" },
  674. { AL_FUNC_INITAPP, "Initialize Application" },
  675. { AL_FUNC_STARTAPP, "Start Application" },
  676. { AL_FUNC_STOPAPP, "Stop Application" },
  677. { AL_FUNC_SAVECFG, "Save Configuration" },
  678. { AL_FUNC_ENSPMSG, "Enable Spontaneous Messages" },
  679. { AL_FUNC_DISSPMSG, "Disable Spontaneous Messages" },
  680. { AL_FUNC_ASSIGNCL, "Assign Classes" },
  681. { AL_FUNC_DELAYMST, "Delay Measurement" },
  682. { AL_FUNC_RECCT, "Record Current Time" },
  683. { AL_FUNC_OPENFILE, "Open File" },
  684. { AL_FUNC_CLOSEFILE, "Close File" },
  685. { AL_FUNC_DELETEFILE, "Delete File" },
  686. { AL_FUNC_GETFILEINF, "Get File Info" },
  687. { AL_FUNC_AUTHFILE, "Authenticate File" },
  688. { AL_FUNC_ABORTFILE, "Abort File" },
  689. { AL_FUNC_ACTCNF, "Activate Config" },
  690. { AL_FUNC_AUTHREQ, "Authentication Request" },
  691. { AL_FUNC_AUTHERR, "Authentication Error" },
  692. { AL_FUNC_RESPON, "Response" },
  693. { AL_FUNC_UNSOLI, "Unsolicited Response" },
  694. { AL_FUNC_AUTHRESP, "Authentication Response" },
  695. { 0, NULL }
  696. };
  697. static value_string_ext dnp3_al_func_vals_ext = VALUE_STRING_EXT_INIT(dnp3_al_func_vals);
  698. #if 0
  699. /* Application Layer Internal Indication (IIN) bit Values */
  700. static const value_string dnp3_al_iin_vals[] = {
  701. { AL_IIN_BMSG, "Broadcast message Rx'd" },
  702. { AL_IIN_CLS1D, "Class 1 Data Available" },
  703. { AL_IIN_CLS2D, "Class 2 Data Available" },
  704. { AL_IIN_CLS3D, "Class 3 Data Available" },
  705. { AL_IIN_TSR, "Time Sync Required from Master" },
  706. { AL_IIN_DOL, "Outputs in Local Mode" },
  707. { AL_IIN_DT, "Device Trouble" },
  708. { AL_IIN_RST, "Device Restart" },
  709. { AL_IIN_FCNI, "Function Code not implemented" },
  710. { AL_IIN_OBJU, "Requested Objects Unknown" },
  711. { AL_IIN_PIOOR, "Parameters Invalid or Out of Range" },
  712. { AL_IIN_EBO, "Event Buffer Overflow" },
  713. { AL_IIN_OAE, "Operation Already Executing" },
  714. { AL_IIN_CC, "Device Configuration Corrupt" },
  715. { 0, NULL }
  716. };
  717. #endif
  718. /* Application Layer Object Qualifier Index Values When Qualifier Code != 11 */
  719. static const value_string dnp3_al_objq_index_vals[] = {
  720. { AL_OBJQL_IDX_NI, "None" },
  721. { AL_OBJQL_IDX_1O, "1-Octet Indexing" },
  722. { AL_OBJQL_IDX_2O, "2-Octet Indexing" },
  723. { AL_OBJQL_IDX_4O, "4-Octet Indexing" },
  724. { AL_OBJQL_IDX_1OS, "1-Octet Object Size" },
  725. { AL_OBJQL_IDX_2OS, "2-Octet Object Size" },
  726. { AL_OBJQL_IDX_4OS, "4-Octet Object Size" },
  727. { 0, NULL }
  728. };
  729. static value_string_ext dnp3_al_objq_index_vals_ext = VALUE_STRING_EXT_INIT(dnp3_al_objq_index_vals);
  730. /* Application Layer Object Qualifier Code Values */
  731. static const value_string dnp3_al_objq_code_vals[] = {
  732. { AL_OBJQL_CODE_SSI8, "8-bit Start and Stop Indices" },
  733. { AL_OBJQL_CODE_SSI16, "16-bit Start and Stop Indices" },
  734. { AL_OBJQL_CODE_SSI32, "32-bit Start and Stop Indices" },
  735. { AL_OBJQL_CODE_AA8, "8-bit Absolute Address in Range Field" },
  736. { AL_OBJQL_CODE_AA16, "16-bit Absolute Address in Range Field" },
  737. { AL_OBJQL_CODE_AA32, "32-bit Absolute Address in Range Field" },
  738. { AL_OBJQL_CODE_R0, "No Range Field" },
  739. { AL_OBJQL_CODE_SF8, "8-bit Single Field Quantity" },
  740. { AL_OBJQL_CODE_SF16, "16-bit Single Field Quantity" },
  741. { AL_OBJQL_CODE_SF32, "32-bit Single Field Quantity" },
  742. { 10, "Reserved" },
  743. { AL_OBJQL_CODE_FF, "Free-format Qualifier" },
  744. { 0, NULL }
  745. };
  746. static value_string_ext dnp3_al_objq_code_vals_ext = VALUE_STRING_EXT_INIT(dnp3_al_objq_code_vals);
  747. /* Application Layer Data Object Values */
  748. static const value_string dnp3_al_obj_vals[] = {
  749. { AL_OBJ_BI_ALL, "Binary Input Default Variation (Obj:01, Var:Default)" },
  750. { AL_OBJ_BI_1BIT, "Single-Bit Binary Input (Obj:01, Var:01)" },
  751. { AL_OBJ_BI_STAT, "Binary Input With Status (Obj:01, Var:02)" },
  752. { AL_OBJ_BIC_ALL, "Binary Input Change Default Variation (Obj:02, Var:Default)" },
  753. { AL_OBJ_BIC_NOTIME, "Binary Input Change Without Time (Obj:02, Var:01)" },
  754. { AL_OBJ_BIC_TIME, "Binary Input Change With Time (Obj:02, Var:02)" },
  755. { AL_OBJ_BIC_RTIME, "Binary Input Change With Relative Time (Obj:02, Var:03)" },
  756. { AL_OBJ_2BI_ALL, "Double-bit Input Default Variation (Obj:03, Var:Default)" },
  757. { AL_OBJ_2BI_NF, "Double-bit Input No Flags (Obj:03, Var:01)" },
  758. { AL_OBJ_2BI_STAT, "Double-bit Input With Status (Obj:03, Var:02)" },
  759. { AL_OBJ_2BIC_NOTIME, "Double-bit Input Change Without Time (Obj:04, Var:01)" },
  760. { AL_OBJ_2BIC_TIME, "Double-bit Input Change With Time (Obj:04, Var:02)" },
  761. { AL_OBJ_2BIC_RTIME, "Double-bit Input Change With Relative Time (Obj:04, Var:03)" },
  762. { AL_OBJ_BO_ALL, "Binary Output Default Variation (Obj:10, Var:Default)" },
  763. { AL_OBJ_BO, "Binary Output (Obj:10, Var:01)" },
  764. { AL_OBJ_BO_STAT, "Binary Output Status (Obj:10, Var:02)" },
  765. { AL_OBJ_BOC_ALL, "Binary Output Change Default Variation (Obj:11, Var:Default)" },
  766. { AL_OBJ_BOC_NOTIME, "Binary Output Change Without Time (Obj:11, Var:01)" },
  767. { AL_OBJ_BOC_TIME, "Binary Output Change With Time (Obj:11, Var:02)" },
  768. { AL_OBJ_CTLOP_BLK, "Control Relay Output Block (Obj:12, Var:01)" },
  769. { AL_OBJ_CTR_ALL, "Binary Counter Default Variation (Obj:20, Var:Default)" },
  770. { AL_OBJ_CTR_32, "32-Bit Binary Counter (Obj:20, Var:01)" },
  771. { AL_OBJ_CTR_16, "16-Bit Binary Counter (Obj:20, Var:02)" },
  772. { AL_OBJ_DCTR_32, "32-Bit Binary Delta Counter (Obj:20, Var:03)" },
  773. { AL_OBJ_DCTR_16, "16-Bit Binary Delta Counter (Obj:20, Var:04)" },
  774. { AL_OBJ_CTR_32NF, "32-Bit Binary Counter Without Flag (Obj:20, Var:05)" },
  775. { AL_OBJ_CTR_16NF, "16-Bit Binary Counter Without Flag (Obj:20, Var:06)" },
  776. { AL_OBJ_DCTR_32NF, "32-Bit Binary Delta Counter Without Flag (Obj:20, Var:07)" },
  777. { AL_OBJ_DCTR_16NF, "16-Bit Binary Delta Counter Without Flag (Obj:20, Var:08)" },
  778. { AL_OBJ_FCTR_ALL, "Frozen Binary Counter Default Variation (Obj:21, Var:Default)" },
  779. { AL_OBJ_FCTR_32, "32-Bit Frozen Binary Counter (Obj:21, Var:01)" },
  780. { AL_OBJ_FCTR_16, "16-Bit Frozen Binary Counter (Obj:21, Var:02)" },
  781. { AL_OBJ_FDCTR_32, "32-Bit Frozen Binary Delta Counter (Obj:21, Var:03)" },
  782. { AL_OBJ_FDCTR_16, "16-Bit Frozen Binary Delta Counter (Obj:21, Var:04)" },
  783. { AL_OBJ_FCTR_32T, "32-Bit Frozen Binary Counter (Obj:21, Var:01)" },
  784. { AL_OBJ_FCTR_16T, "16-Bit Frozen Binary Counter (Obj:21, Var:02)" },
  785. { AL_OBJ_FDCTR_32T, "32-Bit Frozen Binary Delta Counter (Obj:21, Var:03)" },
  786. { AL_OBJ_FDCTR_16T, "16-Bit Frozen Binary Delta Counter (Obj:21, Var:04)" },
  787. { AL_OBJ_FCTR_32NF, "32-Bit Frozen Binary Counter Without Flag (Obj:21, Var:05)" },
  788. { AL_OBJ_FCTR_16NF, "16-Bit Frozen Binary Counter Without Flag (Obj:21, Var:06)" },
  789. { AL_OBJ_FDCTR_32NF, "32-Bit Frozen Binary Delta Counter Without Flag (Obj:21, Var:07)" },
  790. { AL_OBJ_FDCTR_16NF, "16-Bit Frozen Binary Delta Counter Without Flag (Obj:21, Var:08)" },
  791. { AL_OBJ_CTRC_ALL, "Binary Counter Change Default Variation (Obj:22, Var:Default)" },
  792. { AL_OBJ_CTRC_32, "32-Bit Counter Change Event w/o Time (Obj:22, Var:01)" },
  793. { AL_OBJ_CTRC_16, "16-Bit Counter Change Event w/o Time (Obj:22, Var:02)" },
  794. { AL_OBJ_DCTRC_32, "32-Bit Delta Counter Change Event w/o Time (Obj:22, Var:03)" },
  795. { AL_OBJ_DCTRC_16, "16-Bit Delta Counter Change Event w/o Time (Obj:22, Var:04)" },
  796. { AL_OBJ_CTRC_32T, "32-Bit Counter Change Event with Time (Obj:22, Var:05)" },
  797. { AL_OBJ_CTRC_16T, "16-Bit Counter Change Event with Time (Obj:22, Var:06)" },
  798. { AL_OBJ_DCTRC_32T, "32-Bit Delta Counter Change Event with Time (Obj:22, Var:07)" },
  799. { AL_OBJ_DCTRC_16T, "16-Bit Delta Counter Change Event with Time (Obj:22, Var:08)" },
  800. { AL_OBJ_FCTRC_ALL, "Frozen Binary Counter Change Default Variation (Obj:23, Var:Default)" },
  801. { AL_OBJ_FCTRC_32, "32-Bit Frozen Counter Change Event w/o Time (Obj:23, Var:01)" },
  802. { AL_OBJ_FCTRC_16, "16-Bit Frozen Counter Change Event w/o Time (Obj:23, Var:02)" },
  803. { AL_OBJ_FDCTRC_32, "32-Bit Frozen Delta Counter Change Event w/o Time (Obj:23, Var:03)" },
  804. { AL_OBJ_FDCTRC_16, "16-Bit Frozen Delta Counter Change Event w/o Time (Obj:23, Var:04)" },
  805. { AL_OBJ_FCTRC_32T, "32-Bit Frozen Counter Change Event with Time (Obj:23, Var:05)" },
  806. { AL_OBJ_FCTRC_16T, "16-Bit Frozen Counter Change Event with Time (Obj:23, Var:06)" },
  807. { AL_OBJ_FDCTRC_32T, "32-Bit Frozen Delta Counter Change Event with Time (Obj:23, Var:07)" },
  808. { AL_OBJ_FDCTRC_16T, "16-Bit Frozen Delta Counter Change Event with Time (Obj:23, Var:08)" },
  809. { AL_OBJ_AI_ALL, "Analog Input Default Variation (Obj:30, Var:Default)" },
  810. { AL_OBJ_AI_32, "32-Bit Analog Input (Obj:30, Var:01)" },
  811. { AL_OBJ_AI_16, "16-Bit Analog Input (Obj:30, Var:02)" },
  812. { AL_OBJ_AI_32NF, "32-Bit Analog Input Without Flag (Obj:30, Var:03)" },
  813. { AL_OBJ_AI_16NF, "16-Bit Analog Input Without Flag (Obj:30, Var:04)" },
  814. { AL_OBJ_AI_FLT, "32-Bit Floating Point Input (Obj:30, Var:05)" },
  815. { AL_OBJ_AI_DBL, "64-Bit Floating Point Input (Obj:30, Var:06)" },
  816. { AL_OBJ_AIF_FLT, "32-Bit Frozen Floating Point Input (Obj:31, Var:07)" },
  817. { AL_OBJ_AIF_DBL, "64-Bit Frozen Floating Point Input (Obj:31, Var:08)" },
  818. { AL_OBJ_AIC_ALL, "Analog Input Change Default Variation (Obj:32, Var:Default)" },
  819. { AL_OBJ_AIC_32NT, "32-Bit Analog Change Event w/o Time (Obj:32, Var:01)" },
  820. { AL_OBJ_AIC_16NT, "16-Bit Analog Change Event w/o Time (Obj:32, Var:02)" },
  821. { AL_OBJ_AIC_32T, "32-Bit Analog Change Event with Time (Obj:32, Var:03)" },
  822. { AL_OBJ_AIC_16T, "16-Bit Analog Change Event with Time (Obj:32, Var:04)" },
  823. { AL_OBJ_AIC_FLTNT, "32-Bit Floating Point Change Event w/o Time (Obj:32, Var:05)" },
  824. { AL_OBJ_AIC_DBLNT, "64-Bit Floating Point Change Event w/o Time (Obj:32, Var:06)" },
  825. { AL_OBJ_AIC_FLTT, "32-Bit Floating Point Change Event w/ Time (Obj:32, Var:07)" },
  826. { AL_OBJ_AIC_DBLT, "64-Bit Floating Point Change Event w/ Time (Obj:32, Var:08)" },
  827. { AL_OBJ_AIFC_FLTNT, "32-Bit Floating Point Frozen Change Event w/o Time (Obj:33, Var:05)" },
  828. { AL_OBJ_AIFC_DBLNT, "64-Bit Floating Point Frozen Change Event w/o Time (Obj:33, Var:06)" },
  829. { AL_OBJ_AIFC_FLTT, "32-Bit Floating Point Frozen Change Event w/ Time (Obj:33, Var:07)" },
  830. { AL_OBJ_AIFC_DBLT, "64-Bit Floating Point Frozen Change Event w/ Time (Obj:33, Var:08)" },
  831. { AL_OBJ_AIDB_ALL, "Analog Input Deadband Default Variation (Obj:34, Var:Default)" },
  832. { AL_OBJ_AIDB_16, "16-Bit Analog Input Deadband (Obj:34, Var:01)" },
  833. { AL_OBJ_AIDB_32, "32-Bit Analog Input Deadband (Obj:34, Var:02)" },
  834. { AL_OBJ_AIDB_FLT, "32-Bit Floating Point Analog Input Deadband (Obj:34, Var:03)" },
  835. { AL_OBJ_AO_ALL, "Analog Output Default Variation (Obj:40, Var:Default)" },
  836. { AL_OBJ_AO_32, "32-Bit Analog Output Status (Obj:40, Var:01)" },
  837. { AL_OBJ_AO_16, "16-Bit Analog Output Status (Obj:40, Var:02)" },
  838. { AL_OBJ_AO_FLT, "32-Bit Floating Point Output Status (Obj:40, Var:03)" },
  839. { AL_OBJ_AO_DBL, "64-Bit Floating Point Output Status (Obj:40, Var:04)" },
  840. { AL_OBJ_AO_32OPB, "32-Bit Analog Output Block (Obj:41, Var:01)" },
  841. { AL_OBJ_AO_16OPB, "16-Bit Analog Output Block (Obj:41, Var:02)" },
  842. { AL_OBJ_AO_FLTOPB, "32-Bit Floating Point Output Block (Obj:41, Var:03)" },
  843. { AL_OBJ_AO_DBLOPB, "64-Bit Floating Point Output Block (Obj:41, Var:04)" },
  844. { AL_OBJ_AOC_ALL, "Analog Output Event Default Variation (Obj:42, Var:Default)" },
  845. { AL_OBJ_AOC_32NT, "32-Bit Analog Output Event w/o Time (Obj:42, Var:01)" },
  846. { AL_OBJ_AOC_16NT, "16-Bit Analog Output Event w/o Time (Obj:42, Var:02)" },
  847. { AL_OBJ_AOC_32T, "32-Bit Analog Output Event with Time (Obj:42, Var:03)" },
  848. { AL_OBJ_AOC_16T, "16-Bit Analog Output Event with Time (Obj:42, Var:04)" },
  849. { AL_OBJ_AOC_FLTNT, "32-Bit Floating Point Output Event w/o Time (Obj:42, Var:05)" },
  850. { AL_OBJ_AOC_DBLNT, "64-Bit Floating Point Output Event w/o Time (Obj:42, Var:06)" },
  851. { AL_OBJ_AOC_FLTT, "32-Bit Floating Point Output Event w/ Time (Obj:42, Var:07)" },
  852. { AL_OBJ_AOC_DBLT, "64-Bit Floating Point Output Event w/ Time (Obj:42, Var:08)" },
  853. { AL_OBJ_TD_ALL, "Time and Date Default Variations (Obj:50, Var:Default)" },
  854. { AL_OBJ_TD, "Time and Date (Obj:50, Var:01)" },
  855. { AL_OBJ_TDI, "Time and Date w/Interval (Obj:50, Var:02)" },
  856. { AL_OBJ_TDR, "Last Recorded Time and Date (Obj:50, Var:03)" },
  857. { AL_OBJ_TDCTO, "Time and Date CTO (Obj:51, Var:01)" },
  858. { AL_OBJ_TDELAYF, "Time Delay - Fine (Obj:52, Var:02)" },
  859. { AL_OBJ_CLASS0, "Class 0 Data (Obj:60, Var:01)" },
  860. { AL_OBJ_CLASS1, "Class 1 Data (Obj:60, Var:02)" },
  861. { AL_OBJ_CLASS2, "Class 2 Data (Obj:60, Var:03)" },
  862. { AL_OBJ_CLASS3, "Class 3 Data (Obj:60, Var:04)" },
  863. { AL_OBJ_FILE_CMD, "File Control - File Command (Obj:70, Var:03)" },
  864. { AL_OBJ_FILE_STAT, "File Control - File Status (Obj:70, Var:04)" },
  865. { AL_OBJ_FILE_TRANS, "File Control - File Transport (Obj:70, Var:05)" },
  866. { AL_OBJ_FILE_TRAN_ST, "File Control - File Transport Status (Obj:70, Var:06)" },
  867. { AL_OBJ_IIN, "Internal Indications (Obj:80, Var:01)" },
  868. { AL_OBJ_OCT, "Octet String (Obj:110)" },
  869. { AL_OBJ_OCT_EVT, "Octet String Event (Obj:111)" },
  870. { 0, NULL }
  871. };
  872. static value_string_ext dnp3_al_obj_vals_ext =

Large files files are truncated, but you can click here to view the full file