Exemplo n.º 1
0
/**
 * Function to send message to all nodes
 *
 * @param buffer len
 *
 * @return NCSCC_RC_SUCCESS
 * @return NCSCC_RC_FAILURE
 *
 */
uns32 dtm_internode_snd_msg_to_all_nodes(uns8 *buffer, uns16 len)
{
	/* Get each node and send message */
	NODE_ID node_id = 0;
	DTM_NODE_DB *node = NULL;
	TRACE_ENTER();

	/* while (NULL != (node = (DTM_NODE_DB *) ncs_patricia_tree_getnext(&dtms_gl_cb->nodeid_tree, (uns8 *)&node_id)))  */
	while (NULL != (node = dtm_node_getnext_by_id(node_id))) {
		node_id = node->node_id;
		if (node_id != dtms_gl_cb->node_id) {
			uns8 *buf_send = NULL;
			if (NULL == (buf_send = calloc(1, len))) {
				TRACE("DTM :calloc failed for snd_msg_to_all_nodes");
				free(buffer);
				return NCSCC_RC_FAILURE;
			}
			memcpy(buf_send, buffer, len);	
			dtm_internode_snd_msg_common(node, buf_send, len);
		}
	}
	free(buffer);
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
Exemplo n.º 2
0
/**
 * Function to send message to all nodes
 *
 * @param buffer len
 *
 * @return NCSCC_RC_SUCCESS
 * @return NCSCC_RC_FAILURE
 *
 */
uint32_t dtm_internode_snd_msg_to_all_nodes(uint8_t *buffer, uint16_t len)
{
	/* Get each node and send message */
	NODE_ID node_id = 0;
	DTM_NODE_DB *node = NULL;
	TRACE_ENTER();

	while (NULL != (node = dtm_node_getnext_by_id(node_id))) {
		node_id = node->node_id;
		/* send only to fully connected peers */
		if ((node_id != dtms_gl_cb->node_id) &&	node->comm_status) {
			uint8_t *buf_send = NULL;
			if (NULL == (buf_send = calloc(1, len))) {
				TRACE("DTM :calloc failed for snd_msg_to_all_nodes");
				free(buffer);
				return NCSCC_RC_FAILURE;
			}
			memcpy(buf_send, buffer, len);	
			dtm_internode_snd_msg_common(node, buf_send, len);
		}
	}
	free(buffer);
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}
Exemplo n.º 3
0
/**
 * Fucntion to send internode message
 *
 * @param node_id buffer len
 *
 * @return NCSCC_RC_SUCCESS
 * @return NCSCC_RC_FAILURE
 *
 */
uns32 dtm_internode_snd_msg_to_node(uns8 *buffer, uns16 len, NODE_ID node_id)
{
	DTM_NODE_DB *node = NULL;

	TRACE_ENTER();
	node = dtm_node_get_by_id(node_id);

	if (NULL != node) {
		if (NCSCC_RC_SUCCESS != dtm_internode_snd_msg_common(node, buffer, len)) {
			free(buffer);
			TRACE_LEAVE();
			return NCSCC_RC_FAILURE;
		}
	} else {
		free(buffer);
		TRACE_LEAVE();
		return NCSCC_RC_FAILURE;
	}
	/* Get the node entry and send message */
	TRACE_LEAVE();
	return NCSCC_RC_SUCCESS;
}