Candela Technologies Logo
Network Testing and Emulation Solutions

Changing Station POST_IFUP field with the CLI API

Goal: Programmatically change a station's POST_IFUP field.

Creating a series of scripts using the lf_associate_ap.pl script is not adequate for negotiating a captive-portal environment, that script does not set the POST_IFUP parameter for the station. However, stations can be modified to gain that field.

Creating a station that negotiates a Captive Portal environment requires the POST_IFUP field to name a script. (Usually a portal-bot.pl script.) We can assign that port parameter with the set_wifi_extra2 command. At the time of this writing, there are no perl scripts using this CLI command, but I will show an example here:

set_wifi_extra2,
   1,       # resource number
   sta100,  # port name
   0,       # flush-to-kernel
   NA,      # ignore probe
   NA,      # ignore auth
   NA,      # ignore assoc
   NA,      # ignore_reassoc
   NA,      # corrupt_gtk_rekey_mic
   NA,      # radius_ip
   NA,      # radius_port
   NA,      # freq_24
   NA,      # freq_5

   # post_ifup_script
   './portal-bot.pl --bot bp.pm --user "username" --pass "secret" --start_url "http://www.google.com/"  --ap_url "http://localhost/" --login_form "login.php" --login_action "login.php" --logout_form  "logout.php"',
   NA       # ocsp
   

The above command would never actually be formatted in in the way it appears above. It would all appear on one line without commentds.

In a perl script, the command could be formatted like:

my $cmd = fmt_cmd("set_wifi_extra2", 1,
         "sta100",  # port name
         0,         # flush-to-kernel
         "NA",      # ignore probe
         "NA",      # ignore auth
         "NA",      # ignore assoc
         "NA",      # ignore_reassoc
         "NA",      # corrupt_gtk_rekey_mic
         "NA",      # radius_ip
         "NA",      # radius_port
         "NA",      # freq_24
         "NA",      # freq_5
   qq(./portal-bot.pl --bot bp.pm ) # post_ifup_script
   .qq(--user "username" --pass "secret" )
   .qq(--start_url "http://www.google.com/" )
   .qq(--ap_url "http://localhost/" )
   .qq(--login_form "login.php" )
   .qq(--login_action "login.php" )
   .qq(--logout_form "logout.php"),
         "NA"       # ocsp );
   

Important Notes

  1. the LANforge server treats single-quotes (apostrophes, ') as command delimiters. Use only double-quotes (") to quote the arguments to the script.
  2. Do not use newlines (\n or carriage-returns (\r\n). That will truncate the command and LANforge will process it immedately.
  3. These parameters will be provided by the server:

Candela  Technologies, 2417 Main Street, Suite 201, Ferndale, WA 98248, USA
www.candelatech.com | sales@candelatech.com | +1.360.380.1618
Facebook | LinkedIn | Blog