summaryrefslogtreecommitdiffstats
path: root/src/knx/netip/qknxnetip.h
blob: 96e3a63c99eb4143b9f8a82d78d971f963e5a261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
/******************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtKnx module.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
******************************************************************************/

#ifndef QKNXNETIP_H
#define QKNXNETIP_H

#include <QtKnx/qtknxglobal.h>
#include <QtKnx/qknxnamespace.h>

QT_BEGIN_NAMESPACE

namespace QKnx
{
    namespace NetIp
    {
        Q_KNX_EXPORT Q_NAMESPACE

        struct Constants
        {
            static constexpr const quint16 DefaultPort = 3671;
            static constexpr const char *MulticastAddress = "224.0.23.12";
        };

        enum class HostProtocol : quint8
        {
            Unknown = 0x00,
            UDP_IPv4 = 0x01,
            TCP_IPv4 = 0x02
        };
        Q_ENUM_NS(HostProtocol)
        Q_KNX_EXPORT bool isStructType(HostProtocol type);

        enum class ConnectionType : quint8
        {
            Unknown = 0x00,
            DeviceManagement = 0x03,
            Tunnel = 0x04,
            RemoteLogging = 0x06,
            RemoteConfiguration = 0x07,
            ObjectServer = 0x08
        };
        Q_ENUM_NS(ConnectionType)
        Q_KNX_EXPORT bool isStructType(ConnectionType type);

        enum class DescriptionType : quint8
        {
            Unknown = 0x00,
            DeviceInfo = 0x01,
            SupportedServiceFamilies = 0x02,
            IpConfiguration = 0x03,
            CurrentIpConfiguration = 0x04,
            KnxAddresses = 0x05,
            SecuredServices = 0x06,
            TunnelingInfo = 0x07,
            ExtendedDeviceInfo = 0x08,
            ManufacturerData = 0xfe,
            NotUsed = 0xff
        };
        Q_ENUM_NS(DescriptionType)
        Q_KNX_EXPORT bool isStructType(DescriptionType type);

        enum class ServiceFamily : quint8
        {
            Unknown = 0x00,
            Core = 0x02,
            DeviceManagement = 0x03,
            IpTunneling = 0x04,
            IpRouting = 0x05,
            RemoteLogging = 0x06,
            RemoteConfigAndDiagnosis = 0x07,
            ObjectServer = 0x08,
            Security = 0x09
        };
        Q_ENUM_NS(ServiceFamily)
        Q_KNX_EXPORT bool isServiceFamily(ServiceFamily family);

        enum class ServiceType : quint16
        {
            Unknown = 0x0000,

            // KNXnet/IP Core service type identifiers
            SearchRequest = 0x0201,
            SearchResponse = 0x0202,
            DescriptionRequest = 0x0203,
            DescriptionResponse = 0x0204,
            ConnectRequest = 0x0205,
            ConnectResponse = 0x0206,
            ConnectionStateRequest = 0x0207,
            ConnectionStateResponse = 0x0208,
            DisconnectRequest = 0x0209,
            DisconnectResponse = 0x020a,
            ExtendedSearchRequest = 0x020b,
            ExtendedSearchResponse = 0x020c,

            // KNXnet/IP Device Management service type identifiers
            DeviceConfigurationRequest = 0x0310,
            DeviceConfigurationAcknowledge = 0x0311,

            // KNXnet/IP Tunneling service type identifiers
            TunnelingRequest = 0x0420,
            TunnelingAcknowledge = 0x0421,
            TunnelingFeatureGet = 0x0422,
            TunnelingFeatureResponse = 0x0423,
            TunnelingFeatureSet = 0x0424,
            TunnelingFeatureInfo = 0x0425,

            // KNXnet/IP Routing service type identifier
            RoutingIndication = 0x0530,
            RoutingLostMessage = 0x0531,
            RoutingBusy = 0x0532,
            RoutingSystemBroadcast = 0x0533,

            // KNXnet/IP Security service type identifier
            SecureWrapper = 0x0950,
            SessionRequest = 0x0951,
            SessionResponse = 0x0952,
            SessionAuthenticate = 0x0953,
            SessionStatus = 0x0954,
            TimerNotify = 0x0955

        };
        Q_ENUM_NS(ServiceType)
        Q_KNX_EXPORT bool isServiceType(ServiceType type);

        enum class Error : quint8
        {
            None = 0x00,
            HostProtocolType = 0x01,
            VersionNotSupported = 0x02,
            SequenceNumber = 0x04,
            Error = 0x0f,
            ConnectionId = 0x21,
            ConnectionType = 0x22,
            ConnectionOption = 0x23,
            NoMoreConnections = 0x24,
            NoMoreUniqueConnections = 0x25,
            DataConnection = 0x26,
            KnxConnection = 0x27,
            Authorization = 0x28,
            TunnelingLayer = 0x29,
            NoTunnelingAddress = 0x2d,
            ConnectionInUse = 0x2e
        };
        Q_ENUM_NS(Error)

        enum class DeviceState : quint8
        {
            KnxFault = 0x00,
            IpFault = 0x01
        };
        Q_ENUM_NS(DeviceState)

        enum class TunnelLayer : quint8
        {
            Unknown = 0x00,
            Link = 0x02,
            Raw = 0x04,
            Busmonitor = 0x80
        };
        Q_ENUM_NS(TunnelLayer)
        Q_KNX_EXPORT bool isTunnelLayer(TunnelLayer layer);

        enum class ProgrammingMode : quint8
        {
            Inactive = 0x00,
            Active = 0x01,
            Unknown = 0xff
        };
        Q_ENUM_NS(ProgrammingMode)
        Q_KNX_EXPORT bool isProgrammingMode(ProgrammingMode mode);

        enum class AssignmentMethod : quint8
        {
            Unknown = 0x00,
            Manual = 0x01,
            BootP = 0x02,
            Dhcp = 0x04,
            AutoIp = 0x08
        };
        Q_ENUM_NS(AssignmentMethod)
        Q_DECLARE_FLAGS(AssignmentMethods, AssignmentMethod)
        Q_KNX_EXPORT bool isAssignmentMethod(AssignmentMethod method);

        enum class Capability : quint8
        {
            Unknown = 0x00,
            BootP = 0x01,
            Dhcp = 0x02,
            AutoIp = 0x04,
        };
        Q_ENUM_NS(Capability)
        Q_DECLARE_FLAGS(Capabilities, Capability)
        Q_KNX_EXPORT bool isCapability(Capability capability);

        enum Timeout
        {
            HeartbeatTimeout = 60000,
            ConnectionAliveTimeout = 120000,

            // KNXnet/IP Core service time out in ms
            SearchTimeout = 3000,
            DescriptionTimeout = 3000,

            ConnectRequestTimeout = 10000,
            ConnectionStateRequestTimeout = 10000,
            DisconnectRequestTimeout = 10000,

            // KNXnet/IP Device Management service time out in ms
            DeviceConfigurationRequestTimeout = 10000,

            // KNXnet/IP Tunneling service time out in ms
            TunnelingRequestTimeout = 1000,

            // KNXnet/IP routing service
            RoutingBusyWaitTime = 100,

            // KNXnet/IP secure session
            SecureSessionTimeout = 60000,
            SecureSessionRequestTimeout = 10000,
            SecureSessionAuthenticateTimeout = 10000
        };
        Q_ENUM_NS(Timeout)

        namespace CemiServer
        {
            Q_KNX_EXPORT Q_NAMESPACE

            enum class ReturnCode : quint8
            {
                NoError = 0x00
            };
            Q_ENUM_NS(ReturnCode)

            enum class Error : quint8
            {
                Unspecified = 0x00,
                OutOfRange = 0x01,
                OutOfMaxRange = 0x02,
                OutOfMinRange = 0x03,
                Memory = 0x04,
                ReadOnly = 0x05,
                IllegalCommand = 0x06,
                NonExistingProperty = 0x07,
                TypeConflict = 0x08,
                PropertyIndexRangeError = 0x09,
                TemporaryNotWritable = 0x0a,
                None = 0xff  // Qt extension
            };
            Q_ENUM_NS(Error)
        }

        enum class SearchParameterType : quint8
        {
            Unknown = 0x00,
            Invalid = 0x00,
            SelectByProgrammingMode = 0x01,
            SelectByMACAddress = 0x02,
            SelectByService = 0x03,
            SelectByServiceSRP = 0x03, // ### Qt6: remove
            RequestDIBs = 0x04,
            Reserved01 = 0x05,
            Reserved02 = 0x06,
            Reserved03 = 0x07,
        };
        Q_ENUM_NS(SearchParameterType)
        Q_KNX_EXPORT bool isStructType(SearchParameterType type);

        enum class SecureSessionStatus : quint8
        {
            AuthenticationSuccess = 0x00,
            AuthenticationFailed = 0x01,
            Unauthenticated = 0x02,
            Timeout = 0x03,
            KeepAlive = 0x04,
            Close = 0x05,
            Unknown = 0xff
        };
        Q_ENUM_NS(SecureSessionStatus)

        enum SecureUserId : quint8
        {
            Reserved = 0x00,
            Management = 0x01,
            UserRole = 0x02,
            Invalid = 0x80
        };
        Q_ENUM_NS(SecureUserId)
        Q_KNX_EXPORT bool isSecureUserId(SecureUserId userId);
    }
}
namespace QKnxNetIp = QKnx::NetIp;
namespace QKnxNetIpCemiServer = QKnxNetIp::CemiServer;

Q_DECLARE_OPERATORS_FOR_FLAGS(QKnxNetIp::AssignmentMethods)
Q_DECLARE_OPERATORS_FOR_FLAGS(QKnxNetIp::Capabilities)

Q_DECLARE_TYPEINFO(QKnxNetIp::HostProtocol, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::ConnectionType, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::DescriptionType, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::ServiceFamily, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::ServiceType, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::Error, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::DeviceState, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::TunnelLayer, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::ProgrammingMode, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::AssignmentMethod, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::Capability, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::Timeout, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::SearchParameterType, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIp::SecureSessionStatus, Q_PRIMITIVE_TYPE);

Q_DECLARE_TYPEINFO(QKnxNetIpCemiServer::ReturnCode, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QKnxNetIpCemiServer::Error, Q_PRIMITIVE_TYPE);

QT_END_NAMESPACE

#endif