コード例 #1
0
ファイル: sp_db.c プロジェクト: bq/qeo-core
TopicHandle_t DDS_SP_add_topic (ParticipantHandle_t participant_handle, 
				DomainHandle_t      domain_handle)
{
	MSParticipant_t	*p = NULL;
	MSDomain_t	*d = NULL;
	MSUTopic_t	*tp = NULL;
	MSTopic_t       *dtp = NULL;

	/* log_printf (SEC_ID, 0, "MSP: Add default 'allow all' policy for topic\r\n"); */

	if (participant_handle > 0) {
		/*ADD this topic for participant*/
		if (!(p = id_handles [participant_handle]))
			return (-1);

		if ( LIST_HEAD (p->topics) &&
		     LIST_HEAD (p->topics)->topic.index == 0)
			DDS_SP_remove_topic ( participant_handle, 0, 0);

		if (!(tp = calloc (1, sizeof (MSUTopic_t))))
			fatal_printf ("Out of memory!\r\n");
		LIST_ADD_TAIL (p->topics, *tp);
		tp->id = ~0; /* all domains */
		tp->topic.name = NULL; /* name == '*' */
		tp->topic.mode = TA_ALL;
	        tp->topic.index = ++topic_counter;
		log_printf ("MSP: add topic (%d, 0, %d);\r\n", participant_handle, tp->topic.index);
		tp->topic.blacklist = 0;
		p->ntopics++;

		return (tp->topic.index);
	}
	else if (domain_handle > 0) {
		/*ADD this topic for domain*/

		if (!(d = domain_handles [domain_handle]))
			return (-1);

		if (LIST_HEAD (d->topics) &&
		    LIST_HEAD (d->topics)->index == 0)
			DDS_SP_remove_topic (0, domain_handle, 0);

		if (!(dtp = calloc (1, sizeof (MSTopic_t))))
			fatal_printf ("Out of memory!\r\n");
		LIST_ADD_TAIL (d->topics, *dtp);
		dtp->name = NULL; /* name == '*' */
		dtp->mode = TA_ALL;
		dtp->index = ++topic_counter;
		log_printf ("MSP: add topic (0, %d, %d);\r\n", participant_handle, tp->topic.index);
		dtp->blacklist = 0;
		d->ntopics++;

		return (dtp->index);
	}
		
	return (-1);
}
コード例 #2
0
ファイル: sp_db.c プロジェクト: FlavioFalcao/tinq-core
DDS_ReturnCode_t DDS_SP_remove_domain (DomainHandle_t domain_handle)
{
	MSDomain_t       *d;
	unsigned         i, ntopics, npartitions;
	DDS_ReturnCode_t ret;

	/* log_printf (SEC_ID, 0, "MSP: Remove domain\r\n"); */

	if (!(d = domain_handles [domain_handle]))
		return (DDS_RETCODE_BAD_PARAMETER);

	ntopics = d->ntopics;
	for (i = 0; i < ntopics; i++)
		if ((ret = DDS_SP_remove_topic (0, domain_handle,
						LIST_HEAD (d->topics)->index)))
			return (ret);

	npartitions = d->npartitions;
	for (i = 0; i < npartitions; i++)
		if ((ret = DDS_SP_remove_partition (0, domain_handle, 
						    LIST_HEAD (d->partitions)->index)))
			return (ret);

	LIST_REMOVE (domains, *d);
	free (d);

	/*if it is the last one in the list, we can reuse the memory*/
	/*perhaps later we should make it possible to realign the array,
	 when we remove an element*/
	if (domain_handle == num_domains)
		num_domains--;

	return (DDS_RETCODE_OK);
}
コード例 #3
0
ファイル: sp_db.c プロジェクト: FlavioFalcao/tinq-core
DDS_ReturnCode_t DDS_SP_remove_participant (ParticipantHandle_t participant_handle) 
{
	MSParticipant_t  *p;
	unsigned         i, ntopics, npartitions;
	DDS_ReturnCode_t ret;
	
	/* log_printf (SEC_ID, 0, "MSP: Remove participant\r\n"); */

	if (!(p = id_handles [participant_handle]))
		return (DDS_RETCODE_BAD_PARAMETER);

	ntopics = p->ntopics;
	for (i = 0; i < ntopics; i++) 
		if ((ret = DDS_SP_remove_topic (participant_handle, 0, 
					     LIST_HEAD (p->topics)->topic.index)))
			return (ret);

	npartitions = p->npartitions;
	for (i = 0;  i < npartitions; i++)
		if ((ret = DDS_SP_remove_partition (participant_handle, 0, 
						 LIST_HEAD (p->partitions)->partition.index)))
			return (ret);
	/* if the credential is of the DDS_SSL_BASED kind
	   we need to remove the certificate stack as well */
	if (p->cloned && p->credentials && p->credentials->credentialKind == DDS_SSL_BASED) {
		sk_X509_pop_free (p->credentials->info.sslData.certificate_list, X509_free);
		EVP_PKEY_free (p->credentials->info.sslData.private_key);
	}

	if (p->cloned) {
		/* DDS_revoke_participant (local_dom_part_handle, p->part_handle); */
		if (p->credentials) {
			free (p->credentials);
			p->credentials = NULL;
		}
	}
	LIST_REMOVE (participants, *p);
	free (p);
	id_handles [participant_handle] = NULL;

	/*if it is the last one in the list, we can reuse the memory*/
	if (participant_handle == num_ids)
		num_ids--;

	return (DDS_RETCODE_OK);
}