Beispiel #1
0
void text_field::draw_cur(int color, image *screen)
{
  screen->bar(xstart()+cur*wm->font()->width()+1,
                      yend()-2,
                      xstart()+(cur+1)*wm->font()->width(),
                      yend()-1,color);
}
Beispiel #2
0
void text_field::draw(int active, image *screen)
{
  if (active)
  {
    screen->rectangle(xstart(),y,xend(),yend(),wm->bright_color());
    draw_cur(wm->bright_color(),screen);
  }
  else
  {
    screen->rectangle(xstart(),y,xend(),yend(),wm->dark_color());
    draw_cur(wm->dark_color(),screen);
  }
}
Beispiel #3
0
void start_nfs(void)
{
    FILE *fp;
    char *buf;
    char *g;
    char *p;
    int i;
    char *dir,*address,*access,*sync,*subtree,*other;

//  only if enable...
    if( nvram_match( "nfs_enable", "1" ) )
    {

//  read exports from nvram
    if ((buf = strdup(nvram_safe_get("nfs_exports"))) != NULL) {

//      writing data to file
        if( !( fp = fopen( "/etc/exports", "w" ) ) )
        {
            perror( "/etc/exports" );
            return;
        }

        g = buf;

//      dir < address < access < sync < subtree < other

        while ((p = strsep(&g, ">")) != NULL) {
            i = vstrsep(p, "<", &dir, &address, &access, &sync, &subtree, &other);
            if (i!=6) continue;
            fprintf(fp, "%s %s(%s,%s,%s,%s)\n", dir,address,access,sync,subtree,other);
        }
        free(buf);
    }

    fclose( fp );
    chmod( "/etc/exports", 0644 );

    }

    xstart( "/usr/sbin/nfs.rc" );
    return;

}
Beispiel #4
0
void start_siproxd(void)
{
	if (siproxd_fastpath != 1) {
		if (!nvram_match("siproxd_enable", "1")){ /* if siproxd not enabled dont run */
		syslog(LOG_INFO,"Siproxd not enabled - config file generation skipped!\n");
		return;
		}
	} else {
		syslog(LOG_INFO,"Siproxd - fastpath forced generation of config file\n");
	}
		
/* kill and clean all PIDs before running */
        if (siproxd_fastpath != 1) {
                stop_siproxd();
        }else{
                stop_siproxdfp();
        }
        
	build_siproxd_conf();
	syslog(LOG_INFO,"Siproxd - running daemon\n");
	xstart(siproxd_process, "-c", siproxdconf ,"-p", siproxdpid);
}
Beispiel #5
0
void start_dhcpc(void)
{
	char *argv[5];
	int argc;
	char *ifname;

	_dprintf("%s: begin\n", __FUNCTION__);

	nvram_set("wan_get_dns", "");
	f_write(renewing, NULL, 0, 0, 0);

	ifname = nvram_safe_get("wan_ifname");
	if (get_wan_proto() != WP_L2TP) {
		nvram_set("wan_iface", ifname);
	}

	argc = 0;
	argv[1] = nvram_safe_get("wan_hostname");
	if (*argv[1]) {
		argv[0] = "-H";
		argc = 2;
	}
	if (nvram_match("dhcpc_minpkt", "1")) argv[argc++] = "-m";
	argv[argc] = NULL;

	xstart(
		"udhcpc",
		"-i", ifname,

		
		"-s", "dhcpc-event",
		argv[0],	// -H
		argv[1],	// wan_hostname
		argv[2]		// -m
	);
	
	_dprintf("%s: end\n", __FUNCTION__);
}
Beispiel #6
0
void start_nocat(void)
{
    FILE *fp;
	char splashfile[255];
	char logofile[255];
	char iconfile[255];
	char cpcmd[255];
	char *p;

    stop_nocat();

    if( !nvram_match( "NC_enable", "1" ) )
	return;
/* not needed .. but this is what it's testing depending on kernel.. should be modified in /nocat/src/nocat.conf
#ifdef LINUX26
	syslog(LOG_INFO,"Device using K2.6\n");
	syslog(LOG_INFO,"tested & bypassed modprobe xt_mark\n");
	syslog(LOG_INFO,"tested & bypassed modprobe xt_mac\n");
#else
	syslog(LOG_INFO,"Device using K2.4\n");
	syslog(LOG_INFO,"Tested & bypassed modprobe ipt_mark\n");
	syslog(LOG_INFO,"Tested & bypassed modprobe ipt_mac\n");
#endif
*/
    build_nocat_conf();

	if ((p = nvram_get("NC_DocumentRoot")) == NULL) p = "/tmp/splashd";
	sprintf( splashfile, "%s/splash.html", p );
	sprintf( logofile, "%s/tux.png", p );
	sprintf( iconfile, "%s/favicon.ico", p );
    if (!f_exists(splashfile)) {
        nvram_get_file("NC_SplashFile", splashfile, 8192);
        if (!f_exists(splashfile)) {
            sprintf(cpcmd, "cp /www/splash.html %s", splashfile);
            system(cpcmd);
            sprintf(cpcmd, "cp /www/tux.png  %s", logofile);
            system(cpcmd);
            sprintf(cpcmd, "cp /www/favicon.ico  %s", iconfile);
            system(cpcmd);
        }
    }
	
    	if( !( fp = fopen( "/tmp/start_splashd.sh", "w" ) ) )
	{
	perror( "/tmp/start_splashd.sh" );
	return;
	}
	
//	if ( !pidof("splashd") > 0 && (fp = fopen("/tmp/var/lock/splashd.lock", "r" ) ) )
//	{
//	unlink( "/tmp/var/lock/splashd.lock");
//	}
		
	fprintf( fp, "#!/bin/sh\n" );
	fprintf( fp, "LOGGER=logger\n");
	fprintf( fp, "LOCK_FILE=/tmp/var/lock/splashd.lock\n");
	fprintf( fp, "if [ -f $LOCK_FILE ]; then\n");
	fprintf( fp, "	$LOGGER \"Captive Portal halted (0), other process starting.\" \n");
	fprintf( fp, "	exit\n");
	fprintf( fp, "fi\n");
	fprintf( fp, "echo \"TOMATO_RAF\" > $LOCK_FILE\n");
	fprintf( fp, "sleep 20\n" );
	fprintf( fp, "$LOGGER \"splashd : Captive Portal Splash Daemon successfully started\" \n");
	fprintf( fp, "echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse\n");
	fprintf( fp, "/usr/sbin/splashd >> /tmp/nocat.log 2>&1 &\n" );
	fprintf( fp, "sleep 2\n" );
	fprintf( fp, "echo 0 > /proc/sys/net/ipv4/tcp_tw_reuse\n");
	fprintf( fp, "rm $LOCK_FILE\n");
	fclose( fp );
	chmod( "/tmp/start_splashd.sh", 0700 );
	xstart( "/tmp/start_splashd.sh" );
	return;
}
Beispiel #7
0
void start_dsl()
{
#ifdef RTCONFIG_RALINK
	// todo: is it necessary? 
	init_dsl_before_start_wan();
#endif

	char *argv_tp_init[] = {"tp_init", NULL};
	int pid;
	char buf_ip[32];
	
	mkdir("/tmp/adsl", S_IRUSR | S_IWUSR | S_IXUSR);

	/* Paul comment 2012/7/25, the "never overcommit" policy would cause Ralink WiFi driver kernel panic when configure DUT through external registrar. *
	 * So let this value be the default which is 0, the kernel will estimate the amount of free memory left when userspace requests more memory. */
	//f_write_string("/proc/sys/vm/overcommit_memory", "2", 0, 0);

#ifdef RTCONFIG_DSL_TCLINUX
	check_and_set_comm_if();
#endif

#ifndef RTCONFIG_DSL_TCLINUX
#ifdef RTCONFIG_DUALWAN
	if (get_dualwan_secondary()==WANS_DUALWAN_IF_NONE)
	{
		if (get_dualwan_primary()!=WANS_DUALWAN_IF_DSL)
		{
			// it does not need to start dsl driver when using other modes
			// but it still need to run tp_init to have firmware version info
			printf("get modem info\n");
			xstart("tp_init", "eth_wan_mode_only");
			return;
		}
	}
#endif
#endif

	_eval(argv_tp_init, NULL, 0, &pid);

	int config_num = nvram_get_int("dslx_config_num");

	// IPTV
	if (nvram_match("x_Setting", "1") && config_num > 1)
	{
		int x;
		char wan_if[9];
		char wan_num[2];

		eval("brctl", "addbr", "br1");
		for(x=2; x<=config_num; x++) {
			sprintf(wan_num, "%d", x);
#ifdef RTCONFIG_RALINK
			sprintf(wan_if, "eth2.1.%d", x);
			eval("vconfig", "add", "eth2.1", wan_num);
#else
			/* create IPTV PVC interface and begin from eth0.3881 */
			sprintf(wan_num, "%d", (DSL_WAN_VID + x -1));
			sprintf(wan_if, "vlan%s", wan_num);
			eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD");
			eval("vconfig", "add", "eth0", wan_num);
			//Set switch
			sprintf(wan_num, "0x%04x", (DSL_WAN_VID + x -1));
			eval("et", "robowr", "0x05", "0x83", "0x0021");
			eval("et", "robowr", "0x05", "0x81", wan_num);
			eval("et", "robowr", "0x05", "0x80", "0x0000");
			eval("et", "robowr", "0x05", "0x80", "0x0080");
#endif
			eval("ifconfig", wan_if, "up");
			eval("brctl", "addif", "br1", wan_if);
		}
#ifdef RTCONFIG_RALINK
		eval("brctl", "addif", "br1", "eth2.3");
#else
		eval("brctl", "addif", "br1", "vlan3");
#endif
		// it needs assign a IPv4 address to enable packet forwarding
		pick_a_random_ipv4(buf_ip);
		eval("ifconfig", "br1", "up");
		eval("ifconfig", "br1", buf_ip);		
	}
#ifndef RTCONFIG_DSL_TCLINUX
	// auto detection
	if (nvram_match("x_Setting", "0") && config_num == 0)
	{
		int x;
		char wan_if[9];
		char wan_num[2];		
		char country_value[8];
		char cmd_buf[64];
		char *argv_auto_det[] = {"auto_det", country_value, NULL};		
		int pid;		
		for(x=2; x<=8; x++) {
			sprintf(wan_num, "%d", x);
			sprintf(wan_if, "eth2.1.%d", x);
			eval("vconfig", "add", "eth2.1", wan_num);
			eval("ifconfig", wan_if, "up");
		}
		//
		nvram_set("dsltmp_autodet_state", "Detecting");
		// call auto detection with country code
		get_country_code_from_rc(country_value);
		_eval(argv_auto_det, NULL, 0, &pid);
	}
#endif	//nRTCONFIG_DSL_TCLINUX

#ifdef RTCONFIG_DSL_TCLINUX
	if(nvram_match("dslx_diag_enable", "1") && nvram_match("dslx_diag_state", "1"))
		start_dsl_diag();
#endif
}
Beispiel #8
0
void text_field::draw_first(image *screen)
{
  wm->font()->put_string(screen,x,y+3,prompt);
  screen->bar(xstart(),y,xend(),yend(),wm->dark_color());
  wm->font()->put_string(screen,xstart()+1,y+3,data);
}
Beispiel #9
0
void start_telnetd(void)
{
	xstart("telnetd", "-p", nvram_safe_get("telnetd_port"));
}