コード例 #1
0
ファイル: sec_crypto.c プロジェクト: FlavioFalcao/tinq-core
void sec_crypto_dump (unsigned handle)
{
	Entity_t	*p = entity_ptr (handle);
	Participant_t	*pp;
	LocalEndpoint_t	*ep;
	CryptoData_t	*dp;
	unsigned	ch;

	if (!p) {
		dbg_printf ("Entity not found!\r\n");
		return;
	}
	switch (entity_type (p)) {
		case ET_PARTICIPANT:
			pp = (Participant_t *) p;
			ch = pp->p_crypto;
			break;
		case ET_WRITER:
		case ET_READER:
			if ((p->flags & EF_LOCAL) != 0) {
				ep = (LocalEndpoint_t *) p;
				ch = ep->crypto;
			}
			else if (entity_type (p) == ET_WRITER)
				ch = rtps_peer_writer_crypto_get (NULL, 
							(DiscoveredWriter_t *) p);
			else
				ch = rtps_peer_reader_crypto_get (NULL, 
							(DiscoveredReader_t *) p);
			break;
		default:
			dbg_printf ("Invalid entity type!\r\n");
			return;
	}
	if (!ch) {
		dbg_printf ("No associated crypto context.\r\n");
		return;
	}
	dp = crypto_lookup (ch);
	if (!dp) {
		dbg_printf ("Crypto context deleted.\r\n");
		return;
	}
	dp->plugin->dump (dp->plugin, dp, p);
}
コード例 #2
0
ファイル: disc_ctt.c プロジェクト: tinq-iot/tinq
static void ctt_data_writer_crypto_tokens (
				Domain_t                             *dp,
				DDS_ParticipantVolatileSecureMessage *info)
{
	Participant_t		*pp;
	Endpoint_t		*lep, *rep;
	EntityId_t		*eidp;
	DataWriterCrypto_t 	crypto;

	prof_start (disc_ctt_wtok);

	pp = participant_lookup (dp, (GuidPrefix_t *) info->source_endpoint_key);
	if (!pp)
		return;

	if (memcmp (dp->participant.p_guid_prefix.prefix,
		    info->destination_endpoint_key,
		    12)) {
		warn_printf ("CTT: DataWriter Token error: incorrect participant GUID.");
		return;
	}
	lep = endpoint_lookup (&dp->participant, (EntityId_t *) &info->destination_endpoint_key [12]);
	if (!lep) {
		warn_printf ("CTT: DataWriter Token error: not a local DataReader.");
		return;
	}
	rep = endpoint_lookup (pp, (EntityId_t *) &info->source_endpoint_key [12]);
	if (!rep ||
	    (crypto = rtps_peer_writer_crypto_get ((Reader_t *) lep,
					      (DiscoveredWriter_t *) rep)) == 0) {
		eidp = (EntityId_t *) (info->source_endpoint_key + 12);
		log_printf (SEC_ID, 0, "CTT: DataWriter Token remember (0x%04x)!\r\n", eidp->w);
		sec_remember_remote_datawriter_tokens (((Reader_t *) lep)->r_crypto,
						       pp->p_crypto,
						       eidp,
						       &info->message_data);
	}
	else
		sec_set_remote_datawriter_tokens (((Reader_t *) lep)->r_crypto,
						  crypto,
						  &info->message_data);
	prof_stop (disc_ctt_wtok, 1);
}