コード例 #1
0
ファイル: conf.c プロジェクト: northshorenetworks/NSWall
void conf_ifmetrics(FILE *output, int ifs, struct if_data if_data,
    char *ifname)
{
	char tmpa[IPSIZ], tmpb[IPSIZ], tmpc[TMPSIZ];

	/*
	 * Various metrics valid for non-bridge interfaces
	 */
	if (phys_status(ifs, ifname, tmpa, tmpb, IPSIZ, IPSIZ) > 0)
		/* future os may use this for more than tunnel? */
		fprintf(output, " tunnel %s %s\n", tmpa, tmpb);

	/*
	 * print interface mtu, metric
	 *
	 * ignore interfaces named "pfsync" since their mtu
	 * is dynamic and controlled by the kernel
	 */
	if (!MIN_ARG(ifname, "pfsync") && (if_mtu != default_mtu(ifname) &&
	    default_mtu(ifname) != MTU_IGNORE))
		fprintf(output, " mtu %u\n", if_mtu);
	if (if_metric)
		fprintf(output, " metric %u\n", if_metric);

	if (get_nwinfo(ifname, tmpc, TMPSIZ, NWID) != 0) {
		fprintf(output, " nwid %s\n", tmpc);
		if (get_nwinfo(ifname, tmpc, TMPSIZ, NWKEY) != 0)
			fprintf(output, " nwkey %s\n", tmpc);
		if (get_nwinfo(ifname, tmpc, TMPSIZ, TXPOWER) != 0)
			fprintf(output, " txpower %s\n", tmpc);
		if (get_nwinfo(ifname, tmpc, TMPSIZ, POWERSAVE) != 0)
			fprintf(output, " powersave %s\n", tmpc);
	}
}
コード例 #2
0
ファイル: conf.c プロジェクト: rheoli/nsh
void conf_ifmetrics(FILE *output, int ifs, struct if_data if_data,
    char *ifname)
{
	int vnetid;
	int dstport;
	char tmpa[IPSIZ], tmpb[IPSIZ], tmpc[TMPSIZ];
	struct ifreq ifrpriority;

	/*
	 * Various metrics for non-bridge interfaces
	 */
	if ((dstport=
	    phys_status(ifs, ifname, tmpa, tmpb, IPSIZ, IPSIZ)) >= 0) {
		int physrt, physttl;

		fprintf(output, " tunnel %s %s", tmpa, tmpb);
		if (dstport > 0)
			fprintf(output, ":%i", dstport);
		if (((physrt = conf_physrtable(ifs, ifname)) != 0))
			fprintf(output, " rdomain %i", physrt);
		if (((physttl = conf_physttl(ifs, ifname)) != 0))
			fprintf(output, " ttl %i", physttl);
		fprintf(output, "\n");
	}

	if (((vnetid = conf_vnetid(ifs, ifname)) != 0))
			fprintf(output, " vnetid %i\n", vnetid);

	/*
	 * print interface mtu, metric
	 *
	 * ignore interfaces named "pfsync" since their mtu
	 * is dynamic and controlled by the kernel
	 */
	if (!MIN_ARG(ifname, "pfsync") &&
	    (if_data.ifi_mtu != default_mtu(ifname) &&
	    default_mtu(ifname) != MTU_IGNORE) && if_data.ifi_mtu != 0)
		fprintf(output, " mtu %u\n", if_data.ifi_mtu);
	if (if_data.ifi_metric)
		fprintf(output, " metric %u\n", if_data.ifi_metric);

	strlcpy(ifrpriority.ifr_name, ifname, IFNAMSIZ);
	if (ioctl(ifs, SIOCGIFPRIORITY, (caddr_t)&ifrpriority) == 0)
		if(ifrpriority.ifr_metric)
			fprintf(output, " priority %u\n",
			    ifrpriority.ifr_metric);

	if (get_nwinfo(ifname, tmpc, TMPSIZ, NWID) != 0) {
		fprintf(output, " nwid %s\n", tmpc);
		if (get_nwinfo(ifname, tmpc, TMPSIZ, NWKEY) != 0)
			fprintf(output, " nwkey %s\n", tmpc);
		if (get_nwinfo(ifname, tmpc, TMPSIZ, TXPOWER) != 0)
			fprintf(output, " txpower %s\n", tmpc);
		if (get_nwinfo(ifname, tmpc, TMPSIZ, POWERSAVE) != 0)
			fprintf(output, " powersave %s\n", tmpc);
	}
}
コード例 #3
0
ファイル: if.c プロジェクト: northshorenetworks/NSWall
int
intmtu(char *ifname, int ifs, int argc, char **argv)
{
	struct ifreq ifr;
	int set;
	const char *errmsg = NULL;

	if (NO_ARG(argv[0])) {
		set = 0;
		argc--;
		argv++;
	} else
		set = 1;

	argc--;
	argv++;

	if ((!set && argc > 1) || (set && argc != 1)) {
		printf("%% mtu <mtu>\n");
		printf("%% no mtu [mtu]\n");
		return(0);
	}

	if (set) {
		ifr.ifr_mtu = strtonum(argv[0], 0, INT_MAX, &errmsg);
		if (errmsg) {
			printf("%% Invalid MTU %s: %s\n", argv[0], errmsg);
			return(0);
		}
	} else
		ifr.ifr_mtu = default_mtu(ifname);

	strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
	if (ioctl(ifs, SIOCSIFMTU, (caddr_t)&ifr) < 0)
		printf("%% intmtu: SIOCSIFMTU: %s\n", strerror(errno));

	return(0);
}