コード例 #1
0
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
ファイル: addr.c プロジェクト: artisdom/mipv6
static int addr_dump_full(struct nl_object *obj, struct nl_dump_params *p)
{
	struct rtnl_addr *addr = (struct rtnl_addr *) obj;
	int line = addr_dump_brief(obj, p);
	char buf[128];

	if (addr->a_mask & (ADDR_ATTR_LABEL | ADDR_ATTR_BROADCAST |
			    ADDR_ATTR_ANYCAST | ADDR_ATTR_MULTICAST)) {
		dp_dump_line(p, line++, "  ");

		if (addr->a_mask & ADDR_ATTR_LABEL)
			dp_dump(p, " label %s", addr->a_label);

		if (addr->a_mask & ADDR_ATTR_BROADCAST)
			dp_dump(p, " broadcast %s",
				nl_addr2str(addr->a_bcast, buf, sizeof(buf)));

		if (addr->a_mask & ADDR_ATTR_ANYCAST)
			dp_dump(p, " anycast %s",
				nl_addr2str(addr->a_anycast, buf,
					      sizeof(buf)));

		if (addr->a_mask & ADDR_ATTR_MULTICAST)
			dp_dump(p, " multicast %s",
				nl_addr2str(addr->a_multicast, buf,
					      sizeof(buf)));

		dp_dump(p, "\n");
	}

	if (addr->a_mask & ADDR_ATTR_CACHEINFO) {
		struct rtnl_addr_cacheinfo *ci = &addr->a_cacheinfo;

		dp_dump_line(p, line++, "   valid-lifetime %s",
			     ci->aci_valid == 0xFFFFFFFFU ? "forever" :
			     nl_msec2str(ci->aci_valid * 1000,
					   buf, sizeof(buf)));

		dp_dump(p, " preferred-lifetime %s\n",
			ci->aci_prefered == 0xFFFFFFFFU ? "forever" :
			nl_msec2str(ci->aci_prefered * 1000,
				      buf, sizeof(buf)));

		dp_dump_line(p, line++, "   created boot-time+%s ",
			     nl_msec2str(addr->a_cacheinfo.aci_cstamp * 10,
					   buf, sizeof(buf)));
		    
		dp_dump(p, "last-updated boot-time+%s\n",
			nl_msec2str(addr->a_cacheinfo.aci_tstamp * 10,
				      buf, sizeof(buf)));
	}

	return line;
}
コード例 #3
0
ファイル: lookup.c プロジェクト: 62gs8ha/batphone
static int result_dump_brief(struct nl_object *obj, struct nl_dump_params *p)
{
	struct flnl_result *res = (struct flnl_result *) obj;
	char buf[128];
	int line = 1;

	dp_dump(p, "table %s prefixlen %u next-hop-selector %u\n",
		rtnl_route_table2str(res->fr_table_id, buf, sizeof(buf)),
		res->fr_prefixlen, res->fr_nh_sel);
	dp_dump_line(p, line++, "type %s ",
		     nl_rtntype2str(res->fr_type, buf, sizeof(buf)));
	dp_dump(p, "scope %s error %s (%d)\n",
		rtnl_scope2str(res->fr_scope, buf, sizeof(buf)),
		strerror(-res->fr_error), res->fr_error);

	return line;
}
コード例 #4
0
ファイル: rule.c プロジェクト: DINKIN/tuo
static int rule_dump_full(struct nl_object *obj, struct nl_dump_params *p)
{
	struct rtnl_rule *rule = (struct rtnl_rule *) obj;
	char buf[128];
	int line;

	line = rule_dump_brief(obj, p);

	dp_dump_line(p, line++, "  family %s",
		     nl_af2str(rule->r_family, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_SRCMAP)
		dp_dump(p, " srcmap %s",
			nl_addr2str(rule->r_srcmap, buf, sizeof(buf)));

	dp_dump(p, "\n");

	return line;
}
コード例 #5
0
ファイル: tbf.c プロジェクト: ShubhamShah/batphone
static int tbf_dump_full(struct rtnl_qdisc *qdisc, struct nl_dump_params *p,
                         int line)
{
    struct rtnl_tbf *tbf = tbf_qdisc(qdisc);

    if (!tbf)
        goto ignore;

    if (1) {
        char *bu, *cu;
        double bs = nl_cancel_down_bytes(tbf->qt_rate_bucket, &bu);
        double cl = nl_cancel_down_bytes(1 << tbf->qt_rate.rs_cell_log,
                                         &cu);

        dp_dump(p, "mpu %u rate-bucket-size %1.f%s "
                "rate-cell-size %.1f%s\n",
                tbf->qt_mpu, bs, bu, cl, cu);

    }

    if (tbf->qt_mask & TBF_ATTR_PEAKRATE) {
        char *pru, *prbu, *bsu, *clu;
        double pr, prb, bs, cl;

        pr = nl_cancel_down_bytes(tbf->qt_peakrate.rs_rate, &pru);
        prb = nl_cancel_down_bits(tbf->qt_peakrate.rs_rate * 8, &prbu);
        bs = nl_cancel_down_bits(tbf->qt_peakrate_bucket, &bsu);
        cl = nl_cancel_down_bits(1 << tbf->qt_peakrate.rs_cell_log,
                                 &clu);

        dp_dump_line(p, line++, "    peak-rate %.2f%s/s (%.0f%s) "
                     "bucket-size %.1f%s cell-size %.1f%s",
                     "latency %.1f%s",
                     pr, pru, prb, prbu, bs, bsu, cl, clu);
    }

ignore:
    return line;
}
コード例 #6
0
ファイル: addr.c プロジェクト: artisdom/mipv6
static int addr_dump_xml(struct nl_object *obj, struct nl_dump_params *p)
{
	struct rtnl_addr *addr = (struct rtnl_addr *) obj;
	struct nl_cache *link_cache;
	char buf[128];
	int line = 0;

	dp_dump_line(p, line++, "<address>\n");
	dp_dump_line(p, line++, "  <family>%s</family>\n",
		     nl_af2str(addr->a_family, buf, sizeof(buf)));

	if (addr->a_mask & ADDR_ATTR_LOCAL)
		dp_dump_line(p, line++, "  <local>%s</local>\n",
			     nl_addr2str(addr->a_local, buf, sizeof(buf)));

	if (addr->a_mask & ADDR_ATTR_PEER)
		dp_dump_line(p, line++, "  <peer>%s</peer>\n",
			     nl_addr2str(addr->a_peer, buf, sizeof(buf)));

	if (addr->a_mask & ADDR_ATTR_BROADCAST)
		dp_dump_line(p, line++, "  <broadcast>%s</broadcast>\n",
			     nl_addr2str(addr->a_bcast, buf, sizeof(buf)));

	if (addr->a_mask & ADDR_ATTR_ANYCAST)
		dp_dump_line(p, line++, "  <anycast>%s</anycast>\n",
			     nl_addr2str(addr->a_anycast, buf, sizeof(buf)));

	if (addr->a_mask & ADDR_ATTR_MULTICAST)
		dp_dump_line(p, line++, "  <multicast>%s</multicast>\n",
			     nl_addr2str(addr->a_multicast, buf,
					   sizeof(buf)));

	if (addr->a_mask & ADDR_ATTR_PREFIXLEN)
		dp_dump_line(p, line++, "  <prefixlen>%u</prefixlen>\n",
			     addr->a_prefixlen);
	link_cache = nl_cache_mngt_require("route/link");

	if (link_cache)
		dp_dump_line(p, line++, "  <device>%s</device>\n",
			     rtnl_link_i2name(link_cache, addr->a_ifindex,
			     		      buf, sizeof(buf)));
	else
		dp_dump_line(p, line++, "  <device>%u</device>\n",
			     addr->a_ifindex);

	if (addr->a_mask & ADDR_ATTR_SCOPE)
		dp_dump_line(p, line++, "  <scope>%s</scope>\n",
			     rtnl_scope2str(addr->a_scope, buf, sizeof(buf)));

	if (addr->a_mask & ADDR_ATTR_LABEL)
		dp_dump_line(p, line++, "  <label>%s</label>\n", addr->a_label);

	rtnl_addr_flags2str(addr->a_flags, buf, sizeof(buf));
	if (buf[0])
		dp_dump_line(p, line++, "  <flags>%s</flags>\n", buf);

	if (addr->a_mask & ADDR_ATTR_CACHEINFO) {
		struct rtnl_addr_cacheinfo *ci = &addr->a_cacheinfo;

		dp_dump_line(p, line++, "  <cacheinfo>\n");

		dp_dump_line(p, line++, "    <valid>%s</valid>\n",
			     ci->aci_valid == 0xFFFFFFFFU ? "forever" :
			     nl_msec2str(ci->aci_valid * 1000,
					   buf, sizeof(buf)));

		dp_dump_line(p, line++, "    <prefered>%s</prefered>\n",
			     ci->aci_prefered == 0xFFFFFFFFU ? "forever" :
			     nl_msec2str(ci->aci_prefered * 1000,
					 buf, sizeof(buf)));

		dp_dump_line(p, line++, "    <created>%s</created>\n",
			     nl_msec2str(addr->a_cacheinfo.aci_cstamp * 10,
					 buf, sizeof(buf)));

		dp_dump_line(p, line++, "    <last-update>%s</last-update>\n",
			     nl_msec2str(addr->a_cacheinfo.aci_tstamp * 10,
					 buf, sizeof(buf)));

		dp_dump_line(p, line++, "  </cacheinfo>\n");
	}

	dp_dump_line(p, line++, "</address>\n");

	return line;
}
コード例 #7
0
static int addr_dump_env(struct nl_object *obj, struct nl_dump_params *p)
{
	struct rtnl_addr *addr = (struct rtnl_addr *) obj;
	struct nl_cache *link_cache;
	char buf[128];
	int line = 0;

	dp_dump_line(p, line++, "ADDR_FAMILY=%s\n",
		     nl_af2str(addr->a_family, buf, sizeof(buf)));

	if (addr->ce_mask & ADDR_ATTR_LOCAL)
		dp_dump_line(p, line++, "ADDR_LOCAL=%s\n",
			     nl_addr2str(addr->a_local, buf, sizeof(buf)));

	if (addr->ce_mask & ADDR_ATTR_PEER)
		dp_dump_line(p, line++, "ADDR_PEER=%s\n",
			     nl_addr2str(addr->a_peer, buf, sizeof(buf)));

	if (addr->ce_mask & ADDR_ATTR_BROADCAST)
		dp_dump_line(p, line++, "ADDR_BROADCAST=%s\n",
			     nl_addr2str(addr->a_bcast, buf, sizeof(buf)));

	if (addr->ce_mask & ADDR_ATTR_ANYCAST)
		dp_dump_line(p, line++, "ADDR_ANYCAST=%s\n",
			     nl_addr2str(addr->a_anycast, buf, sizeof(buf)));

	if (addr->ce_mask & ADDR_ATTR_MULTICAST)
		dp_dump_line(p, line++, "ADDR_MULTICAST=%s\n",
			     nl_addr2str(addr->a_multicast, buf,
					   sizeof(buf)));

	if (addr->ce_mask & ADDR_ATTR_PREFIXLEN)
		dp_dump_line(p, line++, "ADDR_PREFIXLEN=%u\n",
			     addr->a_prefixlen);
	link_cache = nl_cache_mngt_require("route/link");

	dp_dump_line(p, line++, "ADDR_IFINDEX=%u\n", addr->a_ifindex);
	if (link_cache)
		dp_dump_line(p, line++, "ADDR_IFNAME=%s\n",
			     rtnl_link_i2name(link_cache, addr->a_ifindex,
			     		      buf, sizeof(buf)));

	if (addr->ce_mask & ADDR_ATTR_SCOPE)
		dp_dump_line(p, line++, "ADDR_SCOPE=%s\n",
			     rtnl_scope2str(addr->a_scope, buf, sizeof(buf)));

	if (addr->ce_mask & ADDR_ATTR_LABEL)
		dp_dump_line(p, line++, "ADDR_LABEL=%s\n", addr->a_label);

	rtnl_addr_flags2str(addr->a_flags, buf, sizeof(buf));
	if (buf[0])
		dp_dump_line(p, line++, "ADDR_FLAGS=%s\n", buf);

	if (addr->ce_mask & ADDR_ATTR_CACHEINFO) {
		struct rtnl_addr_cacheinfo *ci = &addr->a_cacheinfo;

		dp_dump_line(p, line++, "ADDR_CACHEINFO_VALID=%s\n",
			     ci->aci_valid == 0xFFFFFFFFU ? "forever" :
			     nl_msec2str(ci->aci_valid * 1000,
					   buf, sizeof(buf)));

		dp_dump_line(p, line++, "ADDR_CACHEINFO_PREFERED=%s\n",
			     ci->aci_prefered == 0xFFFFFFFFU ? "forever" :
			     nl_msec2str(ci->aci_prefered * 1000,
					 buf, sizeof(buf)));

		dp_dump_line(p, line++, "ADDR_CACHEINFO_CREATED=%s\n",
			     nl_msec2str(addr->a_cacheinfo.aci_cstamp * 10,
					 buf, sizeof(buf)));

		dp_dump_line(p, line++, "ADDR_CACHEINFO_LASTUPDATE=%s\n",
			     nl_msec2str(addr->a_cacheinfo.aci_tstamp * 10,
					 buf, sizeof(buf)));
	}

	return line;
}
コード例 #8
0
ファイル: rule.c プロジェクト: DINKIN/tuo
static int rule_dump_env(struct nl_object *obj, struct nl_dump_params *p)
{
	struct rtnl_rule *rule = (struct rtnl_rule *) obj;
	char buf[128];
	int line = 0;

	dp_dump_line(p, line++, "RULE_PRIORITY=%u\n",
		     rule->r_prio);
	dp_dump_line(p, line++, "RULE_FAMILY=%s\n",
		     nl_af2str(rule->r_family, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_DST)
		dp_dump_line(p, line++, "RULE_DST=%s\n",
			     nl_addr2str(rule->r_dst, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_DST_LEN)
		dp_dump_line(p, line++, "RULE_DSTLEN=%u\n",
			     rule->r_dst_len);

	if (rule->ce_mask & RULE_ATTR_SRC)
		dp_dump_line(p, line++, "RULE_SRC=%s\n",
			     nl_addr2str(rule->r_src, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_SRC_LEN)
		dp_dump_line(p, line++, "RULE_SRCLEN=%u\n",
			     rule->r_src_len);

	if (rule->ce_mask & RULE_ATTR_IIF)
		dp_dump_line(p, line++, "RULE_IIF=%s\n", rule->r_iif);

	if (rule->ce_mask & RULE_ATTR_TABLE)
		dp_dump_line(p, line++, "RULE_TABLE=%u\n",
			     rule->r_table);

	if (rule->ce_mask & RULE_ATTR_REALMS)
		dp_dump_line(p, line++, "RULE_REALM=%u\n",
			     rule->r_realms);

	if (rule->ce_mask & RULE_ATTR_MARK)
		dp_dump_line(p, line++, "RULE_MARK=0x%" PRIx64 "\n",
			     rule->r_mark);

	if (rule->ce_mask & RULE_ATTR_DSFIELD)
		dp_dump_line(p, line++, "RULE_DSFIELD=%u\n",
			     rule->r_dsfield);

	if (rule->ce_mask & RULE_ATTR_TYPE)
		dp_dump_line(p, line++, "RULE_TYPE=%s\n",
			     nl_rtntype2str(rule->r_type, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_SRCMAP)
		dp_dump_line(p, line++, "RULE_SRCMAP=%s\n",
			     nl_addr2str(rule->r_srcmap, buf, sizeof(buf)));

	return line;
}
コード例 #9
0
ファイル: rule.c プロジェクト: DINKIN/tuo
static int rule_dump_xml(struct nl_object *obj, struct nl_dump_params *p)
{
	struct rtnl_rule *rule = (struct rtnl_rule *) obj;
	char buf[128];
	int line = 0;
	
	dp_dump_line(p, line++, "<rule>\n");

	dp_dump_line(p, line++, "  <priority>%u</priority>\n",
		     rule->r_prio);
	dp_dump_line(p, line++, "  <family>%s</family>\n",
		     nl_af2str(rule->r_family, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_DST)
		dp_dump_line(p, line++, "  <dst>%s</dst>\n",
			     nl_addr2str(rule->r_dst, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_DST_LEN)
		dp_dump_line(p, line++, "  <dstlen>%u</dstlen>\n",
			     rule->r_dst_len);

	if (rule->ce_mask & RULE_ATTR_SRC)
		dp_dump_line(p, line++, "  <src>%s</src>\n",
			     nl_addr2str(rule->r_src, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_SRC_LEN)
		dp_dump_line(p, line++, "  <srclen>%u</srclen>\n",
			     rule->r_src_len);

	if (rule->ce_mask & RULE_ATTR_IIF)
		dp_dump_line(p, line++, "  <iif>%s</iif>\n", rule->r_iif);

	if (rule->ce_mask & RULE_ATTR_TABLE)
		dp_dump_line(p, line++, "  <table>%u</table>\n",
			     rule->r_table);

	if (rule->ce_mask & RULE_ATTR_REALMS)
		dp_dump_line(p, line++, "  <realms>%u</realms>\n",
			     rule->r_realms);

	if (rule->ce_mask & RULE_ATTR_MARK)
		dp_dump_line(p, line++, "  <mark>%" PRIx64 "</mark>\n",
			     rule->r_mark);

	if (rule->ce_mask & RULE_ATTR_DSFIELD)
		dp_dump_line(p, line++, "  <dsfield>%u</dsfield>\n",
			     rule->r_dsfield);

	if (rule->ce_mask & RULE_ATTR_TYPE)
		dp_dump_line(p, line++, "<type>%s</type>\n",
			     nl_rtntype2str(rule->r_type, buf, sizeof(buf)));

	if (rule->ce_mask & RULE_ATTR_SRCMAP)
		dp_dump_line(p, line++, "<srcmap>%s</srcmap>\n",
			     nl_addr2str(rule->r_srcmap, buf, sizeof(buf)));

	dp_dump_line(p, line++, "</rule>\n");

	return line;
}