bool Variant::isNumeric(bool checkString /* = false */) const { int64_t ival; double dval; DataType t = toNumeric(ival, dval, checkString); return t == KindOfInt64 || t == KindOfDouble; }
String text(EListStyleType type, int count) { // If the list-style-type, say hebrew, cannot represent |count| because it's outside // its ordinal range then we fallback to some list style that can represent |count|. switch (effectiveListMarkerType(type, count)) { case NoneListStyle: return ""; // We use the same characters for text security. // See LayoutText::setInternalString. case Circle: return String(&whiteBulletCharacter, 1); case Disc: return String(&bulletCharacter, 1); case Square: // The CSS 2.1 test suite uses U+25EE BLACK MEDIUM SMALL SQUARE // instead, but I think this looks better. return String(&blackSquareCharacter, 1); case DecimalListStyle: return String::number(count); case DecimalLeadingZero: if (count < -9 || count > 9) return String::number(count); if (count < 0) return "-0" + String::number(-count); // -01 to -09 return "0" + String::number(count); // 00 to 09 case ArabicIndic: { static const UChar arabicIndicNumerals[10] = { 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669 }; return toNumeric(count, arabicIndicNumerals); } case Bengali: { static const UChar bengaliNumerals[10] = { 0x09E6, 0x09E7, 0x09E8, 0x09E9, 0x09EA, 0x09EB, 0x09EC, 0x09ED, 0x09EE, 0x09EF }; return toNumeric(count, bengaliNumerals); } case Cambodian: case Khmer: { static const UChar khmerNumerals[10] = { 0x17E0, 0x17E1, 0x17E2, 0x17E3, 0x17E4, 0x17E5, 0x17E6, 0x17E7, 0x17E8, 0x17E9 }; return toNumeric(count, khmerNumerals); } case Devanagari: { static const UChar devanagariNumerals[10] = { 0x0966, 0x0967, 0x0968, 0x0969, 0x096A, 0x096B, 0x096C, 0x096D, 0x096E, 0x096F }; return toNumeric(count, devanagariNumerals); } case Gujarati: { static const UChar gujaratiNumerals[10] = { 0x0AE6, 0x0AE7, 0x0AE8, 0x0AE9, 0x0AEA, 0x0AEB, 0x0AEC, 0x0AED, 0x0AEE, 0x0AEF }; return toNumeric(count, gujaratiNumerals); } case Gurmukhi: { static const UChar gurmukhiNumerals[10] = { 0x0A66, 0x0A67, 0x0A68, 0x0A69, 0x0A6A, 0x0A6B, 0x0A6C, 0x0A6D, 0x0A6E, 0x0A6F }; return toNumeric(count, gurmukhiNumerals); } case Kannada: { static const UChar kannadaNumerals[10] = { 0x0CE6, 0x0CE7, 0x0CE8, 0x0CE9, 0x0CEA, 0x0CEB, 0x0CEC, 0x0CED, 0x0CEE, 0x0CEF }; return toNumeric(count, kannadaNumerals); } case Lao: { static const UChar laoNumerals[10] = { 0x0ED0, 0x0ED1, 0x0ED2, 0x0ED3, 0x0ED4, 0x0ED5, 0x0ED6, 0x0ED7, 0x0ED8, 0x0ED9 }; return toNumeric(count, laoNumerals); } case Malayalam: { static const UChar malayalamNumerals[10] = { 0x0D66, 0x0D67, 0x0D68, 0x0D69, 0x0D6A, 0x0D6B, 0x0D6C, 0x0D6D, 0x0D6E, 0x0D6F }; return toNumeric(count, malayalamNumerals); } case Mongolian: { static const UChar mongolianNumerals[10] = { 0x1810, 0x1811, 0x1812, 0x1813, 0x1814, 0x1815, 0x1816, 0x1817, 0x1818, 0x1819 }; return toNumeric(count, mongolianNumerals); } case Myanmar: { static const UChar myanmarNumerals[10] = { 0x1040, 0x1041, 0x1042, 0x1043, 0x1044, 0x1045, 0x1046, 0x1047, 0x1048, 0x1049 }; return toNumeric(count, myanmarNumerals); } case Oriya: { static const UChar oriyaNumerals[10] = { 0x0B66, 0x0B67, 0x0B68, 0x0B69, 0x0B6A, 0x0B6B, 0x0B6C, 0x0B6D, 0x0B6E, 0x0B6F }; return toNumeric(count, oriyaNumerals); } case Persian: case Urdu: { static const UChar urduNumerals[10] = { 0x06F0, 0x06F1, 0x06F2, 0x06F3, 0x06F4, 0x06F5, 0x06F6, 0x06F7, 0x06F8, 0x06F9 }; return toNumeric(count, urduNumerals); } case Telugu: { static const UChar teluguNumerals[10] = { 0x0C66, 0x0C67, 0x0C68, 0x0C69, 0x0C6A, 0x0C6B, 0x0C6C, 0x0C6D, 0x0C6E, 0x0C6F }; return toNumeric(count, teluguNumerals); } case Tibetan: { static const UChar tibetanNumerals[10] = { 0x0F20, 0x0F21, 0x0F22, 0x0F23, 0x0F24, 0x0F25, 0x0F26, 0x0F27, 0x0F28, 0x0F29 }; return toNumeric(count, tibetanNumerals); } case Thai: { static const UChar thaiNumerals[10] = { 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, 0x0E58, 0x0E59 }; return toNumeric(count, thaiNumerals); } case LowerAlpha: case LowerLatin: { static const LChar lowerLatinAlphabet[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; return toAlphabetic(count, lowerLatinAlphabet); } case UpperAlpha: case UpperLatin: { static const LChar upperLatinAlphabet[26] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; return toAlphabetic(count, upperLatinAlphabet); } case LowerGreek: { static const UChar lowerGreekAlphabet[24] = { 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9 }; return toAlphabetic(count, lowerGreekAlphabet); } case Hiragana: { // FIXME: This table comes from the CSS3 draft, and is probably // incorrect, given the comments in that draft. static const UChar hiraganaAlphabet[48] = { 0x3042, 0x3044, 0x3046, 0x3048, 0x304A, 0x304B, 0x304D, 0x304F, 0x3051, 0x3053, 0x3055, 0x3057, 0x3059, 0x305B, 0x305D, 0x305F, 0x3061, 0x3064, 0x3066, 0x3068, 0x306A, 0x306B, 0x306C, 0x306D, 0x306E, 0x306F, 0x3072, 0x3075, 0x3078, 0x307B, 0x307E, 0x307F, 0x3080, 0x3081, 0x3082, 0x3084, 0x3086, 0x3088, 0x3089, 0x308A, 0x308B, 0x308C, 0x308D, 0x308F, 0x3090, 0x3091, 0x3092, 0x3093 }; return toAlphabetic(count, hiraganaAlphabet); } case HiraganaIroha: { // FIXME: This table comes from the CSS3 draft, and is probably // incorrect, given the comments in that draft. static const UChar hiraganaIrohaAlphabet[47] = { 0x3044, 0x308D, 0x306F, 0x306B, 0x307B, 0x3078, 0x3068, 0x3061, 0x308A, 0x306C, 0x308B, 0x3092, 0x308F, 0x304B, 0x3088, 0x305F, 0x308C, 0x305D, 0x3064, 0x306D, 0x306A, 0x3089, 0x3080, 0x3046, 0x3090, 0x306E, 0x304A, 0x304F, 0x3084, 0x307E, 0x3051, 0x3075, 0x3053, 0x3048, 0x3066, 0x3042, 0x3055, 0x304D, 0x3086, 0x3081, 0x307F, 0x3057, 0x3091, 0x3072, 0x3082, 0x305B, 0x3059 }; return toAlphabetic(count, hiraganaIrohaAlphabet); } case Katakana: { // FIXME: This table comes from the CSS3 draft, and is probably // incorrect, given the comments in that draft. static const UChar katakanaAlphabet[48] = { 0x30A2, 0x30A4, 0x30A6, 0x30A8, 0x30AA, 0x30AB, 0x30AD, 0x30AF, 0x30B1, 0x30B3, 0x30B5, 0x30B7, 0x30B9, 0x30BB, 0x30BD, 0x30BF, 0x30C1, 0x30C4, 0x30C6, 0x30C8, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF, 0x30D2, 0x30D5, 0x30D8, 0x30DB, 0x30DE, 0x30DF, 0x30E0, 0x30E1, 0x30E2, 0x30E4, 0x30E6, 0x30E8, 0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EF, 0x30F0, 0x30F1, 0x30F2, 0x30F3 }; return toAlphabetic(count, katakanaAlphabet); } case KatakanaIroha: { // FIXME: This table comes from the CSS3 draft, and is probably // incorrect, given the comments in that draft. static const UChar katakanaIrohaAlphabet[47] = { 0x30A4, 0x30ED, 0x30CF, 0x30CB, 0x30DB, 0x30D8, 0x30C8, 0x30C1, 0x30EA, 0x30CC, 0x30EB, 0x30F2, 0x30EF, 0x30AB, 0x30E8, 0x30BF, 0x30EC, 0x30BD, 0x30C4, 0x30CD, 0x30CA, 0x30E9, 0x30E0, 0x30A6, 0x30F0, 0x30CE, 0x30AA, 0x30AF, 0x30E4, 0x30DE, 0x30B1, 0x30D5, 0x30B3, 0x30A8, 0x30C6, 0x30A2, 0x30B5, 0x30AD, 0x30E6, 0x30E1, 0x30DF, 0x30B7, 0x30F1, 0x30D2, 0x30E2, 0x30BB, 0x30B9 }; return toAlphabetic(count, katakanaIrohaAlphabet); } case CjkEarthlyBranch: { static const UChar cjkEarthlyBranchAlphabet[12] = { 0x5B50, 0x4E11, 0x5BC5, 0x536F, 0x8FB0, 0x5DF3, 0x5348, 0x672A, 0x7533, 0x9149, 0x620C, 0x4EA5 }; return toAlphabetic(count, cjkEarthlyBranchAlphabet); } case CjkHeavenlyStem: { static const UChar cjkHeavenlyStemAlphabet[10] = { 0x7532, 0x4E59, 0x4E19, 0x4E01, 0x620A, 0x5DF1, 0x5E9A, 0x8F9B, 0x58EC, 0x7678 }; return toAlphabetic(count, cjkHeavenlyStemAlphabet); } case HangulConsonant: { static const UChar hangulConsonantAlphabet[14] = { 0x3131, 0x3134, 0x3137, 0x3139, 0x3141, 0x3142, 0x3145, 0x3147, 0x3148, 0x314A, 0x314B, 0x314C, 0x314D, 0x314E }; return toAlphabetic(count, hangulConsonantAlphabet); } case Hangul: { static const UChar hangulAlphabet[14] = { 0xAC00, 0xB098, 0xB2E4, 0xB77C, 0xB9C8, 0xBC14, 0xC0AC, 0xC544, 0xC790, 0xCC28, 0xCE74, 0xD0C0, 0xD30C, 0xD558 }; return toAlphabetic(count, hangulAlphabet); } case EthiopicHalehame: { static const UChar ethiopicHalehameGezAlphabet[26] = { 0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228, 0x1230, 0x1240, 0x1260, 0x1270, 0x1280, 0x1290, 0x12A0, 0x12A8, 0x12C8, 0x12D0, 0x12D8, 0x12E8, 0x12F0, 0x1308, 0x1320, 0x1330, 0x1338, 0x1340, 0x1348, 0x1350 }; return toAlphabetic(count, ethiopicHalehameGezAlphabet); } case EthiopicHalehameAm: { static const UChar ethiopicHalehameAmAlphabet[33] = { 0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228, 0x1230, 0x1238, 0x1240, 0x1260, 0x1270, 0x1278, 0x1280, 0x1290, 0x1298, 0x12A0, 0x12A8, 0x12B8, 0x12C8, 0x12D0, 0x12D8, 0x12E0, 0x12E8, 0x12F0, 0x1300, 0x1308, 0x1320, 0x1328, 0x1330, 0x1338, 0x1340, 0x1348, 0x1350 }; return toAlphabetic(count, ethiopicHalehameAmAlphabet); } case EthiopicHalehameTiEr: { static const UChar ethiopicHalehameTiErAlphabet[31] = { 0x1200, 0x1208, 0x1210, 0x1218, 0x1228, 0x1230, 0x1238, 0x1240, 0x1250, 0x1260, 0x1270, 0x1278, 0x1290, 0x1298, 0x12A0, 0x12A8, 0x12B8, 0x12C8, 0x12D0, 0x12D8, 0x12E0, 0x12E8, 0x12F0, 0x1300, 0x1308, 0x1320, 0x1328, 0x1330, 0x1338, 0x1348, 0x1350 }; return toAlphabetic(count, ethiopicHalehameTiErAlphabet); } case EthiopicHalehameTiEt: { static const UChar ethiopicHalehameTiEtAlphabet[34] = { 0x1200, 0x1208, 0x1210, 0x1218, 0x1220, 0x1228, 0x1230, 0x1238, 0x1240, 0x1250, 0x1260, 0x1270, 0x1278, 0x1280, 0x1290, 0x1298, 0x12A0, 0x12A8, 0x12B8, 0x12C8, 0x12D0, 0x12D8, 0x12E0, 0x12E8, 0x12F0, 0x1300, 0x1308, 0x1320, 0x1328, 0x1330, 0x1338, 0x1340, 0x1348, 0x1350 }; return toAlphabetic(count, ethiopicHalehameTiEtAlphabet); } case KoreanHangulFormal: { static const UChar koreanHangulFormalTable[26] = { Korean, 0xB9CC, 0x0000, 0xC5B5, 0x0000, 0xC870, 0x0000, 0xC2ED, 0xBC31, 0xCC9C, 0xC601, 0xC77C, 0xC774, 0xC0BC, 0xC0AC, 0xC624, 0xC721, 0xCE60, 0xD314, 0xAD6C, 0xB9C8, 0xC774, 0xB108, 0xC2A4, 0x0020, 0x0000 }; return toCJKIdeographic(count, koreanHangulFormalTable, Formal); } case KoreanHanjaFormal: { static const UChar koreanHanjaFormalTable[26] = { Korean, 0x842C, 0x0000, 0x5104, 0x0000, 0x5146, 0x0000, 0x62FE, 0x767E, 0x4EDF, 0x96F6, 0x58F9, 0x8CB3, 0x53C3, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D, 0xB9C8, 0xC774, 0xB108, 0xC2A4, 0x0020, 0x0000 }; return toCJKIdeographic(count, koreanHanjaFormalTable, Formal); } case KoreanHanjaInformal: { static const UChar koreanHanjaInformalTable[26] = { Korean, 0x842C, 0x0000, 0x5104, 0x0000, 0x5146, 0x0000, 0x5341, 0x767E, 0x5343, 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D, 0xB9C8, 0xC774, 0xB108, 0xC2A4, 0x0020, 0x0000 }; return toCJKIdeographic(count, koreanHanjaInformalTable, Informal); } case CJKIdeographic: case TradChineseInformal: { static const UChar traditionalChineseInformalTable[22] = { Chinese, 0x842C, 0x0000, 0x5104, 0x0000, 0x5146, 0x0000, 0x5341, 0x767E, 0x5343, 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D, 0x8CA0, 0x0000 }; return toCJKIdeographic(count, traditionalChineseInformalTable, Informal); } case SimpChineseInformal: { static const UChar simpleChineseInformalTable[22] = { Chinese, 0x4E07, 0x0000, 0x4EBF, 0x0000, 0x4E07, 0x4EBF, 0x5341, 0x767E, 0x5343, 0x96F6, 0x4E00, 0x4E8C, 0x4E09, 0x56DB, 0x4E94, 0x516D, 0x4E03, 0x516B, 0x4E5D, 0x8D1F, 0x0000 }; return toCJKIdeographic(count, simpleChineseInformalTable, Informal); } case TradChineseFormal: { static const UChar traditionalChineseFormalTable[22] = { Chinese, 0x842C, 0x0000, 0x5104, 0x0000, 0x5146, 0x0000, 0x62FE, 0x4F70, 0x4EDF, 0x96F6, 0x58F9, 0x8CB3, 0x53C3, 0x8086, 0x4F0D, 0x9678, 0x67D2, 0x634C, 0x7396, 0x8CA0, 0x0000 }; return toCJKIdeographic(count, traditionalChineseFormalTable, Formal); } case SimpChineseFormal: { static const UChar simpleChineseFormalTable[22] = { Chinese, 0x4E07, 0x0000, 0x4EBF, 0x0000, 0x4E07, 0x4EBF, 0x62FE, 0x4F70, 0x4EDF, 0x96F6, 0x58F9, 0x8D30, 0x53C1, 0x8086, 0x4F0D, 0x9646, 0x67D2, 0x634C, 0x7396, 0x8D1F, 0x0000 }; return toCJKIdeographic(count, simpleChineseFormalTable, Formal); } case LowerRoman: return toRoman(count, false); case UpperRoman: return toRoman(count, true); case Armenian: case UpperArmenian: // CSS3 says "armenian" means "lower-armenian". // But the CSS2.1 test suite contains uppercase test results for "armenian", // so we'll match the test suite. return toArmenian(count, true); case LowerArmenian: return toArmenian(count, false); case Georgian: return toGeorgian(count); case Hebrew: return toHebrew(count); } ASSERT_NOT_REACHED(); return ""; }
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; }
static inline String toNumeric(int number, const CharacterType(&alphabet)[size]) { return toNumeric(number, alphabet, size); }