Wireshark
4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
epan
dissectors
packet-mbtcp.h
1
/* packet-mbtcp.h
2
*
3
* Routines for Modbus/TCP dissection
4
* By Riaan Swart <
[email protected]
>
5
* Copyright 2001, Institute for Applied Computer Science
6
* University of Stellenbosch
7
*
8
* See http://www.modbus.org/ for information on Modbus/TCP.
9
*
10
* Wireshark - Network traffic analyzer
11
* By Gerald Combs <
[email protected]
>
12
* Copyright 1998 Gerald Combs
13
*
14
* SPDX-License-Identifier: GPL-2.0-or-later
15
*/
16
#define PORT_MBTCP 502
/* Modbus/TCP located on port 502, with IANA registration */
17
#define PORT_MBTLS 802
/* Modbus/TCP Security protocol (Modbus/TCP over TLS) is registered on port 802 */
18
#define PORT_MBRTU 0
/* Modbus RTU over TCP does not have a standard port, default to zero */
19
20
/* Modbus protocol function codes */
21
#define READ_COILS 1
22
#define READ_DISCRETE_INPUTS 2
23
#define READ_HOLDING_REGS 3
24
#define READ_INPUT_REGS 4
25
#define WRITE_SINGLE_COIL 5
26
#define WRITE_SINGLE_REG 6
27
#define READ_EXCEPT_STAT 7
28
#define DIAGNOSTICS 8
29
#define GET_COMM_EVENT_CTRS 11
30
#define GET_COMM_EVENT_LOG 12
31
#define WRITE_MULT_COILS 15
32
#define WRITE_MULT_REGS 16
33
#define REPORT_SLAVE_ID 17
34
#define READ_FILE_RECORD 20
35
#define WRITE_FILE_RECORD 21
36
#define MASK_WRITE_REG 22
37
#define READ_WRITE_REG 23
38
#define READ_FIFO_QUEUE 24
39
#define ENCAP_INTERFACE_TRANSP 43
40
#define UNITY_SCHNEIDER 90
41
42
/* Modbus protocol exception codes */
43
#define ILLEGAL_FUNCTION 0x01
44
#define ILLEGAL_ADDRESS 0x02
45
#define ILLEGAL_VALUE 0x03
46
#define SLAVE_FAILURE 0x04
47
#define ACKNOWLEDGE 0x05
48
#define SLAVE_BUSY 0x06
49
#define MEMORY_ERR 0x08
50
#define GATEWAY_UNAVAILABLE 0x0a
51
#define GATEWAY_TRGT_FAIL 0x0b
52
53
/* Modbus diagnostic subfunction codes */
54
#define RETURN_QUERY_DATA 0x00
55
#define RESTART_COMMUNICATION_OPTION 0x01
56
#define RETURN_DIAGNOSTIC_REGISTER 0x02
57
#define CHANGE_ASCII_INPUT_DELIMITER 0x03
58
#define FORCE_LISTEN_ONLY_MODE 0x04
59
#define CLEAR_COUNTERS_AND_DIAG_REG 0x0A
60
#define RETURN_BUS_MESSAGE_COUNT 0x0B
61
#define RETURN_BUS_COMM_ERROR_COUNT 0x0C
62
#define RETURN_BUS_EXCEPTION_ERROR_COUNT 0x0D
63
#define RETURN_SLAVE_MESSAGE_COUNT 0x0E
64
#define RETURN_SLAVE_NO_RESPONSE_COUNT 0x0F
65
#define RETURN_SLAVE_NAK_COUNT 0x10
66
#define RETURN_SLAVE_BUSY_COUNT 0x11
67
#define RETURN_BUS_CHAR_OVERRUN_COUNT 0x12
68
#define CLEAR_OVERRUN_COUNTER_AND_FLAG 0x14
69
70
71
72
/* Encapsulation Interface codes */
73
#define CANOPEN_REQ_RESP 0x0D
74
#define READ_DEVICE_ID 0x0E
75
76
/* Event byte codes */
77
#define REMOTE_DEVICE_RECV_EVENT_MASK 0x80
78
#define REMOTE_DEVICE_SEND_EVENT_MASK 0xc0
79
#define REMOTE_DEVICE_SEND_EVENT_VALUE 0x40
80
81
/* return codes of function classifying packets as query/response */
82
#define QUERY_PACKET 0
83
#define RESPONSE_PACKET 1
84
#define CANNOT_CLASSIFY 2
85
86
#define MODBUS_PROTOCOL_ID 0
87
88
/* Preferences for Modbus/TCP Dissector */
89
#define MODBUS_PREF_REGISTER_FORMAT_UINT16 0
90
#define MODBUS_PREF_REGISTER_FORMAT_UINT32 1
91
#define MODBUS_PREF_REGISTER_FORMAT_IEEE_FLOAT 2
92
#define MODBUS_PREF_REGISTER_FORMAT_MODICON_FLOAT 3
93
#define MODBUS_PREF_REGISTER_FORMAT_INT16 4
94
#define MODBUS_PREF_REGISTER_FORMAT_INT32 5
95
96
typedef
struct
{
97
uint32_t fnum;
98
uint8_t function_code;
99
uint16_t mbtcp_transid;
100
uint8_t unit_id;
101
uint16_t base_address;
102
uint16_t num_reg;
103
nstime_t
req_time;
104
}
modbus_request_info_t
;
105
106
typedef
struct
{
107
int
packet_type;
108
uint16_t mbtcp_transid;
/* Set to zero if not available */
109
uint8_t unit_id;
/* Set to zero if not available */
110
}
modbus_data_t
;
111
112
/* List contains request data */
113
typedef
struct
{
114
wmem_list_t
*modbus_request_frame_data;
115
int
register_format;
116
}
modbus_conversation
;
117
118
/*
119
* Editor modelines
120
*
121
* Local Variables:
122
* c-basic-offset: 4
123
* tab-width: 8
124
* indent-tabs-mode: nil
125
* End:
126
*
127
* ex: set shiftwidth=4 tabstop=8 expandtab:
128
* :indentSize=4:tabSize=8:noTabs=true:
129
*/
wmem_list_t
struct _wmem_list_t wmem_list_t
Opaque type representing a scoped, doubly-linked list in the wmem system.
Definition
wmem_list.h:42
modbus_conversation
Definition
packet-mbtcp.h:113
modbus_data_t
Definition
packet-mbtcp.h:106
modbus_request_info_t
Definition
packet-mbtcp.h:96
nstime_t
Definition
nstime.h:26
Generated by
1.15.0