static int fw_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle) { struct rtattr *tb[TCA_FW_MAX+1]; if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_FW_MAX, opt); if (handle || tb[TCA_FW_MASK]) { __u32 mark = 0, mask = 0; if(handle) mark = handle; if(tb[TCA_FW_MASK] && (mask = rta_getattr_u32(tb[TCA_FW_MASK])) != 0xFFFFFFFF) fprintf(f, "handle 0x%x/0x%x ", mark, mask); else fprintf(f, "handle 0x%x ", handle); } if (tb[TCA_FW_CLASSID]) { SPRINT_BUF(b1); fprintf(f, "classid %s ", sprint_tc_classid(rta_getattr_u32(tb[TCA_FW_CLASSID]), b1)); } if (tb[TCA_FW_POLICE]) tc_print_police(f, tb[TCA_FW_POLICE]); if (tb[TCA_FW_INDEV]) { struct rtattr *idev = tb[TCA_FW_INDEV]; fprintf(f, "input dev %s ",rta_getattr_str(idev)); } if (tb[TCA_FW_ACT]) { fprintf(f, "\n"); tc_print_action(f, tb[TCA_FW_ACT]); } return 0; }
static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg) { struct rtattr *tb[TCA_SKBEDIT_MAX + 1]; SPRINT_BUF(b1); __u32 *priority; __u32 *mark; __u16 *queue_mapping, *ptype; struct tc_skbedit *p = NULL; if (arg == NULL) return -1; parse_rtattr_nested(tb, TCA_SKBEDIT_MAX, arg); if (tb[TCA_SKBEDIT_PARMS] == NULL) { fprintf(f, "[NULL skbedit parameters]"); return -1; } p = RTA_DATA(tb[TCA_SKBEDIT_PARMS]); fprintf(f, " skbedit"); if (tb[TCA_SKBEDIT_QUEUE_MAPPING] != NULL) { queue_mapping = RTA_DATA(tb[TCA_SKBEDIT_QUEUE_MAPPING]); fprintf(f, " queue_mapping %u", *queue_mapping); } if (tb[TCA_SKBEDIT_PRIORITY] != NULL) { priority = RTA_DATA(tb[TCA_SKBEDIT_PRIORITY]); fprintf(f, " priority %s", sprint_tc_classid(*priority, b1)); } if (tb[TCA_SKBEDIT_MARK] != NULL) { mark = RTA_DATA(tb[TCA_SKBEDIT_MARK]); fprintf(f, " mark %d", *mark); } if (tb[TCA_SKBEDIT_PTYPE] != NULL) { ptype = RTA_DATA(tb[TCA_SKBEDIT_PTYPE]); if (*ptype == PACKET_HOST) fprintf(f, " ptype host"); else if (*ptype == PACKET_BROADCAST) fprintf(f, " ptype broadcast"); else if (*ptype == PACKET_MULTICAST) fprintf(f, " ptype multicast"); else if (*ptype == PACKET_OTHERHOST) fprintf(f, " ptype otherhost"); else fprintf(f, " ptype %d", *ptype); } print_action_control(f, " ", p->action, ""); fprintf(f, "\n\t index %u ref %d bind %d", p->index, p->refcnt, p->bindcnt); if (show_stats) { if (tb[TCA_SKBEDIT_TM]) { struct tcf_t *tm = RTA_DATA(tb[TCA_SKBEDIT_TM]); print_tm(f, tm); } } fprintf(f, "\n "); return 0; }
static int flow_print_opt(struct filter_util *fu, FILE *f, struct rtattr *opt, __u32 handle) { struct rtattr *tb[TCA_FLOW_MAX+1]; SPRINT_BUF(b1); unsigned int i; __u32 mask = ~0, val = 0; if (opt == NULL) return -EINVAL; parse_rtattr_nested(tb, TCA_FLOW_MAX, opt); fprintf(f, "handle 0x%x ", handle); if (tb[TCA_FLOW_MODE]) { __u32 mode = *(__u32 *)RTA_DATA(tb[TCA_FLOW_MODE]); switch (mode) { case FLOW_MODE_MAP: fprintf(f, "map "); break; case FLOW_MODE_HASH: fprintf(f, "hash "); break; } } if (tb[TCA_FLOW_KEYS]) { __u32 keymask = *(__u32 *)RTA_DATA(tb[TCA_FLOW_KEYS]); char *sep = ""; fprintf(f, "keys "); for (i = 0; i <= FLOW_KEY_MAX; i++) { if (keymask & (1 << i)) { fprintf(f, "%s%s", sep, flow_keys[i]); sep = ","; } } fprintf(f, " "); } if (tb[TCA_FLOW_MASK]) mask = *(__u32 *)RTA_DATA(tb[TCA_FLOW_MASK]); if (tb[TCA_FLOW_XOR]) val = *(__u32 *)RTA_DATA(tb[TCA_FLOW_XOR]); if (mask != ~0 || val != 0) { __u32 or = (mask & val) ^ val; __u32 xor = mask & val; if (mask != ~0) fprintf(f, "and 0x%.8x ", mask); if (xor != 0) fprintf(f, "xor 0x%.8x ", xor); if (or != 0) fprintf(f, "or 0x%.8x ", or); } if (tb[TCA_FLOW_RSHIFT]) fprintf(f, "rshift %u ", *(__u32 *)RTA_DATA(tb[TCA_FLOW_RSHIFT])); if (tb[TCA_FLOW_ADDEND]) fprintf(f, "addend 0x%x ", *(__u32 *)RTA_DATA(tb[TCA_FLOW_ADDEND])); if (tb[TCA_FLOW_DIVISOR]) fprintf(f, "divisor %u ", *(__u32 *)RTA_DATA(tb[TCA_FLOW_DIVISOR])); if (tb[TCA_FLOW_BASECLASS]) fprintf(f, "baseclass %s ", sprint_tc_classid(*(__u32 *)RTA_DATA(tb[TCA_FLOW_BASECLASS]), b1)); if (tb[TCA_FLOW_PERTURB]) fprintf(f, "perturb %usec ", *(__u32 *)RTA_DATA(tb[TCA_FLOW_PERTURB])); if (tb[TCA_FLOW_EMATCHES]) print_ematch(f, tb[TCA_FLOW_EMATCHES]); if (tb[TCA_FLOW_POLICE]) tc_print_police(f, tb[TCA_FLOW_POLICE]); if (tb[TCA_FLOW_ACT]) { fprintf(f, "\n"); tc_print_action(f, tb[TCA_FLOW_ACT]); } return 0; }