Ejemplo n.º 1
0
int
out_cmdline(struct if_info *ifarg_cur, int v4args, struct misc_args m_argv4,
	    int v6args, struct misc_args m_argv6)
{
	int ret = 0;

	if ((v4args & V4CHECK) == V4CHECK || (v6args & V6CHECK) == V6CHECK) {
		if ((v4args & V4CHECK) == V4CHECK && strlen(ifarg_cur->p_v4addr) > 0) {
			if (get_addrv4(ifarg_cur) == 0)
				printf("%s\n", ifarg_cur->p_v4addr);
		} else if ((v6args & V6CHECK) == V6CHECK && strlen(ifarg_cur->p_v6addr) > 0) {
			if (get_addrv6(ifarg_cur) == 0)
				printf("%s\n", ifarg_cur->p_v6addr);
		}

		return 0;
	}

	if (ifarg_cur->type == IFT_V4)
		ret = get_addrv4(ifarg_cur);

	if (ifarg_cur->type == IFT_V6)
		ret = get_addrv6(ifarg_cur);

	if (ifarg_cur->type == IFT_INTV4 || ifarg_cur->type == IFT_INTV6) {
		if (ifarg_cur->errorstr[0] != 0) {
			warnx("Invalid address: %s", ifarg_cur->errorstr);
			return 0;
		}

		ret = get_addrv4(ifarg_cur);
	}

	if (ifarg_cur->type == IFT_UNKWN) {
		warnx("Unknown %s: %s", ifarg_cur->cmdstr, ifarg_cur->errorstr);
		return 0;
	}

	if (ret == -1) {
		warnx("Invalid address");
		return 0;
	}
	if (ret == -2) {
		warnx("Invalid netmask");
		return 0;
	}

	if (ifarg_cur->type == IFT_V4 || ifarg_cur->type == IFT_INTV4) {
		if (!v4args)
			v4args = V4_INFO;

		if ((v4args & V4_INFO) == V4_INFO)
			print_cf_info_v4(ifarg_cur);
		if ((v4args & V4SPLIT) == V4SPLIT)
			show_split_networks_v4(ifarg_cur, m_argv4.splitmask);
		if ((v4args & V4RANGE) == V4RANGE)
			show_network_ranges_v4(ifarg_cur, m_argv4.range_min, m_argv4.range_max);

		printf("\n");
	}

	if (ifarg_cur->type == IFT_V6 || ifarg_cur->type == IFT_INTV6) {
		if (!v6args)
			v6args = V6_INFO;

		if ((v6args & V6_INFO) == V6_INFO)
			print_v6(ifarg_cur);
		if ((v6args & V4INV6) == V4INV6)
			print_v4inv6(ifarg_cur);
		if ((v6args & V6REV) == V6REV)
			print_rev_v6(ifarg_cur);
		if ((v6args & V6SPLIT) == V6SPLIT)
			show_split_networks_v6(ifarg_cur, m_argv6.v6splitmask);

		printf("\n");
	}

	return 0;
}
Ejemplo n.º 2
0
int
out_cmdline(struct if_info *ifarg_cur, int v4args, struct misc_args m_argv4,
	    int v6args, struct misc_args m_argv6, int recurse, int index)
{
	int ret = 0;

	if (ifarg_cur->type == IFT_V4)
		ret = get_addrv4(ifarg_cur);

	if (ifarg_cur->type == IFT_V6)
		ret = get_addrv6(ifarg_cur);

	if (ifarg_cur->type == IFT_INTV4 || ifarg_cur->type == IFT_INTV6) {
		if (ifarg_cur->errorstr[0] != 0) {
			warnx("Invalid address: %s", ifarg_cur->errorstr);
			return 0;
		}

		ret = get_addrv4(ifarg_cur);
	}

	if (ifarg_cur->type == IFT_UNKWN) {
		warnx("Unknown %s: %s", ifarg_cur->cmdstr, ifarg_cur->errorstr);
		return 0;
	}

	if (ret == -1) {
		warnx("Invalid address");
		return 0;
	}
	if (ret == -2) {
		warnx("Invalid netmask");
		return 0;
	}

	if (ifarg_cur->type == IFT_V4 || ifarg_cur->type == IFT_INTV4) {
		if (!v4args)
			v4args = V4_INFO;

		if ((v4args & V4_INFO) == V4_INFO)
			print_cf_info_v4(ifarg_cur);
		if ((v4args & V4SPLIT) == V4SPLIT)
			show_split_networks_v4(ifarg_cur, m_argv4.splitmask, v4args, m_argv4);

		printf("\n");
	}

	if (ifarg_cur->type == IFT_V6 || ifarg_cur->type == IFT_INTV6) {
		if (!v6args)
			v6args = V6_INFO;

		if ((v6args & V6_INFO) == V6_INFO)
			print_v6(ifarg_cur);
		if ((v6args & V4INV6) == V4INV6)
			print_v4inv6(ifarg_cur);
		if ((v6args & V6REV) == V6REV)
			print_rev_v6(ifarg_cur);
		if ((v6args & V6SPLIT) == V6SPLIT)
			show_split_networks_v6(ifarg_cur, m_argv6.v6splitmask, v6args, m_argv6);

		printf("\n");
	}

	return 0;
}