Changeset 1071

Show
Ignore:
Timestamp:
03/27/07 08:50:23 (2 years ago)
Author:
tushar
Message:

Updated hint: wpa-service

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ATTACHMENTS/wpa-service/wpa-service-iface

    r1063 r1071  
    11ONBOOT="yes" 
    2 SERVICE="wpa-service2
     2SERVICE="wpa-service
    33VERBOSE="NO" 
    44        . /etc/sysconfig/wpa_supplicant/wpa_service.conf 
    55 
    6 IP_FUNCTION="if_plugd" 
    76# Here you have to define which wpa driver wpa_supplicant will use for 
    87#this interface 
    98        WPA_DRIVER="madwifi" 
    10  
    11 # To avoid boot freezing with this service 
    12 # one cycle each 5 seconds 
    13         WPA_MAX_WAIT=10 
    14 # or fork anyway in the background: 
    15         FORK_SERVICE="yes" 
  • trunk/ATTACHMENTS/wpa-service/wpa_actions-script

    r1063 r1071  
    33IFACE=$1 
    44EVENT=$2 
     5 
     6. /etc/sysconfig/wpa_supplicant/wpa_service.conf 
    57 
    68NETWORKDIR=/etc/sysconfig/wpa_supplicant 
     
    911. /etc/sysconfig/rc 
    1012. $rc_functions 
    11 #. $IFCONFIG 
     13. $IFCONFIG 
    1214 
    13 #. /etc/rc.d/init.d/functions 
     15. /etc/rc.d/init.d/functions 
    1416. /etc/sysconfig/network-devices/ifconfig.$IFACE/wpa-service 
     17 
    1518 
    1619function verbose { 
     
    2831} 
    2932 
    30 function ctrl_iface { 
    31         verbose -n "$WPA_CLIENT_NAME -i$IFACE $@ :" 
    32         RET=`$WPA_CLIENT_NAME -i$IFACE $@` &> /dev/null 
    33         test_fail $? 
     33function get_ssid { 
     34        RET=`$WPA_CLIENT_NAME -i$IFACE status | grep ^ssid= | cut -f2- -d=` &> /dev/null 
    3435} 
    3536 
    3637if [ "$EVENT" == "CONNECTED" ]; then 
    37         ctrl_iface status 
    38         test_fail $? 
    39         SSID=`echo $RET | grep ^ssid= | cut -f2- -d=` 
     38        get_ssid 
     39        SSID=$RET 
     40        verbose '' "SSID is $SSID" 
    4041        # configure network, signal DHCP client, etc. 
    4142        # If special networks definition exist, use it 
     
    5657if [ "$EVENT" == "DISCONNECTED" ]; then 
    5758    # remove network configuration, if needed 
    58         ctrl_iface status 
    59         test_fail $? 
    60         SSID=`echo $RET | grep ^ssid= | cut -f2- -d=` 
     59        get_ssid 
     60        SSID=$RET 
    6161        # configure network, signal DHCP client, etc. 
    6262        # If special networks definition exist, use it 
     
    6565                $SERVICESDIR/$SERVICE $IFACE down 
    6666        else 
     67                IFCONFIG="$NETWORKDIR/AUTO" 
     68                . $IFCONFIG 
     69                export IFCONFIG 
    6770                $SERVICESDIR/$SERVICE $IFACE down 
    6871        fi 
  • trunk/ATTACHMENTS/wpa-service/wpa_service.conf

    r1063 r1071  
    1717         
    1818        WPA_ACTION_FILE=$WPA_CONFIG_DIR/wpa_actions 
    19         IFPLUGD_WRAPPER=$WPA_CONFIG_DIR/ifplugd_wrapper 
    2019  
    2120 # This is what need wpa_supplicant 
  • trunk/wpa-service.txt

    r1063 r1071  
    11AUTHOR: Eloi Primaux eloi AT bliscat dot org 
    22 
    3 DATE: 2006-10-13 
     3DATE: 2007-02-14 
    44 
    55LICENSE: GNU Free Documentation License Version 2 
    66 
    7 SYNOPSIS: Setting up a wifi interface using wpa_supplicant and LFS IP services 
     7SYNOPSIS: Setting up a wifi interface using wpa_supplicant and LFS IP 
     8services 
    89 
    910DESCRIPTION: 
     
    1112ATTACHMENTS: 
    1213 
    13 http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-service/wpa_service.conf 
    14 http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-service/wpa-rcscript 
    15 http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-service/wpa-service2 
    16 http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-service/wpa-service-iface 
    17 http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-service/wpa_actions-script 
    18 http://www.linuxfromscratch.org/hints/downloads/attachments/wpa-service/ifplugd_wrapper-script 
     14http://www.linuxfromscratch.org/hints/downloads/files/ATTACHMENTS/wpa-service/wpa_service.conf 
     15http://www.linuxfromscratch.org/hints/downloads/files/ATTACHMENTS/wpa-service/wpa-rcscript 
     16http://www.linuxfromscratch.org/hints/downloads/files/ATTACHMENTS/wpa-service/wpa-service 
     17http://www.linuxfromscratch.org/hints/downloads/files/ATTACHMENTS/wpa-service/wpa-service-iface 
     18http://www.linuxfromscratch.org/hints/downloads/files/ATTACHMENTS/wpa-service/wpa_actions-script 
    1919 
    2020 
    2121PREREQUISITES: 
    2222 
    23 - A working LFS-6.1 system or newer with wireless capabilities   
     23- A working LFS-6.1.1 system or newer with wireless capabilities   
    2424- Almost two networks services like ipv4-static/dhcpcd installed 
    25 - wpa_supplicant and wireless drivers 
     25- wpa_supplicant (>=0.5.7) and wireless drivers 
    2626  
    2727HINT: 
     
    32320.a) wpa_supplicant 'The core' 
    3333~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    34 This is NOT an usual step if you omit something here you won't be able to attach 
     34This is NOT an usual step if you omit something here you won't be able 
     35to attach 
    3536your device to any access point 
    3637 
    37 Please use the 0.4.8 version or newer and NOT the 0.4.7, available at: 
     38Please use the 0.5.7 version or newer, available at: 
    3839link: http://hostap.epitest.fi/wpa_supplicant 
    3940 
    40 Again, i strongly recommend you to read its README before doing anything. 
    41 wpa_supplicant may need the source of your drivers then edit the .config file 
    42 as described in the README and set all constants according to your system. 
     41Again, i strongly recommend you to read its README before doing 
     42anything. 
     43wpa_supplicant may need the source of your drivers then edit the .config 
     44file 
     45as described in the README and set all constants according to your 
     46system. 
    4347also when ready install it by executing : 
    4448 
     
    4751make install 
    4852 
    49 0.b) ifplugd a daemon which monitor your interface (optional) 
    50 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    51 This external program is not required but can drastically simplify our life 
    52 because it won't crash wpa_supplicant 
    53 information can be found here 
    54         http://0pointer.de/lennart/projects/ifplugd 
    55 and ifplugd (0.28) can be downloaded from: 
    56         http://0pointer.de/lennart/projects/ifplugd/ifplugd-0.28.tar.gz 
    57  
    58 installation 
    59 As this package is made with the GNU autotools you should run 
    60 ./configure inside the distribution directory for configuring the source tree. 
    61 After that you should run make for compilation 
    62 and make install (as root) for installation of ifplugd. 
    63  
    64 ./configure --prefix=/usr --sysconfdir=/etc 
    65 make 
    66 make install 
    67  
    68 The installation scripts create an init script in ${sysconfdir}/init.d/ifplugd, however no /etc/rc?.d/ links are created for it. 
    69  
    70 ifplugd request two links if you intend to use it out of wpa-service: 
    71  
    72 ln -nsf /etc/sysconfdir/network-devices/{ifup,ifdown} /sbin 
    73  
    74531) This Hints 
    7554~~~~~~~~~~~~~ 
    76 wpa_supplicant is designed to be a "daemon" program that runs in the background 
     55wpa_supplicant is designed to be a "daemon" program that runs in the 
     56background 
    7757and acts as the back-end component controlling the wireless connection. 
    7858wpa_supplicant supports separate front-end programs and a text-based 
    7959front-end (wpa_cli) is included with wpa_supplicant. 
    8060 
    81 1.1) Install Files and Directories 
     611.1) Install Files and Directories (this is only a proposal) 
    8262 
    8363  install -d /etc/sysconfig/wpa_supplicant 
     
    9070  ln -nsf /etc/rc.d/init.d/wpa /etc/rc.d/rc0.d/K85wpa 
    9171 
    92   install -m755 wpa_actions-script /etc/sysconfig/wpa_supplicant/wpa_actions 
    93   install -m755 ifplugd_wrapper-script /etc/sysconfig/wpa_supplicant/ifplugd_wrapper 
    94   install -m755 wpa-service2 /etc/sysconfig/network-devices/services 
     72  install -m755 
     73wpa_actions-script /etc/sysconfig/wpa_supplicant/wpa_actions 
     74  install -m755 
     75ifplugd_wrapper-script /etc/sysconfig/wpa_supplicant/ifplugd_wrapper 
     76  install -m755 wpa-service /etc/sysconfig/network-devices/services 
    9577 
    9678  install -d /etc/sysconfig/network-devices/ifconfig.<IFACE> 
    97   install -m644 wpa-service-iface /etc/sysconfig/network-devices/ifconfig.<IFACE>/wpa-service 
    98  
     79  install -m644 
     80wpa-service-iface /etc/sysconfig/network-devices/ifconfig.<IFACE>/wpa-service 
     81 
     82  were <IFACE> is your interface 
    9983 
    100842) Network Configuration 
    10185~~~~~~~~~~~~~~~~~~~~~~~~ 
    102 2.1) Choosing the network configuration method 
    103 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    10486 
    10587All configurations go in the wpa-service-iface 
    106  
    107 wpa-service 0.2 can be use to only set up one time or continuously manage your 
    108 interface. 
    109  This is done by three functions: 
    110  - wait_for_up     --> a stupid loop waiting for the interface to be ready 
    111  - wait_for_events --> wpa_supplicant internal 'action' function (wpa-cli -a) 
    112  - if_plugd        --> an external daemon 
    113  
    114 This choice is done by setting IP_FUNCTION in the wpa-service-iface file 
    115  
    116 In the case of a static computer, the first function should be used 
    117 wait_for_up: 
    118  (+)the advantages are : less request to the wpa_supplicant daemon 
    119                         only one daemon is running : wpa_supplicant. 
    120  (-)disadvantages      : if network change, you will lost connection 
    121  
    122 wait_for_events: 
    123  (+)the advantages are : dynamic network configuration 
    124                         only one daemon is running : wpa_supplicant. 
    125  (-)disadvantages      : wpa_supplicant crashes under too much pings 
    126                         from wpa_cli , thus you will lost connection 
    127  
    128 if_plugd: 
    129  (+)the advantages are : dynamic network configuration 
    130                         less request to the wpa_supplicant daemon 
    131                         more reliable and can also be use for wired interface  
    132  (-)disadvantages      : require an external daemon 
     88which is located 
     89at /etc/sysconfig/network-device/ifconfig.<IFACE>/wpa-service 
     90 
    13391  
    134 i encourage people to use the wait_for_events function, because errors reports 
    135 will go to wpa_supplicant developers ;) 
    136  
    137 but if you want a more reliable network, use the if_plugd function. 
    138   
    139 2.2) Network configurations with any of the three functions: 
     922.1) Network configurations with any of the three functions: 
    14093~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    14194 
    142 wpa-service can set up your network according to it's SSID, this means that if 
    143 the SSID "DHCP network" manage ip via a dhcp server, wpa-service will use the 
    144 SSID file descriptor to set up you network when connecting to the SSID network. 
    145  
    146  Those ssid descriptors are named with the name of the SSID they describe, 
     95wpa-service can set up your network according to it's SSID, this means 
     96that if 
     97the SSID "DHCP network" manage ip via a dhcp server, wpa-service will 
     98use the 
     99SSID file descriptor to set up you network when connecting to the SSID 
     100network. 
     101 
     102 Those ssid descriptors are named with the name of the SSID they 
     103describe, 
    147104 and took place in the /etc/sysconfig/wpa_supplicant directory. 
    148105  
    149  the "AzErTy" SSID descriptor will be /etc/sysconfig/wpa_supplicant/AzeRtY 
     106 the "AzErTy" SSID descriptor will 
     107be /etc/sysconfig/wpa_supplicant/AzeRtY 
    150108 
    1511092.1) SSID descriptor syntax: 
    152 An SSID descriptor is a regular network configuration file as used in LFS system 
    153 it means that if SSID "IPV4" use ipv4-static, the the descriptor "IPV4" will be 
     110An SSID descriptor is a regular network configuration file as used in 
     111LFS system 
     112it means that if SSID "IPV4" use ipv4-static, the the descriptor "IPV4" 
     113will be 
    154114 
    155115        cat > /etc/sysconfig/wpa_supplicant/IPV4 << "EOF" 
     
    162122        EOF 
    163123 
    164 or if the "DHCP" SSID use dhcp : 
     124and if the "DHCP" SSID use dhcp : 
    165125 
    166126        cat > /etc/sysconfig/wpa_supplicant/DHCP << "EOF" 
     
    168128        SERVICE="dhcpcd" 
    169129        DHCP_START="-o" 
    170         DHCP_STOP="-k -o" 
     130        DHCP_STOP="-k -o" # the '-o' prevent your interface being destroyed by 
     131dhcpcd  
    171132 
    172133        # Set PRINTIP="yes" to have the script print 
     
    179140        EOF 
    180141 
    181 for convenience, wpa_actions fall back to /etc/sysconfig/wpa_supplicant/AUTO 
     142for convenience, wpa_actions fall back 
     143to /etc/sysconfig/wpa_supplicant/AUTO 
    182144when no SSID descriptor is available, 
    183145 
     
    189151        SERVICE="dhcpcd" 
    190152        DHCP_START="-o" 
    191         DHCP_STOP="-k -o" 
     153        DHCP_STOP="-k -o" # the '-o' prevent your interface being destroyed by 
     154dhcpcd 
    192155 
    193156        # Set PRINTIP="yes" to have the script print 
     
    202165 
    203166 
    204  
    205  
    206  
    2071673) The wpa_supplicant.conf (The network keys description)  
    208168~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    210170The wpa_supplicant README and wiki explain the composition of this file. 
    211171 
    212 3.a) File syntax 
    213 ~~~~~~~~~~~~~~~~ 
    214 The file syntax is the wpa_supplicant.conf file syntax, it is specific to the 
    215 wpa_supplicant program and only depend of the programmer choice, thus instead of 
    216 explaining you of how this file is read, i will show you a set of command to 
     172The file syntax is the wpa_supplicant.conf file syntax, it is specific 
     173to the 
     174wpa_supplicant program and only depend of the programmer choice, thus 
     175instead of 
     176explaining you of how this file is read, i will show you a set of 
     177command to 
    217178create a config file with wpa_supplicant. 
    218179 
    219180in a bash shell execute: 
    220181 
    221 wpa_passphrase <ssid> [passphrase] > wpa_supplicant.conf 
    222  
    223 Where <ssid> is the name of the access point and where [pasphrase] is your ... 
     182wpa_passphrase <ssid> [passphrase] >> wpa_supplicant.conf 
     183 
     184Where <ssid> is the name of the access point and where [pasphrase] is 
     185your ... 
    224186pass-phrase. 
    225187 
     
    230192        ssid="ssid" 
    231193        #psk="passphrase" 
    232         psk=2b1d17284c5410ee5eaae7151290e9744af2182b0eb8af20dd4ebb415928f726 
     194 
     195psk=2b1d17284c5410ee5eaae7151290e9744af2182b0eb8af20dd4ebb415928f726 
    233196} 
    234197 
    235 Please quote correctly the strings containing the space characters 
    236  
    237 you will directly see that you can define more than one network in this file, 
     198you will directly see that you can define more than one network in this 
     199file, 
    238200that's why wpa_supplicant is very nice: it chooses automatically in its 
    239 configuration file the best (aka secure and available) network to connect. 
    240  
    241 But at this time your network need to be tuned: 
    242  
    243 open a new console and launch in the foreground wpa_supplicant in debug mode: 
     201configuration file the best (aka secure and available) network to 
     202connect. 
     203 
     2044) Geting over troubles (and tunning your network) 
     205~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     206 
     207open a new console and launch in the foreground wpa_supplicant in debug 
     208mode: 
    244209 
    245210wpa_supplicant -g/var/run/wpa_supplicant-global \ 
     
    248213this will make wpa_supplicant to output anything to us. 
    249214 
    250 Now start the wpa_cli : 
    251  
    252 wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan[X] "" [driver] \ 
     215Now start the wpa_cli in another console: 
     216 
     217wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan[X] 
     218"" [driver] \ 
    253219        /var/run/wpa_supplicant 
    254220 
    255 Where wlan[X] is the device name of your network interface and where [driver] is 
     221Where wlan[X] is the device name of your network interface and where 
     222[driver] is 
    256223the name of your driver 
    257224 
     
    262229        /var/run/wpa_supplicant 
    263230 
    264 if it fail, please have a look to the output of the wpa_supplicant daemon 
     231if it fail, please have a look to the output of the wpa_supplicant 
     232daemon 
    265233 
    266234wpa_cli -iwlan[X] -p/var/run/wpa_supplicant 
     
    318286        group=CCMP 
    319287        #psk="passphrase" 
    320         psk=2b1d17284c5410ee5eaae7151290e9744af2182b0eb8af20dd4ebb415928f726 
     288 
     289psk=2b1d17284c5410ee5eaae7151290e9744af2182b0eb8af20dd4ebb415928f726 
    321290} 
    322291 
     
    336305wpa_supplicant -dmadwifi -iath0 -c./wpa_supplicant.conf -dd 
    337306 
    338 If you see something like SUCCESS it's done, kill it again and copy the config 
     307If you see something like SUCCESS it's done, kill it again and copy the 
     308config 
    339309file to a secure directory: 
    340310 
     
    345315 
    346316 
    347 6) The End 
     3175) The End 
    348318~~~~~~~~~~ 
    349319execute: 
     
    353323/etc/rc.d/init.d/network start 
    354324 
    355 if there is no errors, and your system is connected, then you can safely restart 
     325if there is no errors, and your system is connected, then you can safely 
     326restart 
    356327your computer to see it setting up your wireless card during boot time. 
    357328 
     
    3683392006 03 16 added some words to help wpa-supplicant.conf writing 
    3693402006 03 18 fix wrong paths 
    370 2006 03 31 Rewritten and try to match the LFS-standard thank's to archaic's help 
     3412006 03 31 Rewritten and try to match the LFS-standard thank's to 
     342archaic's help 
    3713432006 04 01 fix incomplete find commands 
    3723442006 10 15 wpa-service 0.2 
    373  
     3452006 02 14 some typo fix in scripts, removed ifplugd support, and 
     346wait_for_up function