示例#1
0
/*
 * Property link_watch
 */
static dbus_bool_t
__ni_objectmodel_team_get_link_watch(const ni_dbus_object_t *object, const ni_dbus_property_t *property,
				ni_dbus_variant_t *result, DBusError *error)
{
	const ni_team_t *team;
	unsigned int i;

	if (!(team = __ni_objectmodel_team_read_handle(object, error)))
		return FALSE;

	if (!team->link_watch.count)
		return FALSE;

	ni_dbus_variant_init_dict(result);
	for (i = 0; i < team->link_watch.count; i++) {
		ni_team_link_watch_t *lw = team->link_watch.data[i];
		ni_dbus_variant_t *entry;
		ni_dbus_variant_t *dict;
		const char *name;

		if (!(name = ni_team_link_watch_type_to_name(lw->type)))
			continue;

		entry = ni_dbus_dict_add(result, "watch");
		ni_dbus_variant_init_struct(entry);
		ni_dbus_struct_add_string(entry, name);
		dict = ni_dbus_struct_add(entry);
		ni_dbus_variant_init_dict(dict);
		__ni_objectmodel_team_link_watch_to_dict(lw, dict, error, object, property);
	}
	return TRUE;
}
示例#2
0
文件: lldp.c 项目: mchf/wicked
static ni_bool_t
__ni_objectmodel_struct_add_sockaddr(ni_dbus_variant_t *strct, const ni_sockaddr_t *value)
{
	ni_dbus_variant_t *member;

	if (!(member = ni_dbus_struct_add(strct)))
		return FALSE;
	return __ni_objectmodel_set_sockaddr(member, value);
}
示例#3
0
static dbus_bool_t
ni_objectmodel_ppp_get_mode(const ni_dbus_object_t *object, const ni_dbus_property_t *property,
				ni_dbus_variant_t *result, DBusError *error)
{
	ni_dbus_variant_t *dict;
	const ni_ppp_t *ppp;
	const char *mode;

	if (!(ppp = ni_objectmodel_ppp_handle(object, FALSE, error)))
		return FALSE;

	if (NI_PPP_MODE_UNKNOWN == ppp->mode.type)
		return ni_dbus_error_property_not_present(error, object->path, property->name);

	if (!(mode = ni_ppp_mode_type_to_name(ppp->mode.type))) {
		dbus_set_error(error, DBUS_ERROR_INVALID_ARGS,
				"bad property %s; unsupported mode type %u",
				property->name, ppp->mode.type);
		return FALSE;
	}

	ni_dbus_variant_init_struct(result);
	ni_dbus_struct_add_string(result, mode);
	dict = ni_dbus_struct_add(result);
	ni_dbus_variant_init_dict(dict);

	switch (ppp->mode.type) {
	case NI_PPP_MODE_PPPOE: {
			const ni_ppp_mode_pppoe_t *pppoe = &ppp->mode.pppoe;

			if (!ni_string_empty(pppoe->device.name))
				ni_dbus_dict_add_string(dict, "device", pppoe->device.name);
		}
		break;

	default:
		return FALSE;
	}

	return TRUE;
}
示例#4
0
static dbus_bool_t
__ni_objectmodel_team_get_runner(const ni_dbus_object_t *object, const ni_dbus_property_t *property,
				ni_dbus_variant_t *result, DBusError *error)
{
	ni_dbus_variant_t *dict;
	const ni_team_t *team;
	const char *name;

	if (!(team = __ni_objectmodel_team_read_handle(object, error)))
		return FALSE;

	if (!team->runner.type)
		return ni_dbus_error_property_not_present(error, object->path, property->name);

	if (!(name = ni_team_runner_type_to_name(team->runner.type))) {
		dbus_set_error(error, DBUS_ERROR_INVALID_ARGS,
				"bad property %s; unsupported runner name type %u",
				property->name, team->runner.type);
		return FALSE;
	}

	ni_dbus_variant_init_struct(result);
	ni_dbus_struct_add_string(result, name);
	dict = ni_dbus_struct_add(result);
	ni_dbus_variant_init_dict(dict);

	switch (team->runner.type) {
	case NI_TEAM_RUNNER_ACTIVE_BACKUP: {
			const ni_team_runner_active_backup_t *ab = &team->runner.ab;
			ni_dbus_dict_add_uint32(dict, "hwaddr_policy", ab->config.hwaddr_policy);
		}
		break;

	case NI_TEAM_RUNNER_LOAD_BALANCE: {
			const ni_team_runner_load_balance_t *lb = &team->runner.lb;
			ni_dbus_variant_t *txb;

			ni_dbus_dict_add_uint32(dict, "tx_hash", lb->config.tx_hash);
			txb = ni_dbus_dict_add(dict, "tx_balancer");
			ni_dbus_variant_init_dict(txb);
			ni_dbus_dict_add_uint32(txb, "name", lb->config.tx_balancer.type);
			ni_dbus_dict_add_uint32(txb, "balancing_interval", lb->config.tx_balancer.interval);
		}
		break;

	case NI_TEAM_RUNNER_ROUND_ROBIN:
		break;

	case NI_TEAM_RUNNER_BROADCAST:
		break;

	case NI_TEAM_RUNNER_RANDOM:
		break;

	case NI_TEAM_RUNNER_LACP: {
			const ni_team_runner_lacp_t *lacp = &team->runner.lacp;
			ni_dbus_variant_t *txb;

			ni_dbus_dict_add_bool(dict, "active", lacp->config.active);
			ni_dbus_dict_add_bool(dict, "fast_rate", lacp->config.fast_rate);
			ni_dbus_dict_add_uint16(dict, "sys_prio", lacp->config.sys_prio);
			ni_dbus_dict_add_uint16(dict, "min_ports", lacp->config.min_ports);
			ni_dbus_dict_add_uint32(dict, "select_policy", lacp->config.select_policy);

			ni_dbus_dict_add_uint32(dict, "tx_hash", lacp->config.tx_hash);
			txb = ni_dbus_dict_add(dict, "tx_balancer");
			ni_dbus_variant_init_dict(txb);
			ni_dbus_dict_add_uint32(txb, "name", lacp->config.tx_balancer.type);
			ni_dbus_dict_add_uint32(txb, "balancing_interval", lacp->config.tx_balancer.interval);
		}
		break;

	default:
		return FALSE;
	}
	return TRUE;
}