Exemple #1
0
/** Set which multicast frames are received.
 *
 * @param[in] dev_sess
 * @param[in] mode          Current operation mode
 * @param[in] address_list  The list of addresses. Can be NULL.
 * @param[in] address_count Number of addresses in the list.
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_multicast_set_mode(async_sess_t *dev_sess, nic_multicast_mode_t mode,
    const nic_address_t *address_list, size_t address_count)
{
	if (address_list == NULL)
		address_count = 0;
	
	async_exch_t *exch = async_exchange_begin(dev_sess);
	
	aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_MULTICAST_SET_MODE, (sysarg_t) mode, address_count, NULL);
	
	int rc;
	if (address_count)
		rc = async_data_write_start(exch, address_list,
		    address_count * sizeof(nic_address_t));
	else
		rc = EOK;
	
	async_exchange_end(exch);
	
	sysarg_t res;
	async_wait_for(message_id, &res);
	
	if (rc != EOK)
		return rc;
	
	return (int) res;
}
Exemple #2
0
/** Add new Wake-On-LAN virtue.
 *
 * @param[in]  dev_sess
 * @param[in]  type     Type of the virtue
 * @param[in]  data     Data required for this virtue
 *                      (depends on type)
 * @param[in]  length   Length of the data
 * @param[out] id       Identifier of the new virtue
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_wol_virtue_add(async_sess_t *dev_sess, nic_wv_type_t type,
    const void *data, size_t length, nic_wv_id_t *id)
{
	assert(id);
	
	bool send_data = ((data != NULL) && (length != 0));
	async_exch_t *exch = async_exchange_begin(dev_sess);
	
	ipc_call_t result;
	aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_WOL_VIRTUE_ADD, (sysarg_t) type, send_data, &result);
	
	sysarg_t res;
	if (send_data) {
		int rc = async_data_write_start(exch, data, length);
		if (rc != EOK) {
			async_exchange_end(exch);
			async_wait_for(message_id, &res);
			return rc;
		}
	}
	
	async_exchange_end(exch);
	async_wait_for(message_id, &res);
	
	*id = IPC_GET_ARG1(result);
	return (int) res;
}
Exemple #3
0
int bd_read_blocks(bd_t *bd, aoff64_t ba, size_t cnt, void *data, size_t size)
{
	async_exch_t *exch = async_exchange_begin(bd->sess);

	ipc_call_t answer;
	aid_t req = async_send_3(exch, BD_READ_BLOCKS, LOWER32(ba),
	    UPPER32(ba), cnt, &answer);
	int rc = async_data_read_start(exch, data, size);
	async_exchange_end(exch);

	if (rc != EOK) {
		async_forget(req);
		return rc;
	}

	sysarg_t retval;
	async_wait_for(req, &retval);

	if (retval != EOK)
		return retval;

	return EOK;
}
Exemple #4
0
/** Set the interrupt/poll mode of the NIC.
 *
 * @param[in] dev_sess
 * @param[in] mode     New poll mode
 * @param[in] period   Period used in periodic polling. Can be NULL.
 *
 * @return EOK If the operation was successfully completed
 *
 */
int nic_poll_set_mode(async_sess_t *dev_sess, nic_poll_mode_t mode,
    const struct timeval *period)
{
	async_exch_t *exch = async_exchange_begin(dev_sess);
	
	aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
	    NIC_POLL_SET_MODE, (sysarg_t) mode, period != NULL, NULL);
	
	int rc;
	if (period)
		rc = async_data_write_start(exch, period, sizeof(struct timeval));
	else
		rc = EOK;
	
	async_exchange_end(exch);
	
	sysarg_t res;
	async_wait_for(message_id, &res);
	
	if (rc != EOK)
		return rc;
	
	return (int) res;
}
Exemple #5
0
/**
 * Retrieve a list of server side actors.
 * @param[in] sess Valid audio session.
 * @param[out] ids list of string identifiers.
 * @param[out] count Number of elements int the @p ids list.
 * @param[in] flags list requirements.
 * @param[in] connection name of target actor. Used only if the list should
 *            contain connected actors.
 * @retval Error code.
 */
int hound_service_get_list(hound_sess_t *sess, const char ***ids, size_t *count,
    int flags, const char *connection)
{
	assert(sess);
	assert(ids);
	assert(count);

	if (connection && !(flags & HOUND_CONNECTED))
		return EINVAL;

	async_exch_t *exch = async_exchange_begin(sess);
	if (!exch)
		return ENOMEM;

	ipc_call_t res_call;
	aid_t mid = async_send_3(exch, IPC_M_HOUND_GET_LIST, flags, *count,
	    (bool)connection, &res_call);

	int ret = EOK;
	if (mid && connection)
		ret = async_data_write_start(exch, connection,
		    str_size(connection));

	if (ret == EOK)
		async_wait_for(mid, (sysarg_t*)&ret);

	if (ret != EOK) {
		async_exchange_end(exch);
		return ret;
	}
	unsigned name_count = IPC_GET_ARG1(res_call);

	/* Start receiving names */
	const char **names = NULL;
	if (name_count) {
		size_t *sizes = calloc(name_count, sizeof(size_t));
		names = calloc(name_count, sizeof(char *));
		if (!names || !sizes)
			ret = ENOMEM;

		if (ret == EOK)
			ret = async_data_read_start(exch, sizes,
			    name_count * sizeof(size_t));
		for (unsigned i = 0; i < name_count && ret == EOK; ++i) {
			char *name = malloc(sizes[i] + 1);
			if (name) {
				memset(name, 0, sizes[i] + 1);
				ret = async_data_read_start(exch, name, sizes[i]);
				names[i] = name;
			} else {
				ret = ENOMEM;
			}
		}
		free(sizes);
	}
	async_exchange_end(exch);
	if (ret != EOK) {
		for (unsigned i = 0; i < name_count; ++i)
			free(names[i]);
		free(names);
	} else {
		*ids = names;
		*count = name_count;
	}
	return ret;
}