*** switchto	Sun Sep 21 08:00:29 2003
--- switchto.new	Wed Jul 14 15:13:07 2004
***************
*** 26,36 ****
  #
  # Send bug-reports, comments, women to bugs@muthanna.com
  #
! # Also see /etc/switchto.conf for further docs.
  #
  # Release: 0.16
  #
  # $Log: switchto,v $
  # Revision 1.17  2003/01/23 16:07:59  muthanna
  # - Taint mode warning on some systems fix.
  #
--- 26,42 ----
  #
  # Send bug-reports, comments, women to bugs@muthanna.com
  #
! # Also see /etc/quickswitch/switchto.conf for further docs.
  #
  # Release: 0.16
  #
  # $Log: switchto,v $
+ # Revision 1.18  2004/07/14 15:10:41  btaitelb
+ # - Added iwconfig options (without parameter checking)
+ # - the following are now valid keywords:
+ #   essid, nwid, freq, channel, sens, mode, ap, nick,
+ #   rate, rts, frag, txpower, key, power, retry
+ #
  # Revision 1.17  2003/01/23 16:07:59  muthanna
  # - Taint mode warning on some systems fix.
  #
***************
*** 143,157 ****
  $AUTHOR    = "Mohit Muthanna, Paul Seamons";
  $DATE      = '2002';
  
! ### I would suggest renaming this /etc/switchto.conf
! $CONF_FILE = "/etc/switchto.conf";
  %DEFAULTS  = (
                autoconfig      => 0,
                device          => "eth0",
                ifconfig        => "/sbin/ifconfig",
                iwconfig        => "/sbin/iwconfig",
                dhcpconfig      => "/sbin/dhcpcd -n", # newer versions of redhat
!               dhcpkill      => "/sbin/dhcpcd -k", # newer versions of redhat
                netstat         => "/bin/netstat",
                route           => "/sbin/route",
                hostnamecmd     => "/bin/hostname",
--- 149,163 ----
  $AUTHOR    = "Mohit Muthanna, Paul Seamons";
  $DATE      = '2002';
  
! ### I would suggest renaming this /etc/quickswitch/switchto.conf
! $CONF_FILE = "/etc/quickswitch/switchto.conf";
  %DEFAULTS  = (
                autoconfig      => 0,
                device          => "eth0",
                ifconfig        => "/sbin/ifconfig",
                iwconfig        => "/sbin/iwconfig",
                dhcpconfig      => "/sbin/dhcpcd -n", # newer versions of redhat
!               dhcpkill        => "/sbin/dhcpcd -k", # newer versions of redhat
                netstat         => "/bin/netstat",
                route           => "/sbin/route",
                hostnamecmd     => "/bin/hostname",
***************
*** 165,171 ****
                nfsexportall    => "/usr/sbin/exportfs -a",
                nfsexportsfile  => "/etc/exports",
                niscommand      => "/bin/nisdomainname",
!               servicefilename => "/etc/switchto.last",
                execpre         => undef,
                execpost        => undef,
  
--- 171,177 ----
                nfsexportall    => "/usr/sbin/exportfs -a",
                nfsexportsfile  => "/etc/exports",
                niscommand      => "/bin/nisdomainname",
!               servicefilename => "/etc/quickswitch/switchto.last",
                execpre         => undef,
                execpost        => undef,
  
***************
*** 472,478 ****
                        domain      search
                        usehosts    nfsexports
                        nisdomain   essid
!                       key
                        )){
      $self->{$key} = $ref->{$key} if defined($ref->{$key});
    }  
--- 478,490 ----
                        domain      search
                        usehosts    nfsexports
                        nisdomain   essid
! 		      nwid        freq
! 		      channel     sens
! 		      mode        ap
! 		      nick        rate
! 		      rts         frag
! 		      txpower     key
! 		      power       retry
                        )){
      $self->{$key} = $ref->{$key} if defined($ref->{$key});
    }  
***************
*** 523,529 ****
      $self->{hostname} = lc($1);
      print "Got Hostname \"$self->{hostname}\"\n" if $self->{verbose};
    }
!   
    if( $cmd_line =~ m/\s+essid:(\S+)?/i ){
      $self->humanerr("Invalid ESSID.\n") unless length($1);
      $self->{essid} = $1;
--- 535,541 ----
      $self->{hostname} = lc($1);
      print "Got Hostname \"$self->{hostname}\"\n" if $self->{verbose};
    }
! 
    if( $cmd_line =~ m/\s+essid:(\S+)?/i ){
      $self->humanerr("Invalid ESSID.\n") unless length($1);
      $self->{essid} = $1;
***************
*** 536,541 ****
--- 548,556 ----
      $self->{key} = $1;
      print "Got key \"$self->{key}\"\n" if $self->{verbose};
    }
+ 
+   # other iwconfig parameter checks should go here!
+ 
    
    if( $cmd_line =~ m/\s+usehosts:(\S+)?/i ){
      $self->humanerr("Invalid host file name.\n") unless length($1);
***************
*** 600,607 ****
    $self->do_execpre if $self->{execpre};
    
    # Setup wireless LAN configuration
!   $self->configure_wireless if $self->{essid} || $self->{key};
! 
    # Setup the device (default is eth0)
    $self->configure_device;
  
--- 615,637 ----
    $self->do_execpre if $self->{execpre};
    
    # Setup wireless LAN configuration
!   $self->configure_wireless if 
!       $self->{essid} || 
!       $self->{nwid} ||
!       $self->{freq} ||
!       $self->{channel} ||
!       $self->{sens} ||
!       $self->{mode} ||
!       $self->{ap} ||
!       $self->{nick} ||
!       $self->{rate} ||
!       $self->{rts} ||
!       $self->{frag} ||
!       $self->{txpower} ||
!       $self->{key} ||
!       $self->{power} ||
!       $self->{retry};
!                                
    # Setup the device (default is eth0)
    $self->configure_device;
  
***************
*** 687,699 ****
  sub configure_wireless {
    my $self = shift;
  
!   $self->do_command("Setting up ESSID...\n",
                      "$self->{iwconfig} $self->{device} essid $self->{essid}")
      if defined $self->{essid};
  
!   $self->do_command("Setting up iwconfig key...\n",
                      "$self->{iwconfig} $self->{device} key $self->{key}")
      if defined $self->{key};
  }
  
  sub configure_device {
--- 717,781 ----
  sub configure_wireless {
    my $self = shift;
  
!   $self->do_command("Setting up iwconfig mode...\n",
! 		    "$self->{iwconfig} $self->{device} mode $self->{mode}")
!     if defined $self->{mode};
! 
!   $self->do_command("Setting up essid...\n",
                      "$self->{iwconfig} $self->{device} essid $self->{essid}")
      if defined $self->{essid};
  
!   $self->do_command("Setting up nwid...\n",
!                     "$self->{iwconfig} $self->{device} nwid $self->{nwid}")
!     if defined $self->{nwid};
! 
!   $self->do_command("Setting up freq...\n",
!                     "$self->{iwconfig} $self->{device} freq $self->{freq}")
!     if defined $self->{freq};
! 
!   $self->do_command("Setting up channel...\n",
!                     "$self->{iwconfig} $self->{device} channel $self->{channel}")
!     if defined $self->{channel};
! 
!   $self->do_command("Setting up sens...\n",
!                     "$self->{iwconfig} $self->{device} sens $self->{sens}")
!     if defined $self->{sens};
! 
!   $self->do_command("Setting up ap...\n",
!                     "$self->{iwconfig} $self->{device} ap $self->{ap}")
!     if defined $self->{ap};
! 
!   $self->do_command("Setting up nick...\n",
!                     "$self->{iwconfig} $self->{device} nick $self->{nick}")
!     if defined $self->{nick};
! 
!   $self->do_command("Setting up rate...\n",
!                     "$self->{iwconfig} $self->{device} rate $self->{rate}")
!     if defined $self->{rate};
! 
!   $self->do_command("Setting up rts...\n",
!                     "$self->{iwconfig} $self->{device} rts $self->{rts}")
!     if defined $self->{rts};
! 
!   $self->do_command("Setting up frag...\n",
!                     "$self->{iwconfig} $self->{device} frag $self->{frag}")
!     if defined $self->{frag};
! 
!   $self->do_command("Setting up txpower...\n",
!                     "$self->{iwconfig} $self->{device} txpower $self->{txpower}")
!     if defined $self->{txpower};
! 
!   $self->do_command("Setting up key...\n",
                      "$self->{iwconfig} $self->{device} key $self->{key}")
      if defined $self->{key};
+ 
+   $self->do_command("Setting up power...\n",
+                     "$self->{iwconfig} $self->{device} power $self->{power}")
+     if defined $self->{power};
+ 
+   $self->do_command("Setting up retry...\n",
+                     "$self->{iwconfig} $self->{device} retry $self->{retry}")
+     if defined $self->{retry};
  }
  
  sub configure_device {
