RDMnet  0.3.0
Implementation of ANSI E1.33 (RDMnet)
View other versions:
common.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************
16  * This file is a part of RDMnet. For more information, go to:
17  * https://github.com/ETCLabs/RDMnet
18  *****************************************************************************/
19 
25 #ifndef RDMNET_COMMON_H_
26 #define RDMNET_COMMON_H_
27 
28 #include "etcpal/error.h"
29 #include "etcpal/inet.h"
30 #include "etcpal/log.h"
31 #include "rdm/message.h"
32 #include "rdmnet/defs.h"
33 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
52 typedef enum
53 {
55  kRptStatusUnknownRptUid = VECTOR_RPT_STATUS_UNKNOWN_RPT_UID,
57  kRptStatusRdmTimeout = VECTOR_RPT_STATUS_RDM_TIMEOUT,
59  kRptStatusInvalidRdmResponse = VECTOR_RPT_STATUS_RDM_INVALID_RESPONSE,
61  kRptStatusUnknownRdmUid = VECTOR_RPT_STATUS_UNKNOWN_RDM_UID,
63  kRptStatusUnknownEndpoint = VECTOR_RPT_STATUS_UNKNOWN_ENDPOINT,
65  kRptStatusBroadcastComplete = VECTOR_RPT_STATUS_BROADCAST_COMPLETE,
67  kRptStatusUnknownVector = VECTOR_RPT_STATUS_UNKNOWN_VECTOR,
69  kRptStatusInvalidMessage = VECTOR_RPT_STATUS_INVALID_MESSAGE,
71  kRptStatusInvalidCommandClass = VECTOR_RPT_STATUS_INVALID_COMMAND_CLASS
73 
75 typedef enum
76 {
78  kEptStatusUnknownCid = VECTOR_EPT_STATUS_UNKNOWN_CID,
80  kEptStatusUnknownVector = VECTOR_EPT_STATUS_UNKNOWN_VECTOR
82 
84 typedef enum
85 {
87  kRdmnetDisconnectShutdown = E133_DISCONNECT_SHUTDOWN,
89  kRdmnetDisconnectCapacityExhausted = E133_DISCONNECT_CAPACITY_EXHAUSTED,
91  kRdmnetDisconnectHardwareFault = E133_DISCONNECT_HARDWARE_FAULT,
93  kRdmnetDisconnectSoftwareFault = E133_DISCONNECT_SOFTWARE_FAULT,
95  kRdmnetDisconnectSoftwareReset = E133_DISCONNECT_SOFTWARE_RESET,
97  kRdmnetDisconnectIncorrectScope = E133_DISCONNECT_INCORRECT_SCOPE,
102  kRdmnetDisconnectRptReconfigure = E133_DISCONNECT_RPT_RECONFIGURE,
107  kRdmnetDisconnectLlrpReconfigure = E133_DISCONNECT_LLRP_RECONFIGURE,
112  kRdmnetDisconnectUserReconfigure = E133_DISCONNECT_USER_RECONFIGURE
114 
116 typedef enum
117 {
119  kRdmnetConnectOk = E133_CONNECT_OK,
121  kRdmnetConnectScopeMismatch = E133_CONNECT_SCOPE_MISMATCH,
123  kRdmnetConnectCapacityExceeded = E133_CONNECT_CAPACITY_EXCEEDED,
125  kRdmnetConnectDuplicateUid = E133_CONNECT_DUPLICATE_UID,
127  kRdmnetConnectInvalidClientEntry = E133_CONNECT_INVALID_CLIENT_ENTRY,
129  kRdmnetConnectInvalidUid = E133_CONNECT_INVALID_UID
131 
133 typedef enum
134 {
136  kRdmnetDynamicUidStatusOk = E133_DYNAMIC_UID_STATUS_OK,
138  kRdmnetDynamicUidStatusInvalidRequest = E133_DYNAMIC_UID_STATUS_INVALID_REQUEST,
140  kRdmnetDynamicUidStatusUidNotFound = E133_DYNAMIC_UID_STATUS_UID_NOT_FOUND,
142  kRdmnetDynamicUidStatusDuplicateRid = E133_DYNAMIC_UID_STATUS_DUPLICATE_RID,
144  kRdmnetDynamicUidStatusCapacityExhausted = E133_DYNAMIC_UID_STATUS_CAPACITY_EXHAUSTED
146 
148 typedef enum
149 {
171 
173 typedef enum
174 {
189 
193 typedef enum
194 {
202 
213 typedef struct RdmnetSyncRdmResponse
214 {
217 
219  union
220  {
227  rdm_nack_reason_t nack_reason;
230 
240 #define RDMNET_SYNC_SEND_RDM_ACK(response_ptr, response_data_len_in) \
241  do \
242  { \
243  (response_ptr)->response_action = kRdmnetRdmResponseActionSendAck; \
244  (response_ptr)->response_data.response_data_len = (response_data_len_in); \
245  } while (0)
246 
252 #define RDMNET_SYNC_SEND_RDM_NACK(response_ptr, nack_reason_in) \
253  do \
254  { \
255  (response_ptr)->response_action = kRdmnetRdmResponseActionSendNack; \
256  (response_ptr)->response_data.nack_reason = (nack_reason_in); \
257  } while (0)
258 
264 #define RDMNET_SYNC_DEFER_RDM_RESPONSE(response_ptr) ((response_ptr)->response_action = kRdmnetRdmResponseActionDefer)
265 
269 typedef enum
270 {
281 
292 typedef struct RdmnetSyncEptResponse
293 {
296 
298  union
299  {
309 
318 #define RDMNET_SYNC_SEND_EPT_DATA(response_ptr, response_data_len_in) \
319  do \
320  { \
321  (response_ptr)->response_action = kRdmnetEptResponseActionSendData; \
322  (response_ptr)->response_data.response_data_len = (response_data_len_in); \
323  } while (0)
324 
330 #define RDMNET_SYNC_SEND_EPT_STATUS(response_ptr, status_code_in) \
331  do \
332  { \
333  (response_ptr)->response_action = kRdmnetEptResponseActionSendStatus; \
334  (response_ptr)->response_data.status_code = (status_code_in); \
335  } while (0)
336 
341 #define RDMNET_SYNC_DEFER_EPT_RESPONSE(response_ptr) ((response_ptr)->response_action = kRdmnetEptResponseActionDefer)
342 
349 typedef enum
350 {
354  kRdmnetCCSetCommand = 0x30
356 
363 typedef struct RdmnetMcastNetintId
364 {
368  unsigned int index;
370 
375 typedef struct RdmnetNetintConfig
376 {
380  size_t num_netints;
382 
383 etcpal_error_t rdmnet_init(const EtcPalLogParams* log_params, const RdmnetNetintConfig* netint_config);
384 void rdmnet_deinit(void);
385 
393 
394 #ifdef __cplusplus
395 }
396 #endif
397 
402 #endif /* RDMNET_COMMON_H_ */
etcpal_error_t
etcpal_iptype_t
rdmnet_ept_response_action_t
Enumeration representing an action to take after an "EPT data received" callback completes.
Definition: common.h:270
const char * rdmnet_rpt_status_code_to_string(rpt_status_code_t code)
Get a string representation of an RPT status code.
Definition: common.c:231
const char * rdmnet_ept_status_code_to_string(ept_status_code_t code)
Get a string representation of an EPT status code.
Definition: common.c:250
ept_status_code_t
EPT status code definitions.
Definition: common.h:76
const char * rdmnet_dynamic_uid_status_to_string(rdmnet_dynamic_uid_status_t code)
Get a string description of an RDMnet Dynamic UID status code.
Definition: common.c:392
struct RdmnetNetintConfig RdmnetNetintConfig
Network interface configuration information to give the RDMnet library at initialization.
rdmnet_disconnect_reason_t
Disconnect reason defines for the BrokerDisconnectMsg.
Definition: common.h:85
rdmnet_command_class_t
An RDM command class, for RDMnet purposes.
Definition: common.h:350
rdmnet_connect_fail_event_t
A high-level reason for RDMnet connection failure.
Definition: common.h:149
struct RdmnetSyncEptResponse RdmnetSyncEptResponse
This structure should not be manipulated directly - use the macros to access it:
rdmnet_disconnect_event_t
A high-level reason for RDMnet connection to be disconnected after successful connection.
Definition: common.h:174
const char * rdmnet_connect_fail_event_to_string(rdmnet_connect_fail_event_t event)
Get a string description of an RDMnet connection failure event.
Definition: common.c:276
const char * rdmnet_disconnect_event_to_string(rdmnet_disconnect_event_t event)
Get a string description of an RDMnet disconnect event.
Definition: common.c:304
struct RdmnetSyncRdmResponse RdmnetSyncRdmResponse
This structure should not be manipulated directly - use the macros to access it:
rpt_status_code_t
RPT status code definitions.
Definition: common.h:53
void rdmnet_deinit(void)
Deinitialize the RDMnet library.
Definition: common.c:201
struct RdmnetMcastNetintId RdmnetMcastNetintId
A set of identifying information for a network interface, for multicast purposes.
rdmnet_rdm_response_action_t
Enumeration representing an action to take after an "RDM command received" callback completes.
Definition: common.h:194
const char * rdmnet_disconnect_reason_to_string(rdmnet_disconnect_reason_t code)
Get a string description of an RDMnet disconnect reason code.
Definition: common.c:364
etcpal_error_t rdmnet_init(const EtcPalLogParams *log_params, const RdmnetNetintConfig *netint_config)
Initialize the RDMnet library.
Definition: common.c:149
rdmnet_connect_status_t
Connect status defines for the BrokerConnectReplyMsg.
Definition: common.h:117
const char * rdmnet_connect_status_to_string(rdmnet_connect_status_t code)
Get a string description of an RDMnet connect status code.
Definition: common.c:333
rdmnet_dynamic_uid_status_t
Dynamic UID Status Codes for the BrokerDynamicUidMapping struct.
Definition: common.h:134
@ kRdmnetEptResponseActionSendStatus
Send an EPT status message to the originating EPT client.
Definition: common.h:274
@ kRdmnetEptResponseActionSendData
Send an EPT data message to the originating EPT client.
Definition: common.h:272
@ kRdmnetEptResponseActionDefer
Do nothing; either the application will send the response later or no response is required.
Definition: common.h:279
@ kEptStatusUnknownCid
The destination CID in the EPT PDU could not be found.
Definition: common.h:78
@ kEptStatusUnknownVector
An EPT PDU was received with an unsupported Vector.
Definition: common.h:80
@ kRdmnetDisconnectSoftwareFault
The component must disconnect due to a software fault.
Definition: common.h:93
@ kRdmnetDisconnectUserReconfigure
The component was reconfigured via some other means, and the new configuration requires connection te...
Definition: common.h:112
@ kRdmnetDisconnectHardwareFault
The component must disconnect due to an internal hardware fault.
Definition: common.h:91
@ kRdmnetDisconnectShutdown
The remote component is shutting down.
Definition: common.h:87
@ kRdmnetDisconnectRptReconfigure
The component was reconfigured using RPT, and the new configuration requires connection termination.
Definition: common.h:102
@ kRdmnetDisconnectIncorrectScope
Sent by brokers that are not on the desired Scope.
Definition: common.h:97
@ kRdmnetDisconnectLlrpReconfigure
The component was reconfigured using LLRP, and the new configuration requires connection termination.
Definition: common.h:107
@ kRdmnetDisconnectSoftwareReset
The component must terminated because of a software reset.
Definition: common.h:95
@ kRdmnetDisconnectCapacityExhausted
The remote component no longer has the ability to support this connection.
Definition: common.h:89
@ kRdmnetCCSetCommand
An RDMnet RDM SET command.
Definition: common.h:354
@ kRdmnetCCGetCommand
An RDMnet RDM GET command.
Definition: common.h:352
@ kRdmnetConnectFailRejected
The remote broker rejected the connection at the RDMnet protocol level.
Definition: common.h:169
@ kRdmnetConnectFailNoReply
The TCP connection was established, but no reply was received from the RDMnet protocol handshake.
Definition: common.h:164
@ kRdmnetConnectFailSocketFailure
The connection was unable to be started because of an error returned from the system during a lower-l...
Definition: common.h:154
@ kRdmnetConnectFailTcpLevel
The connection started but the TCP connection was never established.
Definition: common.h:159
@ kRdmnetDisconnectNoHeartbeat
The TCP connection was deemed unhealthy due to no heartbeat message being received before the heartbe...
Definition: common.h:181
@ kRdmnetDisconnectRedirected
The client was redirected to another broker address.
Definition: common.h:183
@ kRdmnetDisconnectAbruptClose
The TCP connection was closed without an RDMnet disconnect message being sent.
Definition: common.h:176
@ kRdmnetDisconnectGracefulRemoteInitiated
The remote component sent an RDMnet disconnect message with a reason code.
Definition: common.h:185
@ kRdmnetDisconnectGracefulLocalInitiated
A disconnect was requested locally.
Definition: common.h:187
@ kRptStatusRdmTimeout
No RDM response was received from a Gateway's RDM responder.
Definition: common.h:57
@ kRptStatusUnknownEndpoint
The Destination Endpoint ID in the RPT PDU could not be found.
Definition: common.h:63
@ kRptStatusUnknownVector
An RPT PDU was received with an unsupported Vector.
Definition: common.h:67
@ kRptStatusInvalidMessage
The inner PDU contained by the RPT PDU was malformed.
Definition: common.h:69
@ kRptStatusInvalidRdmResponse
An invalid RDM response was received from a Gateway's RDM responder.
Definition: common.h:59
@ kRptStatusInvalidCommandClass
The Command Class of an encapsulated RDM Command was invalid.
Definition: common.h:71
@ kRptStatusBroadcastComplete
A Broadcasted RPT Request was sent to at least one Device.
Definition: common.h:65
@ kRptStatusUnknownRdmUid
The Destination UID in an encapsulated RDM Command could not be found.
Definition: common.h:61
@ kRptStatusUnknownRptUid
The Destination UID in the RPT PDU could not be found.
Definition: common.h:55
@ kRdmnetRdmResponseActionSendNack
Send an RDM NACK with reason to the originating controller.
Definition: common.h:198
@ kRdmnetRdmResponseActionDefer
Do nothing; the application will send the response later.
Definition: common.h:200
@ kRdmnetRdmResponseActionSendAck
Send an RDM ACK to the originating controller.
Definition: common.h:196
@ kRdmnetConnectInvalidClientEntry
The client's Client Entry is invalid.
Definition: common.h:127
@ kRdmnetConnectDuplicateUid
The client's static UID matches another connected client's static UID.
Definition: common.h:125
@ kRdmnetConnectOk
Connection completed successfully.
Definition: common.h:119
@ kRdmnetConnectInvalidUid
The UID sent in the Client Entry PDU is malformed.
Definition: common.h:129
@ kRdmnetConnectScopeMismatch
The client's scope does not match the broker's scope.
Definition: common.h:121
@ kRdmnetConnectCapacityExceeded
The broker has no further capacity for new clients.
Definition: common.h:123
@ kRdmnetDynamicUidStatusOk
The Dynamic UID Mapping was fetched or assigned successfully.
Definition: common.h:136
@ kRdmnetDynamicUidStatusUidNotFound
The requested Dynamic UID was not found in the broker's Dynamic UID mapping table.
Definition: common.h:140
@ kRdmnetDynamicUidStatusCapacityExhausted
The broker has exhausted its capacity to generate Dynamic UIDs.
Definition: common.h:144
@ kRdmnetDynamicUidStatusDuplicateRid
This RID has already been assigned a Dynamic UID by this broker.
Definition: common.h:142
@ kRdmnetDynamicUidStatusInvalidRequest
The corresponding request contained a malformed UID value.
Definition: common.h:138
A set of identifying information for a network interface, for multicast purposes.
Definition: common.h:364
etcpal_iptype_t ip_type
The IP protocol used on the network interface.
Definition: common.h:366
unsigned int index
The index of the network interface.
Definition: common.h:368
Network interface configuration information to give the RDMnet library at initialization.
Definition: common.h:376
size_t num_netints
Size of netints array.
Definition: common.h:380
const RdmnetMcastNetintId * netints
An array of network interface IDs to which to restrict RDMnet traffic.
Definition: common.h:378
This structure should not be manipulated directly - use the macros to access it:
Definition: common.h:293
union RdmnetSyncEptResponse::@1 response_data
Data associated with certain response actions (use the macros to access).
rdmnet_ept_response_action_t response_action
Represents the response action to take.
Definition: common.h:295
ept_status_code_t status_code
The EPT status code.
Definition: common.h:306
size_t response_data_len
The length of the response data which has been copied into the buffer given at initialization time.
Definition: common.h:304
This structure should not be manipulated directly - use the macros to access it:
Definition: common.h:214
union RdmnetSyncRdmResponse::@0 response_data
Data associated with certain response actions (use the macros to access).
size_t response_data_len
The length of the response data which has been copied into the buffer given at initialization time.
Definition: common.h:225
rdm_nack_reason_t nack_reason
The NACK reason code.
Definition: common.h:227
rdmnet_rdm_response_action_t response_action
Represents the response action to take.
Definition: common.h:216