static int tcindex_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle) { struct rtattr *tb[TCA_TCINDEX_MAX+1]; if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_TCINDEX_MAX, opt); if (handle != ~0) fprintf(f, "handle 0x%04x ", handle); if (tb[TCA_TCINDEX_HASH]) { __u16 hash; if (RTA_PAYLOAD(tb[TCA_TCINDEX_HASH]) < sizeof(hash)) return -1; hash = rta_getattr_u16(tb[TCA_TCINDEX_HASH]); fprintf(f, "hash %d ", hash); } if (tb[TCA_TCINDEX_MASK]) { __u16 mask; if (RTA_PAYLOAD(tb[TCA_TCINDEX_MASK]) < sizeof(mask)) return -1; mask = rta_getattr_u16(tb[TCA_TCINDEX_MASK]); fprintf(f, "mask 0x%04x ", mask); } if (tb[TCA_TCINDEX_SHIFT]) { int shift; if (RTA_PAYLOAD(tb[TCA_TCINDEX_SHIFT]) < sizeof(shift)) return -1; shift = *(int *) RTA_DATA(tb[TCA_TCINDEX_SHIFT]); fprintf(f, "shift %d ", shift); } if (tb[TCA_TCINDEX_FALL_THROUGH]) { int fall_through; if (RTA_PAYLOAD(tb[TCA_TCINDEX_FALL_THROUGH]) < sizeof(fall_through)) return -1; fall_through = *(int *) RTA_DATA(tb[TCA_TCINDEX_FALL_THROUGH]); fprintf(f, fall_through ? "fall_through " : "pass_on "); } if (tb[TCA_TCINDEX_CLASSID]) { SPRINT_BUF(b1); fprintf(f, "classid %s ", sprint_tc_classid(*(__u32 *) RTA_DATA(tb[TCA_TCINDEX_CLASSID]), b1)); } if (tb[TCA_TCINDEX_POLICE]) { fprintf(f, "\n"); tc_print_police(f, tb[TCA_TCINDEX_POLICE]); } if (tb[TCA_TCINDEX_ACT]) { fprintf(f, "\n"); tc_print_police(f, tb[TCA_TCINDEX_ACT]); } return 0; }
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) fprintf(f, "handle 0x%x ", handle); if (tb[TCA_FW_CLASSID]) { SPRINT_BUF(b1); fprintf(f, "classid %s ", sprint_tc_classid(*(__u32*)RTA_DATA(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 ",(char *)RTA_DATA(idev)); } if (tb[TCA_FW_ACT]) { fprintf(f, "\n"); tc_print_action(f, tb[TCA_FW_ACT]); } return 0; }
static int basic_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle) { struct rtattr *tb[TCA_BASIC_MAX+1]; if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_BASIC_MAX, opt); if (handle) fprintf(f, "handle 0x%x ", handle); if (tb[TCA_BASIC_CLASSID]) { SPRINT_BUF(b1); fprintf(f, "flowid %s ", sprint_tc_classid(rta_getattr_u32(tb[TCA_BASIC_CLASSID]), b1)); } if (tb[TCA_BASIC_EMATCHES]) print_ematch(f, tb[TCA_BASIC_EMATCHES]); if (tb[TCA_BASIC_POLICE]) { fprintf(f, "\n"); tc_print_police(f, tb[TCA_BASIC_POLICE]); } if (tb[TCA_BASIC_ACT]) { tc_print_action(f, tb[TCA_BASIC_ACT]); } return 0; }
static int cgroup_print_opt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 handle) { struct rtattr *tb[TCA_CGROUP_MAX+1]; if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_CGROUP_MAX, opt); if (handle) fprintf(f, "handle 0x%x ", handle); if (tb[TCA_CGROUP_EMATCHES]) print_ematch(f, tb[TCA_CGROUP_EMATCHES]); if (tb[TCA_CGROUP_POLICE]) { fprintf(f, "\n"); tc_print_police(f, tb[TCA_CGROUP_POLICE]); } if (tb[TCA_CGROUP_ACT]) tc_print_action(f, tb[TCA_CGROUP_ACT]); return 0; }
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 = *(__u32*)RTA_DATA(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_FMASK]) { __u32 mask = 0, shift = 0; mask = *(__u32*)RTA_DATA(tb[TCA_FW_FMASK]); if (tb[TCA_FW_FSHIFT] && (shift = *(__u32*)RTA_DATA(tb[TCA_FW_FSHIFT])) != 0x0) fprintf(f, "mask 0x%x/0x%x ", mask, shift); else fprintf(f, "mask 0x%x ", mask); } if (tb[TCA_FW_CLASSID]) { SPRINT_BUF(b1); fprintf(f, "classid %s ", sprint_tc_classid(*(__u32*)RTA_DATA(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 ",(char *)RTA_DATA(idev)); } if (tb[TCA_FW_ACT]) { fprintf(f, "\n"); tc_print_action(f, tb[TCA_FW_ACT]); } 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; }