CVS commit: src/sbin/ifconfig

2021-06-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 21 03:14:41 UTC 2021

Modified Files:
src/sbin/ifconfig: agr.c env.c lagg.c pfsync.c vlan.c

Log Message:
fix proplib deprecation


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/agr.c src/sbin/ifconfig/vlan.c
cvs rdiff -u -r1.13 -r1.14 src/sbin/ifconfig/env.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/ifconfig/lagg.c
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/pfsync.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/agr.c
diff -u src/sbin/ifconfig/agr.c:1.15 src/sbin/ifconfig/agr.c:1.16
--- src/sbin/ifconfig/agr.c:1.15	Tue Jul 15 17:27:58 2008
+++ src/sbin/ifconfig/agr.c	Sun Jun 20 23:14:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: agr.c,v 1.15 2008/07/15 21:27:58 dyoung Exp $	*/
+/*	$NetBSD: agr.c,v 1.16 2021/06/21 03:14:40 christos Exp $	*/
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: agr.c,v 1.15 2008/07/15 21:27:58 dyoung Exp $");
+__RCSID("$NetBSD: agr.c,v 1.16 2021/06/21 03:14:40 christos Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -101,7 +101,7 @@ agrsetport(prop_dictionary_t env, prop_d
 		return -1;
 	}
 
-	if (!prop_dictionary_get_cstring_nocopy(env, "agrport", )) {
+	if (!prop_dictionary_get_string(env, "agrport", )) {
 		warnx("%s.%d", __func__, __LINE__);
 		errno = ENOENT;
 		return -1;
Index: src/sbin/ifconfig/vlan.c
diff -u src/sbin/ifconfig/vlan.c:1.15 src/sbin/ifconfig/vlan.c:1.16
--- src/sbin/ifconfig/vlan.c:1.15	Fri Aug 16 06:33:17 2019
+++ src/sbin/ifconfig/vlan.c	Sun Jun 20 23:14:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vlan.c,v 1.15 2019/08/16 10:33:17 msaitoh Exp $	*/
+/*	$NetBSD: vlan.c,v 1.16 2021/06/21 03:14:40 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: vlan.c,v 1.15 2019/08/16 10:33:17 msaitoh Exp $");
+__RCSID("$NetBSD: vlan.c,v 1.16 2021/06/21 03:14:40 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -140,7 +140,7 @@ setvlanif(prop_dictionary_t env, prop_di
 	if (getvlan(env, , false) == -1)
 		err(EXIT_FAILURE, "%s: getsock", __func__);
 
-	if (!prop_dictionary_get_cstring_nocopy(env, "vlanif", )) {
+	if (!prop_dictionary_get_string(env, "vlanif", )) {
 		errno = ENOENT;
 		return -1;
 	}

Index: src/sbin/ifconfig/env.c
diff -u src/sbin/ifconfig/env.c:1.13 src/sbin/ifconfig/env.c:1.14
--- src/sbin/ifconfig/env.c:1.13	Sun Jun  7 02:02:58 2020
+++ src/sbin/ifconfig/env.c	Sun Jun 20 23:14:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: env.c,v 1.13 2020/06/07 06:02:58 thorpej Exp $	*/
+/*	$NetBSD: env.c,v 1.14 2021/06/21 03:14:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: env.c,v 1.13 2020/06/07 06:02:58 thorpej Exp $");
+__RCSID("$NetBSD: env.c,v 1.14 2021/06/21 03:14:40 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -122,7 +122,7 @@ getifname(prop_dictionary_t env)
 {
 	const char *s;
 
-	return prop_dictionary_get_cstring_nocopy(env, "if", ) ? s : NULL;
+	return prop_dictionary_get_string(env, "if", ) ? s : NULL;
 }
 
 ssize_t

Index: src/sbin/ifconfig/lagg.c
diff -u src/sbin/ifconfig/lagg.c:1.1 src/sbin/ifconfig/lagg.c:1.2
--- src/sbin/ifconfig/lagg.c:1.1	Mon May 17 00:07:42 2021
+++ src/sbin/ifconfig/lagg.c	Sun Jun 20 23:14:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lagg.c,v 1.1 2021/05/17 04:07:42 yamaguchi Exp $	*/
+/*	$NetBSD: lagg.c,v 1.2 2021/06/21 03:14:40 christos Exp $	*/
 
 /*
  * Copyright (c) 2021 Internet Initiative Japan Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #if !defined(lint)
-__RCSID("$NetBSD: lagg.c,v 1.1 2021/05/17 04:07:42 yamaguchi Exp $");
+__RCSID("$NetBSD: lagg.c,v 1.2 2021/06/21 03:14:40 christos Exp $");
 #endif /* !defined(lint) */
 
 #include 
@@ -391,7 +391,7 @@ setlaggport(prop_dictionary_t env, prop_
 	enum lagg_ioctl ioc;
 	int64_t lpcmd, pri;
 
-	if (!prop_dictionary_get_cstring_nocopy(env, "laggport", )) {
+	if (!prop_dictionary_get_string(env, "laggport", )) {
 		if (lagg_debug)
 			warnx("%s.%d", __func__, __LINE__);
 		errno = ENOENT;

Index: src/sbin/ifconfig/pfsync.c
diff -u src/sbin/ifconfig/pfsync.c:1.3 src/sbin/ifconfig/pfsync.c:1.4
--- src/sbin/ifconfig/pfsync.c:1.3	Sun Jun  7 02:02:58 2020
+++ src/sbin/ifconfig/pfsync.c	Sun Jun 20 23:14:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pfsync.c,v 1.3 2020/06/07 06:02:58 thorpej Exp $	*/
+/*	$NetBSD: pfsync.c,v 1.4 2021/06/21 03:14:40 christos Exp $	*/
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: pfsync.c,v 1.3 2020/06/07 06:02:58 thorpej Exp $");
+__RCSID("$NetBSD: pfsync.c,v 1.4 2021/06/21 03:14:40 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -155,7 +155,7 @@ setpfsyncdev(prop_dictionary_t env, prop
 	struct pfsyncreq pfsyncr;
 	const 

CVS commit: src/sbin/ifconfig

2021-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar  9 14:39:43 UTC 2021

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
PR/50933: Uwe Toenjes: Document hardware limitations


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.121 src/sbin/ifconfig/ifconfig.8:1.122
--- src/sbin/ifconfig/ifconfig.8:1.121	Tue Sep 29 04:52:11 2020
+++ src/sbin/ifconfig/ifconfig.8	Tue Mar  9 09:39:43 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.121 2020/09/29 08:52:11 msaitoh Exp $
+.\"	$NetBSD: ifconfig.8,v 1.122 2021/03/09 14:39:43 christos Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd September 29, 2020
+.Dd March 9, 2021
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -904,6 +904,14 @@ tried to alter an interface's configurat
 .\" .Xr eon 5 ,
 .Xr rc 8 ,
 .Xr routed 8
+.Sh BUGS
+Due to hardware limitations some of the capabilities cannot be turned on
+and off individually and need to be specified together.
+For example the
+.Xr ixg 4
+driver can't enable separately tcp and udp, or the transmit and receive
+checksumming capabilities.
+Unfortunately the diagnostic messages in this case are lacking.
 .Sh HISTORY
 The
 .Nm



CVS commit: src/sbin/ifconfig

2021-03-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Mar  1 16:47:48 UTC 2021

Modified Files:
src/sbin/ifconfig: Makefile.common

Log Message:
Make IEEE802.11 support optional


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/Makefile.common

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile.common
diff -u src/sbin/ifconfig/Makefile.common:1.5 src/sbin/ifconfig/Makefile.common:1.6
--- src/sbin/ifconfig/Makefile.common:1.5	Tue May  2 20:12:27 2017
+++ src/sbin/ifconfig/Makefile.common	Mon Mar  1 16:47:48 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.common,v 1.5 2017/05/02 20:12:27 christos Exp $
+#	$NetBSD: Makefile.common,v 1.6 2021/03/01 16:47:48 martin Exp $
 
 # shared stuff with src/distrib/utils/x_ifconfig for install media.
 # stuff not required by install media should be into Makefile.
@@ -11,8 +11,11 @@ DPADD+=		${LIBUTIL} ${LIBPROP}
 LDADD+=		-lutil -lprop
 
 INCS+=		af_inetany.h env.h extern.h media.h parse.h util.h
-SRCS+=		af_inet.c af_inetany.c env.c ether.c ieee80211.c \
+SRCS+=		af_inet.c af_inetany.c env.c ether.c \
 		ifconfig.c media.c parse.c tunnel.c util.c vlan.c
+.ifndef	NOIEEE80211
+SRCS+=		ieee80211.c
+.endif
 .ifndef SMALLPROG
 SRCS+=		agr.c l2tp.c
 .endif



CVS commit: src/sbin/ifconfig

2020-10-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Oct 14 13:37:14 UTC 2020

Modified Files:
src/sbin/ifconfig: ifconfig.c media.c media.h

Log Message:
ifconfig: go back to using direct ioctls rather than data from getifaddrs

AF_LINK may not be the first address returned for the interface.
Technically, it *might* not even exist on the interface even though
other families do.
This is likely a driver bug if this really is the case though.

As such it's just easier to use direct ioctls rather than thump around
getifaddrs results. As it stands, the code makes a lot of getifaddrs
calls anyway, so an extra ioctl or two won't break the bank.


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.248 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.12 -r1.13 src/sbin/ifconfig/media.c
cvs rdiff -u -r1.2 -r1.3 src/sbin/ifconfig/media.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.247 src/sbin/ifconfig/ifconfig.c:1.248
--- src/sbin/ifconfig/ifconfig.c:1.247	Mon Sep 28 13:50:22 2020
+++ src/sbin/ifconfig/ifconfig.c	Wed Oct 14 13:37:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.247 2020/09/28 13:50:22 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.248 2020/10/14 13:37:14 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.247 2020/09/28 13:50:22 roy Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.248 2020/10/14 13:37:14 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -135,8 +135,7 @@ static int setlinkstr(prop_dictionary_t,
 static int unsetlinkstr(prop_dictionary_t, prop_dictionary_t);
 static int setifdescr(prop_dictionary_t, prop_dictionary_t);
 static int unsetifdescr(prop_dictionary_t, prop_dictionary_t);
-static void status(const struct sockaddr_dl *, const void *,
-prop_dictionary_t, prop_dictionary_t);
+static void status(prop_dictionary_t, prop_dictionary_t);
 __dead static void usage(void);
 
 static const struct kwinst ifflagskw[] = {
@@ -850,9 +849,6 @@ void
 printall(const char *ifname, prop_dictionary_t env0)
 {
 	struct ifaddrs *ifap, *ifa;
-	struct ifreq ifr;
-	const struct sockaddr_dl *sdl = NULL;
-	const struct if_data *ifi = NULL;
 	prop_dictionary_t env, oenv;
 	int idx;
 	char *p;
@@ -872,19 +868,8 @@ printall(const char *ifname, prop_dictio
 	p = NULL;
 	idx = 0;
 	for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
-		memset(, 0, sizeof(ifr));
-		estrlcpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
-		if (sizeof(ifr.ifr_addr) >= ifa->ifa_addr->sa_len) {
-			memcpy(_addr, ifa->ifa_addr,
-			ifa->ifa_addr->sa_len);
-		}
-
 		if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0)
 			continue;
-		if (ifa->ifa_addr->sa_family == AF_LINK) {
-			sdl = (const struct sockaddr_dl *)ifa->ifa_addr;
-			ifi = (const struct if_data *)ifa->ifa_data;
-		}
 		if (p && strcmp(p, ifa->ifa_name) == 0)
 			continue;
 		if (!prop_dictionary_set_string(env, "if", ifa->ifa_name))
@@ -898,8 +883,7 @@ printall(const char *ifname, prop_dictio
 		if (uflag && (ifa->ifa_flags & IFF_UP) == 0)
 			continue;
 
-		if (sflag && (ifi == NULL ||
-		  ifi->ifi_link_state == LINK_STATE_DOWN))
+		if (sflag && carrier(env) == LINK_STATE_DOWN)
 			continue;
 		idx++;
 		/*
@@ -912,9 +896,7 @@ printall(const char *ifname, prop_dictio
 			continue;
 		}
 
-		status(sdl, ifa->ifa_data, env, oenv);
-		sdl = NULL;
-		ifi = NULL;
+		status(env, oenv);
 	}
 	if (lflag)
 		printf("\n");
@@ -1256,13 +1238,12 @@ print_human_bytes(bool humanize, uint64_
 #define MAX_PRINT_LEN 58	/* XXX need a better way to determine this! */
 
 void
-status(const struct sockaddr_dl *sdl, const void *ifa_data,
-prop_dictionary_t env, prop_dictionary_t oenv)
+status(prop_dictionary_t env, prop_dictionary_t oenv)
 {
-	const struct if_data *ifi = ifa_data;
 	status_func_t *status_f;
 	statistics_func_t *statistics_f;
 	struct ifdatareq ifdr;
+	struct if_data *ifi;
 	struct ifreq ifr;
 	struct ifdrv ifdrv;
 	char fbuf[BUFSIZ];
@@ -1351,18 +1332,16 @@ status(const struct sockaddr_dl *sdl, co
 		free(p);
 	}
 
-	media_status(sdl->sdl_type, ifi->ifi_link_state, env, oenv);
+	media_status(env, oenv);
 
 	if (!vflag && !zflag)
 		goto proto_status;
 
 	/* We already have if_data from SIOCGIFDATA in ifa_data. */
-	if (zflag) {
-		estrlcpy(ifdr.ifdr_name, ifname, sizeof(ifdr.ifdr_name));
-		if (prog_ioctl(s, SIOCZIFDATA, ) == -1)
-			err(EXIT_FAILURE, "SIOCZIFDATA");
-		ifi = _data;
-	}
+	estrlcpy(ifdr.ifdr_name, ifname, sizeof(ifdr.ifdr_name));
+	if (prog_ioctl(s, zflag ? SIOCZIFDATA : SIOCGIFDATA, ) == -1)
+		err(EXIT_FAILURE, zflag ? "SIOCZIFDATA" : "SIOCGIFDATA");
+	ifi = _data;
 
 	print_plural("\tinput: ", ifi->ifi_ipackets, "packet");
 	

CVS commit: src/sbin/ifconfig

2020-10-11 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sun Oct 11 21:32:37 UTC 2020

Modified Files:
src/sbin/ifconfig: util.c

Log Message:
ifconfig: if SIOCGLIFADDR fails, continue to the next address


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/ifconfig/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/util.c
diff -u src/sbin/ifconfig/util.c:1.19 src/sbin/ifconfig/util.c:1.20
--- src/sbin/ifconfig/util.c:1.19	Tue Oct  1 10:52:53 2019
+++ src/sbin/ifconfig/util.c	Sun Oct 11 21:32:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.19 2019/10/01 10:52:53 kardel Exp $	*/
+/*	$NetBSD: util.c,v 1.20 2020/10/11 21:32:37 roy Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: util.c,v 1.19 2019/10/01 10:52:53 kardel Exp $");
+__RCSID("$NetBSD: util.c,v 1.20 2020/10/11 21:32:37 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -275,8 +275,10 @@ print_link_addresses(prop_dictionary_t e
 		iflr.flags = IFLR_PREFIX;
 		iflr.prefixlen = sdl->sdl_alen * NBBY;
 
-		if (prog_ioctl(s, SIOCGLIFADDR, ) == -1)
+		if (prog_ioctl(s, SIOCGLIFADDR, ) == -1) {
 			warn("%s: ioctl SIOCGLIFADDR", __func__);
+			continue;
+		}
 
 		if (((iflr.flags & IFLR_ACTIVE) != 0) != print_active_only)
 			continue;



CVS commit: src/sbin/ifconfig

2020-10-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Oct  5 17:29:22 UTC 2020

Modified Files:
src/sbin/ifconfig: media.c

Log Message:
Minor correction to prior


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sbin/ifconfig/media.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/media.c
diff -u src/sbin/ifconfig/media.c:1.11 src/sbin/ifconfig/media.c:1.12
--- src/sbin/ifconfig/media.c:1.11	Mon Oct  5 16:17:05 2020
+++ src/sbin/ifconfig/media.c	Mon Oct  5 17:29:22 2020
@@ -1,6 +1,6 @@
 #include 
 #ifndef lint
-__RCSID("$NetBSD: media.c,v 1.11 2020/10/05 16:17:05 roy Exp $");
+__RCSID("$NetBSD: media.c,v 1.12 2020/10/05 17:29:22 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -424,10 +424,10 @@ media_status(int media_type, int link_st
 		return;
 	}
 
-	/* Interface link status is queried through SIOCGIFMEDIA.
-	 * Not all interfaces have actual media. */
-	if (ifmr.ifm_count == 0)
+	if (ifmr.ifm_count == 0) {
 		warnx("%s: no media types?", ifname);
+		return;
+	}
 
 	media_list = calloc(ifmr.ifm_count, sizeof(int));
 	if (media_list == NULL)



CVS commit: src/sbin/ifconfig

2020-10-05 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Oct  5 16:17:05 UTC 2020

Modified Files:
src/sbin/ifconfig: media.c

Log Message:
ifconfig: Warn once more if media supported but no types

This reverts media.c -r1.7


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/ifconfig/media.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/media.c
diff -u src/sbin/ifconfig/media.c:1.10 src/sbin/ifconfig/media.c:1.11
--- src/sbin/ifconfig/media.c:1.10	Tue Sep 22 14:14:17 2020
+++ src/sbin/ifconfig/media.c	Mon Oct  5 16:17:05 2020
@@ -1,6 +1,6 @@
 #include 
 #ifndef lint
-__RCSID("$NetBSD: media.c,v 1.10 2020/09/22 14:14:17 roy Exp $");
+__RCSID("$NetBSD: media.c,v 1.11 2020/10/05 16:17:05 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -426,25 +426,25 @@ media_status(int media_type, int link_st
 
 	/* Interface link status is queried through SIOCGIFMEDIA.
 	 * Not all interfaces have actual media. */
-	if (ifmr.ifm_count != 0) {
-		media_list = calloc(ifmr.ifm_count, sizeof(int));
-		if (media_list == NULL)
-			err(EXIT_FAILURE, "malloc");
-		ifmr.ifm_ulist = media_list;
-
-		if (prog_ioctl(s, SIOCGIFMEDIA, ) == -1)
-			err(EXIT_FAILURE, "SIOCGIFMEDIA");
-
-		printf("\tmedia: %s ", get_media_type_string(ifmr.ifm_current));
-		print_media_word(ifmr.ifm_current, " ");
-		if (ifmr.ifm_active != ifmr.ifm_current) {
-			printf(" (");
-			print_media_word(ifmr.ifm_active, " ");
-			printf(")");
-		}
-		printf("\n");
-	} else
-		media_list = NULL;
+	if (ifmr.ifm_count == 0)
+		warnx("%s: no media types?", ifname);
+
+	media_list = calloc(ifmr.ifm_count, sizeof(int));
+	if (media_list == NULL)
+		err(EXIT_FAILURE, "malloc");
+	ifmr.ifm_ulist = media_list;
+
+	if (prog_ioctl(s, SIOCGIFMEDIA, ) == -1)
+		err(EXIT_FAILURE, "SIOCGIFMEDIA");
+
+	printf("\tmedia: %s ", get_media_type_string(ifmr.ifm_current));
+	print_media_word(ifmr.ifm_current, " ");
+	if (ifmr.ifm_active != ifmr.ifm_current) {
+		printf(" (");
+		print_media_word(ifmr.ifm_active, " ");
+		printf(")");
+	}
+	printf("\n");
 
 	if (ifmr.ifm_status & IFM_STATUS_VALID)
 		print_media_status(IFM_TYPE(ifmr.ifm_current), ifmr.ifm_status);



CVS commit: src/sbin/ifconfig

2020-09-29 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep 29 08:52:11 UTC 2020

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Add [-]eee and [-]vlan-hwfilter.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.120 src/sbin/ifconfig/ifconfig.8:1.121
--- src/sbin/ifconfig/ifconfig.8:1.120	Wed Sep 23 02:09:18 2020
+++ src/sbin/ifconfig/ifconfig.8	Tue Sep 29 08:52:11 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.120 2020/09/23 02:09:18 roy Exp $
+.\"	$NetBSD: ifconfig.8,v 1.121 2020/09/29 08:52:11 msaitoh Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd September 23, 2020
+.Dd September 29, 2020
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -614,6 +614,10 @@ Remove
 from the
 .Xr agr 4
 interface.
+.It Cm eee
+Enable IEEE 802.3az Energy Efficiency Ethernet function.
+.It Cm -eee
+Disable IEEE 802.3az Energy Efficiency Ethernet function.
 .It Cm vltime Ar n
 .Pq inet6 only
 Set valid lifetime for the address.
@@ -699,6 +703,10 @@ support it.
 .It Cm -tso6
 Disable hardware-assisted TCP/IPv6 segmentation on interfaces that
 support it.
+.It Cm vlan-hwfilter
+Enable hardware-assisted VLAN frame filter on interfaces that support it.
+.It Cm -vlan-hwfilter
+Disable hardware-assisted VLAN frame filter on interfaces that support it.
 .It Cm vlan-hwtagging
 Enable hardware-assisted VLAN tag insertion/removal on interfaces that
 support it.



CVS commit: src/sbin/ifconfig

2020-09-28 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Mon Sep 28 13:50:22 UTC 2020

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
ifconfig: Just look at if_data->ifi_link_state for carrier

It should be the sole source of truth.
if_data is also carried in ifa_data from getifaddrs(3) which saves
more ioctl calls.


To generate a diff of this commit:
cvs rdiff -u -r1.246 -r1.247 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.246 src/sbin/ifconfig/ifconfig.c:1.247
--- src/sbin/ifconfig/ifconfig.c:1.246	Sat Sep 26 23:43:26 2020
+++ src/sbin/ifconfig/ifconfig.c	Mon Sep 28 13:50:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.246 2020/09/26 23:43:26 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.247 2020/09/28 13:50:22 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.246 2020/09/26 23:43:26 roy Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.247 2020/09/28 13:50:22 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -852,6 +852,7 @@ printall(const char *ifname, prop_dictio
 	struct ifaddrs *ifap, *ifa;
 	struct ifreq ifr;
 	const struct sockaddr_dl *sdl = NULL;
+	const struct if_data *ifi = NULL;
 	prop_dictionary_t env, oenv;
 	int idx;
 	char *p;
@@ -880,8 +881,10 @@ printall(const char *ifname, prop_dictio
 
 		if (ifname != NULL && strcmp(ifname, ifa->ifa_name) != 0)
 			continue;
-		if (ifa->ifa_addr->sa_family == AF_LINK)
+		if (ifa->ifa_addr->sa_family == AF_LINK) {
 			sdl = (const struct sockaddr_dl *)ifa->ifa_addr;
+			ifi = (const struct if_data *)ifa->ifa_data;
+		}
 		if (p && strcmp(p, ifa->ifa_name) == 0)
 			continue;
 		if (!prop_dictionary_set_string(env, "if", ifa->ifa_name))
@@ -895,7 +898,8 @@ printall(const char *ifname, prop_dictio
 		if (uflag && (ifa->ifa_flags & IFF_UP) == 0)
 			continue;
 
-		if (sflag && carrier(env))
+		if (sflag && (ifi == NULL ||
+		  ifi->ifi_link_state == LINK_STATE_DOWN))
 			continue;
 		idx++;
 		/*
@@ -910,6 +914,7 @@ printall(const char *ifname, prop_dictio
 
 		status(sdl, ifa->ifa_data, env, oenv);
 		sdl = NULL;
+		ifi = NULL;
 	}
 	if (lflag)
 		printf("\n");
@@ -1213,34 +1218,15 @@ setifmtu(prop_dictionary_t env, prop_dic
 static int
 carrier(prop_dictionary_t env)
 {
-	struct ifmediareq ifmr = { .ifm_status = 0 };
+	struct ifdatareq ifdr = { .ifdr_data.ifi_link_state = 0 };
 
-	if (direct_ioctl(env, SIOCGIFMEDIA, ) == -1) {
-		/*
-		 * Interface doesn't support SIOC{G,S}IFMEDIA;
-		 * check link state.
-		 */
-		struct ifdatareq ifdr = { .ifdr_data.ifi_link_state = 0 };
+	if (direct_ioctl(env, SIOCGIFDATA, ) == -1)
+		return EXIT_FAILURE;
 
-		if (direct_ioctl(env, SIOCGIFDATA, ) == -1)
-			return EXIT_FAILURE;
-		if (ifdr.ifdr_data.ifi_link_state == LINK_STATE_DOWN)
-			return EXIT_FAILURE;
-		else
-			return EXIT_SUCCESS;
-	}
-	if ((ifmr.ifm_status & IFM_AVALID) == 0) {
-		/*
-		 * Interface doesn't report media-valid status.
-		 * assume ok.
-		 */
-		return EXIT_SUCCESS;
-	}
-	/* otherwise, return ok for active, not-ok if not active. */
-	if (ifmr.ifm_status & IFM_ACTIVE)
-		return EXIT_SUCCESS;
-	else
+	if (ifdr.ifdr_data.ifi_link_state == LINK_STATE_DOWN)
 		return EXIT_FAILURE;
+	else /* Assume UP if UNKNOWN */
+		return EXIT_SUCCESS;
 }
 
 static void



CVS commit: src/sbin/ifconfig

2020-09-26 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Sep 26 23:43:26 UTC 2020

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
ifconfig: We already have struct if_data in ifa_data.

So let's not bother with an ioctl we don't need.


To generate a diff of this commit:
cvs rdiff -u -r1.245 -r1.246 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.245 src/sbin/ifconfig/ifconfig.c:1.246
--- src/sbin/ifconfig/ifconfig.c:1.245	Wed Sep 23 10:48:12 2020
+++ src/sbin/ifconfig/ifconfig.c	Sat Sep 26 23:43:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.245 2020/09/23 10:48:12 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.246 2020/09/26 23:43:26 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.245 2020/09/23 10:48:12 roy Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.246 2020/09/26 23:43:26 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -135,8 +135,8 @@ static int setlinkstr(prop_dictionary_t,
 static int unsetlinkstr(prop_dictionary_t, prop_dictionary_t);
 static int setifdescr(prop_dictionary_t, prop_dictionary_t);
 static int unsetifdescr(prop_dictionary_t, prop_dictionary_t);
-static void status(const struct sockaddr_dl *, prop_dictionary_t,
-prop_dictionary_t);
+static void status(const struct sockaddr_dl *, const void *,
+prop_dictionary_t, prop_dictionary_t);
 __dead static void usage(void);
 
 static const struct kwinst ifflagskw[] = {
@@ -908,7 +908,7 @@ printall(const char *ifname, prop_dictio
 			continue;
 		}
 
-		status(sdl, env, oenv);
+		status(sdl, ifa->ifa_data, env, oenv);
 		sdl = NULL;
 	}
 	if (lflag)
@@ -1270,10 +1270,10 @@ print_human_bytes(bool humanize, uint64_
 #define MAX_PRINT_LEN 58	/* XXX need a better way to determine this! */
 
 void
-status(const struct sockaddr_dl *sdl, prop_dictionary_t env,
-prop_dictionary_t oenv)
+status(const struct sockaddr_dl *sdl, const void *ifa_data,
+prop_dictionary_t env, prop_dictionary_t oenv)
 {
-	const struct if_data *ifi;
+	const struct if_data *ifi = ifa_data;
 	status_func_t *status_f;
 	statistics_func_t *statistics_f;
 	struct ifdatareq ifdr;
@@ -1365,18 +1365,19 @@ status(const struct sockaddr_dl *sdl, pr
 		free(p);
 	}
 
-	estrlcpy(ifdr.ifdr_name, ifname, sizeof(ifdr.ifdr_name));
-
-	if (prog_ioctl(s, zflag ? SIOCZIFDATA : SIOCGIFDATA, ) == -1)
-		err(EXIT_FAILURE, zflag ? "SIOCZIFDATA" : "SIOCGIFDATA");
-
-	ifi = _data;
-
 	media_status(sdl->sdl_type, ifi->ifi_link_state, env, oenv);
 
 	if (!vflag && !zflag)
 		goto proto_status;
 
+	/* We already have if_data from SIOCGIFDATA in ifa_data. */
+	if (zflag) {
+		estrlcpy(ifdr.ifdr_name, ifname, sizeof(ifdr.ifdr_name));
+		if (prog_ioctl(s, SIOCZIFDATA, ) == -1)
+			err(EXIT_FAILURE, "SIOCZIFDATA");
+		ifi = _data;
+	}
+
 	print_plural("\tinput: ", ifi->ifi_ipackets, "packet");
 	print_human_bytes(hflag, ifi->ifi_ibytes);
 	if (ifi->ifi_imcasts)



CVS commit: src/sbin/ifconfig

2020-09-23 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Sep 23 10:48:12 UTC 2020

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
ifconfig: test cases want LINK_STATE_UNKNOWN to be treated as up.


To generate a diff of this commit:
cvs rdiff -u -r1.244 -r1.245 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.244 src/sbin/ifconfig/ifconfig.c:1.245
--- src/sbin/ifconfig/ifconfig.c:1.244	Wed Sep 23 02:09:18 2020
+++ src/sbin/ifconfig/ifconfig.c	Wed Sep 23 10:48:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.244 2020/09/23 02:09:18 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.245 2020/09/23 10:48:12 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.244 2020/09/23 02:09:18 roy Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.245 2020/09/23 10:48:12 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -1224,10 +1224,10 @@ carrier(prop_dictionary_t env)
 
 		if (direct_ioctl(env, SIOCGIFDATA, ) == -1)
 			return EXIT_FAILURE;
-		if (ifdr.ifdr_data.ifi_link_state == LINK_STATE_UP)
-			return EXIT_SUCCESS;
-		else
+		if (ifdr.ifdr_data.ifi_link_state == LINK_STATE_DOWN)
 			return EXIT_FAILURE;
+		else
+			return EXIT_SUCCESS;
 	}
 	if ((ifmr.ifm_status & IFM_AVALID) == 0) {
 		/*



CVS commit: src/sbin/ifconfig

2020-09-22 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Sep 23 02:09:18 UTC 2020

Modified Files:
src/sbin/ifconfig: ifconfig.8 ifconfig.c

Log Message:
ifconfig: teach carrier test about ifi_link_state from SIOCGIFDATA

Because not all interfaces support media.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sbin/ifconfig/ifconfig.8
cvs rdiff -u -r1.243 -r1.244 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.119 src/sbin/ifconfig/ifconfig.8:1.120
--- src/sbin/ifconfig/ifconfig.8:1.119	Mon Jul  8 03:04:15 2019
+++ src/sbin/ifconfig/ifconfig.8	Wed Sep 23 02:09:18 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.119 2019/07/08 03:04:15 msaitoh Exp $
+.\"	$NetBSD: ifconfig.8,v 1.120 2020/09/23 02:09:18 roy Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd July 8, 2019
+.Dd September 23, 2020
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -757,12 +757,17 @@ not appear to be connected to a network,
 .Nm
 will exit with status of 1
 .Pq false ;
-otherwise, it will exit with a
-zero
+otherwise, it will exit with a zero
+.Pq true
+exit status.
+For interface drivers that do not support media status reporting.
+then if the link state is not reported to be up,
+.Nm
+will exit with a status of 1
+.Pq false ;
+otherwise, it will exit with a zero
 .Pq true
 exit status.
-Not all interface drivers support media
-status reporting.
 .Pp
 If the
 .Fl m

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.243 src/sbin/ifconfig/ifconfig.c:1.244
--- src/sbin/ifconfig/ifconfig.c:1.243	Tue Sep 22 14:14:17 2020
+++ src/sbin/ifconfig/ifconfig.c	Wed Sep 23 02:09:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.243 2020/09/22 14:14:17 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.244 2020/09/23 02:09:18 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.243 2020/09/22 14:14:17 roy Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.244 2020/09/23 02:09:18 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -1213,16 +1213,21 @@ setifmtu(prop_dictionary_t env, prop_dic
 static int
 carrier(prop_dictionary_t env)
 {
-	struct ifmediareq ifmr;
-
-	memset(, 0, sizeof(ifmr));
+	struct ifmediareq ifmr = { .ifm_status = 0 };
 
 	if (direct_ioctl(env, SIOCGIFMEDIA, ) == -1) {
 		/*
 		 * Interface doesn't support SIOC{G,S}IFMEDIA;
-		 * assume ok.
+		 * check link state.
 		 */
-		return EXIT_SUCCESS;
+		struct ifdatareq ifdr = { .ifdr_data.ifi_link_state = 0 };
+
+		if (direct_ioctl(env, SIOCGIFDATA, ) == -1)
+			return EXIT_FAILURE;
+		if (ifdr.ifdr_data.ifi_link_state == LINK_STATE_UP)
+			return EXIT_SUCCESS;
+		else
+			return EXIT_FAILURE;
 	}
 	if ((ifmr.ifm_status & IFM_AVALID) == 0) {
 		/*



CVS commit: src/sbin/ifconfig

2020-06-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jun  7 06:02:58 UTC 2020

Modified Files:
src/sbin/ifconfig: af_atalk.c af_inetany.c carp.c env.c ether.c
ifconfig.c media.c parse.c pfsync.c tunnel.c

Log Message:
Update for proplib(3) API changes.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/ifconfig/af_atalk.c
cvs rdiff -u -r1.18 -r1.19 src/sbin/ifconfig/af_inetany.c
cvs rdiff -u -r1.13 -r1.14 src/sbin/ifconfig/carp.c
cvs rdiff -u -r1.12 -r1.13 src/sbin/ifconfig/env.c
cvs rdiff -u -r1.8 -r1.9 src/sbin/ifconfig/ether.c src/sbin/ifconfig/media.c
cvs rdiff -u -r1.241 -r1.242 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.19 -r1.20 src/sbin/ifconfig/parse.c
cvs rdiff -u -r1.2 -r1.3 src/sbin/ifconfig/pfsync.c
cvs rdiff -u -r1.21 -r1.22 src/sbin/ifconfig/tunnel.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_atalk.c
diff -u src/sbin/ifconfig/af_atalk.c:1.20 src/sbin/ifconfig/af_atalk.c:1.21
--- src/sbin/ifconfig/af_atalk.c:1.20	Fri Aug 16 10:33:17 2019
+++ src/sbin/ifconfig/af_atalk.c	Sun Jun  7 06:02:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_atalk.c,v 1.20 2019/08/16 10:33:17 msaitoh Exp $	*/
+/*	$NetBSD: af_atalk.c,v 1.21 2020/06/07 06:02:58 thorpej Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_atalk.c,v 1.20 2019/08/16 10:33:17 msaitoh Exp $");
+__RCSID("$NetBSD: af_atalk.c,v 1.21 2020/06/07 06:02:58 thorpej Exp $");
 #endif /* not lint */
 
 #include 
@@ -138,7 +138,13 @@ at_commit_address(prop_dictionary_t env,
 	if ((d0 = (prop_data_t)prop_dictionary_get(env, "address")) == NULL)
 		return;
 
-	addr = prop_data_data(d0);
+	addr = malloc(prop_data_size(d0));
+	if (addr == NULL)
+		return;
+	if (!prop_data_copy_value(d0, addr, prop_data_size(d0))) {
+		free(addr);
+		return;
+	}
 
 	sat = (struct sockaddr_at *)>pfx_addr;
 
@@ -154,11 +160,13 @@ at_commit_address(prop_dictionary_t env,
 
 	/* Copy the new address to a temporary input environment */
 
-	d = prop_data_create_data_nocopy(addr, paddr_prefix_size(addr));
+	d = prop_data_create_copy(addr, paddr_prefix_size(addr));
+	free(addr);
+
 	ienv = prop_dictionary_copy_mutable(env);
 
 	if (d == NULL)
-		err(EXIT_FAILURE, "%s: prop_data_create_data", __func__);
+		err(EXIT_FAILURE, "%s: prop_data_create_copy", __func__);
 	if (ienv == NULL)
 		err(EXIT_FAILURE, "%s: prop_dictionary_copy_mutable", __func__);
 

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.18 src/sbin/ifconfig/af_inetany.c:1.19
--- src/sbin/ifconfig/af_inetany.c:1.18	Fri Aug 16 10:33:17 2019
+++ src/sbin/ifconfig/af_inetany.c	Sun Jun  7 06:02:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.18 2019/08/16 10:33:17 msaitoh Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.19 2020/06/07 06:02:58 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inetany.c,v 1.18 2019/08/16 10:33:17 msaitoh Exp $");
+__RCSID("$NetBSD: af_inetany.c,v 1.19 2020/06/07 06:02:58 thorpej Exp $");
 #endif /* not lint */
 
 #include 
@@ -87,7 +87,7 @@ commit_address(prop_dictionary_t env, pr
 	strlcpy(param->name[1].buf, ifname, param->name[1].buflen);
 
 	if ((d = (prop_data_t)prop_dictionary_get(env, "address")) != NULL)
-		addr = prop_data_data_nocopy(d);
+		addr = prop_data_value(d);
 	else if (!prop_dictionary_get_bool(env, "alias", ) || alias ||
 	param->gifaddr.cmd == 0)
 		return;
@@ -99,17 +99,17 @@ commit_address(prop_dictionary_t env, pr
 		return;
 
 	if ((d = (prop_data_t)prop_dictionary_get(env, "dst")) != NULL)
-		dst = prop_data_data_nocopy(d);
+		dst = prop_data_value(d);
 	else
 		dst = NULL;
 
 	if ((d = (prop_data_t)prop_dictionary_get(env, "netmask")) != NULL)
-		mask = prop_data_data_nocopy(d);
+		mask = prop_data_value(d);
 	else
 		mask = NULL;
 
 	if ((d = (prop_data_t)prop_dictionary_get(env, "broadcast")) != NULL)
-		brd = prop_data_data_nocopy(d);
+		brd = prop_data_value(d);
 	else
 		brd = NULL;
 

Index: src/sbin/ifconfig/carp.c
diff -u src/sbin/ifconfig/carp.c:1.13 src/sbin/ifconfig/carp.c:1.14
--- src/sbin/ifconfig/carp.c:1.13	Fri Sep 11 23:22:28 2009
+++ src/sbin/ifconfig/carp.c	Sun Jun  7 06:02:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: carp.c,v 1.13 2009/09/11 23:22:28 dyoung Exp $ */
+/* $NetBSD: carp.c,v 1.14 2020/06/07 06:02:58 thorpej Exp $ */
 
 /*
  * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: carp.c,v 1.13 2009/09/11 23:22:28 dyoung Exp $");
+__RCSID("$NetBSD: carp.c,v 1.14 2020/06/07 06:02:58 thorpej Exp $");
 #endif /* not lint */
 
 #include 
@@ -167,7 +167,7 @@ setcarp_passwd(prop_dictionary_t env, pr
 
 	memset(carpr.carpr_key, 0, sizeof(carpr.carpr_key));
 	/* XXX Should hash the password into the key here, perhaps? */
-	strlcpy((char 

CVS commit: src/sbin/ifconfig

2020-04-10 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Fri Apr 10 14:32:50 UTC 2020

Modified Files:
src/sbin/ifconfig: af_inet.c

Log Message:
trim extraneous return statement


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sbin/ifconfig/af_inet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.26 src/sbin/ifconfig/af_inet.c:1.27
--- src/sbin/ifconfig/af_inet.c:1.26	Fri Aug 16 10:33:17 2019
+++ src/sbin/ifconfig/af_inet.c	Fri Apr 10 14:32:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.26 2019/08/16 10:33:17 msaitoh Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.27 2020/04/10 14:32:50 plunky Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.26 2019/08/16 10:33:17 msaitoh Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.27 2020/04/10 14:32:50 plunky Exp $");
 #endif /* not lint */
 
 #include 
@@ -219,7 +219,6 @@ in_addr_flags(struct ifaddrs *ifa, int f
 	if (prog_ioctl(s, SIOCGIFAFLAG_IN, ) == -1)
 		err(EXIT_FAILURE, "SIOCGIFAFLAG_IN");
 	return ifr.ifr_addrflags & flags ? true : false;
-	return false;
 }
 #endif
 



CVS commit: src/sbin/ifconfig

2020-01-02 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Jan  2 23:02:19 UTC 2020

Modified Files:
src/sbin/ifconfig: ether.c ifconfig.c

Log Message:
fix printing capabilities and enabled flags.

no need to skip a prefix "0x" of output of snprintb.
ifconfig expect the result of snprintb has "0x" prefix, but snprintb(3) 
specification has changed
so that if 0 is passed, it prints "0" instead of "0x0". 
(common/lib/libutil/snprintb.c r1.22)


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/ether.c
cvs rdiff -u -r1.240 -r1.241 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ether.c
diff -u src/sbin/ifconfig/ether.c:1.7 src/sbin/ifconfig/ether.c:1.8
--- src/sbin/ifconfig/ether.c:1.7	Fri Aug 16 10:33:17 2019
+++ src/sbin/ifconfig/ether.c	Thu Jan  2 23:02:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ether.c,v 1.7 2019/08/16 10:33:17 msaitoh Exp $	*/
+/*	$NetBSD: ether.c,v 1.8 2020/01/02 23:02:19 ryo Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ether.c,v 1.7 2019/08/16 10:33:17 msaitoh Exp $");
+__RCSID("$NetBSD: ether.c,v 1.8 2020/01/02 23:02:19 ryo Exp $");
 #endif /* not lint */
 
 #include 
@@ -165,14 +165,14 @@ ether_status(prop_dictionary_t env, prop
 		eccr.eccr_capabilities, MAX_PRINT_LEN);
 		bp = fbuf;
 		while (*bp != '\0') {
-			printf("\tec_capabilities=%s\n", [2]);
+			printf("\tec_capabilities=%s\n", bp);
 			bp += strlen(bp) + 1;
 		}
 		(void)snprintb_m(fbuf, sizeof(fbuf), ECCAPBITS,
 		eccr.eccr_capenable, MAX_PRINT_LEN);
 		bp = fbuf;
 		while (*bp != '\0') {
-			printf("\tec_enabled=%s\n", [2]);
+			printf("\tec_enabled=%s\n", bp);
 			bp += strlen(bp) + 1;
 		}
 	}

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.240 src/sbin/ifconfig/ifconfig.c:1.241
--- src/sbin/ifconfig/ifconfig.c:1.240	Fri Aug 16 10:33:17 2019
+++ src/sbin/ifconfig/ifconfig.c	Thu Jan  2 23:02:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.240 2019/08/16 10:33:17 msaitoh Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.241 2020/01/02 23:02:19 ryo Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.240 2019/08/16 10:33:17 msaitoh Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.241 2020/01/02 23:02:19 ryo Exp $");
 #endif /* not lint */
 
 #include 
@@ -1318,14 +1318,14 @@ status(const struct sockaddr *sdl, prop_
 		ifcr.ifcr_capabilities, MAX_PRINT_LEN);
 		bp = fbuf;
 		while (*bp != '\0') {
-			printf("\tcapabilities=%s\n", [2]);
+			printf("\tcapabilities=%s\n", bp);
 			bp += strlen(bp) + 1;
 		}
 		(void)snprintb_m(fbuf, sizeof(fbuf), IFCAPBITS,
 		ifcr.ifcr_capenable, MAX_PRINT_LEN);
 		bp = fbuf;
 		while (*bp != '\0') {
-			printf("\tenabled=%s\n", [2]);
+			printf("\tenabled=%s\n", bp);
 			bp += strlen(bp) + 1;
 		}
 	}



CVS commit: src/sbin/ifconfig

2019-04-22 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Apr 22 10:44:55 UTC 2019

Modified Files:
src/sbin/ifconfig: media.c

Log Message:
Suggested by Christos:
 - Dont' cast malloc()'s return value.
 - Use calloc() instead of malloc().


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/media.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/media.c
diff -u src/sbin/ifconfig/media.c:1.7 src/sbin/ifconfig/media.c:1.8
--- src/sbin/ifconfig/media.c:1.7	Wed Sep 14 11:46:43 2016
+++ src/sbin/ifconfig/media.c	Mon Apr 22 10:44:55 2019
@@ -1,6 +1,6 @@
 #include 
 #ifndef lint
-__RCSID("$NetBSD: media.c,v 1.7 2016/09/14 11:46:43 roy Exp $");
+__RCSID("$NetBSD: media.c,v 1.8 2019/04/22 10:44:55 msaitoh Exp $");
 #endif /* not lint */
 
 #include 
@@ -374,7 +374,7 @@ media_status(prop_dictionary_t env, prop
 	/* Interface link status is queried through SIOCGIFMEDIA.
 	 * Not all interfaces have actual media. */
 	if (ifmr.ifm_count != 0) {
-		media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
+		media_list = calloc(ifmr.ifm_count, sizeof(int));
 		if (media_list == NULL)
 			err(EXIT_FAILURE, "malloc");
 		ifmr.ifm_ulist = media_list;



CVS commit: src/sbin/ifconfig

2018-11-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Nov 15 04:37:20 UTC 2018

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Fix the format of ifconfig linkstr; it takes an argument


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.115 src/sbin/ifconfig/ifconfig.8:1.116
--- src/sbin/ifconfig/ifconfig.8:1.115	Tue Jul 31 20:54:18 2018
+++ src/sbin/ifconfig/ifconfig.8	Thu Nov 15 04:37:20 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.115 2018/07/31 20:54:18 sevan Exp $
+.\"	$NetBSD: ifconfig.8,v 1.116 2018/11/15 04:37:20 ozaki-r Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd July 31, 2018
+.Dd November 15, 2018
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -528,7 +528,7 @@ Refer to the man page for the specific d
 for more information.
 .It Fl link[0-2]
 Disable special processing at the link level with the specified interface.
-.It Cm linkstr
+.It Cm linkstr Ar str
 Set a link-level string parameter for the interface.
 This functionality varies from interface to interface.
 Refer to the man page for the specific driver



CVS commit: src/sbin/ifconfig

2018-11-14 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Nov 15 04:36:46 UTC 2018

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
ifconfig: add linkstr/-linkstr to the help message


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.236 src/sbin/ifconfig/ifconfig.c:1.237
--- src/sbin/ifconfig/ifconfig.c:1.236	Thu Jan  7 11:32:21 2016
+++ src/sbin/ifconfig/ifconfig.c	Thu Nov 15 04:36:46 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.236 2016/01/07 11:32:21 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.237 2018/11/15 04:36:46 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: ifconfig.c,v 1.236 2016/01/07 11:32:21 roy Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.237 2018/11/15 04:36:46 ozaki-r Exp $");
 #endif /* not lint */
 
 #include 
@@ -1484,6 +1484,7 @@ usage(void)
 		"\t[ arp | -arp ]\n"
 		"\t[ preference n ]\n"
 		"\t[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]\n"
+		"\t[ linkstr str | -linkstr ]\n"
 		"   %s -a [-b] [-d] [-h] %s[-u] [-v] [-z] [ af ]\n"
 		"   %s -l [-b] [-d] [-s] [-u]\n"
 		"   %s -C\n"



CVS commit: src/sbin/ifconfig

2018-07-31 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Tue Jul 31 20:54:18 UTC 2018

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Remove ISO & XNS references which are now long gone.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.114 src/sbin/ifconfig/ifconfig.8:1.115
--- src/sbin/ifconfig/ifconfig.8:1.114	Thu Feb 16 13:51:08 2017
+++ src/sbin/ifconfig/ifconfig.8	Tue Jul 31 20:54:18 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.114 2017/02/16 13:51:08 wiz Exp $
+.\"	$NetBSD: ifconfig.8,v 1.115 2018/07/31 20:54:18 sevan Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd January 19, 2017
+.Dd July 31, 2018
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -89,29 +89,6 @@ or a
 .Tn DARPA
 Internet address expressed in the Internet standard
 .Dq dot notation .
-For the Xerox Network Systems(tm) family,
-addresses are
-.Ar net:a.b.c.d.e.f ,
-where
-.Ar net
-is the assigned network number
-.Pq in decimal ,
-and each of the six bytes of the host number,
-.Ar a
-through
-.Ar f ,
-are specified in hexadecimal.
-The host number may be omitted on Ethernet interfaces,
-which use the hardware physical address,
-and on interfaces other than the first.
-For the
-.Tn ISO
-family, addresses are specified as a long hexadecimal string,
-as in the Xerox family.
-However, two consecutive dots imply a zero
-byte, and the dots are optional, if the user wishes to
-.Pq carefully
-count out long strings of digits in network byte order.
 .It Ar address_family
 Specifies the
 .Ar address_family
@@ -123,7 +100,6 @@ supported are
 .Dq inet ,
 .Dq inet6 ,
 .Dq atalk ,
-.Dq iso ,
 and
 .Dq link .
 .It Ar interface
@@ -237,15 +213,6 @@ marked ``down'', the system will not att
 transmit messages through that interface.
 If possible, the interface will be reset to disable reception as well.
 This action does not automatically disable routes using the interface.
-.It Cm ipdst
-This is used to specify an Internet host who is willing to receive
-ip packets encapsulating NS packets bound for a remote network.
-An apparent point to point link is constructed, and
-the address specified will be taken as the NS address and network
-of the destination.
-IP encapsulation of
-.Tn CLNP
-packets is done differently.
 .It Cm media Ar type
 Set the media type of the interface to
 .Ar type .
@@ -318,7 +285,7 @@ Set the maximum transmission unit of the
 .Ar n .
 Most interfaces do not support this option.
 .It Cm netmask Ar mask
-.Pq inet, inet6, and ISO
+.Pq inet and inet6
 Specify how much of the address to reserve for subdividing
 networks into sub-networks.
 The mask includes the network part of the local address
@@ -339,31 +306,6 @@ slash-notation after the address
 .Pq e.g 192.168.17.3/24 .
 .\" see
 .\" Xr eon 5 .
-.It Cm nsellength Ar n
-.Pf ( Tn ISO
-only)
-This specifies a trailing number of bytes for a received
-.Tn NSAP
-used for local identification, the remaining leading part of which is
-taken to be the
-.Tn NET
-.Pq Network Entity Title .
-The default value is 1, which is conformant to US
-.Tn GOSIP .
-When an ISO address is set in an ifconfig command,
-it is really the
-.Tn NSAP
-which is being specified.
-For example, in
-.Tn US GOSIP ,
-20 hex digits should be
-specified in the
-.Tn ISO NSAP
-to be assigned to the interface.
-There is some evidence that a number different from 1 may be useful
-for
-.Tn AFI
-37 type addresses.
 .It Cm state Ar state
 Explicitly force the
 .Xr carp 4



CVS commit: src/sbin/ifconfig

2018-06-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun 11 17:45:51 UTC 2018

Modified Files:
src/sbin/ifconfig: af_inet.c

Log Message:
Correct Undefined Behavior in ifconfig(8)

Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined:

# ifconfig
alc0: flags=0x8843 mtu 1500
ec_capabilities=3
ec_enabled=0
address: xx:xx:xx:xx:xx:xx
/public/src.git/sbin/ifconfig/af_inet.c:102:34: runtime error: left shift of 
16777215 by 8 places cannot be represented in type 'int'
inet 192.168.0.38/24 broadcast 192.168.0.255 flags 0x0
inet6 :::::xxx%alc0/64 flags 0x0 scopeid 0x1
lo0: flags=0x8049 mtu 33624
inet 127.0.0.1/8 flags 0x0
inet6 ::1/128 flags 0x20
inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x2

Change shifting left 1 to shifting 1U. This corrects the issue.

if (cidr < 32) {/* more than 1 bit in mask */
/* check for non-contig netmask */
if ((mask ^ (((1 << cidr) - 1) << (32 - cidr))) != 0) // <- here
return -1;  /* noncontig, no pfxlen */
}

Solution suggested by 

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sbin/ifconfig/af_inet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.24 src/sbin/ifconfig/af_inet.c:1.25
--- src/sbin/ifconfig/af_inet.c:1.24	Sat Oct  1 20:59:49 2016
+++ src/sbin/ifconfig/af_inet.c	Mon Jun 11 17:45:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.24 2016/10/01 20:59:49 kre Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.25 2018/06/11 17:45:50 kamil Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.24 2016/10/01 20:59:49 kre Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.25 2018/06/11 17:45:50 kamil Exp $");
 #endif /* not lint */
 
 #include  
@@ -99,7 +99,7 @@ in_prefixlen(struct sockaddr *sa)
 
 	if (cidr < 32) {		/* more than 1 bit in mask */
 		/* check for non-contig netmask */
-		if ((mask ^ (((1 << cidr) - 1) << (32 - cidr))) != 0)
+		if ((mask ^ (((1U << cidr) - 1) << (32 - cidr))) != 0)
 			return -1;	/* noncontig, no pfxlen */
 	}
 



CVS commit: src/sbin/ifconfig

2017-05-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May  2 20:12:27 UTC 2017

Modified Files:
src/sbin/ifconfig: Makefile.common

Log Message:
We don't need agr or l2tp when we are small.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/ifconfig/Makefile.common

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile.common
diff -u src/sbin/ifconfig/Makefile.common:1.4 src/sbin/ifconfig/Makefile.common:1.5
--- src/sbin/ifconfig/Makefile.common:1.4	Thu Feb 16 03:28:03 2017
+++ src/sbin/ifconfig/Makefile.common	Tue May  2 16:12:27 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.common,v 1.4 2017/02/16 08:28:03 knakahara Exp $
+#	$NetBSD: Makefile.common,v 1.5 2017/05/02 20:12:27 christos Exp $
 
 # shared stuff with src/distrib/utils/x_ifconfig for install media.
 # stuff not required by install media should be into Makefile.
@@ -11,5 +11,8 @@ DPADD+=		${LIBUTIL} ${LIBPROP}
 LDADD+=		-lutil -lprop
 
 INCS+=		af_inetany.h env.h extern.h media.h parse.h util.h
-SRCS+=		af_inet.c af_inetany.c agr.c env.c ether.c ieee80211.c \
-		ifconfig.c l2tp.c media.c parse.c tunnel.c util.c vlan.c
+SRCS+=		af_inet.c af_inetany.c env.c ether.c ieee80211.c \
+		ifconfig.c media.c parse.c tunnel.c util.c vlan.c
+.ifndef SMALLPROG
+SRCS+=		agr.c l2tp.c
+.endif



CVS commit: src/sbin/ifconfig

2017-02-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Feb 16 13:51:08 UTC 2017

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
New sentence, new line.
Remove superfluous Oc and merge line to make it less likely to happen again.
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.113 src/sbin/ifconfig/ifconfig.8:1.114
--- src/sbin/ifconfig/ifconfig.8:1.113	Thu Feb 16 08:32:21 2017
+++ src/sbin/ifconfig/ifconfig.8	Thu Feb 16 13:51:08 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.113 2017/02/16 08:32:21 knakahara Exp $
+.\"	$NetBSD: ifconfig.8,v 1.114 2017/02/16 13:51:08 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -509,8 +509,7 @@ flag may be used to display long SSIDs.
 also causes received information elements to be displayed symbolically.
 The interface must be up before any scanning operation.
 Only the super-user can use this command.
-.It Cm tunnel Ar src_addr Ns Oo Ar ,src_port Oc Ar dest_addr Ns Oo Ar ,dest_port
-.Oc
+.It Cm tunnel Ar src_addr Ns Oo Ar ,src_port Oc Ar dest_addr Ns Oo Ar ,dest_port Oc
 .Pq IP tunnel devices only
 Configure the physical source and destination address for IP tunnel
 interfaces, including
@@ -535,21 +534,20 @@ Unconfigure the physical source and dest
 interfaces previously configured with
 .Cm tunnel .
 .It Cm session Ar local_session Ar remote_session
-.Oc
 .Pq L2TPv3 devices only
 Configure local session id and remote session id for L2TPv3
-interface. The length of session id is 4 bytes.
+interface.
+The length of session id is 4 bytes.
 .It Cm deletesession
 Unconfigure the local session id and remote session id for
 L2TPv3 interface previously configured with
 .Cm session .
 .It Cm cookie Ar local_cookie_length Ar local_cookie  Ar remote_cookie_length Ar remote_cookie
-.Oc
 .Pq L2TPv3 devices only
 Configure local cookie and remote cookie for L2TPv3 interface.
 The cookie length must be 4 or 8 bytes.
-Generally, cookies are mangaed by daemon. So, this command would
-be used for test or debug only.
+Generally, cookies are managed by daemon.
+So, this command would be used for test or debug only.
 .It Cm deletecookie
 Unconfigure the local cookie and remote cookie for L2TPv3
 interface previously configured with



CVS commit: src/sbin/ifconfig

2017-02-16 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Feb 16 08:28:03 UTC 2017

Modified Files:
src/sbin/ifconfig: Makefile.common
Added Files:
src/sbin/ifconfig: l2tp.c

Log Message:
add l2tp(4) subcomands to ifconfig(8).

originally implemented by IIJ SEIL team.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/Makefile.common
cvs rdiff -u -r0 -r1.1 src/sbin/ifconfig/l2tp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile.common
diff -u src/sbin/ifconfig/Makefile.common:1.3 src/sbin/ifconfig/Makefile.common:1.4
--- src/sbin/ifconfig/Makefile.common:1.3	Wed Feb  8 23:34:15 2017
+++ src/sbin/ifconfig/Makefile.common	Thu Feb 16 08:28:03 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.common,v 1.3 2017/02/08 23:34:15 rin Exp $
+#	$NetBSD: Makefile.common,v 1.4 2017/02/16 08:28:03 knakahara Exp $
 
 # shared stuff with src/distrib/utils/x_ifconfig for install media.
 # stuff not required by install media should be into Makefile.
@@ -12,4 +12,4 @@ LDADD+=		-lutil -lprop
 
 INCS+=		af_inetany.h env.h extern.h media.h parse.h util.h
 SRCS+=		af_inet.c af_inetany.c agr.c env.c ether.c ieee80211.c \
-		ifconfig.c media.c parse.c tunnel.c util.c vlan.c
+		ifconfig.c l2tp.c media.c parse.c tunnel.c util.c vlan.c

Added files:

Index: src/sbin/ifconfig/l2tp.c
diff -u /dev/null src/sbin/ifconfig/l2tp.c:1.1
--- /dev/null	Thu Feb 16 08:28:03 2017
+++ src/sbin/ifconfig/l2tp.c	Thu Feb 16 08:28:03 2017
@@ -0,0 +1,270 @@
+/*	$NetBSD: l2tp.c,v 1.1 2017/02/16 08:28:03 knakahara Exp $	*/
+
+/*
+ * Copyright (c) 2017 Internet Initiative Japan Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__RCSID("$NetBSD: l2tp.c,v 1.1 2017/02/16 08:28:03 knakahara Exp $");
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "env.h"
+#include "extern.h"
+#include "util.h"
+
+static status_func_t status;
+static usage_func_t usage;
+static cmdloop_branch_t branch;
+
+static void l2tp_constructor(void) __attribute__((constructor));
+static void l2tp_status(prop_dictionary_t, prop_dictionary_t);
+
+static int setl2tpsession(prop_dictionary_t, prop_dictionary_t);
+static int deletel2tpsession(prop_dictionary_t, prop_dictionary_t);
+static int setl2tpcookie(prop_dictionary_t, prop_dictionary_t);
+static int deletel2tpcookie(prop_dictionary_t, prop_dictionary_t);
+
+struct pinteger l2tpremotesession = PINTEGER_INITIALIZER1(,
+"remote session id", 0, UINT_MAX, 10, setl2tpsession, "l2tpremotesession",
+_root.pb_parser);
+
+struct pinteger l2tplocalsession = PINTEGER_INITIALIZER1(,
+"local session id", 0, UINT_MAX, 10, NULL, "l2tplocalsession",
+_parser);
+
+struct pinteger l2tpremotecookie = PINTEGER_INITIALIZER1(,
+"remote cookie", INT64_MIN, INT64_MAX, 10, setl2tpcookie, "l2tpremotecookie",
+_root.pb_parser);
+
+struct pinteger l2tpremotecookielen = PINTEGER_INITIALIZER1(,
+"remote cookie length", 0, UINT16_MAX, 10, NULL, "l2tpremotecookielen",
+_parser);
+
+struct pinteger l2tplocalcookie = PINTEGER_INITIALIZER1(,
+"local cookie", INT64_MIN, INT64_MAX, 10, NULL, "l2tplocalcookie",
+_parser);
+
+struct pinteger l2tplocalcookielen = PINTEGER_INITIALIZER1(,
+"local cookie length", 0, UINT16_MAX, 10, NULL, "l2tplocalcookielen",
+_parser);
+
+static const struct kwinst l2tpkw[] = {
+	 {.k_word = "cookie", .k_nextparser = _parser}
+	,{.k_word = "deletecookie", .k_exec = deletel2tpcookie,
+	  .k_nextparser = _root.pb_parser}
+	,{.k_word = 

CVS commit: src/sbin/ifconfig

2017-02-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Feb  8 23:34:15 UTC 2017

Modified Files:
src/sbin/ifconfig: Makefile Makefile.common

Log Message:
Cosmetic changes. No functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/ifconfig/Makefile
cvs rdiff -u -r1.2 -r1.3 src/sbin/ifconfig/Makefile.common

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.59 src/sbin/ifconfig/Makefile:1.60
--- src/sbin/ifconfig/Makefile:1.59	Wed Feb  8 23:22:43 2017
+++ src/sbin/ifconfig/Makefile	Wed Feb  8 23:34:15 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.59 2017/02/08 23:22:43 rin Exp $
+#	$NetBSD: Makefile,v 1.60 2017/02/08 23:34:15 rin Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -7,25 +7,25 @@
 
 .include 
 
-RUMPPRG=ifconfig
-MAN=	ifconfig.8
+RUMPPRG=	ifconfig
+MAN=		ifconfig.8
+
+SRCS=		af_atalk.c af_link.c carp.c
+
+CPPFLAGS+=	-I${NETBSDSRCDIR}/sys/dist/pf/
+SRCS+=		pfsync.c
 
-#DBG+=-g
-SRCS= af_atalk.c af_link.c carp.c
 .if (${USE_INET6} != "no")
 CPPFLAGS+=	-DINET6
-SRCS+= af_inet6.c
+SRCS+=		af_inet6.c
 .endif
 
 .include "Makefile.common"
 
 .PATH:		${.CURDIR}/../../lib/libc/net
-RUMPSRCS= getifaddrs.c getnameinfo.c if_indextoname.c
+RUMPSRCS=	getifaddrs.c getnameinfo.c if_indextoname.c
 .if (${MKRUMP} != "no")
-CPPFLAGS+= -DRUMP_ACTION
+CPPFLAGS+=	-DRUMP_ACTION
 .endif
 
-CPPFLAGS+=-I${NETBSDSRCDIR}/sys/dist/pf/
-SRCS+= pfsync.c
-
 .include 

Index: src/sbin/ifconfig/Makefile.common
diff -u src/sbin/ifconfig/Makefile.common:1.2 src/sbin/ifconfig/Makefile.common:1.3
--- src/sbin/ifconfig/Makefile.common:1.2	Wed Feb  8 23:22:43 2017
+++ src/sbin/ifconfig/Makefile.common	Wed Feb  8 23:34:15 2017
@@ -1,27 +1,15 @@
-#	$NetBSD: Makefile.common,v 1.2 2017/02/08 23:22:43 rin Exp $
+#	$NetBSD: Makefile.common,v 1.3 2017/02/08 23:34:15 rin Exp $
 
 # shared stuff with src/distrib/utils/x_ifconfig for install media.
 # stuff not required by install media should be into Makefile.
 
 .ifdef SMALLPROG
-CPPFLAGS+=-DSMALL
+CPPFLAGS+=	-DSMALL
 .endif
 
-DPADD+=${LIBUTIL}
-DPADD+=${LIBPROP}
-LDADD+=-lutil
-LDADD+=-lprop
+DPADD+=		${LIBUTIL} ${LIBPROP}
+LDADD+=		-lutil -lprop
 
-INCS+=af_inetany.h env.h extern.h media.h parse.h util.h
-SRCS+= af_inet.c
-SRCS+= af_inetany.c
-SRCS+= agr.c
-SRCS+= env.c
-SRCS+= ether.c
-SRCS+= ieee80211.c
-SRCS+= ifconfig.c
-SRCS+= media.c
-SRCS+= parse.c
-SRCS+= tunnel.c
-SRCS+= util.c
-SRCS+= vlan.c
+INCS+=		af_inetany.h env.h extern.h media.h parse.h util.h
+SRCS+=		af_inet.c af_inetany.c agr.c env.c ether.c ieee80211.c \
+		ifconfig.c media.c parse.c tunnel.c util.c vlan.c



CVS commit: src/sbin/ifconfig

2017-01-18 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Wed Jan 18 22:07:26 UTC 2017

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Fix typo: s/forwared/forwarded
Also remove full stop from the date.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.111 src/sbin/ifconfig/ifconfig.8:1.112
--- src/sbin/ifconfig/ifconfig.8:1.111	Sun Sep 11 22:10:47 2016
+++ src/sbin/ifconfig/ifconfig.8	Wed Jan 18 22:07:25 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.111 2016/09/11 22:10:47 sevan Exp $
+.\"	$NetBSD: ifconfig.8,v 1.112 2017/01/18 22:07:25 abhinav Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd January 7, 2016.
+.Dd January 7, 2016
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -462,7 +462,7 @@ wireless clients directly (default).
 .It Fl apbridge
 .Pq IEEE 802.11 devices only
 When operating as an access point, pass packets through
-the system so that they can be forwared using some other mechanism.
+the system so that they can be forwarded using some other mechanism.
 Disabling the internal bridging is useful when traffic
 is to be processed with packet filtering.
 .It Cm pass Ar passphrase



CVS commit: src/sbin/ifconfig

2016-10-01 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Oct  1 20:59:49 UTC 2016

Modified Files:
src/sbin/ifconfig: af_inet.c

Log Message:
Return to printing explicit "netmask 0x" in the case that the
mask set is non-contiguous.   We don't prohibit setting such things
(even if they are basically useless) so they can be set by accident.
ifconfig ifN 10.0.0.1 netmask 225.0.0.0
produced
ifN .. inet 10.0.0.1/8
with the previous form (since 225 is 0xE1), now it produces
ifN ... inet 10.0.0.1 netmask 0xe100

If the "netmask" form ever appears in ifconfig output, it (now)
means that the netmask is non-contig, which should make that case
obvious (whther intended, or set by accident)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sbin/ifconfig/af_inet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.23 src/sbin/ifconfig/af_inet.c:1.24
--- src/sbin/ifconfig/af_inet.c:1.23	Sat Oct  1 15:10:58 2016
+++ src/sbin/ifconfig/af_inet.c	Sat Oct  1 20:59:49 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.23 2016/10/01 15:10:58 roy Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.24 2016/10/01 20:59:49 kre Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.23 2016/10/01 15:10:58 roy Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.24 2016/10/01 20:59:49 kre Exp $");
 #endif /* not lint */
 
 #include  
@@ -64,6 +64,7 @@ static void in_status(prop_dictionary_t,
 static void in_commit_address(prop_dictionary_t, prop_dictionary_t);
 static bool in_addr_tentative(struct ifaddrs *);
 static bool in_addr_tentative_or_detached(struct ifaddrs *);
+static in_addr_t in_netmask(struct sockaddr *);;
 static int  in_prefixlen(struct sockaddr *);
 static void in_alias(struct ifaddrs *, prop_dictionary_t, prop_dictionary_t);
 
@@ -74,17 +75,34 @@ static struct afswtch af = {
 	.af_addr_tentative_or_detached = in_addr_tentative_or_detached
 };
 
+static in_addr_t
+in_netmask(struct sockaddr *sa)
+{
+	struct sockaddr_in sin;
+
+	memset(, 0, sizeof(sin));
+	memcpy(, sa, sa->sa_len);
+	return ntohl(sin.sin_addr.s_addr);
+}
+
 static int
 in_prefixlen(struct sockaddr *sa)
 {
-	struct sockaddr_in sin;
 	in_addr_t mask;
 	int cidr;
 
-	memset(, 0, sizeof(sin));
-	memcpy(, sa, sa->sa_len);
-	mask = ntohl(sin.sin_addr.s_addr);
-	cidr = 33 - ffs(mask);
+	mask = in_netmask(sa);
+	if (mask == 0)			/* mask 0 ==> /0 */
+		return 0;
+
+	cidr = 33 - ffs(mask);		/* 33 - (1 .. 32) -> 32 .. 1 */
+
+	if (cidr < 32) {		/* more than 1 bit in mask */
+		/* check for non-contig netmask */
+		if ((mask ^ (((1 << cidr) - 1) << (32 - cidr))) != 0)
+			return -1;	/* noncontig, no pfxlen */
+	}
+
 	return cidr;
 }
 
@@ -93,6 +111,7 @@ in_alias(struct ifaddrs *ifa, prop_dicti
 {
 	char hbuf[NI_MAXHOST];
 	const int niflag = Nflag ? 0 : NI_NUMERICHOST;
+	int pfxlen;
 	char fbuf[1024];
 
 	if (lflag)
@@ -102,7 +121,9 @@ in_alias(struct ifaddrs *ifa, prop_dicti
 			hbuf, sizeof(hbuf), NULL, 0, niflag))
 		strlcpy(hbuf, "", sizeof(hbuf));	/* some message? */
 	printf("\tinet %s", hbuf);
-	printf("/%d", in_prefixlen(ifa->ifa_netmask));
+	pfxlen = in_prefixlen(ifa->ifa_netmask);
+	if (pfxlen >= 0)
+		printf("/%d", pfxlen);
 
 	if (ifa->ifa_flags & IFF_POINTOPOINT) {
 		if (getnameinfo(ifa->ifa_dstaddr, ifa->ifa_dstaddr->sa_len,
@@ -111,6 +132,9 @@ in_alias(struct ifaddrs *ifa, prop_dicti
 		printf(" -> %s", hbuf);
 	}
 
+	if (pfxlen < 0)
+		printf(" netmask %#x", in_netmask(ifa->ifa_netmask));
+
 	if (ifa->ifa_flags & IFF_BROADCAST) {
 		if (getnameinfo(ifa->ifa_broadaddr, ifa->ifa_broadaddr->sa_len,
 hbuf, sizeof(hbuf), NULL, 0, niflag))



CVS commit: src/sbin/ifconfig

2016-10-01 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Oct  1 15:10:59 UTC 2016

Modified Files:
src/sbin/ifconfig: af_inet.c af_inet6.c

Log Message:
Modernise the output for the address to address/prefix instead
of differring outputs for INET and INET6.
The hex string of the INET netmask was particulary hard to read.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.37 -r1.38 src/sbin/ifconfig/af_inet6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.22 src/sbin/ifconfig/af_inet.c:1.23
--- src/sbin/ifconfig/af_inet.c:1.22	Fri Sep 30 16:52:17 2016
+++ src/sbin/ifconfig/af_inet.c	Sat Oct  1 15:10:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.22 2016/09/30 16:52:17 roy Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.23 2016/10/01 15:10:58 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.22 2016/09/30 16:52:17 roy Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.23 2016/10/01 15:10:58 roy Exp $");
 #endif /* not lint */
 
 #include  
@@ -64,6 +64,7 @@ static void in_status(prop_dictionary_t,
 static void in_commit_address(prop_dictionary_t, prop_dictionary_t);
 static bool in_addr_tentative(struct ifaddrs *);
 static bool in_addr_tentative_or_detached(struct ifaddrs *);
+static int  in_prefixlen(struct sockaddr *);
 static void in_alias(struct ifaddrs *, prop_dictionary_t, prop_dictionary_t);
 
 static struct afswtch af = {
@@ -73,10 +74,23 @@ static struct afswtch af = {
 	.af_addr_tentative_or_detached = in_addr_tentative_or_detached
 };
 
+static int
+in_prefixlen(struct sockaddr *sa)
+{
+	struct sockaddr_in sin;
+	in_addr_t mask;
+	int cidr;
+
+	memset(, 0, sizeof(sin));
+	memcpy(, sa, sa->sa_len);
+	mask = ntohl(sin.sin_addr.s_addr);
+	cidr = 33 - ffs(mask);
+	return cidr;
+}
+
 static void
 in_alias(struct ifaddrs *ifa, prop_dictionary_t env, prop_dictionary_t oenv)
 {
-	struct sockaddr_in sin;
 	char hbuf[NI_MAXHOST];
 	const int niflag = Nflag ? 0 : NI_NUMERICHOST;
 	char fbuf[1024];
@@ -88,6 +102,7 @@ in_alias(struct ifaddrs *ifa, prop_dicti
 			hbuf, sizeof(hbuf), NULL, 0, niflag))
 		strlcpy(hbuf, "", sizeof(hbuf));	/* some message? */
 	printf("\tinet %s", hbuf);
+	printf("/%d", in_prefixlen(ifa->ifa_netmask));
 
 	if (ifa->ifa_flags & IFF_POINTOPOINT) {
 		if (getnameinfo(ifa->ifa_dstaddr, ifa->ifa_dstaddr->sa_len,
@@ -96,9 +111,6 @@ in_alias(struct ifaddrs *ifa, prop_dicti
 		printf(" -> %s", hbuf);
 	}
 
-	memcpy(, ifa->ifa_netmask, ifa->ifa_netmask->sa_len);
-	printf(" netmask 0x%x", ntohl(sin.sin_addr.s_addr));
-
 	if (ifa->ifa_flags & IFF_BROADCAST) {
 		if (getnameinfo(ifa->ifa_broadaddr, ifa->ifa_broadaddr->sa_len,
 hbuf, sizeof(hbuf), NULL, 0, niflag))

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.37 src/sbin/ifconfig/af_inet6.c:1.38
--- src/sbin/ifconfig/af_inet6.c:1.37	Fri Sep 30 16:47:56 2016
+++ src/sbin/ifconfig/af_inet6.c	Sat Oct  1 15:10:58 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.37 2016/09/30 16:47:56 roy Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.38 2016/10/01 15:10:58 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet6.c,v 1.37 2016/09/30 16:47:56 roy Exp $");
+__RCSID("$NetBSD: af_inet6.c,v 1.38 2016/10/01 15:10:58 roy Exp $");
 #endif /* not lint */
 
 #include  
@@ -277,6 +277,9 @@ in6_alias(struct ifaddrs *ifa, prop_dict
 	printf("\tinet6 %s", hbuf);
 	inet6_putscopeid(sin6, INET6_IS_ADDR_LINKLOCAL);
 
+	sin6 = (struct sockaddr_in6 *)ifa->ifa_netmask;
+	printf("/%d", prefix(>sin6_addr, sizeof(struct in6_addr)));
+
 	if (ifa->ifa_flags & IFF_POINTOPOINT) {
 		sin6 = (struct sockaddr_in6 *)ifa->ifa_dstaddr;
 		inet6_getscopeid(sin6, INET6_IS_ADDR_LINKLOCAL);
@@ -287,10 +290,6 @@ in6_alias(struct ifaddrs *ifa, prop_dict
 		printf(" -> %s", hbuf);
 	}
 
-	sin6 = (struct sockaddr_in6 *)ifa->ifa_netmask;
-	printf(" prefixlen %d", prefix(>sin6_addr,
-	sizeof(struct in6_addr)));
-
 	(void)snprintb(fbuf, sizeof(fbuf), IN6_IFFBITS, ifa->ifa_addrflags);
 	printf(" flags %s", fbuf);
 



CVS commit: src/sbin/ifconfig

2016-09-30 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Sep 30 16:52:17 UTC 2016

Modified Files:
src/sbin/ifconfig: af_inet.c

Log Message:
Remove the alias keyword from ifconfig output as it serves no purpose.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sbin/ifconfig/af_inet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.21 src/sbin/ifconfig/af_inet.c:1.22
--- src/sbin/ifconfig/af_inet.c:1.21	Fri Sep 30 16:47:56 2016
+++ src/sbin/ifconfig/af_inet.c	Fri Sep 30 16:52:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.21 2016/09/30 16:47:56 roy Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.22 2016/09/30 16:52:17 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.21 2016/09/30 16:47:56 roy Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.22 2016/09/30 16:52:17 roy Exp $");
 #endif /* not lint */
 
 #include  
@@ -64,8 +64,7 @@ static void in_status(prop_dictionary_t,
 static void in_commit_address(prop_dictionary_t, prop_dictionary_t);
 static bool in_addr_tentative(struct ifaddrs *);
 static bool in_addr_tentative_or_detached(struct ifaddrs *);
-static void in_alias(struct ifaddrs *, prop_dictionary_t, prop_dictionary_t,
-bool);
+static void in_alias(struct ifaddrs *, prop_dictionary_t, prop_dictionary_t);
 
 static struct afswtch af = {
 	.af_name = "inet", .af_af = AF_INET, .af_status = in_status,
@@ -75,8 +74,7 @@ static struct afswtch af = {
 };
 
 static void
-in_alias(struct ifaddrs *ifa, prop_dictionary_t env, prop_dictionary_t oenv,
-bool alias)
+in_alias(struct ifaddrs *ifa, prop_dictionary_t env, prop_dictionary_t oenv)
 {
 	struct sockaddr_in sin;
 	char hbuf[NI_MAXHOST];
@@ -89,7 +87,7 @@ in_alias(struct ifaddrs *ifa, prop_dicti
 	if (getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len,
 			hbuf, sizeof(hbuf), NULL, 0, niflag))
 		strlcpy(hbuf, "", sizeof(hbuf));	/* some message? */
-	printf("\tinet %s%s", alias ? "alias " : "", hbuf);
+	printf("\tinet %s", hbuf);
 
 	if (ifa->ifa_flags & IFF_POINTOPOINT) {
 		if (getnameinfo(ifa->ifa_dstaddr, ifa->ifa_dstaddr->sa_len,
@@ -118,7 +116,6 @@ in_status(prop_dictionary_t env, prop_di
 	struct ifaddrs *ifap, *ifa;
 	bool printprefs = false;
 	const char *ifname;
-	int alias = 0;
 
 	if ((ifname = getifname(env)) == NULL)
 		err(EXIT_FAILURE, "%s: getifname", __func__);
@@ -134,7 +131,7 @@ in_status(prop_dictionary_t env, prop_di
 		if (ifa->ifa_addr->sa_family != AF_INET)
 			continue;
 		/* The first address is not an alias. */
-		in_alias(ifa, env, oenv, alias++);
+		in_alias(ifa, env, oenv);
 		if (printprefs)
 			ifa_print_preference(ifa->ifa_name, ifa->ifa_addr);
 		printf("\n");



CVS commit: src/sbin/ifconfig

2016-09-30 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Sep 30 16:47:56 UTC 2016

Modified Files:
src/sbin/ifconfig: af_inet.c af_inet6.c

Log Message:
ifaddrs has more data than just the address.
Use it instead of making pointless ioctl calls.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.36 -r1.37 src/sbin/ifconfig/af_inet6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.20 src/sbin/ifconfig/af_inet.c:1.21
--- src/sbin/ifconfig/af_inet.c:1.20	Tue Sep 13 00:20:51 2016
+++ src/sbin/ifconfig/af_inet.c	Fri Sep 30 16:47:56 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.20 2016/09/13 00:20:51 christos Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.21 2016/09/30 16:47:56 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.20 2016/09/13 00:20:51 christos Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.21 2016/09/30 16:47:56 roy Exp $");
 #endif /* not lint */
 
 #include  
@@ -62,11 +62,10 @@ __RCSID("$NetBSD: af_inet.c,v 1.20 2016/
 static void in_constructor(void) __attribute__((constructor));
 static void in_status(prop_dictionary_t, prop_dictionary_t, bool);
 static void in_commit_address(prop_dictionary_t, prop_dictionary_t);
-static bool in_addr_flags(struct ifaddrs *, int);
 static bool in_addr_tentative(struct ifaddrs *);
 static bool in_addr_tentative_or_detached(struct ifaddrs *);
-static void in_alias(const char *, prop_dictionary_t, prop_dictionary_t,
-struct in_aliasreq *);
+static void in_alias(struct ifaddrs *, prop_dictionary_t, prop_dictionary_t,
+bool);
 
 static struct afswtch af = {
 	.af_name = "inet", .af_af = AF_INET, .af_status = in_status,
@@ -76,94 +75,50 @@ static struct afswtch af = {
 };
 
 static void
-in_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv,
-struct in_aliasreq *creq)
+in_alias(struct ifaddrs *ifa, prop_dictionary_t env, prop_dictionary_t oenv,
+bool alias)
 {
-	struct ifreq ifr;
-	bool alias;
-	int s;
-	unsigned short flags;
-	struct in_aliasreq in_addreq;
-	const struct sockaddr_in * const asin = _addreq.ifra_addr;
-	const struct sockaddr_in * const dsin = _addreq.ifra_dstaddr;
-	const struct sockaddr_in * const bsin = _addreq.ifra_broadaddr;
+	struct sockaddr_in sin;
 	char hbuf[NI_MAXHOST];
 	const int niflag = Nflag ? 0 : NI_NUMERICHOST;
+	char fbuf[1024];
 
 	if (lflag)
 		return;
 
-	alias = true;
-
-	/* Get the non-alias address for this interface. */
-	if ((s = getsock(AF_INET)) == -1) {
-		if (errno == EAFNOSUPPORT)
-			return;
-		err(EXIT_FAILURE, "socket");
-	}
-	memset(, 0, sizeof(ifr));
-	estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-	if (prog_ioctl(s, SIOCGIFADDR, ) == -1) {
-		if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT)
-			return;
-		warn("SIOCGIFADDR");
-	}
-	/* If creq and ifr are the same address, this is not an alias. */
-	if (memcmp(_addr, >ifra_addr, sizeof(ifr.ifr_addr)) == 0)
-		alias = false;
-	in_addreq = *creq;
-	if (prog_ioctl(s, SIOCGIFALIAS, _addreq) == -1) {
-		if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) {
-			return;
-		} else
-			warn("SIOCGIFALIAS");
-	}
-
-	if (getnameinfo((const struct sockaddr *)asin, asin->sin_len,
+	if (getnameinfo(ifa->ifa_addr, ifa->ifa_addr->sa_len,
 			hbuf, sizeof(hbuf), NULL, 0, niflag))
 		strlcpy(hbuf, "", sizeof(hbuf));	/* some message? */
 	printf("\tinet %s%s", alias ? "alias " : "", hbuf);
 
-	if (getifflags(env, oenv, ) == -1)
-		err(EXIT_FAILURE, "%s: getifflags", __func__);
-
-	if (flags & IFF_POINTOPOINT) {
-		if (getnameinfo((const struct sockaddr *)dsin, dsin->sin_len,
+	if (ifa->ifa_flags & IFF_POINTOPOINT) {
+		if (getnameinfo(ifa->ifa_dstaddr, ifa->ifa_dstaddr->sa_len,
 hbuf, sizeof(hbuf), NULL, 0, niflag))
 			strlcpy(hbuf, "", sizeof(hbuf)); /* some message? */
 		printf(" -> %s", hbuf);
 	}
 
-	printf(" netmask 0x%x", ntohl(in_addreq.ifra_mask.sin_addr.s_addr));
+	memcpy(, ifa->ifa_netmask, ifa->ifa_netmask->sa_len);
+	printf(" netmask 0x%x", ntohl(sin.sin_addr.s_addr));
 
-	if (flags & IFF_BROADCAST) {
-		if (getnameinfo((const struct sockaddr *)bsin, bsin->sin_len,
+	if (ifa->ifa_flags & IFF_BROADCAST) {
+		if (getnameinfo(ifa->ifa_broadaddr, ifa->ifa_broadaddr->sa_len,
 hbuf, sizeof(hbuf), NULL, 0, niflag))
 			strlcpy(hbuf, "", sizeof(hbuf)); /* some message? */
 		printf(" broadcast %s", hbuf);
 	}
 
-#ifdef IN_IFF_TENTATIVE
-	memcpy(_addr, >ifra_addr, creq->ifra_addr.sin_len);
-	if (prog_ioctl(s, SIOCGIFAFLAG_IN, ) == -1) {
-		if (errno != EADDRNOTAVAIL)
-			warn("SIOCGIFAFLAG_IN");
-	} else {
-		char fbuf[1024];
-		(void)snprintb(fbuf, sizeof(fbuf), IN_IFFBITS,
-		ifr.ifr_addrflags);
-		printf(" flags %s", fbuf);
-	}
-#endif
+	(void)snprintb(fbuf, sizeof(fbuf), IN_IFFBITS, ifa->ifa_addrflags);
+	printf(" flags %s", fbuf);

CVS commit: src/sbin/ifconfig

2016-09-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 22 18:22:52 UTC 2016

Modified Files:
src/sbin/ifconfig: ieee80211.c

Log Message:
fix bugs in ssid printing


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sbin/ifconfig/ieee80211.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ieee80211.c
diff -u src/sbin/ifconfig/ieee80211.c:1.28 src/sbin/ifconfig/ieee80211.c:1.29
--- src/sbin/ifconfig/ieee80211.c:1.28	Tue Apr 28 11:14:57 2015
+++ src/sbin/ifconfig/ieee80211.c	Thu Sep 22 14:22:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.28 2015/04/28 15:14:57 christos Exp $	*/
+/*	$NetBSD: ieee80211.c,v 1.29 2016/09/22 18:22:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: ieee80211.c,v 1.28 2015/04/28 15:14:57 christos Exp $");
+__RCSID("$NetBSD: ieee80211.c,v 1.29 2016/09/22 18:22:51 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -765,14 +765,36 @@ scan_and_wait(prop_dictionary_t env)
 	prog_close(sroute);
 }
 
+static int
+calc_len(const u_int8_t *cp, int len)
+{
+	int maxlen = 0, curlen;
+	const struct ieee80211req_scan_result *sr;
+	char buf[IEEE80211_NWID_LEN];
+
+	while (len >= (int)sizeof(*sr)) {
+		sr = (const struct ieee80211req_scan_result *)cp;
+		cp += sr->isr_len;
+		len -= sr->isr_len;
+		curlen = copy_essid(buf, sizeof(buf),
+		(const u_int8_t *)(sr + 1), sr->isr_ssid_len);
+		if (curlen >= IEEE80211_NWID_LEN)
+			return IEEE80211_NWID_LEN;
+		if (curlen > maxlen)
+			maxlen = curlen;
+	}
+	return maxlen;
+}
+
 static void
 list_scan(prop_dictionary_t env)
 {
-	u_int8_t buf[24*1024];
+	u_int8_t buf[64*1024 - 1];
 	struct ieee80211req ireq;
 	char ssid[IEEE80211_NWID_LEN+1];
 	const u_int8_t *cp;
 	int len, ssidmax;
+	const struct ieee80211req_scan_result *sr;
 
 	memset(, 0, sizeof(ireq));
 	ireq.i_type = IEEE80211_IOC_SCAN_RESULTS;
@@ -781,10 +803,11 @@ list_scan(prop_dictionary_t env)
 	if (direct_ioctl(env, SIOCG80211, ) < 0)
 		errx(EXIT_FAILURE, "unable to get scan results");
 	len = ireq.i_len;
-	if (len < (int)sizeof(struct ieee80211req_scan_result))
+	if (len < (int)sizeof(*sr))
 		return;
 
-	ssidmax = IEEE80211_NWID_LEN;
+	ssidmax = calc_len(buf, len);
+
 	printf("%-*.*s  %-17.17s  %4s %4s  %-7s %3s %4s\n"
 		, ssidmax, ssidmax, "SSID"
 		, "BSSID"
@@ -795,16 +818,14 @@ list_scan(prop_dictionary_t env)
 		, "CAPS"
 	);
 	cp = buf;
-	do {
-		const struct ieee80211req_scan_result *sr;
+	while (len >= (int)sizeof(*sr)) {
 		const uint8_t *vp;
 
 		sr = (const struct ieee80211req_scan_result *) cp;
 		vp = (const u_int8_t *)(sr+1);
+		(void)copy_essid(ssid, sizeof(ssid), vp, sr->isr_ssid_len);
 		printf("%-*.*s  %s  %3d  %3dM %3d:%-3d  %3d %-4.4s"
-			, ssidmax
-			  , copy_essid(ssid, ssidmax, vp, sr->isr_ssid_len)
-			  , ssid
+			, ssidmax, ssidmax, ssid
 			, ether_ntoa((const struct ether_addr *) sr->isr_bssid)
 			, ieee80211_mhz2ieee(sr->isr_freq, sr->isr_flags)
 			, getmaxrate(sr->isr_rates, sr->isr_nrates)
@@ -815,7 +836,7 @@ list_scan(prop_dictionary_t env)
 		printies(vp + sr->isr_ssid_len, sr->isr_ie_len, 24);
 		printf("\n");
 		cp += sr->isr_len, len -= sr->isr_len;
-	} while (len >= (int)sizeof(struct ieee80211req_scan_result));
+	}
 }
 /*
  * Convert MHz frequency to IEEE channel number.
@@ -1144,18 +1165,22 @@ static int
 copy_essid(char buf[], size_t bufsize, const u_int8_t *essid, size_t essid_len)
 {
 	const u_int8_t *p;
+	int printable;
 	size_t maxlen, i;
 
-	if (essid_len > bufsize)
+	if (essid_len + 1 > bufsize)
 		maxlen = bufsize;
 	else
-		maxlen = essid_len;
+		maxlen = essid_len + 1;
 	/* determine printable or not */
-	for (i = 0, p = essid; i < maxlen; i++, p++) {
-		if (*p < ' ' || *p > 0x7e)
+	printable = 1;
+	for (i = 0, p = essid; i < essid_len; i++, p++) {
+		if (*p < ' ' || *p > 0x7e) {
+			printable = 0;
 			break;
+		}
 	}
-	if (i != maxlen) {		/* not printable, print as hex */
+	if (!printable) {		/* not printable, print as hex */
 		if (bufsize < 3)
 			return 0;
 		strlcpy(buf, "0x", bufsize);
@@ -1165,14 +1190,14 @@ copy_essid(char buf[], size_t bufsize, c
 			sprintf([2+2*i], "%02x", p[i]);
 			bufsize -= 2;
 		}
-		if (i != essid_len)
-			memcpy([2+2*i-3], "...", 3);
-	} else {			/* printable, truncate as needed */
-		memcpy(buf, essid, maxlen);
-		if (maxlen != essid_len)
-			memcpy([maxlen-3], "...", 3);
-	}
-	return maxlen;
+		maxlen = i;
+	} else{
+		/* printable, truncate as needed */
+		strlcpy(buf, (const char *)essid, maxlen);
+	}
+	if (maxlen != essid_len + 1)
+		memcpy([maxlen - 4], "...", 4);
+	return (int)strlen(buf);
 }
 
 static void



CVS commit: src/sbin/ifconfig

2016-09-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Sep 14 11:46:43 UTC 2016

Modified Files:
src/sbin/ifconfig: media.c

Log Message:
Don't bail if SIOGIFMEDIA doesn't return any media lists because we
can still report link status.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/media.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/media.c
diff -u src/sbin/ifconfig/media.c:1.6 src/sbin/ifconfig/media.c:1.7
--- src/sbin/ifconfig/media.c:1.6	Mon Aug 29 14:35:00 2011
+++ src/sbin/ifconfig/media.c	Wed Sep 14 11:46:43 2016
@@ -1,6 +1,6 @@
 #include 
 #ifndef lint
-__RCSID("$NetBSD: media.c,v 1.6 2011/08/29 14:35:00 joerg Exp $");
+__RCSID("$NetBSD: media.c,v 1.7 2016/09/14 11:46:43 roy Exp $");
 #endif /* not lint */
 
 #include 
@@ -371,27 +371,27 @@ media_status(prop_dictionary_t env, prop
 		return;
 	}
 
-	if (ifmr.ifm_count == 0) {
-		warnx("%s: no media types?", ifname);
-		return;
-	}
-
-	media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
-	if (media_list == NULL)
-		err(EXIT_FAILURE, "malloc");
-	ifmr.ifm_ulist = media_list;
-
-	if (prog_ioctl(s, SIOCGIFMEDIA, ) == -1)
-		err(EXIT_FAILURE, "SIOCGIFMEDIA");
-
-	printf("\tmedia: %s ", get_media_type_string(ifmr.ifm_current));
-	print_media_word(ifmr.ifm_current, " ");
-	if (ifmr.ifm_active != ifmr.ifm_current) {
-		printf(" (");
-		print_media_word(ifmr.ifm_active, " ");
-		printf(")");
-	}
-	printf("\n");
+	/* Interface link status is queried through SIOCGIFMEDIA.
+	 * Not all interfaces have actual media. */
+	if (ifmr.ifm_count != 0) {
+		media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
+		if (media_list == NULL)
+			err(EXIT_FAILURE, "malloc");
+		ifmr.ifm_ulist = media_list;
+
+		if (prog_ioctl(s, SIOCGIFMEDIA, ) == -1)
+			err(EXIT_FAILURE, "SIOCGIFMEDIA");
+
+		printf("\tmedia: %s ", get_media_type_string(ifmr.ifm_current));
+		print_media_word(ifmr.ifm_current, " ");
+		if (ifmr.ifm_active != ifmr.ifm_current) {
+			printf(" (");
+			print_media_word(ifmr.ifm_active, " ");
+			printf(")");
+		}
+		printf("\n");
+	} else
+		media_list = NULL;
 
 	if (ifmr.ifm_status & IFM_STATUS_VALID) {
 		const struct ifmedia_status_description *ifms;



CVS commit: src/sbin/ifconfig

2016-09-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 13 00:20:51 UTC 2016

Modified Files:
src/sbin/ifconfig: af_inet.c af_inet6.c

Log Message:
print address flag bits using snprintb


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.35 -r1.36 src/sbin/ifconfig/af_inet6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.19 src/sbin/ifconfig/af_inet.c:1.20
--- src/sbin/ifconfig/af_inet.c:1.19	Mon Feb 29 11:23:25 2016
+++ src/sbin/ifconfig/af_inet.c	Mon Sep 12 20:20:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.19 2016/02/29 16:23:25 riastradh Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.20 2016/09/13 00:20:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.19 2016/02/29 16:23:25 riastradh Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.20 2016/09/13 00:20:51 christos Exp $");
 #endif /* not lint */
 
 #include  
@@ -149,12 +149,10 @@ in_alias(const char *ifname, prop_dictio
 		if (errno != EADDRNOTAVAIL)
 			warn("SIOCGIFAFLAG_IN");
 	} else {
-		if (ifr.ifr_addrflags & IN_IFF_TENTATIVE)
-			printf(" tentative");
-		if (ifr.ifr_addrflags & IN_IFF_DUPLICATED)
-			printf(" duplicated");
-		if (ifr.ifr_addrflags & IN_IFF_DETACHED)
-			printf(" detached");
+		char fbuf[1024];
+		(void)snprintb(fbuf, sizeof(fbuf), IN_IFFBITS,
+		ifr.ifr_addrflags);
+		printf(" flags %s", fbuf);
 	}
 #endif
 }

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.35 src/sbin/ifconfig/af_inet6.c:1.36
--- src/sbin/ifconfig/af_inet6.c:1.35	Mon Feb 29 11:23:25 2016
+++ src/sbin/ifconfig/af_inet6.c	Mon Sep 12 20:20:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.35 2016/02/29 16:23:25 riastradh Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.36 2016/09/13 00:20:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet6.c,v 1.35 2016/02/29 16:23:25 riastradh Exp $");
+__RCSID("$NetBSD: af_inet6.c,v 1.36 2016/09/13 00:20:51 christos Exp $");
 #endif /* not lint */
 
 #include  
@@ -325,20 +325,10 @@ in6_alias(const char *ifname, prop_dicti
 		if (errno != EADDRNOTAVAIL)
 			warn("SIOCGIFAFLAG_IN6");
 	} else {
-		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_ANYCAST)
-			printf(" anycast");
-		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_TENTATIVE)
-			printf(" tentative");
-		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_DUPLICATED)
-			printf(" duplicated");
-		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_DETACHED)
-			printf(" detached");
-		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_DEPRECATED)
-			printf(" deprecated");
-		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_AUTOCONF)
-			printf(" autoconf");
-		if (ifr6.ifr_ifru.ifru_flags6 & IN6_IFF_TEMPORARY)
-			printf(" temporary");
+		char fbuf[1024];
+		(void)snprintb(fbuf, sizeof(fbuf), IN6_IFFBITS,
+		ifr6.ifr_ifru.ifru_flags6);
+		printf(" flags %s", fbuf);
 	}
 
 	if (scopeid)



CVS commit: src/sbin/ifconfig

2016-09-11 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Sep 11 22:10:47 UTC 2016

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Replace contractions & abbreviation.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.110 src/sbin/ifconfig/ifconfig.8:1.111
--- src/sbin/ifconfig/ifconfig.8:1.110	Thu Jan  7 11:32:21 2016
+++ src/sbin/ifconfig/ifconfig.8	Sun Sep 11 22:10:47 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.110 2016/01/07 11:32:21 roy Exp $
+.\"	$NetBSD: ifconfig.8,v 1.111 2016/09/11 22:10:47 sevan Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd January 7, 2016
+.Dd January 7, 2016.
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -316,7 +316,7 @@ to the destination network or host.
 .It Cm mtu Ar n
 Set the maximum transmission unit of the interface to
 .Ar n .
-Most interfaces don't support this option.
+Most interfaces do not support this option.
 .It Cm netmask Ar mask
 .Pq inet, inet6, and ISO
 Specify how much of the address to reserve for subdividing
@@ -388,7 +388,7 @@ can be any value between 0 and 2347.
 The default is 2347, which indicates the RTS/CTS mechanism should not be used.
 .It Cm ssid Ar id
 .Pq IEEE 802.11 devices only
-Configure the Service Set Identifier (a.k.a. the network name)
+Configure the Service Set Identifier (aka the network name)
 for IEEE 802.11-based wireless network interfaces.
 The
 .Ar id
@@ -436,7 +436,7 @@ are configured as WEP keys.
 Note that the order must be match within same network if multiple keys
 are used.
 For IEEE 802.11 wireless network, the length of each key is restricted to
-40 bits, i.e. 5-character string or 10 hexadecimal digits,
+40 bits, i.e., 5-character string or 10 hexadecimal digits,
 while the WaveLAN/IEEE Gold cards accept the 104 bits
 .Pq 13 characters
 key.
@@ -497,7 +497,7 @@ to be used for IEEE 802.11-based wireles
 .Pq IEEE 802.11 devices only
 Unset the desired channel to be used
 for IEEE 802.11-based wireless network interfaces.
-It doesn't affect the channel to be created for IBSS or hostap mode.
+It does not affect the channel to be created for IBSS or hostap mode.
 .It Cm list scan
 .Pq IEEE 802.11 devices only
 Display the access points and/or ad-hoc neighbors



CVS commit: src/sbin/ifconfig

2016-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  7 15:56:17 UTC 2016

Modified Files:
src/sbin/ifconfig: env.c

Log Message:
PR/50909: David Binderman: Optimize memset


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/ifconfig/env.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/env.c
diff -u src/sbin/ifconfig/env.c:1.10 src/sbin/ifconfig/env.c:1.11
--- src/sbin/ifconfig/env.c:1.10	Mon Mar  7 07:48:53 2016
+++ src/sbin/ifconfig/env.c	Mon Mar  7 10:56:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: env.c,v 1.10 2016/03/07 12:48:53 christos Exp $	*/
+/*	$NetBSD: env.c,v 1.11 2016/03/07 15:56:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: env.c,v 1.10 2016/03/07 12:48:53 christos Exp $");
+__RCSID("$NetBSD: env.c,v 1.11 2016/03/07 15:56:17 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -141,8 +141,8 @@ getargdata(prop_dictionary_t env, const 
 		errno = ENAMETOOLONG; 
 		return -1;
 	}
-	memset(buf, 0, buflen);
 	memcpy(buf, prop_data_data_nocopy(data), datalen);
+	memset(buf + datalen, 0, buflen - datalen);
 	return datalen;
 }
 



CVS commit: src/sbin/ifconfig

2016-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  7 12:48:53 UTC 2016

Modified Files:
src/sbin/ifconfig: env.c

Log Message:
PR/50909: David Binderman: Optimize memset


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/ifconfig/env.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/env.c
diff -u src/sbin/ifconfig/env.c:1.9 src/sbin/ifconfig/env.c:1.10
--- src/sbin/ifconfig/env.c:1.9	Thu Feb  7 08:20:51 2013
+++ src/sbin/ifconfig/env.c	Mon Mar  7 07:48:53 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: env.c,v 1.9 2013/02/07 13:20:51 apb Exp $	*/
+/*	$NetBSD: env.c,v 1.10 2016/03/07 12:48:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: env.c,v 1.9 2013/02/07 13:20:51 apb Exp $");
+__RCSID("$NetBSD: env.c,v 1.10 2016/03/07 12:48:53 christos Exp $");
 #endif /* not lint */
 
 #include 
@@ -162,8 +162,8 @@ getargstr(prop_dictionary_t env, const c
 		errno = ENAMETOOLONG; 
 		return -1;
 	}
-	memset(buf, 0, buflen);
 	memcpy(buf, prop_data_data_nocopy(data), datalen);
+	memset(buf + datalen, 0, buflen - datalen);
 	return datalen;
 }
 



CVS commit: src/sbin/ifconfig

2016-02-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Feb 29 16:23:25 UTC 2016

Modified Files:
src/sbin/ifconfig: af_inet.c af_inet6.c

Log Message:
Consistently use estrlcpy for ifr.ifr_name here, not strncpy.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.34 -r1.35 src/sbin/ifconfig/af_inet6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.18 src/sbin/ifconfig/af_inet.c:1.19
--- src/sbin/ifconfig/af_inet.c:1.18	Thu Jan  7 11:32:21 2016
+++ src/sbin/ifconfig/af_inet.c	Mon Feb 29 16:23:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.18 2016/01/07 11:32:21 roy Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.19 2016/02/29 16:23:25 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet.c,v 1.18 2016/01/07 11:32:21 roy Exp $");
+__RCSID("$NetBSD: af_inet.c,v 1.19 2016/02/29 16:23:25 riastradh Exp $");
 #endif /* not lint */
 
 #include  
@@ -231,7 +231,7 @@ in_addr_flags(struct ifaddrs *ifa, int f
 	struct ifreq ifr;
 
 	memset(, 0, sizeof(ifr));
-	strncpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
+	estrlcpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
 	ifr.ifr_addr = *ifa->ifa_addr;
 	if ((s = getsock(AF_INET)) == -1)
 		err(EXIT_FAILURE, "%s: getsock", __func__);

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.34 src/sbin/ifconfig/af_inet6.c:1.35
--- src/sbin/ifconfig/af_inet6.c:1.34	Thu Jan  7 11:32:21 2016
+++ src/sbin/ifconfig/af_inet6.c	Mon Feb 29 16:23:25 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.34 2016/01/07 11:32:21 roy Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.35 2016/02/29 16:23:25 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: af_inet6.c,v 1.34 2016/01/07 11:32:21 roy Exp $");
+__RCSID("$NetBSD: af_inet6.c,v 1.35 2016/02/29 16:23:25 riastradh Exp $");
 #endif /* not lint */
 
 #include  
@@ -488,7 +488,7 @@ in6_addr_flags(struct ifaddrs *ifa, int 
 	if ((s = getsock(AF_INET6)) == -1)
 		err(EXIT_FAILURE, "%s: getsock", __func__);
 	memset(, 0, sizeof(ifr));
-	strncpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
+	estrlcpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
 	ifr.ifr_addr = *(struct sockaddr_in6 *)ifa->ifa_addr;
 	if (prog_ioctl(s, SIOCGIFAFLAG_IN6, ) == -1)
 		err(EXIT_FAILURE, "SIOCGIFAFLAG_IN6");



CVS commit: src/sbin/ifconfig

2015-07-29 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 29 07:42:28 UTC 2015

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
Don't divide flags output

If there are many enabled flags, ifconfig divides flags output into
multiple formatted strings due to snprintb_m, e.g.,
  wm0: flags=8b43UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEXwm0: 
flags=8b43MULTICAST mtu 1500

This behavior is probably unexpected. The change always outputs enabled
flags at once like this:
  wm0: flags=8b43UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST mtu 
1500


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.234 src/sbin/ifconfig/ifconfig.c:1.235
--- src/sbin/ifconfig/ifconfig.c:1.234	Wed Apr 22 17:42:22 2015
+++ src/sbin/ifconfig/ifconfig.c	Wed Jul 29 07:42:27 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.234 2015/04/22 17:42:22 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.235 2015/07/29 07:42:27 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.234 2015/04/22 17:42:22 roy Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.235 2015/07/29 07:42:27 ozaki-r Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -1261,12 +1261,8 @@ status(const struct sockaddr *sdl, prop_
 	if ((ifname = getifinfo(env, oenv, flags)) == NULL)
 		err(EXIT_FAILURE, %s: getifinfo, __func__);
 
-	(void)snprintb_m(fbuf, sizeof(fbuf), IFFBITS, flags, MAX_PRINT_LEN);
-	bp = fbuf;
-	while (*bp != '\0') {
-		printf(%s: flags=%s, ifname, bp[2]);
-		bp += strlen(bp) + 1;
-	}
+	(void)snprintb(fbuf, sizeof(fbuf), IFFBITS, flags);
+	printf(%s: flags=%s, ifname, fbuf);
 
 	estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
 	if (prog_ioctl(s, SIOCGIFMETRIC, ifr) == -1)



CVS commit: src/sbin/ifconfig

2015-05-19 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Tue May 19 08:14:38 UTC 2015

Modified Files:
src/sbin/ifconfig: Makefile

Log Message:
Fix rump.ifconfig shows host's interface names in link local addresses


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sbin/ifconfig/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.55 src/sbin/ifconfig/Makefile:1.56
--- src/sbin/ifconfig/Makefile:1.55	Tue Apr 28 15:14:57 2015
+++ src/sbin/ifconfig/Makefile	Tue May 19 08:14:38 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.55 2015/04/28 15:14:57 christos Exp $
+#	$NetBSD: Makefile,v 1.56 2015/05/19 08:14:38 ozaki-r Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -20,7 +20,7 @@ SRCS+= af_inet6.c
 .include Makefile.inc
 
 .PATH:		${.CURDIR}/../../lib/libc/net
-RUMPSRCS= getifaddrs.c
+RUMPSRCS= getifaddrs.c getnameinfo.c if_indextoname.c
 .if (${MKRUMP} != no)
 CPPFLAGS+= -DRUMP_ACTION
 .endif



CVS commit: src/sbin/ifconfig

2015-05-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue May 12 14:05:29 UTC 2015

Modified Files:
src/sbin/ifconfig: af_inet.c af_inet6.c

Log Message:
ioctl - prog_ioctl as pointed out by pooka@


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.32 -r1.33 src/sbin/ifconfig/af_inet6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.16 src/sbin/ifconfig/af_inet.c:1.17
--- src/sbin/ifconfig/af_inet.c:1.16	Sat May  2 14:43:51 2015
+++ src/sbin/ifconfig/af_inet.c	Tue May 12 14:05:29 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.16 2015/05/02 14:43:51 roy Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.17 2015/05/12 14:05:29 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet.c,v 1.16 2015/05/02 14:43:51 roy Exp $);
+__RCSID($NetBSD: af_inet.c,v 1.17 2015/05/12 14:05:29 roy Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -232,7 +232,7 @@ in_addr_tentative(struct ifaddrs *ifa)
 	ifr.ifr_addr = *ifa-ifa_addr;
 	if ((s = getsock(AF_INET)) == -1)
 		err(EXIT_FAILURE, %s: getsock, __func__);
-	if (ioctl(s, SIOCGIFAFLAG_IN, ifr) == -1)
+	if (prog_ioctl(s, SIOCGIFAFLAG_IN, ifr) == -1)
 		err(EXIT_FAILURE, SIOCGIFAFLAG_IN);
 	return ifr.ifr_addrflags  IN_IFF_TENTATIVE ? true : false;
 #else

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.32 src/sbin/ifconfig/af_inet6.c:1.33
--- src/sbin/ifconfig/af_inet6.c:1.32	Wed Apr 22 17:42:22 2015
+++ src/sbin/ifconfig/af_inet6.c	Tue May 12 14:05:29 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.32 2015/04/22 17:42:22 roy Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.33 2015/05/12 14:05:29 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet6.c,v 1.32 2015/04/22 17:42:22 roy Exp $);
+__RCSID($NetBSD: af_inet6.c,v 1.33 2015/05/12 14:05:29 roy Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -487,7 +487,7 @@ in6_addr_tentative(struct ifaddrs *ifa)
 	memset(ifr, 0, sizeof(ifr));
 	strncpy(ifr.ifr_name, ifa-ifa_name, sizeof(ifr.ifr_name));
 	ifr.ifr_addr = *(struct sockaddr_in6 *)ifa-ifa_addr;
-	if (ioctl(s, SIOCGIFAFLAG_IN6, ifr) == -1)
+	if (prog_ioctl(s, SIOCGIFAFLAG_IN6, ifr) == -1)
 		err(EXIT_FAILURE, SIOCGIFAFLAG_IN6);
 	return ifr.ifr_ifru.ifru_flags6  IN6_IFF_TENTATIVE ? true : false;
 }



CVS commit: src/sbin/ifconfig

2015-05-02 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat May  2 14:43:51 UTC 2015

Modified Files:
src/sbin/ifconfig: af_inet.c

Log Message:
Report IN_IFF_TENTATIVE and friends.
Wait for IN_IFF_TENTATIVE to be removed with the -w flag.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/af_inet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.15 src/sbin/ifconfig/af_inet.c:1.16
--- src/sbin/ifconfig/af_inet.c:1.15	Mon Dec 13 17:35:08 2010
+++ src/sbin/ifconfig/af_inet.c	Sat May  2 14:43:51 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.15 2010/12/13 17:35:08 pooka Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.16 2015/05/02 14:43:51 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet.c,v 1.15 2010/12/13 17:35:08 pooka Exp $);
+__RCSID($NetBSD: af_inet.c,v 1.16 2015/05/02 14:43:51 roy Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -62,12 +62,14 @@ __RCSID($NetBSD: af_inet.c,v 1.15 2010/
 static void in_constructor(void) __attribute__((constructor));
 static void in_status(prop_dictionary_t, prop_dictionary_t, bool);
 static void in_commit_address(prop_dictionary_t, prop_dictionary_t);
+static bool in_addr_tentative(struct ifaddrs *ifa);
 static void in_alias(const char *, prop_dictionary_t, prop_dictionary_t,
 struct in_aliasreq *);
 
 static struct afswtch af = {
 	.af_name = inet, .af_af = AF_INET, .af_status = in_status,
-	.af_addr_commit = in_commit_address
+	.af_addr_commit = in_commit_address,
+	.af_addr_tentative = in_addr_tentative
 };
 
 static void
@@ -137,6 +139,21 @@ in_alias(const char *ifname, prop_dictio
 			strlcpy(hbuf, , sizeof(hbuf)); /* some message? */
 		printf( broadcast %s, hbuf);
 	}
+
+#ifdef IN_IFF_TENTATIVE
+	memcpy(ifr.ifr_addr, creq-ifra_addr, creq-ifra_addr.sin_len);
+	if (prog_ioctl(s, SIOCGIFAFLAG_IN, ifr) == -1) {
+		if (errno != EADDRNOTAVAIL)
+			warn(SIOCGIFAFLAG_IN);
+	} else {
+		if (ifr.ifr_addrflags  IN_IFF_TENTATIVE)
+			printf( tentative);
+		if (ifr.ifr_addrflags  IN_IFF_DUPLICATED)
+			printf( duplicated);
+		if (ifr.ifr_addrflags  IN_IFF_DETACHED)
+			printf( detached);
+	}
+#endif
 }
 
 static void
@@ -203,6 +220,26 @@ in_commit_address(prop_dictionary_t env,
 	commit_address(env, oenv, inparam);
 }
 
+static bool
+in_addr_tentative(struct ifaddrs *ifa)
+{
+#ifdef IN_IFF_TENTATIVE
+	int s;
+	struct ifreq ifr;
+
+	memset(ifr, 0, sizeof(ifr));
+	strncpy(ifr.ifr_name, ifa-ifa_name, sizeof(ifr.ifr_name));
+	ifr.ifr_addr = *ifa-ifa_addr;
+	if ((s = getsock(AF_INET)) == -1)
+		err(EXIT_FAILURE, %s: getsock, __func__);
+	if (ioctl(s, SIOCGIFAFLAG_IN, ifr) == -1)
+		err(EXIT_FAILURE, SIOCGIFAFLAG_IN);
+	return ifr.ifr_addrflags  IN_IFF_TENTATIVE ? true : false;
+#else
+	return false;
+#endif
+}
+
 static void
 in_constructor(void)
 {



CVS commit: src/sbin/ifconfig

2015-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 28 15:14:57 UTC 2015

Modified Files:
src/sbin/ifconfig: Makefile ieee80211.c

Log Message:
remove 80211 stats if small.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sbin/ifconfig/Makefile
cvs rdiff -u -r1.27 -r1.28 src/sbin/ifconfig/ieee80211.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.54 src/sbin/ifconfig/Makefile:1.55
--- src/sbin/ifconfig/Makefile:1.54	Fri Mar  1 13:25:16 2013
+++ src/sbin/ifconfig/Makefile	Tue Apr 28 11:14:57 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.54 2013/03/01 18:25:16 joerg Exp $
+#	$NetBSD: Makefile,v 1.55 2015/04/28 15:14:57 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -25,6 +25,10 @@ RUMPSRCS= getifaddrs.c
 CPPFLAGS+= -DRUMP_ACTION
 .endif
 
+.ifdef SMALLPROG
+CPPFLAGS+=-DSMALL
+.endif
+
 CPPFLAGS+=-I${NETBSDSRCDIR}/sys/dist/pf/
 SRCS+= pfsync.c
 

Index: src/sbin/ifconfig/ieee80211.c
diff -u src/sbin/ifconfig/ieee80211.c:1.27 src/sbin/ifconfig/ieee80211.c:1.28
--- src/sbin/ifconfig/ieee80211.c:1.27	Tue Jan  7 20:56:20 2014
+++ src/sbin/ifconfig/ieee80211.c	Tue Apr 28 11:14:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.27 2014/01/08 01:56:20 christos Exp $	*/
+/*	$NetBSD: ieee80211.c,v 1.28 2015/04/28 15:14:57 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: ieee80211.c,v 1.27 2014/01/08 01:56:20 christos Exp $);
+__RCSID($NetBSD: ieee80211.c,v 1.28 2015/04/28 15:14:57 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -482,6 +482,7 @@ scan_exec(prop_dictionary_t env, prop_di
 static void
 ieee80211_statistics(prop_dictionary_t env)
 {
+#ifndef SMALL
 	struct ieee80211_stats stats;
 	struct ifreq ifr;
 
@@ -584,6 +585,7 @@ ieee80211_statistics(prop_dictionary_t e
 	STAT_PRINT(is_ff_decap, fast frames decap'd);
 	STAT_PRINT(is_ff_encap, fast frames encap'd for tx);
 	STAT_PRINT(is_rx_badbintval, rx frame w/ bogus bintval);
+#endif
 }
 
 static void



CVS commit: src/sbin/ifconfig

2015-04-22 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Apr 22 17:42:22 UTC 2015

Modified Files:
src/sbin/ifconfig: af_inet6.c ifconfig.c util.h

Log Message:
Move the INET6 specific code for wait_dad_exec() into af_inet6
by using a new afswtch hook af_addr_tentative.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sbin/ifconfig/af_inet6.c
cvs rdiff -u -r1.233 -r1.234 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.10 -r1.11 src/sbin/ifconfig/util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.31 src/sbin/ifconfig/af_inet6.c:1.32
--- src/sbin/ifconfig/af_inet6.c:1.31	Tue Jan 20 22:13:19 2015
+++ src/sbin/ifconfig/af_inet6.c	Wed Apr 22 17:42:22 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.31 2015/01/20 22:13:19 roy Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.32 2015/04/22 17:42:22 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet6.c,v 1.31 2015/01/20 22:13:19 roy Exp $);
+__RCSID($NetBSD: af_inet6.c,v 1.32 2015/04/22 17:42:22 roy Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -72,6 +72,7 @@ static int setia6vltime_impl(prop_dictio
 static int setia6lifetime(prop_dictionary_t, int64_t, time_t *, uint32_t *);
 
 static void in6_status(prop_dictionary_t, prop_dictionary_t, bool);
+static bool in6_addr_tentative(struct ifaddrs *ifa);
 
 static struct usage_func usage;
 static cmdloop_branch_t branch[2];
@@ -101,7 +102,8 @@ struct pkw inet6 = PKW_INITIALIZER(inet
 
 static struct afswtch in6af = {
 	.af_name = inet6, .af_af = AF_INET6, .af_status = in6_status,
-	.af_addr_commit = in6_commit_address
+	.af_addr_commit = in6_commit_address,
+	.af_addr_tentative = in6_addr_tentative
 };
 
 static int
@@ -474,6 +476,22 @@ in6_commit_address(prop_dictionary_t env
 	commit_address(env, oenv, in6param);
 }
 
+static bool
+in6_addr_tentative(struct ifaddrs *ifa)
+{
+	int s;
+	struct in6_ifreq ifr;
+
+	if ((s = getsock(AF_INET6)) == -1)
+		err(EXIT_FAILURE, %s: getsock, __func__);
+	memset(ifr, 0, sizeof(ifr));
+	strncpy(ifr.ifr_name, ifa-ifa_name, sizeof(ifr.ifr_name));
+	ifr.ifr_addr = *(struct sockaddr_in6 *)ifa-ifa_addr;
+	if (ioctl(s, SIOCGIFAFLAG_IN6, ifr) == -1)
+		err(EXIT_FAILURE, SIOCGIFAFLAG_IN6);
+	return ifr.ifr_ifru.ifru_flags6  IN6_IFF_TENTATIVE ? true : false;
+}
+
 static void
 in6_usage(prop_dictionary_t env)
 {

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.233 src/sbin/ifconfig/ifconfig.c:1.234
--- src/sbin/ifconfig/ifconfig.c:1.233	Fri Sep 12 08:54:26 2014
+++ src/sbin/ifconfig/ifconfig.c	Wed Apr 22 17:42:22 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.233 2014/09/12 08:54:26 martin Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.234 2015/04/22 17:42:22 roy Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.233 2014/09/12 08:54:26 martin Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.234 2015/04/22 17:42:22 roy Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -515,14 +515,12 @@ no_cmds_exec(prop_dictionary_t env, prop
 static int
 wait_dad_exec(prop_dictionary_t env, prop_dictionary_t oenv)
 {
-#ifdef INET6
 	bool waiting;
 	struct ifaddrs *ifaddrs, *ifa;
-	struct in6_ifreq ifr6;
-	int s;
 	const struct timespec ts = { .tv_sec = 0, .tv_nsec = WAIT_DAD };
 	const struct timespec add = { .tv_sec = wflag_secs, .tv_nsec = 0};
 	struct timespec now, end = { .tv_sec = wflag_secs, .tv_nsec = 0};
+	const struct afswtch *afp;
 
 	if (wflag_secs) {
 		if (clock_gettime(CLOCK_MONOTONIC, now) == -1)
@@ -538,27 +536,13 @@ wait_dad_exec(prop_dictionary_t env, pro
 		for (ifa = ifaddrs; ifa; ifa = ifa-ifa_next) {
 			if (ifa-ifa_addr == NULL)
 continue;
-			switch (ifa-ifa_addr-sa_family) {
-			case AF_INET6:
-memset(ifr6, 0, sizeof(ifr6));
-strncpy(ifr6.ifr_name,
-ifa-ifa_name, sizeof(ifr6.ifr_name));
-ifr6.ifr_addr =
-*(struct sockaddr_in6 *)ifa-ifa_addr;
-if ((s = getsock(AF_INET6)) == -1)
-	err(EXIT_FAILURE,
-	%s: getsock, __func__);
-if (ioctl(s, SIOCGIFAFLAG_IN6, ifr6) == -1)
-	err(EXIT_FAILURE, SIOCGIFAFLAG_IN6);
-if (ifr6.ifr_ifru.ifru_flags6 
-IN6_IFF_TENTATIVE)
-{
-	waiting = true;
-	break;
-}
-			}
-			if (waiting)
+			afp = lookup_af_bynum(ifa-ifa_addr-sa_family);
+			if (afp  afp-af_addr_tentative 
+			afp-af_addr_tentative(ifa))
+			{
+waiting = true;
 break;
+			}
 		}
 		if (!waiting)
 			break;
@@ -572,7 +556,6 @@ wait_dad_exec(prop_dictionary_t env, pro
 	}
 
 	freeifaddrs(ifaddrs);
-#endif
 	exit(EXIT_SUCCESS);
 }
 

Index: src/sbin/ifconfig/util.h
diff -u src/sbin/ifconfig/util.h:1.10 

CVS commit: src/sbin/ifconfig

2015-01-20 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Jan 20 22:13:19 UTC 2015

Modified Files:
src/sbin/ifconfig: af_inet6.c

Log Message:
Display the IPv6 address flags autoconf and temporary


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sbin/ifconfig/af_inet6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.30 src/sbin/ifconfig/af_inet6.c:1.31
--- src/sbin/ifconfig/af_inet6.c:1.30	Mon Oct 20 14:50:09 2014
+++ src/sbin/ifconfig/af_inet6.c	Tue Jan 20 22:13:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.30 2014/10/20 14:50:09 roy Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.31 2015/01/20 22:13:19 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet6.c,v 1.30 2014/10/20 14:50:09 roy Exp $);
+__RCSID($NetBSD: af_inet6.c,v 1.31 2015/01/20 22:13:19 roy Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -330,6 +330,10 @@ in6_alias(const char *ifname, prop_dicti
 			printf( detached);
 		if (ifr6.ifr_ifru.ifru_flags6  IN6_IFF_DEPRECATED)
 			printf( deprecated);
+		if (ifr6.ifr_ifru.ifru_flags6  IN6_IFF_AUTOCONF)
+			printf( autoconf);
+		if (ifr6.ifr_ifru.ifru_flags6  IN6_IFF_TEMPORARY)
+			printf( temporary);
 	}
 
 	if (scopeid)



CVS commit: src/sbin/ifconfig

2014-09-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Sep 15 06:46:04 UTC 2014

Modified Files:
src/sbin/ifconfig: vlan.c

Log Message:
Add -vlanif to the help message of ifconfig

PR 49114


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/ifconfig/vlan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/vlan.c
diff -u src/sbin/ifconfig/vlan.c:1.13 src/sbin/ifconfig/vlan.c:1.14
--- src/sbin/ifconfig/vlan.c:1.13	Tue Jul 28 18:22:33 2009
+++ src/sbin/ifconfig/vlan.c	Mon Sep 15 06:46:04 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vlan.c,v 1.13 2009/07/28 18:22:33 dyoung Exp $	*/
+/*	$NetBSD: vlan.c,v 1.14 2014/09/15 06:46:04 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: vlan.c,v 1.13 2009/07/28 18:22:33 dyoung Exp $);
+__RCSID($NetBSD: vlan.c,v 1.14 2014/09/15 06:46:04 ozaki-r Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -175,7 +175,7 @@ vlan_status(prop_dictionary_t env, prop_
 static void
 vlan_usage(prop_dictionary_t env)
 {
-	fprintf(stderr, \t[ vlan n vlanif i ]\n);
+	fprintf(stderr, \t[ vlan n vlanif i ] [ -vlanif i ]\n);
 }
 
 static void



CVS commit: src/sbin/ifconfig

2014-09-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Sep 15 06:48:05 UTC 2014

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Write about -vlanif in ifconfig.8

PR 49114


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.107 src/sbin/ifconfig/ifconfig.8:1.108
--- src/sbin/ifconfig/ifconfig.8:1.107	Thu Sep 11 13:10:04 2014
+++ src/sbin/ifconfig/ifconfig.8	Mon Sep 15 06:48:05 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: ifconfig.8,v 1.107 2014/09/11 13:10:04 roy Exp $
+.\	$NetBSD: ifconfig.8,v 1.108 2014/09/15 06:48:05 ozaki-r Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd January 28, 2012
+.Dd September 15, 2014
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -637,6 +637,12 @@ Note that
 and
 .Cm vlan
 must be set at the same time.
+.It Cm -vlanif Ar iface
+Dissociate
+.Ar iface
+from the
+.Xr vlan 4
+interface.
 .It Cm agrport Ar iface
 Add
 .Ar iface



CVS commit: src/sbin/ifconfig

2014-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 12 08:54:26 UTC 2014

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
Initialize timespec end for the benefit of some gcc versions getting
may be used uninitialized warnings wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.232 src/sbin/ifconfig/ifconfig.c:1.233
--- src/sbin/ifconfig/ifconfig.c:1.232	Thu Sep 11 13:10:04 2014
+++ src/sbin/ifconfig/ifconfig.c	Fri Sep 12 08:54:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.232 2014/09/11 13:10:04 roy Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.233 2014/09/12 08:54:26 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.232 2014/09/11 13:10:04 roy Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.233 2014/09/12 08:54:26 martin Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -522,7 +522,7 @@ wait_dad_exec(prop_dictionary_t env, pro
 	int s;
 	const struct timespec ts = { .tv_sec = 0, .tv_nsec = WAIT_DAD };
 	const struct timespec add = { .tv_sec = wflag_secs, .tv_nsec = 0};
-	struct timespec now, end;
+	struct timespec now, end = { .tv_sec = wflag_secs, .tv_nsec = 0};
 
 	if (wflag_secs) {
 		if (clock_gettime(CLOCK_MONOTONIC, now) == -1)



CVS commit: src/sbin/ifconfig

2014-01-19 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Jan 19 22:31:13 UTC 2014

Modified Files:
src/sbin/ifconfig: af_link.c

Log Message:
Rename link to link_pkw to avoid shadowing the link syscall.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/af_link.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_link.c
diff -u src/sbin/ifconfig/af_link.c:1.6 src/sbin/ifconfig/af_link.c:1.7
--- src/sbin/ifconfig/af_link.c:1.6	Tue Apr 21 22:46:39 2009
+++ src/sbin/ifconfig/af_link.c	Sun Jan 19 22:31:13 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_link.c,v 1.6 2009/04/21 22:46:39 dyoung Exp $	*/
+/*	$NetBSD: af_link.c,v 1.7 2014/01/19 22:31:13 matt Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_link.c,v 1.6 2009/04/21 22:46:39 dyoung Exp $);
+__RCSID($NetBSD: af_link.c,v 1.7 2014/01/19 22:31:13 matt Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -59,7 +59,7 @@ static const struct kwinst linkkw[] = {
 	   .k_bool = true, .k_nextparser = command_root.pb_parser}
 };
 
-struct pkw link = PKW_INITIALIZER(link, link, NULL, NULL,
+struct pkw link_pkw = PKW_INITIALIZER(link_pkw, link, NULL, NULL,
 linkkw, __arraycount(linkkw), NULL);
 
 static struct afswtch af = {
@@ -127,6 +127,6 @@ static void
 link_constructor(void)
 {
 	register_family(af);
-	cmdloop_branch_init(branch, link.pk_parser);
+	cmdloop_branch_init(branch, link_pkw.pk_parser);
 	register_cmdloop_branch(branch);
 }



CVS commit: src/sbin/ifconfig

2014-01-07 Thread Arnaud Degroote
Module Name:src
Committed By:   degroote
Date:   Tue Jan  7 20:25:24 UTC 2014

Modified Files:
src/sbin/ifconfig: ieee80211.c ifconfig.8

Log Message:
Before scanning, check if the card is up. If it is not the case, exit
with some useful error message. Add some note about this fact in the man
page too.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/ifconfig/ieee80211.c
cvs rdiff -u -r1.105 -r1.106 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ieee80211.c
diff -u src/sbin/ifconfig/ieee80211.c:1.25 src/sbin/ifconfig/ieee80211.c:1.26
--- src/sbin/ifconfig/ieee80211.c:1.25	Mon Dec 13 17:35:08 2010
+++ src/sbin/ifconfig/ieee80211.c	Tue Jan  7 20:25:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.25 2010/12/13 17:35:08 pooka Exp $	*/
+/*	$NetBSD: ieee80211.c,v 1.26 2014/01/07 20:25:24 degroote Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: ieee80211.c,v 1.25 2010/12/13 17:35:08 pooka Exp $);
+__RCSID($NetBSD: ieee80211.c,v 1.26 2014/01/07 20:25:24 degroote Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -463,8 +463,19 @@ setifpowersavesleep(prop_dictionary_t en
 static int
 scan_exec(prop_dictionary_t env, prop_dictionary_t oenv)
 {
+	struct ifreq ifr;
+
+	if (direct_ioctl(env, SIOCGIFFLAGS, ifr) == -1) {
+		perror(ioctl(SIOCGIFFLAGS);
+		return -1;
+	}
+
+	if ((ifr.ifr_flags  IFF_UP) == 0) 
+		errx(EXIT_FAILURE, The interface must be up before scanning.);
+
 	scan_and_wait(env);
 	list_scan(env);
+
 	return 0;
 }
 

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.105 src/sbin/ifconfig/ifconfig.8:1.106
--- src/sbin/ifconfig/ifconfig.8:1.105	Sat Nov  9 13:10:35 2013
+++ src/sbin/ifconfig/ifconfig.8	Tue Jan  7 20:25:24 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: ifconfig.8,v 1.105 2013/11/09 13:10:35 kefren Exp $
+.\	$NetBSD: ifconfig.8,v 1.106 2014/01/07 20:25:24 degroote Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -503,6 +503,7 @@ The
 flag may be used to display long SSIDs.
 .Fl v
 also causes received information elements to be displayed symbolically.
+The interface must be up before any scanning operation.
 Only the super-user can use this command.
 .It Cm tunnel Ar src_addr Ns Oo Ar ,src_port Oc Ar dest_addr Ns Oo Ar ,dest_port
 .Oc



CVS commit: src/sbin/ifconfig

2014-01-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan  8 01:56:20 UTC 2014

Modified Files:
src/sbin/ifconfig: ieee80211.c

Log Message:
perror is obsolete, use warn and add missing paren.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sbin/ifconfig/ieee80211.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ieee80211.c
diff -u src/sbin/ifconfig/ieee80211.c:1.26 src/sbin/ifconfig/ieee80211.c:1.27
--- src/sbin/ifconfig/ieee80211.c:1.26	Tue Jan  7 15:25:24 2014
+++ src/sbin/ifconfig/ieee80211.c	Tue Jan  7 20:56:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.26 2014/01/07 20:25:24 degroote Exp $	*/
+/*	$NetBSD: ieee80211.c,v 1.27 2014/01/08 01:56:20 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: ieee80211.c,v 1.26 2014/01/07 20:25:24 degroote Exp $);
+__RCSID($NetBSD: ieee80211.c,v 1.27 2014/01/08 01:56:20 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -466,7 +466,7 @@ scan_exec(prop_dictionary_t env, prop_di
 	struct ifreq ifr;
 
 	if (direct_ioctl(env, SIOCGIFFLAGS, ifr) == -1) {
-		perror(ioctl(SIOCGIFFLAGS);
+		warn(ioctl(SIOCGIFFLAGS));
 		return -1;
 	}
 
@@ -739,7 +739,7 @@ scan_and_wait(prop_dictionary_t env)
 
 	sroute = prog_socket(PF_ROUTE, SOCK_RAW, 0);
 	if (sroute  0) {
-		perror(socket(PF_ROUTE,SOCK_RAW));
+		warn(socket(PF_ROUTE,SOCK_RAW));
 		return;
 	}
 	/* NB: only root can trigger a scan so ignore errors */
@@ -750,7 +750,7 @@ scan_and_wait(prop_dictionary_t env)
 
 		do {
 			if (prog_read(sroute, buf, sizeof(buf))  0) {
-perror(read(PF_ROUTE));
+warn(read(PF_ROUTE));
 break;
 			}
 			rtm = (struct rt_msghdr *) buf;



CVS commit: src/sbin/ifconfig

2013-11-09 Thread Mihai Chelaru
Module Name:src
Committed By:   kefren
Date:   Sat Nov  9 13:10:35 UTC 2013

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Bring tunnel src_addr and dst_addr on the same line


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.104 src/sbin/ifconfig/ifconfig.8:1.105
--- src/sbin/ifconfig/ifconfig.8:1.104	Sat Jan 28 15:01:44 2012
+++ src/sbin/ifconfig/ifconfig.8	Sat Nov  9 13:10:35 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: ifconfig.8,v 1.104 2012/01/28 15:01:44 mbalmer Exp $
+.\	$NetBSD: ifconfig.8,v 1.105 2013/11/09 13:10:35 kefren Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -504,8 +504,8 @@ flag may be used to display long SSIDs.
 .Fl v
 also causes received information elements to be displayed symbolically.
 Only the super-user can use this command.
-.It Cm tunnel Ar src_addr Ns Op Ar ,src_port
-.Ar dest_addr Ns Op Ar ,dest_port
+.It Cm tunnel Ar src_addr Ns Oo Ar ,src_port Oc Ar dest_addr Ns Oo Ar ,dest_port
+.Oc
 .Pq IP tunnel devices only
 Configure the physical source and destination address for IP tunnel
 interfaces, including



CVS commit: src/sbin/ifconfig

2013-10-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 19 00:35:30 UTC 2013

Modified Files:
src/sbin/ifconfig: af_atalk.c af_inet6.c ifconfig.c tunnel.c util.c
util.h

Log Message:
use the new scopeid functions


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/ifconfig/af_atalk.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/ifconfig/af_inet6.c
cvs rdiff -u -r1.230 -r1.231 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.17 -r1.18 src/sbin/ifconfig/tunnel.c
cvs rdiff -u -r1.16 -r1.17 src/sbin/ifconfig/util.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/ifconfig/util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_atalk.c
diff -u src/sbin/ifconfig/af_atalk.c:1.18 src/sbin/ifconfig/af_atalk.c:1.19
--- src/sbin/ifconfig/af_atalk.c:1.18	Sun Aug 14 08:15:15 2011
+++ src/sbin/ifconfig/af_atalk.c	Fri Oct 18 20:35:30 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_atalk.c,v 1.18 2011/08/14 12:15:15 christos Exp $	*/
+/*	$NetBSD: af_atalk.c,v 1.19 2013/10/19 00:35:30 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_atalk.c,v 1.18 2011/08/14 12:15:15 christos Exp $);
+__RCSID($NetBSD: af_atalk.c,v 1.19 2013/10/19 00:35:30 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -183,9 +183,8 @@ static void
 sat_print1(const char *prefix, const struct sockaddr *sa)
 {
 	char buf[40];
-	int rc;
 
-	rc = getnameinfo(sa, sa-sa_len, buf, sizeof(buf), NULL, 0, 0);
+	(void)getnameinfo(sa, sa-sa_len, buf, sizeof(buf), NULL, 0, 0);
 	
 	printf(%s%s, prefix, buf);
 }

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.27 src/sbin/ifconfig/af_inet6.c:1.28
--- src/sbin/ifconfig/af_inet6.c:1.27	Mon Dec 13 12:35:08 2010
+++ src/sbin/ifconfig/af_inet6.c	Fri Oct 18 20:35:30 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.27 2010/12/13 17:35:08 pooka Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.28 2013/10/19 00:35:30 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet6.c,v 1.27 2010/12/13 17:35:08 pooka Exp $);
+__RCSID($NetBSD: af_inet6.c,v 1.28 2013/10/19 00:35:30 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -71,7 +71,6 @@ static int setia6vltime_impl(prop_dictio
 
 static int setia6lifetime(prop_dictionary_t, int64_t, time_t *, uint32_t *);
 
-static void in6_delscopeid(struct sockaddr_in6 *sin6);
 static void in6_status(prop_dictionary_t, prop_dictionary_t, bool);
 
 static struct usage_func usage;
@@ -257,18 +256,6 @@ setia6eui64_impl(prop_dictionary_t env, 
 	return 0;
 }
 
-/* KAME idiosyncrasy */
-static void
-in6_delscopeid(struct sockaddr_in6 *sin6)
-{
-	if (!IN6_IS_ADDR_LINKLOCAL(sin6-sin6_addr) ||
-	sin6-sin6_scope_id == 0)
-		return;
-
-	*(u_int16_t *)sin6-sin6_addr.s6_addr[2] = htons(sin6-sin6_scope_id);
-	sin6-sin6_scope_id = 0;
-}
-
 /* XXX not really an alias */
 void
 in6_alias(const char *ifname, prop_dictionary_t env, prop_dictionary_t oenv,
@@ -291,7 +278,7 @@ in6_alias(const char *ifname, prop_dicti
 
 	sin6 = creq-ifr_addr;
 
-	in6_fillscopeid(sin6);
+	inet6_getscopeid(sin6, 1);
 	scopeid = sin6-sin6_scope_id;
 	if (getnameinfo((const struct sockaddr *)sin6, sin6-sin6_len,
 			hbuf, sizeof(hbuf), NULL, 0, niflag))
@@ -311,7 +298,7 @@ in6_alias(const char *ifname, prop_dicti
 			ifr6.ifr_addr.sin6_len = sizeof(struct sockaddr_in6);
 		}
 		sin6 = ifr6.ifr_addr;
-		in6_fillscopeid(sin6);
+		inet6_getscopeid(sin6, 1);
 		hbuf[0] = '\0';
 		if (getnameinfo((struct sockaddr *)sin6, sin6-sin6_len,
 hbuf, sizeof(hbuf), NULL, 0, niflag))
@@ -419,8 +406,8 @@ in6_pre_aifaddr(prop_dictionary_t env, c
 	setia6vltime_impl(env, ifra);
 	setia6pltime_impl(env, ifra);
 	setia6flags_impl(env, ifra);
-	in6_delscopeid(ifra-ifra_addr);
-	in6_delscopeid(ifra-ifra_dstaddr);
+	inet6_putscopeid(ifra-ifra_addr, 1);
+	inet6_putscopeid(ifra-ifra_dstaddr, 1);
 
 	return 0;
 }

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.230 src/sbin/ifconfig/ifconfig.c:1.231
--- src/sbin/ifconfig/ifconfig.c:1.230	Wed Jul 17 11:40:42 2013
+++ src/sbin/ifconfig/ifconfig.c	Fri Oct 18 20:35:30 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.230 2013/07/17 15:40:42 christos Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.231 2013/10/19 00:35:30 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.230 2013/07/17 15:40:42 christos Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.231 2013/10/19 00:35:30 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -901,12 +901,10 @@ setifaddr(prop_dictionary_t env, prop_di
 static int
 setifnetmask(prop_dictionary_t env, 

CVS commit: src/sbin/ifconfig

2013-07-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jul 17 15:40:42 UTC 2013

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
Allow -v to be used with other commands (list scan for example) as documented.


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.229 src/sbin/ifconfig/ifconfig.c:1.230
--- src/sbin/ifconfig/ifconfig.c:1.229	Thu Feb  7 08:21:34 2013
+++ src/sbin/ifconfig/ifconfig.c	Wed Jul 17 11:40:42 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.229 2013/02/07 13:21:34 apb Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.230 2013/07/17 15:40:42 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.229 2013/02/07 13:21:34 apb Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.230 2013/07/17 15:40:42 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -621,7 +621,6 @@ main(int argc, char **argv)
 
 		case 'L':
 		case 'm':
-		case 'v':
 		case 'z':
 			if (start != opt_family_only.pb_parser)
 start = iface_opt_family_only.pif_parser;



CVS commit: src/sbin/ifconfig

2013-02-07 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Thu Feb  7 11:24:15 UTC 2013

Modified Files:
src/sbin/ifconfig: env.c

Log Message:
Don't call prop_distionary_make_immutable on a NULL pointer.
Coverity CID 275179.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/env.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/env.c
diff -u src/sbin/ifconfig/env.c:1.7 src/sbin/ifconfig/env.c:1.8
--- src/sbin/ifconfig/env.c:1.7	Mon Dec 13 17:35:08 2010
+++ src/sbin/ifconfig/env.c	Thu Feb  7 11:24:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: env.c,v 1.7 2010/12/13 17:35:08 pooka Exp $	*/
+/*	$NetBSD: env.c,v 1.8 2013/02/07 11:24:15 apb Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: env.c,v 1.7 2010/12/13 17:35:08 pooka Exp $);
+__RCSID($NetBSD: env.c,v 1.8 2013/02/07 11:24:15 apb Exp $);
 #endif /* not lint */
 
 #include errno.h
@@ -67,7 +67,8 @@ prop_dictionary_augment(prop_dictionary_
 		}
 	}
 	prop_object_iterator_release(i);
-	prop_dictionary_make_immutable(d);
+	if (d !== NULL)
+		prop_dictionary_make_immutable(d);
 	return d;
 }
 



CVS commit: src/sbin/ifconfig

2013-02-07 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Thu Feb  7 13:20:51 UTC 2013

Modified Files:
src/sbin/ifconfig: env.c

Log Message:
Avoid dereferencing NULL.  Coverity CID 275201.
Also fix a typo in previous: !== should be !=


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sbin/ifconfig/env.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/env.c
diff -u src/sbin/ifconfig/env.c:1.8 src/sbin/ifconfig/env.c:1.9
--- src/sbin/ifconfig/env.c:1.8	Thu Feb  7 11:24:15 2013
+++ src/sbin/ifconfig/env.c	Thu Feb  7 13:20:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: env.c,v 1.8 2013/02/07 11:24:15 apb Exp $	*/
+/*	$NetBSD: env.c,v 1.9 2013/02/07 13:20:51 apb Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: env.c,v 1.8 2013/02/07 11:24:15 apb Exp $);
+__RCSID($NetBSD: env.c,v 1.9 2013/02/07 13:20:51 apb Exp $);
 #endif /* not lint */
 
 #include errno.h
@@ -53,10 +53,12 @@ prop_dictionary_augment(prop_dictionary_
 	const char *key;
 
 	d = prop_dictionary_copy_mutable(bottom);
+	if (d == NULL)
+		return NULL;
 
 	i = prop_dictionary_iterator(top);
 
-	while ((ko = prop_object_iterator_next(i)) != NULL) {
+	while (i != NULL  (ko = prop_object_iterator_next(i)) != NULL) {
 		k = (prop_dictionary_keysym_t)ko;
 		key = prop_dictionary_keysym_cstring_nocopy(k);
 		o = prop_dictionary_get_keysym(top, k);
@@ -66,8 +68,9 @@ prop_dictionary_augment(prop_dictionary_
 			break;
 		}
 	}
-	prop_object_iterator_release(i);
-	if (d !== NULL)
+	if (i != NULL)
+		prop_object_iterator_release(i);
+	if (d != NULL)
 		prop_dictionary_make_immutable(d);
 	return d;
 }



CVS commit: src/sbin/ifconfig

2013-02-07 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Thu Feb  7 13:21:35 UTC 2013

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
Abort on error from prop_dictionary_augment.


To generate a diff of this commit:
cvs rdiff -u -r1.228 -r1.229 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.228 src/sbin/ifconfig/ifconfig.c:1.229
--- src/sbin/ifconfig/ifconfig.c:1.228	Thu Nov  1 13:43:23 2012
+++ src/sbin/ifconfig/ifconfig.c	Thu Feb  7 13:21:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.228 2012/11/01 13:43:23 pgoyette Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.229 2013/02/07 13:21:34 apb Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.228 2012/11/01 13:43:23 pgoyette Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.229 2013/02/07 13:21:34 apb Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -681,8 +681,12 @@ main(int argc, char **argv)
 	env = (nmatch  0) ? match[(int)nmatch - 1].m_env : NULL;
 	if (env == NULL)
 		env = oenv;
-	else
+	else {
 		env = prop_dictionary_augment(env, oenv);
+		if (env == NULL)
+			err(EXIT_FAILURE, %s: prop_dictionary_augment,
+			__func__);
+	}
 
 	/* Process any media commands that may have been issued. */
 	process_media_commands(env);



CVS commit: src/sbin/ifconfig

2012-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 30 22:50:43 UTC 2012

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
PR/46579: Takahiro HAYASHI: ifconfig clone destroy should not print useless
diagnostic and exit with an error code. Get the interface name and flags
opportunistically to allow the code to return normally if it does not need
to do anything.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/af_inetany.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.15 src/sbin/ifconfig/af_inetany.c:1.16
--- src/sbin/ifconfig/af_inetany.c:1.15	Fri Mar 16 22:25:08 2012
+++ src/sbin/ifconfig/af_inetany.c	Sun Dec 30 17:50:42 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.15 2012/03/17 02:25:08 christos Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.16 2012/12/30 22:50:42 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inetany.c,v 1.15 2012/03/17 02:25:08 christos Exp $);
+__RCSID($NetBSD: af_inetany.c,v 1.16 2012/12/30 22:50:42 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -80,7 +80,7 @@ commit_address(prop_dictionary_t env, pr
 	if ((s = getsock(af)) == -1)
 		err(EXIT_FAILURE, %s: getsock, __func__);
 
-	if ((ifname = getifinfo(env, oenv, flags)) == NULL)
+	if ((ifname = getifname(env)) == NULL)
 		err(EXIT_FAILURE, %s: getifinfo, __func__);
 
 	strlcpy(param-name[0].buf, ifname, param-name[0].buflen);
@@ -126,6 +126,9 @@ commit_address(prop_dictionary_t env, pr
 	/* TBD: read matching ifaddr from kernel, use the netmask as default
 	 * TBD: handle preference
 	 */
+	if (getifflags(env, oenv, flags) == -1)
+		err(EXIT_FAILURE, %s: getifflags, __func__);
+
 	switch (flags  (IFF_BROADCAST|IFF_POINTOPOINT)) {
 	case IFF_BROADCAST:
 		if (brd != NULL)



CVS commit: src/sbin/ifconfig

2012-12-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 30 22:52:35 UTC 2012

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
fix function name in error messages.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/ifconfig/af_inetany.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.16 src/sbin/ifconfig/af_inetany.c:1.17
--- src/sbin/ifconfig/af_inetany.c:1.16	Sun Dec 30 17:50:42 2012
+++ src/sbin/ifconfig/af_inetany.c	Sun Dec 30 17:52:35 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.16 2012/12/30 22:50:42 christos Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.17 2012/12/30 22:52:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inetany.c,v 1.16 2012/12/30 22:50:42 christos Exp $);
+__RCSID($NetBSD: af_inetany.c,v 1.17 2012/12/30 22:52:35 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -81,7 +81,7 @@ commit_address(prop_dictionary_t env, pr
 		err(EXIT_FAILURE, %s: getsock, __func__);
 
 	if ((ifname = getifname(env)) == NULL)
-		err(EXIT_FAILURE, %s: getifinfo, __func__);
+		err(EXIT_FAILURE, %s: getifname, __func__);
 
 	strlcpy(param-name[0].buf, ifname, param-name[0].buflen);
 	strlcpy(param-name[1].buf, ifname, param-name[1].buflen);



CVS commit: src/sbin/ifconfig

2012-11-01 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Nov  1 13:43:23 UTC 2012

Modified Files:
src/sbin/ifconfig: ether.c ifconfig.c

Log Message:
Use snprintb_m(3) to split flags/capabilities/enabled across multiple
output lines.

As discussed on current-users


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/ifconfig/ether.c
cvs rdiff -u -r1.227 -r1.228 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ether.c
diff -u src/sbin/ifconfig/ether.c:1.1 src/sbin/ifconfig/ether.c:1.2
--- src/sbin/ifconfig/ether.c:1.1	Wed Oct 31 10:17:34 2012
+++ src/sbin/ifconfig/ether.c	Thu Nov  1 13:43:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ether.c,v 1.1 2012/10/31 10:17:34 msaitoh Exp $	*/
+/*	$NetBSD: ether.c,v 1.2 2012/11/01 13:43:23 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: ether.c,v 1.1 2012/10/31 10:17:34 msaitoh Exp $);
+__RCSID($NetBSD: ether.c,v 1.2 2012/11/01 13:43:23 pgoyette Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -58,11 +58,14 @@ static void ether_constructor(void) __at
 
 static status_func_t status;
 
+#define MAX_PRINT_LEN 55
+
 void
 ether_status(prop_dictionary_t env, prop_dictionary_t oenv)
 {
 	struct eccapreq eccr;
 	char fbuf[BUFSIZ];
+	char *bp;
 
 	memset(eccr, 0, sizeof(eccr));
 
@@ -70,12 +73,20 @@ ether_status(prop_dictionary_t env, prop
 		return;
 
 	if (eccr.eccr_capabilities != 0) {
-		(void)snprintb(fbuf, sizeof(fbuf), ECCAPBITS,
-		eccr.eccr_capabilities);
-		printf(\tec_capabilities=%s\n, fbuf[2]);
-		(void)snprintb(fbuf, sizeof(fbuf), ECCAPBITS,
-		eccr.eccr_capenable);
-		printf(\tec_enabled=%s\n, fbuf[2]);
+		(void)snprintb_m(fbuf, sizeof(fbuf), ECCAPBITS,
+		eccr.eccr_capabilities, MAX_PRINT_LEN);
+		bp = fbuf;
+		while (*bp != '\0') {
+			printf(\tec_capabilities=%s\n, bp[2]);
+			bp += strlen(bp) + 1;
+		}
+		(void)snprintb_m(fbuf, sizeof(fbuf), ECCAPBITS,
+		eccr.eccr_capenable, MAX_PRINT_LEN);
+		bp = fbuf;
+		while (*bp != '\0') {
+			printf(\tec_enabled=%s\n, bp[2]);
+			bp += strlen(bp) + 1;
+		}
 	}
 }
 

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.227 src/sbin/ifconfig/ifconfig.c:1.228
--- src/sbin/ifconfig/ifconfig.c:1.227	Sat Jan 28 15:01:44 2012
+++ src/sbin/ifconfig/ifconfig.c	Thu Nov  1 13:43:23 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.227 2012/01/28 15:01:44 mbalmer Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.228 2012/11/01 13:43:23 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.227 2012/01/28 15:01:44 mbalmer Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.228 2012/11/01 13:43:23 pgoyette Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -1163,6 +1163,9 @@ print_human_bytes(bool humanize, uint64_
  * Print the status of the interface.  If an address family was
  * specified, show it and it only; otherwise, show them all.
  */
+
+#define MAX_PRINT_LEN 58	/* XXX need a better way to determine this! */
+
 void
 status(const struct sockaddr *sdl, prop_dictionary_t env,
 prop_dictionary_t oenv)
@@ -1174,6 +1177,7 @@ status(const struct sockaddr *sdl, prop_
 	struct ifreq ifr;
 	struct ifdrv ifdrv;
 	char fbuf[BUFSIZ];
+	char *bp;
 	int af, s;
 	const char *ifname;
 	struct ifcapreq ifcr;
@@ -1193,8 +1197,12 @@ status(const struct sockaddr *sdl, prop_
 	if ((ifname = getifinfo(env, oenv, flags)) == NULL)
 		err(EXIT_FAILURE, %s: getifinfo, __func__);
 
-	(void)snprintb(fbuf, sizeof(fbuf), IFFBITS, flags);
-	printf(%s: flags=%s, ifname, fbuf[2]);
+	(void)snprintb_m(fbuf, sizeof(fbuf), IFFBITS, flags, MAX_PRINT_LEN);
+	bp = fbuf;
+	while (*bp != '\0') {
+		printf(%s: flags=%s, ifname, bp[2]);
+		bp += strlen(bp) + 1;
+	}
 
 	estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
 	if (prog_ioctl(s, SIOCGIFMETRIC, ifr) == -1)
@@ -1211,12 +1219,20 @@ status(const struct sockaddr *sdl, prop_
 		err(EXIT_FAILURE, %s: getifcaps, __func__);
 
 	if (ifcr.ifcr_capabilities != 0) {
-		(void)snprintb(fbuf, sizeof(fbuf), IFCAPBITS,
-		ifcr.ifcr_capabilities);
-		printf(\tcapabilities=%s\n, fbuf[2]);
-		(void)snprintb(fbuf, sizeof(fbuf), IFCAPBITS,
-		ifcr.ifcr_capenable);
-		printf(\tenabled=%s\n, fbuf[2]);
+		(void)snprintb_m(fbuf, sizeof(fbuf), IFCAPBITS,
+		ifcr.ifcr_capabilities, MAX_PRINT_LEN);
+		bp = fbuf;
+		while (*bp != '\0') {
+			printf(\tcapabilities=%s\n, bp[2]);
+			bp += strlen(bp) + 1;
+		}
+		(void)snprintb_m(fbuf, sizeof(fbuf), IFCAPBITS,
+		ifcr.ifcr_capenable, MAX_PRINT_LEN);
+		bp = fbuf;
+		while (*bp != '\0') {
+			printf(\tenabled=%s\n, bp[2]);
+			bp += strlen(bp) + 1;
+		}
 	}
 
 	SIMPLEQ_FOREACH(status_f, 

CVS commit: src/sbin/ifconfig

2012-08-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug  8 14:10:39 UTC 2012

Modified Files:
src/sbin/ifconfig: Makefile

Log Message:
don't define RUMP_ACTION if MKRUMP = no


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sbin/ifconfig/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.52 src/sbin/ifconfig/Makefile:1.53
--- src/sbin/ifconfig/Makefile:1.52	Sun Aug 14 08:15:15 2011
+++ src/sbin/ifconfig/Makefile	Wed Aug  8 10:10:38 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.52 2011/08/14 12:15:15 christos Exp $
+#	$NetBSD: Makefile,v 1.53 2012/08/08 14:10:38 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -21,7 +21,9 @@ SRCS+= af_inet6.c
 
 .PATH:		${.CURDIR}/../../lib/libc/net
 RUMPSRCS= getifaddrs.c
+.if (${MKRUMP} != no)
 CPPFLAGS+= -DRUMP_ACTION
+.endif
 
 CPPFLAGS+=-I${NETBSDSRCDIR}/sys/dist/pf/
 SRCS+= pfsync.c



CVS commit: src/sbin/ifconfig

2012-03-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 17 02:25:08 UTC 2012

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
PR/43141: Tobias Nygren: Print an error on unknown interfaces.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/ifconfig/af_inetany.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.14 src/sbin/ifconfig/af_inetany.c:1.15
--- src/sbin/ifconfig/af_inetany.c:1.14	Tue May 24 07:38:56 2011
+++ src/sbin/ifconfig/af_inetany.c	Fri Mar 16 22:25:08 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.14 2011/05/24 11:38:56 joerg Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.15 2012/03/17 02:25:08 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inetany.c,v 1.14 2011/05/24 11:38:56 joerg Exp $);
+__RCSID($NetBSD: af_inetany.c,v 1.15 2012/03/17 02:25:08 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -81,7 +81,7 @@ commit_address(prop_dictionary_t env, pr
 		err(EXIT_FAILURE, %s: getsock, __func__);
 
 	if ((ifname = getifinfo(env, oenv, flags)) == NULL)
-		return;
+		err(EXIT_FAILURE, %s: getifinfo, __func__);
 
 	strlcpy(param-name[0].buf, ifname, param-name[0].buflen);
 	strlcpy(param-name[1].buf, ifname, param-name[1].buflen);



CVS commit: src/sbin/ifconfig

2012-01-28 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Sat Jan 28 15:01:44 UTC 2012

Modified Files:
src/sbin/ifconfig: ifconfig.8 ifconfig.c

Log Message:
When ifconfig is invoked without any arguments, display the list of
all network interfaces (equivalent to ifconfig -a), instead of displaying
the usage.  (This is consistent with the behaviour on FreeBSD and OpenBSD.)


To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/sbin/ifconfig/ifconfig.8
cvs rdiff -u -r1.226 -r1.227 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.103 src/sbin/ifconfig/ifconfig.8:1.104
--- src/sbin/ifconfig/ifconfig.8:1.103	Tue May 31 16:17:30 2011
+++ src/sbin/ifconfig/ifconfig.8	Sat Jan 28 15:01:44 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: ifconfig.8,v 1.103 2011/05/31 16:17:30 riastradh Exp $
+.\	$NetBSD: ifconfig.8,v 1.104 2012/01/28 15:01:44 mbalmer Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd November 15, 2010
+.Dd January 28, 2012
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -805,6 +805,12 @@ flag may be used instead of an interface
 This flag instructs
 .Nm
 to display information about all interfaces in the system.
+This is also the default behaviour when no arguments are given to
+.Nm
+on the command line.
+When
+.Fl a
+is used, the output can be modified by adding more flags:
 .Fl d
 limits this to interfaces that are down,
 .Fl u

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.226 src/sbin/ifconfig/ifconfig.c:1.227
--- src/sbin/ifconfig/ifconfig.c:1.226	Mon Aug 29 14:35:00 2011
+++ src/sbin/ifconfig/ifconfig.c	Sat Jan 28 15:01:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.226 2011/08/29 14:35:00 joerg Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.227 2012/01/28 15:01:44 mbalmer Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.226 2011/08/29 14:35:00 joerg Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.227 2012/01/28 15:01:44 mbalmer Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -77,7 +77,7 @@ __RCSID($NetBSD: ifconfig.c,v 1.226 201
 #include net/if_ether.h
 #include netinet/in.h		/* XXX */
 #include netinet/in_var.h	/* XXX */
- 
+
 #include netdb.h
 
 #include sys/protosw.h
@@ -418,7 +418,7 @@ register_family(struct afswtch *af)
 	SIMPLEQ_INSERT_TAIL(aflist, af, af_next);
 	return 0;
 }
- 
+
 int
 register_flag(int flag)
 {
@@ -434,7 +434,7 @@ register_flag(int flag)
 
 	return 0;
 }
- 
+
 static int
 flag_index(int flag)
 {
@@ -467,7 +467,7 @@ get_flag(int flag)
 
 	if ((idx = flag_index(flag)) == -1)
 		return false;
-		
+
 	return gflagset[idx];
 }
 
@@ -482,7 +482,7 @@ init_parser(void)
 		err(EXIT_FAILURE, parser_init(iface_only));
 	if (parser_init(iface_start.pif_parser) == -1)
 		err(EXIT_FAILURE, parser_init(iface_start));
- 
+
 	SIMPLEQ_FOREACH(b, cmdloop_branches, b_next)
 		pbranch_addbranch(command_root, b-b_parser);
 
@@ -557,7 +557,11 @@ main(int argc, char **argv)
 	start = init_parser();
 
 	/* Parse command-line options */
-	aflag = Nflag = vflag = zflag = false;
+	Nflag = vflag = zflag = false;
+	aflag = argc == 1 ? true : false;
+	if (aflag)
+		start = opt_family_only.pb_parser;
+
 	while ((ch = getopt(argc, argv, gflags)) != -1) {
 		switch (ch) {
 		case 'A':
@@ -571,7 +575,7 @@ main(int argc, char **argv)
 		case 'b':
 			bflag = true;
 			break;
-			
+
 		case 'C':
 			Cflag = true;
 			break;
@@ -988,7 +992,7 @@ setifflags(prop_dictionary_t env, prop_d
 	if (direct_ioctl(env, SIOCSIFFLAGS, ifr) == -1)
 		return -1;
 
-	return 0; 
+	return 0;
 }
 
 static int
@@ -1078,7 +1082,7 @@ do_setifpreference(prop_dictionary_t env
 
 	if (!prop_dictionary_get_int16(env, preference,
 	ifap.ifap_preference))
-		return; 
+		return;
 
 	d = (prop_data_t)prop_dictionary_get(env, address);
 	assert(d != NULL);



CVS commit: src/sbin/ifconfig

2011-08-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 14 12:15:15 UTC 2011

Modified Files:
src/sbin/ifconfig: Makefile af_atalk.c

Log Message:
use memcpy to avoid strict aliasing warnings


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/ifconfig/Makefile
cvs rdiff -u -r1.17 -r1.18 src/sbin/ifconfig/af_atalk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.51 src/sbin/ifconfig/Makefile:1.52
--- src/sbin/ifconfig/Makefile:1.51	Tue Jun 21 22:49:43 2011
+++ src/sbin/ifconfig/Makefile	Sun Aug 14 08:15:15 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.51 2011/06/22 02:49:43 mrg Exp $
+#	$NetBSD: Makefile,v 1.52 2011/08/14 12:15:15 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -32,8 +32,3 @@
 .endif
 
 .include bsd.prog.mk
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.af_atalk.c+=	-fno-strict-aliasing
-.endif

Index: src/sbin/ifconfig/af_atalk.c
diff -u src/sbin/ifconfig/af_atalk.c:1.17 src/sbin/ifconfig/af_atalk.c:1.18
--- src/sbin/ifconfig/af_atalk.c:1.17	Mon Dec 13 12:35:08 2010
+++ src/sbin/ifconfig/af_atalk.c	Sun Aug 14 08:15:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_atalk.c,v 1.17 2010/12/13 17:35:08 pooka Exp $	*/
+/*	$NetBSD: af_atalk.c,v 1.18 2011/08/14 12:15:15 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_atalk.c,v 1.17 2010/12/13 17:35:08 pooka Exp $);
+__RCSID($NetBSD: af_atalk.c,v 1.18 2011/08/14 12:15:15 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -150,7 +150,7 @@
 	if (ntohs(nr.nr_firstnet)  ntohs(sat-sat_addr.s_net) ||
 	ntohs(nr.nr_lastnet)  ntohs(sat-sat_addr.s_net))
 		errx(EXIT_FAILURE, AppleTalk address is not in range);
-	*((struct netrange *)sat-sat_zero) = nr;
+	memcpy(sat-sat_zero, nr, sizeof(nr));
 
 	/* Copy the new address to a temporary input environment */
 



CVS commit: src/sbin/ifconfig

2011-05-31 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 31 16:17:30 UTC 2011

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Fix typo: `symbolically' takes three l's, not two.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.102 src/sbin/ifconfig/ifconfig.8:1.103
--- src/sbin/ifconfig/ifconfig.8:1.102	Mon Nov 15 22:42:37 2010
+++ src/sbin/ifconfig/ifconfig.8	Tue May 31 16:17:30 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: ifconfig.8,v 1.102 2010/11/15 22:42:37 pooka Exp $
+.\	$NetBSD: ifconfig.8,v 1.103 2011/05/31 16:17:30 riastradh Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -502,7 +502,7 @@
 .Fl v
 flag may be used to display long SSIDs.
 .Fl v
-also causes received information elements to be displayed symbolicaly.
+also causes received information elements to be displayed symbolically.
 Only the super-user can use this command.
 .It Cm tunnel Ar src_addr Ns Op Ar ,src_port
 .Ar dest_addr Ns Op Ar ,dest_port



CVS commit: src/sbin/ifconfig

2011-05-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue May 24 11:38:56 UTC 2011

Modified Files:
src/sbin/ifconfig: af_inetany.c

Log Message:
Don't use address strings as format string.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/ifconfig/af_inetany.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inetany.c
diff -u src/sbin/ifconfig/af_inetany.c:1.13 src/sbin/ifconfig/af_inetany.c:1.14
--- src/sbin/ifconfig/af_inetany.c:1.13	Mon Dec 13 17:35:08 2010
+++ src/sbin/ifconfig/af_inetany.c	Tue May 24 11:38:56 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inetany.c,v 1.13 2010/12/13 17:35:08 pooka Exp $	*/
+/*	$NetBSD: af_inetany.c,v 1.14 2011/05/24 11:38:56 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inetany.c,v 1.13 2010/12/13 17:35:08 pooka Exp $);
+__RCSID($NetBSD: af_inetany.c,v 1.14 2011/05/24 11:38:56 joerg Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -92,9 +92,9 @@
 	param-gifaddr.cmd == 0)
 		return;
 	else if (prog_ioctl(s, param-gifaddr.cmd, param-dgreq.buf) == -1)
-		err(EXIT_FAILURE, param-gifaddr.desc);
+		err(EXIT_FAILURE, %s, param-gifaddr.desc);
 	else if (prog_ioctl(s, param-difaddr.cmd, param-dgreq.buf) == -1)
-		err(EXIT_FAILURE, param-difaddr.desc);
+		err(EXIT_FAILURE, %s, param-difaddr.desc);
 	else
 		return;
 
@@ -157,20 +157,20 @@
 		if (prog_ioctl(s, param-gifaddr.cmd, param-dgreq.buf) == 0) {
 			rc = prog_ioctl(s, param-difaddr.cmd, param-dgreq.buf);
 			if (rc == -1)
-err(EXIT_FAILURE, param-difaddr.desc);
+err(EXIT_FAILURE, %s, param-difaddr.desc);
 		} else if (errno == EADDRNOTAVAIL)
 			;	/* No address was assigned yet. */
 		else
-			err(EXIT_FAILURE, param-gifaddr.desc);
+			err(EXIT_FAILURE, %s, param-gifaddr.desc);
 	} else if (delete) {
 		loadbuf(param-dgaddr, addr);
 		if (prog_ioctl(s, param-difaddr.cmd, param-dgreq.buf) == -1)
-			err(EXIT_FAILURE, param-difaddr.desc);
+			err(EXIT_FAILURE, %s, param-difaddr.desc);
 		return;
 	}
 	if (param-pre_aifaddr != NULL 
 	(*param-pre_aifaddr)(env, param) == -1)
 		err(EXIT_FAILURE, pre-%s, param-aifaddr.desc);
 	if (prog_ioctl(s, param-aifaddr.cmd, param-req.buf) == -1)
-		err(EXIT_FAILURE, param-aifaddr.desc);
+		err(EXIT_FAILURE, %s, param-aifaddr.desc);
 }



CVS commit: src/sbin/ifconfig

2010-12-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Dec 14 10:51:51 UTC 2010

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
A few weeks ago when i added linkstr support I didn't know that
the string parser gives a proplib object which isn't a terminated
string.  Fix that mistake now.


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.224 src/sbin/ifconfig/ifconfig.c:1.225
--- src/sbin/ifconfig/ifconfig.c:1.224	Mon Dec 13 17:35:08 2010
+++ src/sbin/ifconfig/ifconfig.c	Tue Dec 14 10:51:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.224 2010/12/13 17:35:08 pooka Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.225 2010/12/14 10:51:51 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.224 2010/12/13 17:35:08 pooka Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.225 2010/12/14 10:51:51 pooka Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -1316,9 +1316,9 @@
 setlinkstr(prop_dictionary_t env, prop_dictionary_t oenv)
 {
 	struct ifdrv ifdrv;
-	const char *linkstr;
 	size_t linkstrlen;
 	prop_data_t data;
+	char *linkstr;
 
 	data = (prop_data_t)prop_dictionary_get(env, linkstr);
 	if (data == NULL) {
@@ -1326,7 +1326,12 @@
 		return -1;
 	}
 	linkstrlen = prop_data_size(data)+1;
-	linkstr = prop_data_data_nocopy(data);
+
+	linkstr = malloc(linkstrlen);
+	if (linkstr == NULL)
+		err(EXIT_FAILURE, malloc linkstr space);
+	if (getargstr(env, linkstr, linkstr, linkstrlen) == -1)
+		errx(EXIT_FAILURE, getargstr linkstr failed);
 
 	ifdrv.ifd_cmd = 0;
 	ifdrv.ifd_len = linkstrlen;
@@ -1334,6 +1339,7 @@
 
 	if (direct_ioctl(env, SIOCSLINKSTR, ifdrv) == -1)
 		err(EXIT_FAILURE, SIOCSLINKSTR);
+	free(linkstr);
 
 	return 0;
 }



CVS commit: src/sbin/ifconfig

2010-12-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Dec 13 17:35:08 UTC 2010

Modified Files:
src/sbin/ifconfig: Makefile Makefile.inc af_atalk.c af_inet.c
af_inet6.c af_inetany.c af_iso.c env.c ieee80211.c ifconfig.c
media.c util.c
Added Files:
src/sbin/ifconfig: ifconfig_hostops.c ifconfig_rumpops.c prog_ops.h

Log Message:
Convert from the .ifdef RUMP_ACTION stuff to RUMPPRG.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/ifconfig/Makefile
cvs rdiff -u -r1.7 -r1.8 src/sbin/ifconfig/Makefile.inc
cvs rdiff -u -r1.16 -r1.17 src/sbin/ifconfig/af_atalk.c
cvs rdiff -u -r1.14 -r1.15 src/sbin/ifconfig/af_inet.c
cvs rdiff -u -r1.26 -r1.27 src/sbin/ifconfig/af_inet6.c
cvs rdiff -u -r1.12 -r1.13 src/sbin/ifconfig/af_inetany.c
cvs rdiff -u -r1.13 -r1.14 src/sbin/ifconfig/af_iso.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/env.c
cvs rdiff -u -r1.24 -r1.25 src/sbin/ifconfig/ieee80211.c
cvs rdiff -u -r1.223 -r1.224 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r0 -r1.1 src/sbin/ifconfig/ifconfig_hostops.c \
src/sbin/ifconfig/ifconfig_rumpops.c src/sbin/ifconfig/prog_ops.h
cvs rdiff -u -r1.4 -r1.5 src/sbin/ifconfig/media.c
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.49 src/sbin/ifconfig/Makefile:1.50
--- src/sbin/ifconfig/Makefile:1.49	Fri Nov  5 16:23:56 2010
+++ src/sbin/ifconfig/Makefile	Mon Dec 13 17:35:08 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.49 2010/11/05 16:23:56 pooka Exp $
+#	$NetBSD: Makefile,v 1.50 2010/12/13 17:35:08 pooka Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -7,6 +7,7 @@
 
 .include bsd.own.mk
 
+RUMPPRG=ifconfig
 MAN=	ifconfig.8
 
 #DBG+=-g
@@ -18,6 +19,10 @@
 
 .include Makefile.inc
 
+.PATH:		${.CURDIR}/../../lib/libc/net
+RUMPSRCS= getifaddrs.c
+CPPFLAGS+= -DRUMP_ACTION
+
 CPPFLAGS+=-I${NETBSDSRCDIR}/sys/dist/pf/
 SRCS+= pfsync.c
 
@@ -26,17 +31,4 @@
 COPTS.ifconfig.c+= -fno-loop-optimize
 .endif
 
-#
-# Compile-time debug flag.  If compiled with make RUMP_ACTION=1,
-# make rump system calls to a server in another process.
-#
-.ifdef RUMP_ACTION
-.PATH:		${.CURDIR}/../../lib/libc/net
-CPPFLAGS+=	-DRUMP_SYS_NETWORKING -DRUMP_SYS_IOCTL -DRUMP_SYS_CLOSE
-CPPFLAGS+=	-DRUMP_ACTION
-LDADD+=		-lrumpclient
-DBG=		-g
-SRCS+=		getifaddrs.c
-.endif
-
 .include bsd.prog.mk

Index: src/sbin/ifconfig/Makefile.inc
diff -u src/sbin/ifconfig/Makefile.inc:1.7 src/sbin/ifconfig/Makefile.inc:1.8
--- src/sbin/ifconfig/Makefile.inc:1.7	Wed Sep 16 14:59:45 2009
+++ src/sbin/ifconfig/Makefile.inc	Mon Dec 13 17:35:08 2010
@@ -1,10 +1,8 @@
-#	$NetBSD: Makefile.inc,v 1.7 2009/09/16 14:59:45 tsutsui Exp $
+#	$NetBSD: Makefile.inc,v 1.8 2010/12/13 17:35:08 pooka Exp $
 
 # shared stuff with src/distrib/utils/x_ifconfig for install media.
 # stuff not required by install media should be into Makefile.
 
-PROG=	ifconfig
-
 DPADD+=${LIBUTIL}
 DPADD+=${LIBPROP}
 LDADD+=-lutil

Index: src/sbin/ifconfig/af_atalk.c
diff -u src/sbin/ifconfig/af_atalk.c:1.16 src/sbin/ifconfig/af_atalk.c:1.17
--- src/sbin/ifconfig/af_atalk.c:1.16	Sat Jan 30 18:30:33 2010
+++ src/sbin/ifconfig/af_atalk.c	Mon Dec 13 17:35:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_atalk.c,v 1.16 2010/01/30 18:30:33 is Exp $	*/
+/*	$NetBSD: af_atalk.c,v 1.17 2010/12/13 17:35:08 pooka Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_atalk.c,v 1.16 2010/01/30 18:30:33 is Exp $);
+__RCSID($NetBSD: af_atalk.c,v 1.17 2010/12/13 17:35:08 pooka Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -56,6 +56,7 @@
 #include af_inetany.h
 #include parse.h
 #include extern.h
+#include prog_ops.h
 
 #ifndef satocsat
 #define	satocsat(__sa) ((const struct sockaddr_at *)(__sa))
@@ -209,7 +210,7 @@
 	memset(ifr, 0, sizeof(ifr));
 	estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
 	ifr.ifr_addr.sa_family = AF_APPLETALK;
-	if (ioctl(s, SIOCGIFADDR, ifr) != -1)
+	if (prog_ioctl(s, SIOCGIFADDR, ifr) != -1)
 		;
 	else if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) {
 		if (!force)
@@ -223,7 +224,7 @@
 
 	if (flags  IFF_POINTOPOINT) {
 		estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-		if (ioctl(s, SIOCGIFDSTADDR, ifr) == -1) {
+		if (prog_ioctl(s, SIOCGIFDSTADDR, ifr) == -1) {
 			if (errno == EADDRNOTAVAIL)
 memset(ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));
 			else

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.14 src/sbin/ifconfig/af_inet.c:1.15
--- src/sbin/ifconfig/af_inet.c:1.14	Fri Sep 11 22:06:29 2009
+++ src/sbin/ifconfig/af_inet.c	Mon Dec 13 17:35:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.14 2009/09/11 22:06:29 dyoung Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.15 2010/12/13 17:35:08 pooka Exp $	*/

CVS commit: src/sbin/ifconfig

2010-12-13 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Mon Dec 13 19:17:21 UTC 2010

Modified Files:
src/sbin/ifconfig: prog_ops.h

Log Message:
op_read return value is a ssize_t, not an int.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/ifconfig/prog_ops.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/prog_ops.h
diff -u src/sbin/ifconfig/prog_ops.h:1.1 src/sbin/ifconfig/prog_ops.h:1.2
--- src/sbin/ifconfig/prog_ops.h:1.1	Mon Dec 13 17:35:08 2010
+++ src/sbin/ifconfig/prog_ops.h	Mon Dec 13 19:17:20 2010
@@ -1,4 +1,4 @@
-/*  $NetBSD: prog_ops.h,v 1.1 2010/12/13 17:35:08 pooka Exp $	*/
+/*  $NetBSD: prog_ops.h,v 1.2 2010/12/13 19:17:20 njoly Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 	int (*op_socket)(int, int, int);
 
 	int (*op_ioctl)(int, unsigned long, ...);
-	int (*op_read)(int, void *, size_t);
+	ssize_t (*op_read)(int, void *, size_t);
 
 	int (*op_close)(int);
 };



CVS commit: src/sbin/ifconfig

2010-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov  4 23:31:13 UTC 2010

Modified Files:
src/sbin/ifconfig: Makefile env.h ifconfig.c

Log Message:
Update RUMP_ACTION to use the newstyle rump client.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sbin/ifconfig/Makefile
cvs rdiff -u -r1.2 -r1.3 src/sbin/ifconfig/env.h
cvs rdiff -u -r1.220 -r1.221 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.47 src/sbin/ifconfig/Makefile:1.48
--- src/sbin/ifconfig/Makefile:1.47	Thu Jul  1 16:28:21 2010
+++ src/sbin/ifconfig/Makefile	Thu Nov  4 23:31:12 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.47 2010/07/01 16:28:21 dyoung Exp $
+#	$NetBSD: Makefile,v 1.48 2010/11/04 23:31:12 pooka Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -28,14 +28,12 @@
 
 #
 # Compile-time debug flag.  If compiled with make RUMP_ACTION=1,
-# make rump system calls.  This allows to single-step ioctl commands
-# to figure out where ioctl's go in the kernel.
+# make rump system calls to a server in another process.
 #
 .ifdef RUMP_ACTION
 CPPFLAGS+=	-DRUMP_SYS_NETWORKING -DRUMP_SYS_IOCTL -DRUMP_SYS_CLOSE
 CPPFLAGS+=	-DRUMP_ACTION
-LDADD+=		-lrumpnet_virtif -lrumpnet_netinet -lrumpnet_net -lrumpnet
-LDADD+=		-lrump -lrumpuser -lpthread
+LDADD+=		-lrumpclient
 DBG=		-g
 .endif
 

Index: src/sbin/ifconfig/env.h
diff -u src/sbin/ifconfig/env.h:1.2 src/sbin/ifconfig/env.h:1.3
--- src/sbin/ifconfig/env.h:1.2	Tue May 26 16:03:24 2009
+++ src/sbin/ifconfig/env.h	Thu Nov  4 23:31:12 2010
@@ -19,6 +19,7 @@
 #ifdef RUMP_ACTION
 #include rump/rump.h
 #include rump/rump_syscalls.h
+#include rump/rumpclient.h
 #endif /* RUMP_ACTION */
 
 #endif /* _IFCONFIG_ENV_H */

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.220 src/sbin/ifconfig/ifconfig.c:1.221
--- src/sbin/ifconfig/ifconfig.c:1.220	Fri Aug  7 18:53:37 2009
+++ src/sbin/ifconfig/ifconfig.c	Thu Nov  4 23:31:12 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.220 2009/08/07 18:53:37 dyoung Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.221 2010/11/04 23:31:12 pooka Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.220 2009/08/07 18:53:37 dyoung Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.221 2010/11/04 23:31:12 pooka Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -541,7 +541,10 @@
 	const char *ifname;
 
 #ifdef RUMP_ACTION
-	rump_init();
+	int error;
+
+	if ((error = rumpclient_init()) != 0)
+		errx(1, rump client init: %s, strerror(error));
 #endif
 	memset(match, 0, sizeof(match));
 



CVS commit: src/sbin/ifconfig

2010-07-01 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Thu Jul  1 16:12:23 UTC 2010

Modified Files:
src/sbin/ifconfig: util.c

Log Message:
Change a  to a = to avoid writing to the character after the end of
the buffer passed to get_string().


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sbin/ifconfig/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/util.c
diff -u src/sbin/ifconfig/util.c:1.13 src/sbin/ifconfig/util.c:1.14
--- src/sbin/ifconfig/util.c:1.13	Fri Sep 11 22:06:29 2009
+++ src/sbin/ifconfig/util.c	Thu Jul  1 16:12:23 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.13 2009/09/11 22:06:29 dyoung Exp $	*/
+/*	$NetBSD: util.c,v 1.14 2010/07/01 16:12:23 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: util.c,v 1.13 2009/09/11 22:06:29 dyoung Exp $);
+__RCSID($NetBSD: util.c,v 1.14 2010/07/01 16:12:23 dyoung Exp $);
 #endif /* not lint */
 
 #include ctype.h
@@ -103,7 +103,7 @@
 return NULL;
 			}
 		}
-		if (p  buf + len) {
+		if (p = buf + len) {
 			if (hexstr)
 warnx(hexadecimal digits too long);
 			else



CVS commit: src/sbin/ifconfig

2010-07-01 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Thu Jul  1 16:28:21 UTC 2010

Modified Files:
src/sbin/ifconfig: Makefile

Log Message:
Apparently, -g belongs in the DBG variable, not in CFLAGS.  Make it so
on a line that is commented-out in this makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sbin/ifconfig/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.46 src/sbin/ifconfig/Makefile:1.47
--- src/sbin/ifconfig/Makefile:1.46	Wed Sep 16 15:08:29 2009
+++ src/sbin/ifconfig/Makefile	Thu Jul  1 16:28:21 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.46 2009/09/16 15:08:29 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.47 2010/07/01 16:28:21 dyoung Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -9,7 +9,7 @@
 
 MAN=	ifconfig.8
 
-#CFLAGS+=-g
+#DBG+=-g
 SRCS= af_atalk.c af_iso.c af_link.c carp.c
 .if (${USE_INET6} != no)
 CPPFLAGS+=	-DINET6



CVS commit: src/sbin/ifconfig

2010-07-01 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Thu Jul  1 16:44:05 UTC 2010

Modified Files:
src/sbin/ifconfig: ieee80211.c media.c parse.c parse.h util.c util.h

Log Message:
Add to the string parse object (pstr), and its constructors, a flag that
tells whether it should detect and convert to binary a hexadecimal octet
string of the form 0x0123ABab, or leave those strings undecoded.

If the argument for a 'media', 'mediamode', 'mediaopt', '-mediaopt',
'nwkey', or 'bssid' keyword is a hexadecimal octet string, do not detect
and decode it.  (Note that setifnwkey decodes hexadecimal strings on its
own.)

This fixes a bug noticed by Jim Miller where the trailing zero-octets
were discarded from hexadecimal octet-string arguments for 'nwkey'.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sbin/ifconfig/ieee80211.c
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/media.c
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/parse.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/parse.h
cvs rdiff -u -r1.14 -r1.15 src/sbin/ifconfig/util.c
cvs rdiff -u -r1.8 -r1.9 src/sbin/ifconfig/util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ieee80211.c
diff -u src/sbin/ifconfig/ieee80211.c:1.23 src/sbin/ifconfig/ieee80211.c:1.24
--- src/sbin/ifconfig/ieee80211.c:1.23	Sun Jan 18 00:24:29 2009
+++ src/sbin/ifconfig/ieee80211.c	Thu Jul  1 16:44:05 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ieee80211.c,v 1.23 2009/01/18 00:24:29 lukem Exp $	*/
+/*	$NetBSD: ieee80211.c,v 1.24 2010/07/01 16:44:05 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: ieee80211.c,v 1.23 2009/01/18 00:24:29 lukem Exp $);
+__RCSID($NetBSD: ieee80211.c,v 1.24 2010/07/01 16:44:05 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -184,11 +184,11 @@
 0, INT_MAX, 10, setifpowersavesleep, powersavesleep,
 command_root.pb_parser);
 
-struct pstr parse_nwkey = PSTR_INITIALIZER(parse_nwkey, nwkey, setifnwkey,
-nwkey, command_root.pb_parser);
+struct pstr parse_nwkey = PSTR_INITIALIZER1(parse_nwkey, nwkey, setifnwkey,
+nwkey, false, command_root.pb_parser);
 
-struct pstr parse_bssid = PSTR_INITIALIZER(parse_bssid, bssid, setifbssid,
-bssid, command_root.pb_parser);
+struct pstr parse_bssid = PSTR_INITIALIZER1(parse_bssid, bssid, setifbssid,
+bssid, false, command_root.pb_parser);
 
 static int
 set80211(prop_dictionary_t env, uint16_t type, int16_t val, int16_t len,
@@ -375,7 +375,7 @@
 			val += 2;
 			for (i = 0; i  IEEE80211_WEP_NKID; i++) {
 val = get_string(val, ,, keybuf[i],
-nwkey.i_key[i].i_keylen);
+nwkey.i_key[i].i_keylen, true);
 if (val == NULL) {
 	errno = EINVAL;
 	return -1;
@@ -386,7 +386,7 @@
 			}
 		} else {
 			val = get_string(val, NULL, keybuf[0],
-			nwkey.i_key[0].i_keylen);
+			nwkey.i_key[0].i_keylen, true);
 			if (val == NULL) {
 errno = EINVAL;
 return -1;

Index: src/sbin/ifconfig/media.c
diff -u src/sbin/ifconfig/media.c:1.3 src/sbin/ifconfig/media.c:1.4
--- src/sbin/ifconfig/media.c:1.3	Tue Jul 15 21:27:58 2008
+++ src/sbin/ifconfig/media.c	Thu Jul  1 16:44:05 2010
@@ -1,6 +1,6 @@
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: media.c,v 1.3 2008/07/15 21:27:58 dyoung Exp $);
+__RCSID($NetBSD: media.c,v 1.4 2010/07/01 16:44:05 dyoung Exp $);
 #endif /* not lint */
 
 #include assert.h
@@ -51,21 +51,21 @@
 static const struct ifmedia_status_description ifm_status_descriptions[] =
 IFM_STATUS_DESCRIPTIONS;
 
-static struct pstr mediamode = PSTR_INITIALIZER(mediamode, mediamode,
-setmediamode, mediamode, command_root.pb_parser);
+static struct pstr mediamode = PSTR_INITIALIZER1(mediamode, mediamode,
+setmediamode, mediamode, false, command_root.pb_parser);
 
 static struct pinteger mediainst = PINTEGER_INITIALIZER1(mediainst,
 mediainst, 0, IFM_INST_MAX, 10, setmediainst, mediainst,
 command_root.pb_parser);
 
-static struct pstr unmediaopt = PSTR_INITIALIZER(unmediaopt, -mediaopt,
-unsetmediaopt, unmediaopt, command_root.pb_parser);
+static struct pstr unmediaopt = PSTR_INITIALIZER1(unmediaopt, -mediaopt,
+unsetmediaopt, unmediaopt, false, command_root.pb_parser);
 
-static struct pstr mediaopt = PSTR_INITIALIZER(mediaopt, mediaopt,
-setmediaopt, mediaopt, command_root.pb_parser);
+static struct pstr mediaopt = PSTR_INITIALIZER1(mediaopt, mediaopt,
+setmediaopt, mediaopt, false, command_root.pb_parser);
 
-static struct pstr media = PSTR_INITIALIZER(media, media, setmedia, media,
-command_root.pb_parser);
+static struct pstr media = PSTR_INITIALIZER1(media, media, setmedia, media,
+false, command_root.pb_parser);
 
 static const struct kwinst mediakw[] = {
 	  {.k_word = instance, .k_key = anymedia, .k_type = KW_T_BOOL,

Index: src/sbin/ifconfig/parse.c
diff -u src/sbin/ifconfig/parse.c:1.15 

CVS commit: src/sbin/ifconfig

2010-04-20 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Tue Apr 20 21:25:25 UTC 2010

Modified Files:
src/sbin/ifconfig: parse.c

Log Message:
C99 says that offsetof() expands to a constant expresssion, so we
can't use variable array index in there. Do the calculation manually
for C99 compilers (pcc)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/ifconfig/parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/parse.c
diff -u src/sbin/ifconfig/parse.c:1.14 src/sbin/ifconfig/parse.c:1.15
--- src/sbin/ifconfig/parse.c:1.14	Tue Jul 28 18:21:06 2009
+++ src/sbin/ifconfig/parse.c	Tue Apr 20 21:25:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.14 2009/07/28 18:21:06 dyoung Exp $	*/
+/*	$NetBSD: parse.c,v 1.15 2010/04/20 21:25:25 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: parse.c,v 1.14 2009/07/28 18:21:06 dyoung Exp $);
+__RCSID($NetBSD: parse.c,v 1.15 2010/04/20 21:25:25 plunky Exp $);
 #endif /* not lint */
 
 #include err.h
@@ -252,8 +252,8 @@
 return -1;
 			dbg_warnx(%s.%d, __func__, __LINE__);
 			sdl-sdl_data[i++] = octet;
-			sdl-sdl_len =
-			offsetof(struct sockaddr_dl, sdl_data[i]);
+			sdl-sdl_len = offsetof(struct sockaddr_dl, sdl_data)
+			+ i * sizeof(sdl-sdl_data[0]);
 			sdl-sdl_alen = i;
 			return 0;
 		}



CVS commit: src/sbin/ifconfig

2010-01-30 Thread Ignatios Souvatzis
Module Name:src
Committed By:   is
Date:   Sat Jan 30 18:30:33 UTC 2010

Modified Files:
src/sbin/ifconfig: af_atalk.c

Log Message:
Use getnameinfo() for printing AppleTalk addresses. While here, fix
printing of broadcast for this address family (AT broadcast is fixed
node 255 on the local net).


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/ifconfig/af_atalk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_atalk.c
diff -u src/sbin/ifconfig/af_atalk.c:1.15 src/sbin/ifconfig/af_atalk.c:1.16
--- src/sbin/ifconfig/af_atalk.c:1.15	Fri Aug  1 22:44:17 2008
+++ src/sbin/ifconfig/af_atalk.c	Sat Jan 30 18:30:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_atalk.c,v 1.15 2008/08/01 22:44:17 dyoung Exp $	*/
+/*	$NetBSD: af_atalk.c,v 1.16 2010/01/30 18:30:33 is Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_atalk.c,v 1.15 2008/08/01 22:44:17 dyoung Exp $);
+__RCSID($NetBSD: af_atalk.c,v 1.16 2010/01/30 18:30:33 is Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -42,6 +42,8 @@
 
 #include netatalk/at.h
 
+#include netdb.h
+
 #include err.h
 #include errno.h
 #include string.h
@@ -177,19 +179,20 @@
 }
 
 static void
-sat_print(const char *prefix, const struct sockaddr *sa)
+sat_print1(const char *prefix, const struct sockaddr *sa)
 {
-	const struct sockaddr_at *sat = satocsat(sa);
+	char buf[40];
+	int rc;
 
-	printf(%s%d.%d, prefix, ntohs(sat-sat_addr.s_net),
-	sat-sat_addr.s_node);
+	rc = getnameinfo(sa, sa-sa_len, buf, sizeof(buf), NULL, 0, 0);
+	
+	printf(%s%s, prefix, buf);
 }
 
 static void
 at_status(prop_dictionary_t env, prop_dictionary_t oenv, bool force)
 {
 	struct sockaddr_at *sat;
-	struct netrange *nr;
 	struct ifreq ifr;
 	int s;
 	const char *ifname;
@@ -216,10 +219,7 @@
 		warn(SIOCGIFADDR);
 	sat = (struct sockaddr_at *)ifr.ifr_addr;
 
-	nr = (struct netrange *)sat-sat_zero;
-	sat_print(\tatalk , ifr.ifr_addr);
-	printf( range %d-%d phase %d,
-	ntohs(nr-nr_firstnet), ntohs(nr-nr_lastnet), nr-nr_phase);
+	sat_print1(\tatalk , ifr.ifr_addr);
 
 	if (flags  IFF_POINTOPOINT) {
 		estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
@@ -229,11 +229,13 @@
 			else
 warn(SIOCGIFDSTADDR);
 		}
-		sat_print( -- , ifr.ifr_dstaddr);
+		sat_print1( -- , ifr.ifr_dstaddr);
 	}
 	if (flags  IFF_BROADCAST) {
 		/* note RTAX_BRD overlap with IFF_POINTOPOINT */
-		sat_print( broadcast , ifr.ifr_broadaddr);
+		/* note Appletalk broadcast is fixed. */
+		printf( broadcast %u.%u, ntohs(sat-sat_addr.s_net),
+			ATADDR_BCAST);
 	}
 	printf(\n);
 }



CVS commit: src/sbin/ifconfig

2010-01-22 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Jan 22 23:50:07 UTC 2010

Modified Files:
src/sbin/ifconfig: af_inet6.c

Log Message:
Compare a pointer with NULL instead of testing its truth.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/ifconfig/af_inet6.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.25 src/sbin/ifconfig/af_inet6.c:1.26
--- src/sbin/ifconfig/af_inet6.c:1.25	Fri Sep 11 22:06:29 2009
+++ src/sbin/ifconfig/af_inet6.c	Fri Jan 22 23:50:07 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.25 2009/09/11 22:06:29 dyoung Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.26 2010/01/22 23:50:07 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet6.c,v 1.25 2009/09/11 22:06:29 dyoung Exp $);
+__RCSID($NetBSD: af_inet6.c,v 1.26 2010/01/22 23:50:07 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -247,7 +247,7 @@
 			}
 		}
 	}
-	if (!lladdr)
+	if (lladdr == NULL)
 		errx(EXIT_FAILURE, could not determine link local address); 
 
  	memcpy(in6-s6_addr[8], lladdr-s6_addr[8], 8);



CVS commit: src/sbin/ifconfig

2009-09-16 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Sep 16 14:59:45 UTC 2009

Modified Files:
src/sbin/ifconfig: Makefile Makefile.inc

Log Message:
Add comments that Makefile.inc should have shared stuff with
src/distrib/utils/x_ifconfig for install media.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sbin/ifconfig/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.44 src/sbin/ifconfig/Makefile:1.45
--- src/sbin/ifconfig/Makefile:1.44	Tue Sep 15 09:22:07 2009
+++ src/sbin/ifconfig/Makefile	Wed Sep 16 14:59:45 2009
@@ -1,8 +1,9 @@
-#	$NetBSD: Makefile,v 1.44 2009/09/15 09:22:07 he Exp $
+#	$NetBSD: Makefile,v 1.45 2009/09/16 14:59:45 tsutsui Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
-# also needed for src/distrib/utils/x_ifconfig/Makefile.
+# also needed for src/distrib/utils/x_ifconfig.
+# such stuff should be into Makefile.inc.
 
 .include bsd.own.mk
 

Index: src/sbin/ifconfig/Makefile.inc
diff -u src/sbin/ifconfig/Makefile.inc:1.6 src/sbin/ifconfig/Makefile.inc:1.7
--- src/sbin/ifconfig/Makefile.inc:1.6	Tue Sep 15 09:22:07 2009
+++ src/sbin/ifconfig/Makefile.inc	Wed Sep 16 14:59:45 2009
@@ -1,4 +1,7 @@
-#	$NetBSD: Makefile.inc,v 1.6 2009/09/15 09:22:07 he Exp $
+#	$NetBSD: Makefile.inc,v 1.7 2009/09/16 14:59:45 tsutsui Exp $
+
+# shared stuff with src/distrib/utils/x_ifconfig for install media.
+# stuff not required by install media should be into Makefile.
 
 PROG=	ifconfig
 



CVS commit: src/sbin/ifconfig

2009-09-16 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Sep 16 15:08:29 UTC 2009

Modified Files:
src/sbin/ifconfig: Makefile

Log Message:
- no space needed between -I and dir per gcc(1)
- it's still better to use ${NETBSDSRCDIR} per other existing Makefiles


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sbin/ifconfig/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.45 src/sbin/ifconfig/Makefile:1.46
--- src/sbin/ifconfig/Makefile:1.45	Wed Sep 16 14:59:45 2009
+++ src/sbin/ifconfig/Makefile	Wed Sep 16 15:08:29 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.45 2009/09/16 14:59:45 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.46 2009/09/16 15:08:29 tsutsui Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -18,7 +18,7 @@
 
 .include Makefile.inc
 
-CPPFLAGS+=-I ${.CURDIR}/../../sys/dist/pf/
+CPPFLAGS+=-I${NETBSDSRCDIR}/sys/dist/pf/
 SRCS+= pfsync.c
 
 .if ${MACHINE_ARCH} == m68000



CVS commit: src/sbin/ifconfig

2009-09-15 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Tue Sep 15 09:22:07 UTC 2009

Modified Files:
src/sbin/ifconfig: Makefile Makefile.inc

Log Message:
Move the addition of pfsync.c from Makefile.inc to Makefile,
so that this part doesn't get included in install media versions
of ifconfig, as per comments on source-changes@ from Izumi Tsutsui.
Also re-instate the use of ${.CURDIR} when setting up the include path.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sbin/ifconfig/Makefile
cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.43 src/sbin/ifconfig/Makefile:1.44
--- src/sbin/ifconfig/Makefile:1.43	Tue Jun  2 23:41:35 2009
+++ src/sbin/ifconfig/Makefile	Tue Sep 15 09:22:07 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.43 2009/06/02 23:41:35 pooka Exp $
+#	$NetBSD: Makefile,v 1.44 2009/09/15 09:22:07 he Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -17,6 +17,9 @@
 
 .include Makefile.inc
 
+CPPFLAGS+=-I ${.CURDIR}/../../sys/dist/pf/
+SRCS+= pfsync.c
+
 .if ${MACHINE_ARCH} == m68000
 # XXX workaround for gcc -O1 bug (PR bin/40036 and toolchain/40066)
 COPTS.ifconfig.c+= -fno-loop-optimize

Index: src/sbin/ifconfig/Makefile.inc
diff -u src/sbin/ifconfig/Makefile.inc:1.5 src/sbin/ifconfig/Makefile.inc:1.6
--- src/sbin/ifconfig/Makefile.inc:1.5	Mon Sep 14 15:12:21 2009
+++ src/sbin/ifconfig/Makefile.inc	Tue Sep 15 09:22:07 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.5 2009/09/14 15:12:21 he Exp $
+#	$NetBSD: Makefile.inc,v 1.6 2009/09/15 09:22:07 he Exp $
 
 PROG=	ifconfig
 
@@ -19,6 +19,3 @@
 SRCS+= tunnel.c
 SRCS+= util.c
 SRCS+= vlan.c
-
-CPPFLAGS+=-I ${NETBSDSRCDIR}/sys/dist/pf/
-SRCS+= pfsync.c



CVS commit: src/sbin/ifconfig

2009-09-14 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Mon Sep 14 15:12:21 UTC 2009

Modified Files:
src/sbin/ifconfig: Makefile.inc

Log Message:
Change from using ${.CURDIR} to ${NETBSDSRCDIR} because this file
may be included by different parts of the source tree, in particular
deep down in the distrib/ tree, where ../.. isn't sufficient to climb
up to the top of the tree.  Fixes the build at least for our arc port.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/ifconfig/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile.inc
diff -u src/sbin/ifconfig/Makefile.inc:1.4 src/sbin/ifconfig/Makefile.inc:1.5
--- src/sbin/ifconfig/Makefile.inc:1.4	Mon Sep 14 10:36:49 2009
+++ src/sbin/ifconfig/Makefile.inc	Mon Sep 14 15:12:21 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.4 2009/09/14 10:36:49 degroote Exp $
+#	$NetBSD: Makefile.inc,v 1.5 2009/09/14 15:12:21 he Exp $
 
 PROG=	ifconfig
 
@@ -20,5 +20,5 @@
 SRCS+= util.c
 SRCS+= vlan.c
 
-CPPFLAGS+=-I ${.CURDIR}/../../sys/dist/pf/ 
+CPPFLAGS+=-I ${NETBSDSRCDIR}/sys/dist/pf/
 SRCS+= pfsync.c



CVS commit: src/sbin/ifconfig

2009-09-11 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Sep 11 23:22:28 UTC 2009

Modified Files:
src/sbin/ifconfig: carp.c

Log Message:
This should fix 'carpdev ifname' or, at least, not break it more
badly than before.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sbin/ifconfig/carp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/carp.c
diff -u src/sbin/ifconfig/carp.c:1.12 src/sbin/ifconfig/carp.c:1.13
--- src/sbin/ifconfig/carp.c:1.12	Tue Jul 15 21:27:58 2008
+++ src/sbin/ifconfig/carp.c	Fri Sep 11 23:22:28 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: carp.c,v 1.12 2008/07/15 21:27:58 dyoung Exp $ */
+/* $NetBSD: carp.c,v 1.13 2009/09/11 23:22:28 dyoung Exp $ */
 
 /*
  * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: carp.c,v 1.12 2008/07/15 21:27:58 dyoung Exp $);
+__RCSID($NetBSD: carp.c,v 1.13 2009/09/11 23:22:28 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -257,18 +257,18 @@
 setcarpdev(prop_dictionary_t env, prop_dictionary_t oenv)
 {
 	struct carpreq carpr;
-	prop_data_t data;
+	prop_string_t s;
 
-	data = (prop_data_t)prop_dictionary_get(env, carpdev);
-	if (data == NULL) {
+	s = (prop_string_t)prop_dictionary_get(env, carpdev);
+	if (s == NULL) {
 		errno = ENOENT;
 		return -1;
 	}
 
 	carp_get(env, carpr);
 
-	strlcpy(carpr.carpr_carpdev, prop_data_data_nocopy(data),
-	MIN(sizeof(carpr.carpr_carpdev), prop_data_size(data)));
+	strlcpy(carpr.carpr_carpdev, prop_string_cstring_nocopy(s),
+	sizeof(carpr.carpr_carpdev));
 
 	carp_set(env, carpr);
 	return 0;



CVS commit: src/sbin/ifconfig

2009-08-07 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Aug  7 18:53:37 UTC 2009

Modified Files:
src/sbin/ifconfig: af_inet6.c extern.h ifconfig.c tunnel.c util.c

Log Message:
Add option -N.  -N is just the opposite of option -n in netstat(8)
or route(8): it tells ifconfig(8) to try to resolve numbers to
hosts and service names.

This default ifconfig behavior stays the same as it always was.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sbin/ifconfig/af_inet6.c
cvs rdiff -u -r1.13 -r1.14 src/sbin/ifconfig/extern.h
cvs rdiff -u -r1.219 -r1.220 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.16 -r1.17 src/sbin/ifconfig/tunnel.c
cvs rdiff -u -r1.11 -r1.12 src/sbin/ifconfig/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet6.c
diff -u src/sbin/ifconfig/af_inet6.c:1.23 src/sbin/ifconfig/af_inet6.c:1.24
--- src/sbin/ifconfig/af_inet6.c:1.23	Tue Jul 15 20:56:13 2008
+++ src/sbin/ifconfig/af_inet6.c	Fri Aug  7 18:53:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet6.c,v 1.23 2008/07/15 20:56:13 dyoung Exp $	*/
+/*	$NetBSD: af_inet6.c,v 1.24 2009/08/07 18:53:37 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet6.c,v 1.23 2008/07/15 20:56:13 dyoung Exp $);
+__RCSID($NetBSD: af_inet6.c,v 1.24 2009/08/07 18:53:37 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -278,7 +278,7 @@
 	char hbuf[NI_MAXHOST];
 	u_int32_t scopeid;
 	int s;
-	const int niflag = NI_NUMERICHOST;
+	const int niflag = Nflag ? 0 : NI_NUMERICHOST;
 	unsigned short flags;
 
 	/* Get the non-alias address for this interface. */

Index: src/sbin/ifconfig/extern.h
diff -u src/sbin/ifconfig/extern.h:1.13 src/sbin/ifconfig/extern.h:1.14
--- src/sbin/ifconfig/extern.h:1.13	Tue Jul 15 20:56:13 2008
+++ src/sbin/ifconfig/extern.h	Fri Aug  7 18:53:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.13 2008/07/15 20:56:13 dyoung Exp $	*/
+/*	$NetBSD: extern.h,v 1.14 2009/08/07 18:53:37 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -88,6 +88,6 @@
 int register_flag(int);
 bool get_flag(int);
 
-extern bool lflag, vflag, zflag;
+extern bool lflag, Nflag, vflag, zflag;
 
 #endif	/* _IFCONFIG_EXTERN_H */

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.219 src/sbin/ifconfig/ifconfig.c:1.220
--- src/sbin/ifconfig/ifconfig.c:1.219	Tue May 26 16:03:24 2009
+++ src/sbin/ifconfig/ifconfig.c	Fri Aug  7 18:53:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.219 2009/05/26 16:03:24 pooka Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.220 2009/08/07 18:53:37 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.219 2009/05/26 16:03:24 pooka Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.220 2009/08/07 18:53:37 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -102,9 +102,9 @@
 #include env.h
 
 static bool bflag, dflag, hflag, sflag, uflag;
-bool lflag, vflag, zflag;
+bool lflag, Nflag, vflag, zflag;
 
-static char gflags[10 + 26 * 2 + 1] = AabCdhlsuvz;
+static char gflags[10 + 26 * 2 + 1] = AabCdhlNsuvz;
 bool gflagset[10 + 26 * 2];
 
 static int carrier(prop_dictionary_t);
@@ -550,7 +550,7 @@
 	start = init_parser();
 
 	/* Parse command-line options */
-	aflag = vflag = zflag = false;
+	aflag = Nflag = vflag = zflag = false;
 	while ((ch = getopt(argc, argv, gflags)) != -1) {
 		switch (ch) {
 		case 'A':
@@ -578,6 +578,9 @@
 		case 'l':
 			lflag = true;
 			break;
+		case 'N':
+			Nflag = true;
+			break;
 
 		case 's':
 			sflag = true;

Index: src/sbin/ifconfig/tunnel.c
diff -u src/sbin/ifconfig/tunnel.c:1.16 src/sbin/ifconfig/tunnel.c:1.17
--- src/sbin/ifconfig/tunnel.c:1.16	Tue Jul 15 21:27:58 2008
+++ src/sbin/ifconfig/tunnel.c	Fri Aug  7 18:53:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: tunnel.c,v 1.16 2008/07/15 21:27:58 dyoung Exp $	*/
+/*	$NetBSD: tunnel.c,v 1.17 2009/08/07 18:53:37 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: tunnel.c,v 1.16 2008/07/15 21:27:58 dyoung Exp $);
+__RCSID($NetBSD: tunnel.c,v 1.17 2009/08/07 18:53:37 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -157,7 +157,7 @@
 	char srcserv[sizeof(,65535)];
 	char psrcaddr[NI_MAXHOST];
 	char pdstaddr[NI_MAXHOST];
-	const int niflag = NI_NUMERICHOST|NI_NUMERICSERV;
+	const int niflag = Nflag ? 0 : (NI_NUMERICHOST|NI_NUMERICSERV);
 	struct if_laddrreq req;
 	const struct afswtch *afp;
 

Index: src/sbin/ifconfig/util.c
diff -u src/sbin/ifconfig/util.c:1.11 src/sbin/ifconfig/util.c:1.12
--- src/sbin/ifconfig/util.c:1.11	Mon Apr 27 20:10:49 2009
+++ src/sbin/ifconfig/util.c	Fri Aug  7 18:53:37 2009
@@ -1,4 +1,4 @@

CVS commit: src/sbin/ifconfig

2009-08-07 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Aug  7 19:35:55 UTC 2009

Modified Files:
src/sbin/ifconfig: af_inet.c

Log Message:
Use getnameinfo(3) instead of inet_ntoa(3) to convert IPv4 addresses
to names.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sbin/ifconfig/af_inet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_inet.c
diff -u src/sbin/ifconfig/af_inet.c:1.12 src/sbin/ifconfig/af_inet.c:1.13
--- src/sbin/ifconfig/af_inet.c:1.12	Wed Jul  2 07:44:14 2008
+++ src/sbin/ifconfig/af_inet.c	Fri Aug  7 19:35:55 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_inet.c,v 1.12 2008/07/02 07:44:14 dyoung Exp $	*/
+/*	$NetBSD: af_inet.c,v 1.13 2009/08/07 19:35:55 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_inet.c,v 1.12 2008/07/02 07:44:14 dyoung Exp $);
+__RCSID($NetBSD: af_inet.c,v 1.13 2009/08/07 19:35:55 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -79,6 +79,11 @@
 	int s;
 	unsigned short flags;
 	struct in_aliasreq in_addreq;
+	const struct sockaddr_in * const asin = in_addreq.ifra_addr;
+	const struct sockaddr_in * const dsin = in_addreq.ifra_dstaddr;
+	const struct sockaddr_in * const bsin = in_addreq.ifra_broadaddr;
+	char hbuf[NI_MAXHOST];
+	const int niflag = Nflag ? 0 : NI_NUMERICHOST;
 
 	if (lflag)
 		return;
@@ -109,20 +114,28 @@
 			warn(SIOCGIFALIAS);
 	}
 
-	printf(\tinet %s%s, alias ? alias  : ,
-	inet_ntoa(in_addreq.ifra_addr.sin_addr));
+	if (getnameinfo((const struct sockaddr *)asin, asin-sin_len,
+			hbuf, sizeof(hbuf), NULL, 0, niflag))
+		strlcpy(hbuf, , sizeof(hbuf));	/* some message? */
+	printf(\tinet %s%s, alias ? alias  : , hbuf);
 
 	if (getifflags(env, oenv, flags) == -1)
 		err(EXIT_FAILURE, %s: getifflags, __func__);
 
-	if (flags  IFF_POINTOPOINT)
-		printf( - %s, inet_ntoa(in_addreq.ifra_dstaddr.sin_addr));
+	if (flags  IFF_POINTOPOINT) {
+		if (getnameinfo((const struct sockaddr *)dsin, dsin-sin_len,
+hbuf, sizeof(hbuf), NULL, 0, niflag))
+			strlcpy(hbuf, , sizeof(hbuf)); /* some message? */
+		printf( - %s, hbuf);
+	}
 
 	printf( netmask 0x%x, ntohl(in_addreq.ifra_mask.sin_addr.s_addr));
 
 	if (flags  IFF_BROADCAST) {
-		printf( broadcast %s,
-		inet_ntoa(in_addreq.ifra_broadaddr.sin_addr));
+		if (getnameinfo((const struct sockaddr *)bsin, bsin-sin_len,
+hbuf, sizeof(hbuf), NULL, 0, niflag))
+			strlcpy(hbuf, , sizeof(hbuf)); /* some message? */
+		printf( broadcast %s, hbuf);
 	}
 }
 



CVS commit: src/sbin/ifconfig

2009-08-07 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Fri Aug  7 20:13:12 UTC 2009

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Describe the -N flag.


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.99 src/sbin/ifconfig/ifconfig.8:1.100
--- src/sbin/ifconfig/ifconfig.8:1.99	Wed Jul 29 21:47:11 2009
+++ src/sbin/ifconfig/ifconfig.8	Fri Aug  7 20:13:12 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: ifconfig.8,v 1.99 2009/07/29 21:47:11 hubertf Exp $
+.\	$NetBSD: ifconfig.8,v 1.100 2009/08/07 20:13:12 dyoung Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)ifconfig.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd July 2, 2009
+.Dd August 7, 2009
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -37,6 +37,7 @@
 .Nd configure network interface parameters
 .Sh SYNOPSIS
 .Nm
+.Op Fl N
 .Ar interface address_family
 .Oo
 .Ar address
@@ -44,12 +45,12 @@
 .Oc
 .Op Ar parameters
 .Nm
-.Op Fl hLmvz
+.Op Fl hLmNvz
 .Ar interface
 .Op Ar protocol_family
 .Nm
 .Fl a
-.Op Fl bdhLmsuvz
+.Op Fl bdhLNmsuvz
 .Op Ar protocol_family
 .Nm
 .Fl l
@@ -813,6 +814,21 @@
 flag except that it zeros the interface input and output statistics
 after printing them.
 .Pp
+The
+.Fl N
+flag is just the opposite of the
+.Fl n
+flag in
+.Xr netstat 1
+or in
+.Xr route 8 :
+it tells
+.Nm
+to try to resolve numbers to hostnames or to service names.
+The default
+.Nm
+behavior is to print numbers instead of names.
+.Pp
 Only the super-user may modify the configuration of a network interface.
 .Sh EXAMPLES
 Add a link-layer (MAC) address to an Ethernet:



CVS commit: src/sbin/ifconfig

2009-07-29 Thread Hubert Feyrer
Module Name:src
Committed By:   hubertf
Date:   Wed Jul 29 21:47:11 UTC 2009

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Add MAC keyword to the corresponding example.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.98 src/sbin/ifconfig/ifconfig.8:1.99
--- src/sbin/ifconfig/ifconfig.8:1.98	Thu Jul  2 18:43:47 2009
+++ src/sbin/ifconfig/ifconfig.8	Wed Jul 29 21:47:11 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: ifconfig.8,v 1.98 2009/07/02 18:43:47 dyoung Exp $
+.\	$NetBSD: ifconfig.8,v 1.99 2009/07/29 21:47:11 hubertf Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -819,7 +819,7 @@
 .Pp
 .Ic ifconfig sip0 link 00:11:22:33:44:55
 .Pp
-Add and activate a link-layer address:
+Add and activate a link-layer (MAC) address:
 .Pp
 .Ic ifconfig sip0 link 00:11:22:33:44:55 active
 .Sh DIAGNOSTICS



CVS commit: src/sbin/ifconfig

2009-07-28 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Jul 28 18:22:33 UTC 2009

Modified Files:
src/sbin/ifconfig: vlan.c

Log Message:
Don't require a vlan argument with -vlanif.  ifconfig vlan0
-vlanif works as one would expect, now.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sbin/ifconfig/vlan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/vlan.c
diff -u src/sbin/ifconfig/vlan.c:1.12 src/sbin/ifconfig/vlan.c:1.13
--- src/sbin/ifconfig/vlan.c:1.12	Tue Jul 15 21:27:58 2008
+++ src/sbin/ifconfig/vlan.c	Tue Jul 28 18:22:33 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: vlan.c,v 1.12 2008/07/15 21:27:58 dyoung Exp $	*/
+/*	$NetBSD: vlan.c,v 1.13 2009/07/28 18:22:33 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -31,7 +31,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: vlan.c,v 1.12 2008/07/15 21:27:58 dyoung Exp $);
+__RCSID($NetBSD: vlan.c,v 1.13 2009/07/28 18:22:33 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -140,17 +140,17 @@
 	if (getvlan(env, vlr, false) == -1)
 		err(EXIT_FAILURE, %s: getsock, __func__);
 
-	if (!prop_dictionary_get_int64(env, vlantag, tag)) {
-		errno = ENOENT;
-		return -1;
-	}
-
 	if (!prop_dictionary_get_cstring_nocopy(env, vlanif, parent)) {
 		errno = ENOENT;
 		return -1;
 	}
 	strlcpy(vlr.vlr_parent, parent, sizeof(vlr.vlr_parent));
-	if (strcmp(parent, ) != 0)
+	if (strcmp(parent, ) == 0)
+		;
+	else if (!prop_dictionary_get_int64(env, vlantag, tag)) {
+		errno = ENOENT;
+		return -1;
+	} else
 		vlr.vlr_tag = (unsigned short)tag;
 
 	if (indirect_ioctl(env, SIOCSETVLAN, vlr) == -1)



CVS commit: src/sbin/ifconfig

2009-07-02 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Thu Jul  2 18:43:47 UTC 2009

Modified Files:
src/sbin/ifconfig: ifconfig.8

Log Message:
Use the keyword 'MAC' so that people looking for a way to change
their MAC address can find the example.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sbin/ifconfig/ifconfig.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.97 src/sbin/ifconfig/ifconfig.8:1.98
--- src/sbin/ifconfig/ifconfig.8:1.97	Thu Jul  2 17:45:25 2009
+++ src/sbin/ifconfig/ifconfig.8	Thu Jul  2 18:43:47 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: ifconfig.8,v 1.97 2009/07/02 17:45:25 dyoung Exp $
+.\	$NetBSD: ifconfig.8,v 1.98 2009/07/02 18:43:47 dyoung Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -815,7 +815,7 @@
 .Pp
 Only the super-user may modify the configuration of a network interface.
 .Sh EXAMPLES
-Add a link-layer address to an Ethernet:
+Add a link-layer (MAC) address to an Ethernet:
 .Pp
 .Ic ifconfig sip0 link 00:11:22:33:44:55
 .Pp



CVS commit: src/sbin/ifconfig

2009-06-02 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Jun  2 23:41:35 UTC 2009

Modified Files:
src/sbin/ifconfig: Makefile

Log Message:
If RUMP_ACTION, treat close() as a rump syscall.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sbin/ifconfig/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/Makefile
diff -u src/sbin/ifconfig/Makefile:1.42 src/sbin/ifconfig/Makefile:1.43
--- src/sbin/ifconfig/Makefile:1.42	Tue May 26 16:03:24 2009
+++ src/sbin/ifconfig/Makefile	Tue Jun  2 23:41:35 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.42 2009/05/26 16:03:24 pooka Exp $
+#	$NetBSD: Makefile,v 1.43 2009/06/02 23:41:35 pooka Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 # when making a change to this file, please check if the change is
@@ -28,7 +28,8 @@
 # to figure out where ioctl's go in the kernel.
 #
 .ifdef RUMP_ACTION
-CPPFLAGS+=	-DRUMP_SYS_NETWORKING -DRUMP_SYS_IOCTL -DRUMP_ACTION
+CPPFLAGS+=	-DRUMP_SYS_NETWORKING -DRUMP_SYS_IOCTL -DRUMP_SYS_CLOSE
+CPPFLAGS+=	-DRUMP_ACTION
 LDADD+=		-lrumpnet_virtif -lrumpnet_netinet -lrumpnet_net -lrumpnet
 LDADD+=		-lrump -lrumpuser -lpthread
 DBG=		-g



CVS commit: src/sbin/ifconfig

2009-04-21 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Apr 21 18:00:25 UTC 2009

Modified Files:
src/sbin/ifconfig: af_link.c

Log Message:
Fix indentation: change spaces to tabs.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/ifconfig/af_link.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_link.c
diff -u src/sbin/ifconfig/af_link.c:1.3 src/sbin/ifconfig/af_link.c:1.4
--- src/sbin/ifconfig/af_link.c:1.3	Wed Jul  2 07:44:14 2008
+++ src/sbin/ifconfig/af_link.c	Tue Apr 21 18:00:25 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_link.c,v 1.3 2008/07/02 07:44:14 dyoung Exp $	*/
+/*	$NetBSD: af_link.c,v 1.4 2009/04/21 18:00:25 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_link.c,v 1.3 2008/07/02 07:44:14 dyoung Exp $);
+__RCSID($NetBSD: af_link.c,v 1.4 2009/04/21 18:00:25 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -112,7 +112,7 @@
 		if (ioctl(s, SIOCGLIFADDR, iflr) == -1)
 			err(EXIT_FAILURE, %s: ioctl, __func__);
 
-if ((iflr.flags  IFLR_ACTIVE) != 0)
+		if ((iflr.flags  IFLR_ACTIVE) != 0)
 			continue;
 
 		octets = (const uint8_t *)sdl-sdl_data[sdl-sdl_nlen];



CVS commit: src/sbin/ifconfig

2009-04-21 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Tue Apr 21 22:46:40 UTC 2009

Modified Files:
src/sbin/ifconfig: af_link.c ifconfig.c util.c util.h

Log Message:
To make sure that we always print the active link-layer address in the
'address: ' field, don't treat the first address as the active address,
but search the link-layer addresses for the ones flagged IFLR_ACTIVE,
and print those.  Extract a subroutine, print_link_addresses(), for
printing link-layer addresses.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/ifconfig/af_link.c
cvs rdiff -u -r1.217 -r1.218 src/sbin/ifconfig/ifconfig.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/ifconfig/util.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/ifconfig/util.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/af_link.c
diff -u src/sbin/ifconfig/af_link.c:1.5 src/sbin/ifconfig/af_link.c:1.6
--- src/sbin/ifconfig/af_link.c:1.5	Tue Apr 21 21:42:35 2009
+++ src/sbin/ifconfig/af_link.c	Tue Apr 21 22:46:39 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: af_link.c,v 1.5 2009/04/21 21:42:35 dyoung Exp $	*/
+/*	$NetBSD: af_link.c,v 1.6 2009/04/21 22:46:39 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,7 +27,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: af_link.c,v 1.5 2009/04/21 21:42:35 dyoung Exp $);
+__RCSID($NetBSD: af_link.c,v 1.6 2009/04/21 22:46:39 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h 
@@ -74,53 +74,7 @@
 static void
 link_status(prop_dictionary_t env, prop_dictionary_t oenv, bool force)
 {
-	char hbuf[NI_MAXHOST];
-	const char *ifname;
-	int s;
-	struct ifaddrs *ifa, *ifap;
-	const struct sockaddr_dl *sdl;
-	struct if_laddrreq iflr;
-
-	if ((ifname = getifname(env)) == NULL)
-		err(EXIT_FAILURE, %s: getifname, __func__);
-
-	if ((s = getsock(AF_LINK)) == -1)
-		err(EXIT_FAILURE, %s: getsock, __func__);
-
-	if (getifaddrs(ifap) == -1)
-		err(EXIT_FAILURE, %s: getifaddrs, __func__);
-
-	memset(iflr, 0, sizeof(iflr));
-
-	strlcpy(iflr.iflr_name, ifname, sizeof(iflr.iflr_name));
-
-	for (ifa = ifap; ifa != NULL; ifa = ifa-ifa_next) {
-		if (strcmp(ifname, ifa-ifa_name) != 0)
-			continue;
-		if (ifa-ifa_addr-sa_family != AF_LINK)
-			continue;
-		if (ifa-ifa_data != NULL)
-			continue;
-
-		sdl = satocsdl(ifa-ifa_addr);
-
-		memcpy(iflr.addr, ifa-ifa_addr, MIN(ifa-ifa_addr-sa_len,
-		sizeof(iflr.addr)));
-		iflr.flags = IFLR_PREFIX;
-		iflr.prefixlen = sdl-sdl_alen * NBBY;
-
-		if (ioctl(s, SIOCGLIFADDR, iflr) == -1)
-			err(EXIT_FAILURE, %s: ioctl, __func__);
-
-		if ((iflr.flags  IFLR_ACTIVE) != 0)
-			continue;
-
-		if (getnameinfo(ifa-ifa_addr, ifa-ifa_addr-sa_len,
-			hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) == 0 
-		hbuf[0] != '\0')
-			printf(\tlink %s\n, hbuf);
-	}
-	freeifaddrs(ifap);
+	print_link_addresses(env, false);
 }
 
 static int

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.217 src/sbin/ifconfig/ifconfig.c:1.218
--- src/sbin/ifconfig/ifconfig.c:1.217	Tue Apr 21 22:13:10 2009
+++ src/sbin/ifconfig/ifconfig.c	Tue Apr 21 22:46:39 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.217 2009/04/21 22:13:10 dyoung Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.218 2009/04/21 22:46:39 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.217 2009/04/21 22:13:10 dyoung Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.218 2009/04/21 22:46:39 dyoung Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -1152,7 +1152,6 @@
 	statistics_func_t *statistics_f;
 	struct ifdatareq ifdr;
 	struct ifreq ifr;
-	char hbuf[NI_MAXHOST];
 	char fbuf[BUFSIZ];
 	int af, s;
 	const char *ifname;
@@ -1202,11 +1201,7 @@
 	SIMPLEQ_FOREACH(status_f, status_funcs, f_next)
 		(*status_f-f_func)(env, oenv);
 
-	if (sdl != NULL 
-	getnameinfo(sdl, sdl-sa_len,
-		hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) == 0 
-	hbuf[0] != '\0')
-		printf(\taddress: %s\n, hbuf);
+	print_link_addresses(env, true);
 
 	media_status(env, oenv);
 

Index: src/sbin/ifconfig/util.c
diff -u src/sbin/ifconfig/util.c:1.9 src/sbin/ifconfig/util.c:1.10
--- src/sbin/ifconfig/util.c:1.9	Sun Jan 18 00:24:29 2009
+++ src/sbin/ifconfig/util.c	Tue Apr 21 22:46:39 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.9 2009/01/18 00:24:29 lukem Exp $	*/
+/*	$NetBSD: util.c,v 1.10 2009/04/21 22:46:39 dyoung Exp $	*/
 
 /*-
  * Copyright (c) 2008 David Young.  All rights reserved.
@@ -27,12 +27,13 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: util.c,v 1.9 2009/01/18 00:24:29 lukem Exp $);
+__RCSID($NetBSD: util.c,v 1.10 2009/04/21 22:46:39 dyoung Exp $);
 #endif /* not lint */
 
 #include ctype.h
 #include err.h
 #include errno.h
+#include netdb.h
 #include stddef.h
 #include 

CVS commit: src/sbin/ifconfig

2009-04-04 Thread Iain Hibbert
Module Name:src
Committed By:   plunky
Date:   Sat Apr  4 17:10:20 UTC 2009

Modified Files:
src/sbin/ifconfig: ifconfig.c

Log Message:
Because the IFF_NOARP flag is a negative option it needs to be negated
when being applied from the arp option which itself is positive.

problem demonstrated by

# ifconfig tap3 create
# ifconfig tap3
tap3: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 arp
# ifconfig tap3
tap3: flags=8882BROADCAST,NOARP,SIMPLEX,MULTICAST mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 -arp
# ifconfig tap3
tap3: flags=8802BROADCAST,SIMPLEX,MULTICAST mtu 1500
address: f2:0b:a4:7f:44:03
media: Ethernet autoselect
# ifconfig tap3 destroy
#


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sbin/ifconfig/ifconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/ifconfig/ifconfig.c
diff -u src/sbin/ifconfig/ifconfig.c:1.214 src/sbin/ifconfig/ifconfig.c:1.215
--- src/sbin/ifconfig/ifconfig.c:1.214	Sun Jan 18 00:24:29 2009
+++ src/sbin/ifconfig/ifconfig.c	Sat Apr  4 17:10:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ifconfig.c,v 1.214 2009/01/18 00:24:29 lukem Exp $	*/
+/*	$NetBSD: ifconfig.c,v 1.215 2009/04/04 17:10:19 plunky Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1983, 1993\
  The Regents of the University of California.  All rights reserved.);
-__RCSID($NetBSD: ifconfig.c,v 1.214 2009/01/18 00:24:29 lukem Exp $);
+__RCSID($NetBSD: ifconfig.c,v 1.215 2009/04/04 17:10:19 plunky Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -131,7 +131,7 @@
 static void usage(void);
 
 static const struct kwinst ifflagskw[] = {
-	  IFKW(arp, IFF_NOARP)
+	  IFKW(arp, -IFF_NOARP)
 	, IFKW(debug, IFF_DEBUG)
 	, IFKW(link0, IFF_LINK0)
 	, IFKW(link1, IFF_LINK1)