Let dds_create_participant determine domain id if config specifies "any" (new default)
Note: DDS_DOMAIN_DEFAULT with a configuration specifying "any" results in domain 0. Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
675fbfe013
commit
bb92294f4e
10 changed files with 78 additions and 44 deletions
|
@ -235,11 +235,10 @@ struct config
|
|||
enum boolean_default compat_tcp_enable;
|
||||
int dontRoute;
|
||||
int enableMulticastLoopback;
|
||||
int domainId;
|
||||
struct config_maybe_int32 domainId;
|
||||
int participantIndex;
|
||||
int maxAutoParticipantIndex;
|
||||
int port_base;
|
||||
struct config_maybe_int32 discoveryDomainId;
|
||||
char *spdpMulticastAddressString;
|
||||
char *defaultMulticastAddressString;
|
||||
char *assumeMulticastCapable;
|
||||
|
|
|
@ -101,7 +101,7 @@ static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int p
|
|||
int i;
|
||||
for (i = 0; i <= config.maxAutoParticipantIndex; i++)
|
||||
{
|
||||
int port = config.port_base + config.port_dg * config.domainId + i * config.port_pg + config.port_d1;
|
||||
int port = config.port_base + config.port_dg * config.domainId.value + i * config.port_pg + config.port_d1;
|
||||
loc.port = (unsigned) port;
|
||||
if (i == 0)
|
||||
nn_log (LC_CONFIG, "%s", ddsi_locator_to_string(buf, sizeof(buf), &loc));
|
||||
|
@ -114,7 +114,7 @@ static int add_addresses_to_addrset_1 (struct addrset *as, const char *ip, int p
|
|||
{
|
||||
int port = port_mode;
|
||||
if (port == -1)
|
||||
port = config.port_base + config.port_dg * config.domainId + config.port_d0;
|
||||
port = config.port_base + config.port_dg * config.domainId.value + config.port_d0;
|
||||
loc.port = (unsigned) port;
|
||||
nn_log (LC_CONFIG, "%s", ddsi_locator_to_string(buf, sizeof(buf), &loc));
|
||||
add_to_addrset (as, &loc);
|
||||
|
|
|
@ -161,7 +161,7 @@ DUPF(cipher);
|
|||
#ifdef DDSI_INCLUDE_BANDWIDTH_LIMITING
|
||||
DUPF(bandwidth);
|
||||
#endif
|
||||
DU(domainId);
|
||||
DUPF(domainId);
|
||||
DUPF(durability_cdr);
|
||||
DUPF(transport_selector);
|
||||
DUPF(many_sockets_mode);
|
||||
|
@ -727,8 +727,6 @@ static const struct cfgelem discovery_peers_cfgelems[] = {
|
|||
};
|
||||
|
||||
static const struct cfgelem discovery_cfgelems[] = {
|
||||
{ LEAF("DomainId"), 1, "default", ABSOFF(discoveryDomainId), 0, uf_maybe_int32, 0, pf_maybe_int32,
|
||||
"<p>This element allows overriding of the DDS Domain Id that is used for DDSI2E.</p>" },
|
||||
{ LEAF("AdvertiseBuiltinTopicWriters"), 1, "true", ABSOFF(advertise_builtin_topic_writers), 0, uf_boolean, 0, pf_boolean,
|
||||
"<p>This element controls whether or not DDSI2E advertises writers for the built-in topics from its discovery for backwards compatibility with older OpenSplice versions.</p>" },
|
||||
{ LEAF("DSGracePeriod"), 1, "30 s", ABSOFF(ds_grace_period), 0, uf_duration_inf, 0, pf_duration,
|
||||
|
@ -873,7 +871,7 @@ static const struct cfgelem lease_cfgelems[] = {
|
|||
|
||||
static const struct cfgelem domain_cfgelems[] = {
|
||||
{ GROUP("Lease", lease_cfgelems), NULL },
|
||||
{ LEAF("Id"), 1, "0", ABSOFF(domainId), 0, uf_domainId, 0, pf_int, NULL },
|
||||
{ LEAF("Id"), 1, "any", ABSOFF(domainId), 0, uf_domainId, 0, pf_domainId, NULL },
|
||||
WILDCARD,
|
||||
END_MARKER
|
||||
};
|
||||
|
@ -1904,9 +1902,20 @@ static int uf_int_min_max(struct cfgst *cfgst, void *parent, struct cfgelem cons
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int uf_domainId(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int first, const char *value)
|
||||
static int uf_domainId(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, UNUSED_ARG(int first), const char *value)
|
||||
{
|
||||
return uf_int_min_max(cfgst, parent, cfgelem, first, value, 0, 230);
|
||||
struct config_maybe_int32 *elem = cfg_address(cfgst, parent, cfgelem);
|
||||
int pos;
|
||||
if (os_strcasecmp(value, "any") == 0) {
|
||||
elem->isdefault = 1;
|
||||
elem->value = 0;
|
||||
return 1;
|
||||
} else if (sscanf(value, "%d%n", &elem->value, &pos) == 1 && value[pos] == 0 && elem->value >= 0 && elem->value <= 230) {
|
||||
elem->isdefault = 0;
|
||||
return 1;
|
||||
} else {
|
||||
return cfg_error(cfgst, "'%s': neither 'any' nor a decimal integer in 0 .. 230\n", value);
|
||||
}
|
||||
}
|
||||
|
||||
static int uf_participantIndex(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int first, const char *value)
|
||||
|
@ -2213,11 +2222,11 @@ static void pf_uint32(struct cfgst *cfgst, void *parent, struct cfgelem const *
|
|||
|
||||
static void pf_maybe_int32(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int is_default)
|
||||
{
|
||||
struct config_maybe_int32 *p = cfg_address(cfgst, parent, cfgelem);
|
||||
if ( p->isdefault )
|
||||
cfg_log(cfgst, "default%s", is_default ? " [def]" : "");
|
||||
else
|
||||
cfg_log(cfgst, "%d%s", p->value, is_default ? " [def]" : "");
|
||||
struct config_maybe_int32 *p = cfg_address(cfgst, parent, cfgelem);
|
||||
if ( p->isdefault )
|
||||
cfg_log(cfgst, "default%s", is_default ? " [def]" : "");
|
||||
else
|
||||
cfg_log(cfgst, "%d%s", p->value, is_default ? " [def]" : "");
|
||||
}
|
||||
|
||||
static void pf_maybe_memsize(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int is_default)
|
||||
|
@ -2229,6 +2238,14 @@ static void pf_maybe_memsize(struct cfgst *cfgst, void *parent, struct cfgelem c
|
|||
pf_int64_unit(cfgst, p->value, is_default, unittab_memsize, "B");
|
||||
}
|
||||
|
||||
static void pf_domainId(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int is_default)
|
||||
{
|
||||
struct config_maybe_int32 *p = cfg_address(cfgst, parent, cfgelem);
|
||||
if ( p->isdefault )
|
||||
cfg_log(cfgst, "any (%d)%s", p->value, is_default ? " [def]" : "");
|
||||
else
|
||||
cfg_log(cfgst, "%d%s", p->value, is_default ? " [def]" : "");
|
||||
}
|
||||
|
||||
static void pf_float(struct cfgst *cfgst, void *parent, struct cfgelem const * const cfgelem, int is_default)
|
||||
{
|
||||
|
@ -2707,6 +2724,12 @@ struct cfgst * config_init
|
|||
config.tracingOutputFile = stderr;
|
||||
config.enabled_logcats = LC_ERROR | LC_WARNING;
|
||||
|
||||
/* eventually, we domainId.value will be the real domain id selected, even if it was configured
|
||||
to the default of "any" and has "isdefault" set; initializing it to the default-default
|
||||
value of 0 means "any" in the config & DDS_DOMAIN_DEFAULT in create participant automatically
|
||||
ends up on the right value */
|
||||
config.domainId.value = 0;
|
||||
|
||||
cfgst = os_malloc(sizeof(*cfgst));
|
||||
memset(cfgst, 0, sizeof(*cfgst));
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static int make_uc_sockets (uint32_t * pdisc, uint32_t * pdata, int ppid)
|
|||
if (config.many_sockets_mode == MSM_NO_UNICAST)
|
||||
{
|
||||
assert (ppid == PARTICIPANT_INDEX_NONE);
|
||||
*pdata = *pdisc = (uint32_t) (config.port_base + config.port_dg * config.domainId);
|
||||
*pdata = *pdisc = (uint32_t) (config.port_base + config.port_dg * config.domainId.value);
|
||||
if (config.allowMulticast)
|
||||
{
|
||||
/* FIXME: ugly hack - but we'll fix up after creating the multicast sockets */
|
||||
|
@ -85,7 +85,7 @@ static int make_uc_sockets (uint32_t * pdisc, uint32_t * pdata, int ppid)
|
|||
if (ppid >= 0)
|
||||
{
|
||||
/* FIXME: verify port numbers are in range instead of truncating them like this */
|
||||
int base = config.port_base + (config.port_dg * config.domainId) + (ppid * config.port_pg);
|
||||
int base = config.port_base + (config.port_dg * config.domainId.value) + (ppid * config.port_pg);
|
||||
*pdisc = (uint32_t) (base + config.port_d1);
|
||||
*pdata = (uint32_t) (base + config.port_d3);
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ static int string_to_default_locator (nn_locator_t *loc, const char *string, uin
|
|||
|
||||
static int set_spdp_address (void)
|
||||
{
|
||||
const uint32_t port = (uint32_t) (config.port_base + config.port_dg * config.domainId + config.port_d0);
|
||||
const uint32_t port = (uint32_t) (config.port_base + config.port_dg * config.domainId.value + config.port_d0);
|
||||
int rc = 0;
|
||||
/* FIXME: FIXME: FIXME: */
|
||||
gv.loc_spdp_mc.kind = NN_LOCATOR_KIND_INVALID;
|
||||
|
@ -321,7 +321,7 @@ static int set_spdp_address (void)
|
|||
|
||||
static int set_default_mc_address (void)
|
||||
{
|
||||
const uint32_t port = (uint32_t) (config.port_base + config.port_dg * config.domainId + config.port_d2);
|
||||
const uint32_t port = (uint32_t) (config.port_base + config.port_dg * config.domainId.value + config.port_d2);
|
||||
int rc;
|
||||
if (!config.defaultMulticastAddressString)
|
||||
gv.loc_default_mc = gv.loc_spdp_mc;
|
||||
|
@ -464,15 +464,7 @@ int rtps_config_prep (struct cfgst *cfgst)
|
|||
unsigned num_channel_threads = 0;
|
||||
#endif
|
||||
|
||||
/* if the discovery domain id was explicitly set, override the default here */
|
||||
if (!config.discoveryDomainId.isdefault)
|
||||
{
|
||||
config.domainId = config.discoveryDomainId.value;
|
||||
}
|
||||
|
||||
/* retry_on_reject_duration default is dependent on late_ack_mode and responsiveness timeout, so fix up */
|
||||
|
||||
|
||||
if (config.whc_init_highwater_mark.isdefault)
|
||||
config.whc_init_highwater_mark.value = config.whc_lowwater_mark;
|
||||
if (config.whc_highwater_mark < config.whc_lowwater_mark ||
|
||||
|
@ -662,7 +654,7 @@ int joinleave_spdp_defmcip (int dojoin)
|
|||
unref_addrset (as);
|
||||
if (arg.errcount)
|
||||
{
|
||||
NN_ERROR ("rtps_init: failed to join multicast groups for domain %d participant %d\n", config.domainId, config.participantIndex);
|
||||
NN_ERROR ("rtps_init: failed to join multicast groups for domain %d participant %d\n", config.domainId.value, config.participantIndex);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -676,7 +668,7 @@ int create_multicast_sockets(void)
|
|||
qos->m_multicast = 1;
|
||||
|
||||
/* FIXME: should check for overflow */
|
||||
port = (uint32_t) (config.port_base + config.port_dg * config.domainId + config.port_d0);
|
||||
port = (uint32_t) (config.port_base + config.port_dg * config.domainId.value + config.port_d0);
|
||||
if ((disc = ddsi_factory_create_conn (gv.m_factory, port, qos)) == NULL)
|
||||
goto err_disc;
|
||||
if (config.many_sockets_mode == MSM_NO_UNICAST)
|
||||
|
@ -686,7 +678,7 @@ int create_multicast_sockets(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
port = (uint32_t) (config.port_base + config.port_dg * config.domainId + config.port_d2);
|
||||
port = (uint32_t) (config.port_base + config.port_dg * config.domainId.value + config.port_d2);
|
||||
if ((data = ddsi_factory_create_conn (gv.m_factory, port, qos)) == NULL)
|
||||
goto err_data;
|
||||
}
|
||||
|
@ -960,7 +952,7 @@ int rtps_init (void)
|
|||
#ifdef DDSI_INCLUDE_NETWORK_PARTITIONS
|
||||
/* Convert address sets in partition mappings from string to address sets */
|
||||
{
|
||||
const int port = config.port_base + config.port_dg * config.domainId + config.port_d2;
|
||||
const int port = config.port_base + config.port_dg * config.domainId.value + config.port_d2;
|
||||
struct config_networkpartition_listelem *np;
|
||||
for (np = config.networkPartitions; np; np = np->next)
|
||||
{
|
||||
|
@ -1034,7 +1026,7 @@ int rtps_init (void)
|
|||
{
|
||||
if (make_uc_sockets (&port_disc_uc, &port_data_uc, config.participantIndex) < 0)
|
||||
{
|
||||
NN_ERROR ("rtps_init: failed to create unicast sockets for domain %d participant %d\n", config.domainId, config.participantIndex);
|
||||
NN_ERROR ("rtps_init: failed to create unicast sockets for domain %d participant %d\n", config.domainId.value, config.participantIndex);
|
||||
goto err_unicast_sockets;
|
||||
}
|
||||
}
|
||||
|
@ -1052,13 +1044,13 @@ int rtps_init (void)
|
|||
continue;
|
||||
else /* Oops! */
|
||||
{
|
||||
NN_ERROR ("rtps_init: failed to create unicast sockets for domain %d participant %d\n", config.domainId, ppid);
|
||||
NN_ERROR ("rtps_init: failed to create unicast sockets for domain %d participant %d\n", config.domainId.value, ppid);
|
||||
goto err_unicast_sockets;
|
||||
}
|
||||
}
|
||||
if (ppid > config.maxAutoParticipantIndex)
|
||||
{
|
||||
NN_ERROR ("rtps_init: failed to find a free participant index for domain %d\n", config.domainId);
|
||||
NN_ERROR ("rtps_init: failed to find a free participant index for domain %d\n", config.domainId.value);
|
||||
goto err_unicast_sockets;
|
||||
}
|
||||
config.participantIndex = ppid;
|
||||
|
@ -1069,7 +1061,7 @@ int rtps_init (void)
|
|||
}
|
||||
nn_log (LC_CONFIG, "rtps_init: uc ports: disc %u data %u\n", port_disc_uc, port_data_uc);
|
||||
}
|
||||
nn_log (LC_CONFIG, "rtps_init: domainid %d participantid %d\n", config.domainId, config.participantIndex);
|
||||
nn_log (LC_CONFIG, "rtps_init: domainid %d participantid %d\n", config.domainId.value, config.participantIndex);
|
||||
|
||||
if (config.pcap_file && *config.pcap_file)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue