int landhcp(void) { if (!getWET()) if (nvram_match("dhcp_dnsmasq", "1") && nvram_match("lan_proto", "dhcp") && nvram_match("dhcpfwd_enable", "0")) return 1; return 0; }
void start_ttraff(void) { if (!nvram_match("ttraff_enable", "1")) return; if ((nvram_match("ttraff_iface", "") || !nvram_get("ttraff_iface")) && (nvram_match("wan_proto", "disabled") || getWET())) return; pid_t pid; char *argv[] = { "ttraff", NULL }; int ret = _evalpid(argv, NULL, 0, &pid); dd_syslog(LOG_INFO, "ttraff : traffic counter daemon successfully started\n"); cprintf("done"); return; }
void start_dhcpfwd(void) { if (getWET()) // dont // start // any // dhcp // services // in // bridge // mode { nvram_set("lan_proto", "static"); return; } #ifdef HAVE_DHCPFORWARD FILE *fp; if (nvram_match("dhcpfwd_enable", "1")) { mkdir("/tmp/dhcp-fwd", 0700); mkdir("/var/run/dhcp-fwd", 0700); fp = fopen("/tmp/dhcp-fwd/dhcp-fwd.conf", "wb"); fprintf(fp, "user root\n" "group root\n" "chroot /var/run/dhcp-fwd\n" "logfile /tmp/dhcp-fwd.log\n" "loglevel 1\n" "pidfile /var/run/dhcp-fwd.pid\n" "ulimit core 0\n" "ulimit stack 64K\n" "ulimit data 32K\n" "ulimit rss 200K\n" "ulimit nproc 0\n" "ulimit nofile 0\n" "ulimit as 0\n" "if %s true false true\n", nvram_safe_get("lan_ifname")); char *wan_proto = nvram_safe_get("wan_proto"); char *wan_ifname = nvram_safe_get("wan_ifname"); if (getSTA()) { wan_ifname = getSTA(); // returns eth1/eth2 for broadcom and // ath0 for atheros } #ifdef HAVE_PPPOE if (strcmp(wan_proto, "pppoe") == 0) { fprintf(fp, "if ppp0 false true true\n"); } #else if (0) { } #endif else if (getWET()) { // nothing } else if (strcmp(wan_proto, "dhcp") == 0 || strcmp(wan_proto, "static") == 0) { fprintf(fp, "if %s false true true\n", wan_ifname); } #ifdef HAVE_3G else if (strcmp(wan_proto, "3g") == 0 && nvram_match("3gdata", "qmi")) { fprintf(fp, "if wwan0 false true true\n"); } else if (strcmp(wan_proto, "3g") == 0) { fprintf(fp, "if ppp0 false true true\n"); } #endif #ifdef HAVE_PPTP else if (strcmp(wan_proto, "pptp") == 0) { fprintf(fp, "if ppp0 false true true\n"); } #endif #ifdef HAVE_IPETH else if (strcmp(wan_proto, "iphone") == 0) { fprintf(fp, "if iph0 false true true\n"); } #endif #ifdef HAVE_L2TP else if (strcmp(wan_proto, "l2tp") == 0) { fprintf(fp, "if ppp0 false true true\n"); } #endif #ifdef HAVE_HEARTBEAT else if (strcmp(wan_proto, "heartbeat") == 0) { fprintf(fp, "if ppp0 false true true\n"); } #endif else { fprintf(fp, "if %s false true true\n", wan_ifname); } fprintf(fp, "name %s ws-c\n" "server ip %s\n", nvram_safe_get("lan_ifname"), nvram_safe_get("dhcpfwd_ip")); fclose(fp); eval("dhcpfwd", "-c", "/tmp/dhcp-fwd/dhcp-fwd.conf"); syslog(LOG_INFO, "dhcpfwd : dhcp forwarder daemon successfully started\n"); return; } #endif #ifdef HAVE_DHCPRELAY if (nvram_match("dhcpfwd_enable", "1")) { eval("dhcrelay", "-i", nvram_safe_get("lan_ifname"), nvram_safe_get("dhcpfwd_ip")); syslog(LOG_INFO, "dhcrelay : dhcp relay successfully started\n"); } #endif 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; }