void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; eval("/bin/tar", "-xzf", "/dev/mtdblock/2", "-C", "/"); FILE *in = fopen("/tmp/nvram/nvram.db", "rb"); if (in != NULL) { fclose(in); eval("/usr/sbin/convertnvram"); eval("/sbin/mtd", "erase", "nvram"); nvram_commit(); } if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); int brand = getRouterBrand(); /* * network drivers */ detect_wireless_devices(); struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; }
void start_sysinit(void) { struct stat tmp_stat; time_t tm = 0; eval("mknod", "/dev/gpio", "c", "127", "0"); eval("mknod", "/dev/rtc", "c", "254", "0"); eval("mknod", "/dev/crypto", "c", "10", "70"); eval("mount", "-o", "remount,rw", "/"); if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); // system watchdog cprintf("sysinit() setup console\n"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); nvram_set("intel_eth", "0"); #if 1 insmod("ixp400th"); insmod("ixp400"); system2("cat /usr/lib/firmware/IxNpeMicrocode.dat > /dev/IxNpe"); insmod("ixp400_eth"); eval("ifconfig", "ixp0", "0.0.0.0", "up"); eval("ifconfig", "ixp1", "0.0.0.0", "up"); insmod("ocf"); insmod("cryptodev"); // insmod("ixp4xx", "init_crypto=0"); #else // eval ("mknod", "/dev/IxNpe","c","10","184"); system2("cat /usr/lib/firmware/NPE-B > /dev/misc/ixp4xx_ucode"); system2("cat /usr/lib/firmware/NPE-C > /dev/misc/ixp4xx_ucode"); #endif detect_wireless_devices(); /* * Configure mac addresses by reading data from eeprom */ // char *filename = // "/sys/devices/platform/IXP4XX-I2C.0/i2c-0/0-0051/eeprom"; /* // bank2=0x100 */ char *filename = "/dev/mtdblock/0"; /* bank2=0x100 */ FILE *file = fopen(filename, "r"); if (file) { unsigned char buf[20]; fseek(file, 0x5ffa0, SEEK_SET); // point of mac address fread(&buf[0], 6, 1, file); char mac[20]; sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]); fprintf(stderr, "configure primary mac %s\n", mac); eval("ifconfig", "ixp0", "hw", "ether", mac); eval("ifconfig", "wifi0", "hw", "ether", mac); nvram_set("et0macaddr", mac); MAC_ADD(mac); fprintf(stderr, "configure secondary mac %s\n", mac); eval("ifconfig", "ixp1", "hw", "ether", mac); fclose(file); } eval("ifconfig", "ixp0", "0.0.0.0", "up"); eval("ifconfig", "ixp1", "0.0.0.0", "up"); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); nvram_set("use_crypto", "0"); cprintf("done\n"); return; }
void start_sysinit(void) { time_t tm = 0; if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * network drivers */ fprintf(stderr, "load ag71xx or ag7100_mod Ethernet Driver\n"); system("insmod ag71xx || insmod ag7100_mod || insmod ag7240_mod"); char mac1[32]; char mac2[32]; char wmac[32]; FILE *fp = fopen("/dev/mtdblock/7", "rb"); if (fp) { char mactmp[6]; int copy[6]; int i; #ifdef HAVE_WNDR3700 system("swconfig dev rtl8366s set reset 1"); system("swconfig dev rtl8366s set enable_vlan 0"); system("swconfig dev rtl8366s set blinkrate 2"); system("swconfig dev rtl8366s port 1 set led 9"); system("swconfig dev rtl8366s port 2 set led 6"); system("swconfig dev rtl8366s port 5 set led 2"); system("swconfig dev rtl8366s set apply"); #ifdef HAVE_WNDR3700V2 fseek(fp, 0xff0000, SEEK_SET); #else fseek(fp, 0x7f0000, SEEK_SET); #endif fread(mactmp, 6, 1, fp); for (i = 0; i < 6; i++) copy[i] = mactmp[i]; for (i = 0; i < 6; i++) copy[i] &= 0xff; sprintf(mac1, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fread(mactmp, 6, 1, fp); for (i = 0; i < 6; i++) copy[i] = mactmp[i]; for (i = 0; i < 6; i++) copy[i] &= 0xff; sprintf(mac2, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fread(mactmp, 6, 1, fp); fclose(fp); for (i = 0; i < 6; i++) copy[i] = mactmp[i]; for (i = 0; i < 6; i++) copy[i] &= 0xff; sprintf(wmac, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); #elif HAVE_WZRHPAG300NH system("swconfig dev eth0 set reset 1"); system("swconfig dev eth0 set enable_vlan 0"); system("swconfig dev eth0 vlan 1 set ports \"0 1 2 3 4\""); system("swconfig dev eth0 set apply"); fseek(fp, 0x5120C, SEEK_SET); fread(mactmp, 6, 1, fp); fclose(fp); for (i = 0; i < 6; i++) copy[i] = mactmp[i]; for (i = 0; i < 6; i++) copy[i] &= 0xff; sprintf(mac1, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); sprintf(mac2, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); MAC_ADD(mac2); // eval("gpio","enable","2"); #elif HAVE_WZRG300NH2 #ifndef HAVE_WZR300HP sysprintf("startservice bootloader_check"); #endif fseek(fp, 0x5120C, SEEK_SET); fread(mactmp, 6, 1, fp); fclose(fp); for (i = 0; i < 6; i++) copy[i] = mactmp[i]; for (i = 0; i < 6; i++) copy[i] &= 0xff; sprintf(mac1, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); sprintf(mac2, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); // eval("gpio","enable","13"); #ifdef HAVE_SWCONFIG system("swconfig dev eth0 set reset 1"); system("swconfig dev eth0 set enable_vlan 1"); if(nvram_match("wan_proto", "disabled") && nvram_match("fullswitch", "1")) { system("swconfig dev eth0 vlan 1 set ports \"0t 1 2 3 4 5\""); } else { system("swconfig dev eth0 vlan 1 set ports \"0t 1 3 4 5\""); system("swconfig dev eth0 vlan 2 set ports \"0t 2\""); } system("swconfig dev eth0 set apply"); #endif fprintf(stderr, "configure eth0 to %s\n", mac2); eval("ifconfig", "eth0", "hw", "ether", mac2); eval("ifconfig", "eth0", "up"); eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD"); eval("vconfig", "add", "eth0", "1"); eval("vconfig", "add", "eth0", "2"); fprintf(stderr, "configure vlan1 to %s\n", mac2); eval("ifconfig", "vlan1", "hw", "ether", mac2); fprintf(stderr, "configure vlan2 to %s\n", mac2); eval("ifconfig", "vlan2", "hw", "ether", mac2); #elif HAVE_WZRG450 fseek(fp, 0x51002, SEEK_SET); //osprey eeprom mac location fread(mactmp, 6, 1, fp); fclose(fp); for (i = 0; i < 6; i++) copy[i] = mactmp[i]; for (i = 0; i < 6; i++) copy[i] &= 0xff; sprintf(mac1, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); sprintf(mac2, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); // mac1[0] |= 0x02; // add private bit // mac2[0] |= 0x02; // eval("gpio","disable","16"); #ifdef HAVE_SWCONFIG system("swconfig dev switch0 set reset 1"); system("swconfig dev switch0 set enable_vlan 1"); if(nvram_match("wan_proto", "disabled") && nvram_match("fullswitch", "1")) { system("swconfig dev switch0 vlan 1 set ports \"0t 1 2 3 4 5\""); } else { system("swconfig dev switch0 vlan 1 set ports \"0t 2 3 4 5\""); system("swconfig dev switch0 vlan 2 set ports \"0t 1\""); } system("swconfig dev switch0 set apply"); #endif fprintf(stderr, "configure eth0 to %s\n", mac2); eval("ifconfig", "eth0", "hw", "ether", mac2); eval("ifconfig", "eth0", "up"); eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD"); eval("vconfig", "add", "eth0", "1"); eval("vconfig", "add", "eth0", "2"); fprintf(stderr, "configure vlan1 to %s\n", mac2); eval("ifconfig", "vlan1", "hw", "ether", mac2); fprintf(stderr, "configure vlan2 to %s\n", mac2); eval("ifconfig", "vlan2", "hw", "ether", mac2); #else system("swconfig dev eth0 set reset 1"); system("swconfig dev eth0 set enable_vlan 0"); system("swconfig dev eth0 vlan 1 set ports \"0 1 2 3 4\""); system("swconfig dev eth0 set apply"); fseek(fp, 0x7f120c, SEEK_SET); fread(mactmp, 6, 1, fp); fclose(fp); for (i = 5; i >= 3; i--) if (++mactmp[i] != 0x00) break; // dont know what this is for (i = 0; i < 6; i++) copy[i] = mactmp[i]; for (i = 0; i < 6; i++) copy[i] &= 0xff; sprintf(mac1, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); sprintf(mac2, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); MAC_ADD(mac2); #endif } else { sprintf(mac1, "00:11:22:33:44:55"); sprintf(mac2, "00:11:22:33:44:66"); } #ifndef HAVE_WZRG450 eval("ifconfig", "eth0", "hw", "ether", mac1); eval("ifconfig", "eth0", "up"); eval("ifconfig", "eth1", "hw", "ether", mac2); eval("ifconfig", "eth1", "up"); #else eval("ifconfig", "eth0", "hw", "ether", mac2); eval("ifconfig", "eth0", "up"); #endif struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); #ifdef HAVE_WZRHPAG300NH // eval("ifconfig", "wifi1", "hw", "ether", wmac); setWirelessLedPhy0(1); setWirelessLedPhy1(5); #else #ifndef HAVE_WNDR3700 #ifdef HAVE_WZRG300NH2 setWirelessLedPhy0(5); #else #ifndef HAVE_WZRG450 setWirelessLedGeneric(0,6); setWirelessLedGeneric(1,6); #endif #endif #else eval("ifconfig", "wifi0", "hw", "ether", mac1); eval("ifconfig", "wifi1", "hw", "ether", wmac); setWirelessLedPhy0(5); setWirelessLedPhy1(5); #endif #endif led_control(LED_POWER, LED_ON); led_control(LED_SES, LED_OFF); led_control(LED_SES2, LED_OFF); led_control(LED_DIAG, LED_OFF); led_control(LED_BRIDGE, LED_OFF); led_control(LED_WLAN0, LED_OFF); led_control(LED_WLAN1, LED_OFF); led_control(LED_CONNECTED, LED_OFF); getRouterBrand(); // restore some default settings if (!nvram_get("ath0_rxantenna")) nvram_set("ath0_rxantenna", "3"); if (!nvram_get("ath0_txantenna")) nvram_set("ath0_txantenna", "3"); if (!nvram_get("ath1_rxantenna")) nvram_set("ath1_rxantenna", "3"); if (!nvram_get("ath1_txantenna")) nvram_set("ath1_txantenna", "3"); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; cprintf("done\n"); }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; unlink("/etc/nvram/.lock"); cprintf("sysinit() proc\n"); /* * /proc */ mount("proc", "/proc", "proc", MS_MGC_VAL, NULL); system2("/etc/convert"); mount("sysfs", "/sys", "sysfs", MS_MGC_VAL, NULL); cprintf("sysinit() tmp\n"); /* * /tmp */ mount("ramfs", "/tmp", "ramfs", MS_MGC_VAL, NULL); mount("devpts", "/dev/pts", "devpts", MS_MGC_VAL, NULL); eval("mount", "/etc/www.fs", "/www", "-t", "squashfs", "-o", "loop"); eval("mount", "/etc/modules.fs", "/lib/modules", "-t", "squashfs", "-o", "loop"); eval("mount", "/etc/usr.fs", "/usr", "-t", "squashfs", "-o", "loop"); mkdir("/tmp/www", 0700); eval("mount", "-o", "remount,rw", "/"); mkdir("/usr/local/nvram", 0777); unlink("/tmp/nvram/.lock"); mkdir("/tmp/nvram", 0700); eval("cp", "/etc/nvram/nvram.db", "/tmp/nvram"); // eval ("cp", "/etc/nvram/offsets.db", "/tmp/nvram"); cprintf("sysinit() var\n"); /* * /var */ mkdir("/tmp/var", 0777); mkdir("/var/lock", 0777); mkdir("/var/log", 0777); mkdir("/var/run", 0777); mkdir("/var/tmp", 0777); cprintf("sysinit() setup console\n"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); int brand = getRouterBrand(); // enableAfterBurner (); insmod("md5"); insmod("aes"); insmod("blowfish"); insmod("deflate"); insmod("des"); insmod("michael_mic"); insmod("cast5"); insmod("crypto_null"); system2("/etc/kendin"); insmod("ixp400th"); insmod("ixp400"); system2("cat /usr/lib/firmware/IxNpeMicrocode.dat > /dev/IxNpe"); insmod("ixp400_eth"); insmod("ocf"); insmod("cryptodev"); insmod("ixp4xx", "init_crypto=0"); eval("ifconfig", "ixp0", "0.0.0.0", "up"); eval("vconfig", "add", "ixp0", "1"); eval("vconfig", "add", "ixp0", "2"); detect_wireless_devices(); // load_drivers(); //load madwifi drivers /* * Set a sane date */ stime(&tm); return; cprintf("done\n"); }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; cprintf("sysinit() proc\n"); /* * /proc */ mknod("/dev/mmc",S_IFBLK|0660,makedev(126,0)); mknod("/dev/mmc0",S_IFBLK|0660,makedev(126,1)); mknod("/dev/mmc1",S_IFBLK|0660,makedev(126,2)); mknod("/dev/mmc2",S_IFBLK|0660,makedev(126,3)); mknod("/dev/mmc3",S_IFBLK|0660,makedev(126,4)); mkdir("/dev/mtd",0700); mknod("/dev/mtd/0",S_IFCHR|0644,makedev(90,0)); mknod("/dev/mtd/0ro",S_IFCHR|0644,makedev(90,1)); mknod("/dev/mtd/1",S_IFCHR|0644,makedev(90,2)); mknod("/dev/mtd/1ro",S_IFCHR|0644,makedev(90,3)); mknod("/dev/mtd/2",S_IFCHR|0644,makedev(90,4)); mknod("/dev/mtd/2ro",S_IFCHR|0644,makedev(90,5)); mknod("/dev/mtd/3",S_IFCHR|0644,makedev(90,6)); mknod("/dev/mtd/3ro",S_IFCHR|0644,makedev(90,7)); mknod("/dev/mtd/4",S_IFCHR|0644,makedev(90,8)); mknod("/dev/mtd/4ro",S_IFCHR|0644,makedev(90,9)); cprintf("sysinit() setup console\n"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * load some netfilter stuff */ #ifndef HAVE_WP54G #ifndef HAVE_NP28G insmod("nf_conntrack_ftp"); insmod("nf_conntrack_irc"); insmod("nf_conntrack_netbios_ns"); insmod("nf_conntrack_pptp"); insmod("nf_conntrack_proto_gre"); insmod("nf_conntrack_proto_udplite"); insmod("nf_conntrack_tftp"); insmod("xt_CLASSIFY"); insmod("xt_MARK"); insmod("xt_TCPMSS"); insmod("xt_length"); insmod("xt_limit"); insmod("xt_multiport"); insmod("xt_pkttype"); insmod("xt_state"); insmod("xt_tcpmss"); insmod("xt_u32"); insmod("iptable_filter"); insmod("iptable_mangle"); insmod("nf_nat"); insmod("iptable_nat"); insmod("nf_nat_ftp"); insmod("nf_nat_irc"); insmod("nf_nat_pptp"); insmod("nf_nat_proto_gre"); insmod("nf_nat_tftp"); insmod("ipt_LOG"); insmod("ipt_MASQUERADE"); insmod("ipt_REDIRECT"); insmod("ipt_REJECT"); insmod("ipt_ULOG"); insmod("ipt_TRIGGER"); insmod("ipt_iprange"); insmod("ipt_ipp2p"); insmod("ipt_layer7"); insmod("ipt_webstr"); // ppp drivers insmod("slhc"); insmod("ppp_generic"); insmod("ppp_async"); insmod("ppp_synctty"); insmod("ppp_mppe_mppc"); insmod("pppox"); insmod("pppoe"); #endif #endif insmod("adm5120_wdt"); insmod("adm5120sw"); if (getRouterBrand() != ROUTER_BOARD_WP54G && getRouterBrand() != ROUTER_BOARD_NP28G) { unsigned char mac[6]; char eabuf[32]; char mtdpath[32]; memset(mac, 0, 6); FILE *fp; int mtd = getMTD("boot"); int foundmac = 0; sprintf(mtdpath, "/dev/mtdblock/%d", mtd); fp = fopen(mtdpath, "rb"); if (fp != NULL) { //check for osbridge fseek(fp, 0xff90 - 2, SEEK_SET); unsigned char os[32]; fread(os, 32, 1, fp); if (strcmp(os, "OSBRiDGE 5XLi") == 0) { foundmac = 1; fprintf(stderr, "found OSBRiDGE 5XLi\n"); nvram_set("DD_BOARD", "OSBRiDGE 5LXi"); fseek(fp, 0xff82, SEEK_SET); fread(os, 12, 1, fp); int i; int count = 0; if (memcmp(os, "0050fc488130", 12) == 0) { //force change mac fclose(fp); start_change_mac(); sys_reboot(); } for (i = 0; i < 6; i++) { mac[i] = toNumeric(os[count++]) * 16; mac[i] |= toNumeric(os[count++]); } struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); memcpy((unsigned char *)ifr.ifr_hwaddr. sa_data, mac, 6); ioctl(s, SIOCSIFHWADDR, &ifr); close(s); } if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *) ifr. ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr", ether_etoa((unsigned char *) ifr. ifr_hwaddr.sa_data, eabuf)); close(s); } } if (!foundmac) { int s = searchfor(fp, "mgmc", 0x20000 - 5); if (s != -1) { fread(mac, 6, 1, fp); struct ifreq ifr; int s; foundmac = 1; fprintf(stderr, "found Tonze-AP120\n"); if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); memcpy((unsigned char *) ifr.ifr_hwaddr.sa_data, mac, 6); ioctl(s, SIOCSIFHWADDR, &ifr); close(s); } if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *) ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr", ether_etoa((unsigned char *) ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } } } if (foundmac == 0) { fprintf(stderr, "error: no valid mac address found for eth0\n"); } fclose(fp); } } else { struct mylo_board_params params; char mtdpath[32]; FILE *fp; int mtd = getMTD("boot"); int foundmac = 0; struct ifreq ifr; int s; char eabuf[32]; sprintf(mtdpath, "/dev/mtdblock/%d", mtd); fp = fopen(mtdpath, "rb"); if (fp != NULL) { fseek(fp, 0xf800, SEEK_SET); fread(¶ms, sizeof(params), 1, fp); fclose(fp); if (params.magic == 0x20021103) { fprintf(stderr, "Found compex board magic!\n"); if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); memcpy((unsigned char *)ifr.ifr_hwaddr. sa_data, params.addr[0].mac, 6); ioctl(s, SIOCSIFHWADDR, &ifr); close(s); } if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { strncpy(ifr.ifr_name, "eth1", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); memcpy((unsigned char *)ifr.ifr_hwaddr. sa_data, params.addr[1].mac, 6); ioctl(s, SIOCSIFHWADDR, &ifr); close(s); } if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *) ifr. ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr", ether_etoa((unsigned char *) ifr. ifr_hwaddr.sa_data, eabuf)); close(s); } } } } /* * network drivers */ detect_wireless_devices(); if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); #ifdef HAVE_WP54G writeproc("/proc/sys/dev/wifi0/ledpin","6"); writeproc("/proc/sys/dev/wifi0/softled","1"); #endif /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; if (!nvram_match("disable_watchdog", "1")) { insmod("cns3xxx_wdt"); eval("watchdog"); } /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); int brand = getRouterBrand(); //for extension board struct ifreq ifr; int s; fprintf(stderr, "try modules for ethernet adapters\n"); nvram_set("intel_eth", "0"); insmod("cns3xxx_eth"); if (detect_ethernet_devices()) nvram_set("intel_eth", "1"); //load mmc drivers insmod("mmc_core"); eval("insmod", "sdhci", "debug_quirks=1"); // workaround for mmc detection issue. // insmod("sdhci"); insmod("sdhci-pltfm"); insmod("sdhci-cns3xxx"); insmod("mmc_block"); //sata drivers insmod("scsi_mod"); insmod("scsi_wait_scan"); insmod("scsi_sd_mod"); insmod("libata"); insmod("libahci"); insmod("ahci"); insmod("cns3xxx_ahci"); /* * network drivers */ detect_wireless_devices(); if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); eval("hwclock", "-s"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2391") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2391") ) sysprintf("gsp_updater -f /etc/gsc_2391_v35.txt"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2389") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2389") ) sysprintf("gsp_updater -f /etc/gsc_2388_v35.txt"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2388") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2388") ) sysprintf("gsp_updater -f /etc/gsc_2388_v35.txt"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2387") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2387") ) sysprintf("gsp_updater -f /etc/gsc_2387_v35.txt"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2386") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2386") ) sysprintf("gsp_updater -f /etc/gsc_2386_v35.txt"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2384") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2384") ) sysprintf("gsp_updater -f /etc/gsc_2384_v35.txt"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2383") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2383") ) sysprintf("gsp_updater -f /etc/gsc_2383_v35.txt"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2382") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2382") ) sysprintf("gsp_updater -f /etc/gsc_2382_v35.txt"); if (!strcmp(nvram_safe_get("DD_BOARD"), "Gateworks Laguna GW2380") || !strcmp(nvram_safe_get("DD_BOARD2"), "Gateworks Laguna GW2380") ) sysprintf("gsp_updater -f /etc/gsc_2380_v35.txt"); writeproc("/proc/irq/51/smp_affinity","2"); //use second core for ethernet interrupts. this should increase performance a little bit return; }
void start_sysinit(void) { time_t tm = 0; if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * network drivers */ fprintf(stderr, "load ATH Ethernet Driver\n"); insmod("ag7100_mod"); FILE *fp = fopen("/dev/mtdblock/7", "r"); if (fp) { fseek(fp, 0, SEEK_END); //determine size int size = ftell(fp); fseek(fp, size - 0xf000, SEEK_SET); unsigned char buf[20]; fread(&buf[0], 6, 1, fp); char mac[20]; int i; unsigned int copy[20]; for (i = 0; i < 12; i++) copy[i] = buf[i] & 0xff; sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fprintf(stderr, "configure ETH0 to %s\n", mac); nvram_set("et0macaddr_safe", mac); nvram_set("et0macaddr", mac); eval("ifconfig", "eth0", "hw", "ether", mac); fread(&buf[6], 6, 1, fp); for (i = 0; i < 12; i++) copy[i] = buf[i] & 0xff; sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", copy[6], copy[7], copy[8], copy[9], copy[10], copy[11]); fprintf(stderr, "configure ETH1 to %s\n", mac); eval("ifconfig", "eth1", "hw", "ether", mac); fclose(fp); } // no mac found, use default // eval("ifconfig", "eth0", "hw", "ether", "00:15:6D:FE:00:00"); // eval("ifconfig", "eth1", "hw", "ether", "00:15:6D:FE:00:01"); //#endif // eval("ifconfig", "eth0", "up"); // eval("ifconfig", "eth1", "up"); struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); #ifndef HAVE_ALFAAP94 setWirelessLed(0, 5); setWirelessLed(1, 4); setWirelessLed(2, 3); #else led_control(LED_POWER, LED_ON); #endif /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; cprintf("done\n"); }
void start_sysinit(void) { time_t tm = 0; if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * network drivers */ fprintf(stderr, "load ATH Ethernet Driver\n"); system("insmod ag71xx || insmod ag7240_mod"); insmod("ledtrig-netdev"); FILE *fp = fopen("/dev/mtdblock/0", "rb"); char mac[32]; if (fp) { unsigned char buf2[256]; fseek(fp, 0x1fc00, SEEK_SET); fread(buf2, 256, 1, fp); fclose(fp); unsigned int copy[256]; int i; for (i = 0; i < 256; i++) copy[i] = buf2[i] & 0xff; sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fprintf(stderr, "configure eth0 to %s\n", mac); MAC_SUB(mac); eval("ifconfig", "eth0", "hw", "ether", mac); MAC_ADD(mac); MAC_ADD(mac); fprintf(stderr, "configure eth1 to %s\n", mac); eval("ifconfig", "eth1", "hw", "ether", mac); #ifndef HAVE_ATH9K MAC_SUB(mac); #endif } eval("ifconfig", "eth0", "up"); eval("ifconfig", "eth1", "up"); #ifdef HAVE_SWCONFIG #ifdef HAVE_WDR2543 system("swconfig dev switch0 set reset 1"); system("swconfig dev switch0 set enable_vlan 1"); system("swconfig dev switch0 vlan 1 set ports \"1 2 3 4 9t\""); system("swconfig dev switch0 vlan 2 set ports \"0 9t\""); system("swconfig dev switch0 set apply"); eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD"); eval("vconfig", "add", "eth0", "1"); eval("vconfig", "add", "eth0", "2"); #else system("swconfig dev eth1 set reset 1"); system("swconfig dev eth1 set enable_vlan 0"); system("swconfig dev eth1 vlan 1 set ports \"0 1 2 3 4\""); system("swconfig dev eth1 set apply"); setEthLED(17,"eth0"); setSwitchLED(13,0x2); setSwitchLED(14,0x4); setSwitchLED(15,0x8); setSwitchLED(16,0x10); #endif #endif struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); #ifndef HAVE_ATH9K fprintf(stderr, "configure wifi0 to %s\n", mac); eval("ifconfig", "wifi0", "hw", "ether", mac); #endif //enable wlan led (card gpio based) #if defined(HAVE_WR841v7) || defined(HAVE_WR842) || defined(HAVE_MR3420) setWirelessLedPhy0(0); #else setWirelessLedPhy0(1); #endif led_control(LED_POWER, LED_ON); led_control(LED_SES, LED_OFF); led_control(LED_SES2, LED_OFF); led_control(LED_DIAG, LED_OFF); led_control(LED_BRIDGE, LED_OFF); led_control(LED_WLAN0, LED_OFF); led_control(LED_WLAN1, LED_OFF); led_control(LED_CONNECTED, LED_OFF); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; cprintf("done\n"); }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; if (!nvram_match("disable_watchdog", "1")) { insmod("imx2_wdt"); eval("watchdog"); } /* * Setup console */ eval("mount", "-o", "remount,rw", "/"); eval("mkdir", "-p", "/usr/local/nvram"); cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); int brand = getRouterBrand(); //for extension board struct ifreq ifr; int s; fprintf(stderr, "try modules for ethernet adapters\n"); nvram_set("intel_eth", "0"); insmod("sky2"); if (detect_ethernet_devices()) nvram_set("intel_eth", "1"); /* * network drivers */ detect_wireless_devices(); if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } eval("ifconfig", "eth0", "promisc"); eval("ifconfig", "eth1", "promisc"); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); eval("hwclock", "-s"); eval("i2cset", "-f", "-y", "0", "0x20", "0", "0x0"); eval("i2cset", "-f", "-y", "0", "0x20", "11", "0x10"); char *board = nvram_safe_get("DD_BOARD"); char *board2 = nvram_safe_get("DD_BOARD2"); if (!strncmp(board, "Gateworks Ventana GW54",22) || !strncmp(board2, "Gateworks Ventana GW54",22)) sysprintf("gsp_updater -f /etc/gsc_5400_v43.txt 43"); if (!strncmp(board, "Gateworks Ventana GW53",22) || !strncmp(board2, "Gateworks Ventana GW53",22)) sysprintf("gsp_updater -f /etc/gsc_5300_v43.txt 43"); if (!strncmp(board, "Gateworks Ventana GW52",22) || !strncmp(board2, "Gateworks Ventana GW52",22)) sysprintf("gsp_updater -f /etc/gsc_5200_v43.txt 43"); if (!strncmp(board, "Gateworks Ventana GW51",22) || !strncmp(board2, "Gateworks Ventana GW51",22)) sysprintf("gsp_updater -f /etc/gsc_5100_v43.txt 43"); led_control(LED_POWER, LED_ON); led_control(LED_DIAG, LED_OFF); led_control(LED_SES, LED_OFF); led_control(LED_SES2, LED_OFF); led_control(LED_BRIDGE, LED_OFF); led_control(LED_WLAN0, LED_OFF); led_control(LED_WLAN1, LED_OFF); led_control(LED_CONNECTED, LED_OFF); sysprintf("echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"); return; }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; mknod("/dev/gpio",S_IFCHR|0644,makedev(127,0)); mkdir("/usr/local",0700); mkdir("/usr/local/nvram",0700); install_sdcard(); cprintf("sysinit() setup console\n"); eval("insmod", "ks8695_wdt", "wdt_time=30"); // load watchdog module with 30 seconds timeout if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); int brand = getRouterBrand(); /* * network drivers */ eval("ifconfig", "eth0", "up"); eval("ifconfig", "eth1", "up"); eval("ifconfig", "eth2", "up"); eval("ifconfig", "eth3", "up"); struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); system2("echo 1 >/proc/sys/dev/wifi0/softled"); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); //disable led's return; cprintf("done\n"); }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; eval("/bin/tar", "-xzf", "/dev/mtdblock/3", "-C", "/"); FILE *in = fopen("/tmp/nvram/nvram.db", "rb"); if (in != NULL) { fclose(in); eval("/usr/sbin/convertnvram"); eval("/sbin/mtd", "erase", "nvram"); nvram_commit(); } if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); int brand = getRouterBrand(); insmod("zlib_deflate"); insmod("crc-ccitt"); insmod("crypto"); insmod("crypto_algapi"); insmod("crypto_blkcipher"); insmod("crypto_hash"); insmod("crypto_wq"); insmod("aead"); insmod("arc4"); insmod("ecb"); insmod("pcompress"); insmod("rng"); insmod("sha1_generic"); insmod("chainiv"); insmod("eseqiv"); insmod("cryptomgr"); insmod("slhc"); insmod("ppp_generic"); insmod("ppp_async"); insmod("ppp_synctty"); insmod("ppp_mppe"); insmod("pppox"); insmod("pppoe"); insmod("nf_conntrack_h323"); insmod("nf_nat_h323"); insmod("nf_conntrack_sip"); insmod("nf_nat_sip"); insmod("xt_state"); insmod("xt_recent"); insmod("xt_physdev"); insmod("xt_mac"); insmod("xt_limit"); insmod("xt_layer7"); insmod("xt_dscp"); insmod("xt_connlimit"); insmod("xt_multiport"); insmod("xt_DSCP"); /* * network drivers */ #ifdef HAVE_HOTPLUG2 insmod("ar231x"); #else insmod("ar2313"); #endif detect_wireless_devices(); writeproc("/proc/sys/dev/wifi0/ledpin", "2"); writeproc("/proc/sys/dev/wifi0/softled", "1"); writeproc("/proc/sys/dev/wifi0/ledpin", "3"); writeproc("/proc/sys/dev/wifi0/softled", "1"); // eval ("ifconfig", "wifi0", "up"); // eval ("ifconfig", "wifi1", "up"); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; cprintf("done\n"); }
void start_sysinit(void) { time_t tm = 0; cprintf("sysinit() setup console\n"); if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * network drivers */ #ifdef HAVE_WR1043 fprintf(stderr, "load RTL Switch Driver\n"); insmod("rtl8366rb_smi"); // insmod("swconfig"); insmod("rtl8366_smi"); insmod("rtl8366rb"); #endif fprintf(stderr, "load ag71xx or ag7100_mod Ethernet Driver\n"); system("insmod ag71xx || insmod ag7100_mod"); #ifdef HAVE_WZRG300NH system("swconfig dev rtl8366s set reset 1"); system("swconfig dev rtl8366s set enable_vlan 0"); system("swconfig dev rtl8366s set apply"); FILE *fp = fopen("/dev/mtdblock/6", "rb"); if (fp) { unsigned char buf2[256]; fseek(fp, 0x1ff120c, SEEK_SET); fread(buf2, 256, 1, fp); fclose(fp); char mac[32]; unsigned int copy[256]; int i; for (i = 0; i < 256; i++) copy[i] = buf2[i] & 0xff; sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fprintf(stderr, "configure eth0 to %s\n", mac); eval("ifconfig", "eth0", "hw", "ether", mac); fprintf(stderr, "configure eth1 to %s\n", mac); eval("ifconfig", "eth1", "hw", "ether", mac); } #endif #ifdef HAVE_WR1043 FILE *fp = fopen("/dev/mtdblock/0", "rb"); char mac[32]; if (fp) { system("swconfig dev rtl8366rb set reset 1"); system("swconfig dev rtl8366rb set enable_vlan 1"); system("swconfig dev rtl8366rb vlan 1 set ports \"1 2 3 4 5t\""); system("swconfig dev rtl8366rb vlan 2 set ports \"0 5t\""); system("swconfig dev rtl8366s set apply"); unsigned char buf2[256]; fseek(fp, 0x1fc00, SEEK_SET); fread(buf2, 256, 1, fp); fclose(fp); unsigned int copy[256]; int i; for (i = 0; i < 256; i++) copy[i] = buf2[i] & 0xff; sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fprintf(stderr, "configure eth0 to %s\n", mac); eval("ifconfig", "eth0", "hw", "ether", mac); eval("ifconfig", "eth0", "up"); eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD"); eval("vconfig", "add", "eth0", "1"); eval("vconfig", "add", "eth0", "2"); fprintf(stderr, "configure vlan1 to %s\n", mac); eval("ifconfig", "vlan1", "hw", "ether", mac); MAC_ADD(mac); fprintf(stderr, "configure vlan2 to %s\n", mac); eval("ifconfig", "vlan2", "hw", "ether", mac); MAC_SUB(mac); } #endif #ifdef HAVE_WA901 FILE *fp = fopen("/dev/mtdblock/0", "rb"); char mac[32]; if (fp) { unsigned char buf2[256]; fseek(fp, 0x1fc00, SEEK_SET); fread(buf2, 256, 1, fp); fclose(fp); unsigned int copy[256]; int i; for (i = 0; i < 256; i++) copy[i] = buf2[i] & 0xff; sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fprintf(stderr, "configure eth0 to %s\n", mac); eval("ifconfig", "eth0", "hw", "ether", mac); eval("ifconfig", "eth0", "up"); } #elif HAVE_WR941 FILE *fp = fopen("/dev/mtdblock/0", "rb"); char mac[32]; if (fp) { unsigned char buf2[256]; fseek(fp, 0x1fc00, SEEK_SET); fread(buf2, 256, 1, fp); fclose(fp); unsigned int copy[256]; int i; for (i = 0; i < 256; i++) copy[i] = buf2[i] & 0xff; sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fprintf(stderr, "configure eth0 to %s\n", mac); eval("ifconfig", "eth0", "hw", "ether", mac); eval("ifconfig", "eth0", "up"); eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD"); eval("vconfig", "add", "eth0", "0"); eval("vconfig", "add", "eth0", "1"); fprintf(stderr, "configure vlan0 to %s\n", mac); MAC_SUB(mac); eval("ifconfig", "vlan0", "hw", "ether", mac); MAC_ADD(mac); MAC_ADD(mac); fprintf(stderr, "configure vlan1 to %s\n", mac); eval("ifconfig", "vlan1", "hw", "ether", mac); MAC_SUB(mac); MAC_SUB(mac); } #endif #ifdef HAVE_WRT160NL FILE *fp = fopen("/dev/mtdblock/0", "rb"); unsigned char buf2[256]; if (fp) { #ifdef HAVE_E2100 unsigned int firstoffset = 0x3f29a; unsigned int secondoffset = 0x3f288; #else unsigned int firstoffset = 0x3f288; unsigned int secondoffset = 0x3f29a; #endif fseek(fp, firstoffset, SEEK_SET); fread(buf2, 19, 1, fp); if (buf2[0]==0xff) fseek(fp, secondoffset, SEEK_SET); fread(buf2, 19, 1, fp); fclose(fp); fprintf(stderr, "configure eth0 to %s\n", buf2); eval("ifconfig", "eth0", "hw", "ether", buf2); MAC_ADD(buf2); fprintf(stderr, "configure eth1 to %s\n", buf2); eval("ifconfig", "eth1", "hw", "ether", buf2); } #endif #ifdef HAVE_TG2521 eval("ifconfig", "eth0", "hw", "ether", "00:11:22:33:44:55"); eval("ifconfig", "eth1", "hw", "ether", "00:11:22:33:44:66"); FILE *fp = fopen("/dev/mtdblock/7", "rb"); char mac[32]; if (fp) { unsigned char buf2[256]; fseek(fp, 0x7d08c3, SEEK_SET); // mac location fread(buf2, 6, 1, fp); fclose(fp); unsigned int copy[256]; int i; for (i = 0; i < 6; i++) copy[i] = buf2[i] & 0xff; sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fprintf(stderr, "configure eth0 to %s\n", mac); eval("ifconfig", "eth0", "hw", "ether", mac); MAC_ADD(mac); fprintf(stderr, "configure eth1 to %s\n", mac); eval("ifconfig", "eth1", "hw", "ether", mac); MAC_SUB(mac); } #endif #if defined(HAVE_TEW632BRP) || defined(HAVE_DIR615E) eval("ifconfig", "eth0", "hw", "ether", "00:11:22:33:44:55"); eval("ifconfig", "eth1", "hw", "ether", "00:11:22:33:44:66"); FILE *in = fopen("/dev/mtdblock/0", "rb"); char *lanmac = NULL; if (in != NULL) { fseek(in, 0x20000, SEEK_SET); unsigned char *config = malloc(65536); memset(config, 0, 65536); fread(config, 65536, 1, in); int len = sizeof("lan_mac="); int i; int haslan = 0; int haswan = 0; for (i = 0; i < 65535 - 18; i++) { if (!haslan && !strncmp(&config[i], "lan_mac=", 8)) { haslan = 1; char *mac = &config[i + 8]; if (mac[0] == '"') mac++; mac[17] = 0; lanmac = malloc(32); strcpy(lanmac, mac); eval("ifconfig", "eth0", "hw", "ether", mac); nvram_set("et0macaddr_safe", mac); nvram_set("et0macaddr", mac); if (haswan) break; } if (!haswan && !strncmp(&config[i], "wan_mac=", 8)) { haswan = 1; char *mac = &config[i + 8]; if (mac[0] == '"') mac++; mac[17] = 0; eval("ifconfig", "eth1", "hw", "ether", mac); nvram_set("et0macaddr_safe", mac); nvram_set("et0macaddr", mac); if (haslan) break; } } free(config); fclose(in); } #endif eval("ifconfig", "eth0", "up"); eval("ifconfig", "eth1", "up"); struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); #ifdef HAVE_WRT160NL MAC_ADD(buf2); fprintf(stderr, "configure wifi0 to %s\n", buf2); eval("ifconfig", "wifi0", "hw", "ether", buf2); led_control(LED_POWER, LED_ON); #endif #if defined(HAVE_TEW632BRP) || defined(HAVE_DIR615E) if (lanmac != NULL) { fprintf(stderr, "configure wifi0 to %s\n", lanmac); eval("ifconfig", "wifi0", "hw", "ether", lanmac); free(lanmac); } #endif #ifdef HAVE_TG2521 { fprintf(stderr, "configure wifi0 to %s\n", mac); eval("ifconfig", "wifi0", "hw", "ether", mac); } // eval("gpio", "disable", "5"); // enable usb port #endif #ifdef HAVE_WR1043 { fprintf(stderr, "configure wifi0 to %s\n", mac); eval("ifconfig", "wifi0", "hw", "ether", mac); } #endif #ifdef HAVE_WR941 { fprintf(stderr, "configure wifi0 to %s\n", mac); eval("ifconfig", "wifi0", "hw", "ether", mac); } #endif led_control(LED_POWER, LED_ON); led_control(LED_SES, LED_OFF); led_control(LED_SES2, LED_OFF); led_control(LED_DIAG, LED_OFF); led_control(LED_BRIDGE, LED_OFF); led_control(LED_WLAN0, LED_OFF); led_control(LED_WLAN1, LED_OFF); led_control(LED_CONNECTED, LED_OFF); #ifdef HAVE_RS setWirelessLed(0,2); setWirelessLed(1,2); setWirelessLed(2,2); #elif HAVE_WRT160NL setWirelessLed(0,6); writeproc("/proc/sys/dev/wifi0/ledpin","6"); writeproc("/proc/sys/dev/wifi0/softled","1"); system("swconfig dev eth0 set reset 1"); system("swconfig dev eth0 set enable_vlan 1"); system("swconfig dev eth0 vlan 1 set ports \"0 1 2 3 4 5\""); #elif HAVE_WZRG300NH setWirelessLed(0,6); #elif HAVE_TEW632BRP setWirelessLed(0,6); #elif HAVE_WR941 setWirelessLed(0,9); #elif HAVE_WR1043 setWirelessLed(0,9); #else setWirelessLed(0,2); #endif /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; cprintf("done\n"); }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; unlink("/etc/nvram/.lock"); cprintf("sysinit() proc\n"); /* * /proc */ mount("proc", "/proc", "proc", MS_MGC_VAL, NULL); cprintf("sysinit() tmp\n"); /* * /tmp */ mount("ramfs", "/tmp", "ramfs", MS_MGC_VAL, NULL); // fix for linux kernel 2.6 mount("devpts", "/dev/pts", "devpts", MS_MGC_VAL, NULL); // load ext2 // eval("insmod","jbd"); insmod("ext2"); #ifndef KERNEL_24 if (mount ("/dev/cf/card0/part3", "/usr/local", "ext2", MS_MGC_VAL, NULL)) #else if (mount ("/dev/discs/disc0/part3", "/usr/local", "ext2", MS_MGC_VAL, NULL)) #endif { // not created yet, create ext2 partition eval("/sbin/mkfs.ext2", "-F", "-b", "1024", "/dev/cf/card0/part3"); // mount ext2 mount("/dev/cf/card0/part3", "/usr/local", "ext2", MS_MGC_VAL, NULL); eval("/bin/tar", "-xvvjf", "/etc/local.tar.bz2", "-C", "/"); } eval("mkdir", "-p", "/usr/local/nvram"); unlink("/tmp/nvram/.lock"); eval("cp", "/etc/nvram/nvram.db", "/tmp/nvram"); eval("mount", "/usr/local", "-o", "remount,ro"); // eval ("cp", "/etc/nvram/offsets.db", "/tmp/nvram"); cprintf("sysinit() var\n"); /* * /var */ mkdir("/tmp/var", 0777); mkdir("/var/lock", 0777); mkdir("/var/log", 0777); mkdir("/var/run", 0777); mkdir("/var/tmp", 0777); cprintf("sysinit() setup console\n"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); int brand = getRouterBrand(); /* * insmod("md5"); insmod("aes"); insmod("blowfish"); insmod("deflate"); * insmod("des"); insmod("michael_mic"); insmod("cast5"); * insmod("crypto_null"); */ detect_wireless_devices(); /* * Set a sane date */ stime(&tm); nvram_set("use_crypto", "0"); nvram_set("wl0_ifname", "ath0"); cprintf("done\n"); return; }
void start_sysinit(void) { time_t tm = 0; char dev[64]; char *disk = getdisc(); if (disk == NULL) { fprintf(stderr, "no valid dd-wrt partition found, calling shell"); eval("/bin/sh"); exit(0); } FILE *in = fopen("/usr/local/nvram/nvram.db", "rb"); if (in != NULL) { fclose(in); mkdir("/tmp/nvram", 0700); eval("cp", "/etc/nvram/nvram.db", "/tmp/nvram"); eval("cp", "/etc/nvram/offsets.db", "/tmp/nvram"); eval("/usr/sbin/convertnvram"); nvram_commit(); eval("rm", "-f", "/etc/nvram/nvram.db"); eval("rm", "-f", "/etc/nvram/offsets.db"); } //recover nvram if available in = fopen("/usr/local/nvram/nvram.bin", "rb"); if (in == NULL) { fprintf(stderr, "recover broken nvram\n"); sprintf(dev, "/dev/%s", disk); in = fopen(dev, "rb"); fseeko(in, 0, SEEK_END); off_t mtdlen = ftello(in); fseeko(in, mtdlen - (65536 * 2), SEEK_SET); unsigned char *mem = malloc(65536); fread(mem, 65536, 1, in); fclose(in); if (mem[0] == 0x46 && mem[1] == 0x4c && mem[2] == 0x53 && mem[3] == 0x48) { fprintf(stderr, "found recovery\n"); in = fopen("/usr/local/nvram/nvram.bin", "wb"); if (in != NULL) { fwrite(mem, 65536, 1, in); fclose(in); free(mem); eval("sync"); sleep(5); eval("event", "5", "1", "15"); } } free(mem); } else { fclose(in); } if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); // system watchdog #ifdef HAVE_ERC if (isregistered_real() && nvram_match("ree_resetme", "1")) { fprintf(stderr, "Restoring REE default nvram\n"); eval("nvram", "restore", "/etc/defaults/x86ree.backup"); eval("reboot"); eval("event", "5", "1", "15"); } #endif cprintf("sysinit() setup console\n"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * eval("insmod","md5"); eval("insmod","aes"); eval("insmod","blowfish"); * eval("insmod","deflate"); eval("insmod","des"); * eval("insmod","michael_mic"); eval("insmod","cast5"); * eval("insmod","crypto_null"); */ detect_ethernet_devices(); eval("ifconfig", "eth0", "0.0.0.0", "up"); eval("ifconfig", "eth1", "0.0.0.0", "up"); eval("ifconfig", "eth2", "0.0.0.0", "up"); eval("ifconfig", "eth3", "0.0.0.0", "up"); struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); mknod("/dev/rtc", S_IFCHR | 0644, makedev(253, 0)); #ifdef HAVE_CPUTEMP // insmod("nsc_gpio"); // insmod("scx200_gpio"); // insmod("scx200_i2c"); // insmod("scx200_acb"); // insmod("lm77"); #endif nvram_set("wl0_ifname", "ath0"); mknod("/dev/crypto", S_IFCHR | 0644, makedev(10, 70)); /* * Set a sane date */ stime(&tm); cprintf("done\n"); return; }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; mknod("/dev/mmc", S_IFBLK | 0660, makedev(126, 0)); mknod("/dev/mmc0", S_IFBLK | 0660, makedev(126, 1)); mknod("/dev/mmc1", S_IFBLK | 0660, makedev(126, 2)); mknod("/dev/mmc2", S_IFBLK | 0660, makedev(126, 3)); mknod("/dev/mmc3", S_IFBLK | 0660, makedev(126, 4)); eval("/bin/tar", "-xzf", "/dev/mtdblock/3", "-C", "/"); FILE *in = fopen("/tmp/nvram/nvram.db", "rb"); if (in != NULL) { fclose(in); eval("/usr/sbin/convertnvram"); eval("/sbin/mtd", "erase", "nvram"); nvram_commit(); } if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); #ifdef HAVE_RTG32 insmod("slhc"); insmod("ppp_generic"); insmod("ppp_async"); insmod("ppp_synctty"); insmod("ppp_mppe_mppc "); insmod("pppox"); insmod("pppoe"); #endif /* * network drivers */ #ifdef HAVE_HOTPLUG2 insmod("ar231x"); #else insmod("ar2313"); #endif detect_wireless_devices(); eval("ifconfig", "eth0", "up"); // wan system("swconfig dev eth0 set reset 1"); system("swconfig dev eth0 set enable_vlan 1"); #ifdef HAVE_RTG32 system("swconfig dev eth0 vlan 1 set ports \"0t 1 2 3 4\""); system("swconfig dev eth0 vlan 2 set ports \"0t 5\""); #else system("swconfig dev eth0 vlan 1 set ports \"0t 2 3 4 5\""); system("swconfig dev eth0 vlan 2 set ports \"0t 1\""); #endif system("swconfig dev eth0 set apply"); eval("vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD"); eval("vconfig", "add", "eth0", "1"); eval("vconfig", "add", "eth0", "2"); struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); char macaddr[32]; strcpy(macaddr, ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr", macaddr); MAC_ADD(macaddr); ether_atoe(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data); strncpy(ifr.ifr_name, "vlan2", IFNAMSIZ); ioctl(s, SIOCSIFHWADDR, &ifr); close(s); } eval("gpio", "enable", "1"); #ifdef HAVE_RTG32 writeproc("/proc/sys/dev/wifi0/ledpin", "7"); writeproc("/proc/sys/dev/wifi0/softled", "1"); #else writeproc("/proc/sys/dev/wifi0/ledpin", "0"); writeproc("/proc/sys/dev/wifi0/softled", "1"); #endif /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; }
void start_sysinit(void) { char buf[PATH_MAX]; struct stat tmp_stat; time_t tm = 0; eval("mknod", "/dev/gpio", "c", "127", "0"); if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); int brand = getRouterBrand(); /* * network drivers */ insmod("gemini_negmac"); #ifdef HAVE_WBD222 insmod("libata"); insmod("pata_gemini"); #endif eval("ifconfig", "eth0", "up"); #ifdef HAVE_WBD222 eval("ifconfig", "eth1", "up"); #endif struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); //disable led's eval("gpio", "disable", "1"); eval("gpio", "disable", "2"); eval("gpio", "disable", "3"); eval("gpio", "disable", "5"); eval("hwclock", "-s"); return; cprintf("done\n"); }
void start_sysinit(void) { time_t tm = 0; if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * network drivers */ fprintf(stderr, "load ATH Ethernet Driver\n"); system("insmod ag71xx || insmod ag7240_mod"); FILE *fp = fopen("/dev/mtdblock/6", "rb"); if (fp) { // fseek(fp, 0xFF0000, SEEK_SET); fseek(fp, DDMACOFFSET, SEEK_SET); unsigned char buf[20]; fread(&buf[0], 6, 1, fp); char mac[20]; int i; unsigned int copy[20]; for (i = 0; i < 12; i++) copy[i] = buf[i] & 0xff; sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); fprintf(stderr, "configure ETH0 to %s\n", mac); nvram_set("et0macaddr_safe", mac); nvram_set("et0macaddr", mac); eval("ifconfig", "eth0", "hw", "ether", mac); fread(&buf[6], 6, 1, fp); for (i = 0; i < 12; i++) copy[i] = buf[i] & 0xff; sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X", copy[6], copy[7], copy[8], copy[9], copy[10], copy[11]); fprintf(stderr, "configure ETH1 to %s\n", mac); eval("ifconfig", "eth1", "hw", "ether", mac); fclose(fp); } // eval("ifconfig", "eth0", "up"); // eval("ifconfig", "eth1", "up"); struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); led_control(LED_POWER, LED_ON); led_control(LED_SES, LED_OFF); led_control(LED_DIAG, LED_OFF); led_control(LED_BRIDGE, LED_OFF); led_control(LED_WLAN0, LED_OFF); led_control(LED_CONNECTED, LED_OFF); system2("echo 1 >/proc/sys/dev/wifi0/ledpin"); system2("echo 1 >/proc/sys/dev/wifi0/softled"); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; cprintf("done\n"); }
void start_sysinit(void) { time_t tm = 0; eval("/bin/tar", "-xzf", "/dev/mtdblock/3", "-C", "/"); FILE *in = fopen("/tmp/nvram/nvram.db", "rb"); if (in != NULL) { fclose(in); eval("/usr/sbin/convertnvram"); eval("/sbin/mtd", "erase", "nvram"); nvram_commit(); } if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * network drivers */ #ifdef HAVE_HOTPLUG2 insmod("ar231x"); #else insmod("ar2313"); #endif detect_wireless_devices(); int s; struct ifreq ifr; if (getRouterBrand() == ROUTER_BOARD_RDAT81) { writeproc("/proc/sys/dev/wifi0/ledpin","7"); writeproc("/proc/sys/dev/wifi0/softled","1"); writeproc("/proc/sys/dev/wifi1/ledpin","5"); writeproc("/proc/sys/dev/wifi1/softled","1"); } if (getRouterBrand() == ROUTER_BOARD_RCAA01) { insmod("mvswitch"); // eval("ifconfig", "eth0", "up", "promisc"); // required for vlan config eval("/sbin/vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD"); eval("/sbin/vconfig", "add", "eth0", "0"); eval("/sbin/vconfig", "add", "eth0", "1"); if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); char macaddr[32]; strcpy(macaddr, ether_etoa((unsigned char *)ifr.ifr_hwaddr. sa_data, eabuf)); nvram_set("et0macaddr", macaddr); // MAC_ADD( macaddr ); ether_atoe(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data); strncpy(ifr.ifr_name, "vlan1", IFNAMSIZ); ioctl(s, SIOCSIFHWADDR, &ifr); close(s); } writeproc("/proc/sys/dev/wifi0/ledpin","4"); writeproc("/proc/sys/dev/wifi0/softled","1"); writeproc("/proc/sys/dev/wifi1/ledpin","5"); writeproc("/proc/sys/dev/wifi1/softled","1"); } if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); char macaddr[32]; strcpy(macaddr, ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr", macaddr); nvram_set("et0macaddr_safe", macaddr); close(s); } /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; cprintf("done\n"); }
void start_sysinit(void) { time_t tm = 0; if (!nvram_match("disable_watchdog", "1")) eval("watchdog"); /* * Setup console */ cprintf("sysinit() klogctl\n"); klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel"))); cprintf("sysinit() get router\n"); /* * network drivers */ fprintf(stderr, "load ATH Ethernet Driver\n"); system("insmod ag71xx || insmod ag7100_mod"); char mac1[32]; char mac2[32]; system("swconfig dev rtl8366s set reset 1"); system("swconfig dev rtl8366s set enable_vlan 0"); system("swconfig dev rtl8366s set apply"); #ifndef HAVE_WNDR3700 FILE *fp = fopen("/dev/mtdblock/7", "rb"); if (fp) { #ifdef HAVE_WRT400 char mactmp[6]; int copy[6]; int i; fseek(fp, 0x7f120c, SEEK_SET); fread(mactmp, 6, 1, fp); for (i = 5; i >= 3; i--) if (++mactmp[i] != 0x00) break; // dont know what this is for (i = 0; i < 6; i++) copy[i] = mactmp[i]; sprintf(mac1, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); sprintf(mac2, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0], copy[1], copy[2], copy[3], copy[4], copy[5]); MAC_ADD(mac2); #else fseek(fp, 0x66ffa0, SEEK_SET); fread(mac1, 18, 1, fp); fseek(fp, 0x66ffb4, SEEK_SET); fread(mac2, 18, 1, fp); fclose(fp); #endif } else #endif { sprintf(mac1, "00:11:22:33:44:55"); sprintf(mac2, "00:11:22:33:44:66"); } eval("ifconfig", "eth0", "hw", "ether", mac1); eval("ifconfig", "eth1", "hw", "ether", mac2); eval("ifconfig", "eth0", "up"); eval("ifconfig", "eth1", "up"); struct ifreq ifr; int s; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) { char eabuf[32]; strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); ioctl(s, SIOCGIFHWADDR, &ifr); nvram_set("et0macaddr", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); nvram_set("et0macaddr_safe", ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data, eabuf)); close(s); } detect_wireless_devices(); #ifdef HAVE_WRT400 // eval("ifconfig", "wifi0", "hw", "ether", mac1); // eval("ifconfig", "wifi1", "hw", "ether", mac1); setWirelessLedPhy0(0); setWirelessLedPhy1(0); writeproc("/proc/sys/dev/wifi0/ledpin","0"); writeproc("/proc/sys/dev/wifi0/softled","1"); writeproc("/proc/sys/dev/wifi1/ledpin","0"); writeproc("/proc/sys/dev/wifi1/softled","1"); #else #ifndef HAVE_WNDR3700 eval("ifconfig", "wifi0", "hw", "ether", mac1); eval("ifconfig", "wifi1", "hw", "ether", mac1); #endif setWirelessLedPhy0(5); setWirelessLedPhy1(5); #endif led_control(LED_POWER, LED_ON); led_control(LED_SES, LED_OFF); led_control(LED_SES2, LED_OFF); led_control(LED_DIAG, LED_OFF); led_control(LED_BRIDGE, LED_OFF); led_control(LED_WLAN0, LED_OFF); led_control(LED_WLAN1, LED_OFF); led_control(LED_CONNECTED, LED_OFF); /* * Set a sane date */ stime(&tm); nvram_set("wl0_ifname", "ath0"); return; cprintf("done\n"); }