Beispiel #1
0
function sshdsetup($name)
{
    /* Get the interface */
    $stsp = XNODE_getpathbytarget("/runtime", "inf", "uid", $name, 0);
    $infp = XNODE_getpathbytarget("", "inf", "uid", $name, 0);
    if ($stsp == "" || $infp == "") {
        SHELL_info($_GLOBALS["START"], "sshdsetup: (" . $name . ") no interface.");
        SHELL_info($_GLOBALS["STOP"], "sshdsetup: (" . $name . ") no interface.");
        return;
    }
    /* Is this interface active ? */
    $active = query($infp . "/active");
    $sshd = query($infp . "/sshd");
    if ($active != "1" || $sshd == "") {
        SHELL_info($_GLOBALS["START"], "sshdsetup: (" . $name . ") not active.");
        SHELL_info($_GLOBALS["STOP"], "sshdsetup: (" . $name . ") not active.");
        return;
    }
    /* Get the profile */
    $sshdpro = XNODE_getpathbytarget("/sshd", "entry", "uid", $sshd, 0);
    if ($sshdpro == "") {
        SHELL_info($_GLOBALS["START"], "sshdsetup: (" . $name . ") no profile.");
        SHELL_info($_GLOBALS["STOP"], "sshdsetup: (" . $name . ") no profile.");
        return;
    }
    sshdstart($name, $sshdpro);
    sshdstop($name, $sshdpro);
}
Beispiel #2
0
function netbios_setup($name)
{
    $infp = XNODE_getpathbytarget("", "inf", "uid", $name, 0);
    $stsp = XNODE_getpathbytarget("/runtime", "inf", "uid", $name, 0);
    if ($infp == "" || $stsp == "") {
        SHELL_info($_GLOBALS["START"], "infsvcs_setup: (" . $name . ") not exist.");
        SHELL_info($_GLOBALS["STOP"], "infsvcs_setup: (" . $name . ") not exist.");
        return;
    }
    $addrtype = query($stsp . "/inet/addrtype");
    $ipaddr = query($stsp . "/inet/ipv4/ipaddr");
    $devnam = query($stsp . "/devnam");
    $hostname = query("device/hostname");
    startcmd("hostname " . $hostname . "\n");
    if ($ipaddr == "" || $devnam == "") {
        return;
    }
    if ($addrtype == "ipv4" || $addrtype == "ipv6") {
        //jef add +   for support use shareport.local to access shareportmobile
        $web_file_access = query("/webaccess/enable");
        if ($web_file_access == 1) {
            startcmd("netbios -i " . $devnam . " -r " . $hostname . " -r shareport.local -r shareport &\n");
            startcmd("llmnresp -i " . $devnam . " -r " . $hostname . "  -r shareport.local -r shareport &\n");
        } else {
            //jef add -
            startcmd("netbios -i " . $devnam . " -r " . $hostname . " &\n");
            startcmd("llmnresp -i " . $devnam . " -r " . $hostname . " &\n");
        }
        stopcmd("killall netbios");
        stopcmd("killall llmnresp");
    }
}
Beispiel #3
0
function phyinf_setup($ifname)
{
    $phyinf = XNODE_getpathbytarget("", "phyinf", "uid", $ifname, 0);
    if ($phyinf == "") {
        error("9");
        return;
    }
    if (query($phyinf . "/active") != "1") {
        error("8");
        return;
    }
    /* Set media */
    $media = query($phyinf . "/media/linktype");
    if ($media == "") {
        $media = "AUTO";
    }
    phyinf_setmedia($mode, $ifname, $media);
    startcmd("# PHYINF." . $ifname . ": media=" . $media . ", VID=" . $vid);
    /* Set IPv6 */
    if (isfile("/proc/net/if_inet6") == 1) {
        /* IPv6 is disabled by default (we modified the kernel code).
         * Enable IPv6 here. */
        $dev = PHYINF_getifname($ifname);
        if ($dev != "") {
            startcmd("echo 0 > /proc/sys/net/ipv6/conf/" . $dev . "/disable_ipv6");
            stopcmd("echo 1 > /proc/sys/net/ipv6/conf/" . $dev . "/disable_ipv6");
        }
    }
    /* Set the MAC address */
    $stsp = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $ifname, 0);
    if ($stsp == "") {
        /* The LAYOUT service should be start before PHYINF.XXX.
         * We should never reach here !! */
        fwrite("w", "/dev/console", "PHYINF: The LAYOUT service should be start before PHYINF !!!\n");
    } else {
        $mac = query($phyinf . "/macaddr");
        if ($mac == "") {
            $mac = XNODE_get_var("MACADDR_" . $ifname);
        }
        $mac = tolower($mac);
        $curr = tolower(query($stsp . "/macaddr"));
        startcmd("# MAC: currrent " . $curr . ", target " . $mac);
        if ($mac != $curr) {
            SHELL_info($_GLOBALS["START"], "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" . "!!! Bad MAC address. Device may work abnormally. !!!\n" . "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
        }
    }
}
Beispiel #4
0
/* start IPTABLES first */
fwrite("a", $START, "service IPTABLES start\n");
/* start IP6TABLES first */
if (isfile("/proc/net/if_inet6") == 1) {
    fwrite("a", $START, "service IP6TABLES start\n");
}
if (query("/runtime/device/layout") == "router") {
    /* setup ipaddress for all WAN interfaces. */
    ifinetsetupall("WAN");
    /* LAN interface is needed by VSVR, PFWD & DMZ,
     * they should be started after LAN. */
    fwrite("a", $START, "service IPTMASQ start\n");
    fwrite("a", $START, "service IPTVSVR start\n");
    fwrite("a", $START, "service IPTPFWD start\n");
    fwrite("a", $START, "service IPTPORTT start\n");
    fwrite("a", $START, "service IPTDMZ start\n");
    /* start IPT.ifname services for all WAN interfaces. */
    srviptsetupall("WAN");
    fwrite("a", $STOP, "service IPTDMZ stop\n");
    fwrite("a", $STOP, "service IPTPORTT stop\n");
    fwrite("a", $STOP, "service IPTPFWD stop\n");
    fwrite("a", $STOP, "service IPTVSVR stop\n");
    fwrite("a", $STOP, "service IPTMASQ stop\n");
    chkconnsetupall("WAN");
} else {
    SHELL_info($START, "WAN: The device is not in the router mode.");
    SHELL_info($STOP, "WAN: The device is not in the router mode.");
}
/* Done */
fwrite("a", $START, "exit 0\n");
fwrite("a", $STOP, "exit 0\n");
Beispiel #5
0
<?php

include "/htdocs/phplib/trace.php";
include "/htdocs/phplib/xnode.php";
include "/etc/services/INET/interface.php";
fwrite("w", $START, "#!/bin/sh\n");
fwrite("a", $STOP, "#!/bin/sh\n");
/* start IPTABLES first */
fwrite("a", $START, "service IPTABLES start\n");
/* start IP6TABLES first */
if (isfile("/proc/net/if_inet6") == 1) {
    fwrite("a", $START, "service IP6TABLES start\n");
}
if (query("/runtime/device/layout") == "bridge") {
    /* Start all LAN interfaces. */
    ifinetsetupall("BRIDGE");
} else {
    SHELL_info($START, "BRIDGE: The device is not in the bridge mode.");
    SHELL_info($STOP, "BRIDGE: The device is not in the bridge mode.");
}
/* Done */
fwrite("a", $START, "exit 0\n");
fwrite("a", $STOP, "exit 0\n");
Beispiel #6
0
function ifchildsetup($name)
{
    /* Get the runtime interface */
    $infp = XNODE_getpathbytarget("", "inf", "uid", $name, 0);
    startcmd('# ifchildsetup: infp=' . $infp);
    if ($infp == "") {
        SHELL_info($_GLOBALS["START"], "ifchildsetup: (" . $name . ") no interface.");
        SHELL_info($_GLOBALS["STOP"], "ifchildsetup: (" . $name . ") no interface.");
        error("9");
        return;
    }
    /* Is this interface active ? */
    $disable = query($infp . "/disable");
    $active = query($infp . "/active");
    $phyinf = query($infp . "/phyinf");
    if ($disable == 1 || $active != 1) {
        SHELL_info($_GLOBALS["START"], "ifchildsetup: (" . $name . ") not active.");
        SHELL_info($_GLOBALS["STOP"], "ifchildsetup: (" . $name . ") not active.");
        error("8");
        return;
    }
    /* Get the physical interface */
    if ($phyinf == "") {
        SHELL_info($_GLOBALS["START"], "ifchildsetup: (" . $name . ") no phyinf.");
        SHELL_info($_GLOBALS["STOP"], "ifchildsetup: (" . $name . ") no phyinf.");
        error("9");
        return;
    }
    $_GLOBALS["CHILD_INFNAME"] = $name;
    dophp("load", "/etc/services/INET/inet_child.php");
}
Beispiel #7
0
function layout_router($mode)
{
    SHELL_info($START, "LAYOUT: Start router layout ...");
    $Wan_index_number = query("/device/router/wanindex");
    /* Start .......................................................................... */
    /* Config RTL8367 as router mode layout. (1 WAN + 4 LAN) */
    setup_switch("router");
    //+++ hendry, for wifi topology
    $p = XNODE_getpathbytarget("", "phyinf", "uid", "ETH-1", 0);
    set($p . "/bridge/ports/entry:1/uid", "MBR-1");
    set($p . "/bridge/ports/entry:1/phyinf", "BAND24G-1.1");
    set($p . "/bridge/ports/entry:2/uid", "MBR-2");
    set($p . "/bridge/ports/entry:2/phyinf", "BAND5G-1.1");
    $p = XNODE_getpathbytarget("", "phyinf", "uid", "ETH-2", 0);
    set($p . "/bridge/ports/entry:1/uid", "MBR-1");
    set($p . "/bridge/ports/entry:1/phyinf", "BAND24G-1.2");
    set($p . "/bridge/ports/entry:2/uid", "MBR-2");
    set($p . "/bridge/ports/entry:2/phyinf", "BAND5G-1.2");
    //--- hendry
    /* Setup MAC address */
    $wanmac = PHYINF_getmacsetting("WAN-1");
    $lanmac = PHYINF_getmacsetting("LAN-1");
    setup_vlaninf("eth2", "1", $lanmac);
    setup_vlaninf("eth2", "2", $wanmac);
    /* set smaller tx queue len */
    startcmd("ifconfig eth2 txqueuelen 200");
    /* Create bridge interface. */
    startcmd("brctl addbr br0; brctl stp br0 off; brctl setfd br0 0");
    startcmd("brctl addif br0 eth2.1");
    //startcmd("brctl addif br0 wifig0");
    //startcmd("brctl addif br0 wifig0.1");
    startcmd("ip link set br0 up");
    if ($mode == "1W2L") {
        startcmd("brctl addbr br1; brctl stp br1 off; brctl setfd br1 0");
        //hendry, we let guestzone to bring br1 up
        //startcmd("ip link set br1 up");;
    }
    /* Setup the runtime nodes. */
    if ($mode == "1W1L") {
        PHYINF_setup("ETH-1", "eth", "br0");
        PHYINF_setup("ETH-2", "eth", "eth2.2");
        /* set Service Alias */
        startcmd('service PHYINF.ETH-1 alias PHYINF.LAN-1');
        startcmd('service PHYINF.ETH-2 alias PHYINF.WAN-1');
        /* WAN: set extension nodes for linkstatus */
        $path = XNODE_getpathbytarget("/runtime", "phyinf", "uid", "ETH-2", 0);
        startcmd('xmldbc -x ' . $path . '/linkstatus "get:psts -i ' . $Wan_index_number . '"');
    } else {
        if ($mode == "1W2L") {
            PHYINF_setup("ETH-1", "eth", "br0");
            PHYINF_setup("ETH-2", "eth", "br1");
            PHYINF_setup("ETH-3", "eth", "eth2.2");
            /* set Service Alias */
            startcmd('service PHYINF.ETH-1 alias PHYINF.LAN-1');
            startcmd('service PHYINF.ETH-2 alias PHYINF.LAN-2');
            startcmd('service PHYINF.ETH-3 alias PHYINF.WAN-1');
            /* WAN: set extension nodes for linkstatus */
            $path = XNODE_getpathbytarget("/runtime", "phyinf", "uid", "ETH-3", 0);
            startcmd('xmldbc -x ' . $path . '/linkstatus "get:psts -i ' . $Wan_index_number . '"');
        }
    }
    //+++ hendry
    $p = XNODE_getpathbytarget("/runtime", "phyinf", "uid", "ETH-1", 0);
    add($p . "/bridge/port", "BAND24G-1.1");
    add($p . "/bridge/port", "BAND5G-1.1");
    $p = XNODE_getpathbytarget("/runtime", "phyinf", "uid", "ETH-2", 0);
    add($p . "/bridge/port", "BAND24G-1.2");
    add($p . "/bridge/port", "BAND5G-1.2");
    //--- hendry
    /* LAN: set extension nodes for linkstatus */
    $path = XNODE_getpathbytarget("/runtime", "phyinf", "uid", "ETH-1", 0);
    startcmd('xmldbc -x ' . $path . '/linkstatus:1 "get:psts -i 4"');
    startcmd('xmldbc -x ' . $path . '/linkstatus:2 "get:psts -i 3"');
    startcmd('xmldbc -x ' . $path . '/linkstatus:3 "get:psts -i 2"');
    startcmd('xmldbc -x ' . $path . '/linkstatus:4 "get:psts -i 1"');
    /* Done */
    startcmd("xmldbc -s /runtime/device/layout router");
    startcmd("xmldbc -s /runtime/device/router/mode " . $mode);
    startcmd("usockc /var/gpio_ctrl ROUTER");
    startcmd("service PHYINF.ETH-1 start");
    startcmd("service PHYINF.ETH-2 start");
    if ($mode == "1W2L") {
        startcmd("service PHYINF.ETH-3 start");
    }
    /* Stop ........................................................................... */
    SHELL_info($STOP, "LAYOUT: Stop router layout ...");
    if ($mode == "1W2L") {
        stopcmd("service PHYINF.ETH-3 stop");
        stopcmd('service PHYINF.LAN-2 delete');
    }
    stopcmd("service PHYINF.ETH-2 stop");
    stopcmd("service PHYINF.ETH-1 stop");
    stopcmd('service PHYINF.WAN-1 delete');
    stopcmd('service PHYINF.LAN-1 delete');
    stopcmd('xmldbc -s /runtime/device/layout ""');
    stopcmd('/etc/scripts/delpathbytarget.sh /runtime phyinf uid ETH-1');
    stopcmd('/etc/scripts/delpathbytarget.sh /runtime phyinf uid ETH-2');
    stopcmd('/etc/scripts/delpathbytarget.sh /runtime phyinf uid ETH-3');
    //stopcmd('brctl delif br0 wifig0');
    stopcmd('brctl delif br0 eth2.1');
    //stopcmd('brctl delif br1 wifig0.1');
    stopcmd('ip link set eth2.1 down');
    stopcmd('ip link set eth2.2 down');
    stopcmd('brctl delbr br0; brctl delbr br1');
    stopcmd('vconfig rem eth2.1; vconfig rem eth2.2');
    return 0;
}
Beispiel #8
0
function phyinf_setup($ifname)
{
    $phyinf = XNODE_getpathbytarget("", "phyinf", "uid", $ifname, 0);
    if ($phyinf == "") {
        error("9");
        return;
    }
    if (query($phyinf . "/active") != "1") {
        error("8");
        return;
    }
    /* Get layout mode */
    $layout = query("/runtime/device/layout");
    if ($layout == "bridge") {
        $mode = "1BRIDGE";
    } else {
        if ($layout == "router") {
            $mode = query("/runtime/device/router/mode");
        } else {
            error("10");
            return;
        }
    }
    if ($mode == "") {
        $mode = "1W1L";
    }
    /* Set media */
    $media = query($phyinf . "/media/linktype");
    if ($media == "") {
        $media = "AUTO";
    }
    phyinf_setmedia($mode, $ifname, $media);
    startcmd("# PHYINF." . $ifname . ": media=" . $media . ", VID=" . $vid);
    /* Set IPv6 */
    if (isfile("/proc/net/if_inet6") == 1) {
        if ($layout == "router") {
            /**********************************************************************************
             * only enable ipv6 function at br0(LAN) and eth1(WAN), other disable by default
             *********************************************************************************/
            phyinf_setipv6($mode, $ifname);
        } else {
            $dev = PHYINF_getifname($ifname);
            if ($dev != "") {
                startcmd("echo 0 > /proc/sys/net/ipv6/conf/" . $dev . "/disable_ipv6");
                stopcmd("echo 1 > /proc/sys/net/ipv6/conf/" . $dev . "/disable_ipv6");
            }
        }
    }
    /* Set the MAC address */
    $stsp = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $ifname, 0);
    if ($stsp == "") {
        /* The LAYOUT service should be start before PHYINF.XXX.
         * We should never reach here !! */
        fwrite("w", "/dev/console", "PHYINF: The LAYOUT service should be start before PHYINF !!!\n");
    } else {
        $mac = query($phyinf . "/macaddr");
        if ($mac == "") {
            $mac = XNODE_get_var("MACADDR_" . $ifname);
        }
        $mac = tolower($mac);
        $curr = tolower(query($stsp . "/macaddr"));
        startcmd("# MAC: currrent " . $curr . ", target " . $mac);
        if ($mac != $curr) {
            SHELL_info($_GLOBALS["START"], "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" . "!!! Bad MAC address. Device may work abnormally. !!!\n" . "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
        }
    }
}
Beispiel #9
0
        startcmd('service INET.' . $lower . ' start');
    }
    /* Stopping from upperlayer. */
    stop_cmd('event INFSVCS.' . $lower . '.DOWN add true');
    stop_cmd('event ' . $uid . '.COMBO.DIALUP add true');
    stop_cmd('event ' . $uid . '.COMBO.HANGUP add true');
    stop_cmd('service INET.' . $uid . ' stop');
    return "0";
}
/* Main script *************************************************************/
if ($me == "") {
    $me = "WAN-1";
}
fwrite(w, $START, "#!/bin/sh\n");
fwrite(w, $STOP, "#!/bin/sh\n");
$infp = XNODE_getpathbytarget("", "inf", "uid", $me, 0);
if ($infp != "") {
    $lower = query($infp . "/lowerlayer");
    if ($lower != "") {
        $ret = combo_inf($me, $infp, $lower);
        setup_error($ret);
    } else {
        SHELL_info($START, "INET.COMBO." . $me . ": no lowerlayer !");
        SHELL_info($STOP, "INET.COMBO." . $me . ": no lowerlayer !");
        setup_error("9");
    }
} else {
    SHELL_info($START, "INET.COMBO." . $me . ": no INF !");
    SHELL_info($STOP, "INET.COMBO." . $me . ": no INF !");
    setup_error("9");
}