int setinit(int argc, char** argv) { int i, cmdRet=-1; int intValue=0, intValue1=0; char cmdBuffer[100], tmpBuff[512]; char *token=NULL, *savestr1=NULL; char tmp_args[16]; char Ip[32], Mask[32], Gateway[32]; char strPID[32]; int pid = 0; int wlan_support = 0; int index; int old_wlan_idx; int repeater_enable1=0; int repeater_enable2=0; int reinit=1; #ifdef AEI_WECB if( (!strcmp(argv[2], "aei")) && (!strcmp(argv[3], "mac"))) { #ifdef AEI_CTL_BRIDGE init_mac(); #endif up_mib_value(); RunSystemCmd(REINIT_FILE, "echo", "1", NULL_STR); RunSystemCmd("/var/sys_op", "echo", "1", NULL_STR); RunSystemCmd("/proc/sys/net/ipv4/ip_forward", "echo", "0", NULL_STR); RunSystemCmd(PROC_BR_IGMPPROXY, "echo", "0", NULL_STR); /*cleanup hardware tables*/ RunSystemCmd(HW_NAT_FILE, "echo", "2", NULL_STR); /*bridge mode*/ RunSystemCmd("/proc/br_wlanblock", "echo","0",NULL_STR); RunSystemCmd(NULL_FILE, "iptables", "-F", NULL_STR); RunSystemCmd(NULL_FILE, "iptables", "-F", "-t", "nat", NULL_STR); RunSystemCmd(NULL_FILE, "iptables", "-A", "INPUT", "-j", "ACCEPT", NULL_STR); RunSystemCmd(NULL_FILE, "rm", "-f", "/var/eth1_ip", NULL_STR); RunSystemCmd(NULL_FILE, "rm", "-f", "/var/ntp_run", NULL_STR); //set kthreadd high priority for performance RunSystemCmd(NULL_FILE, "renice -20 2", NULL_STR); //set ksoftirqd high priority for performance RunSystemCmd(NULL_FILE, "renice -20 3", NULL_STR); //set boa high priority if(isFileExist(WEBS_PID_FILE)){ pid=getPid_fromFile(WEBS_PID_FILE); if(pid != 0){ sprintf(strPID, "%d", pid); RunSystemCmd(NULL_FILE, "renice", "-20", strPID, NULL_STR); } } RunSystemCmd("/proc/custom_Passthru", "echo", (intValue & 0x1)?"1":"0", NULL_STR); /*enable igmp snooping*/ /*igmp snooping is independent with igmp proxy*/ #ifdef AEI_IGMPV3 RunSystemCmd(PROC_BR_IGMPVERSION, "echo", "3", NULL_STR); #else RunSystemCmd(PROC_BR_IGMPVERSION, "echo", "2", NULL_STR); #endif RunSystemCmd(PROC_BR_IGMPSNOOP, "echo", "1", NULL_STR); #if defined(AEI_DISABLE_IGMP_QUERY) || defined(AEI_CONTROL_IGMP_QUERY) RunSystemCmd(PROC_BR_IGMPQUERY, "echo", "0", NULL_STR); #else RunSystemCmd(PROC_BR_IGMPQUERY, "echo", "1", NULL_STR); #endif RunSystemCmd(PROC_BR_MLDSNOOP, "echo", "1", NULL_STR); RunSystemCmd(PROC_BR_MLDQUERY, "echo", "1", NULL_STR); /*increase routing cache rebuild count from 4 to 2048*/ RunSystemCmd(RT_CACHE_REBUILD_COUNT, "echo", "2048", NULL_STR); return 0; } #endif //step 1: 802.1x client support #ifdef CONFIG_RTL_802_1X_CLIENT_SUPPORT if((isFileExist(RS_USER_CERT_5G)==0) && (isFileExist(RS_ROOT_CERT_5G)==0) && (isFileExist(RS_USER_CERT_2G)==0) && (isFileExist(RS_ROOT_CERT_2G)==0)){ RunSystemCmd(NULL_FILE, "rsCert","-rd", NULL_STR); } #endif printf("Init Start...\n"); //step 2 num_wlan_interface=get_interfaces_list(5, "wlan", NULL, wlan_interface, sizeof(wlan_interface)); num_wlan_virtual_interface=get_interfaces_list(9, "wlan", "-va", wlan_virtual_interface, sizeof(wlan_virtual_interface)); /*currently, we just support init gw/ap all */ // clean_process(BRIDGE_MODE,0,1, 1, "br0", wlan_interface, "eth1"); RunSystemCmd(HW_NAT_FILE, "echo", "2", NULL_STR); /*bridge mode*/ RunSystemCmd(NULL_FILE, "killall", "-9", "reload", NULL_STR); /*init wlan interface*/ //ifconfig rootap down && flash set_mib for(i=0;i<NUM_WLAN_INTERFACE;i++) { int wlan_disable = 1; unsigned char wlan_name[10]; memset(wlan_name,0x00,sizeof(wlan_name)); int j; for(j=0; j<NUM_VWLAN; j++){ sprintf(wlan_name, "wlan%d-va%d",i, j); RunSystemCmd(NULL_FILE, "ifconfig", wlan_name, "down", NULL_STR); } sprintf(wlan_name, "wlan%d",i); apmib_save_wlanIdx(); if(SetWlan_idx(wlan_name)) { apmib_get( MIB_WLAN_WLAN_DISABLED, (void *)&wlan_disable); if(wlan_disable == 1) { RunSystemCmd(NULL_FILE, "ifconfig", wlan_name, "down", NULL_STR); RunSystemCmd(NULL_FILE, "iwpriv", wlan_name, "radio_off", NULL_STR); } else { RunSystemCmd(NULL_FILE, "ifconfig", wlan_name, "down", NULL_STR); cmdRet=RunSystemCmd(NULL_FILE, "flash", "set_mib", wlan_name, NULL_STR); if(cmdRet != 0) { printf("init %s failed!\n", wlan_name); continue; } } } apmib_recov_wlanIdx(); } //ifconfig vap down && flash set_mib if(wlan_interface[0]){ if(wlan_virtual_interface[0]){ token=NULL; savestr1=NULL; sprintf(tmpBuff, "%s", wlan_virtual_interface); token = strtok_r(tmpBuff," ", &savestr1); do{ if (token == NULL){ break; }else{ RunSystemCmd(NULL_FILE, "ifconfig", token, "down", NULL_STR); RunSystemCmd(NULL_FILE, "flash", "set_mib", token, NULL_STR);/*set virtual wlan iface*/ } token = strtok_r(NULL, " ", &savestr1); }while(token !=NULL); } } /////////////////////////////////////////////////////////// //set_br_interface(tmpBuff); sprintf(tmpBuff, "%s %s", wlan_interface, wlan_virtual_interface); setbridge(tmpBuff);//ifconfig wlanx up or not sprintf(br_interface, "%s", "br0"); start_wlanapp(1); system("reload -k /var/wlsch.conf &"); #if defined(CONFIG_IPV6) set_ipv6(BRIDGE_MODE); #endif return 0; }
int main(int argc, char** argv) { char line[300]; char action[16]; int i; //printf("start.......:%s\n",argv[1]); #if 0 if(strcmp(argv[1],"firewall")) { printf("******************\n"); for(i=0;i<argc;i++) { printf("%s ",argv[i]); } printf("\n***************\n"); } #endif if ( !apmib_init()) { printf("Initialize AP MIB failed !\n"); return -1; } apmib_initialized = 1; memset(line,0x00,300); if(argv[1] && (strcmp(argv[1], "init")==0)){ #if defined(CONFIG_RTL_ULINKER) #if defined(CONFIG_RTL_ULINKER_WLAN_DELAY_INIT) int ulinker_auto = 0; apmib_get(MIB_ULINKER_AUTO, (void *)&ulinker_auto); if (ulinker_auto == 0) system("echo \"wlan 1\" > /proc/wlan_init"); #endif if (strcmp(argv[3], "all")==0) { ulinker_bootup(); } #elif defined(CONFIG_POCKET_ROUTER_SUPPORT) pocketAP_bootup(); #endif #ifdef CONFIG_POCKET_AP_SUPPORT i=BRIDGE_MODE; apmib_set(MIB_OP_MODE,(void *)&i); apmib_get(MIB_DHCP, (void *)&i); //for FC, dhcp server not allowed when client if( i > DHCP_CLIENT ) i=0; apmib_set(MIB_DHCP, (void *)&i); //0:DHCP_DISABLED i = 0xc0a801fa; apmib_set(MIB_IP_ADDR, (void *)&i); //for FC, default IP to 192.168.1.250 #endif setinit(argc,argv); #if defined(CONFIG_RTL_ULINKER_WLAN_DELAY_INIT) if (ulinker_auto == 1) ulinker_wlan_init(); #endif return 0; } else if(argv[1] && (strcmp(argv[1], "br")==0)){ for(i=0;i<argc;i++){ if( i>2 ) string_casecade(line, argv[i]); } setbridge(line); } #ifdef HOME_GATEWAY else if(argv[1] && (strcmp(argv[1], "firewall")==0)){ if(argv[2] && (strcmp(argv[2], "Send_GARP")==0)) //it will be call by set_staticIP function { #ifdef SEND_GRATUITOUS_ARP sendArp(); #endif } else { setFirewallIptablesRules(argc,argv); } } else if(argv[1] && (strcmp(argv[1], "wlanapp")==0)){ for(i=0;i<argc;i++){ if( i>2 ) string_casecade(line, argv[i]); if(i==2) sprintf(action, "%s",argv[i]); } setWlan_Applications(action, line); }else if(argv[1] && (strcmp(argv[1], "disc")==0)){ sprintf(line, "%s", argv[2]); #ifdef MULTI_PPPOE if(argv[3]) wan_disconnect(line,argv[3]); else wan_disconnect(line,"NOMULPPPOE"); #else wan_disconnect(line); #endif }else if(argv[1] && ((strcmp(argv[1], "conn")==0)||(strcmp(argv[1], "renew")==0))){ if(argc < 4){ printf("sysconf conn Invalid agrments!\n"); return 0; } sprintf(action, "%s",argv[3]); for(i=0;i<argc;i++){ if( i>2 ) string_casecade(line, argv[i]); } if((strcmp(argv[1], "renew")==0)&&!strcmp(argv[2],"dhcp") &&!wan_dhcpcNeedRenewConn(action,line)) { return 0; } #if defined(CONFIG_DYNAMIC_WAN_IP) if((!strcmp(argv[2], "dhcp"))&&(isFileExist(TEMP_WAN_CHECK))){ RunSystemCmd(TEMP_WAN_DHCP_INFO, "echo", line, NULL_STR); } #endif #if defined(CONFIG_RTL_ULINKER) /* notice ulinker_process to reset domain name query */ system("echo 1 > /var/ulinker_reset_domain"); #endif #if defined(CONFIG_DOMAIN_NAME_QUERY_SUPPORT) if(!strcmp(action, "br0")) wan_connect_pocket(action, line); else wan_connect(action, line); #else wan_connect(action, line); #endif }else if(argv[1] && (strcmp(argv[1], "pppoe")==0)){ Init_Internet(argc,argv); }else if(argv[1] && (strcmp(argv[1], "pptp")==0)){ Init_Internet(argc,argv); }else if(argv[1] && (strcmp(argv[1], "l2tp")==0)){ Init_Internet(argc,argv); }else if(argv[1] && (strcmp(argv[1], "setQos")==0)){ Init_QoS(argc,argv); }else if(argv[1] && (strcmp(argv[1], "dhcpd")==0)){ sprintf(action, "%s",argv[2]); start_lan_dhcpd(action); } #if defined(CONFIG_DOMAIN_NAME_QUERY_SUPPORT) else if(argv[1] && (strcmp(argv[1], "upnpd")==0)){ if(argc < 4){ printf("sysconf upnpd Invalid agrments!\n"); return 0; } start_upnpd(atoi(argv[2]),atoi(argv[3])); } #endif //### add by sen_liu 2011.4.21 sync the system log update (enlarge from 1 pcs to 8 pcs) to SDKv2.5 from kernel 2.4 #if defined(RINGLOG) else if(argv[1] && (strcmp(argv[1], "log")==0)){ if (argc == 6 && !strcmp(argv[2], "-s") && !strcmp(argv[4], "-b")) { system("killall syslogd >/dev/null 2>&1"); system("rm /var/log/log_split >/dev/null 2>&1"); sprintf(line, "echo %s > /var/log/log_split", argv[5]); system(line); RunSystemCmd(NULL_FILE, "syslogd", "-L", "-s", argv[3], "-b", argv[5], NULL_STR); fprintf(stderr, "syslog will use %dKB for log(%s rotate, 1 original, %sKB for each).\n", atoi(argv[3]) * ((atoi(argv[5]))+1), argv[5], argv[3]); } /* else if (argc == 4 && !strcmp(argv[2], "-R")) { RunSystemCmd(NULL_FILE, "killall syslogd", NULL_STR); RunSystemCmd(NULL_FILE, "syslogd", "-L", "-R", argv[3], NULL_STR); } */ else { fprintf(stderr, "usage:\n"); fprintf(stderr, "sysconf log -s size -b number-of-rotate-backup\n"); //fprintf(stderr, "sysconf log -R IP\n"); } } #endif //### end #endif //#ifdef CONFIG_POCKET_ROUTER_SUPPORT // system("boa"); //#endif return 0; }