function fatlady_dhcps($prefix, $svc) { $service = cut($svc, 0, "."); $version = scut($service, 0, "DHCPS"); XNODE_set_var("FATLADY_DHCPS_PATH", $prefix); XNODE_set_var("SERVICE_NAME", $svc); $b = "/htdocs/phplib/fatlady/DHCPS"; if ($version == 4) { dophp("load", $b . "/dhcps4.php"); } else { if ($version == 6) { dophp("load", $b . "/dhcps6.php"); } else { $_GLOBALS["FATLADY_result"] = "FAILED"; $_GLOBALS["FATLADY_node"] = ""; $_GLOBALS["FATLADY_message"] = "Unsupported DHCP service : " . $svc; /* internal error, no i18n(). */ } } XNODE_del_var("FATLADY_DHCPS_PATH"); XNODE_del_var("SERVICE_NAME"); if ($_GLOBALS["FATLADY_result"] == "OK") { set($prefix . "/valid", 1); } }
function INET_ARP($ipaddr) { $file = "/proc/net/arp"; $arplist = fread("", "/proc/net/arp"); if (ipv6checkip($ipaddr) == "1") { $ipaddr_ipv4 = substr($ipaddr, 7, ""); return scut($arplist, 2, $ipaddr_ipv4); } return scut($arplist, 2, $ipaddr); }
function changes_default_wifi($phyinfuid, $ssid, $password, $mac, $country) { $authtype = "WPA+2PSK"; $encrtype = "TKIP+AES"; $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-5GHz-mac" for 5GHz. if (substr($ssid, 0, 5) == "dlink") { $ssid1 = "dlink"; $ssid2 = scut($ssid, 0, "dlink"); $ssid = $ssid1 . $ssid2 . "-" . toupper($ssidsuffix); } } } //set default value for CN if ($country == "CN") { //$ssid = "D-Link_DIR-802"; $authtype = "OPEN"; $encrtype = "NONE"; set("authtype", $authtype); set("encrtype", $encrtype); set("ssid", $ssid); set("nwkey/psk/passphrase", ""); //20130812 jack add for hostapd error set("nwkey/psk/key", ""); return; } //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"); } }
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"); } }
} while ($i < $cnt) { if ($poli == "DISABLE") { break; } $i++; anchor("/acl/urlctrl/entry:" . $i); if (query("enable") != "1") { continue; } $url = query("url"); $sch = query("schedule"); if ($url != "") { $tmpurl = cut($url, 0, "/"); if ($tmpurl == "http:") { $url = scut($url, 0, "http://"); } if ($sch == "") { $timecmd = ""; } else { $timecmd = IPT_build_time_command($sch); } if ($poli == "ACCEPT") { fwrite("a", $START, "iptables -A " . $CHAIN . " " . $timecmd . " -m string --url " . $url . " -j LOG --log-level notice --log-prefix 'DRP:007:' \n"); fwrite("a", $START, "iptables -A " . $CHAIN . " " . $timecmd . " -m string --url " . $url . " -j " . $policy . " \n"); } else { if ($poli == "DROP") { /*add accept rule*/ fwrite("a", $START, "iptables -A " . $CHAIN . " " . $timecmd . " -m string --url " . $url . " -j RETURN \n"); } }
function handle_stateful($inf, $devnam, $opt) { //$stsp = XNODE_getpathbytarget("/runtime", "inf", "uid", $inf, 0); $stsp = XNODE_getpathbytarget("/runtime", "inf", "uid", $inf, 1); //for wizard detection if ($stsp == "" || $devnam == "") { return; } /* Preparing ... */ //$conf = "/proc/sys/net/ipv6/conf/".$devnam; $conf = "/var/run/" . $devnam; $child = query($stsp . "/child/uid"); $childgz = query($stsp . "/childgz/uid"); /* Strip the tailing spaces. */ $DNS = strip($_GLOBALS["DNS"]); $NAMESERVERS = strip($_GLOBALS["NAMESERVERS"]); $DOMAIN = strip($_GLOBALS["DOMAIN"]); $NEW_ADDR = strip($_GLOBALS["NEW_ADDR"]); $NEW_PD_PREFIX = strip($_GLOBALS["NEW_PD_PREFIX"]); $NEW_PD_PLEN = strip($_GLOBALS["NEW_PD_PLEN"]); $NEW_AFTR_NAME = strip($_GLOBALS["NEW_AFTR_NAME"]); $NEW_PD_PLFT = strip($_GLOBALS["NEW_PD_PLTIME"]); $NEW_PD_VLFT = strip($_GLOBALS["NEW_PD_VLTIME"]); if ($DOMAIN != "") { XNODE_set_var($child . "_DOMAIN", $DOMAIN); XNODE_set_var($childgz . "_DOMAIN", $DOMAIN); } XNODE_set_var($child . "_PDPLFT", $NEW_PD_PLFT); XNODE_set_var($child . "_PDVLFT", $NEW_PD_VLFT); XNODE_set_var($childgz . "_PDPLFT", $NEW_PD_PLFT); XNODE_set_var($childgz . "_PDVLFT", $NEW_PD_VLFT); /* Combine the user config and DHCP server setting. */ $dns = $DNS; /* get primary dns and secondary dns */ $pdns = ''; $sdns = ''; $dns_cnt = scut_count($dns, ""); if ($dns_cnt != 0) { $pdns = scut($dns, 0, ""); $sdns = scut($dns, 1, ""); } $nameserver = ''; if ($NAMESERVERS != "") { $i = 0; $cnt = scut_count($NAMESERVERS, ""); while ($i < $cnt) { $val = scut($NAMESERVERS, $i, ""); if ($val == $pdns || $val == $sdns) { msg("Got the same dns server as dns manual setting"); } else { if ($nameserver == "") { $nameserver = $val; } else { $nameserver = $nameserver . " " . $val; } } $i++; } $NAMESERVERS = $nameserver; } $oflag = fread("e", $conf . ".ra_oflag"); //if($oflag=="1") // for M flag = 1, O flag = 0 case //{ if ($NAMESERVERS != "") { if ($dns == "") { $dns = $NAMESERVERS; } else { $dns = $dns . " " . $NAMESERVERS; } } //} /* Get RA info. */ if ($_GLOBALS["MODE"] != "PPPDHCP") { $prefix = fread("e", $conf . ".ra_prefix"); $pfxlen = fread("e", $conf . ".ra_prefix_len"); $router = fread("e", $conf . ".ra_saddr"); //if ($router=="" || $router=="NULL") {msg("no ra_saddr"); return;}/*TR-124 issue 2 */ //if ($prefix=="" || $prefix=="NULL") {msg("no ra_prefix"); return;} //if ($pfxlen==0) {msg("no ra_prefix_len"); return;} } /* Check renew, do nothing if we got the same prefix and prefix len as previous ones */ $ip = query($stsp . "/inet/ipv6/ipaddr"); $pfl = query($stsp . "/inet/ipv6/prefix"); //IOL if already do renew IA-PD if ($ip == "") { $ip = query($stsp . "/oldinet/ipv6/ipaddr"); $pfl = query($stsp . "/oldinet/ipv6/prefix"); } $childip = query($stsp . "/child/ipaddr"); $childpfl = query($stsp . "/child/prefix"); if ($opt == "IA-NA+IA-PD") { if ($NEW_ADDR != "" && $NEW_PD_PREFIX == "" && $NEW_PD_PLEN == "") { $renew = 1; $renewip = 1; msg("STATEFUL - opt: " . $opt . " RENEW IANA..."); } if ($NEW_ADDR == "" && $NEW_PD_PREFIX != "" && $NEW_PD_PLEN != "") { $renew = 1; $renewip = 0; msg("STATEFUL - opt: " . $opt . " RENEW IAPD..."); } } if ($opt == "IA-NA") { if ($NEW_ADDR != "" && $NEW_PD_PREFIX == "" && $NEW_PD_PLEN == "") { $renew = 1; msg("STATEFUL - opt: " . $opt . " RENEW IANA..."); } } if ($opt == "IA-PD") { if ($child != "") { $mac = PHYINF_getphymac($child); $hostid = ipv6eui64($mac); if ($NEW_PD_PLEN < 64) { $slalen = 64 - $NEW_PD_PLEN; $ipaddr = ipv6ip($NEW_PD_PREFIX, $NEW_PD_PLEN, $hostid, 1, $slalen); $cpfxlen = 64; } else { $slalen = 1; $ipaddr = ipv6ip($NEW_PD_PREFIX, $NEW_PD_PLEN, $hostid, 1, 1); $cpfxlen = $NEW_PD_PLEN + 1; } if ($childip == $ipaddr && $childpfl == $NEW_PD_PLEN + 1) { msg("STATEFUL - Renew but do nothing"); return; } msg("PREFIX=" . $NEW_PD_PREFIX . ", PLEN=" . $NEW_PD_PLEN . ", HOSTID=" . $hostid . ", SLA=1, SLALEN=" . $slalen); msg("IPADDR=" . $ipaddr); set($stsp . "/child/ipaddr", $ipaddr); set($stsp . "/child/prefix", $cpfxlen); set($stsp . "/child/pdnetwork", $NEW_PD_PREFIX); set($stsp . "/child/pdprefix", $NEW_PD_PLEN); set($stsp . "/child/pdplft", $NEW_PD_PLFT); set($stsp . "/child/pdvlft", $NEW_PD_VLFT); } if ($childgz != "") { $mac = PHYINF_getphymac($childgz); $hostid = ipv6eui64($mac); if ($NEW_PD_PLEN < 64) { $slalen = 64 - $NEW_PD_PLEN; $ipaddr = ipv6ip($NEW_PD_PREFIX, $NEW_PD_PLEN, $hostid, 0, $slalen); $cpfxlen = 64; } else { $slalen = 1; $ipaddr = ipv6ip($NEW_PD_PREFIX, $NEW_PD_PLEN, $hostid, 2, 1); $cpfxlen = $NEW_PD_PLEN + 1; } if ($childip == $ipaddr && $childpfl == $NEW_PD_PLEN + 1) { msg("STATEFUL - Renew but do nothing"); return; } msg("PREFIX=" . $NEW_PD_PREFIX . ", PLEN=" . $NEW_PD_PLEN . ", HOSTID=" . $hostid . ", SLA=1, SLALEN=" . $slalen); msg("IPADDR=" . $ipaddr); set($stsp . "/childgz/ipaddr", $ipaddr); set($stsp . "/childgz/prefix", $cpfxlen); set($stsp . "/childgz/pdnetwork", $NEW_PD_PREFIX); set($stsp . "/childgz/pdprefix", $NEW_PD_PLEN); set($stsp . "/childgz/pdplft", $NEW_PD_PLFT); set($stsp . "/childgz/pdvlft", $NEW_PD_VLFT); } $ipaddr = ipv6ip($NEW_PD_PREFIX, $NEW_PD_PLEN, 1, 0, 0); $pfxlen = $NEW_PD_PLEN; if ($ip == $ipaddr && $pfl == $NEW_PD_PLEN) { msg("STATEFUL - opt: " . $opt . " Renew but do nothing"); set($stsp . "/inet/ipv6/ipaddr", $ip); set($stsp . "/inet/ipv6/prefix", $pfl); return; } } else { if ($child != "" && strstr($opt, "IA-PD") != "") { $mac = PHYINF_getphymac($child); $hostid = ipv6eui64($mac); if ($NEW_PD_PLEN <= 64) { msg("STATEFUL - Record " . $NEW_PD_PREFIX . "/" . $NEW_PD_PLEN . " to blackhole"); /* handle blackhole issue */ //cmd("ip -6 route add blackhole ".$NEW_PD_PREFIX."/".$NEW_PD_PLEN." dev lo"); //set($stsp."/blackhole/prefix", $NEW_PD_PREFIX); //set($stsp."/blackhole/plen", $NEW_PD_PLEN); $holecnt = query($stsp . "/blackhole/count"); if ($holecnt == "") { $holecnt = 1; set($stsp . "/blackhole/count", $holecnt); set($stsp . "/blackhole/entry:" . $holecnt . "/prefix", $NEW_PD_PREFIX); set($stsp . "/blackhole/entry:" . $holecnt . "/plen", $NEW_PD_PLEN); if ($NEW_PD_PLEN != 64) { cmd("ip -6 route add blackhole " . $NEW_PD_PREFIX . "/" . $NEW_PD_PLEN . " dev lo"); } } $ipaddr = ipv6ip($NEW_PD_PREFIX, $NEW_PD_PLEN, $hostid, 1, 64 - $NEW_PD_PLEN); $cpfxlen = 64; } else { $ipaddr = ipv6ip($NEW_PD_PREFIX, $NEW_PD_PLEN, $hostid, 0, 0); $cpfxlen = $NEW_PD_PLEN; } if ($renew == 1 && $childip == $ipaddr && $childpfl == $cpfxlen) { msg("STATEFUL - opt: " . $opt . " Renew but do nothing"); return; } if ($renew == 1 && $NEW_PD_PREFIX != "" && $NEW_PD_PLEN != "") { //IOL test, add blackhoel to ip6tables table FORWARD if ($NEW_PD_PLEN <= 64) { $OLD_PD_PREFIX = query($stsp . "/blackhole/entry:" . $holecnt . "/prefix"); $OLD_PD_PLEN = query($stsp . "/blackhole/entry:" . $holecnt . "/plen"); } msg("STATEFUL - Renew and record " . $OLD_PD_PREFIX . "/" . $OLD_PD_PLEN . " to oldblackhole"); set($stsp . "/oldblackhole/entry:1/prefix", $OLD_PD_PREFIX); set($stsp . "/oldblackhole/entry:1/plen", $OLD_PD_PLEN); if ($OLD_PD_PREFIX != 64) { cmd("ip -6 route del blackhole " . $OLD_PD_PREFIX . "/" . $OLD_PD_PLEN . " dev lo"); } cmd("ip -6 route add " . $OLD_PD_PREFIX . "/" . $OLD_PD_PLEN . " dev br0"); //renew and get the different prefix //$holecnt = $holecnt + 1; //set($stsp."/blackhole/entry:".$holecnt."/prefix", $NEW_PD_PREFIX); //set($stsp."/blackhole/entry:".$holecnt."/plen", $NEW_PD_PLEN); //set($stsp."/blackhole/count", $holecnt); //cmd("ip -6 route add blackhole ".$NEW_PD_PREFIX."/".$NEW_PD_PLEN." dev lo"); if ($NEW_PD_PLEN <= 64) { msg("STATEFUL - Add new prefix " . $NEW_PD_PREFIX . "/" . $NEW_PD_PLEN . " to blackhole"); $holecnt = $holecnt + 1; set($stsp . "/blackhole/entry:" . $holecnt . "/prefix", $NEW_PD_PREFIX); set($stsp . "/blackhole/entry:" . $holecnt . "/plen", $NEW_PD_PLEN); set($stsp . "/blackhole/count", $holecnt); if ($NEW_PD_PLEN != 64) { cmd("ip -6 route add blackhole " . $NEW_PD_PREFIX . "/" . $NEW_PD_PLEN . " dev lo"); } } } if ($ipaddr != "") { set($stsp . "/child/ipaddr", $ipaddr); set($stsp . "/child/prefix", $cpfxlen); set($stsp . "/child/pdnetwork", $NEW_PD_PREFIX); set($stsp . "/child/pdprefix", $NEW_PD_PLEN); set($stsp . "/child/pdplft", $NEW_PD_PLFT); set($stsp . "/child/pdvlft", $NEW_PD_VLFT); } } if ($childgz != "" && strstr($opt, "IA-PD") != "") { $mac = PHYINF_getphymac($childgz); $hostid = ipv6eui64($mac); if ($NEW_PD_PLEN < 64) { $ipaddr = ipv6ip($NEW_PD_PREFIX, $NEW_PD_PLEN, $hostid, 0, 64 - $NEW_PD_PLEN); $cpfxlen = 64; } else { //If pd length is bigger than 63, don't set to guest zone $ipaddr = ""; $cpfxlen = ""; } if ($ipaddr != "") { set($stsp . "/childgz/ipaddr", $ipaddr); set($stsp . "/childgz/prefix", $cpfxlen); set($stsp . "/childgz/pdnetwork", $NEW_PD_PREFIX); set($stsp . "/childgz/pdprefix", $NEW_PD_PLEN); set($stsp . "/childgz/pdplft", $NEW_PD_PLFT); set($stsp . "/childgz/pdvlft", $NEW_PD_VLFT); } } if (strstr($opt, "IA-NA") == "") { msg("no IA-NA"); return; } if ($renew == 1 && $renewip == 1 && $ip == $NEW_ADDR) { msg("STATEFUL - opt: " . $opt . " Renew but do nothing"); set($stsp . "/inet/ipv6/ipaddr", $ip); set($stsp . "/inet/ipv6/prefix", $pfl); return; } if ($NEW_ADDR == "" && $renewip == 1) { msg("no NEW_ADDR"); return; } $ipaddr = $NEW_ADDR; $pfxlen = 128; } set($stsp . "/inet/ipv6/dhcpopt", $opt); /* DS-Lite info */ $remote = strip($_GLOBALS["NEW_AFTR_NAME"]); if ($remote != "") { set($stsp . "/inet/ipv4/ipv4in6/remote", $remote); } /* domain info */ if ($DOMAIN != "") { set($stsp . "/inet/ipv6/domain", $DOMAIN); } //IOL test, backup if ($ipaddr != "") { set($stsp . "/oldinet/ipv6/ipaddr", $ipaddr); set($stsp . "/oldinet/ipv6/prefix", $pfxlen); } cmd("phpsh /etc/scripts/IPV6.INET.php ACTION=ATTACH" . " INF=" . $_GLOBALS["INF"] . " MODE=" . $_GLOBALS["MODE"] . " DEVNAM=" . $devnam . " IPADDR=" . $ipaddr . " PREFIX=" . $pfxlen . " GATEWAY=" . $router . ' "DNS=' . $dns . '"'); return; }
$value = query($inetp . "/ppp4/dns/entry:" . $i); if ($value != "") { add($stsp . "/inet/ppp4/dns", $value); } } } /* auto dns */ if ($cnt == 0 && isfile("/etc/ppp/resolv.conf." . $PARAM) == 1) { $dnstext = fread("r", "/etc/ppp/resolv.conf." . $PARAM); $cnt = scut_count($dnstext, ""); $i = 0; while ($i < $cnt) { $token = scut($dnstext, $i, ""); if ($token == "nameserver") { $i++; $token = scut($dnstext, $i, ""); add($stsp . "/inet/ppp4/dns", $token); } $i++; } } /* We use PING peer IP to trigger the dailup at 'ondemand' mode. * So we need to update the command to PING the new gateway. */ $dial = XNODE_get_var($PARAM . ".DIALUP"); if ($dial == "") { $dial = query($inetp . "/ppp4/dialup/mode"); } if ($dial == "ondemand") { echo 'event ' . $PARAM . '.PPP.DIALUP add "ping ' . $REMOTE . '"\\n'; //hendry, for on demand, we at least dial once echo 'event ' . $PARAM . '.PPP.DIALUP\\n';
<span class="value"></span> </div> <?php // Here, we don't check the data in the file, // and trust the data is well structured as domain names immediately followed with it status. if (isfile("/var/run/all_ddns_domain_name") == 1) { $dnstext = fread("r", "/var/run/all_ddns_domain_name"); //echo $dnstext.'<br>'; $cnt = scut_count($dnstext, ""); $no = 0; $i = 0; while ($i < $cnt) { $domain_name = scut($dnstext, $i, ""); $i++; $status = scut($dnstext, $i, ""); $i++; $color = "red"; $symbol = ": "; if ($status == "ON") { $color = "green"; $symbol = ": "; } echo '<div class="textinput" style="height: 14px; margin-top: 0px;">\\n'; echo '\\t<span class="name"></span>\\n'; echo '\\t<span class="delimiter"></span>\\n'; echo '\\t<span class="value"><span style="color: ' . $color . ';">' . $status . '</span>' . $symbol . $domain_name . '</span>\\n'; echo '</div>\\n'; } } ?>