static int vlan_dump_full(struct rtnl_link *link, struct nl_dump_params *p,
			  int line)
{
	struct vlan_info *vi = link->l_info;
	int i, printed;
	char buf[64];

	rtnl_link_vlan_flags2str(vi->vi_flags, buf, sizeof(buf));
	dp_dump_line(p, line++, "    vlan-info id %d <%s>\n",
		vi->vi_vlan_id, buf);

	if (vi->vi_mask & VLAN_HAS_INGRESS_QOS) {
		dp_dump_line(p, line++,
		"      ingress vlan prio -> qos/socket prio mapping:\n");
		for (i = 0, printed = 0; i <= VLAN_PRIO_MAX; i++) {
			if (vi->vi_ingress_qos[i]) {
				if (printed == 0) {
					dp_new_line(p, line);
					dp_dump(p, "      ");
				}
				dp_dump(p, "%x -> %#08x, ",
					i, vi->vi_ingress_qos[i]);
				if (printed++ == 3) {
					dp_dump(p, "\n");
					printed = 0;
				}
			}
		}

		if (printed > 0 && printed != 4)
			dp_dump(p, "\n");
	}

	if (vi->vi_mask & VLAN_HAS_EGRESS_QOS) {
		dp_dump_line(p, line++,
		"      egress qos/socket prio -> vlan prio mapping:\n");
		for (i = 0, printed = 0; i < vi->vi_negress; i++) {
			if (printed == 0) {
				dp_new_line(p, line);
				dp_dump(p, "      ");
			}
			dp_dump(p, "%#08x -> %x, ",
				vi->vi_egress_qos[i].vm_from,
				vi->vi_egress_qos[i].vm_to);
			if (printed++ == 3) {
				dp_dump(p, "\n");
				printed = 0;
			}
		}

		if (printed > 0 && printed != 4)
			dp_dump(p, "\n");
	}

	return line;
}
예제 #2
0
파일: neigh.c 프로젝트: ebichu/dd-wrt
static int neigh_dump_brief(struct nl_cache *c, struct nl_common *a, FILE *fd,
			    struct nl_dump_params *params)
{
	char dst[INET6_ADDRSTRLEN+5], lladdr[INET6_ADDRSTRLEN+5];
	struct rtnl_neigh *n = (struct rtnl_neigh *) a;
	char state[128], flags[64];

	dp_new_line(fd, params, 0);
	fprintf(fd, "%s dev %s lladdr %s ",
		nl_addr2str_r(&(n->n_dst), dst, sizeof(dst)),
		rtnl_link_i2name(nl_cache_lookup(RTNL_LINK), n->n_ifindex),
		nl_addr2str_r(&(n->n_lladdr), lladdr, sizeof(lladdr)));

	rtnl_neigh_state2str_r(n->n_state, state, sizeof(state));
	rtnl_neigh_flags2str_r(n->n_flags, flags, sizeof(flags));

	if (state[0])
		fprintf(fd, "<%s", state);
	if (flags[0])
		fprintf(fd, "%s%s", state[0] ? "," : "<", flags);
	if (state[0] || flags[0])
		fprintf(fd, ">");
	fprintf(fd, "\n");

	return 1;
}
예제 #3
0
파일: route.c 프로젝트: ebichu/dd-wrt
static int route_dump_brief(struct nl_cache *c, struct nl_common *a, FILE *fd,
			    struct nl_dump_params *params)
{
	struct rtnl_route *r = (struct rtnl_route *) a;

	dp_new_line(fd, params, 0);

	if (r->rt_mask & ROUTE_HAS_DST) {
		char dst[INET6_ADDRSTRLEN+5];
		fprintf(fd, "%s ", nl_addr2str_r(&r->rt_dst, dst, sizeof(dst)));
	} else if (r->rt_dst_len)
		fprintf(fd, "0/%u ", r->rt_dst_len);
	else
		fprintf(fd, "default ");

	if (r->rt_mask & ROUTE_HAS_GATEWAY) {
		char via[INET6_ADDRSTRLEN+5];
		fprintf(fd, "via %s ", nl_addr2str_r(&r->rt_gateway, via, sizeof(via)));
	}

	if (r->rt_mask & ROUTE_HAS_OIF) {
		const char *dev = rtnl_link_i2name(nl_cache_lookup(RTNL_LINK), r->rt_oif);
		fprintf(fd, "dev %s ", dev);
	}

	if (r->rt_table != RT_TABLE_MAIN)
		fprintf(fd, "table %u ", r->rt_table);

	if (r->rt_mask & ROUTE_HAS_FLAGS && r->rt_flags) {
		int flags = r->rt_flags;

		fprintf(fd, "<");
		
#define PRINT_FLAG(f) if (flags & RTNH_F_##f) { \
		flags &= ~RTNH_F_##f; fprintf(fd, #f "%s", flags ? "," : ""); }
		PRINT_FLAG(DEAD);
		PRINT_FLAG(ONLINK);
		PRINT_FLAG(PERVASIVE);
#undef PRINT_FLAG

#define PRINT_FLAG(f) if (flags & RTM_F_##f) { \
		flags &= ~RTM_F_##f; fprintf(fd, #f "%s", flags ? "," : ""); }
		PRINT_FLAG(NOTIFY);
		PRINT_FLAG(CLONED);
		PRINT_FLAG(EQUALIZE);
		PRINT_FLAG(PREFIX);
#undef PRINT_FLAG

		fprintf(fd, ">");
	}

	fprintf(fd, "\n");

	return 1;
}
예제 #4
0
파일: rule.c 프로젝트: ebichu/dd-wrt
static int rule_dump_brief(struct nl_cache *c, struct nl_common *o, FILE *fd,
			   struct nl_dump_params *params)
{
	struct rtnl_rule *r = (struct rtnl_rule *) o;
	char addr[INET6_ADDRSTRLEN+5], realms[32], type[32];

	dp_new_line(fd, params, 0);

	if (r->r_mask & RULE_HAS_PRIO)
		fprintf(fd, "%d:\t", r->r_prio);
	else
		fprintf(fd, "0:\t");

	if (r->r_mask & RULE_HAS_SRC)
		fprintf(fd, "from %s ",
			nl_addr2str_r(&r->r_src, addr, sizeof(addr)));
	else if (r->r_mask & RULE_HAS_SRC_LEN && r->r_src_len)
		fprintf(fd, "from 0/%d ", r->r_src_len);
	else
		fprintf(fd, "from all ");

	if (r->r_mask & RULE_HAS_DST)
		fprintf(fd, "to %s ",
			nl_addr2str_r(&r->r_dst, addr, sizeof(addr)));
	else if (r->r_mask & RULE_HAS_DST_LEN && r->r_dst_len)
		fprintf(fd, "to 0/%d ", r->r_dst_len);
	else
		fprintf(fd, "to all ");

	if (r->r_mask & RULE_HAS_DSFIELD)
		fprintf(fd, "tos %d ", r->r_dsfield);

	if (r->r_mask & RULE_HAS_FWMARK)
		fprintf(fd, "fwmark %" PRIx64 , r->r_fwmark);

	if (r->r_mask & RULE_HAS_IIF)
		fprintf(fd, "iif %s ", r->r_iif);

	if (r->r_mask & RULE_HAS_TABLE)
		fprintf(fd, "lookup %d ", r->r_table);

	if (r->r_mask & RULE_HAS_REALMS)
		fprintf(fd, "realms %s ",
			rtnl_realms2str_r(r->r_realms, realms, sizeof(realms)));

	fprintf(fd, "%s\n", nl_rtntype2str_r(r->r_type, type, sizeof(type)));

	return 1;
}
예제 #5
0
파일: neigh.c 프로젝트: ebichu/dd-wrt
static int neigh_dump_full(struct nl_cache *c, struct nl_common *a, FILE *fd,
			   struct nl_dump_params *params)
{
	char rtn_type[32];
	struct rtnl_neigh *n = (struct rtnl_neigh *) a;
	int hz = nl_get_hz();

	int line = neigh_dump_brief(c, a, fd, params);

	dp_new_line(fd, params, line++);
	fprintf(fd, "    refcnt %u type %s confirmed %u used %u updated %u\n",
		n->n_cacheinfo.nci_refcnt,
		nl_rtntype2str_r(n->n_type, rtn_type, sizeof(rtn_type)),
		n->n_cacheinfo.nci_confirmed/hz,
		n->n_cacheinfo.nci_used/hz, n->n_cacheinfo.nci_updated/hz);

	return line;
}
예제 #6
0
파일: route.c 프로젝트: ebichu/dd-wrt
static int route_dump_full(struct nl_cache *c, struct nl_common *a, FILE *fd,
			   struct nl_dump_params *params)
{
	struct rtnl_route *r = (struct rtnl_route *) a;

	int line = route_dump_brief(c, a, fd, params);

	dp_new_line(fd, params, line++);

	if (r->rt_mask & ROUTE_HAS_PRIO)
		fprintf(fd, "metric %u ", r->rt_prio);

	if (r->rt_mask & ROUTE_HAS_PREF_SRC) {
		char p[INET6_ADDRSTRLEN+5];
		fprintf(fd, "pref %s ", nl_addr2str_r(&r->rt_pref_src, p,
						      sizeof(p)));
	}

	fprintf(fd, "\n");

	return line;
}