static void ipaddr_mt4_print(const void *entry,
		const struct xt_entry_match *match, int numeric)
{
	const struct xt_ipaddr_mtinfo *info = (const void *)match->data;

	if (info->flags & XT_IPADDR_SRC) {
		printf("src IP ");

		if (info->flags & XT_IPADDR_SRC_INV)
			printf("! ");

		if (numeric)
			printf("%s ", numeric ?
					xtables_ipaddr_to_numeric(&info->src.in) :
					xtables_ipaddr_to_anyname(&info->src.in));
	}

	if (info->flags & XT_IPADDR_DST) {
		printf("dst IP ");

		if (info->flags & XT_IPADDR_DST_INV)
			printf("! ");

		printf("%s ", numeric ?
				xtables_ipaddr_to_numeric(&info->dst.in):
				xtables_ipaddr_to_anyname(&info->dst.in));
	}
}
Beispiel #2
0
/* Shamelessly copied from libxt_conntrack.c */
static void ipvs_mt_dump_addr(const union nf_inet_addr *addr,
			      const union nf_inet_addr *mask,
			      unsigned int family, bool numeric)
{
	char buf[BUFSIZ];

	if (family == NFPROTO_IPV4) {
		if (!numeric && addr->ip == 0) {
			printf("anywhere ");
			return;
		}
		if (numeric)
			strcpy(buf, xtables_ipaddr_to_numeric(&addr->in));
		else
			strcpy(buf, xtables_ipaddr_to_anyname(&addr->in));
		strcat(buf, xtables_ipmask_to_numeric(&mask->in));
		printf("%s ", buf);
	} else if (family == NFPROTO_IPV6) {
		if (!numeric && addr->ip6[0] == 0 && addr->ip6[1] == 0 &&
		    addr->ip6[2] == 0 && addr->ip6[3] == 0) {
			printf("anywhere ");
			return;
		}
		if (numeric)
			strcpy(buf, xtables_ip6addr_to_numeric(&addr->in6));
		else
			strcpy(buf, xtables_ip6addr_to_anyname(&addr->in6));
		strcat(buf, xtables_ip6mask_to_numeric(&mask->in6));
		printf("%s ", buf);
	}
}
Beispiel #3
0
static void
conntrack_dump_addr(const union nf_inet_addr *addr,
                    const union nf_inet_addr *mask,
                    unsigned int family, bool numeric)
{
	if (family == NFPROTO_IPV4) {
		if (!numeric && addr->ip == 0) {
			printf("anywhere ");
			return;
		}
		if (numeric)
			printf("%s ", xtables_ipaddr_to_numeric(&addr->in));
		else
			printf("%s ", xtables_ipaddr_to_anyname(&addr->in));
	} else if (family == NFPROTO_IPV6) {
		if (!numeric && addr->ip6[0] == 0 && addr->ip6[1] == 0 &&
		    addr->ip6[2] == 0 && addr->ip6[3] == 0) {
			printf("anywhere ");
			return;
		}
		if (numeric)
			printf("%s ", xtables_ip6addr_to_numeric(&addr->in6));
		else
			printf("%s ", xtables_ip6addr_to_anyname(&addr->in6));
	}
}
Beispiel #4
0
static void tee_tg_print(const void *ip, const struct xt_entry_target *target,
                         int numeric)
{
	const struct xt_tee_tginfo *info = (const void *)target->data;

	if (numeric)
		printf(" TEE gw:%s", xtables_ipaddr_to_numeric(&info->gw.in));
	else
		printf(" TEE gw:%s", xtables_ipaddr_to_anyname(&info->gw.in));
	if (*info->oif != '\0')
		printf(" oif=%s", info->oif);
}
Beispiel #5
0
 void nat64_tg4_print(const void *entry,
		const struct xt_entry_target *target, int numeric)
{
	const struct xt_nat64_tginfo *info = (const void *)target->data;

	if (info->flags & XT_NAT64_IP_SRC) {
		printf("src IP ");

		if (numeric)
			printf("%s ", numeric ?
					xtables_ipaddr_to_numeric(&info->ipsrc.in) :
					xtables_ipaddr_to_anyname(&info->ipsrc.in));
	}

	if (info->flags & XT_NAT64_IP_DST) {
		printf("dst IP ");

		printf("%s ", numeric ?
				xtables_ipaddr_to_numeric(&info->ipdst.in):
				xtables_ipaddr_to_anyname(&info->ipdst.in));
	}
}
Beispiel #6
0
static int tee_tg_xlate(const void *ip, const struct xt_entry_target *target,
			struct xt_xlate *xl, int numeric)
{
	const struct xt_tee_tginfo *info =
		(const void *)target->data;

	if (numeric)
		xt_xlate_add(xl, "dup to %s",
			     xtables_ipaddr_to_numeric(&info->gw.in));
	else
		xt_xlate_add(xl, "dup to %s",
			     xtables_ipaddr_to_anyname(&info->gw.in));
	if (*info->oif != '\0')
		xt_xlate_add(xl, " device %s", info->oif);

	return 1;
}
Beispiel #7
0
static void
print_addr(struct in_addr *addr, struct in_addr *mask, int inv, int numeric)
{
	char buf[BUFSIZ];

	if (inv)
	       	printf("! ");

	if (mask->s_addr == 0L && !numeric)
		printf("%s ", "anywhere");
	else {
		if (numeric)
			strcpy(buf, xtables_ipaddr_to_numeric(addr));
		else
			strcpy(buf, xtables_ipaddr_to_anyname(addr));
		strcat(buf, xtables_ipmask_to_numeric(mask));
		printf("%s ", buf);
	}
}