function mk_neapscfg($name, $neaps_conf) { /* the interface status <runtime><inf> */ $stsp = XNODE_getpathbytarget("/runtime", "inf", "uid", $name, 0); $addrtype = query($stsp . "/inet/addrtype"); if ($addrtype == "ipv4") { $ipaddr = query($stsp . "/inet/ipv4/ipaddr"); } else { $ipaddr = query($stsp . "/inet/ppp4/local"); } $mask = query($stsp . "/inet/ipv4/mask"); $netmask = ipv4int2mask($mask); $phyinf = query($stsp . "/phyinf"); /* the interface status <runtime><phyinf> */ $rphyinf = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $phyinf, 0); $rmacaddr = query($rphyinf . "/macaddr"); $rname = query($rphyinf . "/name"); /* Get other info*/ $vender = "D-Link"; $model = query("/runtime/device/modelname"); $description = $vender . " " . $model . " Wireless Broadband Router"; $version = "v0.5.0"; fwrite("w", $neaps_conf, 'ipaddr=' . $ipaddr . '\\n' . 'netmask=' . $netmask . '\\n' . 'macaddr=' . $rmacaddr . '\\n' . 'vender=' . $vender . '\\n' . 'description=' . $description . '\\n' . 'model=' . $model . '\\n' . 'version=' . $version . '\\n'); return $rname; }
<?php /* extern parameters: $ACTION, $ENDCODE, $VALUE */ include "/htdocs/neap/NEAP_LIB.php"; include "/htdocs/webinc/config.php"; $set_value = $VALUE; $get_value = ""; $uid = $LAN1; $inet = INET_getpathbyinf($uid); $ipv4 = $inet . "/ipv4"; if ($ENDCODE == "1") { $path = $ipv4 . "/ipaddr"; $get_value = query($path); } else { if ($ENDCODE == "2") { $path = $ipv4 . "/mask"; $mask = query($path); $get_value = ipv4int2mask($mask); $set_value = ipv4mask2int($set_value); } } NEAP_action($ACTION, $path, $get_value, $set_value);
function pptp_l2tp_func($waninf, $wan2inf, $over, $ACTION, $ENDCODE, $VALUE) { $path = ""; $get_value = ""; $set_value = $VALUE; $uid = $wan2inf; $inetp = INET_getpathbyinf($uid); $addrtype_path = $inetp . "/ipv4"; $infp = XNODE_getpathbytarget("", "inf", "uid", $waninf, "0"); set($infp . "/lowerlayer", "WAN-2"); $infp = XNODE_getpathbytarget("", "inf", "uid", $wan2inf, "0"); set($infp . "/active", 1); set($infp . "/upperlayer", "WAN-1"); set($infp . "/defaultroute", ""); if ($over == "pptp") { set($infp . "/nat", ""); } if ($ENDCODE == "1") { $node = "/static"; $path = $addrtype_path . $node; $static = query($path); $get_value = pptp_static_get($static); $set_value = pptp_static_set($set_values); } else { if ($ENDCODE == "2") { $node = "/ipaddr"; $path = $addrtype_path . $node; $get_value = query($path); } else { if ($ENDCODE == "3") { $node = "/mask"; $path = $addrtype_path . $node; $mask = query($path); if ($mask != "") { $get_value = ipv4int2mask($mask); } $set_value = ipv4mask2int($set_value); } else { if ($ENDCODE == "4") { $node = "/gateway"; $path = $addrtype_path . $node; $get_value = query($path); } else { if ($ENDCODE == "5") { $uid = $waninf; $inetp = INET_getpathbyinf($uid); $path = $inetp . "/ppp4/" . $over . "/server"; $get_value = query($path); } } } } } NEAP_action($ACTION, $path, $get_value, $set_value); }
echo "\\<\\?xml version='1.0' encoding='utf-8'\\?\\>"; include "/htdocs/phplib/xnode.php"; include "/htdocs/webinc/config.php"; $path_inf_lan1 = XNODE_getpathbytarget("", "inf", "uid", $LAN1, 0); $path_run_inf_lan1 = XNODE_getpathbytarget("/runtime", "inf", "uid", $LAN1, 0); $mask = query($path_run_inf_lan1 . "/inet/ipv4/mask"); $dhcp_enbled = "false"; if (query($path_inf_lan1 . "/dhcps4") != "") { $dhcp_enbled = "true"; } ?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetRouterLanSettingsResponse xmlns="http://purenetworks.com/HNAP1/"> <GetRouterLanSettingsResult>OK</GetRouterLanSettingsResult> <RouterIPAddress><?php echo query($path_run_inf_lan1 . "/inet/ipv4/ipaddr"); ?> </RouterIPAddress> <RouterSubnetMask><?php echo ipv4int2mask($mask); ?> </RouterSubnetMask> <DHCPServerEnabled><?php echo $dhcp_enbled; ?> </DHCPServerEnabled> </GetRouterLanSettingsResponse> </soap:Body> </soap:Envelope>
$ServiceName = get("x", $path_wan1_inet . "/ppp4/pptp/server"); if (query($path_wan1_phyinf . "/macaddr") != "") { $mac = query($path_wan1_phyinf . "/macaddr"); } if (query($path_wan1_inet . "/ppp4/dialup/mode") == "auto") { $AutoReconnect = "true"; } $MTU = query($path_wan1_inet . "/ppp4/mtu"); } else { if ($mode == "ppp4" && query($path_wan1_inet . "/ppp4/over") == "l2tp") { anchor($path_wan2_inet . "/ipv4"); if (query("static") == 1) { $Type = "StaticL2TP"; $ipaddr = query("ipaddr"); $gateway = query("gateway"); $mask = ipv4int2mask(query("mask")); $dns1 = query("dns/entry"); $dns2 = query("dns/entry:2"); } else { $Type = "DynamicL2TP"; } $Username = get("x", $path_wan1_inet . "/ppp4/username"); $Password = get("x", $path_wan1_inet . "/ppp4/password"); $MaxIdletime = query($path_wan1_inet . "/ppp4/dialup/idletimeout"); $ServiceName = get("x", $path_wan1_inet . "/ppp4/l2tp/server"); if (query($path_wan1_phyinf . "/macaddr") != "") { $mac = query($path_wan1_phyinf . "/macaddr"); } if (query($path_wan1_inet . "/ppp4/dialup/mode") == "auto") { $AutoReconnect = "true"; }