Example #1
0
/*
 * Report time in RFC-822 format 
 */
void ej_localtime(webs_t wp, int argc, char_t ** argv)
{
	time_t tm;

	time(&tm);

	if (time(0) > (unsigned long)31536000)	// 60 * 60 * 24 * 365
	{
		char t[64];

		websWrite(wp, rfctime(&tm, t));
	} else
		websWrite(wp, "%s", live_translate("status_router.notavail"));
	// websWrite (wp, "<script
	// type=\"text/javascript\">Capture(status_router.notavail)</script>\n");
}
Example #2
0
void ej_get_wpsconfigure(webs_t wp, int argc, char_t ** argv)
{
	if (nvram_match("wps_status", "0"))
		websWrite(wp, "<input class=\"button\" type=\"button\" value=\"%s\" onclick=\"to_configure(this.form);\" />", live_translate("aoss.configure"));
	else
		websWrite(wp, "<input class=\"button\" type=\"button\" value=\"%s\" onclick=\"to_forcerelease(this.form);\" />", live_translate("aoss.release"));
}
Example #3
0
void ej_dump_site_survey(webs_t wp, int argc, char_t ** argv)
{
	int i;
	char buf[10] = { 0 };
	char *rates = NULL;
	char *name;

	name = websGetVar(wp, "hidden_scan", NULL);
	if (name == NULL || strlen(name) == 0)
		system2("site_survey");
	else {
		sysprintf("site_survey \"%s\"", name);
	}

	open_site_survey();

	for (i = 0; i < SITE_SURVEY_NUM; i++) {

		if (site_survey_lists[i].BSSID[0] == 0 || (site_survey_lists[i].channel & 0xff) == 0)
			break;

		// fix for " in SSID
		char *tssid = (site_survey_lists[i].SSID[0] == 0) ? "hidden" : &site_survey_lists[i].SSID[0];
		int pos = 0;
		int tpos;
		int ssidlen = strlen(tssid);

		while (pos < ssidlen) {
			if (tssid[pos] == '\"') {
				for (tpos = ssidlen; tpos > pos - 1; tpos--)
					tssid[tpos + 1] = tssid[tpos];

				tssid[pos] = '\\';
				pos++;
				ssidlen++;
			}
			pos++;
		}
		// end fix for " in SSID
		char strbuf[64];

		if (site_survey_lists[i].channel & 0x1000) {
			int cbw = site_survey_lists[i].channel & 0x100;
			//0x000 = 80 mhz
			//0x100 = 8080 mhz
			//0x200 = 160 mhz
			int speed = site_survey_lists[i].rate_count;

			switch (cbw) {
			case 0:
				if (speed == 150)
					speed = 433;
				else if (speed == 300)
					speed = 867;
				else if (speed == 450)
					speed = 1300;
			case 0x100:
			case 0x200:
				if (speed == 150)
					speed = 867;
				else if (speed == 300)
					speed = 1733;
				else if (speed == 450)
					speed = 2600;
			}
			rates = strbuf;

			if ((site_survey_lists[i].channel & 0xff) < 15) {
				sprintf(rates, "%d(b/g/n/ac)", speed);
			} else {
				sprintf(rates, "%d(a/n/ac)", speed);
			}

		} else {
			if ((site_survey_lists[i].channel & 0xff) < 15) {
				if (site_survey_lists[i].rate_count == 4)
					rates = "11(b)";
				else if (site_survey_lists[i].rate_count == 12)
					rates = "54(b/g)";
				else if (site_survey_lists[i].rate_count == 13)
					rates = "108(b/g)";
				else if (site_survey_lists[i].rate_count == 300)
					rates = "300(b/g/n)";
				else if (site_survey_lists[i].rate_count == 450)
					rates = "450(b/g/n)";
				else if (site_survey_lists[i].rate_count == 150)
					rates = "150(b/g/n)";
				else {
					rates = buf;
					snprintf(rates, 9, "%d", site_survey_lists[i].rate_count);
				}
			} else {
				if (site_survey_lists[i].rate_count == 4)
					rates = "11(b)";	//bogus, never shown. but if, its definitly b with weired channel setting
				else if (site_survey_lists[i].rate_count == 12)
					rates = "54(a)";
				else if (site_survey_lists[i].rate_count == 13)
					rates = "108(a)";
				else if (site_survey_lists[i].rate_count == 300)
					rates = "300(a/n)";
				else if (site_survey_lists[i].rate_count == 450)
					rates = "450(a/n)";
				else if (site_survey_lists[i].rate_count == 150)
					rates = "150(a/n)";
				else {
					rates = buf;
					snprintf(rates, 9, "%d", site_survey_lists[i].rate_count);
				}

			}
		}

		/*
		 * #define DOT11_CAP_ESS 0x0001 #define DOT11_CAP_IBSS 0x0002 #define 
		 * DOT11_CAP_POLLABLE 0x0004 #define DOT11_CAP_POLL_RQ 0x0008 #define 
		 * DOT11_CAP_PRIVACY 0x0010 #define DOT11_CAP_SHORT 0x0020 #define
		 * DOT11_CAP_PBCC 0x0040 #define DOT11_CAP_AGILITY 0x0080 #define
		 * DOT11_CAP_SPECTRUM 0x0100 #define DOT11_CAP_SHORTSLOT 0x0400
		 * #define DOT11_CAP_CCK_OFDM 0x2000 
		 */

		char open[32];
		strncpy(open, (site_survey_lists[i].capability & DOT11_CAP_PRIVACY) ? live_translate("share.no")
			: live_translate("share.yes"), 31);

		char *netmode;
		int netmodecap = site_survey_lists[i].capability;

		netmodecap &= (DOT11_CAP_ESS | DOT11_CAP_IBSS);
		if (netmodecap == DOT11_CAP_ESS)
			netmode = "AP";
		else if (netmodecap == DOT11_CAP_IBSS)
			netmode = "AdHoc";
		else
			netmode = live_translate("share.unknown");
		char net[32];
		strcpy(net, netmode);
		websWrite(wp, "%c\"", i ? ',' : ' ');
		tf_webWriteJS(wp, tssid);
		websWrite(wp,
			  "\",\"%s\",\"%s\",\"%d (%d MHz)\",\"%d\",\"%d\",\"%d\",\"%s\",\"%s\",\"%d\",\"%s\"\n",
			  net, site_survey_lists[i].BSSID,
			  site_survey_lists[i].channel & 0xff,
			  site_survey_lists[i].frequency,
			  site_survey_lists[i].RSSI, site_survey_lists[i].phy_noise, site_survey_lists[i].beacon_period, open, site_survey_lists[i].ENCINFO, site_survey_lists[i].dtim_period, rates);

	}

	return;
}
Example #4
0
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 = "&nbsp;";
		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;
}