RDMnet  0.3.0
Implementation of ANSI E1.33 (RDMnet)
View other versions:
discovery.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 
28 #ifndef RDMNET_DISCOVERY_H_
29 #define RDMNET_DISCOVERY_H_
30 
31 #include <stddef.h>
32 #include <stdint.h>
33 #include <string.h>
34 #include "etcpal/error.h"
35 #include "etcpal/uuid.h"
36 #include "etcpal/socket.h"
37 #include "rdmnet/common.h"
38 #include "rdmnet/defs.h"
39 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
71 typedef struct RdmnetDnsTxtRecordItem
72 {
73  const char* key;
74  const uint8_t* value;
75  uint8_t value_len;
77 
79 typedef struct RdmnetBrokerRegisterRef* rdmnet_registered_broker_t;
81 #define RDMNET_REGISTERED_BROKER_INVALID NULL
82 
84 typedef struct RdmnetBrokerDiscInfo
85 {
89  RdmUid uid;
99  const char* service_instance_name;
101  uint16_t port;
107  const char* scope;
109  const char* model;
111  const char* manufacturer;
112 
118 
132  const char* assigned_service_instance_name,
133  void* context);
134 
142  int platform_error,
143  void* context);
144 
152  const RdmnetBrokerDiscInfo* broker_info,
153  void* context);
154 
163  const char* scope,
164  const char* service_instance_name,
165  void* context);
166 
173 {
178  void* context;
180 
183 {
184  /************************************************************************************************
185  * Required Values
186  ***********************************************************************************************/
187 
191  RdmUid uid;
202  uint16_t port;
207  const unsigned int* netints;
209  size_t num_netints;
211  const char* scope;
213  const char* model;
215  const char* manufacturer;
216 
221 
225 
235 #define RDMNET_BROKER_REGISTER_CONFIG_DEFAULT_INIT \
236  { \
237  {{0}}, {0}, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0, { NULL, NULL, NULL, NULL, NULL } \
238  }
239 
241 typedef struct RdmnetScopeMonitorRef* rdmnet_scope_monitor_t;
243 #define RDMNET_SCOPE_MONITOR_INVALID NULL
244 
257  const RdmnetBrokerDiscInfo* broker_info,
258  void* context);
259 
267  const RdmnetBrokerDiscInfo* updated_broker_info,
268  void* context);
269 
278  const char* scope,
279  const char* service_instance_name,
280  void* context);
281 
288 {
292  void* context;
294 
297 {
298  /************************************************************************************************
299  * Required Values
300  ***********************************************************************************************/
301 
303  const char* scope;
306 
307  /************************************************************************************************
308  * Optional Values
309  ***********************************************************************************************/
310 
312  const char* domain;
314 
324 #define RDMNET_SCOPE_MONITOR_CONFIG_DEFAULT_INIT \
325  { \
326  E133_DEFAULT_SCOPE, {NULL, NULL, NULL}, NULL \
327  }
328 
331  RdmnetDiscBrokerRegisteredCallback broker_registered,
332  RdmnetDiscBrokerRegisterFailedCallback broker_register_failed,
333  RdmnetDiscOtherBrokerFoundCallback other_broker_found,
334  RdmnetDiscOtherBrokerLostCallback other_broker_lost,
335  void* context);
336 
339  RdmnetDiscBrokerFoundCallback broker_found,
340  RdmnetDiscBrokerUpdatedCallback broker_udpated,
341  RdmnetDiscBrokerLostCallback broker_lost,
342  void* context);
343 
345  rdmnet_scope_monitor_t* handle,
346  int* platform_specific_error);
349 
353 
354 #ifdef __cplusplus
355 }
356 #endif
357 
362 #endif /* RDMNET_DISCOVERY_H_ */
Functions and definitions common to all RDMnet API modules.
etcpal_error_t
void(* RdmnetDiscBrokerRegisterFailedCallback)(rdmnet_registered_broker_t handle, int platform_error, void *context)
Broker registration has failed.
Definition: discovery.h:141
void(* RdmnetDiscOtherBrokerLostCallback)(rdmnet_registered_broker_t handle, const char *scope, const char *service_instance_name, void *context)
A broker which was previously detected on the same scope as a registered broker has been lost.
Definition: discovery.h:162
struct RdmnetBrokerDiscInfo RdmnetBrokerDiscInfo
Information about a broker discovered or registered using DNS-SD.
void rdmnet_scope_monitor_config_init(RdmnetScopeMonitorConfig *config)
Initialize an RdmnetScopeMonitorConfig with default values for the optional config options.
Definition: common.c:165
struct RdmnetDiscBrokerCallbacks RdmnetDiscBrokerCallbacks
A set of notification callbacks received by a registered broker instance.
etcpal_error_t rdmnet_disc_start_monitoring(const RdmnetScopeMonitorConfig *config, rdmnet_scope_monitor_t *handle, int *platform_specific_error)
Begin monitoring an RDMnet scope for brokers.
Definition: common.c:215
void rdmnet_broker_register_config_set_callbacks(RdmnetBrokerRegisterConfig *config, RdmnetDiscBrokerRegisteredCallback broker_registered, RdmnetDiscBrokerRegisterFailedCallback broker_register_failed, RdmnetDiscOtherBrokerFoundCallback other_broker_found, RdmnetDiscOtherBrokerLostCallback other_broker_lost, void *context)
Set the callbacks in an RDMnet broker register configuration structure.
Definition: common.c:133
void(* RdmnetDiscBrokerLostCallback)(rdmnet_scope_monitor_t handle, const char *scope, const char *service_instance_name, void *context)
A previously-discovered RDMnet broker has been lost on a monitored scope.
Definition: discovery.h:277
etcpal_error_t rdmnet_disc_register_broker(const RdmnetBrokerRegisterConfig *config, rdmnet_registered_broker_t *handle)
Register an RDMnet broker on a scope.
Definition: common.c:324
void rdmnet_disc_stop_monitoring(rdmnet_scope_monitor_t handle)
Stop monitoring an RDMnet scope for brokers.
Definition: common.c:268
void(* RdmnetDiscOtherBrokerFoundCallback)(rdmnet_registered_broker_t handle, const RdmnetBrokerDiscInfo *broker_info, void *context)
Another broker has been found on the scope on which this broker is registered.
Definition: discovery.h:151
void rdmnet_scope_monitor_config_set_callbacks(RdmnetScopeMonitorConfig *config, RdmnetDiscBrokerFoundCallback broker_found, RdmnetDiscBrokerUpdatedCallback broker_udpated, RdmnetDiscBrokerLostCallback broker_lost, void *context)
Set the callbacks in an RDMnet scope monitor configuration structure.
Definition: common.c:182
struct RdmnetScopeMonitorCallbacks RdmnetScopeMonitorCallbacks
A set of notification callbacks received by a scope monitor instance.
void(* RdmnetDiscBrokerUpdatedCallback)(rdmnet_scope_monitor_t handle, const RdmnetBrokerDiscInfo *updated_broker_info, void *context)
Updated information has been received for a previously-discovered RDMnet broker.
Definition: discovery.h:266
void(* RdmnetDiscBrokerFoundCallback)(rdmnet_scope_monitor_t handle, const RdmnetBrokerDiscInfo *broker_info, void *context)
An RDMnet broker has been found on a monitored scope.
Definition: discovery.h:256
struct RdmnetScopeMonitorRef * rdmnet_scope_monitor_t
A handle to a monitored RDMnet scope.
Definition: discovery.h:241
void(* RdmnetDiscBrokerRegisteredCallback)(rdmnet_registered_broker_t handle, const char *assigned_service_instance_name, void *context)
A broker has been registered successfully with the DNS-SD service.
Definition: discovery.h:131
struct RdmnetDnsTxtRecordItem RdmnetDnsTxtRecordItem
An extra key/value pair in a broker's DNS TXT record that does not have a standard RDMnet use.
void rdmnet_disc_unregister_broker(rdmnet_registered_broker_t handle)
Unegister an RDMnet broker on a scope.
Definition: common.c:379
struct RdmnetScopeMonitorConfig RdmnetScopeMonitorConfig
A set of information that defines the parameters of an RDMnet scope to be monitored using DNS-SD.
struct RdmnetBrokerRegisterRef * rdmnet_registered_broker_t
A handle to an RDMnet broker's DNS-SD registration.
Definition: discovery.h:79
void rdmnet_disc_stop_monitoring_all(void)
Stop monitoring all RDMnet scopes for brokers.
Definition: common.c:287
struct RdmnetBrokerRegisterConfig RdmnetBrokerRegisterConfig
A set of information that defines the parameters of an RDMnet broker registered with DNS-SD.
void rdmnet_broker_register_config_init(RdmnetBrokerRegisterConfig *config)
Initialize an RdmnetBrokerRegisterConfig with default values for the optional config options.
Definition: common.c:113
Information about a broker discovered or registered using DNS-SD.
Definition: discovery.h:85
uint16_t port
The port on which the broker is listening for RDMnet connections.
Definition: discovery.h:101
const char * model
The broker's product model name.
Definition: discovery.h:109
const char * scope
The broker's RDMnet scope.
Definition: discovery.h:107
const char * manufacturer
The name of the broker's manufacturer.
Definition: discovery.h:111
const RdmnetDnsTxtRecordItem * additional_txt_items
Any additional non-standard items that were present in the discovered broker's TXT record.
Definition: discovery.h:114
const char * service_instance_name
The broker's service instance name.
Definition: discovery.h:99
int e133_version
The E1.33 version that the broker supports.
Definition: discovery.h:91
RdmUid uid
The broker's UID.
Definition: discovery.h:89
EtcPalUuid cid
The broker's CID.
Definition: discovery.h:87
size_t num_listen_addrs
Size of the listen_addrs array.
Definition: discovery.h:105
size_t num_additional_txt_items
Size of the additional_txt_items array.
Definition: discovery.h:116
const EtcPalIpAddr * listen_addrs
An array of IP addresses at which the broker is listening for RDMnet connections.
Definition: discovery.h:103
A set of information that defines the parameters of an RDMnet broker registered with DNS-SD.
Definition: discovery.h:183
const char * model
The broker's product model name.
Definition: discovery.h:213
EtcPalUuid cid
The broker's CID.
Definition: discovery.h:189
uint16_t port
The port on which the broker is listening for RDMnet connections.
Definition: discovery.h:202
const char * scope
The broker's RDMnet scope.
Definition: discovery.h:211
RdmUid uid
The broker's UID.
Definition: discovery.h:191
const char * service_instance_name
The broker's requested service instance name.
Definition: discovery.h:200
const char * manufacturer
The name of the broker's manufacturer.
Definition: discovery.h:215
size_t num_additional_txt_items
Size of the additional_txt_items array.
Definition: discovery.h:220
const RdmnetDnsTxtRecordItem * additional_txt_items
Any additional non-standard items to add to the broker's TXT record.
Definition: discovery.h:218
size_t num_netints
Size of the netints array.
Definition: discovery.h:209
RdmnetDiscBrokerCallbacks callbacks
A set of callbacks to receive notifications about the registered broker.
Definition: discovery.h:223
const unsigned int * netints
An array of network interface indexes on which the broker should respond to mDNS queries.
Definition: discovery.h:207
A set of notification callbacks received by a registered broker instance.
Definition: discovery.h:173
RdmnetDiscOtherBrokerLostCallback other_broker_lost
Required.
Definition: discovery.h:177
RdmnetDiscBrokerRegisteredCallback broker_registered
Required.
Definition: discovery.h:174
RdmnetDiscOtherBrokerFoundCallback other_broker_found
Required.
Definition: discovery.h:176
void * context
(optional) Pointer to opaque data passed back with each callback.
Definition: discovery.h:178
RdmnetDiscBrokerRegisterFailedCallback broker_register_failed
Required.
Definition: discovery.h:175
An extra key/value pair in a broker's DNS TXT record that does not have a standard RDMnet use.
Definition: discovery.h:72
const char * key
The key for this item.
Definition: discovery.h:73
uint8_t value_len
The length of the value data.
Definition: discovery.h:75
const uint8_t * value
The value data for this item.
Definition: discovery.h:74
A set of notification callbacks received by a scope monitor instance.
Definition: discovery.h:288
RdmnetDiscBrokerUpdatedCallback broker_updated
Required.
Definition: discovery.h:290
RdmnetDiscBrokerFoundCallback broker_found
Required.
Definition: discovery.h:289
RdmnetDiscBrokerLostCallback broker_lost
Required.
Definition: discovery.h:291
void * context
(optional) Pointer to opaque data passed back with each callback.
Definition: discovery.h:292
A set of information that defines the parameters of an RDMnet scope to be monitored using DNS-SD.
Definition: discovery.h:297
const char * scope
Scope string of the scope to be monitored.
Definition: discovery.h:303
const char * domain
(optional) The search domain to use for DNS discovery.
Definition: discovery.h:312
RdmnetScopeMonitorCallbacks callbacks
A set of callbacks to receive notifications about the monitored scope.
Definition: discovery.h:305