Ejemplo n.º 1
0
static void rule_dump_line(struct nl_object *o, struct nl_dump_params *p)
{
	struct rtnl_rule *r = (struct rtnl_rule *) o;
	char buf[128];

	nl_dump_line(p, "%8d ", (r->ce_mask & RULE_ATTR_PRIO) ? r->r_prio : 0);
	nl_dump(p, "%s ", nl_af2str(r->r_family, buf, sizeof(buf)));

	if (r->ce_mask & RULE_ATTR_SRC)
		nl_dump(p, "from %s ",
			nl_addr2str(r->r_src, buf, sizeof(buf)));

	if (r->ce_mask & RULE_ATTR_DST)
		nl_dump(p, "to %s ",
			nl_addr2str(r->r_dst, buf, sizeof(buf)));

	if (r->ce_mask & RULE_ATTR_DSFIELD)
		nl_dump(p, "tos %u ", r->r_dsfield);

	if (r->ce_mask & (RULE_ATTR_MARK | RULE_ATTR_MASK))
		nl_dump(p, "mark %#x/%#x", r->r_mark, r->r_mask);

	if (r->ce_mask & RULE_ATTR_IIFNAME)
		nl_dump(p, "iif %s ", r->r_iifname);

	if (r->ce_mask & RULE_ATTR_OIFNAME)
		nl_dump(p, "oif %s ", r->r_oifname);

	if (r->ce_mask & RULE_ATTR_TABLE)
		nl_dump(p, "lookup %s ",
			rtnl_route_table2str(r->r_table, buf, sizeof(buf)));

	if (r->ce_mask & RULE_ATTR_FLOW)
		nl_dump(p, "flow %s ",
			rtnl_realms2str(r->r_flow, buf, sizeof(buf)));

	if (r->ce_mask & RULE_ATTR_GOTO)
		nl_dump(p, "goto %u ", r->r_goto);

	if (r->ce_mask & RULE_ATTR_ACTION)
		nl_dump(p, "action %s",
			nl_rtntype2str(r->r_action, buf, sizeof(buf)));

	nl_dump(p, "\n");
}
Ejemplo n.º 2
0
Archivo: rule.c Proyecto: DINKIN/tuo
static int rule_dump_brief(struct nl_object *o, struct nl_dump_params *p)
{
	struct rtnl_rule *r = (struct rtnl_rule *) o;
	char buf[128];

	if (r->ce_mask & RULE_ATTR_PRIO)
		dp_dump(p, "%d:\t", r->r_prio);
	else
		dp_dump(p, "0:\t");

	if (r->ce_mask & RULE_ATTR_SRC)
		dp_dump(p, "from %s ",
			nl_addr2str(r->r_src, buf, sizeof(buf)));
	else if (r->ce_mask & RULE_ATTR_SRC_LEN && r->r_src_len)
		dp_dump(p, "from 0/%d ", r->r_src_len);

	if (r->ce_mask & RULE_ATTR_DST)
		dp_dump(p, "to %s ",
			nl_addr2str(r->r_dst, buf, sizeof(buf)));
	else if (r->ce_mask & RULE_ATTR_DST_LEN && r->r_dst_len)
		dp_dump(p, "to 0/%d ", r->r_dst_len);

	if (r->ce_mask & RULE_ATTR_DSFIELD && r->r_dsfield)
		dp_dump(p, "tos %d ", r->r_dsfield);

	if (r->ce_mask & RULE_ATTR_MARK)
		dp_dump(p, "mark %" PRIx64 , r->r_mark);

	if (r->ce_mask & RULE_ATTR_IIF)
		dp_dump(p, "iif %s ", r->r_iif);

	if (r->ce_mask & RULE_ATTR_TABLE)
		dp_dump(p, "lookup %s ",
			rtnl_route_table2str(r->r_table, buf, sizeof(buf)));

	if (r->ce_mask & RULE_ATTR_REALMS)
		dp_dump(p, "realms %s ",
			rtnl_realms2str(r->r_realms, buf, sizeof(buf)));

	dp_dump(p, "action %s\n",
		nl_rtntype2str(r->r_type, buf, sizeof(buf)));

	return 1;
}
Ejemplo n.º 3
0
static void rule_dump_line(struct nl_object *o, struct nl_dump_params *p)
{
	struct rtnl_rule *r = (struct rtnl_rule *) o;
	char buf[128];

	nl_dump_line(p, "%8d ", (r->ce_mask & RULE_ATTR_PRIO) ? r->r_prio : 0);
	nl_dump(p, "%s ", nl_af2str(r->r_family, buf, sizeof(buf)));

	if (r->ce_mask & RULE_ATTR_SRC)
		nl_dump(p, "from %s ",
			nl_addr2str(r->r_src, buf, sizeof(buf)));
	else if (r->ce_mask & RULE_ATTR_SRC_LEN && r->r_src_len)
		nl_dump(p, "from 0/%d ", r->r_src_len);

	if (r->ce_mask & RULE_ATTR_DST)
		nl_dump(p, "to %s ",
			nl_addr2str(r->r_dst, buf, sizeof(buf)));
	else if (r->ce_mask & RULE_ATTR_DST_LEN && r->r_dst_len)
		nl_dump(p, "to 0/%d ", r->r_dst_len);

	if (r->ce_mask & RULE_ATTR_DSFIELD && r->r_dsfield)
		nl_dump(p, "tos %d ", r->r_dsfield);

	if (r->ce_mask & RULE_ATTR_MARK)
		nl_dump(p, "mark %" PRIx64 , r->r_mark);

	if (r->ce_mask & RULE_ATTR_IIF)
		nl_dump(p, "iif %s ", r->r_iif);

	if (r->ce_mask & RULE_ATTR_TABLE)
		nl_dump(p, "lookup %s ",
			rtnl_route_table2str(r->r_table, buf, sizeof(buf)));

	if (r->ce_mask & RULE_ATTR_REALMS)
		nl_dump(p, "realms %s ",
			rtnl_realms2str(r->r_realms, buf, sizeof(buf)));

	nl_dump(p, "action %s\n",
		nl_rtntype2str(r->r_type, buf, sizeof(buf)));
}