RDMnet  0.3.0
Implementation of ANSI E1.33 (RDMnet)
View other versions:
client.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_CLIENT_H_
26 #define RDMNET_CLIENT_H_
27 
28 #include <stdbool.h>
29 #include <stdint.h>
30 #include "etcpal/inet.h"
31 #include "etcpal/uuid.h"
32 #include "rdm/uid.h"
33 #include "rdmnet/common.h"
34 
43 #define RDMNET_CLIENT_SCOPE_INVALID -1
44 
49 typedef enum
50 {
52  kRdmnetClientListAppend = VECTOR_BROKER_CLIENT_ADD,
54  kRdmnetClientListRemove = VECTOR_BROKER_CLIENT_REMOVE,
56  kRdmnetClientListUpdate = VECTOR_BROKER_CLIENT_ENTRY_CHANGE,
58  kRdmnetClientListReplace = VECTOR_BROKER_CONNECTED_CLIENT_LIST
60 
65 typedef struct RdmnetSourceAddr
66 {
68  uint16_t source_endpoint;
72  uint16_t subdevice;
74 
83 typedef struct RdmnetDestinationAddr
84 {
86  RdmUid rdmnet_uid;
91  uint16_t endpoint;
96  RdmUid rdm_uid;
98  uint16_t subdevice;
100 
106 #define RDMNET_ADDR_TO_DEFAULT_RESPONDER(manu_id, dev_id) \
107  { \
108  {(manu_id), (dev_id)}, E133_NULL_ENDPOINT, {(manu_id), (dev_id)}, 0 \
109  }
110 
117 #define RDMNET_ADDR_TO_DEFAULT_RESPONDER_SUBDEV(manu_id, dev_id, subdevice) \
118  { \
119  {(manu_id), (dev_id)}, E133_NULL_ENDPOINT, {(manu_id), (dev_id)}, (subdevice) \
120  }
121 
130 #define RDMNET_ADDR_TO_SUB_RESPONDER(rdmnet_manu, rdmnet_dev, endpoint, rdm_manu, rdm_dev) \
131  { \
132  {(rdmnet_manu), (rdmnet_dev)}, (endpoint), {(rdm_manu), (rdm_dev)}, 0 \
133  }
134 
144 #define RDMNET_ADDR_TO_SUB_RESPONDER_SUBDEV(rdmnet_manu, rdmnet_dev, endpoint, rdm_manu, rdm_dev, subdevice) \
145  { \
146  {(rdmnet_manu), (rdmnet_dev)}, (endpoint), {(rdm_manu), (rdm_dev)}, (subdevice) \
147  }
148 
151 {
155  const char* broker_name;
159  RdmUid broker_uid;
161 
164 {
190 
196 {
218 
223 typedef struct RdmnetScopeConfig
224 {
229  const char* scope;
237 
247 #define RDMNET_SCOPE_CONFIG_DEFAULT_INIT \
248  { \
249  E133_DEFAULT_SCOPE, { 0, ETCPAL_IP_INVALID_INIT } \
250  }
251 
262 #define RDMNET_CLIENT_SET_SCOPE(configptr, scope_str) \
263  do \
264  { \
265  (configptr)->scope = scope_str; \
266  ETCPAL_IP_SET_INVALID(&(configptr)->static_broker_addr.ip); \
267  } while (0)
268 
277 #define RDMNET_CLIENT_SET_DEFAULT_SCOPE(configptr) \
278  do \
279  { \
280  (configptr)->scope = E133_DEFAULT_SCOPE; \
281  ETCPAL_IP_SET_INVALID(&(configptr)->static_broker_addr.ip); \
282  } while (0)
283 
295 #define RDMNET_CLIENT_SET_STATIC_SCOPE(configptr, scope_str, broker_addr) \
296  do \
297  { \
298  (configptr)->scope = (scope_str); \
299  (configptr)->static_broker_addr = (broker_addr); \
300  } while (0)
301 
312 #define RDMNET_CLIENT_SET_STATIC_DEFAULT_SCOPE(configptr, broker_addr) \
313  do \
314  { \
315  (configptr)->scope = E133_DEFAULT_SCOPE; \
316  (configptr)->static_broker_addr = (broker_addr); \
317  } while (0)
318 
323 #endif /* RDMNET_CLIENT_H_ */
Functions and definitions common to all RDMnet API modules.
etcpal_error_t
struct RdmnetClientConnectFailedInfo RdmnetClientConnectFailedInfo
Information provided by the library about an unsuccessful RDMnet client connection.
struct RdmnetScopeConfig RdmnetScopeConfig
A set of configuration information for a single scope in which an RDMnet client is participating.
rdmnet_disconnect_reason_t
Disconnect reason defines for the BrokerDisconnectMsg.
Definition: common.h:85
client_list_action_t
How to apply the client entries to the existing client list in a client_list_update_received callback...
Definition: client.h:50
rdmnet_connect_fail_event_t
A high-level reason for RDMnet connection failure.
Definition: common.h:149
struct RdmnetClientConnectedInfo RdmnetClientConnectedInfo
Information provided by the library about a successful RDMnet client connection.
rdmnet_disconnect_event_t
A high-level reason for RDMnet connection to be disconnected after successful connection.
Definition: common.h:174
int rdmnet_client_scope_t
A handle to a scope that an RDMnet client participates in.
Definition: client.h:41
struct RdmnetDestinationAddr RdmnetDestinationAddr
A destination address for an RDM command in RDMnet's RPT protocol.
struct RdmnetClientDisconnectedInfo RdmnetClientDisconnectedInfo
Information provided by the library about an RDMnet client connection that disconnected after a succe...
struct RdmnetSourceAddr RdmnetSourceAddr
The source address for an unsolicited RDM response generated by a local component.
rdmnet_connect_status_t
Connect status defines for the BrokerConnectReplyMsg.
Definition: common.h:117
@ kRdmnetClientListAppend
The client entries should be appended to the existing client list.
Definition: client.h:52
@ kRdmnetClientListRemove
The client entries should be removed from the existing client list.
Definition: client.h:54
@ kRdmnetClientListUpdate
The client entries should be updated in the existing client list.
Definition: client.h:56
@ kRdmnetClientListReplace
The existing client list should be replaced wholesale with this one.
Definition: client.h:58
Information provided by the library about an unsuccessful RDMnet client connection.
Definition: client.h:164
rdmnet_connect_status_t rdmnet_reason
The reason given in the RDMnet-level connection refuse message.
Definition: client.h:176
bool will_retry
Whether the connection will be retried automatically.
Definition: client.h:188
rdmnet_connect_fail_event_t event
The high-level reason that this connection failed.
Definition: client.h:166
etcpal_error_t socket_err
The system error code associated with the failure.
Definition: client.h:171
Information provided by the library about a successful RDMnet client connection.
Definition: client.h:151
const char * broker_name
The DNS name of the broker, if it was discovered using DNS-SD; otherwise an empty string.
Definition: client.h:155
EtcPalSockAddr broker_addr
The IP address and port of the remote broker to which we have connected.
Definition: client.h:153
RdmUid broker_uid
The RDM UID of the connected broker.
Definition: client.h:159
EtcPalUuid broker_cid
The CID of the connected broker.
Definition: client.h:157
Information provided by the library about an RDMnet client connection that disconnected after a succe...
Definition: client.h:196
etcpal_error_t socket_err
The system error code associated with the disconnect.
Definition: client.h:203
rdmnet_disconnect_event_t event
The high-level reason for the disconnect.
Definition: client.h:198
rdmnet_disconnect_reason_t rdmnet_reason
The reason given in the RDMnet-level disconnect message.
Definition: client.h:208
bool will_retry
Whether the connection will be retried automatically.
Definition: client.h:216
A destination address for an RDM command in RDMnet's RPT protocol.
Definition: client.h:84
RdmUid rdm_uid
The UID of the RDM responder to which this message is addressed.
Definition: client.h:96
uint16_t subdevice
The sub-device to which this command is addressed, or 0 for the root device.
Definition: client.h:98
RdmUid rdmnet_uid
The UID of the RDMnet component to which this command is addressed.
Definition: client.h:86
uint16_t endpoint
The endpoint on the RDMnet component to which this message is addressed.
Definition: client.h:91
A set of configuration information for a single scope in which an RDMnet client is participating.
Definition: client.h:224
EtcPalSockAddr static_broker_addr
The broker address to which to connect, if a static broker has been configured.
Definition: client.h:235
const char * scope
The scope string.
Definition: client.h:229
The source address for an unsolicited RDM response generated by a local component.
Definition: client.h:66
uint16_t source_endpoint
The endpoint from which this response is being sent.
Definition: client.h:68
RdmUid rdm_source_uid
The UID of the RDM responder from which this response is being sent.
Definition: client.h:70
uint16_t subdevice
The sub-device from which this response is being sent, or 0 for the root device.
Definition: client.h:72