Exemplo n.º 1
0
static void connect_cg(cgraph cg, struct endp from, struct endp to)
{
  gnode gfrom = endpoint_lookup(cg, &from), gto = endpoint_lookup(cg, &to);

  graph_add_edge(gfrom, gto, NULL);
  /* If an endpoint has args, we must also connect the node w/o args */
  if (from.args_node)
    graph_add_edge(fn_lookup(cg, from.function), gfrom, NULL);
  if (to.args_node)
    graph_add_edge(gto, fn_lookup(cg, to.function), NULL);
}
Exemplo n.º 2
0
static void ctt_data_reader_crypto_tokens (
				Domain_t                             *dp,
				DDS_ParticipantVolatileSecureMessage *info)
{
	Participant_t		*pp;
	Endpoint_t		*lep, *rep;
	EntityId_t		*eidp;
	DataReaderCrypto_t 	crypto;

	prof_start (disc_ctt_rtok);

	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: DataReader Token error: incorrect participant GUID.");
		return;
	}
	lep = endpoint_lookup (&dp->participant, (EntityId_t *) &info->destination_endpoint_key [12]);
	if (!lep) {
		warn_printf ("CTT: DataReader Token error: not a local DataWriter.");
		return;
	}
	rep = endpoint_lookup (pp, (EntityId_t *) &info->source_endpoint_key [12]);
	if (!rep ||
	    (crypto = rtps_peer_reader_crypto_get ((Writer_t *) lep,
					      (DiscoveredReader_t *) rep)) == 0) {
		eidp = (EntityId_t *) (info->source_endpoint_key + 12);
		log_printf (SEC_ID, 0, "CTT: DataReader Token remember (0x%04x)!\r\n", eidp->w);
		sec_remember_remote_datareader_tokens (((Writer_t *) lep)->w_crypto,
						       pp->p_crypto,
						       eidp,
						       &info->message_data);
	}
	else
		sec_set_remote_datareader_tokens (((Writer_t *) lep)->w_crypto,
						  crypto,
						  &info->message_data);
	prof_stop (disc_ctt_rtok, 1);
}
Exemplo n.º 3
0
/*===========================================================================*
 *                              do_safememset                                *
 *===========================================================================*/
int do_safememset(struct proc *caller, message *m_ptr) {
	/* Implementation of the do_safememset() kernel call */

	/* Extract parameters */
	endpoint_t dst_endpt = m_ptr->SMS_DST;
	endpoint_t caller_endpt = caller->p_endpoint;
	cp_grant_id_t grantid = m_ptr->SMS_GID;
	vir_bytes g_offset = m_ptr->SMS_OFFSET;
	int pattern = m_ptr->SMS_PATTERN;
	size_t len = (size_t)m_ptr->SMS_BYTES;

	struct proc *dst_p;
	endpoint_t new_granter;
	static vir_bytes v_offset;
	int r;

	if (dst_endpt == NONE || caller_endpt == NONE)
		return EFAULT;

	if (!(dst_p = endpoint_lookup(dst_endpt)))
		return EINVAL;

	if (!(priv(dst_p) && priv(dst_p)->s_grant_table)) {
		printf("safememset: dst %d has no grant table\n", dst_endpt);
		return EINVAL;
	}

	/* Verify permission exists, memset always requires CPF_WRITE */
	r = verify_grant(dst_endpt, caller_endpt, grantid, len, CPF_WRITE,
			 g_offset, &v_offset, &new_granter);

	if (r != OK) {
		printf("safememset: grant %d verify failed %d", grantid, r);
		return r;
	}

	return vm_memset(caller, new_granter, v_offset, pattern, len);
}
Exemplo n.º 4
0
static void connect_userg(location l, cgraph userg, struct endp from, struct endp to)
{
  gnode gfrom = endpoint_lookup(userg, &from), gto = endpoint_lookup(userg, &to);

  graph_add_edge(gfrom, gto, l);
}
Exemplo n.º 5
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);
	}
}