Exemple #1
0
DDS_ReturnCode_t get_identity_token (Identity_t    handle,
				     unsigned char *identity,
				     size_t        *identity_length)
{
	Token_t			*tokens, *token;
	DDS_IdentityToken	*idp;
	DDS_ReturnCode_t	error;

	tokens = sec_get_identity_tokens (handle, SECC_DTLS_UDP, &error);
	if (!tokens)
		return (error);

	for (token = tokens; token; token = token->next)
		if (token->encoding) {
			idp = token->data;
			if (!idp->binary_value1 ||
			    DDS_SEQ_LENGTH (*idp->binary_value1) > *identity_length ||
			    !DDS_SEQ_LENGTH (*idp->binary_value1))
				return (DDS_RETCODE_BAD_PARAMETER);

			memcpy (identity,
				DDS_SEQ_DATA (*idp->binary_value1),
				DDS_SEQ_LENGTH (*idp->binary_value1));
			break;
		}
	sec_release_id_tokens (tokens);
	return ((token) ? DDS_RETCODE_OK : DDS_RETCODE_BAD_PARAMETER);
}
static void my_on_data_available(const qeocore_reader_t *reader,
                                 const qeocore_data_t *data,
                                 uintptr_t userdata)
{
    switch (qeocore_data_get_status(data)) {
        case QEOCORE_DATA: {
            qeocore_data_t *seqdata = NULL;
            byte_array_t array;
            int i, size;

            log_pid("reader received data");
            assert(QEO_OK == qeocore_data_get_member(data, _size_id, &size));
            assert(QEO_OK == qeocore_data_get_member(data, _buf_id, &seqdata));
            assert(QEO_OK == qeocore_data_sequence_get(seqdata, (qeo_sequence_t *)&array, 0, QEOCORE_SIZE_UNLIMITED));
            assert(size == DDS_SEQ_LENGTH(array));
            assert(_test_size == DDS_SEQ_LENGTH(array));
            for (i = 0; i < size; i++) {
                assert(DDS_SEQ_ITEM(array, i) == (i & 0xff));
            }
            qeocore_data_sequence_free(seqdata, (qeo_sequence_t *)&array);
            qeocore_data_free(seqdata);
            sem_post(&_sync); /* release main thread */
            break;
        }
        case QEOCORE_NO_MORE_DATA:
        case QEOCORE_REMOVE:
            /* ignore */
            break;
        default:
            abort();
            break;
    }
}
Exemple #3
0
static bool simplechat_ChatMessage_get_val_cb(uintptr_t in_data, const char *name, CDR_TypeCode_t type, qeo_t2d_types_t *value){

    const org_qeo_sample_simplechat_ChatMessage_t *chat_msg = (const org_qeo_sample_simplechat_ChatMessage_t *)in_data;
    if (strcmp(name, "from") == 0){
        value->string_val = chat_msg->from;
    } else if (strcmp(name, "fromExtra") == 0){
        value->typeref.ref = (uintptr_t)&chat_msg->fromExtra;
        value->typeref.mcbs = &_uuid_mcbs;
    } else if (strcmp(name, "message") == 0){
        value->string_val = chat_msg->message;
    } else if (strcmp(name, "extraInfo") == 0){
        value->seq.seq_ref = (uintptr_t)&chat_msg->extraInfo;
        value->seq.seq_size = DDS_SEQ_LENGTH(chat_msg->extraInfo);
        value->seq.mcbs = &_sc_extraInfo_mcbs;
    } else if (strcmp(name, "list") == 0){
        value->seq.seq_ref = (uintptr_t)&chat_msg->list;
        value->seq.seq_size = DDS_SEQ_LENGTH(chat_msg->list);
        value->seq.mcbs = &_sc_list_mcbs;
    } else if (strcmp(name, "maincolor") == 0){
        ck_assert_int_eq(type, CDR_TYPECODE_ENUM);
        value->enum_val = chat_msg->maincolor;
    } else if (strcmp(name, "colorlist") == 0){
        ck_assert_int_eq(type, CDR_TYPECODE_SEQUENCE);
        value->seq.seq_ref = (uintptr_t)&chat_msg->colorlist;
        value->seq.seq_size = DDS_SEQ_LENGTH(chat_msg->colorlist);
        value->seq.mcbs = &_sc_colorlist_mcbs;

    } else {
        qeo_log_e("unknown field %s", name);
        return false;
    }

    return true;
}
Exemple #4
0
static void fwd_client_on_data(const qeocore_reader_t *reader,
                               const qeocore_data_t *data,
                               uintptr_t userdata)
{
    qeo_factory_t *factory = (qeo_factory_t *)userdata;
    qeocore_data_status_t status;
    org_qeo_system_Forwarder_t *fwd_data;
    org_qeo_system_ForwarderLocator_t fwd_locator;
    qeo_mgmt_client_locator_t locator;

    status = qeocore_data_get_status(data);
    if (QEOCORE_DATA == status) {
        fwd_data = (org_qeo_system_Forwarder_t *)qeocore_data_get_data(data);
        /* check locator */
        if ((NULL != fwd_data) && (DDS_SEQ_LENGTH(fwd_data->locator) > 0)) {
            fwd_locator = DDS_SEQ_ITEM(fwd_data->locator, 0);
            locator.type = fwd_locator.type;
            locator.port = fwd_locator.port;
            locator.address = fwd_locator.address;
            client_state_machine_eval(factory, CLIENT_EVENT_FWD_DATA_RECEIVED, &locator, fwd_data->deviceId);
        }
    }
    else if (QEOCORE_REMOVE == status) {
        fwd_data = (org_qeo_system_Forwarder_t *)qeocore_data_get_data(data);
        if (NULL != fwd_data) {
            client_state_machine_eval(factory, CLIENT_EVENT_FWD_DATA_REMOVED, NULL, fwd_data->deviceId);
        }
    }
}
Exemple #5
0
static void msg_dump_data (DDS_OctetSeq *sp)
{
	unsigned		i;
	const unsigned char	*cp;

	if (!DDS_SEQ_LENGTH (*sp)) {
		log_printf (SPDP_ID, 0, "<empty>\r\n");
		return;
	}
	for (i = 0, cp = sp->_buffer; i < DDS_SEQ_LENGTH (*sp); i++) {
		if ((i & 0xf) == 0)
			log_printf (SPDP_ID, 0, "\t%04u: ", i);
		log_printf (SPDP_ID, 0, "%02x ", *cp++);
	}
	log_printf (SPDP_ID, 0, "\r\n");
}
static unsigned partition_set (DDS_StringSeq *ssp,
			       Strings_t     *pp,
			       unsigned char *dst)
{
	String_t	*sp;
	unsigned char	*start = dst;
	unsigned	i, len;

	ssp->_esize = sizeof (char *);
	if (pp) {
		ssp->_maximum = ssp->_length = pp->_length;
		ssp->_buffer = (char **) dst;
		dst += pp->_length * sizeof (char *);
		for (i = 0; i < DDS_SEQ_LENGTH (*pp); i++) {
			sp = DDS_SEQ_ITEM (*pp, i);
			if (sp) {
				len = str_len (sp);
				memcpy (dst, str_ptr (sp), len);
			}
			else {
				len = 1;
				*dst = '\0';
			}
			DDS_SEQ_ITEM_SET (*ssp, i, (char *) dst);
			dst += len;
		}
	}
	else
		ssp->_maximum = ssp->_length = 0;
	return (dst - start);
}
Exemple #7
0
DDS_ReturnCode_t DDS_ContentFilteredTopic_set_expression_parameters (
						DDS_ContentFilteredTopic ftp,
						DDS_StringSeq *expr_pars)
{
	DDS_ReturnCode_t	rc;

	ctrc_begind (DCPS_ID, DCPS_FT_S_PARS, &ftp, sizeof (ftp));
	ctrc_contd (&expr_pars, sizeof (expr_pars));
	ctrc_endd ();

	if (!topic_ptr (ftp, 1, NULL))
		return (DDS_RETCODE_ALREADY_DELETED);

	if ((ftp->topic.entity.flags & EF_FILTERED) == 0) {
		rc = DDS_RETCODE_ALREADY_DELETED;
		goto done;
	}
	if (!expr_pars || DDS_SEQ_LENGTH (*expr_pars) < ftp->data.program.npars) {
		rc = DDS_RETCODE_BAD_PARAMETER;
		goto done;
	}
	rc = dcps_update_str_pars (&ftp->data.filter.expression_pars, expr_pars);

    done:
	lock_release (ftp->topic.lock);
	return (rc);
}
Exemple #8
0
void dr_on_statistic_data_available(DDS_DataReaderListener *self, DDS_DataReader dataReader)
{
	acceptance_high_end_StatisticPtrSeq samples;
	DDS_SampleInfoSeq sampleInfos;
	DDS_ReturnCode_t retCode;
	int i;

	DDS_SEQ_INIT(samples);
	DDS_SEQ_INIT(sampleInfos);

	retCode = DDS_DataReader_take(dataReader, (DDS_DataSeq *)&samples, &sampleInfos, -1, DDS_ANY_SAMPLE_STATE, DDS_ANY_VIEW_STATE, DDS_ANY_INSTANCE_STATE);
	if (retCode == DDS_RETCODE_NO_DATA) {
		return;
	}
	else if (retCode != DDS_RETCODE_OK) {
		fprintf(stderr, "Error taking sample (%s).\r\n", DDS_error(retCode));
		return;
	}

	for (i = 0; i < DDS_SEQ_LENGTH (samples); i++)
		if (DDS_SEQ_ITEM (sampleInfos, i)->valid_data)
			nofConfigSamples++;

	retCode = DDS_DataReader_return_loan(dataReader, (DDS_DataSeq *)&samples, &sampleInfos);
	if (retCode != DDS_RETCODE_OK) {
		fprintf(stderr, "Error returning loan (%s).\r\n", DDS_error(retCode));
		return;
	}
}
Exemple #9
0
void read_data (DDS_DataReaderListener *l, DDS_DataReader dr)
{
	static DDS_DynamicDataSeq drx_sample = DDS_SEQ_INITIALIZER (void *);
	static DDS_SampleInfoSeq rx_info = DDS_SEQ_INITIALIZER (DDS_SampleInfo *);
	DDS_SampleStateMask	ss = DDS_NOT_READ_SAMPLE_STATE;
	DDS_ViewStateMask	vs = DDS_ANY_VIEW_STATE;
	DDS_InstanceStateMask	is = DDS_ANY_INSTANCE_STATE;
	DDS_SampleInfo		*info;
	DDS_ReturnCode_t	error;
	DDS_DynamicData		dd;
	Topic			*tp;
	int			secure = (cert_path != NULL);

	tp = (Topic *) l->cookie;
	for (;;) {
		error = DDS_DynamicDataReader_take (dr, &drx_sample, &rx_info, 1, ss, vs, is);
		if (error) {
			if (error != DDS_RETCODE_NO_DATA)
				printf ("Unable to read samples: error = %s!\r\n", DDS_error (error));
			return;
		}
		if (DDS_SEQ_LENGTH (rx_info)) {
			info = DDS_SEQ_ITEM (rx_info, 0);
			if (info->valid_data) {
				dd = DDS_SEQ_ITEM (drx_sample, 0);
				if (!dd)
					fatal ("Empty dynamic sample!");

				tp->ndata++;
				if (!paused) {
					dbg_printf ("%s: ", tp->topic_name);
					DDS_Debug_dump_dynamic (0, tp->ts, dd, 0, secure, 1);
					dbg_printf ("\r\n");
				}
			}
			else if (info->instance_handle && info->instance_state != DDS_ALIVE_INSTANCE_STATE) {
				if (info->instance_state == DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE)
					tp->ndispose++;
				else if (info->instance_state == DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE)
					tp->nnowriter++;
				if (!paused) {
					dd = DDS_DynamicDataFactory_create_data (tp->dtype);
					DDS_DynamicDataReader_get_key_value (dr, dd, info->instance_handle);
					dbg_printf ("%s: ", tp->topic_name);
					DDS_Debug_dump_dynamic (0, tp->ts, dd, 1, secure, 1);
					if (info->instance_state == DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE)
						dbg_printf (": Not alive - disposed.");
					else if (info->instance_state == DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE)
						dbg_printf (": Not alive - no writers.");
					dbg_printf ("\r\n");
				}
			}
			DDS_DynamicDataReader_return_loan (dr, &drx_sample, &rx_info);
		}
		else
			return;
	}
}
Exemple #10
0
static size_t partition_size (Strings_t *partition)
{
	size_t		s;
	unsigned	i;
	String_t	*sp;

	if (!partition)
		return (0);

	s = DDS_SEQ_LENGTH (*partition) * sizeof (char *);
	for (i = 0; i < DDS_SEQ_LENGTH (*partition); i++) {
		sp = DDS_SEQ_ITEM (*partition, i);
		if (sp)
			s += str_len (sp) + 1;
		else
			s += 1;
	}
	return (s);
}
Exemple #11
0
void introspect_annotation (DDS_AnnotationDescriptor *adp, int after)
{
	unsigned		i;
	DDS_ReturnCode_t	ret;
	DDS_TypeDescriptor	desc;
	DDS_Parameters		pars;
	MapEntry_DDS_ObjectName_DDS_ObjectName *p;

	if (after)
		dbg_printf ("  //");

	DDS_TypeDescriptor__init (&desc);
	ret = DDS_DynamicType_get_descriptor (adp->type, &desc);
	fail_unless (ret == DDS_RETCODE_OK);

	dbg_printf ("@%s", desc.name);
	DDS_SEQ_INIT (pars);
	ret = DDS_AnnotationDescriptor_get_all_value (adp, &pars);
	fail_unless (ret == DDS_RETCODE_OK);

	if (DDS_SEQ_LENGTH (pars) == 1 &&
	    !strcmp (DDS_SEQ_ITEM (pars, 0).key, "value")) { /* Shorthand notation! */
		if (strcmp (DDS_SEQ_ITEM (pars, 0).value, "true"))
			dbg_printf ("(%s)", DDS_SEQ_ITEM (pars, 0).value);
	}
	else {
		dbg_printf ("(");
		for (i = 0; i < DDS_SEQ_LENGTH (pars); i++) {
			if (i)
				dbg_printf (", ");
			p = DDS_SEQ_ITEM_PTR (pars, i);
			dbg_printf ("%s=\"%s\"", p->key, p->value);
		}
		dbg_printf (")");
	}
	if (!after)
		dbg_printf (" ");

	DDS_Parameters__clear (&pars);
	DDS_TypeDescriptor__clear (&desc);
}
Exemple #12
0
void ctt_send (Domain_t                             *dp,
	       Participant_t                        *pp,
	       Endpoint_t                           *sep,
	       Endpoint_t                           *dep,
	       DDS_ParticipantVolatileSecureMessage *msg)
{
	Writer_t			*wp;
	DDS_Time_t			time;
	DDS_InstanceHandleSeq		handles;
	DDS_InstanceHandle_t		h;
	int				error;

	CTT_ASSERT (dp);

	memcpy (msg->message_identity.source_guid, dp->participant.p_guid_prefix.prefix, 12);
	msg->message_identity.sequence_number = psmp_seqnr++;
	if (pp)
		memcpy (msg->destination_participant_key, pp->p_guid_prefix.prefix, 12);
	if (dep) {
		memcpy (msg->destination_endpoint_key, pp->p_guid_prefix.prefix, 12);
		memcpy (msg->destination_endpoint_key + 12, dep->entity_id.id, 4);
		memcpy (msg->source_endpoint_key, dp->participant.p_guid_prefix.prefix, 12);
		memcpy (msg->source_endpoint_key + 12, sep->entity_id.id, 4);
	}
	CTT_TRACE ('T', msg);
	wp = (Writer_t *) dp->participant.p_builtin_ep [EPB_PARTICIPANT_VOL_SEC_W];

	/* Send participant data. */
	if (pp) {
		DDS_SEQ_INIT (handles);
		h = pp->p_builtin_ep [EPB_PARTICIPANT_VOL_SEC_R]->entity.handle;
		DDS_SEQ_LENGTH (handles) = DDS_SEQ_MAXIMUM (handles) = 1;
		DDS_SEQ_DATA (handles) = &h;
		sys_gettime ((Time_t *) &time);
		error = DDS_DataWriter_write_w_timestamp_directed (wp, msg, 0, &time, &handles);
		if (error)
			fatal_printf ("ctt_send: error sending crypto tokens message!");
	} else {
		sys_gettime ((Time_t *) &time);
		error = DDS_DataWriter_write_w_timestamp (wp, msg, 0, &time);
		if (error)
			fatal_printf ("ctt_send: error sending crypto tokens message!");

	}
	CTT_ASSERT (dp);
}
static void run_writer(pid_t peer)
{
    qeo_factory_t *factory;
    qeocore_type_t *type;
    qeocore_writer_t *writer;
    qeocore_data_t *data, *seqdata;
    byte_array_t array;
    int status, i;

    /* initialize */
    assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT)));
    init_factory(factory);
    assert(NULL != (type = type_register(factory)));
    assert(NULL != (writer = qeocore_writer_open(factory, type, NULL,
                                                 QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE,
                                                 NULL, NULL)));
    log_pid("writer initialized");
    assert(NULL != (data = qeocore_writer_data_new(writer)));
    assert(QEO_OK == qeocore_data_set_member(data, _size_id, &_test_size));
    /* init sequence */
    DDS_SEQ_INIT(array);
    assert(NULL != (DDS_SEQ_DATA(array) = malloc(_test_size * sizeof(char))));
    DDS_SEQ_LENGTH(array) = DDS_SEQ_MAXIMUM(array) = _test_size;
    for (i = 0; i < _test_size; i++) {
        DDS_SEQ_ITEM(array, i) = i & 0xff;
    }
    assert(QEO_OK == qeocore_data_get_member(data, _buf_id, &seqdata));
    assert(QEO_OK == qeocore_data_sequence_set(seqdata, (const qeo_sequence_t *)&array, 0));
    assert(QEO_OK == qeocore_data_set_member(data, _buf_id, &seqdata));
    /* write */
    assert(QEO_OK == qeocore_writer_write(writer, data));
    log_pid("writer wrote data");
    assert(peer == waitpid(peer, &status, 0));
    assert(0 == status);
    log_pid("writer done");
    /* clean up */
    free(DDS_SEQ_DATA(array));
    qeocore_data_free(seqdata);
    qeocore_data_free(data);
    qeocore_writer_close(writer);
    qeocore_type_free(type);
    qeocore_factory_close(factory);
}
Exemple #14
0
static qeo_retcode_t write_generated_data(qeocore_writer_t *writer, int arraysize){
    org_qeo_dynamic_qdm_test_TypeWithStructs_t t = {};
    size_t i, j;
    qeo_retcode_t rc = QEO_EFAIL;
    int stringsize = 10;

    t.mfloat32 = 32;
    t.mstring = "asdfdfasdfqwreqwrqwdfadfadsfadfd";

    DDS_SEQ_INIT(t.msubstruct3);
    org_qeo_dynamic_qdm_test_Substruct3_t ss3[arraysize];
    char strings[arraysize][arraysize+2][stringsize];
    for (i = 0; i < arraysize; ++i) {
        ss3[i].msubfloat = i;
        ss3[i].msubstring = str_random(strings[i][0], stringsize);
        DDS_SEQ_INIT(ss3[i].msubstruct2);
        org_qeo_dynamic_qdm_test_Substruct2_t ss2[arraysize];
        for (j = 0; j < arraysize; ++j) {
            ss2[j].msubshort = j*i;
            ss2[j].msubstring = str_random(strings[i][j+2], stringsize);
        }
        dds_seq_from_array(&ss3[i].msubstruct2, ss2, arraysize);
    }
    dds_seq_from_array(&t.msubstruct3, ss3, arraysize);

    DDS_SEQ_INIT(t.msubstruct1);
    org_qeo_dynamic_qdm_test_Substruct1_t ss1[arraysize];
    for (i = 0; i < arraysize; ++i) {
        ss1[i].msubint32 = i;
        ss1[i].msubstring = str_random(strings[i][1], stringsize);
    }
    dds_seq_from_array(&t.msubstruct1, ss1, arraysize);

    rc = qeocore_writer_write(writer, &t);
    for(i = 0; i < DDS_SEQ_LENGTH(t.msubstruct3); ++i) {
        dds_seq_cleanup(&(DDS_SEQ_ITEM(t.msubstruct3, i).msubstruct2));
    }
    dds_seq_cleanup(&t.msubstruct3);
    dds_seq_cleanup(&t.msubstruct1);

    return rc;
}
Exemple #15
0
static void ctt_trace (char dir, DDS_ParticipantVolatileSecureMessage *m)
{
#ifdef CTT_TRACE_DATA
	DDS_CryptoToken	*cp;
	unsigned	i;
#endif
	char		buf [40];

	if (dir == 'T')
		guid_prefix_str ((GuidPrefix_t *) m->destination_participant_key, buf);
	else
		guid_prefix_str ((GuidPrefix_t *) m->message_identity.source_guid, buf);
	log_printf (SPDP_ID, 0, "CTT: %c [%s].%llu - %s",
		dir,
		buf, 
		m->message_identity.sequence_number,
		m->message_class_id);
	if (strcmp (m->message_class_id, GMCLASSID_SECURITY_PARTICIPANT_CRYPTO_TOKENS)) {
		log_printf (SPDP_ID, 0, " (%s->", entity_id_str ((EntityId_t *) (m->source_endpoint_key + 12), buf));
		log_printf (SPDP_ID, 0, "%s)", entity_id_str ((EntityId_t *) (m->destination_endpoint_key + 12), buf));
	}
	log_printf (SPDP_ID, 0, "\r\n");
#ifdef CTT_TRACE_DATA
/*	if (strcmp (m->message_class_id, GMCLASSID_SECURITY_PARTICIPANT_CRYPTO_TOKENS)) {
		log_printf (SPDP_ID, 0, "       {%s -> ",
			guid_str ((GUID_t *) m->source_endpoint_key, buf));
		log_printf (SPDP_ID, 0, "%s}\r\n",
			guid_str ((GUID_t *) m->destination_endpoint_key, buf));
	} */
	for (i = 0; i < DDS_SEQ_LENGTH (m->message_data); i++) {
		cp = DDS_SEQ_ITEM_PTR (m->message_data, i);
		log_printf (SPDP_ID, 0, "  %u: %s:\r\n", i, cp->class_id);
		if (cp->binary_value1)
			ctt_dump_binary_value (1, cp->binary_value1);
		if (cp->binary_value2)
			ctt_dump_binary_value (2, cp->binary_value2);
	}
#endif
}
Exemple #16
0
static Permissions_t sp_check_rem_perms (const SEC_PERM            *pp,
					 Identity_t                local,
					 Identity_t                remote,
					 DDS_PermissionsToken      *token,
					 DDS_PermissionsCredential *cred)
{
	DDS_SecurityReqData	data;
	DDS_ReturnCode_t	ret;

	ARG_NOT_USED (pp)
	ARG_NOT_USED (token)

	data.handle = remote;
	data.secure = local;
	data.data = DDS_SEQ_DATA (*cred->binary_value1);
	data.length = DDS_SEQ_LENGTH (*cred->binary_value1);
	data.name = cred->class_id;
	ret = sec_access_control_request (DDS_VALIDATE_REMOTE_PERM, &data);
	if (ret)
		return (0);

	return (data.handle);
}
Exemple #17
0
void introspect_enum_type (unsigned                 indent,
		           const DDS_DynamicType    t,
		           const DDS_TypeDescriptor *dp)
{
	unsigned		i, j, n;
	DDS_ReturnCode_t	ret;
	DDS_MemberDescriptor	md;
	DDS_AnnotationDescriptor ad;
	DDS_DynamicTypeMembersById members;
	MapEntry_DDS_MemberId_DDS_DynamicTypeMember *p;

	dbg_printf ("enum %s {\r\n", dp->name);
	indent++;
	DDS_MemberDescriptor__init (&md);
	ret = DDS_DynamicType_get_all_members (t, &members);
	fail_unless (ret == DDS_RETCODE_OK);

	DDS_SEQ_FOREACH_ENTRY (members, i, p) {
		INDENT (indent, j);
		if ((n = DDS_DynamicTypeMember_get_annotation_count (p->value)) != 0) {
			DDS_AnnotationDescriptor__init (&ad);
			for (i = 0; i < n; i++) {
				ret = DDS_DynamicType_get_annotation (t, &ad, i);
				fail_unless (ret == DDS_RETCODE_OK);

				introspect_annotation (&ad, 0);
				DDS_AnnotationDescriptor__clear (&ad);
			}
		}
		ret = DDS_DynamicTypeMember_get_descriptor (p->value, &md);
		fail_unless (ret == DDS_RETCODE_OK);

		dbg_printf ("%s", md.name);
		if (i + 1 < DDS_SEQ_LENGTH (members))
			dbg_printf (",");
		dbg_printf ("\r\n");
	}
Exemple #18
0
static void test_qos (int enabled)
{
	DDS_DomainParticipantFactoryQos	qos;
	DDS_DomainParticipant		p;
	DDS_Publisher			pub;
	DDS_Subscriber			sub;
	DDS_DataWriter			dw;
	DDS_DataReader			dr;
	DDS_Topic			t;
	DDS_TopicDescription		td;
	DDS_DataReaderQos		rq, refrq;
	DDS_ReturnCode_t		r;
	static unsigned char		data [] = { 0x77, 0x88, 0xaa, 0xbb, 0xcc, 0xdd };
	unsigned char			d2 [sizeof (data) + 1];
	unsigned			n;
	int				err;

	v_printf (" - Set factory QoS to %sabled.\r\n", (enabled) ? "en" : "dis");
	r = DDS_DomainParticipantFactory_get_qos (&qos);
	fail_unless (r == DDS_RETCODE_OK);
	qos.entity_factory.autoenable_created_entities = enabled;
	r = DDS_DomainParticipantFactory_set_qos (&qos);
	fail_unless (r == DDS_RETCODE_OK);

	p = DDS_DomainParticipantFactory_create_participant (0, DDS_PARTICIPANT_QOS_DEFAULT, NULL, 0);
	fail_unless (p != NULL);
	r = register_HelloWorldData_type (p);
	fail_unless (r == DDS_RETCODE_OK);

	t = DDS_DomainParticipant_create_topic (p, "HelloWorld", TYPE_NAME, DDS_TOPIC_QOS_DEFAULT, NULL, 0);
	fail_unless (t != NULL);

	td = DDS_DomainParticipant_lookup_topicdescription (p, "HelloWorld");
	fail_unless (td != NULL);

	sub = DDS_DomainParticipant_create_subscriber (p, NULL, NULL, 0);
	fail_unless (sub != NULL);

	DDS_DataReaderQos__init (&refrq);
	err = dds_seq_from_array (&refrq.user_data, data, sizeof (data));
	fail_unless (err == 0);

	v_printf (" - Create datareader with specific QoS parameters.\r\n");
	dr = DDS_Subscriber_create_datareader (sub, td, &refrq, NULL, 0);
	fail_unless (dr != NULL);

	memset (&rq, 0, sizeof (rq));
	r = DDS_DataReader_get_qos (dr, &rq);
	n = dds_seq_to_array (&rq.user_data, d2, sizeof (d2));
	fail_unless (r == DDS_RETCODE_OK &&
		     DDS_SEQ_LENGTH (refrq.user_data.value) == sizeof (data));
	n = dds_seq_to_array (&rq.user_data, d2, sizeof (d2));
	fail_unless (n == sizeof (data) && !memcmp (data, d2, sizeof (data)));
	DDS_DataReaderQos__clear (&rq);
	r = DDS_Subscriber_delete_datareader (sub, dr);
	fail_unless (r == DDS_RETCODE_OK);

	v_printf (" - Create datareader with default QoS parameters.\r\n");
	dr = DDS_Subscriber_create_datareader (sub, td, DDS_DATAREADER_QOS_DEFAULT, NULL, 0);
	fail_unless (dr != NULL);
	pub = DDS_DomainParticipant_create_publisher (p, DDS_PUBLISHER_QOS_DEFAULT, NULL, 0);
	fail_unless (sub != NULL);
	dw = DDS_Publisher_create_datawriter (pub, t, DDS_DATAWRITER_QOS_DEFAULT, NULL, 0);
	fail_unless (dw != NULL);

	v_printf (" - Update datareader QoS parameters.\r\n");
	r = DDS_DataReader_get_qos (dr, &rq);
	fail_unless (r == DDS_RETCODE_OK);
	DDS_DataReaderQos__clear (&refrq);
	fail_unless (r == DDS_RETCODE_OK && !memcmp (&rq, &refrq, sizeof (refrq)));
	err = dds_seq_from_array (&refrq.user_data, data, sizeof (data));
	fail_unless (err == 0);

	r = DDS_DataReader_set_qos (dr, &refrq);
	fail_unless (r == DDS_RETCODE_OK);

	delay ();
	r = DDS_DataReader_get_qos (dr, &rq);
	fail_unless (r == DDS_RETCODE_OK &&
		     DDS_SEQ_LENGTH (rq.user_data.value) == sizeof (data));
	n = dds_seq_to_array (&rq.user_data, d2, sizeof (d2));
	fail_unless (n == sizeof (data) && !memcmp (data, d2, sizeof (data)));

	DDS_DataReaderQos__clear (&refrq);
	DDS_DataReaderQos__clear (&rq);

	delay ();
	if (!enabled) {
		v_printf (" - Enable all entities.\r\n");
		r = DDS_DomainParticipant_enable (p);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_Topic_enable (t);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_Publisher_enable (pub);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_Subscriber_enable (sub);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_DataWriter_enable (dw);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_DataReader_enable (dr);
		fail_unless (r == DDS_RETCODE_OK);
		sleep (1);
	}
	r = DDS_Publisher_delete_datawriter (pub, dw);
	fail_unless (r == DDS_RETCODE_OK);
	r = DDS_Subscriber_delete_datareader (sub, dr);
	fail_unless (r == DDS_RETCODE_OK);
	r = DDS_DomainParticipant_delete_publisher (p, pub);
	fail_unless (r == DDS_RETCODE_OK);
	r = DDS_DomainParticipant_delete_subscriber (p, sub);
	fail_unless (r == DDS_RETCODE_OK);
	r = DDS_DomainParticipant_delete_topic (p, t);
	fail_unless (r == DDS_RETCODE_OK);

	unregister_HelloWorldData_type (p);
	r = DDS_DomainParticipantFactory_delete_participant (p);
	fail_unless (r == DDS_RETCODE_OK);
}
Exemple #19
0
void test_dyn_array1 (void)
{
	DDS_DynamicTypeSupport ts;
	DDS_DynamicTypeBuilder sb, abc20;
	DDS_TypeDescriptor *desc;
	DDS_MemberDescriptor *md;
	DDS_DynamicType s, ac20;
	DDS_BoundSeq bounds;
	DDS_DynamicData dd, dda, dd2;
	DDS_ReturnCode_t rc;
	unsigned i;

	v_printf ("test_dyn_array1 - ");

	/* 1. Create the type. */
	desc = DDS_TypeDescriptor__alloc ();
	fail_unless (desc != NULL);

	desc->kind = DDS_STRUCTURE_TYPE;
	desc->name = "dstruct1";
	sb = DDS_DynamicTypeBuilderFactory_create_type (desc);
	fail_unless (sb != NULL);

	md = DDS_MemberDescriptor__alloc ();
	fail_unless (md != NULL);

	DDS_SEQ_INIT (bounds);
	dds_seq_require (&bounds, 1);
	DDS_SEQ_LENGTH (bounds) = 1;
	DDS_SEQ_ITEM (bounds, 0) = 20;

	abc20 = DDS_DynamicTypeBuilderFactory_create_array_type (
		DDS_DynamicTypeBuilderFactory_get_primitive_type (DDS_CHAR_8_TYPE),
		&bounds);
	fail_unless (abc20 != NULL);

	dds_seq_cleanup (&bounds);

	ac20 = DDS_DynamicTypeBuilder_build (abc20);
	fail_unless (ac20 != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (abc20);

	md->name = "char_a";
	md->index = md->id = 0;
	md->type = ac20;

	rc = DDS_DynamicTypeBuilder_add_member (sb, md);
	fail_unless (rc == DDS_RETCODE_OK);

	s = DDS_DynamicTypeBuilder_build (sb);
	fail_unless (s != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (sb);
	ts = DDS_DynamicTypeSupport_create_type_support (s);
	fail_unless (ts != NULL);

	DDS_TypeDescriptor__free (desc);
	DDS_MemberDescriptor__free (md);

	/* 2. Create a Dynamic Data item for this type. */
	dd = DDS_DynamicDataFactory_create_data (s);
	fail_unless (dd != NULL);

	dda = DDS_DynamicDataFactory_create_data (ac20);
	fail_unless (dda != NULL);

	for (i = 0; i < 20; i++) {
		SET_FIELD (dda, i, char8, i + '0');
	}
	SET_FIELD (dd, 0, complex, dda);

	marshallDynamic (dd, &dd2, ts);

	DDS_DynamicDataFactory_delete_data (dd);
	DDS_DynamicDataFactory_delete_data (dda);

	DDS_DynamicTypeBuilderFactory_delete_type (ac20);
	DDS_DynamicTypeBuilderFactory_delete_type (s);
	DDS_DynamicTypeSupport_delete_type_support (ts);
	v_printf ("success!\r\n");
}
Exemple #20
0
void test_dyn_array2 (void)
{
	DDS_DynamicTypeSupport ts;
	DDS_DynamicTypeBuilder sb1, sb1a, abi64, abs1a;
	DDS_DynamicType s1, s1a, ai64, as1a;
	DDS_TypeDescriptor *desc;
	DDS_MemberDescriptor *md;
	DDS_DynamicData dd, dds, dda, ddas, dd2;
	DDS_ReturnCode_t rc;
	DDS_BoundSeq bounds;
	unsigned i, j;

	v_printf ("test_dyn_array2 - ");

	/* 1. Create the type. */
	desc = DDS_TypeDescriptor__alloc ();
	fail_unless (desc != NULL);

	desc->kind = DDS_STRUCTURE_TYPE;
	desc->name = "dstruct2a";
	sb1a = DDS_DynamicTypeBuilderFactory_create_type (desc);
	fail_unless (sb1a != NULL);

	md = DDS_MemberDescriptor__alloc ();
	fail_unless (md != NULL);

	DDS_SEQ_INIT (bounds);
	dds_seq_require (&bounds, 1);
	DDS_SEQ_LENGTH (bounds) = 1;
	DDS_SEQ_ITEM (bounds, 0) = 5;

	abi64 = DDS_DynamicTypeBuilderFactory_create_array_type (
		DDS_DynamicTypeBuilderFactory_get_primitive_type (DDS_INT_64_TYPE),
		&bounds);
	fail_unless (abi64 != NULL);

	ai64 = DDS_DynamicTypeBuilder_build (abi64);
	fail_unless (ai64 != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (abi64);

	md->name = "i64";
	md->index = md->id = 0;
	md->type = ai64;

	rc = DDS_DynamicTypeBuilder_add_member (sb1a, md);
	fail_unless (rc == DDS_RETCODE_OK);

	ADD_FIELD (sb1a, md, "ch", 1, 1, DDS_CHAR_8_TYPE);

	s1a = DDS_DynamicTypeBuilder_build (sb1a);
	fail_unless (s1a != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (sb1a);

	DDS_SEQ_ITEM (bounds, 0) = 7;
	abs1a = DDS_DynamicTypeBuilderFactory_create_array_type (s1a, &bounds);
	fail_unless (abs1a != NULL);

	dds_seq_cleanup (&bounds);

	as1a = DDS_DynamicTypeBuilder_build (abs1a);
	fail_unless (as1a != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (abs1a);
	desc->kind = DDS_STRUCTURE_TYPE;
	desc->name = "dstruct2";
	sb1 = DDS_DynamicTypeBuilderFactory_create_type (desc);
	fail_unless (sb1 != NULL);

	ADD_FIELD (sb1, md, "c", 0, 0, DDS_CHAR_8_TYPE);

	md->name = "str2";
	md->index = md->id = 1;
	md->type = as1a;
	rc = DDS_DynamicTypeBuilder_add_member (sb1, md);
	fail_unless (rc == DDS_RETCODE_OK);

	ADD_FIELD (sb1, md, "u16", 2, 2, DDS_UINT_16_TYPE);

	s1 = DDS_DynamicTypeBuilder_build (sb1);
	fail_unless (s1 != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (sb1);
	ts = DDS_DynamicTypeSupport_create_type_support (s1);
	fail_unless (ts != NULL);

	DDS_TypeDescriptor__free (desc);
	DDS_MemberDescriptor__free (md);

	/* 2. Create a Dynamic Data item for this type. */
	dd = DDS_DynamicDataFactory_create_data (s1);
	fail_unless (dd != NULL);

	ddas = DDS_DynamicDataFactory_create_data (as1a);
	fail_unless (ddas != NULL);

	SET_FIELD (dd, 0, char8, 'A');
	for (i = 0; i < 7; i++) {
		dds = DDS_DynamicDataFactory_create_data (s1a);
		fail_unless (dds != NULL);

		dda = DDS_DynamicDataFactory_create_data (ai64);
		fail_unless (dda != NULL);

		for (j = 0; j < 5; j++) {
			SET_FIELD (dda, j, int64, ((i + 6) * j) << i);
		}
		SET_FIELD (dds, 0, complex, dda);
		DDS_DynamicDataFactory_delete_data (dda);

		SET_FIELD (dds, 1, char8, i + 0x30);

		SET_FIELD (ddas, i, complex, dds);
		DDS_DynamicDataFactory_delete_data (dds);
	}
	SET_FIELD (dd, 1, complex, ddas);
	DDS_DynamicDataFactory_delete_data (ddas);

	SET_FIELD (dd, 2, uint16, 1366);

	marshallDynamic (dd, &dd2, ts);

	DDS_DynamicDataFactory_delete_data (dd);
	DDS_DynamicTypeBuilderFactory_delete_type (s1);
	DDS_DynamicTypeBuilderFactory_delete_type (as1a);
	DDS_DynamicTypeBuilderFactory_delete_type (s1a);
	DDS_DynamicTypeBuilderFactory_delete_type (ai64);
	DDS_DynamicTypeSupport_delete_type_support (ts);
	v_printf ("success!\r\n");
}
Exemple #21
0
int dcps_get_local_publication_data (DDS_PublicationBuiltinTopicData *dp,
				     Writer_t                        *wp)
{
	size_t		size, psize;
	char		*xp;
	UniQos_t	*uqp;

	size = str_len (wp->w_topic->name);
	size += str_len (wp->w_topic->type->type_name);
	if (wp->w_qos->qos.user_data) {
		ROUND_LEN (size);
		size += str_len (wp->w_qos->qos.user_data);
	}
	if (wp->w_publisher->qos.partition) {
		ROUND_LEN (size);
		psize = partition_size (wp->w_publisher->qos.partition);
		size += psize;
	}
	if (wp->w_topic->qos->qos.topic_data) {
		ROUND_LEN (size);
		size += str_len (wp->w_topic->qos->qos.topic_data);
	}
	if (wp->w_publisher->qos.group_data) {
		ROUND_LEN (size);
		size += str_len (wp->w_publisher->qos.group_data);
	}
	xp = xmalloc (size);
	if (!xp)
		return (DDS_RETCODE_OUT_OF_RESOURCES);

	dp->topic_name = xp;
	dp->key.value [0] = wp->w_publisher->domain->participant.p_guid_prefix.w [0];
	dp->key.value [1] = wp->w_publisher->domain->participant.p_guid_prefix.w [1];
	dp->key.value [2] = wp->w_entity_id.w;
	memcpy (&dp->participant_key,
		&wp->w_publisher->domain->participant.p_guid_prefix,
		sizeof (DDS_BuiltinTopicKey_t));
	memcpy (xp, str_ptr (wp->w_topic->name),
						str_len (wp->w_topic->name));
	xp += str_len (wp->w_topic->name);
	dp->type_name = xp;
	memcpy (xp, str_ptr (wp->w_topic->type->type_name),
				     str_len (wp->w_topic->type->type_name));
	xp += str_len (wp->w_topic->type->type_name);
	uqp = &wp->w_qos->qos;
	dp->durability.kind = uqp->durability_kind;
#ifdef DURABILITY_SERVICE
	dp->durability_service.service_cleanup_delay = uqp->ds_cleanup_delay;
	dp->durability_service.history_kind = uqp->ds_history_kind;
	dp->durability_service.history_depth = uqp->ds_history_depth;
	dp->durability_service.max_samples = uqp->ds_limits.max_samples;
	dp->durability_service.max_instances = uqp->ds_limits.max_instances;
	dp->durability_service.max_samples_per_instance = uqp->ds_limits.max_samples_per_instance;
#else
	dp->durability_service = qos_def_writer_qos.durability_service;
#endif
	dp->deadline = uqp->deadline;
	dp->latency_budget = uqp->latency_budget;
	dp->liveliness.kind = uqp->liveliness_kind;
	dp->liveliness.lease_duration = uqp->liveliness_lease_duration;
	dp->reliability.kind = uqp->reliability_kind;
	dp->reliability.max_blocking_time = uqp->reliability_max_blocking_time;
	dp->lifespan = uqp->lifespan;
	if (uqp->user_data)
		ROUND_PTR (xp);
	oseq_set (&dp->user_data.value, uqp->user_data, (unsigned char *) xp);
	xp += DDS_SEQ_LENGTH (dp->user_data.value);
	dp->ownership.kind = uqp->ownership_kind;
	dp->ownership_strength = uqp->ownership_strength;
	dp->destination_order.kind = uqp->destination_order_kind;
	dp->presentation.access_scope = uqp->presentation_access_scope;
	dp->presentation.coherent_access = uqp->presentation_coherent_access;
	dp->presentation.ordered_access = uqp->presentation_ordered_access;
	if (uqp->partition)
		ROUND_PTR (xp);
	xp += partition_set (&dp->partition.name, wp->w_publisher->qos.partition, (unsigned char *) xp);
	if (wp->w_topic->qos->qos.topic_data)
		ROUND_PTR (xp);
	oseq_set (&dp->topic_data.value, wp->w_topic->qos->qos.topic_data, (unsigned char *) xp);
	xp += DDS_SEQ_LENGTH (dp->topic_data.value);
	if (wp->w_publisher->qos.group_data)
		ROUND_PTR (xp);
	oseq_set (&dp->group_data.value, wp->w_publisher->qos.group_data, (unsigned char *) xp);
	return (DDS_RETCODE_OK);
}
static json_t *array_data_to_json(const json_t *typedesc, qeocore_data_t *data)
{
    json_t          *json_data  = NULL;
    qeo_sequence_t  seq         = { 0 };

    json_t *type = json_object_get(typedesc, KEY_QEO_TYPE_CODE); // Mandatory

    if ((NULL == type) || (!json_is_integer(type)) ||
        (QEO_OK != qeocore_data_sequence_get(data, &seq, 0, QEOCORE_SIZE_UNLIMITED))) {
        return json_data;
    }
    json_data = json_array();
    qeocore_typecode_t qeoTypeCode = (qeocore_typecode_t) json_integer_value(type);

    int i;
    int numOfElem = DDS_SEQ_LENGTH(seq);
    for (i = 0; i < numOfElem; ++i) {
        switch (qeoTypeCode) {
            case QEOCORE_TYPECODE_BOOLEAN:
            {
                qeo_boolean_t bool_value = ((qeo_boolean_t *)DDS_SEQ_DATA(seq))[i];
                json_array_append_new(json_data, bool_value ? (json_true()) : (json_false()));
            }
            break;

            case QEOCORE_TYPECODE_INT8:
            {
                int8_t int_value = ((int8_t *)DDS_SEQ_DATA(seq))[i];
                json_array_append_new(json_data, json_integer((json_int_t)int_value));
            }
            break;

            case QEOCORE_TYPECODE_INT16:
            {
                int8_t int_value = ((int16_t *)DDS_SEQ_DATA(seq))[i];
                json_array_append_new(json_data, json_integer((json_int_t)int_value));
            }
            break;

            case QEOCORE_TYPECODE_INT32:
            {
                int8_t int_value = ((int32_t *)DDS_SEQ_DATA(seq))[i];
                json_array_append_new(json_data, json_integer((json_int_t)int_value));
            }
            break;

            case QEOCORE_TYPECODE_INT64:
            {
                int64_t int_value   = ((int64_t *)DDS_SEQ_DATA(seq))[i];
                char    *char_value = NULL;
                if (-1 != asprintf(&char_value, "%" PRId64 "", int_value)) {
                    json_array_append_new(json_data, json_string(char_value));
                    free(char_value);
                }
            }
            break;

            case QEOCORE_TYPECODE_STRING:
            {
                char *char_value = ((char **)DDS_SEQ_DATA(seq))[i];
                json_array_append_new(json_data, json_string(char_value));
            }
            break;

            case QEOCORE_TYPECODE_STRUCT:
            {
                json_t *item = json_object_get(typedesc, KEY_ITEM);
                if ((NULL != item) && json_is_object(item)) {
                    qeocore_data_t  *object_value = ((qeocore_data_t **)DDS_SEQ_DATA(seq))[i];
                    json_t          *json_element = object_data_to_json(item, object_value);
                    if (NULL != json_element) {
                        json_array_append_new(json_data, json_element);
                    }
                    else {
                        json_decref(json_data);
                        json_data = NULL;
                    }
                }
                else {
                    json_decref(json_data);
                    json_data = NULL;
                }
            }
            break;

            case QEOCORE_TYPECODE_SEQUENCE:
            {
                json_t *items = json_object_get(typedesc, KEY_ITEMS);
                if ((NULL != items) && json_is_object(items)) {
                    qeocore_data_t  *element_value  = ((qeocore_data_t **)DDS_SEQ_DATA(seq))[i];
                    json_t          *json_element   = array_data_to_json(items, element_value);
                    if (NULL != json_element) {
                        json_array_append_new(json_data, json_element);
                    }
                    else {
                        json_decref(json_data);
                        json_data = NULL;
                    }
                }
                else {
                    json_decref(json_data);
                    json_data = NULL;
                }
            }
            break;
            case QEOCORE_TYPECODE_ENUM:
            {
                qeo_enum_value_t enum_value = ((qeo_enum_value_t *)DDS_SEQ_DATA(seq))[i];
                if (is_valid_enum_value(typedesc, enum_value) == false){
                    qeo_log_e("Not a valid enum value");
                    break;
                }
                json_t *json_enum = json_integer(enum_value);
                json_array_append_new(json_data, json_enum);
            }
            break;
            case QEOCORE_TYPECODE_FLOAT32:
            {
                float float_value = ((float *)DDS_SEQ_DATA(seq))[i];
                json_array_append_new(json_data, json_real(float_value));
            }
            break;

        }

        if (NULL == json_data) {
            break;
        }
    }
    qeocore_data_sequence_free(data, &seq);
    return json_data;
}
Exemple #23
0
DDS_ContentFilteredTopic DDS_DomainParticipant_create_contentfilteredtopic (
					DDS_DomainParticipant dp,
					const char            *topic_name,
					DDS_Topic             related_topic,
					const char            *filter_expr,
					DDS_StringSeq         *expr_pars)
{
	Topic_t			*tp;
	BCProgram		bc_program;
	FilteredTopic_t		*ftp;
	DDS_ReturnCode_t	ret;
	int			error;
	static const char	ddssql [] = "DDSSQL";

	ctrc_begind (DCPS_ID, DCPS_DP_C_FTOP, &dp, sizeof (dp));
	ctrc_contd (topic_name, strlen (topic_name) + 1);
	ctrc_contd (related_topic, sizeof (DDS_Topic));
	ctrc_contd (filter_expr, strlen (filter_expr) + 1);
	ctrc_contd (&expr_pars, sizeof (expr_pars));
	ctrc_endd ();

	prof_start (dcps_create_ftopic);

	/* Check some required parameters. */
	if (!filter_expr)
		return (NULL);

	/* Get Domain Participant. */
	if (!domain_ptr (dp, 1, NULL)) {
		log_printf (DCPS_ID, 0, "create_topic(%s): domain doesn't exist!\r\n", topic_name);
		return (NULL);
	}

	/* Get Original Topic descriptor. */
	tp = topic_ptr (related_topic, 1, &ret);
	if (!tp || tp->domain != dp) {
		lock_release (dp->lock);
		return (NULL);
	}

#ifdef DDS_SECURITY

	/* Check if security policy allows this topic. */
	if (check_create_topic (dp->participant.p_permissions, topic_name, NULL)) {
		log_printf (DCPS_ID, 0, "create_topic(%s): topic create not allowed!\r\n", topic_name);
		lock_release (dp->lock);
		return (NULL);
	}
#endif

	/* Check filter validity. */
	ret = sql_parse_filter (tp->type->type_support, filter_expr, &bc_program);
	if (ret)
		goto free_locks;

	/* Check required # of parameters. */
	if (expr_pars && DDS_SEQ_LENGTH (*expr_pars) < bc_program.npars)
		goto free_program;

	/* Create the content-filtered topic. */
	ftp = filtered_topic_create (dp, tp, topic_name);
	if (!ftp)
		goto free_program;

	/* Setup filtered topic data. */
	ftp->data.filter.expression = str_new_cstr (filter_expr);
	if (!ftp->data.filter.expression)
		goto free_filtered_topic;

	if (expr_pars) {
		ftp->data.filter.expression_pars = dcps_new_str_pars (expr_pars, &error);
		if (!ftp->data.filter.expression_pars && error)
			goto pars_failed;
	}
	else
		ftp->data.filter.expression_pars = NULL;

	ftp->data.filter.name = str_ref (ftp->topic.name);
	ftp->data.filter.related_name = str_ref (ftp->related->name);
	ftp->data.filter.class_name = str_new_cstr (ddssql);
	if (!ftp->data.filter.name || !ftp->data.filter.related_name || !ftp->data.filter.class_name)
		goto pars_failed;

	ftp->data.program = bc_program;

	bc_cache_init (&ftp->data.cache);

	lock_release (tp->lock);
	lock_release (dp->lock);

	prof_stop (dcps_create_ftopic, 1);
	return (ftp);

    pars_failed:
	lock_release (tp->lock);
	lock_release (dp->lock);
	DDS_DomainParticipant_delete_contentfilteredtopic (dp, ftp);
	return (NULL);

    free_filtered_topic:
    	filtered_topic_delete (ftp);

    free_program:
	xfree (bc_program.buffer);

    free_locks:
	lock_release (tp->lock);
	lock_release (dp->lock);
	return (NULL);
}
Exemple #24
0
void dr_listener_data_available (DDS_DataReaderListener *list,
				 DDS_DataReader         dr)
{
	MsgData_t *data;
	types_t *datax;
	static DDS_DataSeq	rx_sample = DDS_SEQ_INITIALIZER (void *);
	static DDS_SampleInfoSeq rx_info = DDS_SEQ_INITIALIZER (DDS_SampleInfo *);
	DDS_ReturnCode_t error;
	DDS_SampleInfo *info;

	DDS_DataReader_return_loan (dr, &rx_sample, &rx_info);

	error = DDS_DataReader_take_next_instance(dr, &rx_sample, &rx_info, 1, 
						  DDS_HANDLE_NIL, 
						  DDS_NOT_READ_SAMPLE_STATE, DDS_ANY_VIEW_STATE,
						  DDS_ANY_INSTANCE_STATE);

	printf ("dds-interop: Take next instance.\r\n");
	
	if (error)
		printf ("Error taking next instance\r\n");


	/* === print sample === */
  
	if (DDS_SEQ_LENGTH (rx_info)) {
		data = DDS_SEQ_ITEM (rx_sample, 0);
		datax = DDS_SEQ_ITEM (rx_sample, 0);
		info = DDS_SEQ_ITEM (rx_info, 0);
		if (info->instance_state == DDS_ALIVE_INSTANCE_STATE) {
			if (tsm_type == 0)
				printf ("DDS-R: [%2u] ALIVE - %2u :%6llu - %s\r\n", 
					info->instance_handle,
					data->key,
					(unsigned long long) data->counter,
					data->message);
			else
				printf ("DDS-R: [%2u] ALIVE - %2u -  %s\r\n", 
					info->instance_handle, datax->i8, datax->string);
			if (test == 3)
				sem_post (&_sync);
		}
		else if (info->instance_state == DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE) {
			if (tsm_type == 0)
				printf ("DDS-R: The sample %s with key (%d) has been disposed.\r\n", data->message,  data->key);
			else 
				printf ("DDS-R: The sample has been disposed.\r\n", datax->string);
			if (test == 3)
				sem_post (&_sync);
		}
		else if (info->instance_state == DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) {
			printf ("DDS-R: There are no more writers.\r\n");
			if (test == 3)
				sem_post (&_sync);
		}
		else
			printf ("DDS-R: Unknown state.\r\n");
	}
	
	DDS_DataReader_return_loan (dr, &rx_sample, &rx_info);

}
Exemple #25
0
int dcps_get_local_subscription_data (DDS_SubscriptionBuiltinTopicData *dp,
				      Reader_t                         *rp)
{
	size_t		size, psize;
	char		*xp;
	UniQos_t	*uqp;

	size = str_len (rp->r_topic->name);
	size += str_len (rp->r_topic->type->type_name);
	if (rp->r_qos->qos.user_data) {
		ROUND_LEN (size);
		size += str_len (rp->r_qos->qos.user_data);
	}
	if (rp->r_subscriber->qos.partition) {
		ROUND_LEN (size);
		psize = partition_size (rp->r_subscriber->qos.partition);
		size += psize;
	}
	if (rp->r_topic->qos->qos.topic_data) {
		ROUND_LEN (size);
		size += str_len (rp->r_topic->qos->qos.topic_data);
	}
	if (rp->r_subscriber->qos.group_data) {
		ROUND_LEN (size);
		size += str_len (rp->r_subscriber->qos.group_data);
	}
	xp = xmalloc (size);
	if (!xp)
		return (DDS_RETCODE_OUT_OF_RESOURCES);

	dp->topic_name = xp;
	dp->key.value [0] = rp->r_subscriber->domain->participant.p_guid_prefix.w [0];
	dp->key.value [1] = rp->r_subscriber->domain->participant.p_guid_prefix.w [1];
	dp->key.value [2] = rp->r_entity_id.w;
	memcpy (&dp->participant_key,
		&rp->r_subscriber->domain->participant.p_guid_prefix,
		sizeof (DDS_BuiltinTopicKey_t));
	memcpy (xp, str_ptr (rp->r_topic->name),
				str_len (rp->r_topic->name));
	xp += str_len (rp->r_topic->name);
	dp->type_name = xp;
	memcpy (xp, str_ptr (rp->r_topic->type->type_name),
				str_len (rp->r_topic->type->type_name));
	xp += str_len (rp->r_topic->type->type_name);
	uqp = &rp->r_qos->qos;
	dp->durability.kind = uqp->durability_kind;
	dp->deadline = uqp->deadline;
	dp->latency_budget = uqp->latency_budget;
	dp->liveliness.kind = uqp->liveliness_kind;
	dp->liveliness.lease_duration = uqp->liveliness_lease_duration;
	dp->reliability.kind = uqp->reliability_kind;
	dp->reliability.max_blocking_time = uqp->reliability_max_blocking_time;
	dp->ownership.kind = uqp->ownership_kind;
	dp->destination_order.kind = uqp->destination_order_kind;
	if (uqp->user_data)
		ROUND_PTR (xp);
	oseq_set (&dp->user_data.value, uqp->user_data, (unsigned char *) xp);
	xp += DDS_SEQ_LENGTH (dp->user_data.value);
	dp->time_based_filter = rp->r_time_based_filter;
	dp->presentation.access_scope = uqp->presentation_access_scope;
	dp->presentation.coherent_access = uqp->presentation_coherent_access;
	dp->presentation.ordered_access = uqp->presentation_ordered_access;
	if (uqp->partition)
		ROUND_PTR (xp);
	xp += partition_set (&dp->partition.name, rp->r_subscriber->qos.partition, (unsigned char *) xp);
	if (rp->r_topic->qos->qos.topic_data)
		ROUND_PTR (xp);
	oseq_set (&dp->topic_data.value, rp->r_topic->qos->qos.topic_data, (unsigned char *) xp);
	xp += DDS_SEQ_LENGTH (dp->topic_data.value);
	if (rp->r_subscriber->qos.group_data)
		ROUND_PTR (xp);
	oseq_set (&dp->group_data.value, rp->r_subscriber->qos.group_data, (unsigned char *) xp);
	return (DDS_RETCODE_OK);
}
Exemple #26
0
static void ctt_dump_binary_value (unsigned i, DDS_OctetSeq *sp)
{
	log_printf (SPDP_ID, 0, "   BV%u:\r\n", i);
	log_print_region (SPDP_ID, 0, DDS_SEQ_DATA (*sp), DDS_SEQ_LENGTH (*sp), 1, 1);
}
Exemple #27
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);
}
Exemple #28
0
static void test_qos (int enabled)
{
	DDS_DomainParticipantFactoryQos	qos;
	DDS_DomainParticipant		p;
	DDS_Publisher			pub;
	DDS_Subscriber			sub;
	DDS_DataWriter			dw;
	DDS_DataReader			dr;
	DDS_Topic			t;
	DDS_TopicDescription		td;
	DDS_SubscriberQos		psq, refsq;
	DDS_ReturnCode_t		r;
	static char			*buf [] = { "Hello", "World" };
	static unsigned char		data [] = { 0x77, 0x88, 0xaa, 0xbb, 0xcc };
	unsigned char			d2 [sizeof (data) + 1];
	unsigned			n;
	size_t				i;
	int				err;

	v_printf (" - Set factory QoS to %sabled.\r\n", (enabled) ? "en" : "dis");
	r = DDS_DomainParticipantFactory_get_qos (&qos);
	fail_unless (r == DDS_RETCODE_OK);
	qos.entity_factory.autoenable_created_entities = enabled;
	r = DDS_DomainParticipantFactory_set_qos (&qos);
	fail_unless (r == DDS_RETCODE_OK);

	p = DDS_DomainParticipantFactory_create_participant (1, DDS_PARTICIPANT_QOS_DEFAULT, NULL, 0);
	fail_unless (p != NULL);
	r = register_HelloWorldData_type (p);
	fail_unless (r == DDS_RETCODE_OK);

	DDS_SubscriberQos__init (&refsq);
	for (i = 0; (size_t) i < sizeof (buf) / sizeof (char *); i++) {
		err = dds_seq_append (&refsq.partition.name, &buf [i]);
		fail_unless (err == 0);
	}
	err = dds_seq_from_array (&refsq.group_data, data, sizeof (data));
	fail_unless (err == 0);
	v_printf (" - Create subscriber with specific QoS parameters.\r\n");
	sub = DDS_DomainParticipant_create_subscriber (p, &refsq, NULL, 0);
	fail_unless (sub != NULL);
	memset (&psq, 0, sizeof (psq));
	r = DDS_Subscriber_get_qos (sub, &psq);
	fail_unless (r == DDS_RETCODE_OK &&
	             DDS_SEQ_LENGTH (refsq.partition.name) == DDS_SEQ_LENGTH (psq.partition.name) &&
		     DDS_SEQ_LENGTH (refsq.group_data.value) == sizeof (data));
	DDS_SEQ_FOREACH (refsq.partition.name, i)
		fail_unless (!strcmp (DDS_SEQ_ITEM (psq.partition.name, i),
				      DDS_SEQ_ITEM (refsq.partition.name, i)));
	n = dds_seq_to_array (&psq.group_data, d2, sizeof (d2));
	fail_unless (n == sizeof (data) && !memcmp (data, d2, sizeof (data)));
	DDS_SubscriberQos__clear (&psq);
	r = DDS_DomainParticipant_delete_subscriber (p, sub);
	fail_unless (r == DDS_RETCODE_OK);

	v_printf (" - Create topic/publisher/writer/subscriber/reader entities.\r\n");
	t = DDS_DomainParticipant_create_topic (p, "HelloWorld", TYPE_NAME, DDS_TOPIC_QOS_DEFAULT, NULL, 0);
	fail_unless (t != NULL);
	td = DDS_DomainParticipant_lookup_topicdescription (p, "HelloWorld");
	fail_unless (td != NULL);
	pub = DDS_DomainParticipant_create_publisher (p, DDS_PUBLISHER_QOS_DEFAULT, NULL, 0);
	fail_unless (pub != NULL);
	dw = DDS_Publisher_create_datawriter (pub, t, DDS_DATAWRITER_QOS_DEFAULT, NULL, 0);
	fail_unless (dw != NULL);
	sub = DDS_DomainParticipant_create_subscriber (p, DDS_SUBSCRIBER_QOS_DEFAULT, NULL, 0);
	fail_unless (sub != NULL);
	dr = DDS_Subscriber_create_datareader (sub, td, DDS_DATAREADER_QOS_DEFAULT, NULL, 0);
	fail_unless (dr != NULL);

	v_printf (" - Update subscriber QoS.\r\n");
	r = DDS_Subscriber_get_qos (sub, &psq);
	fail_unless (r == DDS_RETCODE_OK);
	DDS_SubscriberQos__clear (&refsq);
	fail_unless (r == DDS_RETCODE_OK && !memcmp (&psq, &refsq, sizeof (refsq)));
	for (i = 0; (size_t) i < sizeof (buf) / sizeof (char *); i++) {
		err = dds_seq_append (&refsq.partition.name, &buf [i]);
		fail_unless (err == 0);
	}
	err = dds_seq_from_array (&refsq.group_data, data, sizeof (data));
	fail_unless (err == 0);

	r = DDS_Subscriber_set_qos (sub, &refsq);
	fail_unless (r == DDS_RETCODE_OK);

	delay ();
	r = DDS_Subscriber_get_qos (sub, &psq);
	fail_unless (r == DDS_RETCODE_OK &&
	             DDS_SEQ_LENGTH (refsq.partition.name) == DDS_SEQ_LENGTH (psq.partition.name) &&
		     DDS_SEQ_LENGTH (psq.group_data.value) == sizeof (data));
	DDS_SEQ_FOREACH (psq.partition.name, i)
		fail_unless (!strcmp (DDS_SEQ_ITEM (psq.partition.name, i),
				      DDS_SEQ_ITEM (refsq.partition.name, i)));
	n = dds_seq_to_array (&psq.group_data, d2, sizeof (d2));
	fail_unless (n == sizeof (data) && !memcmp (data, d2, sizeof (data)));
	DDS_SubscriberQos__clear (&refsq);
	DDS_SubscriberQos__clear (&psq);

	delay ();
	if (!enabled) {
		v_printf (" - Enable child entities.\r\n");
		r = DDS_DomainParticipant_enable (p);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_Topic_enable (t);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_Publisher_enable (pub);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_Subscriber_enable (sub);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_DataWriter_enable (dw);
		fail_unless (r == DDS_RETCODE_OK);
		r = DDS_DataReader_enable (dr);
		fail_unless (r == DDS_RETCODE_OK);
		sleep (1);
	}

	v_printf (" - Delete child entities.\r\n");
	r = DDS_Publisher_delete_datawriter (pub, dw);
	fail_unless (r == DDS_RETCODE_OK);
	r = DDS_Subscriber_delete_datareader (sub, dr);
	fail_unless (r == DDS_RETCODE_OK);
	r = DDS_DomainParticipant_delete_publisher (p, pub);
	fail_unless (r == DDS_RETCODE_OK);
	r = DDS_DomainParticipant_delete_subscriber (p, sub);
	fail_unless (r == DDS_RETCODE_OK);
	r = DDS_DomainParticipant_delete_topic (p, t);
	fail_unless (r == DDS_RETCODE_OK);

	unregister_HelloWorldData_type (p);
	r = DDS_DomainParticipantFactory_delete_participant (p);
	fail_unless (r == DDS_RETCODE_OK);
}
Exemple #29
0
int dcps_get_builtin_subscription_data (DDS_SubscriptionBuiltinTopicData *dp,
					DiscoveredReader_t               *drp)
{
	size_t		size, psize;
	char		*xp;
	UniQos_t	*uqp;

	size = str_len (drp->dr_topic->name);
	size += str_len (drp->dr_topic->type->type_name);
	if (drp->dr_qos->qos.user_data) {
		ROUND_LEN (size);
		size += str_len (drp->dr_qos->qos.user_data);
	}
	if (drp->dr_qos->qos.partition) {
		ROUND_LEN (size);
		psize = partition_size (drp->dr_qos->qos.partition);
		size += psize;
	}
	if (drp->dr_qos->qos.topic_data) {
		ROUND_LEN (size);
		size += str_len (drp->dr_qos->qos.topic_data);
	}
	if (drp->dr_qos->qos.group_data) {
		ROUND_LEN (size);
		size += str_len (drp->dr_qos->qos.group_data);
	}
	xp = xmalloc (size);
	if (!xp)
		return (DDS_RETCODE_OUT_OF_RESOURCES);

	dp->topic_name = xp;
	endpoint_key_from_guid (&drp->dr_participant->p_guid_prefix,
				&drp->dr_entity_id,
				(KeyHash_t *) &dp->key);
	memcpy (&dp->participant_key,
		&drp->dr_participant->p_guid_prefix,
		GUIDPREFIX_SIZE);
	if (sizeof (DDS_BuiltinTopicKey_t) > GUIDPREFIX_SIZE)
		dp->participant_key.value [3] = 0;
	memcpy (xp, str_ptr (drp->dr_topic->name),
				str_len (drp->dr_topic->name));
	xp += str_len (drp->dr_topic->name);
	dp->type_name = xp;
	memcpy (xp, str_ptr (drp->dr_topic->type->type_name),
				str_len (drp->dr_topic->type->type_name));
	xp += str_len (drp->dr_topic->type->type_name);
	uqp = &drp->dr_qos->qos;
	dp->durability.kind = uqp->durability_kind;
	dp->deadline = uqp->deadline;
	dp->latency_budget = uqp->latency_budget;
	dp->liveliness.kind = uqp->liveliness_kind;
	dp->liveliness.lease_duration = uqp->liveliness_lease_duration;
	dp->reliability.kind = uqp->reliability_kind;
	dp->reliability.max_blocking_time = uqp->reliability_max_blocking_time;
	dp->ownership.kind = uqp->ownership_kind;
	dp->destination_order.kind = uqp->destination_order_kind;
	if (uqp->user_data)
		ROUND_PTR (xp);
	oseq_set (&dp->user_data.value, uqp->user_data, (unsigned char *) xp);
	xp += DDS_SEQ_LENGTH (dp->user_data.value);
	dp->time_based_filter = drp->dr_time_based_filter;
	dp->presentation.access_scope = uqp->presentation_access_scope;
	dp->presentation.coherent_access = uqp->presentation_coherent_access;
	dp->presentation.ordered_access = uqp->presentation_ordered_access;
	if (uqp->partition)
		ROUND_PTR (xp);
	xp += partition_set (&dp->partition.name, uqp->partition, (unsigned char *) xp);
	if (uqp->topic_data)
		ROUND_PTR (xp);
	oseq_set (&dp->topic_data.value, uqp->topic_data, (unsigned char *) xp);
	xp += DDS_SEQ_LENGTH (dp->topic_data.value);
	if (uqp->group_data)
		ROUND_PTR (xp);
	oseq_set (&dp->group_data.value, uqp->group_data, (unsigned char *) xp);
	return (DDS_RETCODE_OK);
}
Exemple #30
0
void test_dyn_mutable2 (void)
{
	DDS_DynamicTypeSupport ts;
	DDS_DynamicTypeBuilder sb2, stb, sstb;
	DDS_DynamicType s2, st, sst;
	DDS_TypeDescriptor *desc;
	DDS_MemberDescriptor *md;
	DDS_DynamicData dd, dd2, dds;
	DDS_ReturnCode_t rc;
	DDS_StringSeq ss;
	unsigned n;
	char *strings [] = {
		"Hi there", "blabla", "\0", NULL, 
		"got here", "not yet done", "", "num8",
		"9", "10", "11", "12",
		"13", "14", "15", "16",
		"17", "18", "19", "done :)"
	};

	v_printf ("test_mutable2 - ");

	/* 1. Create the type. */
	desc = DDS_TypeDescriptor__alloc ();
	fail_unless (desc != NULL);
	desc->kind = DDS_STRUCTURE_TYPE;
	desc->name = "dstruct2m";

	sb2 = DDS_DynamicTypeBuilderFactory_create_type (desc);
	fail_unless (sb2 != NULL);

	md = DDS_MemberDescriptor__alloc ();
	fail_unless (md != NULL);

	ADD_FIELD (sb2, md, "u16", 0, 5, DDS_UINT_16_TYPE);
	set_key_annotation (sb2, "u16");

	stb = DDS_DynamicTypeBuilderFactory_create_string_type (DDS_UNBOUNDED_COLLECTION);
	fail_unless (stb != NULL);

	st = DDS_DynamicTypeBuilder_build (stb);
	fail_unless (st != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (stb);

	sstb = DDS_DynamicTypeBuilderFactory_create_sequence_type (st, 
							DDS_UNBOUNDED_COLLECTION);
	fail_unless (sstb != NULL);

	sst = DDS_DynamicTypeBuilder_build (sstb);
	fail_unless (sst != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (sstb);

	md->name = "s";
	md->index = 1;
	md->id = 6;
	md->type = sst;
	rc = DDS_DynamicTypeBuilder_add_member (sb2, md);
	fail_unless (rc == DDS_RETCODE_OK);

	set_ext_annotation (sb2, "MUTABLE_EXTENSIBILITY");

	s2 = DDS_DynamicTypeBuilder_build (sb2);
	fail_unless (s2 != NULL);

	DDS_DynamicTypeBuilderFactory_delete_type (sb2);

	ts = DDS_DynamicTypeSupport_create_type_support (s2);
	fail_unless (ts != NULL);

	DDS_TypeDescriptor__free (desc);
	DDS_MemberDescriptor__free (md);

	/* 2. Create a Dynamic data item for this type. */

	DDS_SEQ_INIT (ss);
	dds_seq_from_array (&ss, strings, sizeof (strings) / sizeof (char *));

	for (n = 0; n <= DDS_SEQ_MAXIMUM (ss); n++) {

		dd = DDS_DynamicDataFactory_create_data (s2);
		fail_unless (dd != NULL);

		SET_FIELD (dd, 5, uint16, n);

		dds = DDS_DynamicDataFactory_create_data (sst);
		fail_unless (dds != NULL);

		DDS_SEQ_LENGTH (ss) = n;
		rc = DDS_DynamicData_set_string_values (dds, 0, &ss);

		fail_unless (rc == DDS_RETCODE_OK);

		SET_FIELD (dd, 6, complex, dds);

		marshallDynamic (dd, &dd2, ts);

		DDS_DynamicDataFactory_delete_data (dd);
		DDS_DynamicDataFactory_delete_data (dds);
		if (n > 2) {
			n += 3;
			if (n == 18)
				n++;
		}
	}
	dds_seq_cleanup (&ss);

	DDS_DynamicTypeBuilderFactory_delete_type (s2);
	DDS_DynamicTypeBuilderFactory_delete_type (sst);
	DDS_DynamicTypeBuilderFactory_delete_type (st);

	DDS_DynamicTypeSupport_delete_type_support (ts);

	set_key_annotation (NULL, NULL);
	set_ext_annotation (NULL, NULL);

	v_printf ("success!\r\n");
}