void ej_exec_milkfish_service(webs_t wp, int argc, char_t ** argv) { FILE *fp; char line[254]; char *request; #ifdef FASTWEB ejArgs(argc, argv, "%s", &request); #else if (ejArgs(argc, argv, "%s", &request) < 1) { websError(wp, 400, "Insufficient args\n"); } #endif if ((fp = popen(request, "r"))) { while (fgets(line, sizeof(line), fp) != NULL) { websWrite(wp, line); websWrite(wp, "<br>"); } pclose(fp); } return; }
int ej_get_isp_list(int eid, webs_t wp, int argc, char_t **argv){ char *name; FILE* fpIsp; char bufIsp[512]; if (ejArgs(argc, argv, "%s", &name) < 1) { websError(wp, 400, "Insufficient args\n"); return -1; } fpIsp = fopen(name,"r"); if (fpIsp != NULL) { // read out UTF-8 3 bytes header fread(bufIsp,3,1,fpIsp); while(!feof(fpIsp)) { char* ret_fgets; ret_fgets = fgets(bufIsp,sizeof(bufIsp),fpIsp); if (ret_fgets != NULL) { websWrite(wp, bufIsp); websWrite(wp, "\n"); } } fclose(fpIsp); } return 0; }
static int aspTest(int eid, webs_t wp, int argc, char_t **argv) { char_t *name, *address; if (ejArgs(argc, argv, T("%s %s"), &name, &address) < 2) { websError(wp, 400, T("Insufficient args\n")); return -1; } return websWrite(wp, T("Name: %s, Address %s"), name, address); }
int ej_wlv_sec_show_setting(int eid, INPUT *input, int argc, char_t **argv) { char buf_sec[TMP_LEN], buf_if[TMP_LEN], buf_vif[TMP_LEN]; int if_idx, vif_idx, num; char *secmode = NULL; INPUT *tmp; /* Get physical interface index */ if (ejArgs(argc, argv, "%d %d", &if_idx, &vif_idx) < 2) { FCGI_LOG("Insufficient args"); return FALSE; } num = atoi(nvram_safe_get("wlv_rule_num")); /* Get security mode rule */ snprintf(buf_if, TMP_LEN, "wl%d_ssid%d_secmode" , if_idx, vif_idx); if ((tmp = CGI_Find_Parameter(input, buf_if))) { secmode = tmp->val; } if (!secmode || !*secmode) { snprintf(buf_if, TMP_LEN, "wl%d_sec_rule", if_idx); ezplib_get_attr_val(buf_if, vif_idx, "secmode", buf_sec, TMP_LEN, EZPLIB_USE_CLI); } else{ sprintf(buf_sec, "%s", secmode); } /*---------------- buf_sec : security mode buf_if : interface index buf_vif : ssid index -----------------*/ snprintf(buf_if, TMP_LEN, "%d", if_idx); snprintf(buf_vif, TMP_LEN, "%d", vif_idx); if (!strcmp(buf_sec, "wep")) { do_ej("wlv_sec_wep.asp", input, buf_if, buf_vif, ""); } else if (!strcmp(buf_sec, "psk")) { do_ej("wlv_sec_psk.asp", input, buf_if, buf_vif, ""); } else if (!strcmp(buf_sec, "wpa")) { do_ej("wlv_sec_wpa.asp", input, buf_if, buf_vif, ""); } else if (!strcmp(buf_sec, "psk2")) { do_ej("wlv_sec_psk2.asp", input, buf_if, buf_vif, ""); } else if (!strcmp(buf_sec, "wpa2")) { do_ej("wlv_sec_wpa2.asp", input, buf_if, buf_vif, ""); } if (appmgr_check("guest_lan") && ( vif_idx == num - 1 )) { do_ej("guest_lan_setting.asp", input, buf_if, buf_vif, ""); } return 0; }
void ej_get_url(webs_t wp, int argc, char_t ** argv) { char *type; if (ejArgs(argc, argv, "%s", &type) < 1) { websError(wp, 400, "Insufficient args\n"); return; } websWrite(wp, "%s", "Invalid argument\n"); }
void ej_show_sysinfo(webs_t wp, int argc, char_t ** argv) { char *type; ejArgs(argc, argv, "%s", &type); if (type && !strcmp(type, "other")) show_other_info(wp); else show_default_info(wp); return; }
void ej_get_clone_mac(webs_t wp, int argc, char_t ** argv) { char *c; int mac, which; int dofree = 0; #ifdef FASTWEB ejArgs(argc, argv, "%d", &which); #else if (ejArgs(argc, argv, "%d", &which) < 1) { websError(wp, 400, "Insufficient args\n"); } #endif if (nvram_match("clone_wan_mac", "1")) c = nvram_safe_get("http_client_mac"); else { if (nvram_match("def_hwaddr", "00:00:00:00:00:00")) { if (nvram_match("port_swap", "1")) c = strdup(nvram_safe_get("et1macaddr")); else c = strdup(nvram_safe_get("et0macaddr")); if (c) { MAC_ADD(c); dofree = 1; } } else c = nvram_safe_get("def_hwaddr"); } if (c) { mac = get_single_mac(c, which); websWrite(wp, "%02X", mac); if (dofree) free(c); } else websWrite(wp, "00"); }
static int getCount(int eid, webs_t wp, int argc, char_t **argv) { int type; char_t *field; char count[3]; if (2 > ejArgs(argc, argv, T("%d %s"), &type, &field)) { return websWrite(wp, T("Insufficient args\n")); } if (0 == strcmp(field, "AllDir")) { sprintf(count, "%d", dir_count); // fprintf(stderr,"AllDir: %s\n", count); } else if (0 == strcmp(field, "AllPart")) { sprintf(count, "%d", part_count); // fprintf(stderr,"AllPart: %s\n", count); } #if defined CONFIG_USER_SAMBA && (defined CONFIG_USB || defined CONFIG_MMC) else if (0 == strcmp(field, "AllSmbDir")) { sprintf(count, "%d", smb_conf.count); // fprintf(stderr,"AllSmbDir: %s\n", count); } #endif else if (0 == strcmp(field, "AllMediaDir")) { sprintf(count, "%d", media_dir_count); // fprintf(stderr,"AllPart: %s\n", count); } if (1 == type) { if (!strcmp(count, "")) return websWrite(wp, T("0")); return websWrite(wp, T("%s"), count); } if (!strcmp(count, "")) ejSetResult(eid, "0"); ejSetResult(eid, count); return 0; }
int ej_do_print_end(int eid, webs_t wp, int argc, char_t ** argv) { char *str; int level, cur_level; if (ejArgs(argc, argv, "%s", &str) < 1) { websError(wp, 400, "Insufficient args\n"); return -1; } sscanf(str, "EZP_PRODUCT_LEVEL_%d", &level); str = nvram_safe_get("prod_level"); if (!*str) cur_level = 1; cur_level = atoi(str); if (cur_level < level) { ej_print = 1; } return 0; }
int ej_show_sysinfo(int eid, webs_t wp, int argc, char_t ** argv) { char *type; char result[2048]; int retval = 0; struct sysinfo sys; char *tmp; strcpy(result,"None"); if (ejArgs(argc, argv, "%s", &type) < 1) { websError(wp, 400, "Insufficient args\n"); return retval; } if (type) { if (strcmp(type,"cpu.model") == 0) { char *buffer = read_whole_file("/proc/cpuinfo"); if (buffer) { tmp = strstr(buffer, "system type"); if (tmp) sscanf(tmp, "system type : %[^\n]", result); free(buffer); } } else if(strcmp(type,"cpu.freq") == 0) { tmp = nvram_get("clkfreq"); if (tmp) sscanf(tmp,"%[^,]s", result); } else if(strcmp(type,"memory.total") == 0) { sysinfo(&sys); sprintf(result,"%.2f",(sys.totalram/(float)MBYTES)); } else if(strcmp(type,"memory.free") == 0) { sysinfo(&sys); sprintf(result,"%.2f",(sys.freeram/(float)MBYTES)); } else if(strcmp(type,"memory.buffer") == 0) { sysinfo(&sys); sprintf(result,"%.2f",(sys.bufferram/(float)MBYTES)); } else if(strcmp(type,"memory.swap.total") == 0) { sysinfo(&sys); sprintf(result,"%.2f",(sys.totalswap/(float)MBYTES)); } else if(strcmp(type,"memory.swap.used") == 0) { sysinfo(&sys); sprintf(result,"%.2f",((sys.totalswap - sys.freeswap) / (float)MBYTES)); } else if(strcmp(type,"cpu.load.1") == 0) { sysinfo(&sys); sprintf(result,"%.2f",(sys.loads[0] / (float)(1<<SI_LOAD_SHIFT))); } else if(strcmp(type,"cpu.load.5") == 0) { sysinfo(&sys); sprintf(result,"%.2f",(sys.loads[1] / (float)(1<<SI_LOAD_SHIFT))); } else if(strcmp(type,"cpu.load.15") == 0) { sysinfo(&sys); sprintf(result,"%.2f",(sys.loads[2] / (float)(1<<SI_LOAD_SHIFT))); } else if(strcmp(type,"nvram.total") == 0) { sprintf(result,"%d",NVRAM_SPACE); } else if(strcmp(type,"nvram.used") == 0) { char *buf; int size = 0; buf = malloc(NVRAM_SPACE); if (buf) { nvram_getall(buf, NVRAM_SPACE); tmp = buf; while (*tmp) tmp += strlen(tmp) +1; size = sizeof(struct nvram_header) + (int) tmp - (int) buf; free(buf); } sprintf(result,"%d",size); } else if(strcmp(type,"jffs.usage") == 0) { struct statvfs fiData; char *mount_info = read_whole_file("/proc/mounts"); if ((mount_info) && (strstr(mount_info, "/jffs")) && (statvfs("/jffs",&fiData) == 0 )) { sprintf(result,"%.2f / %.2f MB",((fiData.f_blocks-fiData.f_bfree) * fiData.f_frsize / (float)MBYTES) ,(fiData.f_blocks * fiData.f_frsize / (float)MBYTES)); } else { strcpy(result,"<i>Unmounted</i>"); } if (mount_info) free(mount_info); } else if(strncmp(type,"temperature",11) == 0) { unsigned int temperature; int radio=0; sscanf(type,"temperature.%d", &radio); temperature = get_phy_temperature(radio); if (temperature == 0) strcpy(result,"<i>disabled</i>"); else sprintf(result,"%u°C", temperature); } else if(strcmp(type,"conn.total") == 0) { FILE* fp; fp = fopen ("/proc/sys/net/ipv4/netfilter/ip_conntrack_count", "r"); if (fp) { if (fgets(result, sizeof(result), fp) != NULL) { fclose(fp); } } } else if(strcmp(type,"conn.active") == 0) { char buf[256]; FILE* fp; unsigned int established = 0; fp = fopen("/proc/net/nf_conntrack", "r"); if (fp) { while (fgets(buf, sizeof(buf), fp) != NULL) { if (strstr(buf,"ESTABLISHED") || ((strstr(buf,"udp")) && (strstr(buf,"ASSURED")))) established++; } fclose(fp); } sprintf(result,"%u",established); } else if(strcmp(type,"conn.max") == 0) { FILE* fp; fp = fopen ("/proc/sys/net/ipv4/netfilter/ip_conntrack_max", "r"); if (fp) { if (fgets(result, sizeof(result), fp) != NULL) { fclose(fp); } } } else if(strncmp(type,"conn.wifi",9) == 0) { int count, radio; char command[10]; sscanf(type,"conn.wifi.%d.%9s", &radio, command); if (strcmp(command,"autho") == 0) { count = get_wifi_clients(radio,SI_WL_QUERY_AUTHO); } else if (strcmp(command,"authe") == 0) { count = get_wifi_clients(radio,SI_WL_QUERY_AUTHE); } else if (strcmp(command,"assoc") == 0) { count = get_wifi_clients(radio,SI_WL_QUERY_ASSOC); } else { count = 0; } if (count == -1) strcpy(result,"<i>off</i>"); else sprintf(result,"%d",count); } else if(strcmp(type,"driver_version") == 0 ) { system("/usr/sbin/wl ver >/tmp/output.txt"); char *buffer = read_whole_file("/tmp/output.txt"); if (buffer) { if (tmp = strstr(buffer, "\n")) strncpy(result, tmp+1, sizeof result); else strncpy(result, buffer, sizeof result); free(buffer); unlink("/tmp/output.txt"); } } else if(strncmp(type,"pid",3) ==0 ) { char service[32]; sscanf(type, "pid.%31s", service); if (strlen(service)) sprintf(result, "%d", pidof(service)); } else if(strncmp(type,"vpnstatus",9) == 0 ) { int num = 0; char service[10], buf[256]; sscanf(type,"vpnstatus.%9[^.].%d", service, &num); if ( strlen(service) && (num > 0) ) { // Trigger OpenVPN to update the status file snprintf(buf, sizeof(buf), "vpn%s%d", service, num); killall(buf, SIGUSR2); // Give it a chance to update the file sleep(1); // Read the status file and repeat it verbatim to the caller sprintf(buf,"/etc/openvpn/%s%d/status", service, num); char *buffer = read_whole_file(buf); if (buffer) { strncpy(result, buffer, sizeof(result)); free(buffer); } } } else { strcpy(result,"Not implemented"); } } retval += websWrite(wp, result); return retval; }
int asp_voip_getInfo(int eid, webs_t wp, int argc, char_t **argv) #endif { char_t *name; int i; /*+++added by Jack for auto configuration+++*/ voipCfgParam_t *pVoIPCfg; if (web_flash_get(&pVoIPCfg) != 0) return -1; /*---end---*/ #ifdef CONFIG_APP_BOA if (argc != 1) { websWrite(wp, "Insufficient args %d\n", argc); return -1; } name = argv[0]; #else if (ejArgs(argc, argv, T("%s"), &name) < 1) { websError(wp, 400, T("Insufficient args\n")); return -1; } #endif if (strcmp(name, T("voip_status")) == 0) { return websWrite(wp, "<tr>" \ "<td width=100%% colspan=2 bgcolor=#008000><font color=#FFFFFF size=2><b>VoIP</b></font></td>" \ "</tr>" \ "<tr bgcolor=#DDDDDD>" \ "<td width=40%%><font size=2><b>Version</b></td>" \ "<td width=60%%><font size=2>%s</td>" \ "</tr>" \ /*+++added by Jack for auto configuration+++*/ "<tr bgcolor=#DDDDDD>" \ "<td width=40%%><font size=2><b>Flash Version</b></td>" \ "<td width=60%%><font size=2>%d.%d</td>" \ "</tr>" \ "<tr bgcolor=#DDDDDD>" \ "<td width=40%%><font size=2><b>Autoconfig Version</b></td>" \ "<td width=60%%><font size=2>%d</td>" \ "</tr>" \ "<tr bgcolor=#DDDDDD>" \ "<td width=40%%><font size=2><b>Firmware upgrade Version</b></td>" \ "<td width=60%%><font size=2>%s</td>" \ /*---end---*/ "</tr>", voipVersion, CURRENT_SETTING_VER, VOIP_FLASH_VER, pVoIPCfg->auto_cfg_ver, pVoIPCfg->fw_update_fw_version); } else if (strcmp(name, T("voip_menu")) == 0) { websWrite(wp,"document.write('" \ "<tr><td><b>VoIP Settings</b></td></tr>"); for (i=0; i<g_VoIP_Ports; i++) { if (g_VoIP_Ports == 1) websWrite(wp, "<tr><td><a href=voip_general.asp?port=0 target=view>General</a></td></tr>"); else if (RTK_VOIP_IS_DECT_CH( i, g_VoIP_Feature )) websWrite(wp, "<tr><td><a href=voip_general.asp?port=%d target=view>DECT %d</a></td></tr>", i, i - RTK_VOIP_DECT_CH_OFFSET( g_VoIP_Feature ) ); else if (RTK_VOIP_IS_SLIC_CH( i, g_VoIP_Feature )) websWrite(wp, "<tr><td><a href=voip_general.asp?port=%d target=view>FXS %d</a></td></tr>", i, i - RTK_VOIP_SLIC_CH_OFFSET( g_VoIP_Feature ) ); else websWrite(wp, "<tr><td><a href=voip_general.asp?port=%d target=view>FXO %d</a></td></tr>", i, i - RTK_VOIP_DAA_CH_OFFSET( g_VoIP_Feature ) ); } #ifdef CONFIG_RTK_VOIP_IP_PHONE return websWrite(wp, "<tr><td><a href=voip_tone.asp target=view>Tone</a></td></tr>" \ "<tr><td><a href=voip_config.asp target=view>Config</a></td></tr>" \ "')"); #else return websWrite(wp, "<tr><td><a href=voip_tone.asp target=view>Tone</a></td></tr>" \ "<tr><td><a href=voip_ring.asp target=view>Ring</a></td></tr>" \ "<tr><td><a href=voip_other.asp target=view>Other</a></td></tr>" \ "<tr><td><a href=voip_config.asp target=view>Config</a></td></tr>" \ "')"); #endif } else if (strcmp(name, T("voip_tree_menu")) == 0) { websWrite(wp, "menu.addItem('VoIP Settings');" \ "voip = new MTMenu();"); for (i=0; i<g_VoIP_Ports; i++) { if (g_VoIP_Ports == 1) websWrite(wp, "voip.addItem('General', 'voip_general.asp?port=0', '', 'Setup General settings');"); else if (RTK_VOIP_IS_DECT_CH( i, g_VoIP_Feature )) websWrite(wp, "voip.addItem('DECT %d', 'voip_general.asp?port=%d', '', 'Setup DECT%d settings');", i - RTK_VOIP_DECT_CH_OFFSET( g_VoIP_Feature ), i, i); else if (RTK_VOIP_IS_SLIC_CH( i, g_VoIP_Feature )) websWrite(wp, "voip.addItem('FXS %d', 'voip_general.asp?port=%d', '', 'Setup FXS%d settings');", i - RTK_VOIP_SLIC_CH_OFFSET( g_VoIP_Feature ), i, i); else websWrite(wp, "voip.addItem('FXO %d', 'voip_general.asp?port=%d', '', 'Setup FXO%d settings');", i - RTK_VOIP_DAA_CH_OFFSET( g_VoIP_Feature ), i, i); } #ifdef CONFIG_RTK_VOIP_IP_PHONE return websWrite(wp, "voip.addItem('Tone', 'voip_tone.asp', '', 'Setup Tone settings');" \ "voip.addItem('Config', 'voip_config.asp', '', 'Config settings');" \ "voip.addItem('Network', 'voip_network.asp', '', 'Setup Network Settings');" \ "menu.makeLastSubmenu(voip);"); #else return websWrite(wp, "voip.addItem('Tone', 'voip_tone.asp', '', 'Setup Tone settings');" \ "voip.addItem('Ring', 'voip_ring.asp', '', 'Setup Ring settings');" \ "voip.addItem('Other', 'voip_other.asp', '', 'Setup Other settings');" \ "voip.addItem('Config', 'voip_config.asp', '', 'Config settings');" \ "voip.addItem('Network', 'voip_network.asp', '', 'Setup Network Settings');" \ "menu.makeLastSubmenu(voip);"); #endif } return -1; }
void ej_sputnik_apd_status(webs_t wp, int argc, char_t ** argv) { char *key; FILE *fh; #ifdef FASTWEB ejArgs(argc, argv, "%s", &key); #else if (ejArgs(argc, argv, "%s", &key) < 1) { websError(wp, 400, "Insufficient args\n"); return; } #endif if ((fh = fopen("/var/run/apd.status", "r"))) { char s[128]; /* * The first line is always the PPID. If it doesn't exist, apd * isn't running. */ if (fgets(s, sizeof(s), fh)) { int apd_pid = (pid_t) atol(s); if (!kill(apd_pid, 0)) { if (!strcmp(key, "pid")) { websWrite(wp, "%d", apd_pid); } else { /* * We're good, read the rest. */ while (fgets(s, sizeof(s), fh)) { int len = strlen(s); char *eqloc; if (len > 0 && s[len - 1] == '\n') { s[len - 1] = '\0'; } if ((eqloc = index(s, '='))) { char *v; *eqloc = '\0'; v = eqloc + 1; if (!strcmp(key, s)) { websWrite(wp, "%s", v); break; } } } /* End while */ } } } fclose(fh); } return; } /* End ej_sputnik_apd_status() */
void ej_show_status(webs_t wp, int argc, char_t ** argv) { char *type; char *wan_proto = nvram_safe_get("wan_proto"); char *submit_type = websGetVar(wp, "submit_type", NULL); int wan_link = 0; char buf[254]; #ifdef HAVE_DSL_CPE_CONTROL if (argc > 0) { if (!strcmp(argv[0], "adsl")) { websWrite(wp, "{dsl_iface_status::%s}\n", nvram_get("dsl_iface_status")); websWrite(wp, "{dsl_datarate_ds::%11.2f}\n", atof(nvram_get("dsl_datarate_ds"))); websWrite(wp, "{dsl_datarate_us::%11.2f}\n", atof(nvram_get("dsl_datarate_us"))); websWrite(wp, "{dsl_snr_down::%d}\n", atoi(nvram_get("dsl_snr_down"))); websWrite(wp, "{dsl_snr_up::%d}\n", atoi(nvram_get("dsl_snr_up"))); } } #endif if (!strcmp(wan_proto, "pppoe") || !strcmp(wan_proto, "pptp") #ifdef HAVE_PPPOEDUAL || !strcmp(wan_proto, "pppoe_dual") #endif #ifdef HAVE_3G || !strcmp(wan_proto, "3g") #endif #ifdef HAVE_IPETH || !strcmp(wan_proto, "iphone") #endif #ifdef HAVE_PPPOATM || !strcmp(wan_proto, "pppoa") #endif #ifdef HAVE_L2TP || !strcmp(wan_proto, "l2tp") #endif || !strcmp(wan_proto, "heartbeat")) { /* * get type [ refresh | reload ] */ ejArgs(argc, argv, "%s", &type); /* * get ppp status , if /tmp/ppp/link exist, the connection is enabled */ wan_link = check_wan_link(0); if (!strcmp(type, "init")) { /* * press [ Connect | Disconnect ] button */ /* * set retry count */ if (nvram_match("gozila_action", "1")) retry_count = STATUS_RETRY_COUNT; // retry 3 times /* * set refresh time */ // submit_type old format is "Disconnect", new format is // "Disconnect_pppoe" or "Disconnect_pptp" or // "Disconnect_heartbeat" if (submit_type && !strncmp(submit_type, "Disconnect", 10)) // Disconnect // always // 60 // seconds // to // refresh retry_count = -1; refresh_time = (retry_count <= 0) ? STATUS_REFRESH_TIME2 : STATUS_REFRESH_TIME1; } else if (!strcmp(type, "refresh_time")) { websWrite(wp, "%d", refresh_time * 1000); } else if (!strcmp(type, "onload")) { if (retry_count == 0 || (!submit_type && !wan_link && nvram_match("gozila_action", "1"))) { // After refresh 2 times, if the status is // disconnect, show Alert message. websWrite(wp, "ShowAlert(\"TIMEOUT\");"); retry_count = -1; } else if (file_to_buf("/tmp/ppp/log", buf, sizeof(buf))) { websWrite(wp, "ShowAlert(\"%s\");", buf); retry_count = -1; unlink("/tmp/ppp/log"); } else { websWrite(wp, "Refresh();"); } if (retry_count != -1) retry_count--; } } return; }
void ej_nvram_status_get(webs_t wp, int argc, char_t ** argv) { char *type; char *wan_ipaddr, *wan_netmask, *wan_gateway; char *status1 = "", *status2 = "", *hidden1, *hidden2, *button1 = ""; char *wan_proto = nvram_safe_get("wan_proto"); struct dns_lists *dns_list = NULL; int wan_link = check_wan_link(0); int trans = 0; ejArgs(argc, argv, "%s %d", &type, &trans); if (!strcmp(wan_proto, "pptp")) { wan_ipaddr = wan_link ? nvram_safe_get("pptp_get_ip") : nvram_safe_get("wan_ipaddr"); wan_netmask = wan_link ? nvram_safe_get("wan_netmask") : nvram_safe_get("wan_netmask"); wan_gateway = wan_link ? nvram_safe_get("wan_gateway") : nvram_safe_get("pptp_server_ip"); } else if (!strcmp(wan_proto, "pppoe") #ifdef HAVE_PPPOEDUAL || !strcmp(wan_proto, "pppoe_dual") #endif #ifdef HAVE_PPPOATM || !strcmp(wan_proto, "pppoa") #endif #ifdef HAVE_3G || !strcmp(wan_proto, "3g") #endif #ifdef HAVE_IPETH || !strcmp(wan_proto, "iphone") #endif ) { wan_ipaddr = wan_link ? nvram_safe_get("wan_ipaddr") : "0.0.0.0"; wan_netmask = wan_link ? nvram_safe_get("wan_netmask") : "0.0.0.0"; wan_gateway = wan_link ? nvram_safe_get("wan_gateway") : "0.0.0.0"; } #ifdef HAVE_L2TP else if (!strcmp(wan_proto, "l2tp")) { wan_ipaddr = wan_link ? nvram_safe_get("l2tp_get_ip") : nvram_safe_get("wan_ipaddr"); wan_netmask = wan_link ? nvram_safe_get("wan_netmask") : nvram_safe_get("wan_netmask"); wan_gateway = wan_link ? nvram_safe_get("wan_gateway") : nvram_safe_get("wan_gateway"); } #endif else { wan_ipaddr = nvram_safe_get("wan_ipaddr"); wan_gateway = nvram_safe_get("wan_gateway"); wan_netmask = nvram_safe_get("wan_netmask"); } dns_list = get_dns_list(); if (!strcmp(wan_proto, "pppoe") || !strcmp(wan_proto, "pptp") #ifdef HAVE_PPPOEDUAL || !strcmp(wan_proto, "pppoe_dual") #endif #ifdef HAVE_3G || !strcmp(wan_proto, "3g") #endif #ifdef HAVE_IPETH || !strcmp(wan_proto, "iphone") #endif #ifdef HAVE_PPPOATM || !strcmp(wan_proto, "pppoa") #endif #ifdef HAVE_L2TP || !strcmp(wan_proto, "l2tp") #endif || !strcmp(wan_proto, "heartbeat")) { hidden1 = ""; hidden2 = ""; if (wan_link == 0) { // submit_button old format is "Connect", new format is // "Connect_pppoe" or "Connect_pptp" or "Connect_heartbeat" // if(submit_type && !strncmp(submit_type,"Connect",7) && // retry_count != -1){ if (retry_count != -1) { status1 = "share.statu"; status2 = "share.connecting"; if (trans) button1 = "share.disconnect"; else button1 = "Disconnect"; } else { status1 = "share.statu"; status2 = "share.disconnected"; if (trans) button1 = "share.connect"; else button1 = "Connect"; } } else { retry_count = -1; status1 = "share.statu"; status2 = "share.connected"; if (trans) button1 = "share.disconnect"; else button1 = "Disconnect"; } } else { status1 = "share.disable"; // only for nonbrand status2 = " "; hidden1 = "<!--"; hidden2 = "-->"; } if (!strcmp(type, "wan_ipaddr")) { if (getWET() || !strcmp(wan_proto, "disabled")) { websWrite(wp, "%s", live_translate("share.disabled")); } else websWrite(wp, "%s", wan_ipaddr); } else if (!strcmp(type, "wan_netmask")) websWrite(wp, "%s", wan_netmask); else if (!strcmp(type, "wan_gateway")) websWrite(wp, "%s", wan_gateway); else if (!strcmp(type, "wan_dns0")) { if (dns_list) websWrite(wp, "%s", dns_list->dns_server[0]); } else if (!strcmp(type, "wan_dns1")) { if (dns_list) websWrite(wp, "%s", dns_list->dns_server[1]); } else if (!strcmp(type, "wan_dns2")) { if (dns_list) websWrite(wp, "%s", dns_list->dns_server[2]); } else if (!strcmp(type, "status1")) websWrite(wp, "%s", live_translate(status1)); else if (!strcmp(type, "status2")) websWrite(wp, "%s", live_translate(status2)); else if (!strcmp(type, "button1")) { if (trans) websWrite(wp, "%s", live_translate(button1)); else websWrite(wp, "%s", button1); } else if (!strcmp(type, "hidden1")) websWrite(wp, "%s", hidden1); else if (!strcmp(type, "hidden2")) websWrite(wp, "%s", hidden2); else if (!strcmp(type, "wan_3g_signal")) websWrite(wp, "-40 DBm"); if (dns_list) free(dns_list); return; }