示例#1
0
function init_update_status_for_station($PHY_UID)
{
    if (get_phyinf_freq($PHY_UID) == 5) {
        $upwifistats_pidfile = "/var/run/upwifistats5g.pid";
        $helper_script = "/etc/scripts/upwifistatshlper_A_band.sh";
    } else {
        $upwifistats_pidfile = "/var/run/upwifistats24g.pid";
        $helper_script = "/etc/scripts/upwifistatshlper_G_band.sh";
    }
    $pid = fread("", $upwifistats_pidfile);
    if ($pid != "") {
        echo "kill " . $pid . "\n";
    }
    $upwifi_attr0 = "updatewifistats -s " . $helper_script . " -m bcm -i " . devname($PHY_UID) . " ";
    $upwifi_attr1 = "-x ";
    //for upwifistats argument (-x --> /phyinf:#)
    $upwifi_attr2 = "-r ";
    //for upwifistats argument (-r --> /runtime/phyinf:#)
    $p = XNODE_getpathbytarget("", "phyinf", "uid", $PHY_UID, 0);
    if ($p == "") {
        return;
    }
    $r = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $PHY_UID, 0);
    if ($r == "") {
        return;
    }
    $upwifi_attr1 = $upwifi_attr1 . $p . " ";
    $upwifi_attr2 = $upwifi_attr2 . $r . " ";
    $cmd = $upwifi_attr0 . $upwifi_attr1 . $upwifi_attr2 . " &";
    TRACE_error($cmd);
    echo $cmd . "\n";
    echo "echo \$! > " . $upwifistats_pidfile . "\n";
}
示例#2
0
function dhcps_setcfg($prefix, $svc)
{
    /* set dhcpX of inf */
    $inf = cut($svc, 1, ".");
    $svc = tolower(cut($svc, 0, "."));
    $base = XNODE_getpathbytarget("", "inf", "uid", $inf, 0);
    $dhcps_uid = query($prefix . "/inf/" . $svc);
    set($base . "/" . $svc, $dhcps_uid);
    /* copy the dhcp profile. */
    $uid = INF_getinfinfo($inf, $svc);
    $spath = XNODE_getpathbytarget($prefix . "/" . $svc, "entry", "uid", $dhcps_uid, 0);
    $dhcps = XNODE_getpathbytarget("/" . $svc, "entry", "uid", $uid, 0);
    if ($dhcps != "") {
        if ($svc == "dhcps4") {
            copy_dhcps4($spath, $dhcps);
        } else {
            if ($svc == "dhcps6") {
                $_GLOBALS["SETCFG_DHCPS6_SRC_PATH"] = $spath;
                $_GLOBALS["SETCFG_DHCPS6_DST_PATH"] = $dhcps;
                $b = "/htdocs/phplib/setcfg/libs";
                dophp("load", $b . "/dhcps6.php");
            }
        }
    } else {
        TRACE_error("SETCFG/DHCPS: no dhcps entry for [" . $uid . "] found!");
    }
}
示例#3
0
function phyinf_setcfg($prefix)
{
    $phy = query($prefix . "/inf/phyinf");
    $phytmp = XNODE_getpathbytarget($prefix, "phyinf", "uid", $phy, 0);
    $phyinf = XNODE_getpathbytarget("", "phyinf", "uid", $phy, 0);
    if ($phy == "" || $phytmp == "" || $phyinf == "") {
        TRACE_error("SETCFG/PHYINF: no phyinf entry for [" . $phy . "] found !");
        return;
    }
    /* We only valid 'macaddr' & 'media' in 'fatlady',
     * so only save these 2 nodes. */
    $macaddr = query($phytmp . "/macaddr");
    set($phyinf . "/macaddr", $macaddr);
    $type = query($phytmp . "/type");
    if ($type == "eth") {
        $media = query($phytmp . "/media/linktype");
        set($phyinf . "/media/linktype", $media);
    }
}
示例#4
0
function WIFI_issupport11n($phy_uid)
{
    $p = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $phy_uid);
    if ($p == "") {
        TRACE_error("phplib/WIFI.php - WIFI_issupport11n(): no phyinf (" . $phy_uid . ")!");
        return 0;
    }
    $parent = query($p . "/media/parent");
    if ($parent != "") {
        $p = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $parent);
    }
    if ($p == "") {
        TRACE_error("phplib/WIFI.php - WIFI_issupport11n(): no phyinf (" . $parent . ")!");
        return 0;
    }
    $b = query($p . "/media/band");
    TRACE_error("MEDIA BAND:" . $b . "");
    if (strchr($b, "N") != "") {
        return 1;
    } else {
        return 0;
    }
}
示例#5
0
function changes_default_wifi($phyinfuid, $ssid, $password, $mac)
{
    $p = XNODE_getpathbytarget("", "phyinf", "uid", $phyinfuid, 0);
    $wifi = XNODE_getpathbytarget("/wifi", "entry", "uid", query($p . "/wifi"), 0);
    if ($p == "" || $wifi == "") {
        return;
    }
    anchor($wifi);
    if ($ssid == "") {
        $n5 = cut($mac, 4, ":");
        $n6 = cut($mac, 5, ":");
        $ssidsuffix = $n5 . $n6;
        $ssid = query("ssid");
        if ($ssidsuffix != "") {
            //For dlink product, make the default SSID "dlink-mac" for 2.4GHz and "dlink-mac-media" for 5GHz.
            if (substr($ssid, 0, 5) == "dlink") {
                $ssid1 = "dlink";
                $ssid2 = scut($ssid, 0, "dlink");
                $ssid = $ssid1 . "-" . toupper($ssidsuffix) . $ssid2;
            }
        }
    }
    //TRACE_error("ssid=".$ssid."=password="******"");
    if ($password != "" && $ssid != "") {
        //chanhe the mode to wpa-auto psk
        set("authtype", "WPA+2PSK");
        set("encrtype", "TKIP+AES");
        set("wps/configured", "1");
        set("ssid", $ssid);
        set("nwkey/psk/passphrase", "1");
        set("nwkey/psk/key", $password);
        set("nwkey/wpa/groupintv", "3600");
        set("nwkey/rekey/gtk", "1800");
    } else {
        TRACE_error("the mfc do not init wifi password,using default");
    }
}
示例#6
0
function phyinf_setmedia($layout, $ifname, $media)
{
    /* Only support for WAN port now. */
    $wanindex = query("/device/router/wanindex");
    if ($wanindex == "") {
        TRACE_error("you do not assigned /device/router/wanindex using default 0\n");
        $wanindex = 0;
    }
    if ($layout == "1W1L" && $ifname == "ETH-2") {
        $port = $wanindex;
    } else {
        if ($layout == "1W2L" && $ifname == "ETH-3") {
            $port = $wanindex;
        } else {
            return;
        }
    }
    if ($media == "") {
        $media = "AUTO";
    }
    startcmd("slinktype -i " . $port . " -d " . $media);
    stopcmd("slinktype -i " . $port . " -d AUTO");
    startcmd("sleep 1");
}
示例#7
0
    echo "kill " . $pid . "\n";
}
$upwifi_attr0 = "updatewifistats -s " . $helper_script . "  -m RT2800 -i " . devname($prefix) . " ";
$upwifi_attr1 = "-x ";
//for upwifistats argument (-x --> /phyinf:#)
$upwifi_attr2 = "-r ";
//for upwifistats argument (-r --> /runtime/phyinf:#)
$found = 0;
/* for each interface. */
$i = 1;
while ($i > 0) {
    $uid = $prefix . "-1." . $i;
    $p = XNODE_getpathbytarget("", "phyinf", "uid", $uid, 0);
    if ($p == "") {
        $i = 0;
        break;
    }
    $r = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $uid, 0);
    if ($r != "") {
        $upwifi_attr1 = $upwifi_attr1 . $p . " ";
        $upwifi_attr2 = $upwifi_attr2 . $r . " ";
        $found = 1;
    }
    $i++;
}
if ($found == 1) {
    $cmd = $upwifi_attr0 . $upwifi_attr1 . $upwifi_attr2 . " &";
    TRACE_error($cmd);
    echo $cmd . "\n";
    echo "echo \$! > " . $upwifistats_pidfile . "\n";
}
示例#8
0
include "/htdocs/phplib/xnode.php";
include "/htdocs/phplib/trace.php";
/* I save the channel list into /runtime/freqrule/channellist/a & runtime/freqrule/channellist/g */
$path_a = "/runtime/freqrule/channellist/a";
$path_g = "/runtime/freqrule/channellist/g";
$c = query("/runtime/devdata/countrycode");
$fcc = query("/runtime/device/fcc");
/*marco*/
$ce = query("/runtime/device/ce");
/*marco*/
if ($c == "") {
    TRACE_error("phplib/getchlist.php - GETCHLIST() ERROR: no Country Code!!! Please check if you board is initialized.");
    return;
}
if (isdigit($c) == 1) {
    TRACE_error("phplib/getchlist.php - GETCHLIST() ERROR: Country Code (" . $c . ") is not in ISO Name!! Please use ISO name insteads of Country Number.");
    return;
}
/* never set the channel list, so do it.*/
if (query($path_a) == "" || query($path_g) == "") {
    /* map the region by country ISO name */
    if ($c == "AU") {
        $list_g = "1,2,3,4,5,6,7,8,9,10,11,12,13";
        $list_a = "36,40,44,48";
        if ($fcc == "1") {
            $list_a = $list_a . ",52,56,60,64,100,104,108,112,116,132,136,140";
        }
        $list_a = $list_a . ",149,153,157,161,165";
    } else {
        if ($c == "CA") {
            $list_g = "1,2,3,4,5,6,7,8,9,10,11";
示例#9
0
function changes_default_tz($country)
{
    if ($country != "") {
        TRACE_debug("changes_default_tz(): country=" . $country);
        if ($country == "AU") {
            set("/device/time/timezone", "67");
        } else {
            if ($country == "CA") {
                set("/device/time/timezone", "14");
            } else {
                if ($country == "CN") {
                    set("/device/time/timezone", "57");
                } else {
                    if ($country == "SG") {
                        set("/device/time/timezone", "58");
                    } else {
                        if ($country == "TW") {
                            set("/device/time/timezone", "60");
                        } else {
                            if ($country == "US" || $country == "NA") {
                                set("/device/time/timezone", "14");
                            } else {
                                if ($country == "LA") {
                                    set("/device/time/timezone", "11");
                                } else {
                                    if ($country == "EU" || $country == "GB") {
                                        set("/device/time/timezone", "28");
                                    } else {
                                        if ($country == "IL") {
                                            set("/device/time/timezone", "38");
                                        } else {
                                            if ($country == "KR") {
                                                set("/device/time/timezone", "64");
                                            } else {
                                                if ($country == "JP") {
                                                    set("/device/time/timezone", "63");
                                                } else {
                                                    if ($country == "EG") {
                                                        set("/device/time/timezone", "35");
                                                    } else {
                                                        if ($country == "BR") {
                                                            set("/device/time/timezone", "20");
                                                        } else {
                                                            if ($country == "RU") {
                                                                set("/device/time/timezone", "45");
                                                            } else {
                                                                if ($country == "DI") {
                                                                    set("/device/time/timezone", "11");
                                                                } else {
                                                                    TRACE_error("changes_default_tz(): Error unknow country code.");
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
示例#10
0
文件: ACL.php 项目: jhbsz/DIR-850L_A1
<?php

include "/htdocs/phplib/trace.php";
/* setcfg is used to move the validated session data to the configuration database.
 * The variable, 'SETCFG_prefix',  will indicate the path of the session data. */
set("/acl/anti_spoof/enable", query($SETCFG_prefix . "/acl/anti_spoof/enable"));
set("/acl/dos/enable", query($SETCFG_prefix . "/acl/dos/enable"));
set("/acl/spi/enable", query($SETCFG_prefix . "/acl/spi/enable"));
set("/acl/applications/qq/action", query($SETCFG_prefix . "/acl/applications/qq/action"));
set("/acl/applications/msn/action", query($SETCFG_prefix . "/acl/applications/msn/action"));
set("/acl/applications/kaixin/action", query($SETCFG_prefix . "/acl/applications/kaixin/action"));
set("/device/passthrough/pptp", query($SETCFG_prefix . "/acl/alg/pptp"));
set("/device/passthrough/rtsp", query($SETCFG_prefix . "/acl/alg/rtsp"));
set("/device/passthrough/sip", query($SETCFG_prefix . "/acl/alg/sip"));
set("/device/passthrough/ipsec", query($SETCFG_prefix . "/acl/alg/ipsec"));
TRACE_error("==================================");
$test = query($SETCFG_prefix . "/acl/cone/udp_cone");
TRACE_error($test);
set("/acl/cone/udp_cone", query($SETCFG_prefix . "/acl/cone/udp_cone"));
set("/acl/cone/tcp_cone", query($SETCFG_prefix . "/acl/cone/tcp_cone"));
示例#11
0
}
TRACE_debug("SendMailFlag=" . $SendMailFlag);
$enable = query("/device/log/email/enable");
if ($enable == "1" && $SendMailFlag == 1) {
    $from = query("/device/log/email/from");
    $email_addr = query("/device/log/email/to");
    $mail_subject = get(s, "/device/log/email/subject");
    $mail_server = query("/device/log/email/smtp/server");
    $mail_port = query("/device/log/email/smtp/port");
    if ($mail_port == "") {
        $mail_port = "25";
    }
    $authenable = query("/device/log/email/authenable");
    $username = query("/device/log/email/smtp/user");
    $password = query("/device/log/email/smtp/password");
    fwrite("w", "/var/log/subject", $mail_subject);
    if ($from == "" || $email_addr == "" || $mail_server == "") {
        TRACE_error("sendmail: invalid args!!! from=[" . $from . "], to=[" . $email_addr . "], smtp server=[" . $mail_server . "]\n");
        return;
    }
    if ($mail_subject == "") {
        $mail_subject = "RG log";
    }
    echo 'logger -p 192.1 "Sending the Log to ' . $email_addr . '"\\n';
    /* static options */
    if ($authenable != "0") {
        echo 'sendmail' . ' -s "' . $mail_subject . '"' . ' -S ' . $mail_server . ' -P ' . $mail_port . ' -a ' . $from . ' -t ' . $email_addr . ' -u ' . $username . ' -p ' . $password . ' -f ' . $logfile . ' &\\n';
    } else {
        echo 'sendmail' . ' -s "' . $mail_subject . '"' . ' -S ' . $mail_server . ' -P ' . $mail_port . ' -a ' . $from . ' -t ' . $email_addr . ' -f ' . $logfile . ' &\\n';
    }
}
示例#12
0
<?php

include "/htdocs/phplib/trace.php";
include "/htdocs/phplib/xnode.php";
include "/htdocs/phplib/phyinf.php";
include "/etc/services/WIFI/function.php";
/********************************************************************/
if (isfile("/usr/sbin/updatewifistats") != 1) {
    TRACE_error("/usr/sbin/updatewifistats doesn't exist \n");
    return;
}
if ($PHY_UID == "") {
    $PHY_UID = "BAND24G-1.1";
}
$prefix = cut($PHY_UID, 0, "-");
if ($prefix == "BAND24G") {
    $upwifistats_pidfile = "/var/run/upwifistats24g.pid";
    $helper_script = "/etc/scripts/upwifistatshlper_G_band.sh";
} else {
    $upwifistats_pidfile = "/var/run/upwifistats5g.pid";
    $helper_script = "/etc/scripts/upwifistatshlper_A_band.sh";
}
$dev = devname($PHY_UID);
/* restart upwifistats 
 * 1. kill previous pid
 * 2. get the prefix, restart the upwifistats
*/
$pid = fread("", $upwifistats_pidfile);
if ($pid != "") {
    echo "kill " . $pid . "\n";
}
示例#13
0
    /*echo "nvram set ".$pci_5g_path."regrev=".$regrev."\n";
    	echo "nvram set ".$pci_5g_path."ccode=".$ctry_code."\n";*/
    startcmd("nvram set " . $pci_path . "regrev=0");
    startcmd("nvram set " . $pci_path . "ccode=0");
    startcmd("nvram set wl" . $wlif_bss_idx . "_country_code=" . $ctry_code);
    startcmd("nvram set wl" . $wlif_bss_idx . "_country_rev=" . $regrev);
    /* alpha create nvram parameter: it's value include country code and regulatory revision */
    startcmd("nvram set wl" . $wlif_bss_idx . "_alpha_country_code=" . $ctry_code . "/" . $regrev);
}
$ccode = query("/runtime/devdata/countrycode");
if (isdigit($ccode) == 1) {
    TRACE_error("\n\nError\nWe do not support digital country,assign as US\n\n");
    $ccode = "US";
}
if ($ccode == "") {
    TRACE_error("\n\nError\nempty country,assign as US\n\n");
    $ccode = "US";
}
$pci_2g_path = "pci/2/1/";
$pci_5g_path = "pci/1/1/";
/*wl0 is 5G*/
nvram_country_setup(0, $ccode, $pci_5g_path);
/*wl1 is 2.4G*/
nvram_country_setup(1, $ccode, $pci_2g_path);
/*for ap client we need set country to dirver this moment. 
  the site survey will run without wlconfig ifname up
  the driver will using default channel (1~11).
  we set the country here via wl command.
*/
startcmd("wl -i " . $BAND24G_DEVNAME . " country " . $ccode);
startcmd("wl -i " . $BAND5G_DEVNAME . " country " . $ccode);
示例#14
0
<?php

include "/htdocs/phplib/xnode.php";
include "/htdocs/phplib/trace.php";
$stsp = "/runtime/wifi_tmpnode/sitesurvey/entry:" . $INDEX;
if ($ACTION == "ADD_ENTRY" || $ACTION == "ADD_ENTRY_HIDDENSSID") {
    set($stsp . "/channel", $CHANNEL);
    set($stsp . "/ssid", $SSID);
    set($stsp . "/macaddr", $BSSID);
    set($stsp . "/rssi", $SIGNAL);
    set($stsp . "/wlmode", $WLMODE);
    set($stsp . "/authtype", $AUTHTYPE);
    set($stsp . "/encrtype", $ENCRTYPE);
} else {
    if ($ACTION == "CLEAN") {
        del("/runtime/wifi_tmpnode/sitesurvey");
    } else {
        TRACE_error("sitesurvey.php :  UNKNOWN COMMAND !!");
    }
}