Ejemplo n.º 1
0
static void HMARK_ip4_save(const void *ip, const struct xt_entry_target *target)
{
	const struct xt_hmark_info *info =
		(const struct xt_hmark_info *)target->data;
	int ret;

	if (info->flags & XT_HMARK_FLAG(XT_HMARK_SADDR_MASK)) {
		ret = xtables_ipmask_to_cidr(&info->src_mask.in);
		printf(" --hmark-src-prefix %d", ret);
	}
	if (info->flags & XT_HMARK_FLAG(XT_HMARK_DADDR_MASK)) {
		ret = xtables_ipmask_to_cidr(&info->dst_mask.in);
		printf(" --hmark-dst-prefix %d", ret);
	}
	HMARK_save(info);
}
Ejemplo n.º 2
0
static void HMARK_ip4_print(const void *ip,
			    const struct xt_entry_target *target, int numeric)
{
	const struct xt_hmark_info *info =
		(const struct xt_hmark_info *)target->data;

	printf(" HMARK ");
	if (info->flags & XT_HMARK_FLAG(XT_HMARK_MODULUS))
		printf("mod %u ", info->hmodulus);
	if (info->flags & XT_HMARK_FLAG(XT_HMARK_OFFSET))
		printf("+ 0x%x ", info->hoffset);
	if (info->flags & XT_HMARK_FLAG(XT_HMARK_CT))
		printf("ct, ");
	if (info->flags & XT_HMARK_FLAG(XT_HMARK_SADDR_MASK))
		printf("src-prefix %u ",
		       xtables_ipmask_to_cidr(&info->src_mask.in));
	if (info->flags & XT_HMARK_FLAG(XT_HMARK_DADDR_MASK))
		printf("dst-prefix %u ",
		       xtables_ipmask_to_cidr(&info->dst_mask.in));
	HMARK_print(info);
}
Ejemplo n.º 3
0
const char *xtables_ipmask_to_numeric(const struct in_addr *mask)
{
	static char buf[20];
	uint32_t cidr;

	cidr = xtables_ipmask_to_cidr(mask);
	if (cidr < 0) {
		/* mask was not a decent combination of 1's and 0's */
		sprintf(buf, "/%s", xtables_ipaddr_to_numeric(mask));
		return buf;
	} else if (cidr == 32) {
		/* we don't want to see "/32" */
		return "";
	}

	sprintf(buf, "/%d", cidr);
	return buf;
}