Exemplo n.º 1
0
DDS_ReturnCode_t DDS_DataWriter_get_matched_subscription_data (
				DDS_DataWriter                   wp,
				DDS_SubscriptionBuiltinTopicData *data,
				DDS_InstanceHandle_t             handle)
{
	Entity_t		*ep;
	DDS_ReturnCode_t	ret;

	ctrc_begind (DCPS_ID, DCPS_DW_G_SUBS_D, &wp, sizeof (wp));
	ctrc_contd (&data, sizeof (data));
	ctrc_contd (&handle, sizeof (handle));
	ctrc_endd ();

	if (!data || !handle)
		return (DDS_RETCODE_BAD_PARAMETER);

	if (!writer_ptr (wp, 1, &ret))
		return (ret);

	ep = entity_ptr (handle);
	if (!ep ||
	     ep->type != ET_READER ||
	     entity_ignored (ep->flags)) {
		ret = DDS_RETCODE_BAD_PARAMETER;
		goto done;
	}
	if (entity_discovered (ep->flags))
		ret = dcps_get_builtin_subscription_data (data, (DiscoveredReader_t *) ep);
	else
		ret = dcps_get_local_subscription_data (data, (Reader_t *) ep);

    done:
	lock_release (wp->w_lock);
	return (ret);
}
Exemplo n.º 2
0
static int participant_add_handle (Skiplist_t *list, void *node, void *arg)
{
	const Participant_t	*pp, **ppp = (const Participant_t **) node;
	DDS_InstanceHandleSeq	*handles = (DDS_InstanceHandleSeq *) arg;
	DDS_InstanceHandle_t	h;

	ARG_NOT_USED (list)

	pp = *ppp;
	if (entity_ignored (pp->p_entity.flags))
		return (1);

	h = pp->p_handle;
	return (dds_seq_append (handles, &h) == 0);
}
Exemplo n.º 3
0
static int topic_add_handle (Skiplist_t *list, void *node, void *arg)
{
	const Topic_t		*tp, **tpp = (const Topic_t **) node;
	DDS_InstanceHandleSeq	*handles = (DDS_InstanceHandleSeq *) arg;
	DDS_InstanceHandle_t	h;

	ARG_NOT_USED (list)

	tp = *tpp;
	if (!entity_discovered (tp->entity.flags) ||
	    entity_ignored (tp->entity.flags))
		return (1);

	h = tp->entity.handle;
	return (dds_seq_append (handles, &h) == 0);
}
Exemplo n.º 4
0
DDS_ReturnCode_t DDS_DomainParticipant_get_discovered_topic_data (
					DDS_DomainParticipant     dp,
					DDS_TopicBuiltinTopicData *data,
					DDS_InstanceHandle_t      handle)
{
	Entity_t		*ep;
	DDS_ReturnCode_t	ret;

	ctrc_begind (DCPS_ID, DCPS_DP_G_DISC_T, &dp, sizeof (dp));
	ctrc_contd (&data, sizeof (data));
	ctrc_contd (&handle, sizeof (handle));
	ctrc_endd ();

	if (!data || !handle)
		return (DDS_RETCODE_BAD_PARAMETER);

	if (!domain_ptr (dp, 1, &ret))
		return (ret);

	if ((dp->participant.p_flags & EF_ENABLED) == 0) {
		lock_release (dp->lock);
		return (DDS_RETCODE_NOT_ENABLED);
	}
	ep = entity_ptr (handle);
	if (!ep ||
	     ep->type != ET_TOPIC ||
	     !entity_discovered (ep->flags) ||
	     entity_ignored (ep->flags)) {
		ret = DDS_RETCODE_BAD_PARAMETER;
		goto done;
	}
	if (dcps_get_builtin_topic_data (data, (Topic_t *) ep, 0)) {
		ret = DDS_RETCODE_OUT_OF_RESOURCES;
		goto done;
	}

    done:
	lock_release (dp->lock);
	return (ret);
}
Exemplo n.º 5
0
void msg_data_event (Reader_t *rp, NotificationType_t t, int secure)
{
	Domain_t		*dp = rp->r_subscriber->domain;
	Participant_t		*pp;
	unsigned		nchanges;
	ChangeData_t		change;
	ParticipantMessageData	*info = NULL;
#ifdef DISC_MSG_DUMP
	InfoType_t		type;
#endif
	int			error;

	ARG_NOT_USED (secure)

	if (t != NT_DATA_AVAILABLE)
		return;

	rp->r_status &= ~DDS_DATA_AVAILABLE_STATUS;
	do {
		nchanges = 1;
		/*dtrc_print0 ("PMSG: get samples");*/
		error = disc_get_data (rp, &change);
		if (error) {
			/*dtrc_print0 ("- none\r\n");*/
			break;
		}
		/*dtrc_print1 ("- valid(%u)\r\n", change.kind);*/
		if (change.kind != ALIVE) {
			/*error = hc_get_key (cdp, change.h, &info, 0);
			if (error)
				continue;*/

#ifdef DISC_MSG_DUMP
			type = EI_DELETE;
#endif
			hc_inst_free (rp->r_cache, change.h);
		}
		else {
#ifdef DISC_MSG_DUMP
			if (change.is_new)
				type = EI_NEW;
			else
				type = EI_UPDATE;
#endif
			info = change.data;
		}
		pp = entity_participant (change.writer);
		if (!pp ||				/* Not found. */
		    pp == &dp->participant ||		/* Own sent info. */
		    entity_ignored (pp->p_flags)) {	/* Ignored. */
			hc_inst_free (rp->r_cache, change.h);
			continue;	/* Filter out unneeded info. */
		}

		/* If it's a liveliness indication, then propagate it. */ 
		if (info) {
#ifdef DISC_MSG_DUMP

			/* Message from remote participant. */
			if (spdp_log)
				msg_data_info (pp, info, 'R', type);
#endif
			if (info->kind [0] == 0 &&
			    info->kind [1] == 0 &&
			    info->kind [2] == 0 &&
			    (info->kind [3] == 1 || info->kind [3] == 2)) {
				pp = participant_lookup (dp, &info->participantGuidPrefix);
				if (pp)
					liveliness_participant_event (pp, info->kind [3] != 1);
			}
			xfree (info);
		}
		hc_inst_free (rp->r_cache, change.h);
	}
	while (nchanges);
}
Exemplo n.º 6
0
void sedp_topic_event (Reader_t *rp, NotificationType_t t)
{
	Domain_t		*dp = rp->r_subscriber->domain;
	Participant_t		*pp;
	ChangeData_t		change;
	DiscoveredTopicData	*info = NULL, tinfo;
	Topic_t			*tp;
	InfoType_t		type;
	int			error, new_node, valid_data = 0;
	const char		*names [2];

	if (t != NT_DATA_AVAILABLE)
		return;

	rp->r_status &= ~DDS_DATA_AVAILABLE_STATUS;
	for (;;) {
		if (info) {
			pid_topic_data_cleanup (&info);
			xfree (info);
			info = NULL;
		}
		/*dtrc_print0 ("SEDP-Topic: get samples ");*/
		error = disc_get_data (rp, &change);
		if (error) {
			/*dtrc_print0 ("- none\r\n");*/
			break;
		}
		/*dtrc_print1 ("- valid(%u)\r\n", change.kind);*/
		if (change.kind != ALIVE) {
			/* error = hc_get_key (rp->r_cache, change.h, &tinfo, 0);
			if (error)
				continue; */

			type = EI_DELETE;
			hc_inst_free (rp->r_cache, change.h);
		}
		else {
			type = EI_NEW;
			info = change.data;
		}
		pp = entity_participant (change.writer);
		if (!pp ||				/* Not found. */
		    pp == &dp->participant ||		/* Own sent info. */
		    entity_ignored (pp->p_flags)) {	/* Ignored. */
			hc_inst_free (rp->r_cache, change.h);
			continue;	/* Filter out unneeded info. */
		}

		/* Topic from remote participant. */
		if (type == EI_DELETE) {
			/* TBD: Certified not to work correctly. */
			tp = topic_lookup (pp, str_ptr (info.name));
			if (!tp) {
				hc_inst_free (rp->r_cache, change.h);
				continue; /* If doesn't exist - no action. */
			}
			names [0] = str_ptr (tp->name);
			names [1] = str_ptr (tp->type->type_name);
		}
		else {
			tp = topic_create (pp, NULL, names [0], names [1], &new_node);
			if (!tp) {
				hc_inst_free (rp->r_cache, change.h);
				continue; /* Can't create info -- just ignore. */
			}
			if (!new_node) {
				if (entity_ignored (tp->entity.flags)) {
					hc_inst_free (rp->r_cache, change.h);
					continue;
				}
				type = EI_UPDATE;
			}
			names [0] = str_ptr (info->name);
			names [1] = str_ptr (info->type_name);
		}
		if (sedp_log)
			log_printf (SEDP_ID, 0, "SEDP: %s topic (%s/%s) from peer!\r\n",
					    info_type_str [type], names [0], names [1]);
		sedp_topic_info (pp, tp, info, type);
	}
	if (info) {
		pid_topic_data_cleanup (info);
		xfree (info);
	}
}
Exemplo n.º 7
0
void sedp_publication_event (Reader_t *rp,
			     NotificationType_t t,
			     int cdd,
			     int secure)
{
	Domain_t		*dp = rp->r_subscriber->domain;
	Participant_t		*pp;
	ChangeData_t		change;
	DiscoveredWriterData	*info = NULL, tinfo;
	Topic_t			*tp;
	DiscoveredWriter_t	*dwp;
	Reader_t		*mrp;
	UniQos_t		qos;
	InfoType_t		type;
	GUID_t			*guidp;
	int			error;

	if (t != NT_DATA_AVAILABLE)
		return;

	rp->r_status &= ~DDS_DATA_AVAILABLE_STATUS;
	for (;;) {
		if (info) {
			pid_writer_data_cleanup (info);
			xfree (info);
			info = NULL;
		}
		/*dtrc_print0 ("SEDP-Pub: get samples ");*/
		error = disc_get_data (rp, &change);
		if (error) {
			/*dtrc_print0 ("- none\r\n");*/
			break;
		}
		/*dtrc_print1 ("- valid(%u)\r\n", change.kind);*/
		if (change.kind != ALIVE) {
			error = hc_get_key (rp->r_cache, change.h, &tinfo, 0);
			if (error)
				continue;

			guidp = &tinfo.proxy.guid;
			type = EI_DELETE;
			hc_inst_free (rp->r_cache, change.h);
		}
		else {
			info = change.data;
			if (!info->topic_name || !info->type_name) {
				hc_inst_free (rp->r_cache, change.h);
				continue;
			}
			type = EI_NEW;
			guidp = &info->proxy.guid;
		}
			pp = entity_participant (change.writer);
		if (!pp ||				/* Not found. */
		    pp == &dp->participant ||		/* Own sent info. */
		    entity_ignored (pp->p_flags)) {	/* Ignored. */
			if (pp != &dp->participant && !cdd)
				warn_printf ("sedp_publication_rx: invalid change.writer field!\r\n");

			hc_inst_free (rp->r_cache, change.h);
			dtrc_print0 ("SEDP-Pub: unneeded!\r\n");
			continue;	/* Filter out unneeded info. */
		}

		/* Publication from remote participant. */
		if (type == EI_DELETE) {
			dwp = (DiscoveredWriter_t *) endpoint_lookup (pp,
							&guidp->entity_id);
			if (!dwp) {
				dtrc_print0 ("SEDP-Pub: DELETE && doesn't exist!\r\n");
				continue; /* If doesn't exist - no action. */
			}
			if (!dwp->dw_topic) {
				endpoint_delete (pp, &dwp->dw_ep);
				continue; /* Ignored topic -- only endpoint. */
			}
			if (sedp_log)
				log_printf (SEDP_ID, 0, "SEDP: Deleted %spublication (%s/%s) from peer!\r\n",
						(secure) ? "secure " : "",
						str_ptr (dwp->dw_topic->name),
						str_ptr (dwp->dw_topic->type->type_name));
			disc_publication_remove (pp, dwp);

			hc_inst_free (rp->r_cache, change.h);
			continue;
		}

		/* Do we know this topic? */
		tp = topic_lookup (&dp->participant, str_ptr (info->topic_name));
		if (tp && entity_ignored (tp->entity.flags)) {
			hc_inst_free (rp->r_cache, change.h);
			dtrc_print1 ("SEDP: ignored topic (%s)!\r\n", str_ptr (info->topic_name));
			continue;	/* Ignored topic. */
		}

		/* Do we know this endpoint already? */
		dwp = (DiscoveredWriter_t *) endpoint_lookup (pp, &guidp->entity_id);
		if (dwp) {
			if (entity_ignored (dwp->dw_flags) || cdd) {
				hc_inst_free (rp->r_cache, change.h);
				continue; /* Ignored endpoint. */
			}
			dtrc_print1 ("Already exists (%s)!\r\n", str_ptr (info->topic_name));
			type = EI_UPDATE;
			disc_publication_update (pp, dwp, info);
			if (sedp_log)
				log_printf (SEDP_ID, 0, "SEDP: Updated %spublication (%s/%s) from peer!\r\n",
						(secure) ? "secure " : "",
						str_ptr (info->topic_name),
						str_ptr (info->type_name));
			hc_inst_free (rp->r_cache, change.h);
		}
		else {
			/* Get QoS parameters. */
			qos_disc_writer_set (&qos, &info->qos);
			mrp = NULL;
			/* Create new endpoint. */
			dwp = (DiscoveredWriter_t *) endpoint_create (pp,
					pp, &guidp->entity_id, NULL);
			if (!dwp) {
				dtrc_print1 ("SEDP: Create endpoint (%s) not possible - exit!\r\n", str_ptr (info->topic_name));
				hc_inst_free (rp->r_cache, change.h);
				qos_disc_writer_restore (&info->qos, &qos);
				continue;  /* Can't create -- just ignore. */
			}
			disc_publication_add (pp, dwp, &qos, tp, mrp, info);
			hc_inst_free (rp->r_cache, change.h);
			if (sedp_log)
				log_printf (SEDP_ID, 0, "SEDP: New %spublication (%s/%s) from %s!\r\n",
						(secure) ? "secure " : "",
						str_ptr (info->topic_name),
						str_ptr (info->type_name),
						(cdd) ? "CDD" : "peer");

		}
	}
	if (info) {
		pid_writer_data_cleanup (info);
		xfree (info);
	}
}