コード例 #1
0
/*
 * Get information about port on bridge.
 */
int br_get_port_info(const char *brname, const char *port, 
		     struct port_info *info)
{
#ifndef HAVE_LIBSYSFS
	return old_get_port_info(brname, port, info);
#else
	struct sysfs_directory *sdir
		= bridge_sysfs_directory(port, SYSFS_BRIDGE_PORT_ATTR);

	if (!sdir) 
		return old_get_port_info(brname, port, info);

	memset(info, 0, sizeof(*info));
	fetch_id(sdir, "designated_root", &info->designated_root);
	fetch_id(sdir, "designated_bridge", &info->designated_bridge);
	info->port_no = fetch_int(sdir, "port_no");
	info->port_id = fetch_int(sdir, "port_id");
	info->designated_port = fetch_int(sdir, "designated_port");
	info->path_cost = fetch_int(sdir, "path_cost");
	info->designated_cost = fetch_int(sdir, "designated_cost");
	info->state = fetch_int(sdir, "state");
	info->top_change_ack = fetch_int(sdir, "change_ack");
	info->config_pending = fetch_int(sdir, "config_pending");
	fetch_tv(sdir, "message_age_timer", 
		 &info->message_age_timer_value);
	fetch_tv(sdir, "forward_delay_timer",
		 &info->forward_delay_timer_value);
	fetch_tv(sdir, "hold_timer",
		 &info->hold_timer_value);
	sysfs_close_directory(sdir);

	return 0;
#endif
}
コード例 #2
0
ファイル: libbridge_devif.c プロジェクト: 1x23/unifi-gpl
/*
 * Get information about port on bridge.
 */
int br_get_port_info(const char *brname, const char *port, 
		     struct port_info *info)
{
	DIR *d;
	char path[SYSFS_PATH_MAX];

	snprintf(path, SYSFS_PATH_MAX, SYSFS_CLASS_NET "%s/brport", port);
	d = opendir(path);
	if (!d)
		goto fallback;

	memset(info, 0, sizeof(*info));

	fetch_id(path, "designated_root", &info->designated_root);
	fetch_id(path, "designated_bridge", &info->designated_bridge);
	info->port_no = fetch_int(path, "port_no");
	info->port_id = fetch_int(path, "port_id");
	info->designated_port = fetch_int(path, "designated_port");
	info->path_cost = fetch_int(path, "path_cost");
	info->designated_cost = fetch_int(path, "designated_cost");
	info->state = fetch_int(path, "state");
	info->top_change_ack = fetch_int(path, "change_ack");
	info->config_pending = fetch_int(path, "config_pending");
	fetch_tv(path, "message_age_timer", &info->message_age_timer_value);
	fetch_tv(path, "forward_delay_timer", &info->forward_delay_timer_value);
	fetch_tv(path, "hold_timer", &info->hold_timer_value);
	closedir(d);

	return 0;
fallback:
	return old_get_port_info(brname, port, info);
}