MSWSP: add two more Property Sets
[wireshark-wip.git] / epan / dissectors / packet-mbtcp.h
blobba53509c768242764479f062d8341ee0d72e5421
1 /* packet-mbtcp.h
3 * Routines for Modbus/TCP dissection
4 * By Riaan Swart <rswart@cs.sun.ac.za>
5 * Copyright 2001, Institute for Applied Computer Science
6 * University of Stellenbosch
8 * See http://www.modbus.org/ for information on Modbus/TCP.
10 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #define PORT_MBTCP 502 /* Modbus/TCP located on port 502, with IANA registration */
31 #define PORT_MBRTU 0 /* Modbus RTU over TCP does not have a standard port, default to zero */
33 /* Modbus protocol function codes */
34 #define READ_COILS 1
35 #define READ_DISCRETE_INPUTS 2
36 #define READ_HOLDING_REGS 3
37 #define READ_INPUT_REGS 4
38 #define WRITE_SINGLE_COIL 5
39 #define WRITE_SINGLE_REG 6
40 #define READ_EXCEPT_STAT 7
41 #define DIAGNOSTICS 8
42 #define GET_COMM_EVENT_CTRS 11
43 #define GET_COMM_EVENT_LOG 12
44 #define WRITE_MULT_COILS 15
45 #define WRITE_MULT_REGS 16
46 #define REPORT_SLAVE_ID 17
47 #define READ_FILE_RECORD 20
48 #define WRITE_FILE_RECORD 21
49 #define MASK_WRITE_REG 22
50 #define READ_WRITE_REG 23
51 #define READ_FIFO_QUEUE 24
52 #define ENCAP_INTERFACE_TRANSP 43
54 /* Modbus protocol exception codes */
55 #define ILLEGAL_FUNCTION 0x01
56 #define ILLEGAL_ADDRESS 0x02
57 #define ILLEGAL_VALUE 0x03
58 #define SLAVE_FAILURE 0x04
59 #define ACKNOWLEDGE 0x05
60 #define SLAVE_BUSY 0x06
61 #define MEMORY_ERR 0x08
62 #define GATEWAY_UNAVAILABLE 0x0a
63 #define GATEWAY_TRGT_FAIL 0x0b
65 /* Modbus diagnostic subfunction codes */
66 #define RETURN_QUERY_DATA 0x00
67 #define RESTART_COMMUNICATION_OPTION 0x01
68 #define RETURN_DIAGNOSTIC_REGISTER 0x02
69 #define CHANGE_ASCII_INPUT_DELIMITER 0x03
70 #define FORCE_LISTEN_ONLY_MODE 0x04
71 #define CLEAR_COUNTERS_AND_DIAG_REG 0x0A
72 #define RETURN_BUS_MESSAGE_COUNT 0x0B
73 #define RETURN_BUS_COMM_ERROR_COUNT 0x0C
74 #define RETURN_BUS_EXCEPTION_ERROR_COUNT 0x0D
75 #define RETURN_SLAVE_MESSAGE_COUNT 0x0E
76 #define RETURN_SLAVE_NO_RESPONSE_COUNT 0x0F
77 #define RETURN_SLAVE_NAK_COUNT 0x10
78 #define RETURN_SLAVE_BUSY_COUNT 0x11
79 #define RETURN_BUS_CHAR_OVERRUN_COUNT 0x12
80 #define CLEAR_OVERRUN_COUNTER_AND_FLAG 0x14
84 /* Encapsulation Interface codes */
85 #define CANOPEN_REQ_RESP 0x0D
86 #define READ_DEVICE_ID 0x0E
88 /* Event byte codes */
89 #define REMOTE_DEVICE_RECV_EVENT_MASK 0x80
90 #define REMOTE_DEVICE_SEND_EVENT_MASK 0xc0
91 #define REMOTE_DEVICE_SEND_EVENT_VALUE 0x40
93 /* return codes of function classifying packets as query/response */
94 #define QUERY_PACKET 0
95 #define RESPONSE_PACKET 1
96 #define CANNOT_CLASSIFY 2
98 #define MODBUS_PROTOCOL_ID 0
100 /* Preferences for Modbus/TCP Dissector */
101 #define MBTCP_PREF_REGISTER_FORMAT_UINT16 0
102 #define MBTCP_PREF_REGISTER_FORMAT_UINT32 1
103 #define MBTCP_PREF_REGISTER_FORMAT_IEEE_FLOAT 2
104 #define MBTCP_PREF_REGISTER_FORMAT_MODICON_FLOAT 3
106 #define MBTCP_PREF_REGISTER_ADDR_RAW 0
107 #define MBTCP_PREF_REGISTER_ADDR_MOD5 1
108 #define MBTCP_PREF_REGISTER_ADDR_MOD6 2
111 typedef struct {
112 guint8 register_format;
113 guint8 register_addr_type;
114 guint8 packet_type;
115 } modbus_request_info_t;