function ospf_interface($iname, $netid, $maskbits, $ospf_name, $ospf_zone, $ospf_id, $disabled) { _outln('/ routing ospf interface'); _outln(sprintf(':foreach i in [/routing ospf interface find interface=%s] do={/routing ospf interface remove $i;}', $iname)); _outln(sprintf('add interface=%s', $iname)); _outln('/ routing ospf network'); _outln(sprintf(':foreach i in [/routing ospf network find network=%s/%d] do={/routing ospf network remove $i;}', $netid, $maskbits)); _outln(sprintf('add network=%s/%d area=%s disabled=%s', $netid, $maskbits, $ospf_name, $disabled)); }
function unsolclic_airos($dev) { $version = "1.1"; $loc = node_load(array('nid' => $dev->nid)); $zone = node_load(array('nid' => $loc->zone_id)); $wan = guifi_unsolclic_if($dev->id, 'Wan'); list($primary_dns, $secondary_dns) = explode(' ', guifi_get_dns($zone, 2)); $dns[] .= $primary_dns; $dns[] .= $secondary_dns; foreach ($dev->radios[0]['interfaces'] as $interface_id => $interface) { foreach ($interface['ipv4'] as $ipv4_id => $ipv4) { if (isset($ipv4['links'])) { foreach ($ipv4['links'] as $key => $link) { $gateway = $link['interface']['ipv4']['ipv4']; } } } } $apssid = guifi_get_ap_ssid($link['interface']['device_id'], $link['interface']['radiodev_counter']); if (empty($dev->radios[0][antenna_mode])) { $dev->radios[0][antenna_mode] = 'Main'; } if ($dev->radios[0][antenna_mode] == 'Main') { if ($dev->variable['model_id'] == '34') { // NanoStation Loco2. $dev->radios[0][antenna_mode] = '1'; } else { $dev->radios[0][antenna_mode] = '2'; } // Main on NanoStation2, Nanostation5 and Loco5. } else { if ($dev->variable['model_id'] == '34') { // NanoStation Loco2. $dev->radios[0][antenna_mode] = '2'; } else { $dev->radios[0][antenna_mode] = '1'; } // External on NanoStation2, Nanostation5 and Loco5. } $radiorx = $dev->radios[0][antenna_mode]; $radiotx = $dev->radios[0][antenna_mode]; switch ($dev->variable['model_id']) { case "25": //NanoStation2 $net_mode = 'b'; $lnet_mode = 'B Only (2,4Ghz 11MB)'; $rate_max = '11M'; $txpower = '6'; $ack = '45'; $extant = 'disabled'; $mcastrate = '11'; break; case "26": //NanoStation5 $net_mode = 'a'; $lnet_mode = 'A (5Ghz)'; $rate_max = '54M'; $txpower = '6'; $ack = '25'; $extant = 'disabled'; $mcastrate = '54'; break; case "34": //NanoStation Loco2 $net_mode = 'b'; $lnet_mode = 'B Only (2,4Ghz 11MB)'; $rate_max = '11M'; $txpower = '6'; $ack = '44'; $extant = 'enabled'; $mcastrate = '11'; break; case "35": //NanoStation Loco5 $net_mode = 'a'; $lnet_mode = 'A (5Ghz)'; $rate_max = '54M'; $txpower = '6'; $ack = '25'; $extant = 'disabled'; $mcastrate = '54'; } ## Create Script file $File = 'files/nanostation/' . $dev->nick . '.cfg'; $Handle = fopen($File, 'w'); $Data = "aaa.1.status=disabled\naaa.status=disabled\nbridge.1.devname=br0\nbridge.1.fd=1\nbridge.1.port.1.devname=eth0\nbridge.1.port.2.devname=ath0\nbridge.status=disabled\ndhcpc.1.devname=br0\ndhcpc.1.status=disabled\ndhcpc.status=disabled\ndhcpd.1.devname=eth0\ndhcpd.1.end=192.168.1.254\ndhcpd.1.lease_time=3600\ndhcpd.1.netmask=255.255.255.0\ndhcpd.1.start=192.168.1.33\ndhcpd.1.status=enabled\ndhcpd.status=enabled\nebtables.1.cmd=-t nat -A PREROUTING --in-interface ath0 -j arpnat --arpnat-target ACCEPT\nebtables.1.status=enabled\nebtables.2.cmd=-t nat -A POSTROUTING --out-interface ath0 -j arpnat --arpnat-target ACCEPT\nebtables.2.status=enabled\nebtables.3.cmd=-t broute -A BROUTING --protocol 0x888e --in-interface ath0 -j DROP\nebtables.3.status=enabled\nebtables.status=disabled\nhttpd.https.status=enabled\nhttpd.port.http=80\nhttpd.status=enabled\niptables.1.status=enabled\niptables.1.cmd=-t nat -I POSTROUTING -o ath0 -j MASQUERADE\niptables.2.status=disabled\niptables.status=enabled\nnetconf.1.devname=eth0\nnetconf.1.ip=192.168.1.1\nnetconf.1.netmask=255.255.255.0\nnetconf.1.promisc=enabled\nnetconf.1.status=enabled\nnetconf.1.up=enabled\nnetconf.2.allmulti=enabled\nnetconf.2.devname=ath0\nnetconf.2.status=enabled\nnetconf.2.up=enabled\nnetconf.3.devname=br0\nnetconf.3.ip=192.168.1.20\nnetconf.3.netmask=255.255.255.0\nnetconf.3.status=disabled\nnetconf.3.up=enabled\nnetconf.status=enabled\nnetmode=router\nppp.1.password=\nppp.1.status=disabled\nppp.status=disabled\nradio.1.ack.auto=enabled\nradio.1.ackdistance=450\nradio.1.ani.status=enabled\nradio.1.chanshift=0\nradio.1.clksel=0\nradio.1.countrycode=724\nradio.1.devname=ath0\nradio.1.frag=off\nradio.1.mode=managed\nradio.1.rate.auto=enabled\nradio.1.rts=off\nradio.1.tx_antenna_diversity=disabled\nradio.1.rx_antenna_diversity=disabled\nradio.1.status=enabled\nradio.1.thresh62a=28\nradio.1.thresh62b=28\nradio.1.thresh62g=28\nradio.ratemodule=ath_rate_minstrel\nradio.countrycode=724\nradio.status=enabled\nresolv.host.1.status=enabled\nresolv.nameserver.1.status=enabled\nresolv.nameserver.2.status=enabled\nresolv.status=enabled\nroute.1.devname=ath0\nroute.1.ip=0.0.0.0\nroute.1.netmask=0\nroute.1.status=enabled\nroute.status=enabled\nsnmp.community=public\nsnmp.contact=guifi@guifi.net\nsnmp.status=enabled\ntelnetd.status=enabled\nsshd.status=enabled\ntshaper.status=disabled\nusers.1.name=root\nusers.1.password=JjYNUu92yMZd.\nusers.1.status=enabled\nusers.status=enabled\nwireless.1.ap=\nwireless.1.authmode=1\nwireless.1.compression=0\nwireless.1.devname=ath0\nwireless.1.fastframes=0\nwireless.1.frameburst=0\nwireless.1.hide_ssid=disabled\nwireless.1.l2_isolation=enabled\nwireless.1.macclone=disabled\nwireless.1.rssi_led1=1\nwireless.1.rssi_led2=15\nwireless.1.rssi_led3=22\nwireless.1.rssi_led4=30\nwireless.1.security=none\nwireless.1.status=enabled\nwireless.1.wds=disabled\nwireless.1.wmm=disabled\nwireless.1.wmmlevel=-1\nwireless.status=enabled\nwpasupplicant.device.1.status=disabled\nwpasupplicant.status=disabled\nwireless.1.ssid=guifi.net-{$apssid}\nnetconf.2.ip={$wan->ipv4}\nnetconf.2.netmask={$wan->netmask}\nroute.1.gateway={$gateway}\nresolv.nameserver.1.ip={$primary_dns}\nresolv.nameserver.2.ip={$secondary_dns}\nresolv.host.1.name={$dev->nick}\nsnmp.location={$loc->nick}\nradio.1.ieee_mode={$net_mode}\nradio.1.rate.max={$rate_max}\nradio.1.txpower={$txpower}\nradio.1.acktimeout={$ack}\nradio.1.rx_antenna={$radiorx}\nradio.1.tx_antenna={$radiotx}\nradio.1.ext_antenna={$extant}\nradio.1.mcastrate={$mcastrate}\n"; fwrite($Handle, $Data); print '<br/><a href="' . base_path() . 'files/nanostation/' . $dev->nick . '.cfg"> Click here to download configuration file for: ' . $dev->nick . ' </a><br />'; print 'Put the mouse cursor over the link. Right click the link and select "Save Link/Target As..." to save to your Desktop.<br /><br />'; fclose($Handle); if ($radiorx == '2') { if ($dev->variable['model_id'] == '34') { // NanoStation Loco2. $ant = 'Horizontal'; } if ($dev->variable['model_id'] == '35') { // NanoStation Loco5. $ant = 'Vertical'; } if ($dev->variable['model_id'] == '25' || $dev->variable['model_id'] == '26') { // NanoStation2 and NanoStation5. $ant = 'Main/Internal - Vertical'; } } else { if ($dev->variable['model_id'] == '34') { // NanoStation Loco2. $ant = 'Vertical'; } if ($dev->variable['model_id'] == '35') { // NanoStation Loco5. $ant = 'Horizontal'; } if ($dev->variable['model_id'] == '25' || $dev->variable['model_id'] == '26') { // NanoStation2 and NanoStation5. $ant = 'Aux/External - Vertical'; } } _outln_comment('Configuration for AirOs> Unsolclic version:' . $version . ' !! WARNING: Beta version !!'); _outln_comment(' Device: ' . $dev->nick . ''); _outln_comment(); _outln_comment(' Methods to upload/execute the file:'); _outln_comment(' 1.- As a file. Upload this through web management:'); _outln_comment(' a.System->Configuration Management->Locate file'); _outln_comment(' b.Upload'); _outln_comment(' 2.- Telnet: Open a terminal session, create new /tmp/system.cfg file and cut&paste'); _outln_comment(' the contents of the file. Save it an execute the command:'); _outln_comment(); _outln_comment(' /usr/etc/rc.d/rc.softrestart save'); _outln_comment(); _outln_comment(' Notes:'); _outln_comment(' -Web access method is recommended'); _outln_comment(' (the script reconfigures some IP addresses, so communication can be lost.'); _outln_comment(' 192.168.1.1 will be the new one)'); _outln_comment(' -Changes are done in user passwords on the device, default user and password are'); _outln_comment(' changed to root/guifi.'); _outln_comment(' -The ACK is set to 45 for 802.11b mode, and to 25 for 802.11a (600 meters aprox,)'); _outln_comment(); _outln('## Link to AP info'); _outln(' Ap SSID = guifi.net-' . $apssid . '<br /> WAN Ip address = ' . $wan->ipv4 . '<br /> WAN Netmask = ' . $wan->netmask . '<br /> WAN Gateway = ' . $gateway . '<br /> Primary DNS Server = ' . $primary_dns . '<br /> Secondary DNS Server = ' . $secondary_dns . '<br /> Device HostName = ' . $dev->nick . '<br /> IEEE 802.11 Mode: = ' . $lnet_mode . '<br /> Antenna Selection or/and Polarization: = ' . $ant . '<br /> '); }
function unsolclic_guifistationos($dev) { $version = "1.0"; $loc = node_load(array('nid' => $dev->nid)); $zone = node_load(array('nid' => $loc->zone_id)); $wan = guifi_unsolclic_if($dev->id, 'Wan'); list($primary_dns, $secondary_dns) = explode(' ', guifi_get_dns($zone, 2)); $dns[] .= $primary_dns; $dns[] .= $secondary_dns; list($ntp1, $ntp2) = explode(' ', guifi_get_ntp($zone, 2)); $ntp[] .= $ntp1; $ntp[] .= $ntp2; foreach ($dev->radios[0]['interfaces'] as $interface_id => $interface) { foreach ($interface['ipv4'] as $ipv4_id => $ipv4) { if (isset($ipv4['links'])) { foreach ($ipv4['links'] as $key => $link) { $gateway = $link['interface']['ipv4']['ipv4']; } } } } $apssid = guifi_get_ap_ssid($link['interface']['device_id'], $link['interface']['radiodev_counter']); if (empty($dev->radios[0][antenna_mode])) { $dev->radios[0][antenna_mode] = 'Main'; } if ($dev->radios[0][antenna_mode] == 'Main') { $dev->radios[0][antenna_mode] = '1'; } else { $dev->radios[0][antenna_mode] = '2'; } // External on GuifiStation2 and GuifiStation5. $radiorx = $dev->radios[0][antenna_mode]; $radiotx = $dev->radios[0][antenna_mode]; switch ($dev->variable['model_id']) { case "49": // GuifiStation2 $skin = 'skin.active=guifi-station-2'; $net_mode = 'B'; $lnet_mode = 'B Only (2,4Ghz 11MB)'; $rate_max = '11M'; $txpower = '10'; $ack = '45'; $extant = 'disabled'; $mcastrate = '11'; $iface = 'eth0'; $wiface = 'ath0'; $lanip = '192.168.2.66'; $lanmask = '255.255.255.0'; $wanip = $wan->ipv4; $wanmask = $wan->netmask; $iiface = '1'; $specs = 'device.limitband.1.bands.1.band=B device.limitband.1.bands.2.band=G device.limitband.1.bands.3.band=PUREG'; break; case "50": // GuifiStation5 $skin = 'skin.active=guifi-station-5'; $net_mode = 'A'; $lnet_mode = 'A (5Ghz)'; $rate_max = '54M'; $txpower = '10'; $ack = '45'; $extant = 'disabled'; $mcastrate = '54'; $iface = 'ath0'; $wiface = 'eth0'; $lanip = $wan->ipv4; $lanmask = $wan->netmask; $wanip = '192.168.2.66'; $wanmask = '255.255.255.0'; $iiface = '2'; $specs = 'device.limitband.1.bands.1.band=A device.limitband.1.bands.1.status=enabled device.limitband.1.bands.2.band=AST'; break; } ## Create Script file $File = 'files/guifistation/' . $dev->nick . '.cfg'; $Handle = fopen($File, 'w'); $Data = "netconf.status=enabled\nnetconf.1.status=enabled\nnetconf.2.status=enabled\nradio.countrycode=es\nradio.status=enabled\nradio.1.channel=0\nradio.1.devname=ath0\nradio.1.frag=off\nradio.1.mode=managed\nradio.1.parent=wifi0\nradio.1.rate.auto=enabled\nradio.1.rts=off\nradio.1.rx_antenna_diversity=disabled\nradio.1.status=enabled\nradio.1.turbo=disabled\nradio.1.tx_antenna_diversity=disabled\nwireless.status=enabled\nwireless.1.devname=ath0\nwireless.1.fastframes=disabled\nwireless.1.frameburst=disabled\nwireless.1.l2_isolation=disabled\nwireless.1.max_clients=64\nwireless.1.ssid_broadcast=enabled\nwireless.1.status=enabled\nwireless.1.wmm=disabled\nroute.status=enabled\nroute.1.devname=ath0\nroute.1.ip=0.0.0.0\nroute.1.netmask=0\nroute.1.status=enabled\nfirewall.status=enabled\nfirewall.rule.1.chain=POSTROUTING\nfirewall.rule.1.out=ath0\nfirewall.rule.1.status=enabled\nfirewall.rule.1.table=nat\nfirewall.rule.1.target=MASQUERADE\ndhcpd.status=enabled\ndhcpd.1.devname=eth0\ndhcpd.1.dns.1.server=192.168.2.66\ndhcpd.1.end=192.168.2.254\ndhcpd.1.gateway=192.168.2.66\ndhcpd.1.lease_time=600\ndhcpd.1.netmask=255.255.255.0\ndhcpd.1.start=192.168.2.100\ndhcpd.1.status=enabled\nsyslog.file=/var/log/messages\nsyslog.file.msg.level=info\nsyslog.file.umask=077\nsyslog.status=enabled\nsnmpd.contact=guifi@guifi.net\nsnmpd.rocommunity=public\nsnmpd.status=enabled\nresolv.status=enabled\ndate.status=enabled\ndate.timezone=GMT-1\nntpd.status=enabled\nntpd.1.status=enabled\nusers.status=enabled\nusers.1.name=admin\nusers.1.password=84OZbhpCnpRZI\nusers.1.status=enabled\ndevice.mode=router\ndevice.status=enabled\ndiscoveryd.status=enabled\nhttpd.backlog=100\nhttpd.external.status=disabled\nhttpd.max.connections=50\nhttpd.max.request=51200\nhttpd.port.admin=444\nhttpd.port.http=80\nhttpd.port.https=443\nhttpd.status=enabled\nhttpd.verbose=disabled\nsshd.port=22\nsshd.status=enabled\ndnsmasq.status=enabled\ndnsmasq.1.status=enabled\ndnsmasq.1.devname=eth0\ndevice.limitband.status=enabled\ndevice.limitband.1.status=enabled\ndevice.limitband.1.devname=ath0\nwireless.1.ssid=guifi.net-{$apssid}\nnetconf.1.devname={$iface}\nnetconf.1.ip={$lanip}\nnetconf.1.netmask={$lanmask}\nnetconf.2.devname={$wiface}\nnetconf.2.ip={$wanip}\nnetconf.2.netmask={$wanmask}\nroute.1.gateway={$gateway}\nresolv.nameserver.1.ip={$primary_dns}\nresolv.nameserver.2.ip={$secondary_dns}\nsnmpd.name={$dev->nick}\nsnmpd.location={$loc->nick}\nradio.1.ieee_mode={$net_mode}\nradio.1.rate.max={$rate_max}\nradio.1.txpower={$txpower}\nradio.1.acktimeout={$ack}\nradio.1.rx_antenna={$radiorx}\nradio.1.tx_antenna={$radiotx}\nntpd.1.server={$ntp1}\nskin.active={$skin}\nnetconf.{$iiface}.duplex=full\nnetconf.{$iiface}.speed=100\nnetconf.{$iiface}.up=enabled\n{$specs}\n"; fwrite($Handle, $Data); _outln_comment('Unsolclic version: ' . $version); print '<br/><a href="' . base_path() . 'files/guifistation/' . $dev->nick . '.cfg"> Click here to download configuration file for: ' . $dev->nick . ' </a><br />'; print 'Put the mouse cursor over the link. Right click the link and select "Save Link/Target As..." to save to your Desktop.<br /><br />'; fclose($Handle); _outln_comment(' Method to upload/execute the file:'); _outln(' 1. Open your web browser and type the router IP address (Usually 192.168.2.66) and login'); _outln(' 2. Go to System Tab'); _outln(' 3. Press on restore button'); _outln(' 4. Select downloaded file and upload it'); _outln(' 5. When the saved new settings message appears on the screen, click on Reboot button'); _outln(' 6. Wait aproximate 2 minutes, then you can surf the network!'); _outln(); _outln_comment(' Notes:'); _outln(' The script reconfigures IP addresses, so communication can be lost.'); _outln(' -Changes are done in user passwords on the device,'); _outln(' default user and password are changed to admin/guifi.'); _outln(' -The ACK is set to 45 for 802.11b mode, and to 45 for 802.11a (600 meters aprox,)'); _outln(); _outln_comment(' Link to AP info:'); _outln(' Ap SSID = guifi.net-' . $apssid . '<br /> WAN Ip address = ' . $wan->ipv4 . '<br /> WAN Netmask = ' . $wan->netmask . '<br /> WAN Gateway = ' . $gateway . '<br /> Primary DNS Server = ' . $primary_dns . '<br /> Secondary DNS Server = ' . $secondary_dns . '<br /> Device HostName = ' . $dev->nick . '<br /> IEEE 802.11 Mode: = ' . $lnet_mode . '<br /> '); }
function unsolclic_qmp($dev) { $version = "v1.0.3"; // sed 's/<br \/>//g' // echo "<pre>"; // _outln_comment("<pre>"); _outln_comment("<style type=\"text/css\"> x {font-family:courier;} </style> <x>"); _outln_comment("qMp Guifi-oneclick " . $version); _outln_comment(" __ _ /\\/\\ _ __"); _outln_comment(" / _` |/ \\| '_ \\ "); _outln_comment("| (_| / /\\/\\ \\ |_) | "); _outln_comment(" \\__, \\/ \\/ .__/ "); _outln_comment(" |_| |_| "); _outln_comment(" quick MESH project </x> "); _outln_comment(""); _outln_comment("<b>Important:</b> You should have <b>'qmp-guifi'</b> package installed in your node."); _outln_comment(""); _outln_comment("To apply this configuration in your node, you can follow this instructions: "); _outln_comment("<a href='http://dev.qmp.cat/projects/qmp/wiki/Guifi_oneclick' target='_blank'>http://dev.qmp.cat/projects/qmp/wiki/Guifi_oneclick</a> "); _outln_comment(""); // ONLY THE FIRST MESH IP FOUND IS GET // TO DO: Check if there are more than one MESH radios and/or interfaces // $mesh = "no"; $ipv4 = "-"; $netmask = "-"; $devmodel = "-"; foreach ($dev->radios as $radio) { if ($radio['mode'] == 'mesh') { $mesh = "yes"; $ipd = guifi_main_ip($dev->id); if ($ipd != '') { $ipv4 = $ipd['ipv4']; $netmask = $ipd['netmask']; $maskbits = $ipd['maskbits']; } else { $ipv4 = "-"; $netmask = "-"; $maskbits = "-"; } } } // GET ZONE NICK (MAYBE ID?) // $node = node_load(array('nid' => $dev->nid)); $zone = node_load(array('nid' => $node->zone_id)); $zonename = $zone->nick; _outln(); _outln("meshradio='" . $mesh . "'"); if ($mesh == 'yes') { _outln("nodename='" . $node->nick . "'"); // This is the node name _outln("latitude='" . $node->lat . "'"); _outln("longitude='" . $node->lon . "'"); _outln("devname='" . $dev->nick . "'"); // This is the device name with mesh radio _outln("devmodel='" . $dev->model . "'"); _outln("ipv4='" . $ipv4 . "'"); _outln("netmask='" . $netmask . "'"); _outln("zoneid='" . $zonename . "'"); } else { _outln(); _outln_comment(" <b>You don't have any Mesh radio!</b>"); _outln_comment(" If you want to use Guifi-oneclick, make sure you configure it properly."); _outln_comment(" You can follow the instructions in the wiki: <a href='./unsolclic' target='_self'>EN (not yet)</a>, <a href='http://es.wiki.guifi.net/wiki/Mesh#Conectarse_a_una_red_Mesh' target='_blank'>ES</a>, <a href='http://ca.wiki.guifi.net/wiki/Mesh#Connectar-se_a_una_xarxa_Mesh' target='_blank'>CA</a>"); } // var_dump($node->nid['zone_id']); }