Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/ifconfig Add powersave, -powersave, and powersavesleep ...



details:   https://anonhg.NetBSD.org/src/rev/65a372e7bef6
branches:  trunk
changeset: 500440:65a372e7bef6
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Dec 12 04:08:40 2000 +0000

description:
Add powersave, -powersave, and powersavesleep to manipulate 802.11
power management parameters.

diffstat:

 sbin/ifconfig/ifconfig.8 |  11 ++++++++-
 sbin/ifconfig/ifconfig.c |  59 +++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 66 insertions(+), 4 deletions(-)

diffs (138 lines):

diff -r b65a1d7402d1 -r 65a372e7bef6 sbin/ifconfig/ifconfig.8
--- a/sbin/ifconfig/ifconfig.8  Tue Dec 12 04:07:35 2000 +0000
+++ b/sbin/ifconfig/ifconfig.8  Tue Dec 12 04:08:40 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ifconfig.8,v 1.44 2000/10/18 07:27:11 kleink Exp $
+.\"    $NetBSD: ifconfig.8,v 1.45 2000/12/12 04:08:40 thorpej Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -332,6 +332,15 @@
 .It Fl nwkey
 (IEEE 802.11 devices only)
 Disable WEP encryption for IEEE 802.11-based wireless network interfaces.
+.It Cm powersave
+(IEEE 802.11 devices only)
+Enable 802.11 power saving mode.
+.It Fl powersave
+(IEEE 802.11 devices only)
+Disable 802.11 power saving mode.
+.It Cm powersavesleep
+(IEEE 802.11 devices only)
+Set the receiver sleep duration for 802.11 power saving mode.
 .It Cm tunnel Ar src_addr Ar dest_addr
 (IP tunnel devices only)
 Configure the physical source and destination address for IP tunnel
diff -r b65a1d7402d1 -r 65a372e7bef6 sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c  Tue Dec 12 04:07:35 2000 +0000
+++ b/sbin/ifconfig/ifconfig.c  Tue Dec 12 04:08:40 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ifconfig.c,v 1.91 2000/11/07 14:47:59 itojun Exp $     */
+/*     $NetBSD: ifconfig.c,v 1.92 2000/12/12 04:08:40 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
 #if 0
 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
 #else
-__RCSID("$NetBSD: ifconfig.c,v 1.91 2000/11/07 14:47:59 itojun Exp $");
+__RCSID("$NetBSD: ifconfig.c,v 1.92 2000/12/12 04:08:40 thorpej Exp $");
 #endif
 #endif /* not lint */
 
@@ -162,6 +162,8 @@
 void   setifmtu __P((const char *, int));
 void   setifnwid __P((const char *, int));
 void   setifnwkey __P((const char *, int));
+void   setifpowersave __P((const char *, int));
+void   setifpowersavesleep __P((const char *, int));
 void   setifnetmask __P((const char *, int));
 void   setifprefixlen __P((const char *, int));
 void   setnsellength __P((const char *, int));
@@ -240,6 +242,9 @@
        { "nwid",       NEXTARG,        0,              setifnwid },
        { "nwkey",      NEXTARG,        0,              setifnwkey },
        { "-nwkey",     -1,             0,              setifnwkey },
+       { "powersave",  1,              0,              setifpowersave },
+       { "-powersave", 0,              0,              setifpowersave },
+       { "powersavesleep", NEXTARG,    0,              setifpowersavesleep },
        { "broadcast",  NEXTARG,        0,              setifbroadaddr },
        { "ipdst",      NEXTARG,        0,              setifipdst },
        { "prefixlen",  NEXTARG,        0,              setifprefixlen},
@@ -1387,11 +1392,48 @@
 }
 
 void
+setifpowersave(val, d)
+       const char *val;
+       int d;
+{
+       struct ieee80211_power power;
+
+       (void)strncpy(power.i_name, name, sizeof(power.i_name));
+       if (ioctl(s, SIOCG80211POWER, (caddr_t)&power) < 0) {
+               warn("SIOCG80211POWER");
+               return;
+       }
+
+       power.i_enabled = d;
+       if (ioctl(s, SIOCS80211POWER, (caddr_t)&power) < 0)
+               warn("SIOCS80211POWER");
+}
+
+void
+setifpowersavesleep(val, d)
+       const char *val;
+       int d;
+{
+       struct ieee80211_power power;
+
+       (void)strncpy(power.i_name, name, sizeof(power.i_name));
+       if (ioctl(s, SIOCG80211POWER, (caddr_t)&power) < 0) {
+               warn("SIOCG80211POWER");
+               return;
+       }
+
+       power.i_maxsleep = atoi(val);
+       if (ioctl(s, SIOCS80211POWER, (caddr_t)&power) < 0)
+               warn("SIOCS80211POWER");
+}
+
+void
 ieee80211_status()
 {
        int i;
        struct ieee80211_nwid nwid;
        struct ieee80211_nwkey nwkey;
+       struct ieee80211_power power;
        u_int8_t keybuf[IEEE80211_WEP_NKID][16];
 
        memset(&ifr, 0, sizeof(ifr));
@@ -1411,7 +1453,7 @@
        if (ioctl(s, SIOCG80211NWKEY, (caddr_t)&nwkey) != 0 ||
            nwkey.i_wepon == 0) {
                printf("\n");
-               return;
+               goto skip_wep;
        }
 
        printf(" nwkey ");
@@ -1452,6 +1494,17 @@
                }
        }
        printf("\n");
+
+ skip_wep:
+       (void)strncpy(power.i_name, name, sizeof(power.i_name));
+       if (ioctl(s, SIOCG80211POWER, &power) != 0)
+               return;
+       printf("\tpowersave ");
+       if (power.i_enabled)
+               printf("on (%dms sleep)", power.i_maxsleep);
+       else
+               printf("off");
+       printf("\n");
 }
 
 void



Home | Main Index | Thread Index | Old Index