23 #ifndef RDMNET_CPP_BROKER_H_
24 #define RDMNET_CPP_BROKER_H_
33 #include "etcpal/common.h"
38 #include "rdm/cpp/uid.h"
40 #include "rdmnet/defs.h"
59 DnsTxtRecordItem(
const char* new_key,
const uint8_t* new_value,
size_t new_value_len);
66 inline DnsTxtRecordItem::DnsTxtRecordItem(
const char* new_key,
const char* new_value)
67 : key(new_key), value(new_value, &new_value[
std::strlen(new_value)])
72 inline DnsTxtRecordItem::DnsTxtRecordItem(
const char* new_key,
const uint8_t* new_value,
size_t new_value_len)
73 : key(new_key), value(new_value, new_value + new_value_len)
79 : key(new_key), value(new_value.begin(), new_value.end())
84 inline DnsTxtRecordItem::DnsTxtRecordItem(
const std::string& new_key,
const uint8_t* new_value,
size_t new_value_len)
85 : key(new_key), value(new_value, new_value + new_value_len)
91 : key(new_key), value(new_value)
234 inline Broker::Settings::Settings(
const etcpal::Uuid& cid_in,
const rdm::Uid& static_uid_in)
235 : cid(cid_in), uid(static_uid_in)
241 inline Broker::Settings::Settings(
const etcpal::Uuid& cid_in, uint16_t rdm_manu_id_in)
242 : cid(cid_in), uid(rdm::Uid::DynamicUidRequest(rdm_manu_id_in))
253 (!scope.empty() && scope.length() < (E133_SCOPE_STRING_PADDED_LENGTH - 1)) &&
254 (!dns.manufacturer.empty() && dns.manufacturer.length() < (E133_MANUFACTURER_STRING_PADDED_LENGTH - 1)) &&
255 (!dns.model.empty() && dns.model.length() < (E133_MODEL_STRING_PADDED_LENGTH - 1)) &&
256 (!dns.service_instance_name.empty() && dns.service_instance_name.length() < (E133_SERVICE_NAME_STRING_PADDED_LENGTH - 1)) &&
257 (listen_port == 0 || listen_port >= 1024) &&
258 (uid.manufacturer_id() != 0) &&
259 (uid.IsStatic() || uid.IsDynamicUidRequest())
std::string ToString() const
A callback interface for notifications from the broker.
Definition: broker.h:193
virtual void HandleScopeChanged(const std::string &new_scope)
The scope of the broker has changed via RDMnet configuration.
Definition: broker.h:202
Defines an instance of RDMnet broker functionality.
Definition: broker.h:114
virtual ~Broker()
Destroys a broker instance. Call Broker::Shutdown() first.
Definition: broker_api.cpp:33
Broker & operator=(Broker &&other)=default
Move an instance of broker functionality.
void Shutdown(rdmnet_disconnect_reason_t disconnect_reason=kRdmnetDisconnectShutdown)
Shut down all broker functionality and threads.
Definition: broker_api.cpp:63
Broker & operator=(const Broker &other)=delete
Brokers cannot be copied.
Broker(Broker &&other)=default
Move an instance of broker functionality.
const Settings & settings() const
Get the current settings the broker is using.
Definition: broker_api.cpp:91
Broker()
Constructs a broker instance. Broker is not running until Broker::Startup() is called.
Definition: broker_api.cpp:28
etcpal::Error Startup(const Settings &settings, etcpal::Logger *logger=nullptr, NotifyHandler *notify=nullptr)
Start all broker functionality and threads.
Definition: broker_api.cpp:52
Broker(const Broker &other)=delete
Brokers cannot be copied.
etcpal::Error ChangeScope(const std::string &new_scope, rdmnet_disconnect_reason_t disconnect_reason)
Change the scope on which a broker operates.
Definition: broker_api.cpp:82
Functions and definitions common to all RDMnet API modules.
rdmnet_disconnect_reason_t
Disconnect reason defines for the BrokerDisconnectMsg.
Definition: common.h:85
@ kRdmnetDisconnectShutdown
The remote component is shutting down.
Definition: common.h:87
A namespace which contains all C++ language definitions in the RDMnet library.
Definition: broker.h:45
Settings for the Broker's DNS Discovery functionality.
Definition: broker.h:119
std::string service_instance_name
Your unique name for this broker DNS-SD service instance.
Definition: broker.h:125
std::string manufacturer
A string to identify the manufacturer of this broker instance.
Definition: broker.h:128
std::string model
A string to identify the model of product in which the broker instance is included.
Definition: broker.h:130
std::vector< DnsTxtRecordItem > additional_txt_record_items
Any additional non-standard items to add to the broker's DNS TXT record.
Definition: broker.h:133
A set of limits for broker operation.
Definition: broker.h:138
unsigned int connections
The maximum number of client connections supported. 0 means infinite.
Definition: broker.h:140
unsigned int controller_messages
The maximum number of queued messages per controller. 0 means infinite.
Definition: broker.h:144
unsigned int reject_connections
If you reach the number of max connections, this number of tcp-level connections are still supported ...
Definition: broker.h:151
unsigned int devices
The maximum number of devices allowed. 0 means infinite.
Definition: broker.h:146
unsigned int controllers
The maximum number of controllers allowed. 0 means infinite.
Definition: broker.h:142
unsigned int device_messages
The maximum number of queued messages per device. 0 means infinite.
Definition: broker.h:148
A group of settings for broker operation.
Definition: broker.h:157
Limits limits
The broker's limits.
Definition: broker.h:161
uint16_t listen_port
The port on which this broker should listen for incoming connections (and advertise via DNS).
Definition: broker.h:172
std::vector< std::string > listen_interfaces
A list of strings representing the system name of network interfaces to listen on.
Definition: broker.h:179
void SetDefaultServiceInstanceName()
Generate a DNS service instance name based on the broker's current CID.
Definition: broker.h:228
etcpal::Uuid cid
The broker's CID.
Definition: broker.h:158
bool allow_rdm_scope_change
Whether the broker should allow the scope to be changed via RDM commands.
Definition: broker.h:166
std::string scope
The RDMnet scope on which this broker should operate.
Definition: broker.h:164
bool IsValid() const
Whether this structure contains valid settings for broker operation.
Definition: broker.h:248
rdm::Uid uid
The broker's UID.
Definition: broker.h:159
bool allow_rdm_disable
Whether the broker should allow being disabled and enabled via the BROKER_STATUS RDM command.
Definition: broker.h:168
DnsAttributes dns
The broker's DNS attributes.
Definition: broker.h:160
A key/value pair representing a DNS TXT record item.
Definition: broker.h:53
std::vector< uint8_t > value
The value is opaque binary data.
Definition: broker.h:55
std::string key
The key is an ASCII-only string.
Definition: broker.h:54