Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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);
	}
}
Ejemplo n.º 3
0
void ctt_event (Reader_t *rp, NotificationType_t t)
{
	Domain_t			*dp = rp->r_subscriber->domain;
	ChangeData_t			change;
	DDS_ParticipantStatelessMessage *info = NULL;
	int				error;
#ifdef DDS_QEO_TYPES
	unsigned                        i;
	DDS_DataHolder                  *cp;
#endif

	if (t != NT_DATA_AVAILABLE)
		return;

	rp->r_status &= ~DDS_DATA_AVAILABLE_STATUS;
	for (;;) {
		error = disc_get_data (rp, &change);
		if (error)
			break;

		/* Unmarshall handshake message. */
		info = change.data;
		if (!info)
			break;

		/* Drop message if not a broadcast or no matching key. */
		if (memcmp (info->destination_participant_key,
				psmp_unknown_key, GUIDPREFIX_SIZE) &&
		    memcmp (info->destination_participant_key,
		    		dp->participant.p_guid_prefix.prefix, GUIDPREFIX_SIZE))
			goto free_data;

		CTT_TRACE ('R', info);

		CTT_ASSERT (dp);

		/* Handle different message classes specifically: */
		if (!info->message_class_id)
			;
		else if (!strcmp (info->message_class_id,
				  GMCLASSID_SECURITY_PARTICIPANT_CRYPTO_TOKENS))
			ctt_participant_crypto_tokens (dp, info);
		else if (!strcmp (info->message_class_id,
				  GMCLASSID_SECURITY_DATAWRITER_CRYPTO_TOKENS))
			ctt_data_writer_crypto_tokens (dp, info);
		else if (!strcmp (info->message_class_id,
				  GMCLASSID_SECURITY_DATAREADER_CRYPTO_TOKENS))
			ctt_data_reader_crypto_tokens (dp, info);
#ifdef DDS_QEO_TYPES
		else if (cb_fct) {
			for (i = 0; i < DDS_SEQ_LENGTH (info->message_data); i++) {
				cp = DDS_SEQ_ITEM_PTR (info->message_data, i);
				(*cb_fct) (cp);
			}
		}
#endif
		CTT_ASSERT (dp);

		/* Free message info. */

	    free_data:
		xfree (info);
		info = NULL;
	}
	if (info)
		xfree (info);
}
Ejemplo n.º 4
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);
	}
}