mirror of
https://bitbucket.org/padavan/rt-n56u.git
synced 2026-01-09 03:42:39 +08:00
rc: LTE 4G implementation
This commit is contained in:
@@ -1121,7 +1121,17 @@ CONFIG_USB_HIDDEV=y
|
||||
# CONFIG_USB_PEGASUS is not set
|
||||
# CONFIG_USB_RTL8150 is not set
|
||||
# CONFIG_USB_USBNET_MII is not set
|
||||
# CONFIG_USB_USBNET is not set
|
||||
CONFIG_USB_USBNET=m
|
||||
# CONFIG_USB_NET_AX8817X is not set
|
||||
CONFIG_USB_NET_CDCETHER=m
|
||||
# CONFIG_USB_NET_DM9601 is not set
|
||||
# CONFIG_USB_NET_GL620A is not set
|
||||
# CONFIG_USB_NET_NET1080 is not set
|
||||
# CONFIG_USB_NET_PLUSB is not set
|
||||
# CONFIG_USB_NET_MCS7830 is not set
|
||||
CONFIG_USB_NET_RNDIS_HOST=m
|
||||
# CONFIG_USB_NET_CDC_SUBSET is not set
|
||||
# CONFIG_USB_NET_ZAURUS is not set
|
||||
# CONFIG_USB_MON is not set
|
||||
|
||||
#
|
||||
|
||||
@@ -1153,7 +1153,17 @@ CONFIG_USB_HIDDEV=y
|
||||
# CONFIG_USB_PEGASUS is not set
|
||||
# CONFIG_USB_RTL8150 is not set
|
||||
# CONFIG_USB_USBNET_MII is not set
|
||||
# CONFIG_USB_USBNET is not set
|
||||
CONFIG_USB_USBNET=m
|
||||
# CONFIG_USB_NET_AX8817X is not set
|
||||
CONFIG_USB_NET_CDCETHER=m
|
||||
# CONFIG_USB_NET_DM9601 is not set
|
||||
# CONFIG_USB_NET_GL620A is not set
|
||||
# CONFIG_USB_NET_NET1080 is not set
|
||||
# CONFIG_USB_NET_PLUSB is not set
|
||||
# CONFIG_USB_NET_MCS7830 is not set
|
||||
CONFIG_USB_NET_RNDIS_HOST=m
|
||||
# CONFIG_USB_NET_CDC_SUBSET is not set
|
||||
# CONFIG_USB_NET_ZAURUS is not set
|
||||
# CONFIG_USB_MON is not set
|
||||
|
||||
#
|
||||
|
||||
@@ -1157,7 +1157,17 @@ CONFIG_USB_HIDDEV=y
|
||||
# CONFIG_USB_PEGASUS is not set
|
||||
# CONFIG_USB_RTL8150 is not set
|
||||
# CONFIG_USB_USBNET_MII is not set
|
||||
# CONFIG_USB_USBNET is not set
|
||||
CONFIG_USB_USBNET=m
|
||||
# CONFIG_USB_NET_AX8817X is not set
|
||||
CONFIG_USB_NET_CDCETHER=m
|
||||
# CONFIG_USB_NET_DM9601 is not set
|
||||
# CONFIG_USB_NET_GL620A is not set
|
||||
# CONFIG_USB_NET_NET1080 is not set
|
||||
# CONFIG_USB_NET_PLUSB is not set
|
||||
# CONFIG_USB_NET_MCS7830 is not set
|
||||
CONFIG_USB_NET_RNDIS_HOST=m
|
||||
# CONFIG_USB_NET_CDC_SUBSET is not set
|
||||
# CONFIG_USB_NET_ZAURUS is not set
|
||||
# CONFIG_USB_MON is not set
|
||||
|
||||
#
|
||||
|
||||
@@ -1189,7 +1189,17 @@ CONFIG_USB_HIDDEV=y
|
||||
# CONFIG_USB_PEGASUS is not set
|
||||
# CONFIG_USB_RTL8150 is not set
|
||||
# CONFIG_USB_USBNET_MII is not set
|
||||
# CONFIG_USB_USBNET is not set
|
||||
CONFIG_USB_USBNET=m
|
||||
# CONFIG_USB_NET_AX8817X is not set
|
||||
CONFIG_USB_NET_CDCETHER=m
|
||||
# CONFIG_USB_NET_DM9601 is not set
|
||||
# CONFIG_USB_NET_GL620A is not set
|
||||
# CONFIG_USB_NET_NET1080 is not set
|
||||
# CONFIG_USB_NET_PLUSB is not set
|
||||
# CONFIG_USB_NET_MCS7830 is not set
|
||||
CONFIG_USB_NET_RNDIS_HOST=m
|
||||
# CONFIG_USB_NET_CDC_SUBSET is not set
|
||||
# CONFIG_USB_NET_ZAURUS is not set
|
||||
# CONFIG_USB_MON is not set
|
||||
|
||||
#
|
||||
|
||||
@@ -50,7 +50,6 @@ dir_y += utils
|
||||
dir_y += lanauth
|
||||
dir_y += comgt-0.32
|
||||
dir_y += 802.1x
|
||||
dir_y += madwimax
|
||||
dir_y += wpa_supplicant
|
||||
dir_y += pppd
|
||||
dir_y += pppoe-relay
|
||||
|
||||
@@ -899,9 +899,6 @@ int discover_all() {
|
||||
if (nvram_match("wan_route_x", "IP_Bridged"))
|
||||
return 0;
|
||||
|
||||
if (nvram_match("wan0_proto", "3g"))
|
||||
return 0;
|
||||
|
||||
/* Initialize connection info */
|
||||
memset(&conn, 0, sizeof(conn));
|
||||
conn.discoverySocket = -1;
|
||||
|
||||
@@ -720,11 +720,9 @@
|
||||
"pppoe:PPPoE",
|
||||
|
||||
"pptp:PPTP",
|
||||
|
||||
|
||||
"l2tp:L2TP",
|
||||
|
||||
//"bigpond:BigPond",
|
||||
|
||||
|
||||
0), FALSE, RESTART_NETWORKING}, // 2007.10 James
|
||||
|
||||
{"wan_mode_x", "", validate_choice, ARGV(
|
||||
|
||||
@@ -2595,7 +2595,7 @@ is_dns_static()
|
||||
{
|
||||
if (get_usb_modem_state())
|
||||
{
|
||||
return 0; // force dynamic dns for ppp0
|
||||
return 0; // force dynamic dns for ppp0/eth0
|
||||
}
|
||||
if (nvram_match("wan0_proto", "static"))
|
||||
{
|
||||
@@ -2605,56 +2605,62 @@ is_dns_static()
|
||||
return !nvram_match("wan_dnsenable_x", "1"); // dynamic or static dns for ppp0 or eth3
|
||||
}
|
||||
|
||||
static int wanlink_hook(int eid, webs_t wp, int argc, char_t **argv) {
|
||||
FILE *fp;
|
||||
char type[32], ip[64], netmask[32], gateway[32], dns[128], statusstr[32], etherlink[32] = {0};
|
||||
int status = 0, unit, s;
|
||||
char tmp[100], prefix[] = "wanXXXXXXXXXX_";
|
||||
char filename[80], conntype[10];
|
||||
int
|
||||
get_if_status(char *wan_ifname)
|
||||
{
|
||||
int s, status;
|
||||
struct ifreq ifr;
|
||||
struct sockaddr_in *our_ip;
|
||||
struct in_addr in;
|
||||
char *pwanip = NULL, *ppp_addr, *usb_device, *wan0_ip, *wanx_ip = NULL;
|
||||
|
||||
status = 0;
|
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s >= 0) {
|
||||
/* Check for valid IP address */
|
||||
strncpy(ifr.ifr_name, wan_ifname, IFNAMSIZ);
|
||||
|
||||
if (ioctl(s, SIOCGIFADDR, &ifr) == 0) {
|
||||
our_ip = (struct sockaddr_in *) &ifr.ifr_addr;
|
||||
|
||||
if (our_ip->sin_addr.s_addr != INADDR_ANY) {
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
close(s);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static int wanlink_hook(int eid, webs_t wp, int argc, char_t **argv) {
|
||||
char type[32], ip[64], netmask[32], gateway[32], dns[128], statusstr[32], etherlink[32] = {0};
|
||||
int status = 0, unit;
|
||||
char tmp[100], prefix[] = "wanXXXXXXXXXX_";
|
||||
char *ppp_addr, *usb_device, *wan0_ip, *wanx_ip = NULL;
|
||||
|
||||
/* current unit */
|
||||
if ((unit = atoi(nvram_safe_get("wan_unit"))) < 0)
|
||||
unit = 0;
|
||||
|
||||
wan_prefix(unit, prefix);
|
||||
|
||||
if(get_usb_modem_state()){
|
||||
DIR *ppp_dir;
|
||||
int got_ppp_link;
|
||||
struct dirent *entry;
|
||||
|
||||
if ((ppp_dir = opendir("/tmp/ppp")) == NULL) {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
statusstr[0] = 0;
|
||||
|
||||
if(get_usb_modem_state())
|
||||
{
|
||||
if(nvram_match("modem_enable", "4"))
|
||||
status = get_if_status(LTE_INTERFACE);
|
||||
else {
|
||||
got_ppp_link = 0;
|
||||
while((entry = readdir(ppp_dir)) != NULL) {
|
||||
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
|
||||
continue;
|
||||
|
||||
if (strstr(entry->d_name, "link") != NULL) {
|
||||
got_ppp_link = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(ppp_dir);
|
||||
|
||||
if (got_ppp_link == 0) {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
else if (check_ppp_exist() == -1) {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
else {
|
||||
status = 1;
|
||||
strcpy(statusstr, "Connected");
|
||||
status = get_if_status("ppp0");
|
||||
// Dual access with 3G Modem
|
||||
if (nvram_match(strcat_r(prefix, "proto", tmp), "pptp") ||
|
||||
nvram_match(strcat_r(prefix, "proto", tmp), "l2tp") ||
|
||||
nvram_match(strcat_r(prefix, "proto", tmp), "pppoe") )
|
||||
{
|
||||
if (is_phyconnected())
|
||||
wanx_ip = nvram_safe_get("wanx_ipaddr");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2663,195 +2669,34 @@ static int wanlink_hook(int eid, webs_t wp, int argc, char_t **argv) {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Cable is not attached");
|
||||
}
|
||||
// 2008.07 James. {
|
||||
else if (!strcmp(nvram_safe_get("manually_disconnect_wan"), "1")) {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
// 2008.07 James. }
|
||||
else if (nvram_match(strcat_r(prefix, "proto", tmp), "pptp")
|
||||
|| nvram_match(strcat_r(prefix, "proto", tmp), "PPTP")
|
||||
|| nvram_match(strcat_r(prefix, "proto", tmp), "l2tp")
|
||||
|| nvram_match(strcat_r(prefix, "proto", tmp), "pppoe")
|
||||
|| nvram_match(strcat_r(prefix, "proto", tmp), "PPPoE")
|
||||
)
|
||||
else if (nvram_match(strcat_r(prefix, "proto", tmp), "pptp") ||
|
||||
nvram_match(strcat_r(prefix, "proto", tmp), "l2tp") ||
|
||||
nvram_match(strcat_r(prefix, "proto", tmp), "pppoe") )
|
||||
{
|
||||
DIR *ppp_dir;
|
||||
int got_ppp_link;
|
||||
struct dirent *entry;
|
||||
status = get_if_status("ppp0");
|
||||
|
||||
// get ip for physical eth3
|
||||
wanx_ip = nvram_safe_get("wanx_ipaddr");
|
||||
|
||||
if ((ppp_dir = opendir("/tmp/ppp")) == NULL) {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
else {
|
||||
got_ppp_link = 0;
|
||||
while((entry = readdir(ppp_dir)) != NULL) {
|
||||
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
|
||||
continue;
|
||||
|
||||
if (strstr(entry->d_name, "link") != NULL) {
|
||||
got_ppp_link = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(ppp_dir);
|
||||
|
||||
if (got_ppp_link == 0) {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
else if (check_ppp_exist() == -1) {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
else {
|
||||
status = 1;
|
||||
strcpy(statusstr, "Connected");
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
DIR *ppp_dir; // 2008.01 James.
|
||||
struct dirent *entry; // 2008.01 James.
|
||||
char *name;
|
||||
char* pos = NULL;
|
||||
// char* cpos = NULL;
|
||||
|
||||
memset(filename, 0, 80);
|
||||
|
||||
ppp_dir = opendir("/tmp/ppp");
|
||||
if (ppp_dir == NULL) {
|
||||
printf("wanlink_hook ppp_dir == NULL\n"); // tmp test
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
|
||||
while ((entry = readdir(ppp_dir)) != NULL) {
|
||||
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
|
||||
continue;
|
||||
|
||||
if ((pos = strstr(entry->d_name, "link")) != NULL) {
|
||||
sprintf(filename, "/tmp/ppp/%s", entry->d_name);
|
||||
strcpy(conntype, pos+5);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(ppp_dir);
|
||||
|
||||
if (strlen(filename) > 0 && (fp = fopen(filename, "r")) != NULL) {
|
||||
int pid = -1;
|
||||
fclose(fp);
|
||||
|
||||
if (nvram_match(strcat_r(prefix, "proto", tmp), "heartbeat")) {
|
||||
char buf[20];
|
||||
|
||||
file_to_buf(filename, buf, sizeof(buf));
|
||||
pid = atoi(buf);
|
||||
}
|
||||
else
|
||||
pid = get_ppp_pid(conntype);
|
||||
|
||||
name = find_name_by_proc(pid);
|
||||
|
||||
if (!strncmp(name, "pppoecd", 7) || // for PPPoE
|
||||
!strncmp(name, "pppd", 4) // for PPTP
|
||||
/*!strncmp(name, "bpalogin", 8) // for HearBeat*/
|
||||
) {
|
||||
if (!strcmp(nvram_safe_get("manually_disconnect_wan"), "1"))
|
||||
{
|
||||
status = 0;
|
||||
//printf("[status str] chk dicconn 0\n"); // tmp test
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
else
|
||||
{
|
||||
status = 1;
|
||||
//printf("[status str] chk conn 1\n"); // tmp test
|
||||
strcpy(statusstr, "Connected");
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
//printf("[status str] chk disconn 1\n"); // tmp test
|
||||
// For some reason, the pppoed had been died, by link file still exist.
|
||||
unlink(filename);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//wendebug
|
||||
//printf("filename : open fail\n");
|
||||
//csprintf("wanlink_hook filename : open fail\n");
|
||||
status = 0;
|
||||
//printf("[status str] chk disconn 2\n"); // tmp test
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
#endif // #if 0
|
||||
}
|
||||
else {
|
||||
// 2009.05 James. {
|
||||
//if (!strcmp(nvram_safe_get("wan_gateway_t"), nvram_safe_get("lan_ipaddr_t"))) {
|
||||
if (check_subnet()) {
|
||||
if (check_subnet())
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
else
|
||||
// 2009.05 James. }
|
||||
/* Open socket to kernel */
|
||||
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
//printf("wanlink_hook Open socket to kernel : open fail\n"); // tmp test
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
//printf("[status str] chk disconn 3\n"); // tmp test
|
||||
}
|
||||
else {
|
||||
/* Check for valid IP address */
|
||||
strncpy(ifr.ifr_name, nvram_safe_get(strcat_r(prefix, "ifname", tmp)), IFNAMSIZ);
|
||||
|
||||
if (!ioctl(s, SIOCGIFADDR, &ifr)) {
|
||||
our_ip = (struct sockaddr_in *) &ifr.ifr_addr;
|
||||
in.s_addr = our_ip->sin_addr.s_addr;
|
||||
pwanip = inet_ntoa(in);
|
||||
|
||||
if (!strcmp(pwanip, "") || pwanip == NULL) {
|
||||
// csprintf("wanlink_hook !strcmp(pwanip, "") || pwanip == NULL\n");
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
//printf("[status str] chk disconn 4\n"); // tmp test
|
||||
}
|
||||
// 2008.07 James. {
|
||||
else if (!strcmp(nvram_safe_get("manually_disconnect_wan"), "1")) {
|
||||
//printf("wanlink_hook manually_disconnect_wan=1\n"); // tmp test
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
//printf("[status str] chk disconn 5\n"); // tmp test
|
||||
}
|
||||
// 2008.07 James. }
|
||||
else {
|
||||
status = 1;
|
||||
strcpy(statusstr, "Connected");
|
||||
//printf("[status str] chk conn 2\n"); // tmp test
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = 0;
|
||||
strcpy(statusstr, "Disconnected");
|
||||
//printf("[status str] chk disconn 6\n"); // tmp test
|
||||
}
|
||||
|
||||
close(s);
|
||||
}
|
||||
status = get_if_status("eth3");
|
||||
}
|
||||
|
||||
if ( !statusstr[0] ) {
|
||||
if (status)
|
||||
strcpy(statusstr, "Connected");
|
||||
else
|
||||
strcpy(statusstr, "Disconnected");
|
||||
}
|
||||
|
||||
//printf("[httpd] wan status str is %s\n", statusstr); // tmp test
|
||||
if(get_usb_modem_state())
|
||||
{
|
||||
strcpy(type, "Modem");
|
||||
if(nvram_match("modem_enable", "4"))
|
||||
strcpy(type, "LTE Modem");
|
||||
else
|
||||
strcpy(type, "Modem");
|
||||
}
|
||||
else
|
||||
if (nvram_match(strcat_r(prefix, "proto", tmp), "pppoe"))
|
||||
@@ -2862,15 +2707,10 @@ static int wanlink_hook(int eid, webs_t wp, int argc, char_t **argv) {
|
||||
{
|
||||
strcpy(type, "PPTP");
|
||||
}
|
||||
//2008.10 magic add l2tp
|
||||
else if (nvram_match(strcat_r(prefix, "proto", tmp), "l2tp"))
|
||||
else if (nvram_match(strcat_r(prefix, "proto", tmp), "l2tp"))
|
||||
{
|
||||
strcpy(type, "L2TP");
|
||||
}
|
||||
else if (nvram_match(strcat_r(prefix, "proto", tmp), "bigpond"))
|
||||
{
|
||||
strcpy(type, "Big Pond");
|
||||
}
|
||||
else if (nvram_match(strcat_r(prefix, "proto", tmp), "static"))
|
||||
{
|
||||
strcpy(type, "Static IP");
|
||||
@@ -2886,13 +2726,13 @@ static int wanlink_hook(int eid, webs_t wp, int argc, char_t **argv) {
|
||||
if (status == 0)
|
||||
{
|
||||
wan0_ip = "0.0.0.0";
|
||||
strcpy(gateway, "0.0.0.0");
|
||||
strcpy(gateway, "0.0.0.0");
|
||||
}
|
||||
else
|
||||
{
|
||||
wan0_ip = nvram_safe_get(strcat_r(prefix, "ipaddr", tmp));
|
||||
strcpy(netmask, nvram_safe_get(strcat_r(prefix, "netmask", tmp)));
|
||||
strcpy(gateway, nvram_safe_get(strcat_r(prefix, "gateway", tmp)));
|
||||
strcpy(gateway, nvram_safe_get(strcat_r(prefix, "gateway", tmp)));
|
||||
}
|
||||
|
||||
if (wanx_ip && *wanx_ip && strcmp(wanx_ip, "0.0.0.0") )
|
||||
@@ -2914,7 +2754,6 @@ static int wanlink_hook(int eid, webs_t wp, int argc, char_t **argv) {
|
||||
sprintf(dns, "%s", nvram_safe_get("wan_dns_t"));
|
||||
}
|
||||
|
||||
// Padavan
|
||||
fill_switch_port_status(RTL8367M_IOCTL_STATUS_SPEED_PORT_WAN, etherlink);
|
||||
|
||||
websWrite(wp, "function wanlink_status() { return %d;}\n", status);
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
#define RTCONFIG_USB
|
||||
#define RTCONFIG_USB_PRINTER
|
||||
#define RTCONFIG_USB_MODEM
|
||||
#define RTCONFIG_USB_MODEM_WIMAX
|
||||
#define RTCONFIG_USB_MODEM_LTE
|
||||
|
||||
#ifdef RTCONFIG_USB_MODEM_WIMAX
|
||||
#define WIMAX_INTERFACE "eth0"
|
||||
#endif
|
||||
#define LTE_INTERFACE "eth0"
|
||||
|
||||
//#define DEBUG_USB
|
||||
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright 2004, ASUSTeK Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS OFFERED "AS IS", AND ASUS GRANTS NO WARRANTIES OF ANY
|
||||
* KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
|
||||
* SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <shutils.h>
|
||||
#include <nvram/bcmnvram.h>
|
||||
#include <rc.h>
|
||||
#include <netconf.h>
|
||||
#include <nvparse.h>
|
||||
|
||||
int
|
||||
start_bpalogin(void)
|
||||
{
|
||||
FILE *fp;
|
||||
int ret;
|
||||
char authserver[20];
|
||||
char authdomain[80];
|
||||
char buf[254];
|
||||
|
||||
if (!nvram_match("wan_heartbeat_x", "")) {
|
||||
snprintf(authserver, sizeof(authserver), "%s", nvram_safe_get("wan_heartbeat_x"));
|
||||
snprintf(authdomain, sizeof(authdomain), "%s", "");
|
||||
}
|
||||
else if (!nvram_match("wan0_domain", " ") && !nvram_match("wan0_domain", ""))
|
||||
{
|
||||
snprintf(authserver, sizeof(authserver), "%s", "sm-server");
|
||||
snprintf(authdomain, sizeof(authdomain), "%s", nvram_safe_get("wan0_domain"));
|
||||
}
|
||||
#ifdef REMOVE
|
||||
else if (nvram_match("wan0_domain", "nsw.bigpond.net.au")) { // NSW
|
||||
snprintf(authserver, sizeof(authserver), "%s", "spr3");
|
||||
snprintf(authdomain, sizeof(authdomain), "%s", "nsw-remote.bigpond.net.au");
|
||||
}
|
||||
else if (nvram_match("wan0_domain", "vic.bigpond.net.au")) { // Victoria
|
||||
snprintf(authserver, sizeof(authserver), "%s", "mer3");
|
||||
snprintf(authdomain, sizeof(authdomain), "%s", "vic-remote.bigpond.net.au");
|
||||
}
|
||||
else if (nvram_match("wan0_domain","qld.bigpond.net.au")) { // Queensland
|
||||
snprintf(authserver, sizeof(authserver), "%s", "bcr3");
|
||||
snprintf(authdomain, sizeof(authdomain), "%s", "qld-remote.bigpond.net.au");
|
||||
}
|
||||
else if (nvram_match("wan0_domain", "sa.bigpond.net.au")) { // South Austrialia
|
||||
snprintf(authserver, sizeof(authserver), "%s", "afr3");
|
||||
snprintf(authdomain, sizeof(authdomain), "%s", "sa-remote.bigpond.net.au");
|
||||
}
|
||||
else if (nvram_match("wan0_domain", "wa.bigpond.net.au")) { // Western Austrialia
|
||||
snprintf(authserver, sizeof(authserver), "%s", "pwr3");
|
||||
snprintf(authdomain, sizeof(authdomain), "%s", "wa-remote.bigpond.net.au");
|
||||
}
|
||||
#endif
|
||||
else{
|
||||
snprintf(authserver, sizeof(authserver), "%s", nvram_safe_get("wan0_gateway"));
|
||||
snprintf(authdomain, sizeof(authdomain), "%s", "");
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s%s%s", authserver, !strcmp(authdomain,"") ? "" : ".", authdomain);
|
||||
|
||||
nvram_set("hb_server_name", buf);
|
||||
|
||||
if (!(fp = fopen("/tmp/bpalogin.conf", "w"))) {
|
||||
perror("/tmp/bpalogin.conf");
|
||||
return errno;
|
||||
}
|
||||
fprintf(fp, "username %s\n", nvram_safe_get("wan_pppoe_username"));
|
||||
fprintf(fp, "password %s\n", nvram_safe_get("wan_pppoe_passwd"));
|
||||
fprintf(fp, "authserver %s\n", authserver);
|
||||
if (strcmp(authdomain, "")) {
|
||||
fprintf(fp, "authdomain %s\n", authdomain);
|
||||
}
|
||||
fprintf(fp, "localport 5050\n");
|
||||
fprintf(fp, "logging syslog\n");
|
||||
fprintf(fp, "debuglevel 0\n");
|
||||
fprintf(fp, "minheartbeatinterval 60\n");
|
||||
fprintf(fp, "maxheartbeatinterval 420\n");
|
||||
fprintf(fp, "connectedprog bpa_connect\n");
|
||||
fprintf(fp, "disconnectedprog bpa_disconnect\n");
|
||||
fclose(fp);
|
||||
|
||||
//mkdir("/tmp/ppp", 0777);
|
||||
if ((fp = fopen("/tmp/bpa_connect_success", "r"))) {
|
||||
ret = system("bpalogin -c /tmp/bpalogin.conf -t");
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
ret = system("bpalogin -c /tmp/bpalogin.conf");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
stop_bpalogin(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = system("killall bpalogin");
|
||||
ret += system("killall -9 bpalogin");
|
||||
dprintf("done\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
int
|
||||
bpa_connect_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[254];
|
||||
#ifdef NOIPTABLES
|
||||
netconf_filter_t filter;
|
||||
int log_level, log_accept;
|
||||
char tmp[100], prefix[] = "wanXXXXXXXXXX_";
|
||||
int i;
|
||||
|
||||
// Optionally log connections
|
||||
log_level = atoi(nvram_safe_get("log_level"));
|
||||
log_accept = (log_level & 2) ? NETCONF_LOG_ACCEPT : NETCONF_ACCEPT;
|
||||
|
||||
memset(&filter, 0, sizeof(filter));
|
||||
strcpy(filter.match.in.name, nvram_safe_get("wan0_ifname"));
|
||||
filter.target = log_accept;
|
||||
filter.match.ipproto = IPPROTO_UDP;
|
||||
inet_aton(nvram_safe_get("wan0_ipaddr"), &filter.match.dst.ipaddr);
|
||||
inet_aton(nvram_safe_get("wan0_netmask"), &filter.match.dst.netmask);
|
||||
filter.match.dst.ports[0] = htons(atoi("5050"));
|
||||
add_forward(&filter, NETCONF_IN, log_accept);
|
||||
nvram_set("wan_auth_t", "OK");
|
||||
#else
|
||||
nvram_set("wan_auth_t", "OK");
|
||||
snprintf(buf, sizeof(buf), "iptables -I INPUT -d %s -i %s -p udp --dport %d -j %s",
|
||||
nvram_safe_get("wan0_ipaddr"),
|
||||
nvram_safe_get("wan0_ifname"),
|
||||
5050,
|
||||
"ACCEPT");
|
||||
|
||||
system(buf);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
bpa_disconnect_main(int argc, char **argv)
|
||||
{
|
||||
char tmp[100], *str;
|
||||
int pid;
|
||||
|
||||
#if 1 // Thanks for Oleg
|
||||
nvram_set("wan_auth_t", "FAIL");
|
||||
#else
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "/var/run/udhcpc%d.pid", 0);
|
||||
if ((str = file2str(tmp))) {
|
||||
pid = atoi(str);
|
||||
free(str);
|
||||
kill(pid, SIGUSR2);
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
@@ -568,14 +568,10 @@ void convert_asus_values(int skipflag)
|
||||
|
||||
#ifdef DLM
|
||||
if (nvram_match("ftp_lang","")) {
|
||||
// if ((nvram_match("regulation_domain","0x47TW"))||(nvram_match("regulation_domain","0X47TW")))
|
||||
if (nvram_match("wl_country_code", "TW"))
|
||||
nvram_set("ftp_lang","TW");
|
||||
// else if ((nvram_match("regulation_domain","0x44CN"))||(nvram_match("regulation_domain","0X44CN")))
|
||||
else if (nvram_match("wl_country_code", "CN"))
|
||||
nvram_set("ftp_lang", "CN");
|
||||
// else if ((nvram_match("regulation_domain","0x46KR"))||(nvram_match("regulation_domain","0X46KR")))
|
||||
// nvram_set("ftp_lang", "KR");
|
||||
else
|
||||
nvram_set("ftp_lang","EN");
|
||||
}
|
||||
@@ -901,12 +897,8 @@ void convert_asus_values(int skipflag)
|
||||
|
||||
if (!skipflag)
|
||||
{
|
||||
#ifdef CDMA
|
||||
nvram_set("support_cdma", "1");
|
||||
nvram_set("cdma_down", "99");
|
||||
#else
|
||||
nvram_unset("support_cdma");
|
||||
#endif
|
||||
|
||||
nvram_set("reboot", "");
|
||||
#ifdef WSC
|
||||
nvram_unset("wps_start_flag");
|
||||
@@ -1048,10 +1040,6 @@ void update_wan_status(int isup)
|
||||
else if (!strcmp(proto, "pppoe")) nvram_set("wan_proto_t", "PPPoE");
|
||||
else if (!strcmp(proto, "pptp")) nvram_set("wan_proto_t", "PPTP");
|
||||
else if (!strcmp(proto, "l2tp")) nvram_set("wan_proto_t", "L2TP"); // oleg patch
|
||||
//else if (!strcmp(proto, "bigpond")) nvram_set("wan_proto_t", "BigPond");
|
||||
#ifdef CDMA
|
||||
else if (!strcmp(proto, "cdma")) nvram_set("wan_proto_t", "CDMA");
|
||||
#endif
|
||||
if (!isup)
|
||||
{
|
||||
nvram_set("wan_ipaddr_t", "");
|
||||
|
||||
@@ -1325,14 +1325,6 @@ filter_setting(char *wan_if, char *wan_ip, char *lan_if, char *lan_ip, char *log
|
||||
|
||||
ip2class(lan_ip, nvram_safe_get("lan_netmask"), lan_class);
|
||||
|
||||
if ( nvram_match("wan0_proto", "bigpond"))
|
||||
{
|
||||
fprintf(fp, "-I INPUT -d %s -i %s -p udp --dport %d -j %s\n"
|
||||
, nvram_safe_get("wan0_ipaddr")
|
||||
, nvram_safe_get("wan0_ifname")
|
||||
, 5050
|
||||
, "ACCEPT");
|
||||
}
|
||||
strcpy(macaccept, "");
|
||||
|
||||
if (atoi(nvram_safe_get("macfilter_num_x")) == 0)
|
||||
@@ -1534,12 +1526,8 @@ filter_setting(char *wan_if, char *wan_ip, char *lan_if, char *lan_ip, char *log
|
||||
}
|
||||
|
||||
/* Clamp TCP MSS to PMTU of WAN interface before accepting RELATED packets */
|
||||
if (nvram_match("wan_proto", "pptp") || nvram_match("wan_proto", "pppoe") || nvram_match("wan_proto", "l2tp") ||
|
||||
nvram_match("wan_proto", "3g")
|
||||
#ifdef CDMA
|
||||
|| nvram_match("wan_proto", "cdma")
|
||||
#endif
|
||||
) {
|
||||
if (nvram_match("wan_proto", "pptp") || nvram_match("wan_proto", "pppoe") || nvram_match("wan_proto", "l2tp"))
|
||||
{
|
||||
fprintf(fp, "-A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu\n");
|
||||
if (strlen(macaccept)>0)
|
||||
fprintf(fp, "-A MACS -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu\n");
|
||||
|
||||
@@ -1202,6 +1202,22 @@ flush_route_caches(void)
|
||||
}
|
||||
}
|
||||
|
||||
int is_module_loaded(char *module_name)
|
||||
{
|
||||
DIR *dir_to_open = NULL;
|
||||
char sys_path[128];
|
||||
|
||||
sprintf(sys_path, "/sys/module/%s", module_name);
|
||||
dir_to_open = opendir(sys_path);
|
||||
if (dir_to_open)
|
||||
{
|
||||
closedir(dir_to_open);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_ftp_conntrack_loaded(int ftp_port)
|
||||
{
|
||||
DIR *dir_to_open = NULL;
|
||||
@@ -1351,7 +1367,7 @@ void get_wan_ifname(char wan_ifname[16])
|
||||
|
||||
if(get_usb_modem_state()){
|
||||
if(nvram_match("modem_enable", "4"))
|
||||
ifname = WIMAX_INTERFACE;
|
||||
ifname = LTE_INTERFACE;
|
||||
else
|
||||
ifname = "ppp0";
|
||||
}
|
||||
@@ -1564,11 +1580,15 @@ start_wan(void)
|
||||
* ip-up/ip-down scripts upon link's connect/disconnect.
|
||||
*/
|
||||
|
||||
if(get_usb_modem_state()){
|
||||
if(nvram_match("modem_enable", "4")){
|
||||
start_udhcpc_wan(WIMAX_INTERFACE, unit, 0);
|
||||
if(get_usb_modem_state())
|
||||
{
|
||||
if(nvram_match("modem_enable", "4"))
|
||||
{
|
||||
ifconfig(LTE_INTERFACE, IFUP, "0.0.0.0", NULL);
|
||||
|
||||
nvram_set("wan_ifname_t", WIMAX_INTERFACE);
|
||||
start_udhcpc_wan(LTE_INTERFACE, unit, 0);
|
||||
|
||||
nvram_set("wan_ifname_t", LTE_INTERFACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1669,7 +1689,7 @@ start_wan(void)
|
||||
* 'udhcpc bound'/'udhcpc deconfig' upon finishing IP address
|
||||
* renew and release.
|
||||
*/
|
||||
else if (strcmp(wan_proto, "dhcp") == 0 || strcmp(wan_proto, "bigpond") == 0 )
|
||||
else if (strcmp(wan_proto, "dhcp") == 0)
|
||||
{
|
||||
/* Start eapol-md5 authenticator */
|
||||
if (nvram_match("wan_auth_mode", "2"))
|
||||
@@ -1680,7 +1700,7 @@ start_wan(void)
|
||||
nvram_set("wan_ifname_t", wan_ifname);
|
||||
}
|
||||
/* Configure static IP connection. */
|
||||
else if ((strcmp(wan_proto, "static") == 0) || (strcmp(wan_proto, "Static") == 0))
|
||||
else if ((strcmp(wan_proto, "static") == 0))
|
||||
{
|
||||
/* Assign static IP address to i/f */
|
||||
ifconfig(wan_ifname, IFUP,
|
||||
@@ -1714,13 +1734,24 @@ select_usb_modem_to_wan(int wait_modem_sec)
|
||||
// Check modem enabled
|
||||
if (modem_type > 0)
|
||||
{
|
||||
if (modem_type == 4)
|
||||
{
|
||||
if ( !is_module_loaded("rndis_host") )
|
||||
{
|
||||
system("modprobe -q rndis_host");
|
||||
wait_modem_sec += 2;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<=wait_modem_sec; i++)
|
||||
{
|
||||
if ( modem_type == 4)
|
||||
if (modem_type == 4)
|
||||
{
|
||||
if ( is_ready_modem_4g() )
|
||||
{
|
||||
is_modem_found = 1;
|
||||
|
||||
logmessage("select_usb_modem_to_wan", "LTE 4G modem found!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1782,7 +1813,7 @@ is_dns_static(void)
|
||||
{
|
||||
if (get_usb_modem_state())
|
||||
{
|
||||
return 0; // force dynamic dns for ppp0
|
||||
return 0; // force dynamic dns for ppp0/eth0
|
||||
}
|
||||
|
||||
if (nvram_match("wan0_proto", "static"))
|
||||
@@ -1801,7 +1832,7 @@ is_physical_wan_dhcp(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nvram_match("wan_proto", "dhcp") || nvram_match("wan_proto", "bigpond") || nvram_match("x_DHCPClient", "1"))
|
||||
if (nvram_match("wan_proto", "dhcp") || nvram_match("x_DHCPClient", "1"))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1812,7 +1843,6 @@ is_physical_wan_dhcp(void)
|
||||
void
|
||||
stop_wan(void)
|
||||
{
|
||||
char name[80], *next;
|
||||
char *wan_ifname = "eth3";
|
||||
char *svcs[] = { "stats",
|
||||
"ntpclient",
|
||||
@@ -1845,10 +1875,10 @@ stop_wan(void)
|
||||
wan_down(wan_ifname);
|
||||
|
||||
/* Bring down WAN interfaces */
|
||||
foreach(name, nvram_safe_get("wan_ifnames"), next)
|
||||
{
|
||||
ifconfig(name, 0, "0.0.0.0", NULL);
|
||||
}
|
||||
ifconfig(wan_ifname, 0, "0.0.0.0", NULL);
|
||||
|
||||
/* Bring down LTE interface */
|
||||
ifconfig(LTE_INTERFACE, 0, "0.0.0.0", NULL);
|
||||
|
||||
/* Remove dynamically created links */
|
||||
unlink("/tmp/zcip.script");
|
||||
@@ -2068,14 +2098,15 @@ is_ifunit_modem(char *wan_ifname)
|
||||
{
|
||||
if (get_usb_modem_state())
|
||||
{
|
||||
if ( (ppp_ifunit(wan_ifname) >= 0)
|
||||
#ifdef RTCONFIG_USB_MODEM_WIMAX
|
||||
|| (strcmp(wan_ifname, WIMAX_INTERFACE) == 0)
|
||||
#endif
|
||||
)
|
||||
if (ppp_ifunit(wan_ifname) >= 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strcmp(wan_ifname, LTE_INTERFACE) == 0)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -2164,7 +2195,7 @@ wan_up(char *wan_ifname) // oleg patch, replace
|
||||
route_add(wan_ifname, 0, "0.0.0.0", gateway, "0.0.0.0");
|
||||
|
||||
/* hack: avoid routing cycles, when both peer and server has the same IP */
|
||||
if (strcmp(wan_proto, "pptp") == 0 || strcmp(wan_proto, "l2tp") == 0) {
|
||||
if ( (!is_modem_unit) && (strcmp(wan_proto, "pptp") == 0 || strcmp(wan_proto, "l2tp") == 0)) {
|
||||
/* delete gateway route as it's no longer needed */
|
||||
route_del(wan_ifname, 0, gateway, "0.0.0.0", "255.255.255.255");
|
||||
}
|
||||
@@ -2173,15 +2204,15 @@ wan_up(char *wan_ifname) // oleg patch, replace
|
||||
/* Install interface dependent static routes */
|
||||
add_wan_routes(wan_ifname);
|
||||
|
||||
/* setup static wan routes via physical device */
|
||||
if ( (!is_modem_unit) && (strcmp(wan_proto, "dhcp") == 0 || strcmp(wan_proto, "static") == 0) )
|
||||
/* Add static wan routes */
|
||||
if ( ((!is_modem_unit) && (strcmp(wan_proto, "dhcp") == 0 || strcmp(wan_proto, "static") == 0)) || (is_modem_unit == 2) )
|
||||
{
|
||||
nvram_set("wanx_gateway", nvram_safe_get(strcat_r(prefix, "gateway", tmp)));
|
||||
add_routes("wan_", "route", wan_ifname);
|
||||
}
|
||||
|
||||
/* and one supplied via DHCP */
|
||||
if ( (!is_modem_unit) && (strcmp(wan_proto, "dhcp") == 0) )
|
||||
/* Add dynamic routes supplied via DHCP */
|
||||
if ( ((!is_modem_unit) && (strcmp(wan_proto, "dhcp") == 0)) || (is_modem_unit == 2) )
|
||||
{
|
||||
add_wanx_routes(prefix, wan_ifname, 0);
|
||||
}
|
||||
@@ -2204,13 +2235,6 @@ wan_up(char *wan_ifname) // oleg patch, replace
|
||||
|
||||
update_upnp(1);
|
||||
|
||||
#ifdef CDMA
|
||||
if ((strcmp(wan_proto, "cdma")==0))
|
||||
{
|
||||
nvram_set("cdma_down", "2");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* start multicast router */
|
||||
if ( (!is_modem_unit) && (strcmp(wan_proto, "dhcp") == 0 || strcmp(wan_proto, "static") == 0) )
|
||||
{
|
||||
@@ -2252,7 +2276,7 @@ wan_down(char *wan_ifname)
|
||||
if (wan_prefix(wan_ifname, prefix) < 0)
|
||||
{
|
||||
// dhcp + ppp (wan_ifname=eth3)
|
||||
/* Padavan - stop multicast router */
|
||||
/* stop multicast router */
|
||||
stop_igmpproxy();
|
||||
|
||||
// flush conntrack caches
|
||||
@@ -2294,14 +2318,7 @@ wan_down(char *wan_ifname)
|
||||
}
|
||||
|
||||
update_wan_status(0);
|
||||
|
||||
#ifdef CDMA
|
||||
if ((strcmp(wan_proto, "cdma")==0))
|
||||
{
|
||||
stop_cdma();
|
||||
nvram_set("cdma_down", "1");
|
||||
}
|
||||
#endif
|
||||
|
||||
// cleanup
|
||||
nvram_set("wan_ipaddr_t", "");
|
||||
|
||||
@@ -2380,17 +2397,13 @@ wan_ifunit(char *wan_ifname)
|
||||
if ((unit = ppp_ifunit(wan_ifname)) >= 0) {
|
||||
return unit;
|
||||
} else {
|
||||
if (strcmp(wan_ifname, LTE_INTERFACE) == 0)
|
||||
return 0;
|
||||
|
||||
for (unit = 0; unit < MAX_NVPARSE; unit ++) {
|
||||
snprintf(prefix, sizeof(prefix), "wan%d_", unit);
|
||||
if (nvram_match(strcat_r(prefix, "ifname", tmp), wan_ifname) &&
|
||||
(nvram_match(strcat_r(prefix, "proto", tmp), "dhcp") ||
|
||||
nvram_match(strcat_r(prefix, "proto", tmp), "bigpond") ||
|
||||
//#ifdef DHCP_PPTP // oleg patch mark off
|
||||
// nvram_match(strcat_r(prefix, "proto", tmp), "pptp") ||
|
||||
//#endif
|
||||
#ifdef CDMA
|
||||
nvram_match(strcat_r(prefix, "proto", tmp), "cdma") ||
|
||||
#endif
|
||||
nvram_match(strcat_r(prefix, "proto", tmp), "static")))
|
||||
return unit;
|
||||
}
|
||||
@@ -2518,11 +2531,9 @@ get_wan_ipaddr()
|
||||
return strdup("0.0.0.0");
|
||||
|
||||
if(get_usb_modem_state()){
|
||||
#ifdef RTCONFIG_USB_MODEM_WIMAX
|
||||
if(nvram_match("modem_enable", "4"))
|
||||
strncpy(ifr.ifr_name, WIMAX_INTERFACE, IFNAMSIZ);
|
||||
strncpy(ifr.ifr_name, LTE_INTERFACE, IFNAMSIZ);
|
||||
else
|
||||
#endif
|
||||
strncpy(ifr.ifr_name, "ppp0", IFNAMSIZ);
|
||||
}
|
||||
else
|
||||
@@ -2542,6 +2553,26 @@ get_wan_ipaddr()
|
||||
return inet_ntoa(ip_addr);
|
||||
}
|
||||
|
||||
int is_interface_exist(const char *ifname)
|
||||
{
|
||||
int sockfd;
|
||||
struct ifreq ifreq;
|
||||
int if_exist = 1;
|
||||
|
||||
if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(ifreq.ifr_name, ifname, IFNAMSIZ);
|
||||
if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0) {
|
||||
if_exist = 0;
|
||||
}
|
||||
|
||||
close(sockfd);
|
||||
|
||||
return if_exist;
|
||||
}
|
||||
|
||||
int is_interface_up(const char *ifname)
|
||||
{
|
||||
int sockfd;
|
||||
@@ -2583,11 +2614,9 @@ has_wan_ip(void)
|
||||
return 0;
|
||||
|
||||
if(get_usb_modem_state()){
|
||||
#ifdef RTCONFIG_USB_MODEM_WIMAX
|
||||
if(nvram_match("modem_enable", "4"))
|
||||
strncpy(ifr.ifr_name, WIMAX_INTERFACE, IFNAMSIZ);
|
||||
strncpy(ifr.ifr_name, LTE_INTERFACE, IFNAMSIZ);
|
||||
else
|
||||
#endif
|
||||
strncpy(ifr.ifr_name, "ppp0", IFNAMSIZ);
|
||||
}
|
||||
else
|
||||
@@ -2821,15 +2850,13 @@ found_default_route(void)
|
||||
if (found)
|
||||
{
|
||||
if(get_usb_modem_state()){
|
||||
#ifdef RTCONFIG_USB_MODEM_WIMAX
|
||||
if(nvram_match("modem_enable", "4")){
|
||||
if(!strcmp(WIMAX_INTERFACE, device))
|
||||
if(!strcmp(LTE_INTERFACE, device))
|
||||
return 1;
|
||||
else
|
||||
goto no_default_route;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if(!strcmp("ppp0", device))
|
||||
return 1;
|
||||
|
||||
@@ -148,6 +148,7 @@ int preset_wan_routes(char *ifname);
|
||||
void safe_remove_usb_modem(void);
|
||||
void flush_conntrack_caches(void);
|
||||
void flush_route_caches(void);
|
||||
int is_module_loaded(char *module_name);
|
||||
int is_hwnat_allow(void);
|
||||
int is_hwnat_loaded(void);
|
||||
int is_fastnat_allow(void);
|
||||
@@ -161,6 +162,7 @@ int is_physical_wan_dhcp(void);
|
||||
void start_mac_clone(void);
|
||||
void dumparptable(void);
|
||||
int has_wan_ip(void);
|
||||
int is_interface_exist(const char *ifname);
|
||||
int is_phyconnected(void);
|
||||
int found_default_route(void);
|
||||
|
||||
|
||||
@@ -844,11 +844,13 @@ void manual_wan_disconnect(void)
|
||||
logmessage("wan", "perform manual disconnect");
|
||||
|
||||
if (get_usb_modem_state()){
|
||||
stop_wan_ppp();
|
||||
if(nvram_match("modem_enable", "4"))
|
||||
release_udhcpc_wan(0);
|
||||
else
|
||||
stop_wan_ppp();
|
||||
}
|
||||
else
|
||||
if (nvram_match("wan0_proto", "dhcp") ||
|
||||
nvram_match("wan0_proto", "bigpond"))
|
||||
if (nvram_match("wan0_proto", "dhcp"))
|
||||
{ /* dhcp */
|
||||
logmessage("service_handle", "perform DHCP release");
|
||||
release_udhcpc_wan(0);
|
||||
|
||||
@@ -176,7 +176,9 @@ deconfig(char *wan_ifname, int is_zcip)
|
||||
{
|
||||
char *client_info = (is_zcip) ? "zeroconf client" : "dhcp client";
|
||||
|
||||
if (nvram_match("wan0_proto", "l2tp") || nvram_match("wan0_proto", "pptp"))
|
||||
int unit = wan_ifunit(wan_ifname);
|
||||
|
||||
if ( (unit < 0) && (nvram_match("wan0_proto", "l2tp") || nvram_match("wan0_proto", "pptp")))
|
||||
{
|
||||
/* fix hang-up issue */
|
||||
logmessage("dhcp client", "skipping resetting IP address to 0.0.0.0");
|
||||
@@ -185,7 +187,7 @@ deconfig(char *wan_ifname, int is_zcip)
|
||||
{
|
||||
ifconfig(wan_ifname, IFUP, "0.0.0.0", NULL);
|
||||
|
||||
if (wan_ifunit(wan_ifname) < 0)
|
||||
if (unit < 0)
|
||||
{
|
||||
nvram_set("wanx_ipaddr", "0.0.0.0");
|
||||
}
|
||||
|
||||
@@ -1711,7 +1711,7 @@ is_ready_modem_3g(void)
|
||||
int
|
||||
is_ready_modem_4g(void)
|
||||
{
|
||||
if ( is_usb_modem_ready() && pids("madwimax") )
|
||||
if ( is_usb_modem_ready() && is_interface_exist(LTE_INTERFACE) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1719,7 +1719,6 @@ is_ready_modem_4g(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
stop_modem_3g(void)
|
||||
{
|
||||
@@ -1756,12 +1755,16 @@ stop_modem_3g(void)
|
||||
void
|
||||
stop_modem_4g(void)
|
||||
{
|
||||
ifconfig(LTE_INTERFACE, 0, "0.0.0.0", NULL);
|
||||
|
||||
system("killall -q usb_modeswitch");
|
||||
system("killall -q sdparm");
|
||||
|
||||
system("killall -q madwimax");
|
||||
|
||||
unlink(USB_MODESWITCH_CONF);
|
||||
|
||||
if (is_module_loaded("rndis_host")) {
|
||||
system("modprobe -r rndis_host");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2862,23 +2865,11 @@ int asus_usb_interface(const char *device_name, const char *action){
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef RTCONFIG_USB_MODEM_WIMAX
|
||||
if( (!strcmp(vid, "04e8") && !strcmp(pid, "6761")) ||
|
||||
(!strcmp(vid, "04e9") && !strcmp(pid, "6761")) ||
|
||||
(!strcmp(vid, "04e8") && !strcmp(pid, "6731")) ||
|
||||
(!strcmp(vid, "04e8") && !strcmp(pid, "6780")) ){
|
||||
usb_dbg("(%s): Runing WiMAX...\n", device_name);
|
||||
system("madwimax &");
|
||||
}
|
||||
else
|
||||
#endif // RTCONFIG_USB_MODEM_WIMAX
|
||||
{
|
||||
usb_dbg("(%s): Runing USB serial...\n", device_name);
|
||||
sleep(1);
|
||||
system("modprobe -q usbserial");
|
||||
sprintf(modem_cmd, "modprobe -q option vendor=0x%s product=0x%s", vid, pid);
|
||||
system(modem_cmd);
|
||||
}
|
||||
usb_dbg("(%s): Runing USB serial...\n", device_name);
|
||||
sleep(1);
|
||||
system("modprobe -q usbserial");
|
||||
sprintf(modem_cmd, "modprobe -q option vendor=0x%s product=0x%s", vid, pid);
|
||||
system(modem_cmd);
|
||||
}
|
||||
else{ // isACMInterface(device_name)
|
||||
usb_dbg("(%s): Runing USB ACM...\n", device_name);
|
||||
|
||||
@@ -109,9 +109,7 @@ function show_3G_modem_list(){
|
||||
, "ZTE-MF626"
|
||||
, "ZTE-MF632"
|
||||
, "ZTE-MF112"
|
||||
// *** Changes by Padavan ***
|
||||
, "ZTE-MF180"
|
||||
// *** Changes by Padavan ***
|
||||
, "ZTE-MFK3570-Z"
|
||||
, "CS15"
|
||||
, "CS17"
|
||||
@@ -129,8 +127,7 @@ function show_3G_modem_list(){
|
||||
function show_4G_modem_list(){
|
||||
modemlist = new Array(
|
||||
"AUTO"
|
||||
, "Samsung U200"
|
||||
//, "Beceem BCMS250"
|
||||
, "YOTA Modem"
|
||||
);
|
||||
|
||||
free_options($("shown_modems"));
|
||||
@@ -142,8 +139,6 @@ function show_4G_modem_list(){
|
||||
}
|
||||
|
||||
function switch_modem_mode(mode){
|
||||
//if(mode != "0" && $("hsdpa_hint").style.display == "none")
|
||||
// alert("<#HSDPA_LANtoWAN#>");
|
||||
|
||||
show_modem_list(mode);
|
||||
|
||||
@@ -156,8 +151,6 @@ function switch_modem_mode(mode){
|
||||
document.form.modem_dialnum.disabled = false;
|
||||
document.form.modem_user.disabled = false;
|
||||
document.form.modem_pass.disabled = false;
|
||||
//$("hsdpa_hint").style.display = "";
|
||||
$("ttlsid_x").style.display = "none";
|
||||
$("tty_node_x").style.display = "";
|
||||
$("port_speed_x").style.display = "";
|
||||
}
|
||||
@@ -170,8 +163,6 @@ function switch_modem_mode(mode){
|
||||
document.form.modem_dialnum.disabled = false;
|
||||
document.form.modem_user.disabled = false;
|
||||
document.form.modem_pass.disabled = false;
|
||||
//$("hsdpa_hint").style.display = "";
|
||||
$("ttlsid_x").style.display = "none";
|
||||
$("tty_node_x").style.display = "";
|
||||
$("port_speed_x").style.display = "";
|
||||
}
|
||||
@@ -184,8 +175,6 @@ function switch_modem_mode(mode){
|
||||
document.form.modem_dialnum.disabled = false;
|
||||
document.form.modem_user.disabled = false;
|
||||
document.form.modem_pass.disabled = false;
|
||||
//$("hsdpa_hint").style.display = "";
|
||||
$("ttlsid_x").style.display = "none";
|
||||
$("tty_node_x").style.display = "";
|
||||
$("port_speed_x").style.display = "";
|
||||
}
|
||||
@@ -196,10 +185,8 @@ function switch_modem_mode(mode){
|
||||
document.form.modem_apn.disabled = true;
|
||||
document.form.wan_3g_pin.disabled = true;
|
||||
document.form.modem_dialnum.disabled = true;
|
||||
document.form.modem_user.disabled = false;
|
||||
document.form.modem_pass.disabled = false;
|
||||
//$("hsdpa_hint").style.display = "";
|
||||
$("ttlsid_x").style.display = "";
|
||||
document.form.modem_user.disabled = true;
|
||||
document.form.modem_pass.disabled = true;
|
||||
$("tty_node_x").style.display = "none";
|
||||
$("port_speed_x").style.display = "none";
|
||||
}
|
||||
@@ -212,8 +199,6 @@ function switch_modem_mode(mode){
|
||||
document.form.modem_dialnum.disabled = true;
|
||||
document.form.modem_user.disabled = true;
|
||||
document.form.modem_pass.disabled = true;
|
||||
//$("hsdpa_hint").style.display = "none";
|
||||
$("ttlsid_x").style.display = "none";
|
||||
$("tty_node_x").style.display = "none";
|
||||
$("port_speed_x").style.display = "none";
|
||||
}
|
||||
@@ -311,7 +296,6 @@ function applyRule(){
|
||||
var mode = document.form.modem_enable.value;
|
||||
|
||||
if(document.form.modem_enable.value != "0"){
|
||||
//if(confirm("<#HSDPA_enable_confirm#>")){
|
||||
showLoading();
|
||||
|
||||
document.form.action_mode.value = " Apply ";
|
||||
@@ -319,7 +303,6 @@ function applyRule(){
|
||||
document.form.next_page.value = "";
|
||||
|
||||
document.form.submit();
|
||||
//}
|
||||
}
|
||||
else{
|
||||
showLoading();
|
||||
@@ -402,10 +385,8 @@ function done_validating(action){
|
||||
<option value="1" <% nvram_match_x("General", "modem_enable", "1", "selected"); %>>WCDMA (UMTS)</option>
|
||||
<option value="2" <% nvram_match_x("General", "modem_enable", "2", "selected"); %>>CDMA2000 (EVDO)</option>
|
||||
<option value="3" <% nvram_match_x("General", "modem_enable", "3", "selected"); %>>TD-SCDMA</option>
|
||||
<option value="4" <% nvram_match_x("General", "modem_enable", "4", "selected"); %>>WiMAX</option>
|
||||
<option value="4" <% nvram_match_x("General", "modem_enable", "4", "selected"); %>>LTE 4G</option>
|
||||
</select>
|
||||
|
||||
<br/><span id="hsdpa_hint" style="display:none;"><#HSDPAConfig_hsdpa_enable_hint1#></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -457,12 +438,6 @@ function done_validating(action){
|
||||
<input id="modem_pass" name="modem_pass" class="input" onClick="openHint(21,12);" type="password" value="<% nvram_get_x("", "modem_pass"); %>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="ttlsid_x">
|
||||
<th>E-mail</th>
|
||||
<td>
|
||||
<input id="modem_ttlsid" name="modem_ttlsid" class="input" value="<% nvram_get_x("", "modem_ttlsid"); %>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="tty_node_x">
|
||||
<th><#COM_Port_Node#></th>
|
||||
<td>
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
<script type="text/javascript" src="/popup.js"></script>
|
||||
<script type="text/javascript" src="/help.js"></script>
|
||||
<script type="text/javascript" src="/detect.js"></script>
|
||||
<script type="text/javascript" src="/wcdma_list.js"></script>
|
||||
<script type="text/javascript" src="/cdma2000_list.js"></script>
|
||||
<script type="text/javascript" src="/td-scdma_list.js"></script>
|
||||
<script type="text/javascript" src="/wimax_list.js"></script>
|
||||
<script>
|
||||
wan_route_x = '<% nvram_get_x("IPConnection", "wan_route_x"); %>';
|
||||
wan_nat_x = '<% nvram_get_x("IPConnection", "wan_nat_x"); %>';
|
||||
|
||||
@@ -45,16 +45,6 @@ function initial(){
|
||||
|
||||
change_nat(sw_mode);
|
||||
|
||||
$("wan_proto_menu").style.display = (wan_proto == "3g")?"none":"block";
|
||||
$("wan_proto_hint").style.display = (wan_proto == "3g")?"block":"none";
|
||||
if(wan_proto == "3g"){
|
||||
$("ip_sect").style.display = "none";
|
||||
$("dns_sect").style.display = "none";
|
||||
$("account_sect").style.display = "none";
|
||||
$("isp_sect").style.display = "none";
|
||||
$("wan_stb_x").style.display = "none";
|
||||
}
|
||||
|
||||
ISPSelection(document.form.vlan_isp.value);
|
||||
AuthSelection(document.form.wan_auth_mode.value);
|
||||
}
|
||||
@@ -447,10 +437,6 @@ function change_wan_dhcp_enable(flag){
|
||||
}
|
||||
}
|
||||
|
||||
function hsdpa_disable(){
|
||||
location.href = "/Advanced_Modem_others.asp";
|
||||
}
|
||||
|
||||
function ISPSelection(isp){
|
||||
var wan_type = document.form.wan_proto.value;
|
||||
|
||||
@@ -667,14 +653,13 @@ function simplyMAC(fullMAC){
|
||||
<tr>
|
||||
<th width="30%"><#Layer3Forwarding_x_ConnectionType_itemname#></th>
|
||||
<td align="left">
|
||||
<select id="wan_proto_menu" class="input" name="wan_proto" onchange="change_wan_type(this.value);fixed_change_wan_type(this.value);">
|
||||
<select class="input" name="wan_proto" onchange="change_wan_type(this.value);fixed_change_wan_type(this.value);">
|
||||
<option value="static" <% nvram_match_x("Layer3Forwarding", "wan_proto", "static", "selected"); %>><#BOP_ctype_title5#></option>
|
||||
<option value="dhcp" <% nvram_match_x("Layer3Forwarding", "wan_proto", "dhcp", "selected"); %>><#BOP_ctype_title1#></option>
|
||||
<option value="pppoe" <% nvram_match_x("Layer3Forwarding", "wan_proto", "pppoe", "selected"); %>>PPPoE</option>
|
||||
<option value="pptp" <% nvram_match_x("Layer3Forwarding", "wan_proto", "pptp", "selected"); %>>PPTP</option>
|
||||
<option value="l2tp" <% nvram_match_x("Layer3Forwarding", "wan_proto", "l2tp", "selected"); %>>L2TP</option>
|
||||
</select>
|
||||
<span style="font-weight:normal;" id="wan_proto_hint"><span style="color:#000;font-size:14px;">3G/3.5G</span><input class="button" onclick="hsdpa_disable();" type="button" value="<#Disconnected#>"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -11,10 +11,7 @@ var restart_time;
|
||||
var wan_proto = "<% nvram_get_x("", "wan_proto"); %>";
|
||||
|
||||
function restart_needed_time(second){
|
||||
if(wan_proto == "3g" && "<% detect_if_wan(); %>" == "1")
|
||||
restart_time = 60;
|
||||
else
|
||||
restart_time = second;
|
||||
restart_time = second;
|
||||
}
|
||||
|
||||
function Callback(){
|
||||
|
||||
@@ -693,11 +693,7 @@ function show_menu(L1, L2, L3){
|
||||
|
||||
menuL2_link[1] = tablink[0][1];
|
||||
menuL2_link[6] = tablink[5][1];
|
||||
|
||||
}
|
||||
if(wan_proto == "3g"){
|
||||
tablink[0].splice(3,1);//WPS
|
||||
tabtitle[0].splice(3,1);//WPS
|
||||
|
||||
}
|
||||
|
||||
for(i = 1; i <= menuL1_title.length-1; i++){
|
||||
|
||||
@@ -703,10 +703,6 @@ function show_menu(L1, L2, L3){
|
||||
menuL2_link[6] = tablink[5][1];
|
||||
|
||||
}
|
||||
if(wan_proto == "3g"){
|
||||
tablink[0].splice(3,1);//WPS
|
||||
tabtitle[0].splice(3,1);//WPS
|
||||
}
|
||||
|
||||
for(i = 1; i <= menuL1_title.length-1; i++){
|
||||
if(menuL1_title[i] == "")
|
||||
|
||||
Reference in New Issue
Block a user