Esempio n. 1
0
int
disconnect_ndis(int devnum)
{
	int valid_node, qmi_mode = 0;
	char control_node[16] = {0};

	// check wdm device
	valid_node = find_modem_node("cdc-wdm", 0, 0, -1, NULL); // todo (need devnode for cdc-wdm)
	if (valid_node >= 0) {
		qmi_mode = 1;
		sprintf(control_node, "cdc-wdm%d", valid_node);
	}
	else {
		// check serial device
		valid_node = get_modem_node("ttyUSB", devnum, NULL);
		if (valid_node >= 0)
			sprintf(control_node, "ttyUSB%d", valid_node);
	}

	if (strlen(control_node) > 0) {
		if (!qmi_mode) {
			int vid = 0, pid = 0;
			get_modem_vid_pid(control_node, &vid, &pid);
			if ( (vid == 0x1199 || vid == 0x0f3d) && (pid == 0x68a3 || pid == 0x68aa) )
				return doSystem("/bin/comgt -d /dev/%s -s %s/ppp/3g/%s", control_node, MODEM_SCRIPTS_DIR, "Sierra_disconn.scr");
			else
				return doSystem("/bin/comgt -d /dev/%s -s %s/ppp/3g/%s", control_node, MODEM_SCRIPTS_DIR, "NDIS_disconn.scr");
		}
		else
			return qmi_stop_network(control_node);
	}

	return 1;
}
Esempio n. 2
0
void
safe_remove_usb_modem(void)
{
	doSystem("killall %s %s", "-q", "usb_modeswitch");
	doSystem("killall %s %s", "-q", "eject");

	if (nvram_get_int("modem_type") == 3)
	{
		char* svcs[] = { "udhcpc", NULL };
		
		if (pids(svcs[0]))
		{
			doSystem("killall %s %s", "-SIGUSR2", svcs[0]);
			usleep(300000);
			
			kill_services(svcs, 3, 1);
		}
		
		stop_wan_usbnet();
//		unlink_modem_ndis();
	}
	else
	{
		char* svcs_ppp[] = { "pppd", NULL };
		
		kill_services(svcs_ppp, 10, 1);
//		unlink_modem_ras();
	}

	set_usb_modem_dev_wan(0, 0);
}
Esempio n. 3
0
void
stop_modem_ndis(void)
{
	int i, modem_devnum = 0;
	char node_fname[64];
	char ndis_ifname[16] = {0};

	doSystem("killall %s %s", "-q", "usb_modeswitch");
	doSystem("killall %s %s", "-q", "eject");

	if (get_modem_ndis_ifname(ndis_ifname, &modem_devnum)) {
		disconnect_ndis(modem_devnum);
		if (is_interface_exist(ndis_ifname))
			ifconfig(ndis_ifname, 0, "0.0.0.0", NULL);
	}

	for (i=0; i<MAX_USB_NODE; i++)
	{
		sprintf(node_fname, "%s/ttyUSB%d", MODEM_NODE_DIR, i);
		unlink(node_fname);
		
		sprintf(node_fname, "%s/cdc-wdm%d", MODEM_NODE_DIR, i);
		unlink(node_fname);
		
		sprintf(node_fname, "%s/weth%d", MODEM_NODE_DIR, i);
		unlink(node_fname);
		
		sprintf(node_fname, "%s/wwan%d", MODEM_NODE_DIR, i);
		unlink(node_fname);
	}
}
Esempio n. 4
0
static void storageDiskPart(webs_t wp, char_t *path, char_t *query)
{
	char_t *part1_vol, *part2_vol, *part3_vol;
	int max_part = atoi(websGetVar(wp, T("max_part"), T("")));
	FILE *fp = NULL;
	char part[30];

	if (NULL == (fp = fopen("/proc/mounts", "r")))
	{
		perror(__FUNCTION__);
		return;
	}
	while(EOF != fscanf(fp, "%s %*s %*s %*s %*s %*s\n", part))
	{
		if (NULL != strstr(part, "/dev/sd") || NULL != strstr(part, "/dev/mmc"))
			doSystem("umount -l %s", part);
	}
	fclose(fp);
	part1_vol = websGetVar(wp, T("part1_vol"), T(""));
	part2_vol = websGetVar(wp, T("part2_vol"), T(""));
	part3_vol = websGetVar(wp, T("part3_vol"), T(""));
	doSystem("storage.sh reparted %s %s %s %d", 
			  part1_vol, part2_vol, part3_vol, max_part);
	sleep(50);
	memset(part, 0, 30);
	do {
		sprintf(part, "/dev/sda%d", max_part+4);
		FormatPart(part, "");
		sleep(5);
	} while (max_part--);
	doSystem("storage.sh restart");
	sleep(5);
	websRedirect(wp, "usb/STORAGEdisk_admin.asp");
}
Esempio n. 5
0
/* goform/webcamra */
static void webcamra(webs_t wp, char_t *path, char_t *query)
{
	char_t *enable, *resolution, *fps, *port;

	// fetch from web input
	enable = websGetVar(wp, T("enabled"), T(""));
	resolution = websGetVar(wp, T("resolution"), T(""));
	fps = websGetVar(wp, T("fps"), T(""));
	port = websGetVar(wp, T("port"), T(""));

	// set to nvram
	nvram_bufset(RT2860_NVRAM, "WebCamEnabled", enable);
	nvram_bufset(RT2860_NVRAM, "WebCamResolution", resolution);
	nvram_bufset(RT2860_NVRAM, "WebCamFPS", fps);
	nvram_bufset(RT2860_NVRAM, "WebCamPort", port);
	nvram_commit(RT2860_NVRAM);

	// setup device
	doSystem("killall uvc_stream");
	if (0 == strcmp(enable, "1"))
	{
		doSystem("uvc_stream -r %s -f %s -p %s -b", 
				  resolution, fps, port);
	}

	// debug print
	websHeader(wp);
	websWrite(wp, T("<h2>Web Camera Settings</h2><br>\n"));
	websWrite(wp, T("enabled: %s<br>\n"), enable);
	websWrite(wp, T("resolution: %s<br>\n"), resolution);
	websWrite(wp, T("fps: %s<br>\n"), fps);
	websWrite(wp, T("port: %s<br>\n"), port);
	websFooter(wp);
	websDone(wp, 200);
}
Esempio n. 6
0
/* goform/storageAdm */
static void storageAdm(webs_t wp, char_t *path, char_t *query)
{
	char_t *submit;

	submit = websGetVar(wp, T("hiddenButton"), T(""));

	if (0 == strcmp(submit, "delete"))
	{
		char_t *user_select;
		char feild[20];

		feild[0] = '\0';
		user_select = websGetVar(wp, T("storage_user_select"), T(""));
		sprintf(feild, "User%s", user_select);
		nvram_bufset(RT2860_NVRAM, feild, "");
		doSystem("rm -rf \"%s/home/%s\"", first_part, nvram_bufget(RT2860_NVRAM, feild));
		sprintf(feild, "User%sPasswd", user_select);
		nvram_bufset(RT2860_NVRAM, feild, "");
		sprintf(feild, "FtpUser%s", user_select);
		nvram_bufset(RT2860_NVRAM, feild, "");
		sprintf(feild, "SmbUser%s", user_select);
		nvram_bufset(RT2860_NVRAM, feild, "");
		nvram_commit(RT2860_NVRAM);
		doSystem("storage.sh admin");
	}
	else if (0 == strcmp(submit, "apply"))
	{
		initUSB();
	}
	websRedirect(wp, "usb/STORAGEuser_admin.asp");
}
Esempio n. 7
0
void media_processcheck(void)
{
	media_timer = (media_timer + 1) % 6;

	if (!media_timer)
	{
#if 0
		if (nvram_match("apps_dms_ex", "1") && nvram_match("dms_comp_mode", "1") && pids("ushare"))
		{
			if (nvram_match("ushare_debug", "1"))
			{
				system("date");
				dbg("ushare reloading media content...\n");
			}

			kill_pidfile_s("/var/run/ushare.pid", SIGHUP);
		}
#endif
		if (	nvram_match("wan_route_x", "IP_Routed") &&
			nvram_match("apps_itunes_ex", "1") &&
			pids("mt-daapd") &&
			!pids("mDNSResponder")	)
		{
			if (pids("mDNSResponder"))
				system("killall mDNSResponder");

			if (!nvram_match("computer_name", "") && is_valid_hostname(nvram_safe_get("computer_name")))
				doSystem("mDNSResponder %s thehost %s _daap._tcp. 3689 &", nvram_safe_get("lan_ipaddr_t"), nvram_safe_get("computer_name"));
			else
				doSystem("mDNSResponder %s thehost %s _daap._tcp. 3689 &", nvram_safe_get("lan_ipaddr_t"), nvram_safe_get("productid"));
		}
	}
}
Esempio n. 8
0
static void iTunesSrv(webs_t wp, char_t *path, char_t *query)
{
	char_t *enable, *dir_path, *name;

	// fetch from web input
	enable = websGetVar(wp, T("enabled"), T("0"));
	dir_path = websGetVar(wp, T("dir_path"), T(""));
	name = websGetVar(wp, T("srv_name"), T(""));
	// set to nvram
	nvram_bufset(RT2860_NVRAM, "iTunesEnable", enable);
	nvram_bufset(RT2860_NVRAM, "iTunesDir", dir_path);
	nvram_bufset(RT2860_NVRAM, "iTunesSrvName", name);
	nvram_commit(RT2860_NVRAM);

	// setup device
	doSystem("killall mt-daapd; killall mDNSResponder");
	if (strcmp(enable, "1") == 0)
		doSystem("config-iTunes.sh \"%s\" \"%s\" \"%s\"", 
				 name,
				 nvram_bufget(RT2860_NVRAM, "Password"),
				 dir_path);

	// debug print
	websHeader(wp);
	websWrite(wp, T("<h2>iTunes Server Settings</h2><br>\n"));
	websWrite(wp, T("capability: %s<br>\n"), enable);
	websWrite(wp, T("srv_name: %s<br>\n"), name);
	websWrite(wp, T("media library: %s<br>\n"), dir_path);
	websFooter(wp);
	websDone(wp, 200);
}
Esempio n. 9
0
void
stop_dhcpd(void)
{
/*
* Process udhcpd handles two signals - SIGTERM and SIGUSR1
*
*  - SIGUSR1 saves all leases in /tmp/udhcpd.leases
*  - SIGTERM causes the process to be killed
*
* The SIGUSR1+SIGTERM behavior is what we like so that all current client
* leases will be honorred when the dhcpd restarts and all clients can extend
* their leases and continue their current IP addresses. Otherwise clients
* would get NAK'd when they try to extend/rebind their leases and they 
* would have to release current IP and to request a new one which causes 
* a no-IP gap in between.
*/
	if (pids("udhcpd"))
	{
		doSystem("killall -%d udhcpd", SIGUSR1);
		sleep(1);
		doSystem("killall udhcpd");
	}

	dprintf("done\n");
}
Esempio n. 10
0
static void
openvpn_tunif_stop(const char *ifname)
{
	if (is_interface_exist(ifname)) {
		doSystem("ifconfig %s %s", ifname, "down");
		doSystem("%s %s --dev %s", OPENVPN_EXE, "--rmtun", ifname);
	}
}
Esempio n. 11
0
   void link_backup_run(int sign)
  {
	if(sign==1){
		doSystem("start_linkbackup > /dev/console&");
	}else{
		doSystem("killall link_backup");
	}
  }
Esempio n. 12
0
static void
openvpn_tapif_start(const char *ifname, int insert_to_bridge)
{
	if (!is_interface_exist(ifname))
		doSystem("%s %s --dev %s", OPENVPN_EXE, "--mktun", ifname);
	if (insert_to_bridge)
		doSystem("brctl %s %s %s", "addif", IFNAME_BR, ifname);
	doSystem("ifconfig %s %s %s", ifname, "0.0.0.0", "promisc up");
}
Esempio n. 13
0
static void
openvpn_tapif_stop(const char *ifname)
{
	if (is_interface_exist(ifname)) {
		doSystem("ifconfig %s %s", ifname, "down");
		doSystem("brctl %s %s %s 2>/dev/null", "delif", IFNAME_BR, ifname);
		doSystem("%s %s --dev %s", OPENVPN_EXE, "--rmtun", ifname);
	}
}
Esempio n. 14
0
/*
 * write default .nvm and .pib to flash
 */
int default_plc_write_to_flash(void)
{
	FILE *fp;
	int len, i;
	char cmd[64], buf[64];
	char mac[18], dak[48], nmk[48];
	unsigned char emac[ETHER_ADDR_LEN], enmk[PLC_KEY_LEN];

	doSystem("cp %s %s", DEFAULT_NVM_PATH, BOOT_NVM_PATH);
	doSystem("cp %s %s", DEFAULT_PIB_PATH, BOOT_PIB_PATH);

	// modify .pib
	// MAC
	if (!__getPLC_para(emac, OFFSET_PLC_MAC)) {
		_dprintf("READ PLC MAC: Out of scope\n");
	}
	else {
		if (emac[0] != 0xff) {
			if (ether_etoa(emac, mac))
				doSystem("/usr/local/bin/modpib %s -M %s", BOOT_PIB_PATH, mac);

			// DAK
			if (__getPLC_PWD(emac, buf)) {
				sprintf(cmd, "/usr/local/bin/hpavkey -D %s", buf);
				fp = popen(cmd, "r");
				if (fp) {
					len = fread(buf, 1, sizeof(buf), fp);
					pclose(fp);
					if (len > 1) {
						buf[len - 1] = '\0';

						for (i = 0; i < PLC_KEY_LEN; i++) {
							if (i == 0)
								sprintf(dak, "%c%c", buf[0], buf[1]);
							else
								sprintf(dak, "%s:%c%c", dak, buf[i*2], buf[i*2+1]);
						}
						doSystem("/usr/local/bin/modpib %s -D %s", BOOT_PIB_PATH, dak);
					}
				}
			}
		}
	}

	// NMK
	if (!__getPLC_para(enmk, OFFSET_PLC_NMK))
		_dprintf("READ PLC NMK: Out of scope\n");
	else {
		if (enmk[0] != 0xff && enmk[1] != 0xff && enmk[2] != 0xff) {
			if (key_etoa(enmk, nmk))
				doSystem("/usr/local/bin/modpib %s -N %s", BOOT_PIB_PATH, nmk);
		}
	}

	return plc_write_to_flash(BOOT_NVM_PATH, BOOT_PIB_PATH);
}
Esempio n. 15
0
void set_radio(int on, int unit, int subunit)
{
	uint32 n;

	// TODO: replace hardcoded 
	// TODO: handle subunit
	if(unit==0)
		doSystem("iwpriv %s set RadioOn=%d", WIF_2G, on);
	else doSystem("iwpriv %s set RadioOn=%d", WIF, on);
}
Esempio n. 16
0
static void
openvpn_tapif_start(const char *ifname, int insert_to_bridge)
{
    if (!is_interface_exist(ifname))
        doSystem("%s %s --dev %s", OPENVPN_EXE, "--mktun", ifname);

    if (insert_to_bridge)
        br_add_del_if(IFNAME_BR, ifname, 1);
    doSystem("ifconfig %s %s %s", ifname, "0.0.0.0", "promisc up");
    set_vpn_balancing(ifname);
}
Esempio n. 17
0
void wan6_up(char *wan_ifname)
{
	int ipv6_type, start_radvd_now;
	char *wan_addr6, *wan_gate6, *wan_addr4;

	ipv6_type = get_ipv6_type();
	if (ipv6_type == IPV6_DISABLED)
		return;

	stop_dhcp6c();

	build_dns6_var();

	control_if_ipv6_dad(IFNAME_BR, 1);

	start_radvd_now = 1;

	if (ipv6_type == IPV6_6IN4 || ipv6_type == IPV6_6TO4 || ipv6_type == IPV6_6RD)
	{
		wan_addr4 = nvram_safe_get("wan0_ipaddr");
		wan_addr6 = nvram_safe_get("wan0_addr6");
		start_sit_tunnel(ipv6_type, wan_addr4, wan_addr6);
	}
	else
	{
		control_if_ipv6_dad(wan_ifname, 1);
		
		if (ipv6_type == IPV6_NATIVE_STATIC) {
			wan_addr6 = nvram_safe_get("wan0_addr6");
			wan_gate6 = nvram_safe_get("wan0_gate6");
			control_if_ipv6_radv(wan_ifname, 0);
			clear_if_addr6(wan_ifname);
			if (*wan_addr6)
				doSystem("ip -6 addr add %s dev %s", wan_addr6, wan_ifname);
			if (*wan_gate6) {
				doSystem("ip -6 route add %s dev %s", wan_gate6, wan_ifname);
				doSystem("ip -6 route add default via %s metric %d", wan_gate6, 1);
			}
		}
		else {
			doSystem("ip -6 route add default dev %s metric %d", wan_ifname, 2048);
			control_if_ipv6_autoconf(wan_ifname, nvram_invmatch("ip6_wan_dhcp", "1"));
			control_if_ipv6_radv(wan_ifname, 1);
			/* wait for interface ready */
			sleep(2);
			start_dhcp6c(wan_ifname);
			if (nvram_match("ip6_lan_auto", "1"))
				start_radvd_now = 0;
		}
	}

	if (start_radvd_now)
		reload_radvd();
}
Esempio n. 18
0
int radio_main_rt(int ctrl)
{
	if (!ctrl)
	{
		doSystem("iwpriv %s set RadioOn=0", WIF2G);
	}
	else
	{
		if (nvram_match("rt_radio_x", "1"))
			doSystem("iwpriv %s set RadioOn=1", WIF2G);
	}
}
Esempio n. 19
0
static void
load_wireless_modules(void)
{
#if defined (USE_RT2860V2_AP)
	doSystem("modprobe %s", "rt2860v2_ap");
#endif

#if defined (USE_RT3090_AP)
	doSystem("modprobe %s", "rt3090_ap");
#elif defined (USE_RT5392_AP)
	doSystem("modprobe %s", "rt5392_ap");
#elif defined (USE_MT76X3_AP)
	doSystem("modprobe %s", "mt76x3_ap");
#endif

#if defined (USE_MT76X2_AP)
	doSystem("modprobe %s", "mt76x2_ap");
#endif

#if defined (USE_RT5592_AP)
	doSystem("modprobe %s", "rt5592_ap");
#elif defined (USE_RT3593_AP)
	doSystem("modprobe %s", "rt3593_ap");
#elif defined (USE_MT7610_AP)
	doSystem("modprobe %s", "mt7610_ap");
#endif
}
Esempio n. 20
0
int
ipup_vpns_main(int argc, char **argv)
{
	FILE *fp;
	int i_cast, i_vuse;
	char *peer_name;
	char *script_name = VPN_SERVER_UPDOWN_SCRIPT;

	if (argc < 7)
		return -1;

	peer_name = safe_getenv("PEERNAME");

	logmessage(VPNS_LOG_NAME, "peer %s (%s) connected - ifname: %s, local IP: %s",
			argv[6], peer_name, argv[1], argv[5]);

	umask(0000);

	/* add firewall permission for this client */
	vpns_firewall_permission(argv[1], 1);

	i_vuse = nvram_get_int("vpns_vuse");
	if (i_vuse) {
		/* disable multicast flag */
		doSystem("ifconfig %s %s", argv[1], "-multicast");
	}

	/* add route to client's LAN */
	vpns_route_to_remote_lan(peer_name, argv[1], NULL, 1);

	fp = fopen(VPN_SERVER_LEASE_FILE, "a+");
	if (fp) {
		fprintf(fp, "%s %s %s %s\n", argv[1], argv[5], argv[6], peer_name);
		fclose(fp);
	}

	if (i_vuse == 0 && !pids("bcrelay")) {
		i_cast = nvram_get_int("vpns_cast");
		if (i_cast == 1 || i_cast == 3)
			eval("/usr/sbin/bcrelay", "-d", "-i", IFNAME_BR, "-o", "ppp[1-5][0-9]", "-n");
		if (i_cast == 2 || i_cast == 3)
			eval("/usr/sbin/bcrelay", "-d", "-i", "ppp[1-5][0-9]", "-o", IFNAME_BR, "-n");
	}

	if (check_if_file_exist(script_name))
		doSystem("%s %s %s %s %s %s", script_name, "up", argv[1], argv[5], argv[6], peer_name);

	return 0;
}
Esempio n. 21
0
void set_radio(int on, int unit, int subunit)
{
	int led = (!unit)? LED_2G:LED_5G, onoff = (!on)? LED_OFF:LED_ON;
	char tmp[100], prefix[] = "wlXXXXXXXXXXXXXX", athfix[]="athXXXXXX";

	if (subunit > 0)
	{   
		snprintf(prefix, sizeof(prefix), "wl%d.%d_", unit, subunit);
//		snprintf(athfix, sizeof(athfix), "ath%d0%d", unit, subunit);
	}	
	else
	{   
		snprintf(prefix, sizeof(prefix), "wl%d_", unit);
//		snprintf(athfix, sizeof(athfix), "ath%d", unit);
	}
	strcpy(athfix, nvram_safe_get(strcat_r(prefix, "ifname", tmp)));

	if (*athfix != '\0')
	{   
	   	if(!strstr(athfix,"sta")) //all lan-interfaces except sta when running repeater mode
			doSystem("ifconfig %s %s",athfix, on?"up":"down");
	}

	led_control(led, onoff);
}
Esempio n. 22
0
int initial_all_var_file_in_mount_path(const char *const mount_path) {
	int i;
	int acc_num = 0;
	char **account_list = NULL;
	
	if (mount_path == NULL || strlen(mount_path) <= 0) {
		return -1;
	}
	
	// delete all var files
	doSystem("rm -f /%s/.__*.txt", mount_path);
	
	// initial the var file for ftp anonymous
	initial_one_var_file_in_mount_path(FTP_ANONYMOUS_USER, mount_path);
	
	// get the account number and account_list
	get_account_list(&acc_num, &account_list);
	
	// initial the var file
	for (i = 0; i < acc_num; ++i)
		initial_one_var_file_in_mount_path(account_list[i], mount_path);
	free_2_dimension_list(&acc_num, &account_list);
	
	// initial the folder list
	initial_folder_list_in_mount_path(mount_path);
	
	return 0;
}
Esempio n. 23
0
int test_of_var_files(const char *const mount_path) {
	doSystem("rm -f /%s/.__MediaServer_var.txt", mount_path);
	create_if_no_var_files(mount_path);	// According to the old folder_list, add the new folder.
	initial_folder_list_in_mount_path(mount_path);	// get the new folder_list.
	create_if_no_var_files(mount_path);	// According to the new folder_list, add the new var file.
	return 0;
}
Esempio n. 24
0
/* goform/StorageEditUser */
static void StorageEditUser(webs_t wp, char_t *path, char_t *query)
{
	char_t *index, *password; 
	char_t *user_ftp_enable, *user_smb_enable;
	char feild[20];

	feild[0] = '\0';
	// fetch from web input
	index = websGetVar(wp, T("hiddenIndex"), T(""));
	password = websGetVar(wp, T("edituser_pw"), T(""));
	user_ftp_enable = websGetVar(wp, T("edituser_ftp"), T(""));
	user_smb_enable = websGetVar(wp, T("edituser_smb"), T(""));
	/*
	DEBUG(index);
	DEBUG(password);
	DEBUG(user_ftp_enable);
	DEBUG(user_smb_enable);
	*/

	// set to nvram
	sprintf(feild, "User%sPasswd", index);
	nvram_bufset(RT2860_NVRAM, feild, password);
	sprintf(feild, "FtpUser%s", index);
	// DEBUG(feild);
	nvram_bufset(RT2860_NVRAM, feild, user_ftp_enable);
	sprintf(feild, "SmbUser%s", index);
	// DEBUG(feild);
	nvram_bufset(RT2860_NVRAM, feild, user_smb_enable);
	nvram_commit(RT2860_NVRAM);
	doSystem("storage.sh admin");
		
	websRedirect(wp, "usb/STORAGEuser_admin.asp");
}
Esempio n. 25
0
void
safe_remove_usb_modem(void)
{
	char* svcs[] = { "pppd", NULL };

	if (nvram_match("modem_type", "3"))
	{
		if (pids("udhcpc"))
		{
			doSystem("killall %s %s", "-SIGUSR2", "udhcpc");
			usleep(250000);
			
			svcs[0] = "udhcpc";
			kill_services(svcs, 3, 1);
		}
		
		stop_modem_ndis();
	}
	else
	{
		kill_services(svcs, 10, 1);
		
		stop_modem_ras();
	}

	set_usb_modem_dev_wan(0, 0);
}
Esempio n. 26
0
int
launch_wan_usbnet(int unit)
{
	int modem_devnum = 0;
	char ndis_ifname[16] = {0};

	if (get_modem_ndis_ifname(ndis_ifname, &modem_devnum) && is_interface_exist(ndis_ifname)) {
		int ndis_mtu = nvram_safe_get_int("modem_mtu", 1500, 1000, 1500);
		
		check_upnp_wanif_changed(ndis_ifname);
		set_wan_unit_value(unit, "proto_t", "NDIS Modem");
		set_wan_unit_value(unit, "ifname_t", ndis_ifname);
		
		/* bring up NDIS interface */
		doSystem("ifconfig %s mtu %d up %s", ndis_ifname, ndis_mtu, "0.0.0.0");
		
		/* re-build iptables rules (first stage w/o WAN IP) */
		start_firewall_ex();
		
		if (ndis_control_network(ndis_ifname, modem_devnum, 1) == 0)
			sleep(1);
		
		start_udhcpc_wan(ndis_ifname, unit, 0);
		
		return 0;
	}

	set_wan_unit_value(unit, "ifname_t", "");
	return -1;
}
Esempio n. 27
0
static void
exec_printer_daemons(int call_fw)
{
	int i, has_printer = 0;
	char *opt_printer_script = "/opt/bin/on_hotplug_printer.sh";
	char dev_lp[16];

	for (i = 0; i < 10; i++) {
		sprintf(dev_lp, "/dev/usb/lp%d", i);
		if (check_if_dev_exist(dev_lp)) {
			has_printer = 1;
			if (call_fw) {
				if (check_if_file_exist(opt_printer_script))
					doSystem("%s %s", opt_printer_script, dev_lp);
			}
			start_p910nd(dev_lp);
		}
	}
	
	if (has_printer) {
#if defined(SRV_U2EC)
		start_u2ec();
#endif
#if defined(SRV_LPRD)
		start_lpd();
#endif
	}
}
Esempio n. 28
0
static void QoSSetup(webs_t wp, char_t *path, char_t *query)
{
	char *submitUrl;

	char_t *QoS_type = websGetVar(wp, T("QoSSelect"), T("0"));
	if (QoS_type == NULL)
		QoS_type = "0";

	char_t *simpleqos = websGetVar(wp, T("simple_qos"), T("0"));
	if (strcmp(simpleqos, "on") != 0)
		simpleqos = "off";
	simpleqos = (strcmp(simpleqos, "on") == 0) ? "1" : "0";

	nvram_init(RT2860_NVRAM);
	nvram_bufset(RT2860_NVRAM, "QoSEnable", QoS_type);
	nvram_bufset(RT2860_NVRAM, "simple_qos", simpleqos);

	if (CHK_IF_DIGIT(QoS_type, 2))
		setupParameters(wp, QoS_args, 0);

	nvram_close(RT2860_NVRAM);
	doSystem("service shaper restart && service iptables restart && service kext restart");

	submitUrl = websGetVar(wp, T("submit-url"), T(""));   // hidden page
#ifdef PRINT_DEBUG
	if (!submitUrl || !submitUrl[0])
		websDone(wp, 200);
	else
#endif
		websRedirect(wp, submitUrl);
}
Esempio n. 29
0
int
disconnect_ndis(int devnum)
{
	int valid_node, qmi_mode = 0;
	char control_node[16] = {0};
	
	valid_node = find_modem_node("cdc-wdm", 0, 0, -1, NULL); // todo (need devnode for cdc-wdm)
	if (valid_node >= 0) {
		qmi_mode = 1;
		sprintf(control_node, "cdc-wdm%d", valid_node);
	}
	else {
		valid_node = find_modem_node("ttyUSB", 1, devnum, -1, NULL);
		if (valid_node < 0)
			valid_node = find_modem_node("ttyUSB", 0, devnum, -1, NULL);
		
		if (valid_node >= 0)
			sprintf(control_node, "ttyUSB%d", valid_node);
	}
	
	if (strlen(control_node) > 0) {
		if (qmi_mode)
			return qmi_stop_network(control_node);
		else
			return doSystem("/bin/comgt -d /dev/%s -s %s/ppp/3g/NDIS_disconn.scr", control_node, MODEM_SCRIPTS_DIR);
	}
	
	return 1;
}
Esempio n. 30
0
unsigned int
get_cpu_usage()
{
	FILE *fp;
	unsigned int usage, ret = 0;
	char buf[256], cpu[32];
	int i;

	doSystem("/usr/bin/top -n 1 > %s", "/tmp/result_top");
        
	if (fp = fopen("/tmp/result_top", "r"))
	{
		while (fgets(buf, sizeof(buf), fp) != NULL)
		{
			i = sscanf(buf, "%32s %d ", cpu, &usage);
                        
			if (i && !strncmp(cpu, "CPU", 3))
			{
				ret = usage;
				break;
			}
		}
                
		fclose(fp);
		return ret;
	}

	return 0;
}