diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e10c35d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +tmp/ +*.log +*.tmp +.* diff --git a/README.md b/README.md new file mode 100644 index 0000000..665d1cf --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +## What is this? + +This repo was a **unofficial** MediaTek feeds for [OpenWrt](https://openwrt.org "OpenWrt") or [Lede](https://lede-project.org). This project is experimental, and technical support will be limited. + +In OpenWrt/Lede, a [feeds](https://wiki.openwrt.org/doc/devel/feeds "feeds") is collection of software components (applications, libraries, kernel-modules, ...) that you can integrate into your OpenWrt/Lede system. + +## How can I use them? + +I assume that you already have a working OpenWrt/Lede workspace, then add the following line into "feeds.conf.default" (You will find it under the top dir of your workspace). + + src-git mtk https://github.com/Nossiac/mtk-openwrt-feeds;lede-17.01 + +then execute: + + scripts/feeds update -f mtk + scripts/feeds install -a -p mtk + +Now you will be able to see extra packages via `make menuconfig`. All packages from this feeds are located under `MTK Properties`. + +## What do we have here? + +### mt7620/mt7610/mt7612/mt7628/mt7603/mt7615 + +These are prebuilt WiFi modules for OpenWrt/Lede. + +The following drivers are planned : + +* mt7620 (done) +* mt7628 (done) +* mt7610 (done) +* mt7612 (todo) +* mt7603 (todo) +* mt7615 (done) + +Currently I only build them with latest stable branch of lede. + +### uci2dat + +An application that translates "/etc/config/wireless" into MTK's WiFi profiles (e.g. mt7620.dat). You may use it as an adapter to make MTK's WiFi drivers work with standard LuCi's WiFi management. + +### mtk-nvram + +The term "nvram" in MTK's software means a raw storage scheme on flash chips. It access flash device in raw mode (without filesystem). + +All data stored in nvram partition are "=[Value]" pairs. It usually resides in mtd partition "config". + +Noteļ¼š OpenWrt/Lede has replaced nvram scheme with [uci](https://wiki.openwrt.org/doc/uci) long ago. I keep this for back compatibility only. + +### mtk-luci-plugin + +This is a plugin for LuCI web interface, which manipulate MTK's proprietary drivers by reading/writing its profile directly. It does not use uci, so "/etc/config/wireless" is left untouched. + +To use this, you should install LuCI first: + + scripts/feeds update + scripts/feeds install luci + +Also we have a small tool called "web console" along with the plugin, it exposes root shell to the web interface, and sometimes you may need it. + +## Technical support? + +I do this in my spare time, so I cannot promise too much. Anyway, you are welcome to feedback any issues/bugs/suggestions/patches here. That would be helpful for MTK to improve what they are doing. + + diff --git a/applications/mtk-nvram/Makefile b/applications/mtk-nvram/Makefile new file mode 100755 index 0000000..2109d86 --- /dev/null +++ b/applications/mtk-nvram/Makefile @@ -0,0 +1,94 @@ +# +# hua.shao@mediatek.com +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=mtk-nvram +PKG_RELEASE:=1 +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +PKG_KCONFIG:=NVRAM_MTD_NAME + +PKG_MAINTAINER:=Hua Shao + +include $(INCLUDE_DIR)/package.mk + +define Package/nvram + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Applications + TITLE:=MTK APSoC nvram tool + DEPENDS:=+libnvram + MENU:=1 +endef + +define Package/nvram/config + source "$(SOURCE)/config.in" +endef + +define Package/flash + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Applications + TITLE:=MTK APSoC flash R/W tool + DEPENDS:=+libnvram +endef + +define Package/libnvram + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Libraries + TITLE:=MTK APSoC nvram library + DEPENDS:= +endef + +define Package/nvram/description + MTK nvram tool +endef + +define Package/flash/description + flash r/w tool +endef + +define Package/libnvram/description + MTK nvram library +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ + $(call Build/Prepare/Default) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) ./src/nvram.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib*.so $(1)/usr/lib/ +endef + + +MAKE_FLAGS += \ + CONFIG_NVRAM_MTD_NAME=$(CONFIG_NVRAM_MTD_NAME) + + +define Package/nvram/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/nvram $(1)/usr/bin +endef + +define Package/flash/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/flash $(1)/usr/bin +endef + +define Package/libnvram/install + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_BIN) $(PKG_BUILD_DIR)/*.so $(1)/usr/lib +endef + + +$(eval $(call BuildPackage,libnvram)) +$(eval $(call BuildPackage,nvram)) +$(eval $(call BuildPackage,flash)) + diff --git a/applications/mtk-nvram/config.in b/applications/mtk-nvram/config.in new file mode 100755 index 0000000..633c88b --- /dev/null +++ b/applications/mtk-nvram/config.in @@ -0,0 +1,6 @@ +menu "nvram Features" + depends on PACKAGE_nvram +config NVRAM_MTD_NAME + string "mtd name for nvram" + default "Config" +endmenu diff --git a/applications/mtk-nvram/src/Makefile b/applications/mtk-nvram/src/Makefile new file mode 100755 index 0000000..abe3b8c --- /dev/null +++ b/applications/mtk-nvram/src/Makefile @@ -0,0 +1,35 @@ +exe1 := nvram +exe2 := flash +lib:= libnvram.so +libobjs := crc32.o flash.o nvram.o +exe1objs := main_nvram.o +exe2objs := main_flash.o + +CFLAGS += -Wall + +ifdef CONFIG_NVRAM_MTD_NAME +CFLAGS += -DNVRAM_MTD_NAME=\"$(CONFIG_NVRAM_MTD_NAME)\" +endif + +all: $(lib) $(exe1) $(exe2) + +$(lib) : $(libobjs) + $(CC) $(CFLAGS) -shared -o $@ $^ + +$(exe1) : $(exe1objs) $(lib) + $(CC) $(CFLAGS) -o $@ $^ + +$(exe2) : $(exe2objs) flash.o + $(CC) $(CFLAGS) -o $@ $^ + +$(exe1objs): %.o : %.c + $(CC) $(CFLAGS) -fPIC -c $< -o $@ + +$(exe2objs): %.o : %.c + $(CC) $(CFLAGS) -fPIC -c $< -o $@ + +$(libobjs): %.o : %.c + $(CC) $(CFLAGS) -fPIC -c $< -o $@ + +clean: + -rm *.o $(exe1) $(exe2) $(lib) diff --git a/applications/mtk-nvram/src/crc32.c b/applications/mtk-nvram/src/crc32.c new file mode 100755 index 0000000..f337dc3 --- /dev/null +++ b/applications/mtk-nvram/src/crc32.c @@ -0,0 +1,88 @@ +/****************************************************************** + * $File: crc32.c + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ +#include + +static const uint32_t crc_table[256] = +{ + 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, + 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, + 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, + 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, + 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, + 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, + 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, + 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, + 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, + 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, + 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, + 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, + 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, + 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, + 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, + 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, + 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, + 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, + 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, + 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, + 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, + 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, + 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, + 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, + 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, + 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, + 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, + 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, + 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, + 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, + 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, + 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, + 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, + 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, + 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, + 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, + 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, + 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, + 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, + 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, + 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, + 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, + 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, + 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, + 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, + 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, + 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, + 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, + 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, + 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, + 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, + 0x2d02ef8dL +}; + + +#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define DO2(buf) DO1(buf); DO1(buf); +#define DO4(buf) DO2(buf); DO2(buf); +#define DO8(buf) DO4(buf); DO4(buf); + +uint32_t crc32(uint32_t crc, const uint8_t *buf, uint32_t len) +{ + crc = crc ^ 0xffffffffL; + while (len >= 8) + { + DO8(buf); + len -= 8; + } + if (len) do + { + DO1(buf); + } + while (--len); + return crc ^ 0xffffffffL; +} + + diff --git a/applications/mtk-nvram/src/crc32.h b/applications/mtk-nvram/src/crc32.h new file mode 100755 index 0000000..81c7a98 --- /dev/null +++ b/applications/mtk-nvram/src/crc32.h @@ -0,0 +1,16 @@ +/****************************************************************** + * $File: crc32.h + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#ifndef CRC32_H +#define CRC32_H + +#include + +uint32_t crc32(uint32_t crc, const uint8_t *buf, uint32_t len); + +#endif /* CRC32_H */ diff --git a/applications/mtk-nvram/src/flash.c b/applications/mtk-nvram/src/flash.c new file mode 100755 index 0000000..d0038d4 --- /dev/null +++ b/applications/mtk-nvram/src/flash.c @@ -0,0 +1,253 @@ +/****************************************************************** + * $File: flash.c + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nvram.h" +#include "flash.h" + +struct mtd_info_user +{ + uint8_t type; + uint32_t flags; + uint32_t size; + uint32_t erasesize; + uint32_t oobblock; + uint32_t oobsize; + uint32_t ecctype; + uint32_t eccsize; +}; + +struct erase_info_user +{ + uint32_t start; + uint32_t length; +}; + +#define MEMGETINFO _IOR('M', 1, struct mtd_info_user) +#define MEMERASE _IOW('M', 2, struct erase_info_user) +#define min(x,y) ({ typeof(x) _x = (x); typeof(y) _y = (y); (void) (&_x == &_y); _x < _y ? _x : _y; }) + +int32_t mtd_open(const char *name, int32_t flags) +{ + FILE *fp; + char dev[80]; + int i, ret; + + if (strstr(name, "/dev/mtd")) + { + return open(name, flags); + } + + if ((fp = fopen("/proc/mtd", "r"))) + { + while (fgets(dev, sizeof(dev), fp)) + { + if (sscanf(dev, "mtd%d:", &i) && strstr(dev, name)) + { + snprintf(dev, sizeof(dev), "/dev/mtd%d", i); + if ((ret = open(dev, flags)) < 0) + { + snprintf(dev, sizeof(dev), "/dev/mtd/%d", i); + ret = open(dev, flags); + } + fclose(fp); + return ret; + } + } + fclose(fp); + } + fprintf(stderr, "Could not open mtd device, %s\n", strerror(errno)); + return -1; +} + +uint32_t mtd_size(const char *name) +{ + FILE *fp; + char buf[80]; + + if ((fp = fopen("/proc/mtd", "r"))) + { + while (fgets(buf, sizeof(buf), fp)) + { + if (strstr(buf, name)) + { + char * p = strchr(buf, ' '); + ASSERT(p); + p++; + fclose(fp); + return strtoul(p,0,16); + } + } + } + fclose(fp); + return 0; +} + + +int32_t flash_read(char *path, char *buf, off_t from, size_t len) +{ + int32_t fd, ret; + struct mtd_info_user info; + + fd = mtd_open(path, O_RDONLY); + if (fd < 0) + { + fprintf(stderr, "Could not open mtd device\n"); + return -1; + } + + if (ioctl(fd, MEMGETINFO, &info)) + { + fprintf(stderr, "Could not get mtd device info\n"); + close(fd); + return -1; + } + if (len > info.size) + { + fprintf(stderr, "Too many bytes - %zu > %u bytes\n", len, info.erasesize); + close(fd); + return -1; + } + + lseek(fd, from, SEEK_SET); + ret = read(fd, buf, len); + if (ret == -1) + { + fprintf(stderr, "Reading from mtd failed\n"); + close(fd); + return -1; + } + + close(fd); + return ret; +} + + +int32_t flash_write(char *path, char *buf, off_t to, size_t len) +{ + int32_t fd, ret = 0; + char *bak = NULL; + struct mtd_info_user info; + struct erase_info_user ei; + + fd = mtd_open(path, O_RDWR | O_SYNC); + if (fd < 0) + { + fprintf(stderr, "Could not open mtd device\n"); + return -1; + } + + if (ioctl(fd, MEMGETINFO, &info)) + { + fprintf(stderr, "Could not get mtd device info\n"); + close(fd); + return -1; + } + if (len > info.size) + { + fprintf(stderr, "Too many bytes - %zu > %u bytes\n", len, info.erasesize); + close(fd); + return -1; + } + + while (len > 0) + { + if ((len & (info.erasesize-1)) || (len < info.erasesize)) + { + int piece_size; + unsigned int piece, bakaddr; + + bak = (char *)malloc(info.erasesize); + if (bak == NULL) + { + fprintf(stderr, "Not enough memory\n"); + close(fd); + return -1; + } + + bakaddr = to & ~(info.erasesize - 1); + lseek(fd, bakaddr, SEEK_SET); + + ret = read(fd, bak, info.erasesize); + if (ret == -1) + { + fprintf(stderr, "Reading from mtd failed\n"); + close(fd); + free(bak); + return -1; + } + + piece = to & (info.erasesize - 1); + piece_size = min((uint32_t)len, info.erasesize - piece); + memcpy(bak + piece, buf, piece_size); + + ei.start = bakaddr; + ei.length = info.erasesize; + if (ioctl(fd, MEMERASE, &ei) < 0) + { + fprintf(stderr, "Erasing mtd failed\n"); + close(fd); + free(bak); + return -1; + } + + lseek(fd, bakaddr, SEEK_SET); + ret = write(fd, bak, info.erasesize); + if (ret == -1) + { + fprintf(stderr, "Writing to mtd failed\n"); + close(fd); + free(bak); + return -1; + } + + free(bak); + buf += piece_size; + to += piece_size; + len -= piece_size; + } + else + { + ei.start = to; + ei.length = info.erasesize; + if (ioctl(fd, MEMERASE, &ei) < 0) + { + fprintf(stderr, "Erasing mtd failed\n"); + close(fd); + return -1; + } + + ret = write(fd, buf, info.erasesize); + if (ret == -1) + { + fprintf(stderr, "Writing to mtd failed\n"); + close(fd); + free(bak); + return -1; + } + + buf += info.erasesize; + to += info.erasesize; + len -= info.erasesize; + } + } + + close(fd); + return ret; +} + + diff --git a/applications/mtk-nvram/src/flash.h b/applications/mtk-nvram/src/flash.h new file mode 100755 index 0000000..b9f000a --- /dev/null +++ b/applications/mtk-nvram/src/flash.h @@ -0,0 +1,19 @@ +/****************************************************************** + * $File: flash.h + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#ifndef FLASH_H +#define FLASH_H + +#include + +uint32_t mtd_size(const char *name); +int32_t flash_read(char *path, char *buf, off_t from, size_t len); +int32_t flash_write(char *path, char *buf, off_t to, size_t len); + +#endif /* FLASH_H */ + diff --git a/applications/mtk-nvram/src/layout.h b/applications/mtk-nvram/src/layout.h new file mode 100755 index 0000000..312cac1 --- /dev/null +++ b/applications/mtk-nvram/src/layout.h @@ -0,0 +1,52 @@ +/****************************************************************** + * $File: layout.h + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#ifndef LAYOUT_H +#define LAYOUT_H + +/* uncomment NVRAM_CUSTOM_LAYOUT to enable your layout. */ + +// #define NVRAM_CUSTOM_LAYOUT + +#ifdef NVRAM_CUSTOM_LAYOUT +static layout_t nvlayout[] = +{ + /* the first 4KB of "Config" is reserved for uboot. */ + { + .name = "uboot", + .offset = 0x0, + .size = 0x1000, + .flag = NV_RO, + }, + /* you can use the rest space, up to 60KB. */ + { + .name = "2860", + .offset = 0x2000, + .size = 0x4000, + }, + { + .name = "rtdev", + .offset = 0x6000, + .size = 0x2000, + }, + { + .name = "cert", + .offset = 0x8000, + .size = 0x2000, + }, + { + .name = "wapi", + .offset = 0xa000, + .size = 0x5000, + }, +}; +#endif /* NVRAM_CUSTOM_LAYOUT */ + +#endif /* LAYOUT_H */ + + diff --git a/applications/mtk-nvram/src/main_flash.c b/applications/mtk-nvram/src/main_flash.c new file mode 100755 index 0000000..7f04a9a --- /dev/null +++ b/applications/mtk-nvram/src/main_flash.c @@ -0,0 +1,94 @@ +/****************************************************************** + * $File: main.c + * + * $Author: Hua Shao + * $Date: Oct, 2014 + * + ******************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include "flash.h" + + +int usage(void) +{ + printf("%s", "flash r \n"); + printf("%s", "flash w <0xNN> [<0xNN> ...]\n"); + return 0; +} + +int main(int argc, char ** argv) +{ + int off = 0; + int len = 0; + int ret = 0; + int i = 0; + char * buf = NULL; + + if (argc < 5) + return usage(); + + if (0 == strcmp(argv[1], "r")) + { + off = atoi(argv[3]); + len = atoi(argv[4]); + buf = (char *)malloc(len); + if (!buf) + { + fprintf(stderr, "failed to alloc buf[%d], %s\n", len, strerror(errno)); + return -1; + } + memset(buf, 0, len); + + ret = flash_read(argv[2], buf, off, len); + if (ret < 0) + { + fprintf(stderr, "failed to read buf[%d], %s\n", len, strerror(errno)); + if (buf) free(buf); + return -1; + } + + for(i=0; i +#include "nvram.h" + +int32_t usage(int32_t reason) +{ + if (reason != OK) + printf("Invalid usage! "); + fprintf(stderr, "Usage:\n" + "\tnvram get
\n" + "\t\t Get a value from the section by name. It operates in cache.\n" + "\tnvram set
\n" + "\t\t Set a value into the section by name. It operates in cache.\n" + "\tnvram del
\n" + "\t\t Delete an entry in the section by name. It operates in cache.\n" + "\tnvram commit\n" + "\t\t Flush cache into flash.\n" + "\tnvram layout\n" + "\t\t Display nvram sections layout.\n" + "\tnvram show [section]\n" + "\t\t Display all entries in nvram. Section name is optional.\n" + "\tnvram loadfile
\n" + "\t\t Load nvram entries from a file, and flush it into the section.\n" + "\tnvram clear
\n" + "\t\t DANGEROUS! Clear all nvram entries inside flash.\n" + ); + return OK; +} + + +int32_t main(int32_t argc, char ** argv) +{ +#if 0 + int32_t i = 0; + + for(i=0; i +#include +#include +#include +#include +#include +#include + +#include "nvram.h" +#include "crc32.h" +#include "flash.h" + + +#define MAX_ENTRY 500 + + +typedef struct +{ + char * name; + char * value; +} entry_t; + +typedef struct +{ + char * name; + uint32_t offset; + uint32_t size; + uint32_t flag; + uint32_t crc; + entry_t cache[MAX_ENTRY]; +} section_t; + + +#define NV_RO (1) /* read only */ + +typedef struct +{ + char * name; + uint32_t offset; + uint32_t size; + uint32_t flag; +} layout_t; + +#include "layout.h" + +#ifndef NVRAM_CUSTOM_LAYOUT + +/* this is a demo layout, + please make your own layout in layout.h +*/ + +static layout_t nvlayout[] = +{ + /* the first 4KB of "Config" is reserved for uboot. */ + { + .name = "uboot", + .offset = 0x0, + .size = 0x1000, + .flag = NV_RO, + }, + { + .name = "readonly", + .offset = 0x1000, + .size = 0x1000, + .flag = NV_RO, + }, + { + .name = "test1", + .offset = 0x2000, + .size = 0x4000, + .flag = 0, + }, + { + .name = "test2", + .offset = 0x6000, + .size = 0x2000, + .flag = 0, + }, + { + .name = "test3", + .offset = 0x8000, + .size = 0x8000, + }, +}; +#endif + + +static uint32_t nvram_mtd_size = 0; +static section_t * nvramcache = NULL; +static uint32_t sectionnum = sizeof(nvlayout)/sizeof(layout_t); + +static section_t * _nvram_section(char * name) +{ + int32_t i = 0; + for (i=0; iflag & NV_RO) + { + fprintf(stderr, "section \"%s\"is read-only!\n", section); + return NG; + } + + /* check if name exists */ + for (i=0; icache[i].name && + 0 == strcmp(key, sect->cache[i].name)) + break; + } + + if (i >= MAX_ENTRY) + { + fprintf(stderr, "no such entry!\n"); + return NG; + } + + sfree(sect->cache[i].name); + sfree(sect->cache[i].value); + + return OK; + +} + + +static int32_t _nvram_buf_set(char * section, char * key, char * value) +{ + int32_t i = 0; + section_t * sect = NULL; + + DEBUG("%s(%s,%s,%s)\n", __FUNCTION__, section, key, value); + + sect = _nvram_section(section); + if (!sect) + return NG; + + if (sect->flag & NV_RO) + { + fprintf(stderr, "section \"%s\"is read-only!\n", section); + return NG; + } + + /* check if name exists */ + for (i=0; icache[i].name && + 0 == strcmp(key, sect->cache[i].name)) + break; + } + if (i < MAX_ENTRY) + goto __set; + + /* else, find an empty room */ + for (i=0; icache[i].name) + break; + } + if (i >= MAX_ENTRY) + { + fprintf(stderr, "no empty room found! %s\n", __FUNCTION__); + return NG; + } + + ASSERT(!sect->cache[i].name); + ASSERT(!sect->cache[i].value); + +__set: + sect->cache[i].name = strdup(key); + sect->cache[i].value = strdup(value); + + return OK; +} + +static char * _nvram_buf_get(char * section, char * key) +{ + int32_t i = 0; + section_t * sect = NULL; + + DEBUG("%s(%s,%s)\n", __FUNCTION__, section, key); + + sect = _nvram_section(section); + if (!sect) + return NULL; + + for (i=0; icache[i].name && + 0 == strcmp(sect->cache[i].name, key)) + { + printf("%s\n", sect->cache[i].value); + return sect->cache[i].value; + } + } + + fprintf(stderr, "no such entry!\n"); + return NULL; +} + + + +int32_t nvram_parse(char * section, char * cachefile) +{ + int32_t rc = 0; + FILE * fp = NULL; + size_t len = 0; + char * data, * p = NULL, * q = NULL; + int32_t i = 0, j = 0; + + API(); + + fp = fopen(cachefile, "r+b"); + if (!fp) + { + fprintf(stderr, "failed to load %s, %s, %s\n", cachefile, strerror(errno), __FUNCTION__); + return NG; + } + + fseek(fp, 0, SEEK_END); + len = ftell(fp); + fseek(fp, 0, SEEK_SET); + + data = (char *)malloc(len); + if(!data) + { + fprintf(stderr, "failed to alloc buffer (%zu) for nvram! %s.\n", len, __FUNCTION__); + fclose(fp); + return NG; + } + memset(data, 0, len); + rc = fread(data, 1, len, fp); + DEBUG("rc %d, len %zu\n", rc, len); + ASSERT(rc == len); + + nvramcache = (section_t *)malloc(sizeof(section_t)*sectionnum); + memset(nvramcache, 0, sizeof(sizeof(section_t)*sectionnum)); + for (i = 0; i 128) break; + q = strchr(p, '='); + if (!q) + { + fprintf(stderr, "nvram format error, offset %d, in %s!\n", + (int32_t)(p-data), nvlayout[i].name); + break; + } + *q = 0; + q++; + DEBUG("\t<%s>=<%s>\n", p, q); + nvramcache[i].cache[j].name = strdup(p); + nvramcache[i].cache[j].value = strdup(q); + p = q + strlen(q) + 1; + j++; + } + } + + fclose(fp); + return OK; +} + + +int32_t nvram_commit(char flash) +{ + int32_t rc = OK; + int32_t sect = 0, i = 0; + FILE * fp = NULL; + char * buffer = NULL, * p = NULL, * q = NULL; + + API(); + + fp = fopen(NVRAM_CACHE_FILE, "r+"); + if(!fp) + { + fprintf(stderr, "failed to open %s, %s.\n", NVRAM_CACHE_FILE, __FUNCTION__); + rc = NG; + goto __quit; + } + + buffer = (char *)malloc(nvram_mtd_size); + if(!buffer) + { + fprintf(stderr, "failed to alloc buffer (%d) for nvram! %s.\n", nvram_mtd_size, __FUNCTION__); + rc = NG; + goto __quit; + } + + for (sect=0; sect=q) + { + fprintf(stderr, "exceed nvram section size %u!\n", nvramcache[sect].size); + rc = NG; + goto __quit; + } + sprintf(p, "%s=%s", + nvramcache[sect].cache[i].name, + nvramcache[sect].cache[i].value); + p += l; + } + } + *p = '\0'; // just make sure + + nvramcache[sect].crc = + crc32(0, (uint8_t *)(buffer + nvramcache[sect].offset+4), nvramcache[sect].size-4); + *(uint32_t *)(buffer + nvramcache[sect].offset) = nvramcache[sect].crc; + DEBUG("cal crc32 = 0x%8x!\n", nvramcache[sect].crc); + p = buffer + nvramcache[sect].offset; + + fseek(fp, nvramcache[sect].offset, SEEK_SET); + DEBUG("write nvram raw data, offset %u, size %u!\n", + nvramcache[sect].offset, nvramcache[sect].size); + i = fwrite(buffer + nvramcache[sect].offset, 1, nvramcache[sect].size, fp); + ASSERT(i == nvramcache[sect].size); + } + + if (flash) + { + i = flash_write(NVRAM_MTD_NAME, buffer, 0, nvram_mtd_size); + ASSERT(i>0); + } + + +__quit: + sfree(buffer); + fclose(fp); + return rc; +} + + +char * nvram_get(char * section, char * key) +{ + API(); + return _nvram_buf_get(section, key); +} + + +int32_t nvram_del(char * section, char * key) +{ + API(); + + if (OK == _nvram_buf_del(section, key)) + return nvram_commit(0); + return NG; +} + + +int32_t nvram_set(char * section, char * key, char * value) +{ + API(); + if (OK == _nvram_buf_set(section, key, value)) + return nvram_commit(0); + return NG; +} + +int32_t nvram_show(char * section) +{ + int32_t i = 0, j = 0; + API(); + for (i=0; iflag & NV_RO)) + { + fprintf(stderr, "invalid section!\n"); + return NG; + } + + fseek(fp, sec->offset, SEEK_SET); + + buffer = (char *)malloc(sec->size); + if(!buffer) + { + fprintf(stderr, "failed to alloc buffer (%d) for nvram! %s.\n", sec->size, __FUNCTION__); + fclose(fp); + return NG; + } + memset(buffer, 0, sec->size); + + sec->crc = + crc32(0, (uint8_t *)(buffer+4), sec->size-4); + *(uint32_t *)(buffer) = sec->crc; + + i = fwrite(buffer, sec->size, 1, fp); + ASSERT(i == 1); + + fclose(fp); + return OK; +} + +int32_t nvram_loadfile(char * section, char * defile) +{ + API(); + + if (OK == nvram_parse(section, defile)) + return nvram_commit(1); + + return NG; +} + + +int32_t nvram_filecache(char * defile) +{ + int32_t rc = OK; + FILE * fp = NULL; + struct stat statbuf; + char * buffer = NULL; + int32_t i; + + API(); + + nvram_mtd_size = mtd_size(NVRAM_MTD_NAME); + DEBUG("mtd_size(%s) = %u\n", NVRAM_MTD_NAME, nvram_mtd_size); + if (nvram_mtd_size <= 0) + return NG; + + + /* create a cache file */ + rc = stat(defile, &statbuf); + if (!rc) + { + DEBUG("cache file %s is ready.\n", defile); + return OK; + } + + + fp = fopen(defile, "w+b"); + if (!fp) + { + fprintf(stderr, "failed to create %s, %s, %s\n", + defile, strerror(errno), __FUNCTION__); + return NG; + } + DEBUG("cache file %s, created.\n", defile); + + buffer = (char *)malloc(nvram_mtd_size); + if(!buffer) + { + fprintf(stderr, "failed to alloc %d bytes for , %s, %s\n", + nvram_mtd_size, defile, __FUNCTION__); + fclose(fp); + return NG; + } + rc = fwrite(buffer, 1, nvram_mtd_size, fp); + ASSERT(rc == nvram_mtd_size); + + /* dump nvram partition into a cache file. */ + for (i=0; i +#include +#include + +#ifndef NVRAM_CACHE_FILE +#define NVRAM_CACHE_FILE "/tmp/.nvramcache" +#endif + +#ifndef NVRAM_MTD_NAME +#define NVRAM_MTD_NAME "Config" +#endif + + +#define OK (0) +#define NG (-1) + +#if 0 +#define DEBUG(...) do{ fprintf(stderr, " ");printf(__VA_ARGS__);} while(0) +#define API() fprintf(stderr, " api: %s.\n", __FUNCTION__) +#else +#define DEBUG(...) +#define API() +#endif +#define ASSERT(cond) \ + do { \ + if(!(cond)) \ + { \ + fprintf(stderr, " assert [%s] fail, %s L%d\n", #cond, __FUNCTION__, __LINE__); \ + exit(-1); \ + } \ + } while(0) + +#define sfree(p) do {if(p) { free(p); p = NULL;} } while(0) + +char * nvram_get(char * section, char * key); +int32_t nvram_set(char * section, char * key, char * value); +int32_t nvram_del(char * section, char * key); +int32_t nvram_show(char * section); +int32_t nvram_layout(void); +int32_t nvram_loadfile(char * section, char * defile); +int32_t nvram_filecache(char * defile); +int32_t nvram_clear(char * section); +int32_t nvram_parse(char * section, char * cachefile); +int32_t nvram_commit(char flash); + +#endif /* NVRAM_H */ + diff --git a/applications/reg/Makefile b/applications/reg/Makefile new file mode 100755 index 0000000..e6090a3 --- /dev/null +++ b/applications/reg/Makefile @@ -0,0 +1,45 @@ +# +# hua.shao@mediatek.com +# +# MTK Property Software. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=reg +PKG_RELEASE:=1 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +PKG_CONFIG_DEPENDS:= + +PKG_MAINTAINER:=Hua Shao + +include $(INCLUDE_DIR)/package.mk + +define Package/reg + SECTION:=MTK Properties + CATEGORY:=MTK Properties + DEPENDS:= + TITLE:=todo + SUBMENU:=Applications +endef + +define Package/reg/description + todo +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ +endef + +TARGET_CFLAGS += -Wall +TARGET_CFLAGS += -Wno-error=format-security + +define Package/reg/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/reg $(1)/usr/bin +endef + + +$(eval $(call BuildPackage,reg)) diff --git a/applications/reg/src/Makefile b/applications/reg/src/Makefile new file mode 100755 index 0000000..f47eee9 --- /dev/null +++ b/applications/reg/src/Makefile @@ -0,0 +1,11 @@ +EXEC = reg +OBJS = reg.o + +all: $(EXEC) + +$(EXEC): $(OBJS) + $(CC) $(LDFLAGS) -o $@ $(OBJS) + +clean: + -rm -f $(EXEC) *.elf *.gdb *.o + diff --git a/applications/reg/src/reg.c b/applications/reg/src/reg.c new file mode 100755 index 0000000..a7663d6 --- /dev/null +++ b/applications/reg/src/reg.c @@ -0,0 +1,355 @@ +#include /* malloc, free, etc. */ +#include /* stdin, stdout, stderr */ +#include /* strdup */ +#include +#include + +#if 0 +#include "rdm.h" + + +int ra_reg_write(int offset, int value) +{ + int fd; + int method = RT_RDM_CMD_WRITE | (offset << 16); + + fd = open("/dev/rdm0", O_RDONLY); + if (fd < 0) + { + printf("Open pseudo device failed\n"); + return -1; + } + + if(ioctl(fd, method, &value)<0) + { + printf("ioctl error\n"); + close(fd); + return -1; + } + + close(fd); + return 0; +} + +int ra_reg_read(int offset) +{ + int fd; + + fd = open("/dev/rdm0", O_RDONLY); + if (fd < 0) + { + printf("Open pseudo device failed\n"); + return -1; + } + + if(ioctl(fd, RT_RDM_CMD_READ, &offset)<0) + { + printf("ioctl error\n"); + close(fd); + return -1; + } + + close(fd); + + return offset; +} + +void ra_reg_mod_bits(int offset, int data, int start_bit, int len) +{ + int Mask=0; + int Value; + int i; + + for (i = 0; i < len; i++) + { + Mask |= 1 << (start_bit + i); + } + + Value = ra_reg_read(offset); + Value &= ~Mask; + Value |= (data << start_bit) & Mask;; + + ra_reg_write(offset, Value); +} + + + + +// syntax: reg [r/w] [offset(hex)] [value(hex, w only)] +// example reg r 18 +// example reg w 18 12345678 +int main2(int argc, char *argv[]) +{ + int fd, method = 0, offset = 0, value = 0; + char *p; + char driver[32]= {0}; + char devnum[32]= {0}; + char cmd[64] = {0}; + FILE * fp = NULL; + + + fp = popen("cat /proc/devices | grep rdm | sed -r -n \"s/[0-9]+ //p\"", "r"); + fscanf(fp, "%s", driver); + pclose(fp); + + fp = popen("cat /proc/devices | grep rdm | sed -r -n \"s/ [a-z0-9]*//p\"", "r"); + fscanf(fp, "%s", devnum); + pclose(fp); + + if (strlen(driver) && strlen(devnum)) + { + snprintf(cmd, sizeof(cmd), "[ -c /dev/rdm0 ] || mknod /dev/rdm0 c %d 0", atoi(devnum)); + system(cmd); + } + else + { + printf("RDM module not enabled!\n"); + } + + + if (argc < 3) + { + printf("syntax: reg [method(r/w/s/d/f)] [offset(Hex)] [value(hex, w only)]\n"); + printf("syntax: reg q [interval(Hex in ms)] [count(Hex)]\n"); + printf("syntax: reg o [offset_number] [offset_value]\n"); + printf("read example : reg r 18\n"); + printf("write example : reg w 18 12345678\n"); + printf("dump example : reg d 18 \n"); + printf("dump example [FPGA emulation]: reg f 18 \n"); + printf("modify example : reg m [Offset:Hex] [Data:Hex] [StartBit:Decimal] [DataLen:Decimal] \n"); + printf("To use system register: reg s 0\n"); + printf("To use wireless register: reg s 1\n"); + printf("To use other base address offset: reg s [offset]\n"); + printf("for example: reg s 0xa0500000\n"); + printf("for example: reg m c8 1 31 1\n"); + printf("To show current base address offset: reg s 2\n"); + printf("reg q reads and shows the 16 register values [count] times in the interval of [interval]ms.\n"); + printf("the addresses of the 16 registers are assigned by reg o\n"); + printf("for example: reg o 5 10. This sets the 5th register offset as 0x10\n"); + printf("[interval]: 1 ~ 1000. [count]: 1 ~ 1000. [offset_number]: 0 ~ 15.\n"); + return 0; + } + + p = argv[1]; + if (*p == 'r') + { + method = RT_RDM_CMD_SHOW; + } + else if (*p == 'p') + { + method = RT_RDM_CMD_READ; + } + else if (*p == 'd') + { + method = RT_RDM_CMD_DUMP; + } + else if (*p == 'q') + { + method = RT_RDM_CMD_DUMP_QUEUE; + } + else if (*p == 'f') + { + method = RT_RDM_CMD_DUMP_FPGA_EMU; + } + else if (*p == 'w') + { + method = RT_RDM_CMD_WRITE; + } + else if (*p == 's') + { + p = argv[2]; + if (*p == '0' && *(p+1) == '\0') + { + method = RT_RDM_CMD_SET_BASE_SYS; + } + else if (*p == '1') + { + method = RT_RDM_CMD_SET_BASE_WLAN; + } + else if (*p == '2') + { + method = RT_RDM_CMD_SHOW_BASE; + } + else + { + method = RT_RDM_CMD_SET_BASE; + } + + + if (method != RT_RDM_CMD_SET_BASE) + { + fd = open("/dev/rdm0", O_RDONLY); + if (fd < 0) + { + printf("Open pseudo device failed\n"); + return 0; + } + + ioctl(fd, method, offset); + + close(fd); + + return 0; + } + } + else if (*p == 'm') + { + int offset=strtoul(argv[2], NULL, 16); + int data=strtoul(argv[3], NULL, 16); + int start_bit=strtoul(argv[4], NULL, 10); + int len=strtoul(argv[5], NULL, 10); + if (len > 32) + { + printf("len must <= 32\n"); + return 0; + } + ra_reg_mod_bits(offset,data, start_bit,len); + } + else if (*p == 'o') + { + method = RT_RDM_CMD_DUMP_QUEUE_OFFSET; + } + else + { + printf("method must be either r p d f w s m\n"); + return 0; + } + + p = argv[2]; + if (*p == '0' && *(p+1) == 'x') + p += 2; + if (strlen(p) > 8) + { + printf("invalid offset\n"); + } + + while (*p != '\0') + { + if (*p >= '0' && *p <= '9') + offset = offset * 16 + *p - 48; + else + { + if (*p >= 'A' && *p <= 'F') + offset = offset * 16 + *p - 55; + else if (*p >= 'a' && *p <= 'f') + offset = offset * 16 + *p - 87; + else + { + printf("invalid offset\n"); + return 0; + } + } + p++; + } + + if (method == RT_RDM_CMD_WRITE || method == RT_RDM_CMD_DUMP_QUEUE || method == RT_RDM_CMD_DUMP_QUEUE_OFFSET) + { + p = argv[3]; + if (*p == '0' && *(p+1) == 'x') + p += 2; + if (strlen(p) > 8) + { + printf("invalid value\n"); + } + + method = (method | (offset << 16)); + while (*p != '\0') + { + if (*p >= '0' && *p <= '9') + value = value * 16 + *p - 48; + else + { + if (*p >= 'A' && *p <= 'F') + value = value * 16 + *p - 55; + else if (*p >= 'a' && *p <= 'f') + value = value * 16 + *p - 87; + else + { + printf("invalid value\n"); + return 0; + } + } + p++; + } + offset = value; + } + if ((method & 0xffff) == RT_RDM_CMD_DUMP_QUEUE && ( ((method >> 16) > 1023 || (method >> 16) == 0) || (offset > 1023 || offset == 0 ) )) + { + printf("[interval]: 1 ~ 3ff . [count]: 1 ~ 3ff.\n"); + return 0; + } + if (method == 0) + { + printf("no method\n"); + return 0; + } + fd = open("/dev/rdm0", O_RDONLY); + if (fd < 0) + { + printf("Open pseudo device failed\n"); + return 0; + } + + ioctl(fd, method, &offset); + if (method == RT_RDM_CMD_READ) + { + printf("0x%x\n", offset); + } + + close(fd); + + return 0; +} +#endif + +#include + +int usage() +{ + printf("reg
-- read\n"); + printf("reg
-- write\n"); + return 0; +} + + +int reg_write(unsigned long addr, unsigned long value) +{ + return 0; +} + + +unsigned long reg_read(unsigned long addr) +{ + int fd = open("/dev/mem", O_RDONLY); + unsigned char buf[4]; + + if (lseek(fd, addr, SEEK_SET) < 0) + return 0; + + read(fd, buf, 4); + + return 0; +} + + + + + +int main(int argc, char ** argv) +{ + unsigned long addr, value; + if (argc < 2) + return usage(); + + addr = strtoul(argv[1], NULL, 0); + printf("addr 0x%X\n", addr); + + if (argc > 2) + { + value = strtoul(argv[2], NULL, 0); + printf("value 0x%X\n", value); + } + + return 0; +} + diff --git a/applications/uci2dat/Makefile b/applications/uci2dat/Makefile new file mode 100755 index 0000000..9fe62ca --- /dev/null +++ b/applications/uci2dat/Makefile @@ -0,0 +1,48 @@ +# +# hua.shao@mediatek.com +# +# MTK Property Software. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=uci2dat +PKG_RELEASE:=1 + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) +PKG_CONFIG_DEPENDS:= + +PKG_MAINTAINER:=Hua Shao + +include $(INCLUDE_DIR)/package.mk + +define Package/uci2dat + SECTION:=MTK Properties + CATEGORY:=MTK Properties + DEPENDS:=+libuci + TITLE:=Translate uci config into MTK/Ralink WiFi profile + SUBMENU:=Applications +endef + +define Package/uci2dat/description + Translate uci config into ralink wifi dat format +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) + $(CP) ./src/* $(PKG_BUILD_DIR)/ +endef + +TARGET_CFLAGS += -luci -Wall +TARGET_CFLAGS += -Wno-error=format-security + +define Build/Configure +endef + +define Package/uci2dat/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/uci2dat $(1)/usr/bin +endef + + +$(eval $(call BuildPackage,uci2dat)) diff --git a/applications/uci2dat/src/Makefile b/applications/uci2dat/src/Makefile new file mode 100755 index 0000000..9e73270 --- /dev/null +++ b/applications/uci2dat/src/Makefile @@ -0,0 +1,7 @@ + +uci2dat: + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ uci2dat.c + +clean: + -rm -f *.o *.elf *.gbd + diff --git a/applications/uci2dat/src/uci2dat.c b/applications/uci2dat/src/uci2dat.c new file mode 100755 index 0000000..f7847d5 --- /dev/null +++ b/applications/uci2dat/src/uci2dat.c @@ -0,0 +1,1356 @@ +/***************************************************************************** + * $File: uci2dat.c + * + * $Author: Hua Shao + * $Date: Feb, 2014 + * + * Boring, Boring, Boring, Boring, Boring........ + * + *****************************************************************************/ + + +#include +#include +#include +#include +#include +#include + +#include + + +#ifdef OK +#undef OK +#endif +#define OK (0) + +#ifdef NG +#undef NG +#endif +#define NG (-1) + +#ifdef SHDBG +#undef SHDBG +#endif +#define SHDBG(...) printf(__VA_ARGS__) +#define DEVNUM_MAX (4) +#define MBSSID_MAX (4) + + +#define VFPRINT(fp, e, ...) \ + do {\ + char buffer[128] = {0}; \ + snprintf(buffer, sizeof(buffer), __VA_ARGS__); \ + if (strlen(buffer) > 0) { \ + SHDBG("%s(),%s=", __FUNCTION__, e->dat_key); \ + fprintf(fp, "%s", buffer); \ + SHDBG("%s(),%s=%s, def=\"%s\"\n", __FUNCTION__, \ + e->dat_key, buffer, e->defvalue?e->defvalue:""); \ + } \ + }while(0) + +#define FPRINT(fp, e, v) \ + do {\ + if (v && strlen(v) > 0) { \ + SHDBG("%s(),%s=", __FUNCTION__, e->dat_key); \ + fprintf(fp, "%s", v); \ + SHDBG("%s", v); \ + SHDBG(", def=\"%s\"\n", e->defvalue?e->defvalue:""); \ + } \ + }while(0) + +#define WIFI_UCI_FILE "/etc/config/wireless" + +#define PARSE_UCI_OPTION(dst, src) \ + do { \ + src = NULL; \ + src = uci_lookup_option_string(uci_ctx, s, dst.uci_key); \ + if(src) { \ + dst.value = strdup(src); \ + SHDBG("%s(), %s=%s\n", __FUNCTION__, dst.uci_key, dst.value); \ + } \ + }while(0) + + +struct _param; + +typedef void (*ucihook)(FILE *,struct _param *, const char * devname); + +typedef struct _param +{ + const char * dat_key; + const char * uci_key; + char * value; + ucihook hook; + const char * defvalue; +} param; + + +typedef struct __extra_cfg +{ + param cfg; + struct __extra_cfg * next; +} extra_cfg; + +typedef struct _vif +{ + param ssid; + param authmode; /* wep, wpa, ... */ + param hidden; /* Hidden SSID */ + param cipher; /* ccmp(aes),tkip */ + param key; /* wpa psk */ + + param wepkey[4]; /* wep key, ugly, yep! */ + + param auth_server; + param auth_port; + param auth_secret; + param rekeyinteval; + param preauth; + param pmkcacheperiod; +} vif; + +typedef struct +{ + char devname[16]; + param * params; + int vifnum; + vif vifs[MBSSID_MAX]; +} wifi_params; + +void hooker(FILE * fp, param * p, const char * devname); + +/* these are separated from CFG_ELEMENTS because they + use a different represention structure. +*/ +vif VIF = +{ + .ssid = {NULL, "ssid", NULL, NULL, NULL}, + .authmode = {NULL, "encryption", NULL, NULL, NULL}, + .hidden = {NULL, "hidden", NULL, NULL, NULL}, + .cipher = {NULL, "cipher", NULL, NULL, NULL}, + + /* wpa key, or wep key index */ + .key = {NULL, "key", NULL, NULL, NULL}, + + /* wep key group */ + .wepkey = { + {NULL, "key1", NULL, NULL, NULL}, + {NULL, "key2", NULL, NULL, NULL}, + {NULL, "key3", NULL, NULL, NULL}, + {NULL, "key4", NULL, NULL, NULL} + }, + + /* wpa & 8021x */ + .auth_server = {NULL, "auth_server", "0", NULL, NULL}, + .auth_port = {NULL, "auth_port", "1812", NULL, NULL}, + .auth_secret = {NULL, "auth_secret", NULL, NULL, NULL}, + .pmkcacheperiod = {NULL, "pmkcacheperiod", NULL, NULL, NULL}, + .preauth = {NULL, "preauth", NULL, NULL, NULL}, + .rekeyinteval = {NULL, "rekeyinteval", NULL, NULL, NULL}, +}; + +param CFG_ELEMENTS[] = +{ + /* Default configurations described in : + MTK_Wi-Fi_SoftAP_Software_Programmming_Guide_v3.6.pdf + */ + {"CountryRegion", "region", NULL, hooker, "1"}, + {"CountryRegionABand", "aregion", NULL, hooker, "7"}, + {"CountryCode", "country", NULL, hooker, NULL}, + {"BssidNum", NULL, NULL, hooker, "1"}, + {"SSID1", NULL, NULL, hooker, "OpenWrt"}, + {"SSID2", NULL, NULL, hooker, NULL}, + {"SSID3", NULL, NULL, hooker, NULL}, + {"SSID4", NULL, NULL, hooker, NULL}, + {"WirelessMode", "wifimode", NULL, hooker, "9"}, + {"TxRate", "txrate", NULL, hooker, "0"}, + {"Channel", "channel", NULL, hooker, "0"}, + {"BasicRate", "basicrate", NULL, hooker, "15"}, + {"BeaconPeriod", "beacon", NULL, hooker, "100"}, + {"DtimPeriod", "dtim", NULL, hooker, "1"}, + {"TxPower", "txpower", NULL, hooker, "100"}, + {"DisableOLBC", "disolbc", NULL, hooker, "0"}, + {"BGProtection", "bgprotect", NULL, hooker, "0"}, + {"TxAntenna", "txantenna", NULL, hooker, NULL}, + {"RxAntenna", "rxantenna", NULL, hooker, NULL}, + {"TxPreamble", "txpreamble", NULL, hooker, "0"}, + {"RTSThreshold", "rtsthres", NULL, hooker, "2347"}, + {"FragThreshold", "fragthres", NULL, hooker, "2346"}, + {"TxBurst", "txburst", NULL, hooker, "1"}, + {"PktAggregate", "pktaggre", NULL, hooker, "0"}, + {"TurboRate", "turborate", NULL, hooker, "0"}, + {"WmmCapable", "wmm", NULL, hooker, "1"}, + {"APSDCapable", "apsd", NULL, hooker, "1"}, + {"DLSCapable", "dls", NULL, hooker, "0"}, + {"APAifsn", "apaifsn", NULL, hooker, "3;7;1;1"}, + {"APCwmin", "apcwmin", NULL, hooker, "4;4;3;2"}, + {"APCwmax", "apcwmax", NULL, hooker, "6;10;4;3"}, + {"APTxop", "aptxop", NULL, hooker, "0;0;94;47"}, + {"APACM", "apacm", NULL, hooker, "0;0;0;0"}, + {"BSSAifsn", "bssaifsn", NULL, hooker, "3;7;2;2"}, + {"BSSCwmin", "bsscwmin", NULL, hooker, "4;4;3;2"}, + {"BSSCwmax", "bsscwmax", NULL, hooker, "10;10;4;3"}, + {"BSSTxop", "bsstxop", NULL, hooker, "0;0;94;47"}, + {"BSSACM", "bssacm", NULL, hooker, "0;0;0;0"}, + {"AckPolicy", "ackpolicy", NULL, hooker, "0;0;0;0"}, + {"NoForwarding", "noforward", NULL, hooker, "0"}, + {"NoForwardingBTNBSSID", NULL, NULL, NULL, "0"}, + {"HideSSID", "hidden", NULL, hooker, "0"}, + {"StationKeepAlive", NULL, NULL, NULL, "0"}, + {"ShortSlot", "shortslot", NULL, hooker, "1"}, + {"AutoChannelSelect", "channel", NULL, hooker, "2"}, + {"IEEE8021X", "ieee8021x", NULL, hooker, "0"}, + {"IEEE80211H", "ieee80211h", NULL, hooker, "0"}, + {"CSPeriod", "csperiod", NULL, hooker, "10"}, + {"WirelessEvent", "wirelessevent", NULL, hooker, "0"}, + {"IdsEnable", "idsenable", NULL, hooker, "0"}, + {"AuthFloodThreshold", NULL, NULL, NULL, "32"}, + {"AssocReqFloodThreshold", NULL, NULL, NULL, "32"}, + {"ReassocReqFloodThreshold", NULL, NULL, NULL, "32"}, + {"ProbeReqFloodThreshold", NULL, NULL, NULL, "32"}, + {"DisassocFloodThreshold", NULL, NULL, NULL, "32"}, + {"DeauthFloodThreshold", NULL, NULL, NULL, "32"}, + {"EapReqFooldThreshold", NULL, NULL, NULL, "32"}, + {"PreAuth", "preauth", NULL, hooker, "0"}, + {"AuthMode", NULL, NULL, hooker, "OPEN"}, + {"EncrypType", NULL, NULL, hooker, "NONE"}, + {"RekeyInterval", "rekeyinteval", NULL, hooker, "0"}, + {"PMKCachePeriod", "pmkcacheperiod", NULL, hooker, "10"}, + {"WPAPSK1", NULL, NULL, hooker, NULL}, + {"WPAPSK2", NULL, NULL, hooker, NULL}, + {"WPAPSK3", NULL, NULL, hooker, NULL}, + {"WPAPSK4", NULL, NULL, hooker, NULL}, + {"DefaultKeyID", NULL, NULL, hooker, "1"}, + {"Key1Type", NULL, NULL, hooker, "1"}, + {"Key1Str1", NULL, NULL, hooker, NULL}, + {"Key1Str2", NULL, NULL, hooker, NULL}, + {"Key1Str3", NULL, NULL, hooker, NULL}, + {"Key1Str4", NULL, NULL, hooker, NULL}, + {"Key2Type", NULL, NULL, hooker, "1"}, + {"Key2Str1", NULL, NULL, hooker, NULL}, + {"Key2Str2", NULL, NULL, hooker, NULL}, + {"Key2Str3", NULL, NULL, hooker, NULL}, + {"Key2Str4", NULL, NULL, hooker, NULL}, + {"Key3Type", NULL, NULL, hooker, "1"}, + {"Key3Str1", NULL, NULL, hooker, NULL}, + {"Key3Str2", NULL, NULL, hooker, NULL}, + {"Key3Str3", NULL, NULL, hooker, NULL}, + {"Key3Str4", NULL, NULL, hooker, NULL}, + {"Key4Type", NULL, NULL, hooker, "1"}, + {"Key4Str1", NULL, NULL, hooker, NULL}, + {"Key4Str2", NULL, NULL, hooker, NULL}, + {"Key4Str3", NULL, NULL, hooker, NULL}, + {"Key4Str4", NULL, NULL, hooker, NULL}, + {"AccessPolicy0", NULL, NULL, NULL, "0"}, + {"AccessControlList0", NULL, NULL, NULL, NULL}, + {"AccessPolicy1", NULL, NULL, NULL, "0"}, + {"AccessControlList1", NULL, NULL, NULL, NULL}, + {"AccessPolicy2", NULL, NULL, NULL, "0"}, + {"AccessControlList2", NULL, NULL, NULL, NULL}, + {"AccessPolicy3", NULL, NULL, NULL, "0"}, + {"AccessControlList3", NULL, NULL, NULL, NULL}, + {"WdsEnable", "wds_enable", NULL, hooker, "0"}, + {"WdsEncrypType", "wds_enctype", NULL, hooker, "NONE"}, + {"WdsList", NULL, NULL, NULL, NULL}, + {"Wds0Key", NULL, NULL, NULL, NULL}, + {"Wds1Key", NULL, NULL, NULL, NULL}, + {"Wds2Key", NULL, NULL, NULL, NULL}, + {"Wds3Key", NULL, NULL, NULL, NULL}, + {"RADIUS_Server", "auth_server", NULL, hooker, NULL}, + {"RADIUS_Port", "auth_port", NULL, hooker, NULL}, + {"RADIUS_Key1", "radius_key1", NULL, hooker, NULL}, + {"RADIUS_Key2", "radius_key2", NULL, hooker, NULL}, + {"RADIUS_Key3", "radius_key2", NULL, hooker, NULL}, + {"RADIUS_Key4", "radius_key4", NULL, hooker, NULL}, + {"own_ip_addr", "own_ip_addr", NULL, hooker, "192.168.5.234"}, + {"EAPifname", "eapifname", NULL, hooker, NULL}, + {"PreAuthifname", "preauthifname", NULL, hooker, "br-lan"}, + {"HT_HTC", "ht_htc", NULL, hooker, "0"}, + {"HT_RDG", "ht_rdg", NULL, hooker, "0"}, + {"HT_EXTCHA", "ht_extcha", NULL, hooker, "0"}, + {"HT_LinkAdapt", "ht_linkadapt", NULL, hooker, "0"}, + {"HT_OpMode", "ht_opmode", NULL, hooker, "0"}, + {"HT_MpduDensity", NULL, NULL, hooker, "5"}, + {"HT_BW", "bw", NULL, hooker, "0"}, + {"VHT_BW", "bw", NULL, hooker, "0"}, + {"VHT_Sec80_Channel", "vht2ndchannel", NULL, hooker, NULL}, + {"VHT_SGI", "vht_sgi", NULL, hooker, "1"}, + {"VHT_STBC", "vht_stbc", NULL, hooker, "0"}, + {"VHT_BW_SIGNAL", "vht_bw_sig", NULL, hooker, "0"}, + {"VHT_DisallowNonVHT", "vht_disnonvht", NULL, hooker, NULL}, + {"VHT_LDPC", "vht_ldpc", NULL, hooker, "1"}, + {"HT_AutoBA", "ht_autoba", NULL, hooker, "1"}, + {"HT_AMSDU", "ht_amsdu", NULL, hooker, NULL}, + {"HT_BAWinSize", "ht_bawinsize", NULL, hooker, "64"}, + {"HT_GI", "ht_gi", NULL, hooker, "1"}, + {"HT_MCS", "ht_mcs", NULL, hooker, "33"}, + {"WscManufacturer", "wscmanufacturer", NULL, hooker, NULL}, + {"WscModelName", "wscmodelname", NULL, hooker, NULL}, + {"WscDeviceName", "wscdevicename", NULL, hooker, NULL}, + {"WscModelNumber", "wscmodelnumber", NULL, hooker, NULL}, + {"WscSerialNumber", "wscserialnumber", NULL, hooker, NULL}, + + /* Extra configurations found in 76x2e */ + {"FixedTxMode", "fixedtxmode", NULL, hooker, "0"}, + {"AutoProvisionEn", "autoprovision", NULL, hooker, "0"}, + {"FreqDelta", "freqdelta", NULL, hooker, "0"}, + {"CarrierDetect", "carrierdetect", NULL, hooker, "0"}, + {"ITxBfEn", NULL, NULL, hooker, "0"}, + {"PreAntSwitch", "preantswitch", NULL, hooker, "1"}, + {"PhyRateLimit", "phyratelimit", NULL, hooker, "0"}, + {"DebugFlags", "debugflags", NULL, hooker, "0"}, + {"ETxBfEnCond", NULL, NULL, hooker, "0"}, + {"ITxBfTimeout", NULL, NULL, NULL, "0"}, + {"ETxBfNoncompress", NULL, NULL, NULL, "0"}, + {"ETxBfIncapable", NULL, NULL, hooker, "1"}, + {"FineAGC", "fineagc", NULL, hooker, "0"}, + {"StreamMode", "streammode", NULL, hooker, "0"}, + {"StreamModeMac0", NULL, NULL, NULL, NULL}, + {"StreamModeMac1", NULL, NULL, NULL, NULL}, + {"StreamModeMac2", NULL, NULL, NULL, NULL}, + {"StreamModeMac3", NULL, NULL, NULL, NULL}, + {"RDRegion", NULL, NULL, NULL, NULL}, + {"DfsLowerLimit", "dfs_lowlimit", NULL, hooker, "0"}, + {"DfsUpperLimit", "dfs_uplimit", NULL, hooker, "0"}, + {"DfsOutdoor", "dfs_outdoor", NULL, hooker, "0"}, + {"SymRoundFromCfg", NULL, NULL, NULL, "0"}, + {"BusyIdleFromCfg", NULL, NULL, NULL, "0"}, + {"DfsRssiHighFromCfg", NULL, NULL, NULL, "0"}, + {"DfsRssiLowFromCfg", NULL, NULL, NULL, "0"}, + {"DFSParamFromConfig", NULL, NULL, NULL, "0"}, + {"FCCParamCh0", NULL, NULL, NULL, NULL}, + {"FCCParamCh1", NULL, NULL, NULL, NULL}, + {"FCCParamCh2", NULL, NULL, NULL, NULL}, + {"FCCParamCh3", NULL, NULL, NULL, NULL}, + {"CEParamCh0", NULL, NULL, NULL, NULL}, + {"CEParamCh1", NULL, NULL, NULL, NULL}, + {"CEParamCh2", NULL, NULL, NULL, NULL}, + {"CEParamCh3", NULL, NULL, NULL, NULL}, + {"JAPParamCh0", NULL, NULL, NULL, NULL}, + {"JAPParamCh1", NULL, NULL, NULL, NULL}, + {"JAPParamCh2", NULL, NULL, NULL, NULL}, + {"JAPParamCh3", NULL, NULL, NULL, NULL}, + {"JAPW53ParamCh0", NULL, NULL, NULL, NULL}, + {"JAPW53ParamCh1", NULL, NULL, NULL, NULL}, + {"JAPW53ParamCh2", NULL, NULL, NULL, NULL}, + {"JAPW53ParamCh3", NULL, NULL, NULL, NULL}, + {"FixDfsLimit", "fixdfslimit", NULL, hooker, "0"}, + {"LongPulseRadarTh", "lpsradarth", NULL, hooker, "0"}, + {"AvgRssiReq", "avgrssireq", NULL, hooker, "0"}, + {"DFS_R66", "dfs_r66", NULL, hooker, "0"}, + {"BlockCh", "blockch", NULL, hooker, NULL}, + {"GreenAP", "greenap", NULL, hooker, "0"}, + {"WapiPsk1", NULL, NULL, NULL, NULL}, + {"WapiPsk2", NULL, NULL, NULL, NULL}, + {"WapiPsk3", NULL, NULL, NULL, NULL}, + {"WapiPsk4", NULL, NULL, NULL, NULL}, + {"WapiPsk5", NULL, NULL, NULL, NULL}, + {"WapiPsk6", NULL, NULL, NULL, NULL}, + {"WapiPsk7", NULL, NULL, NULL, NULL}, + {"WapiPsk8", NULL, NULL, NULL, NULL}, + {"WapiPskType", NULL, NULL, NULL, NULL}, + {"Wapiifname", NULL, NULL, NULL, NULL}, + {"WapiAsCertPath", NULL, NULL, NULL, NULL}, + {"WapiUserCertPath", NULL, NULL, NULL, NULL}, + {"WapiAsIpAddr", NULL, NULL, NULL, NULL}, + {"WapiAsPort", NULL, NULL, NULL, NULL}, + {"RekeyMethod", "rekeymethod", NULL, hooker, "TIME"}, + {"MeshAutoLink", "mesh_autolink", NULL, hooker, "0"}, + {"MeshAuthMode", "mesh_authmode", NULL, hooker, NULL}, + {"MeshEncrypType", "mesh_enctype", NULL, hooker, NULL}, + {"MeshDefaultkey", "mesh_defkey", NULL, hooker, "0"}, + {"MeshWEPKEY", "mesh_wepkey", NULL, hooker, NULL}, + {"MeshWPAKEY", "mesh_wpakey", NULL, hooker, NULL}, + {"MeshId", "mesh_id", NULL, hooker, NULL}, + {"HSCounter", "hscount", NULL, hooker, "0"}, + {"HT_BADecline", "ht_badec", NULL, hooker, "0"}, + {"HT_STBC", "ht_stbc", NULL, hooker, "0"}, + {"HT_LDPC", "ht_ldpc", NULL, hooker, "1"}, + {"HT_TxStream", "ht_txstream", NULL, hooker, "1"}, + {"HT_RxStream", "ht_rxstream", NULL, hooker, "1"}, + {"HT_PROTECT", "ht_protect", NULL, hooker, "1"}, + {"HT_DisallowTKIP", "ht_distkip", NULL, hooker, "0"}, + {"HT_BSSCoexistence", "ht_bsscoexist", NULL, hooker, "0"}, + {"WscConfMode", "wsc_confmode", NULL, hooker, "0"}, + {"WscConfStatus", "wsc_confstatus", NULL, hooker, "2"}, + {"WCNTest", "wcntest", NULL, hooker, "0"}, + {"WdsPhyMode", "wds_phymode", NULL, hooker, NULL}, + {"RADIUS_Acct_Server", "radius_acctserver", NULL, hooker, NULL}, + {"RADIUS_Acct_Port", "radius_acctport", NULL, hooker, "1813"}, + {"RADIUS_Acct_Key", "radius_acctkey", NULL, hooker, NULL}, + {"Ethifname", "ethifname", NULL, hooker, NULL}, + {"session_timeout_interval", "session_intv", NULL, hooker, "0"}, + {"idle_timeout_interval", "idle_intv", NULL, hooker, "0"}, + {"WiFiTest", NULL, NULL, NULL, "0"}, + {"TGnWifiTest", "tgnwifitest", NULL, hooker, "0"}, + {"ApCliEnable", NULL, NULL, NULL, "0"}, + {"ApCliSsid", NULL, NULL, NULL, NULL}, + {"ApCliBssid", NULL, NULL, NULL, NULL}, + {"ApCliAuthMode", NULL, NULL, NULL, NULL}, + {"ApCliEncrypType", NULL, NULL, NULL, NULL}, + {"ApCliWPAPSK", NULL, NULL, NULL, NULL}, + {"ApCliDefaultKeyID", NULL, NULL, NULL, "0"}, + {"ApCliKey1Type", NULL, NULL, NULL, "0"}, + {"ApCliKey1Str", NULL, NULL, NULL, NULL}, + {"ApCliKey2Type", NULL, NULL, NULL, "0"}, + {"ApCliKey2Str", NULL, NULL, NULL, NULL}, + {"ApCliKey3Type", NULL, NULL, NULL, "0"}, + {"ApCliKey3Str", NULL, NULL, NULL, NULL}, + {"ApCliKey4Type", NULL, NULL, NULL, "0"}, + {"ApCliKey4Str", NULL, NULL, NULL, NULL}, + {"EfuseBufferMode", "efusebufmode", NULL, hooker, "0"}, + {"E2pAccessMode", "e2paccmode", NULL, hooker, "1"}, + {"RadioOn", "radio", NULL, hooker, "1"}, + {"BW_Enable", "bw_enable", NULL, hooker, "0"}, + {"BW_Root", "bw_root", NULL, hooker, "0"}, + {"BW_Priority", "bw_priority", NULL, hooker, NULL}, + {"BW_Guarantee_Rate", "bw_grtrate", NULL, hooker, NULL}, + {"BW_Maximum_Rate", "bw_maxrate", NULL, hooker, NULL}, + + /* add more configurations */ + {"AutoChannelSkipList", "autoch_skip", NULL, hooker, NULL}, + {"WscConfMethod", "wsc_confmethod", NULL, hooker, NULL}, + {"WscKeyASCII", "wsc_keyascii", NULL, hooker, NULL}, + {"WscSecurityMode", "wsc_security", NULL, hooker, NULL}, + {"Wsc4digitPinCode", "wsc_4digitpin", NULL, hooker, NULL}, + {"WscVendorPinCode", "wsc_vendorpin", NULL, hooker, NULL}, + {"WscV2Support", "wsc_v2", NULL, hooker, NULL}, + {"HT_MIMOPS", "mimops", NULL, hooker, "3"}, + {"G_BAND_256QAM", "g256qam", NULL, hooker, "1"}, + {"DBDC_MODE", "dbdc", NULL, hooker, "0"}, + {"IgmpSnEnable", "igmpsnoop", NULL, hooker, "1"}, + {"MUTxRxEnable", "mutxrxenable", NULL, hooker, "1"}, + {"ITxBfEnCond", "itxbfencond", NULL, hooker, "0"}, + {"BandSteering", "bandsteering", NULL, hooker, "0"}, + + {NULL, "txbf", NULL, hooker, "0"}, // all txbf params use this hook +}; + +extra_cfg * __extra_cfgs__ = NULL; + +static struct uci_context * uci_ctx; +static struct uci_package * uci_wireless; +static wifi_params wifi_cfg[DEVNUM_MAX]; + + +char * __get_value_by_datkey(char * datkey, wifi_params * wifi) +{ + int i; + for(i=0; iparams[i].dat_key && 0 == strcmp(datkey, wifi->params[i].dat_key)) + return wifi->params[i].value; + return NULL; +} + + +char * __get_value_by_ucikey(char * ucikey, wifi_params * wifi) +{ + int i; + for(i=0; iparams[i].uci_key && 0 == strcmp(ucikey, wifi->params[i].uci_key)) + return wifi->params[i].value; + return NULL; +} + + +int strmatch(const char * str, const char * pattern) +{ + int i = strlen(str); + int j = 0; + if (i != strlen(pattern)) + return -1; + + for(j=0; jdat_key, p->uci_key, + p->value?p->value:"(null)", p->hook?"Y":"-", p->defvalue); + } + } + return NULL; +} + + +void parse_dat(char * devname, char * datpath) +{ + FILE * fp = NULL; + char buffer[1024] = {0}; + char k[512] = {0}; + char v[512] = {0}; + int i = 0, n = 0; + char * p = NULL; + char * q = NULL; + wifi_params * cfg = NULL; + + for (i=0; iparams[n].value = strdup(v); + //printf("%s(), <%s>=<%s>", __FUNCTION__,CFG_ELEMENTS[n].dat_key,cfg->params[n].value); + break; + } + } + if (n >= sizeof(CFG_ELEMENTS)/sizeof(CFG_ELEMENTS[0])) + { + fprintf(stderr, "<%s> not supported by uci2dat yet, ignored.\n", k); + extra_cfg * c = (extra_cfg *)malloc(sizeof(extra_cfg)); + memset(c, 0, sizeof(extra_cfg)); + c->cfg.dat_key = strdup(k); + c->cfg.uci_key = strdup(k); + c->cfg.value = strdup(v); + c->cfg.defvalue = NULL; + c->cfg.hook = NULL; + c->next = __extra_cfgs__; + __extra_cfgs__ = c; + } + // else + // printf("<%s>=<%s>\n", k, v); + + } while(1); + +__error: + if(fp) fclose(fp); + + return; +} + + +void parse_uci(char * arg) +{ + struct uci_element *e = NULL; + const char * value = NULL; + int i = 0; + int cur_dev, cur_vif; + + if (!uci_wireless || !uci_ctx) + { + fprintf(stderr, "%s() uci context not ready!\n", __FUNCTION__); + return; + } + + /* scan wireless devices ! */ + uci_foreach_element(&uci_wireless->sections, e) + { + struct uci_section *s = uci_to_section(e); + + if(0 == strcmp(s->type, "wifi-device")) + { + printf("%s(), wifi-device: %s\n", __FUNCTION__, s->e.name); + for(cur_dev=0; cur_deve.name, wifi_cfg[cur_dev].devname)) + break; + } + + if(cur_dev>=DEVNUM_MAX) + { + printf("%s(), device (%s) not found!\n", __FUNCTION__, s->e.name); + break; + } + + for( i = 0; isections, e) + { + struct uci_section *s = uci_to_section(e); + if(0 == strcmp(s->type, "wifi-iface")) + { + value = NULL; + value = uci_lookup_option_string(uci_ctx, s, "device"); + for(cur_dev=0; cur_dev= DEVNUM_MAX) + { + fprintf(stderr, "%s(), device (%s) not found!\n", __FUNCTION__, value); + break; + } + value = NULL; + value = uci_lookup_option_string(uci_ctx, s, "ifname"); + printf("%s(), wifi-iface: %s\n", __FUNCTION__, value); + + cur_vif = wifi_cfg[cur_dev].vifnum; + + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].ssid, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].hidden, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].key, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].wepkey[0], value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].wepkey[1], value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].wepkey[2], value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].wepkey[3], value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].auth_server, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].auth_port, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].auth_secret, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].rekeyinteval, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].preauth, value); + PARSE_UCI_OPTION(wifi_cfg[cur_dev].vifs[cur_vif].pmkcacheperiod, value); + + #define STRNCPPP(dst,src) \ + do {\ + dst.value = strdup(src);\ + printf("%s(), %s=%s\n", __FUNCTION__, dst.uci_key, src); \ + } while(0) + + /* cipher */ + value = uci_lookup_option_string(uci_ctx, s, "encryption"); + if(value) + { + const char * p = NULL; + if (0 == strncmp("8021x", value, strlen("8021x"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "8021x"); + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "wep"); + } + + if (0 == strncmp("none", value, strlen("none"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "none"); + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "NONE"); + } + else if (0 == strncmp("wep-open", value, strlen("wep-open"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wep-open"); + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "wep"); + } + else if (0 == strncmp("wep-shared", value, strlen("wep-shared"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wep-shared"); + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "wep"); + } + else if (0 == strncmp("mixed-psk", value, strlen("mixed-psk"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk-mixed"); + p = value+strlen("mixed-psk"); + if (*p == '+' && *(p+1) != 0) + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, p+1); + else + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "tkip+ccmp"); + } + else if(0 == strncmp("psk", value, strlen("psk"))) + { + if (0 == strncmp("psk-mixed", value, strlen("psk-mixed"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk-mixed"); + p = value+strlen("psk-mixed"); + } + else if (0 == strncmp("psk+psk2", value, strlen("psk+psk2"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk-mixed"); + p = value+strlen("psk+psk2"); + } + else if (0 == strncmp("psk2", value, strlen("psk2"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk2"); + p = value+strlen("psk2"); + } + else if (0 == strncmp("psk", value, strlen("psk"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "psk"); + p = value+strlen("psk"); + } + + if (*p == '+' && *(p+1) != 0) + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, p+1); + else + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "tkip+ccmp"); + } + else if(0 == strncmp("wpa", value, strlen("wpa"))) + { + if (0 == strncmp("wpa-mixed", value, strlen("wpa-mixed"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wpa-mixed"); + p = value+strlen("wpa-mixed"); + } + else if (0 == strncmp("wpa+wpa2", value, strlen("wpa+wpa2"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wpa-mixed"); + p = value+strlen("wpa+wpa2"); + } + else if (0 == strncmp("wpa2", value, strlen("wpa2"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wpa2"); + p = value+strlen("wpa2"); + } + else if (0 == strncmp("wpa", value, strlen("wpa"))) + { + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].authmode, "wpa"); + p = value+strlen("wpa"); + } + + if (*p == '+' && *(p+1) != 0) + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, p+1); + else + STRNCPPP(wifi_cfg[cur_dev].vifs[cur_vif].cipher, "tkip+ccmp"); + } + + } + wifi_cfg[cur_dev].vifnum++; + } + } + return; +} + + +void hooker(FILE * fp, param * p, const char * devname) +{ + int N = 0; + int i = 0; + + if (!uci_wireless || !uci_ctx) + { + fprintf(stderr, "%s() uci context not ready!\n", __FUNCTION__); + return; + } + + for(N=0; N= MBSSID_MAX) + { + fprintf(stderr, "%s() device (%s) not found!\n", __FUNCTION__, devname); + return; + } + + if(0 == strmatch(p->dat_key, "SSID?")) + { + i = atoi(p->dat_key+4)-1; + if(i<0 || i >= MBSSID_MAX) + { + fprintf(stderr, "%s() array index error, L%d\n", __FUNCTION__, __LINE__); + return; + } + FPRINT(fp, p, wifi_cfg[N].vifs[i].ssid.value); + } + else if(0 == strcmp(p->dat_key, "BssidNum")) + { + VFPRINT(fp, p, "%d", wifi_cfg[N].vifnum); + } + else if(0 == strcmp(p->dat_key, "EncrypType")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + + if (!wifi_cfg[N].vifs[i].authmode.value) continue; + if (!wifi_cfg[N].vifs[i].cipher.value) continue; + + if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "none")) + FPRINT(fp, p, "NONE"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-open") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-shared") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "8021x")) + FPRINT(fp, p, "WEP"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].cipher.value, "ccmp")) + FPRINT(fp, p, "AES"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].cipher.value, "tkip")) + FPRINT(fp, p, "TKIP"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].cipher.value, "ccmp+tkip") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].cipher.value, "tkip+ccmp")) + FPRINT(fp, p, "TKIPAES"); + else + FPRINT(fp, p, "NONE"); + } + } + else if(0 == strcmp(p->dat_key, "AuthMode")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + if (!wifi_cfg[N].vifs[i].authmode.value) continue; + + if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "none")) + FPRINT(fp, p, "OPEN"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-open")) + FPRINT(fp, p, "OPEN"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "8021x")) + FPRINT(fp, p, "OPEN"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-shared")) + FPRINT(fp, p, "SHARED"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wep-auto")) + FPRINT(fp, p, "WEPAUTO"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk")) + FPRINT(fp, p, "WPAPSK"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk2")) + FPRINT(fp, p, "WPA2PSK"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk-mixed") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk+psk2")) + FPRINT(fp, p, "WPAPSKWPA2PSK"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wpa")) + FPRINT(fp, p, "WPA"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wpa2")) + FPRINT(fp, p, "WPA2"); + else if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wpa-mixed") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "wpa+wpa2")) + FPRINT(fp, p, "WPA1WPA2"); + else + FPRINT(fp, p, "OPEN"); + } + + } + else if(0 == strcmp(p->dat_key, "HideSSID")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + if (!wifi_cfg[N].vifs[i].hidden.value) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, wifi_cfg[N].vifs[i].hidden.value); + } + } + else if(0 == strcmp(p->dat_key, "Channel")) + { + if(0 == strcmp(p->value, "auto")) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, p->value); + } + else if(0 == strcmp(p->dat_key, "AutoChannelSelect")) + { + if(0 == strcmp(p->value, "0")) + FPRINT(fp, p, "2"); + else + FPRINT(fp, p, "0"); + } + else if(0 == strcmp(p->dat_key, "HT_BW")) + { + if(0 == strcmp(p->value, "0")) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, "1"); + } + else if(0 == strcmp(p->dat_key, "VHT_BW")) + { + if(0 == strcmp(p->value, "2")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(p->value, "3")) + FPRINT(fp, p, "2"); + else if (0 == strcmp(p->value, "4")) + FPRINT(fp, p, "3"); + else + FPRINT(fp, p, "0"); + } + else if(0 == strmatch(p->dat_key, "WPAPSK?"))//(0 == strncmp(p->dat_key, "WPAPSK", 6)) + { + i = atoi(p->dat_key+6)-1; + if(i<0 || i >= MBSSID_MAX) + { + fprintf(stderr, "%s() array index error, L%d\n", __FUNCTION__, __LINE__); + return; + } + if (!wifi_cfg[N].vifs[i].authmode.value) return; + if (0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk2") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk+psk2") + || 0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "psk-mixed")) + FPRINT(fp, p, wifi_cfg[N].vifs[i].key.value); + } + else if(0 == strcmp(p->dat_key, "RADIUS_Server")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].auth_server.value); + } + } + else if(0 == strcmp(p->dat_key, "RADIUS_Port")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].auth_port.value); + } + } + else if(0 == strmatch(p->dat_key, "RADIUS_Key?"))//(0 == strncmp(p->dat_key, "WPAPSK", 6)) + { + i = atoi(p->dat_key+10)-1; + if(i<0 || i >= MBSSID_MAX) + { + fprintf(stderr, "%s() array index error, L%d\n", __FUNCTION__, __LINE__); + return; + } + FPRINT(fp, p, wifi_cfg[N].vifs[i].auth_secret.value); + } + else if(0 == strcmp(p->dat_key, "PreAuth")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].preauth.value); + } + } + else if(0 == strcmp(p->dat_key, "RekeyInterval")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].rekeyinteval.value); + } + } + else if(0 == strcmp(p->dat_key, "PMKCachePeriod")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + FPRINT(fp, p, wifi_cfg[N].vifs[i].pmkcacheperiod.value); + } + } + + else if(0 == strcmp(p->dat_key, "IEEE8021X")) + { + for(i=0; i0) FPRINT(fp, p, ";"); + if (!wifi_cfg[N].vifs[i].authmode.value) continue; + if(0 == strcasecmp(wifi_cfg[N].vifs[i].authmode.value, "8021x")) + FPRINT(fp, p, "1"); + } + } + else if(0 == strmatch(p->dat_key, "DefaultKeyID")) /* WEP */ + { + for(i=0; idat_key, "Key?Type")) /* WEP */ + { + int j; + i = atoi(p->dat_key+3)-1; + for(j=0; jdat_key, "Key?Str?")) /* WEP */ + { + int j; + i = atoi(p->dat_key+3)-1; + j = atoi(p->dat_key+7)-1; + if (!wifi_cfg[N].vifs[j].wepkey[i].value) return; + if(0 == strncmp("s:", wifi_cfg[N].vifs[j].wepkey[i].value, 2)) + FPRINT(fp, p, wifi_cfg[N].vifs[j].wepkey[i].value+2); + else + FPRINT(fp, p, wifi_cfg[N].vifs[j].wepkey[i].value); + } + else if (0 == strcmp(p->dat_key, "ETxBfIncapable")) + { + char * value = __get_value_by_ucikey("txbf", &wifi_cfg[N]); + if (!value) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "3")) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "2")) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "1")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "0")) + FPRINT(fp, p, "1"); + else + FPRINT(fp, p, "0"); + } + else if (0 == strcmp(p->dat_key, "ITxBfEn")) + { + char * value = __get_value_by_ucikey("txbf", &wifi_cfg[N]); + if (!value) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "3")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "2")) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "1")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "0")) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, "1"); + } + else if (0 == strcmp(p->dat_key, "ETxBfEnCond")) + { + char * value = __get_value_by_ucikey("txbf", &wifi_cfg[N]); + if (!value) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "3")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "2")) + FPRINT(fp, p, "1"); + else if (0 == strcmp(value, "1")) + FPRINT(fp, p, "0"); + else if (0 == strcmp(value, "0")) + FPRINT(fp, p, "0"); + else + FPRINT(fp, p, "1"); + } + /* the rest part is quite simple! */ + else + { + FPRINT(fp, p, p->value); + } + +} + + +void gen_dat(char * devname, char * datpath) +{ + FILE * fp = NULL; + char buffer[1024] = {0}; + int i = 0; + param * p = NULL; + wifi_params * cfg = NULL; + extra_cfg * e = __extra_cfgs__; + + for (i=0; idevname); + system(buffer); + + snprintf(buffer, sizeof(buffer), "/etc/wireless/%s/%s.dat", cfg->devname, cfg->devname); + fp = fopen(buffer, "wb"); + } + + if(!fp) + { + fprintf(stderr, "Failed to open %s, %s!\n", buffer, strerror(errno)); + return; + } + + fprintf(fp, "# Generated by uci2dat\n"); + fprintf(fp, "# The word of \"Default\" must not be removed\n"); + fprintf(fp, "Default\n"); + + + for(i=0; iparams[i]; + if (!p->dat_key) continue; + printf("%s(), %s\n", __FUNCTION__, p->dat_key); + /* either get value from dat or uci */ + if(p->value) + { + fprintf(fp, "%s=", p->dat_key); + if(p->hook) + p->hook(fp, p, cfg->devname); + else if(strlen(p->value) > 0) + fprintf(fp, p->value); + /* + else if(p->defvalue) + fprintf(fp, p->defvalue); + */ + fprintf(fp, "\n"); + } + } + + while (e) + { + fprintf(fp, "%s=", e->cfg.dat_key); + if(strlen(e->cfg.value) > 0) + fprintf(fp, e->cfg.value); + else if(e->cfg.defvalue) + fprintf(fp, e->cfg.defvalue); + fprintf(fp, "\n"); + e = e->next; + } + + fclose(fp); + + return; +} + +void init_wifi_cfg(void) +{ + struct uci_element *e = NULL; + int i,j; + + for(i=0; isections, e) + { + struct uci_section *s = uci_to_section(e); + if(0 == strcmp(s->type, "wifi-device")) + { + for(i=0; ie.name, sizeof(wifi_cfg[i].devname)); + break; + } + } + + if(i>=DEVNUM_MAX) + { + fprintf(stderr, "%s(), too many devices!\n", __FUNCTION__); + break; + } + } + } +} + +void usage(void) +{ + int i, j; + param * p = NULL; + + printf("uci2dat -- a tool to translate uci config (/etc/config/wireless)\n"); + printf(" into ralink driver dat.\n"); + printf("\nUsage:\n"); + printf(" uci2dat -d -f \n"); + + printf("\nArguments:\n"); + printf(" -d device name, mt7620, eg.\n"); + printf(" -f dat file path.\n"); + + printf("\nSupported keywords:\n"); + printf(" %-16s\t%-16s\t%s\n", "[uci-key]", "[dat-key]", "[default]"); + for(i=0, j=0; iuci_key) + { + printf("%3d. %-16s\t%-16s\t%s\n",j, p->uci_key, p->dat_key, p->defvalue); + j++; + } + } + + printf("%2d. %s\n", j++, VIF.ssid.uci_key); + printf("%2d. %s\n", j++, VIF.authmode.uci_key); + printf("%2d. %s\n", j++, VIF.hidden.uci_key); + printf("%2d. %s\n", j++, VIF.cipher.uci_key); + printf("%2d. %s\n", j++, VIF.key.uci_key); + +} + + +int main(int argc, char ** argv) +{ + int opt = 0; + char * dev = NULL; + char * dat = NULL; + int test = 0; + + while ((opt = getopt (argc, argv, "htf:d:")) != -1) + { + switch (opt) + { + case 'f': + dat = optarg; + break; + case 'd': + dev = optarg; + break; + case 't': + test = 1; + break; + case 'h': + usage(); + return OK; + default: + usage(); + return NG; + } + } + + if (!uci_ctx) + { + uci_ctx = uci_alloc_context(); + } + else + { + uci_wireless = uci_lookup_package(uci_ctx, "wireless"); + if (uci_wireless) + uci_unload(uci_ctx, uci_wireless); + } + + if (uci_load(uci_ctx, "wireless", &uci_wireless)) + { + return NG; + } + + init_wifi_cfg(); + + if(dev && dat) + { + parse_dat(dev, dat); + parse_uci(NULL); + } + + if(test) + { + FILE * fp = NULL; + char * p = NULL; + char device[32] = {0}; + char profile[128] = {0}; + fp = popen("cat /etc/config/wireless" + " | grep \"wifi-device\"" + " | sed -n \"s/config[ \t]*wifi-device[\t]*//gp\"", + "r"); + if(!fp) + { + fprintf(stderr, "%s(), error L%d\n", __FUNCTION__, __LINE__); + return NG; + } + while(fgets(device, sizeof(device), fp)) + { + if (strlen(device) > 0) + { + p = device+strlen(device)-1; + while(*p < ' ') + { + *p=0; // trim newline + p++; + } + snprintf(profile, sizeof(profile), "/etc/wireless/%s/%s.dat", device, device); + parse_dat(device, profile); + } + else + printf("%s(), error L%d\n", __FUNCTION__, __LINE__); + } + pclose(fp); + parse_uci(NULL); + __dump_all(); + + } + else if(dev && dat) + gen_dat(dev, dat); + else + usage(); + + uci_unload(uci_ctx, uci_wireless); + return OK; +} + + + + diff --git a/drivers/mt7603/Makefile b/drivers/mt7603/Makefile new file mode 100755 index 0000000..1ebd51d --- /dev/null +++ b/drivers/mt7603/Makefile @@ -0,0 +1,49 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=mt7603 +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:=base-files +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Hua Shao +PKG_URLS:=http://nossiac.com/download/mtk-wifi-ko \ + http://119.23.148.191:8888/mtk-wifi-ko + + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/mt7603 + CATEGORY:=MTK Properties + SUBMENU:=Drivers + TITLE:=MTK MT7603 WiFi AP driver + AUTOLOAD:=$(call AutoProbe,mt7603) +endef + + +define Package/mt7603/config-notyet + config MT7603_USING_LUA_SCRIPT + bool "use lua script to init/config driver" + depends on PACKAGE_mt7603 + default y +endef + + +define Build/Compile + for PKG_URL in $(PKG_URLS); do \ + wget $$$${PKG_URL}/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + -O $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko; \ + if [ "$$$$?" != "0" ]; then continue; else break; fi \ + done +endef + +define Package/mt7603/install + $(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION) + -$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + $(1)/lib/modules/$(LINUX_VERSION)/$(PKG_NAME).ko + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,mt7603)) diff --git a/drivers/mt7603/files/etc/wireless/mt7603/mt7603.dat b/drivers/mt7603/files/etc/wireless/mt7603/mt7603.dat new file mode 100755 index 0000000..c6a573c --- /dev/null +++ b/drivers/mt7603/files/etc/wireless/mt7603/mt7603.dat @@ -0,0 +1,171 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=TW +BssidNum=1 +SSID1=wifi-mt7603 +SSID2= +SSID3= +SSID4= +WirelessMode=9 +TxRate=0 +Channel=11 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +DisableOLBC=0 +BGProtection=0 +MaxStaNum=0 +TxPreamble=0 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=0 +TurboRate=0 +WmmCapable=1 +APSDCapable=1 +DLSCapable=0 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +StationKeepAlive=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=0 +CSPeriod=10 +WirelessEvent=0 +IdsEnable=0 +AuthFloodThreshold=32 +AssocReqFloodThreshold=32 +ReassocReqFloodThreshold=32 +ProbeReqFloodThreshold=32 +DisassocFloodThreshold=32 +DeauthFloodThreshold=32 +EapReqFooldThreshold=32 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +RekeyInterval=0 +RekeyMethod=DISABLE +PMKCachePeriod=10 +WPAPSK1= +WPAPSK2= +WPAPSK3= +WPAPSK4= +DefaultKeyID=1 +Key1Type=1;1;1;1 +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key2Type=1;1;1;1 +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key3Type=1;1;1;1 +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key4Type=1;1;1;1 +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +HSCounter=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +WdsKey= +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=192.168.2.3 +RADIUS_Port=1812 +RADIUS_Key=ralink +own_ip_addr=192.168.5.234 +EAPifname=br-lan +PreAuthifname=br-lan +HT_HTC=0 +HT_RDG=0 +HT_EXTCHA=0 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_BW=1 +HT_AutoBA=1 +HT_AMSDU=0 +HT_BAWinSize=64 +HT_GI=1 +HT_LDPC=0 +HT_MCS=33 +VHT_BW=1 +VHT_SGI=1 +VHT_STBC=0 +VHT_BW_SIGNAL=0 +VHT_DisallowNonVHT=0 +VHT_LDPC=0 +MeshId=MESH +MeshAutoLink=1 +MeshAuthMode=OPEN +MeshEncrypType=NONE +MeshWPAKEY= +MeshDefaultkey=1 +MeshWEPKEY= +WscManufacturer= +WscModelName= +WscDeviceName= +WscModelNumber= +WscSerialNumber= +RadioOn=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +LoadCodeMethod=0 +ApCliHideSSID= +HT_TxStream=2 +HT_RxStream=2 +EzEnable= +EzConfStatus= +EzGroupID= +EzGenGroupID= +EzOpenGroupID= +EzPushBW= +EzDefaultSsid= +EzDefaultPmk= +EzDefaultPmkValid= +EzDefaultSettings= +ManConf= +ApCliEzEnable= +ApCliEzConfStatus= +ApCliEzGroupID= +ApCliEzGenGroupID= +ApCliEzOpenGroupID= +ApCliEzRssiThreshold= +E2pAccessMode=1 diff --git a/drivers/mt7603/files/lib/wifi/mt7603.lua b/drivers/mt7603/files/lib/wifi/mt7603.lua new file mode 100755 index 0000000..c4b7f5e --- /dev/null +++ b/drivers/mt7603/files/lib/wifi/mt7603.lua @@ -0,0 +1,151 @@ +#!/usr/bin/lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + + +local function esc(x) + return (x:gsub('%%', '%%%%') + :gsub('^%^', '%%^') + :gsub('%$$', '%%$') + :gsub('%(', '%%(') + :gsub('%)', '%%)') + :gsub('%.', '%%.') + :gsub('%[', '%%[') + :gsub('%]', '%%]') + :gsub('%*', '%%*') + :gsub('%+', '%%+') + :gsub('%-', '%%-') + :gsub('%?', '%%?')) +end + +function add_vif_into_lan(vif) + local mtkwifi = require("mtkwifi") + local brvifs = mtkwifi.__trim( + mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, esc(vif)) then + nixio.syslog("debug", "add "..vif.." into lan") + brvifs = brvifs.." "..vif + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + -- os.execute("brctl addif br-lan "..vif) + os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end +end + +function mt7603_up(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7603_up called!") + + -- 7603 is always the 1st card and it takes "ra" and "apcli" prefix. + -- for multi-bssid, we must bring up ra0 first. ra0 will create ra1, ra2,... + if not mtkwifi.exists("/sys/class/net/ra0") then + nixio.syslog("err", "unable to detect ra0, abort!") + return + end + os.execute("ifconfig ra0 up") + add_vif_into_lan("ra0") + + -- then we bring up ra1, ra2,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra[1-9][0-9]*") then + os.execute("ifconfig "..vif.." up") + if not string.find(vif, "apcli") then + add_vif_into_lan(vif) + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + -- then we bring up apcli0, apcli1,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") then + os.execute("ifconfig "..vif.." up") + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7603*.need_reload") +end + +function mt7603_down(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7603_down called!") + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") then + os.execute("ifconfig "..vif.." down") + end + end + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra%d+") then + os.execute("ifconfig "..vif.." down") + local brvifs = mtkwifi.read_pipe("uci get network.lan.ifname") + if string.match(brvifs, vif) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, vif, "")) + nixio.syslog("debug", "remove "..vif.." from lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7603*.need_reload") +end + +function mt7603_reload(devname) + local nixio = require("nixio") + nixio.syslog("debug", "mt7603_reload called!") + mt7603_down() + os.execute("rmmod mt7603") + os.execute("modprobe mt7603") + mt7603_up() +end + +function mt7603_reset(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7603_reset called!") + if mtkwifi.exists("/rom/etc/wireless/mt7603/") then + os.execute("rm -rf /etc/wireless/mt7603/") + os.execute("cp -rf /rom/etc/wireless/mt7603/ /etc/wireless/") + mt7603_reload() + else + nixio.syslog("debug", "/rom"..profile.." missing, unable to reset!") + end +end + +function mt7603_status(devname) + return wifi_common_status() +end + +function mt7603_detect(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7603_detect called!") + + for _,dev in ipairs(mtkwifi.get_all_devs()) do + print([[ +config wifi-device ]]..dev.maindev.."\n"..[[ + option type mt7603 + option vendor ralink +]]) + for _,vif in ipairs(dev.vifs) do + print([[ +config wifi-iface + option device ]]..dev.maindev.."\n"..[[ + option ifname ]]..vif.vifname.."\n"..[[ + option network lan + option mode ap + option ssid ]]..vif.__ssid.."\n") + end + end +end diff --git a/drivers/mt7610/Makefile b/drivers/mt7610/Makefile new file mode 100755 index 0000000..9225593 --- /dev/null +++ b/drivers/mt7610/Makefile @@ -0,0 +1,47 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=mt7610 +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:=base-files +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Hua Shao +PKG_URLS:=http://nossiac.com/download/mtk-wifi-ko \ + http://119.23.148.191:8888/mtk-wifi-ko + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/mt7610 + CATEGORY:=MTK Properties + SUBMENU:=Drivers + TITLE:=MTK MT7610 WiFi AP driver + AUTOLOAD:=$(call AutoProbe,mt7610) +endef + + +define Package/mt7610/config-notyet + config MT7610_USING_LUA_SCRIPT + bool "use lua script to init/config driver" + depends on PACKAGE_mt7610 + default y +endef + +define Build/Compile + for PKG_URL in $(PKG_URLS); do \ + wget $$$${PKG_URL}/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + -O $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko; \ + if [ "$$$$?" != "0" ]; then continue; else break; fi \ + done +endef + +define Package/mt7610/install + $(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION) + -$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + $(1)/lib/modules/$(LINUX_VERSION)/$(PKG_NAME).ko + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,mt7610)) diff --git a/drivers/mt7610/files/etc/wireless/mt7610/mt7610.dat b/drivers/mt7610/files/etc/wireless/mt7610/mt7610.dat new file mode 100755 index 0000000..98192c9 --- /dev/null +++ b/drivers/mt7610/files/etc/wireless/mt7610/mt7610.dat @@ -0,0 +1,132 @@ +#The word of "Default" must not be removed +Default +CountryRegion= +CountryRegionABand=7 +CountryCode= +BssidNum=1 +SSID1=wifi-mt7610 +SSID2= +SSID3= +SSID4= +WirelessMode=9 +TxRate=0 +Channel=auto +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +DisableOLBC=0 +BGProtection=0 +MaxStaNum=0 +TxPreamble=0 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=0 +TurboRate=0 +WmmCapable=1 +APSDCapable=1 +DLSCapable=0 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +StationKeepAlive=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=0 +CSPeriod=10 +WirelessEvent=0 +IdsEnable=0 +AuthFloodThreshold=32 +AssocReqFloodThreshold=32 +ReassocReqFloodThreshold=32 +ProbeReqFloodThreshold=32 +DisassocFloodThreshold=32 +DeauthFloodThreshold=32 +EapReqFooldThreshold=32 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +RekeyInterval=0 +RekeyMethod=DISABLE +PMKCachePeriod=10 +WPAPSK1= +WPAPSK2= +WPAPSK3= +WPAPSK4= +DefaultKeyID=1 +Key1Type=1;1;1;1 +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key2Type=1;1;1;1 +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key3Type=1;1;1;1 +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key4Type=1;1;1;1 +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +HSCounter=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +WdsEnable=0 +WdsEncrypType=NONE +WdsList=EOF +WdsKey= +RADIUS_Server=192.168.2.3 +RADIUS_Port=1812 +RADIUS_Key=ralink +own_ip_addr=192.168.5.234 +EAPifname=br-lan +PreAuthifname=br-lan +HT_HTC=0 +HT_RDG=0 +HT_EXTCHA=0 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_BW=0 +HT_AutoBA=1 +HT_AMSDU=0 +HT_BAWinSize=64 +HT_GI=1 +HT_MCS=33 + +# WPS stuff +# 1 = enrollee, 2 = proxy, 4 = registrar (bitmask) +# This value is enabled later on, for WPA only +WscConfMode=0 +# 1 = disabled, 2 = enabled +WscConfStatus=2 +# 2 = PBC, 1 = PIN +WscMode = 2 + +HT_TxStream=2 +HT_RxStream=2 diff --git a/drivers/mt7610/files/lib/wifi/mt7610.lua b/drivers/mt7610/files/lib/wifi/mt7610.lua new file mode 100755 index 0000000..38c0276 --- /dev/null +++ b/drivers/mt7610/files/lib/wifi/mt7610.lua @@ -0,0 +1,151 @@ +#!/usr/bin/lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + + +local function esc(x) + return (x:gsub('%%', '%%%%') + :gsub('^%^', '%%^') + :gsub('%$$', '%%$') + :gsub('%(', '%%(') + :gsub('%)', '%%)') + :gsub('%.', '%%.') + :gsub('%[', '%%[') + :gsub('%]', '%%]') + :gsub('%*', '%%*') + :gsub('%+', '%%+') + :gsub('%-', '%%-') + :gsub('%?', '%%?')) +end + +function add_vif_into_lan(vif) + local mtkwifi = require("mtkwifi") + local brvifs = mtkwifi.__trim( + mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, esc(vif)) then + nixio.syslog("debug", "add "..vif.." into lan") + brvifs = brvifs.." "..vif + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + -- os.execute("brctl addif br-lan "..vif) + os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end +end + +function mt7610_up(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7610_up called!") + + -- 7610 is always the 2nd card and it takes "rai" and "apclii" prefix. + -- for multi-bssid, we must bring up rai0 first. rai0 will create rai1, rai2,... + if not mtkwifi.exists("/sys/class/net/rai0") then + nixio.syslog("err", "unable to detect rai0, abort!") + return + end + os.execute("ifconfig rai0 up") + add_vif_into_lan("rai0") + + -- then we bring up ra1, ra2,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra[1-9][0-9]*") then + os.execute("ifconfig "..vif.." up") + if not string.find(vif, "apcli") then + add_vif_into_lan(vif) + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + -- then we bring up apcli0, apcli1,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") then + os.execute("ifconfig "..vif.." up") + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7610*.need_reload") +end + +function mt7610_down(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7610_down called!") + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") then + os.execute("ifconfig "..vif.." down") + end + end + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra%d+") then + os.execute("ifconfig "..vif.." down") + local brvifs = mtkwifi.read_pipe("uci get network.lan.ifname") + if string.match(brvifs, vif) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, vif, "")) + nixio.syslog("debug", "remove "..vif.." from lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7610*.need_reload") +end + +function mt7610_reload(devname) + local nixio = require("nixio") + nixio.syslog("debug", "mt7610_reload called!") + mt7610_down() + os.execute("rmmod mt7610") + os.execute("modprobe mt7610") + mt7610_up() +end + +function mt7610_reset(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7610_reset called!") + if mtkwifi.exists("/rom/etc/wireless/mt7610/") then + os.execute("rm -rf /etc/wireless/mt7610/") + os.execute("cp -rf /rom/etc/wireless/mt7610/ /etc/wireless/") + mt7610_reload() + else + nixio.syslog("debug", "/rom"..profile.." missing, unable to reset!") + end +end + +function mt7610_status(devname) + return wifi_common_status() +end + +function mt7610_detect(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7610_detect called!") + + for _,dev in ipairs(mtkwifi.get_all_devs()) do + print([[ +config wifi-device ]]..dev.maindev.."\n"..[[ + option type mt7610 + option vendor ralink +]]) + for _,vif in ipairs(dev.vifs) do + print([[ +config wifi-iface + option device ]]..dev.maindev.."\n"..[[ + option ifname ]]..vif.vifname.."\n"..[[ + option network lan + option mode ap + option ssid ]]..vif.__ssid.."\n") + end + end +end diff --git a/drivers/mt7612/Makefile b/drivers/mt7612/Makefile new file mode 100755 index 0000000..b73c71b --- /dev/null +++ b/drivers/mt7612/Makefile @@ -0,0 +1,49 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=mt7612 +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:=base-files +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Hua Shao +PKG_URLS:=http://nossiac.com/download/mtk-wifi-ko \ + http://119.23.148.191:8888/mtk-wifi-ko + + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/mt7612 + CATEGORY:=MTK Properties + SUBMENU:=Drivers + TITLE:=MTK MT7612 WiFi AP driver + AUTOLOAD:=$(call AutoProbe,mt7612) +endef + + +define Package/mt7612/config-notyet + config MT7612_USING_LUA_SCRIPT + bool "use lua script to init/config driver" + depends on PACKAGE_mt7612 + default y +endef + + +define Build/Compile + for PKG_URL in $(PKG_URLS); do \ + wget $$$${PKG_URL}/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + -O $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko; \ + if [ "$$$$?" != "0" ]; then continue; else break; fi \ + done +endef + +define Package/mt7612/install + $(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION) + -$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + $(1)/lib/modules/$(LINUX_VERSION)/$(PKG_NAME).ko + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,mt7612)) diff --git a/drivers/mt7612/files/etc/wireless/mt7612/mt7612.dat b/drivers/mt7612/files/etc/wireless/mt7612/mt7612.dat new file mode 100755 index 0000000..b58ab40 --- /dev/null +++ b/drivers/mt7612/files/etc/wireless/mt7612/mt7612.dat @@ -0,0 +1,280 @@ +#The word of "Default" must not be removed +Default +CountryRegion=1 +CountryRegionABand=7 +CountryCode= +BssidNum=1 +SSID1=wifi-mt7612 +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +WirelessMode=14 +FixedTxMode=0 +TxRate=0 +Channel=44 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=0 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=0 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch=1 +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK1=12345678 +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +DefaultKeyID=1 +Key1Type=1;1;1;1;1;1;1;1 +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key2Type=1;1;1;1;1;1;1;1 +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key3Type=1;1;1;1;1;1;1;1 +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key4Type=1;1;1;1;1;1;1;1 +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +HSCounter=0 +HT_HTC=1 +HT_RDG=0 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=0 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=0 +HT_MCS=33 +HT_TxStream=2 +HT_RxStream=2 +HT_PROTECT=1 +HT_DisallowTKIP=0 +HT_BSSCoexistence=0 +HT_LDPC=1 +GreenAP=0 +VHT_BW=1 +VHT_STBC=0 +VHT_SGI=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr= +Ethifname= +EAPifname=br-lan +PreAuthifname=br-lan +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEnable=0 +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID=0 +ApCliKey1Type=0 +ApCliKey1Str= +ApCliKey2Type=0 +ApCliKey2Str= +ApCliKey3Type=0 +ApCliKey3Str= +ApCliKey4Type=0 +ApCliKey4Str= +EfuseBufferMode=0 +E2pAccessMode=2 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +SSID= +WPAPSK= +Key1Str= +Key2Str= +Key3Str= +Key4Str= diff --git a/drivers/mt7612/files/lib/wifi/mt7612.lua b/drivers/mt7612/files/lib/wifi/mt7612.lua new file mode 100755 index 0000000..53812da --- /dev/null +++ b/drivers/mt7612/files/lib/wifi/mt7612.lua @@ -0,0 +1,151 @@ +#!/usr/bin/lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + + +local function esc(x) + return (x:gsub('%%', '%%%%') + :gsub('^%^', '%%^') + :gsub('%$$', '%%$') + :gsub('%(', '%%(') + :gsub('%)', '%%)') + :gsub('%.', '%%.') + :gsub('%[', '%%[') + :gsub('%]', '%%]') + :gsub('%*', '%%*') + :gsub('%+', '%%+') + :gsub('%-', '%%-') + :gsub('%?', '%%?')) +end + +function add_vif_into_lan(vif) + local mtkwifi = require("mtkwifi") + local brvifs = mtkwifi.__trim( + mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, esc(vif)) then + nixio.syslog("debug", "add "..vif.." into lan") + brvifs = brvifs.." "..vif + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + -- os.execute("brctl addif br-lan "..vif) + os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end +end + +function mt7612_up(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7612_up called!") + + -- 7612 always takes "rai" and "apclii" prefix. + -- for multi-bssid, we must bring up rai0 first. rai0 will create rai1, rai2,... + if not mtkwifi.exists("/sys/class/net/rai0") then + nixio.syslog("err", "unable to detect rai0, abort!") + return + end + os.execute("ifconfig rai0 up") + add_vif_into_lan("rai0") + + -- then we bring up rai1, rai2,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "rai[1-9][0-9]*") then + os.execute("ifconfig "..vif.." up") + if not string.find(vif, "apclii") then + add_vif_into_lan(vif) + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + -- then we bring up apclii0, apclii1,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apclii%d+") then + os.execute("ifconfig "..vif.." up") + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7612*.need_reload") +end + +function mt7612_down(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7612_down called!") + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apclii%d+") then + os.execute("ifconfig "..vif.." down") + end + end + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "rai%d+") then + os.execute("ifconfig "..vif.." down") + local brvifs = mtkwifi.read_pipe("uci get network.lan.ifname") + if string.match(brvifs, vif) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, vif, "")) + nixio.syslog("debug", "remove "..vif.." from lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7612*.need_reload") +end + +function mt7612_reload(devname) + local nixio = require("nixio") + nixio.syslog("debug", "mt7612_reload called!") + mt7612_down() + os.execute("rmmod mt7612") + os.execute("modprobe mt7612") + mt7612_up() +end + +function mt7612_reset(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7612_reset called!") + if mtkwifi.exists("/rom/etc/wireless/mt7612/") then + os.execute("rm -rf /etc/wireless/mt7612/") + os.execute("cp -rf /rom/etc/wireless/mt7612/ /etc/wireless/") + mt7612_reload() + else + nixio.syslog("debug", "/rom"..profile.." missing, unable to reset!") + end +end + +function mt7612_status(devname) + return wifi_common_status() +end + +function mt7612_detect(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7612_detect called!") + + for _,dev in ipairs(mtkwifi.get_all_devs()) do + print([[ +config wifi-device ]]..dev.maindev.."\n"..[[ + option type mt7612 + option vendor ralink +]]) + for _,vif in ipairs(dev.vifs) do + print([[ +config wifi-iface + option device ]]..dev.maindev.."\n"..[[ + option ifname ]]..vif.vifname.."\n"..[[ + option network lan + option mode ap + option ssid ]]..vif.__ssid.."\n") + end + end +end diff --git a/drivers/mt7615/Makefile b/drivers/mt7615/Makefile new file mode 100755 index 0000000..ebff12f --- /dev/null +++ b/drivers/mt7615/Makefile @@ -0,0 +1,52 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=mt7615 +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:=base-files +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Hua Shao +PKG_URLS:=http://nossiac.com/download/mtk-wifi-ko \ + http://119.23.148.191:8888/mtk-wifi-ko + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/mt7615 + CATEGORY:=MTK Properties + SUBMENU:=Drivers + TITLE:=MTK MT7615 WiFi AP driver + AUTOLOAD:=$(call AutoProbe,mt7615) +endef + +define Package/mt7615/config-todo + if PACKAGE_mt7615 + source "$(SOURCE)/mt7615-config.in" + endif +endef + +define Package/mt7615/config-notyet + config MT7615_USING_LUA_SCRIPT + bool "use lua script to init/config driver" + depends on PACKAGE_mt7615 + default y +endef + +define Build/Compile + for PKG_URL in $(PKG_URLS); do \ + wget $$$${PKG_URL}/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + -O $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko; \ + if [ "$$$$?" != "0" ]; then continue; else break; fi \ + done +endef + +define Package/mt7615/install + $(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION) + -$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + $(1)/lib/modules/$(LINUX_VERSION)/$(PKG_NAME).ko + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,mt7615)) diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.2G.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.2G.dat new file mode 100755 index 0000000..f536078 --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.2G.dat @@ -0,0 +1,474 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=US +AutoChannelSkipList= +DBDC_MODE=1 +IcapMode=0 +BssidNum=1 +SSID= +SSID1=wifi-mt7615.1.2G +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=0 +FtSupport= +ChannelGrp= +WirelessMode=9 +FixedTxMode=HT +EthConvertMode=dongle +TxRate=0 +Channel=6 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=3 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch= +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=0 +DfsApplyStopWifi=0 +DfsFalseAlarmPrevent=1 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DfsDedicatedZeroWait=0 +DfsTPDutyRatio=0 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +EzEnable= +EzConfStatus= +EzGroupID= +EzGenGroupID= +EzOpenGroupID= +EzPushBW= +EzDefaultSsid= +EzDefaultPmk= +EzDefaultPmkValid= +EzDefaultSettings= +ManConf= +FtMdId1= +FtMdId2= +MacAddress= +MacAddress1= +RegroupSupport= +RegroupPeriodicity= +EtherTrafficBand= +ApMWDS= +ApCliMWDS= +ForceRoamSupport= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1=12345678 +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=2 +HT_RxStream=2 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=0 +HT_LDPC=1 +VHT_BW=0 +VHT_Sec80_Channel=0 +VHT_STBC=1 +VHT_SGI=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEzEnable= +ApCliEzConfStatus= +ApCliEzGroupID= +ApCliEzGenGroupID= +ApCliEzOpenGroupID= +ApCliEzRssiThreshold= +ApCliHideSSID= +ApCliEnable=1 +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=9 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_STA_FRR_QUANTUM= +RED_Enable=1 +CP_SUPPORT=2 +BgndScanSkipCh= +EDCCAEnable=1 +BandSteering=0 +BndStrgBssIdx= +RadioLinkSelection=0 +RoamingEnhance=0 +BandNoBf=0 +IgmpSnEnable=0 diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.5G.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.5G.dat new file mode 100755 index 0000000..52db15a --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.5G.dat @@ -0,0 +1,474 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=US +AutoChannelSkipList= +DBDC_MODE=1 +IcapMode=0 +BssidNum=1 +SSID= +SSID1=wifi-mt7615.1.5G +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=0 +FtSupport= +ChannelGrp= +WirelessMode=14 +FixedTxMode=HT +EthConvertMode= +TxRate=0 +Channel=157 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=3 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch=1 +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=0 +DfsApplyStopWifi=0 +DfsFalseAlarmPrevent=1 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DfsDedicatedZeroWait=0 +DfsTPDutyRatio=0 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +EzEnable= +EzConfStatus= +EzGroupID= +EzGenGroupID= +EzOpenGroupID= +EzPushBW= +EzDefaultSsid= +EzDefaultPmk= +EzDefaultPmkValid= +EzDefaultSettings= +ManConf= +FtMdId1= +FtMdId2= +MacAddress= +MacAddress1= +RegroupSupport= +RegroupPeriodicity= +EtherTrafficBand= +ApMWDS= +ApCliMWDS= +ForceRoamSupport= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1=12345678 +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=2 +HT_RxStream=2 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=0 +HT_LDPC=1 +VHT_BW=1 +VHT_Sec80_Channel=0 +VHT_STBC=1 +VHT_SGI=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEzEnable= +ApCliEzConfStatus= +ApCliEzGroupID= +ApCliEzGenGroupID= +ApCliEzOpenGroupID= +ApCliEzRssiThreshold= +ApCliHideSSID= +ApCliEnable=1 +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=14 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_STA_FRR_QUANTUM= +RED_Enable=1 +CP_SUPPORT= +BgndScanSkipCh= +EDCCAEnable= +BandSteering=0 +BndStrgBssIdx= +RadioLinkSelection=0 +RoamingEnhance=0 +BandNoBf=0 +IgmpSnEnable=0 diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.dat new file mode 100755 index 0000000..c9f3c43 --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.1.dat @@ -0,0 +1,473 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=US +AutoChannelSkipList= +DBDC_MODE=0 +IcapMode=0 +BssidNum=1 +SSID= +SSID1=wifi-mt7615.1 +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=1 +FtSupport=1 +ChannelGrp= +WirelessMode=9 +FixedTxMode=HT +EthConvertMode=dongle +TxRate=0 +Channel=6 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=3 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch= +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=0 +DfsApplyStopWifi=0 +DfsFalseAlarmPrevent=0 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DfsDedicatedZeroWait=0 +DfsTPDutyRatio=0 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +EzEnable= +EzConfStatus= +EzGroupID= +EzGenGroupID= +EzOpenGroupID= +EzPushBW= +EzDefaultSsid= +EzDefaultPmk= +EzDefaultPmkValid= +EzDefaultSettings= +ManConf= +FtMdId1= +FtMdId2= +MacAddress= +MacAddress1= +RegroupSupport= +RegroupPeriodicity= +EtherTrafficBand= +ApMWDS= +ApCliMWDS= +ForceRoamSupport= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1=12345678 +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=4 +HT_RxStream=4 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=0 +HT_LDPC=1 +VHT_BW=0 +VHT_Sec80_Channel=0 +VHT_STBC=1 +VHT_SGI=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEzEnable= +ApCliEzConfStatus= +ApCliEzGroupID= +ApCliEzGenGroupID= +ApCliEzOpenGroupID= +ApCliEzRssiThreshold= +ApCliHideSSID= +ApCliEnable=1 +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=9 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_STA_FRR_QUANTUM= +RED_Enable=1 +CP_SUPPORT=2 +BgndScanSkipCh= +EDCCAEnable=1 +BandSteering=0 +BndStrgBssIdx= +RadioLinkSelection=0 +RoamingEnhance=0 +BandNoBf=0 diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.2G.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.2G.dat new file mode 100755 index 0000000..278a8cb --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.2G.dat @@ -0,0 +1,439 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=US +AutoChannelSkipList= +DBDC_MODE=1 +IcapMode=0 +BssidNum=1 +SSID= +SSID1=wifi-mt7615.2.2G +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=0 +FtSupport=0 +ChannelGrp= +WirelessMode=9 +FixedTxMode=HT +EthConvertMode=dongle +TxRate=0 +Channel=6 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch= +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=0 +DfsApplyStopWifi=0 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1=12345678 +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=2 +HT_RxStream=2 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=0 +HT_LDPC=1 +VHT_BW=0 +VHT_Sec80_Channel=0 +VHT_STBC=0 +VHT_SGI=0 +VHT_BW_SIGNAL=0 +VHT_LDPC=0 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEnable= +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=9 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +RED_Enable=1 +CP_SUPPORT=2 +BgndScanSkipCh= +EDCCAEnable=1 +BandSteering=0 +BndStrgBssIdx= +RadioLinkSelection=0 diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.5G.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.5G.dat new file mode 100755 index 0000000..175cd0d --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.5G.dat @@ -0,0 +1,439 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=US +AutoChannelSkipList= +DBDC_MODE=1 +IcapMode=0 +BssidNum=1 +SSID=TVWS +SSID1=wifi-mt7615.5.5G +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=0 +FtSupport=0 +ChannelGrp= +WirelessMode=15 +FixedTxMode=HT +EthConvertMode= +TxRate=0 +Channel=157 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch=1 +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=1 +DfsApplyStopWifi=0 +DfsZeroWait=1 +DfsZeroWaitCacTime=255 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1= +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=2 +HT_RxStream=2 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=1 +HT_LDPC=1 +VHT_BW=1 +VHT_Sec80_Channel=0 +VHT_STBC=1 +VHT_SGI=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEnable= +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=15 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +RED_Enable=1 +CP_SUPPORT= +BgndScanSkipCh= +EDCCAEnable=0 +BandSteering=0 +BndStrgBssIdx= +RadioLinkSelection=0 diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.dat new file mode 100755 index 0000000..3196366 --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.2.dat @@ -0,0 +1,473 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=US +AutoChannelSkipList= +DBDC_MODE=0 +IcapMode=0 +BssidNum=1 +SSID= +SSID1=wifi-mt7615.2 +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=1 +FtSupport=1 +ChannelGrp= +WirelessMode=14 +FixedTxMode=HT +EthConvertMode=dongle +TxRate=0 +Channel=157 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=3 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch=1 +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=0 +DfsApplyStopWifi=0 +DfsFalseAlarmPrevent=0 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DfsDedicatedZeroWait=0 +DfsTPDutyRatio=0 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +EzEnable= +EzConfStatus= +EzGroupID= +EzGenGroupID= +EzOpenGroupID= +EzPushBW= +EzDefaultSsid= +EzDefaultPmk= +EzDefaultPmkValid= +EzDefaultSettings= +ManConf= +FtMdId1= +FtMdId2= +MacAddress= +MacAddress1= +RegroupSupport= +RegroupPeriodicity= +EtherTrafficBand= +ApMWDS= +ApCliMWDS= +ForceRoamSupport= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1=12345678 +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=4 +HT_RxStream=4 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=0 +HT_LDPC=1 +VHT_BW=1 +VHT_Sec80_Channel=0 +VHT_STBC=1 +VHT_SGI=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEzEnable= +ApCliEzConfStatus= +ApCliEzGroupID= +ApCliEzGenGroupID= +ApCliEzOpenGroupID= +ApCliEzRssiThreshold= +ApCliHideSSID= +ApCliEnable=1 +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=14 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +VOW_STA_FRR_QUANTUM= +RED_Enable=1 +CP_SUPPORT=2 +BgndScanSkipCh= +EDCCAEnable=1 +BandSteering=1 +BndStrgBssIdx= +RadioLinkSelection=0 +RoamingEnhance=0 +BandNoBf=0 diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.2G.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.2G.dat new file mode 100755 index 0000000..7dad65d --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.2G.dat @@ -0,0 +1,432 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=US +AutoChannelSkipList= +DBDC_MODE=1 +IcapMode=0 +BssidNum=1 +SSID= +SSID1=wifi-mt7615.3.2G +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=0 +FtSupport=0 +ChannelGrp= +WirelessMode=9 +FixedTxMode=HT +EthConvertMode=dongle +TxRate=0 +Channel=6 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch= +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=0 +DfsApplyStopWifi=0 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1=12345678 +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=2 +HT_RxStream=2 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=0 +HT_LDPC=1 +VHT_BW=0 +VHT_Sec80_Channel=0 +VHT_STBC=0 +VHT_SGI=0 +VHT_BW_SIGNAL=0 +VHT_LDPC=0 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEnable= +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=9 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +RED_Enable=1 +CP_SUPPORT=2 +BgndScanSkipCh= +EDCCAEnable=1 +BandSteering=0 +BndStrgBssIdx= +RadioLinkSelection=0 diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.5G.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.5G.dat new file mode 100755 index 0000000..5281b7c --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.5G.dat @@ -0,0 +1,432 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode=US +AutoChannelSkipList= +DBDC_MODE=1 +IcapMode=0 +BssidNum=1 +SSID=TVWS +SSID1=wifi-mt7615.3.5G +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=0 +FtSupport=0 +ChannelGrp= +WirelessMode=15 +FixedTxMode=HT +EthConvertMode= +TxRate=0 +Channel=157 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=1 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch=1 +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=1 +DfsApplyStopWifi=0 +DfsZeroWait=1 +DfsZeroWaitCacTime=255 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1= +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=2 +HT_RxStream=2 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=1 +HT_LDPC=1 +VHT_BW=1 +VHT_Sec80_Channel=0 +VHT_STBC=1 +VHT_SGI=1 +VHT_BW_SIGNAL=0 +VHT_LDPC=1 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEnable= +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=15 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=1 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +RED_Enable=1 +CP_SUPPORT= +BgndScanSkipCh= +EDCCAEnable=0 +BandSteering=0 +BndStrgBssIdx= +RadioLinkSelection=0 diff --git a/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.dat b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.dat new file mode 100755 index 0000000..efd8d12 --- /dev/null +++ b/drivers/mt7615/files/etc/wireless/mt7615/mt7615.3.dat @@ -0,0 +1,439 @@ +#The word of "Default" must not be removed +Default +CountryRegion=5 +CountryRegionABand=7 +CountryCode= +AutoChannelSkipList= +DBDC_MODE=0 +IcapMode=0 +BssidNum=1 +SSID= +SSID1=wifi-mt7615.3 +SSID2= +SSID3= +SSID4= +SSID5= +SSID6= +SSID7= +SSID8= +SSID9= +SSID10= +SSID11= +SSID12= +SSID13= +SSID14= +SSID15= +SSID16= +RRMEnable=0 +FtSupport=0 +ChannelGrp= +WirelessMode=9 +FixedTxMode=HT +EthConvertMode=dongle +TxRate=0 +Channel=6 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +LinkTestSupport=0 +ThermalRecal=0 +PowerUpCckOfdm=0:0:0:0:0:0:0 +PowerUpHT20=0:0:0:0:0:0:0 +PowerUpHT40=0:0:0:0:0:0:0 +PowerUpVHT20=0:0:0:0:0:0:0 +PowerUpVHT40=0:0:0:0:0:0:0 +PowerUpVHT80=0:0:0:0:0:0:0 +PowerUpVHT160=0:0:0:0:0:0:0 +SKUenable=0 +PERCENTAGEenable=1 +BFBACKOFFenable=0 +CalCacheApply=0 +DisableOLBC=0 +BGProtection=0 +TxAntenna= +RxAntenna= +TxPreamble=0 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=1 +AutoProvisionEn=0 +FreqDelta=0 +TurboRate=0 +WmmCapable=1 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +APSDCapable=0 +DLSCapable=0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=1 +CarrierDetect=0 +ITxBfEn=0 +PreAntSwitch= +PhyRateLimit=0 +DebugFlags=0 +ETxBfEnCond=0 +MUTxRxEnable=0 +ITxBfTimeout=0 +ETxBfTimeout=0 +ETxBfNoncompress=0 +ETxBfIncapable=0 +FineAGC=0 +StreamMode=0 +StreamModeMac0= +StreamModeMac1= +StreamModeMac2= +StreamModeMac3= +CSPeriod=6 +RDRegion= +StationKeepAlive=0 +DfsCalibration=0 +DfsEnable=0 +DfsApplyStopWifi=0 +DfsZeroWait=0 +DfsZeroWaitCacTime=255 +DfsLowerLimit=0 +DfsUpperLimit=0 +DfsOutdoor=0 +SymRoundFromCfg=0 +BusyIdleFromCfg=0 +DfsRssiHighFromCfg=0 +DfsRssiLowFromCfg=0 +DFSParamFromConfig=0 +FCCParamCh0= +FCCParamCh1= +FCCParamCh2= +FCCParamCh3= +CEParamCh0= +CEParamCh1= +CEParamCh2= +CEParamCh3= +JAPParamCh0= +JAPParamCh1= +JAPParamCh2= +JAPParamCh3= +JAPW53ParamCh0= +JAPW53ParamCh1= +JAPW53ParamCh2= +JAPW53ParamCh3= +FixDfsLimit=0 +LongPulseRadarTh=0 +AvgRssiReq=0 +DFS_R66=0 +BlockCh= +GreenAP=0 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +WapiPsk1= +WapiPsk2= +WapiPsk3= +WapiPsk4= +WapiPsk5= +WapiPsk6= +WapiPsk7= +WapiPsk8= +WapiPsk9= +WapiPsk10= +WapiPsk11= +WapiPsk12= +WapiPsk13= +WapiPsk14= +WapiPsk15= +WapiPsk16= +WapiPskType= +Wapiifname= +WapiAsCertPath= +WapiUserCertPath= +WapiAsIpAddr= +WapiAsPort= +RekeyMethod=DISABLE +RekeyInterval=3600 +PMKCachePeriod=10 +MeshAutoLink=0 +MeshAuthMode= +MeshEncrypType= +MeshDefaultkey=0 +MeshWEPKEY= +MeshWPAKEY= +MeshId= +WPAPSK= +WPAPSK1=12345678 +WPAPSK2= +WPAPSK3= +WPAPSK4= +WPAPSK5= +WPAPSK6= +WPAPSK7= +WPAPSK8= +WPAPSK9= +WPAPSK10= +WPAPSK11= +WPAPSK12= +WPAPSK13= +WPAPSK14= +WPAPSK15= +WPAPSK16= +DefaultKeyID=1 +Key1Type=0 +Key1Str= +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key1Str5= +Key1Str6= +Key1Str7= +Key1Str8= +Key1Str9= +Key1Str10= +Key1Str11= +Key1Str12= +Key1Str13= +Key1Str14= +Key1Str15= +Key1Str16= +Key2Type=0 +Key2Str= +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key2Str5= +Key2Str6= +Key2Str7= +Key2Str8= +Key2Str9= +Key2Str10= +Key2Str11= +Key2Str12= +Key2Str13= +Key2Str14= +Key2Str15= +Key2Str16= +Key3Type=0 +Key3Str= +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key3Str5= +Key3Str6= +Key3Str7= +Key3Str8= +Key3Str9= +Key3Str10= +Key3Str11= +Key3Str12= +Key3Str13= +Key3Str14= +Key3Str15= +Key3Str16= +Key4Type=0 +Key4Str= +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +Key4Str5= +Key4Str6= +Key4Str7= +Key4Str8= +Key4Str9= +Key4Str10= +Key4Str11= +Key4Str12= +Key4Str13= +Key4Str14= +Key4Str15= +Key4Str16= +HSCounter=0 +HT_HTC=1 +HT_RDG=1 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_EXTCHA=1 +HT_BW=1 +HT_AutoBA=1 +HT_BADecline=0 +HT_AMSDU=1 +HT_BAWinSize=64 +HT_GI=1 +HT_STBC=1 +HT_MCS=33 +HT_TxStream=2 +HT_RxStream=2 +HT_PROTECT=1 +HT_DisallowTKIP=1 +HT_BSSCoexistence=0 +HT_LDPC=1 +VHT_BW=0 +VHT_Sec80_Channel=0 +VHT_STBC=0 +VHT_SGI=0 +VHT_BW_SIGNAL=0 +VHT_LDPC=0 +G_BAND_256QAM=1 +WscConfMode=0 +WscConfStatus=2 +WCNTest=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +AccessPolicy4=0 +AccessControlList4= +AccessPolicy5=0 +AccessControlList5= +AccessPolicy6=0 +AccessControlList6= +AccessPolicy7=0 +AccessControlList7= +AccessPolicy8=0 +AccessControlList8= +AccessPolicy9=0 +AccessControlList9= +AccessPolicy10=0 +AccessControlList10= +AccessPolicy11=0 +AccessControlList11= +AccessPolicy12=0 +AccessControlList12= +AccessPolicy13=0 +AccessControlList13= +AccessPolicy14=0 +AccessControlList14= +AccessPolicy15=0 +AccessControlList15= +WdsEnable=0 +WdsPhyMode= +WdsEncrypType=NONE +WdsList= +Wds0Key= +Wds1Key= +Wds2Key= +Wds3Key= +RADIUS_Server=0 +RADIUS_Port=1812 +RADIUS_Key1= +RADIUS_Key2= +RADIUS_Key3= +RADIUS_Key4= +RADIUS_Key5= +RADIUS_Key6= +RADIUS_Key7= +RADIUS_Key8= +RADIUS_Key9= +RADIUS_Key10= +RADIUS_Key11= +RADIUS_Key12= +RADIUS_Key13= +RADIUS_Key14= +RADIUS_Key15= +RADIUS_Key16= +RADIUS_Acct_Server= +RADIUS_Acct_Port=1813 +RADIUS_Acct_Key= +own_ip_addr=10.10.10.254 +Ethifname= +EAPifname=br0 +PreAuthifname=br0 +session_timeout_interval=0 +idle_timeout_interval=0 +WiFiTest=0 +TGnWifiTest=0 +ApCliEnable= +ApCliSsid= +ApCliBssid= +ApCliAuthMode= +ApCliEncrypType= +ApCliWPAPSK= +ApCliDefaultKeyID= +ApCliKey1Type= +ApCliKey1Str= +ApCliKey2Type= +ApCliKey2Str= +ApCliKey3Type= +ApCliKey3Str= +ApCliKey4Type= +ApCliKey4Str= +MACRepeaterEn= +MACRepeaterOuiMode=2 +ApCliWirelessMode=9 +ApCliWPAPSK1= +ApCliKey1Str1= +ApCliKey2Str1= +ApCliKey3Str1= +ApCliKey4Str1= +EfuseBufferMode=0 +E2pAccessMode=2 +PMFMFPC=0 +PMFMFPR=0 +PMFSHA256=0 +RadioOn=1 +BW_Enable=0 +BW_Root=0 +BW_Priority= +BW_Guarantee_Rate= +BW_Maximum_Rate= +VOW_BW_Ctrl= +VOW_Airtime_Fairness_En=1 +VOW_RX_En= +VOW_Refill_Period= +VOW_Sta_VO_DWRR_Quantum= +VOW_Sta_VI_DWRR_Quantum= +VOW_Sta_BE_DWRR_Quantum= +VOW_Sta_BK_DWRR_Quantum= +VOW_WMM_Search_Rule_Band0= +VOW_WMM_Search_Rule_Band1= +VOW_Sta_DWRR_Max_Wait_Time= +VOW_Group_DWRR_Max_Wait_Time= +VOW_Group_Min_Rate= +VOW_Group_Max_Rate= +VOW_Group_Min_Ratio= +VOW_Group_Max_Ratio= +VOW_Airtime_Ctrl_En= +VOW_Rate_Ctrl_En= +VOW_Group_Min_Rate_Bucket_Size= +VOW_Group_Max_Rate_Bucket_Size= +VOW_Group_Min_Airtime_Bucket_Size= +VOW_Group_Max_Airtime_Bucket_Size= +VOW_Group_Backlog= +VOW_Group_Max_Wait_Time= +VOW_Group_DWRR_Quantum= +VOW_WATF_Enable= +VOW_WATF_Q_LV0= +VOW_WATF_Q_LV1= +VOW_WATF_Q_LV2= +VOW_WATF_Q_LV3= +VOW_WATF_MAC_LV0= +VOW_WATF_MAC_LV1= +VOW_WATF_MAC_LV2= +VOW_WATF_MAC_LV3= +RED_Enable=1 +CP_SUPPORT=2 +BgndScanSkipCh= +EDCCAEnable=1 +BandSteering=0 +BndStrgBssIdx= +RadioLinkSelection=0 diff --git a/drivers/mt7615/files/lib/wifi/mt7615.lua b/drivers/mt7615/files/lib/wifi/mt7615.lua new file mode 100755 index 0000000..8cc2763 --- /dev/null +++ b/drivers/mt7615/files/lib/wifi/mt7615.lua @@ -0,0 +1,210 @@ +#!/usr/bin/lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + + +local vif_prefix = {"ra", "rai", "rae", "rax", "ray", "raz", + "apcli", "apclix", "apclii", "apcliy", "apclie", "apcliz", } + +local function esc(x) + return (x:gsub('%%', '%%%%') + :gsub('^%^', '%%^') + :gsub('%$$', '%%$') + :gsub('%(', '%%(') + :gsub('%)', '%%)') + :gsub('%.', '%%.') + :gsub('%[', '%%[') + :gsub('%]', '%%]') + :gsub('%*', '%%*') + :gsub('%+', '%%+') + :gsub('%-', '%%-') + :gsub('%?', '%%?')) +end + +function add_vif_into_lan(vif) + local mtkwifi = require("mtkwifi") + local brvifs = mtkwifi.__trim( + mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, esc(vif)) then + nixio.syslog("debug", "mt7615_up: add "..vif.." into lan") + brvifs = brvifs.." "..vif + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + -- os.execute("brctl addif br-lan "..vif) + os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end +end + +function mt7615_up(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + + nixio.syslog("debug", "mt7615_up called!") + + local devs, l1parser = mtkwifi.__get_l1dat() + -- l1 profile present, good! + if l1parser and devs then + dev = devs.devname_ridx[devname] + if not dev then + nixio.syslog("err", "mt7615_up: dev "..devname.." not found!") + return + end + -- we have to bring up main_ifname first, main_ifname will create all other vifs. + if mtkwifi.exists("/sys/class/net/"..dev.main_ifname) then + nixio.syslog("debug", "mt7615_up: ifconfig "..dev.main_ifname.." up") + os.execute("ifconfig "..dev.main_ifname.." up") + add_vif_into_lan(dev.main_ifname) + else + nixio.syslog("err", "mt7615_up: main_ifname "..dev.main_ifname.." missing, quit!") + return + end + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if vif ~= dev.main_ifname and + ( string.match(vif, esc(dev.ext_ifname).."[0-9]+") + or string.match(vif, esc(dev.apcli_ifname).."[0-9]+") + or string.match(vif, esc(dev.wds_ifname).."[0-9]+") + or string.match(vif, esc(dev.mesh_ifname).."[0-9]+")) + then + nixio.syslog("debug", "mt7615_up: ifconfig "..vif.."0 up") + os.execute("ifconfig "..vif.." up") + add_vif_into_lan(vif) + -- else nixio.syslog("debug", "mt7615_up: skip "..vif..", prefix not match "..pre) + end + end + elseif mtkwifi.exists("/etc/wireless/mt7615/"..devname..".dat") then + for _, pre in ipairs(vif_prefix) do + -- we have to bring up root vif first, root vif will create all other vifs. + if mtkwifi.exists("/sys/class/net/"..pre.."0") then + nixio.syslog("debug", "mt7615_up: ifconfig "..pre.."0 up") + os.execute("ifconfig "..pre.."0 up") + add_vif_into_lan(pre.."0") + end + + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + -- nixio.syslog("debug", "mt7615_up: navigate "..pre) + if string.match(vif, pre.."[1-9]+") then + nixio.syslog("debug", "mt7615_up: ifconfig "..vif.." up") + os.execute("ifconfig "..vif.." up") + add_vif_into_lan(vif) + -- else nixio.syslog("debug", "mt7615_up: skip "..vif..", prefix not match "..pre) + end + end + end + else nixio.syslog("debug", "mt7615_up: skip "..devname..", config not exist") + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7615*.need_reload") +end + +function mt7615_down(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7615_down called!") + + local devs, l1parser = mtkwifi.__get_l1dat() + -- l1 profile present, good! + if l1parser and devs then + dev = devs.devname_ridx[devname] + if not dev then + nixio.syslog("err", "mt7615_down: dev "..devname.." not found!") + return + end + + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if vif == dev.main_ifname + or string.match(vif, esc(dev.ext_ifname).."[0-9]+") + or string.match(vif, esc(dev.apcli_ifname).."[0-9]+") + or string.match(vif, esc(dev.wds_ifname).."[0-9]+") + or string.match(vif, esc(dev.mesh_ifname).."[0-9]+") + then + nixio.syslog("debug", "mt7615_down: ifconfig "..vif.." down") + os.execute("ifconfig "..vif.." down") + local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname")) + if string.match(brvifs, esc(vif)) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, esc(vif), "")) + nixio.syslog("debug", "mt7615_down: remove "..vif.." from lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end + -- else nixio.syslog("debug", "mt7615_down: skip "..vif..", prefix not match "..pre) + end + end + elseif mtkwifi.exists("/etc/wireless/mt7615/"..devname..".dat") then + for _, pre in ipairs(vif_prefix) do + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, pre.."[0-9]+") then + nixio.syslog("debug", "mt7615_down: ifconfig "..vif.."down") + os.execute("ifconfig "..vif.." down") + local brvifs = mtkwifi.read_pipe("uci get network.lan.ifname") + if string.match(brvifs, vif) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, vif, "")) + nixio.syslog("debug", "mt7615_down: remove "..vif.." from lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end + -- else nixio.syslog("debug", "mt7615_down: skip "..vif..", prefix not match "..pre) + end + end + end + else nixio.syslog("debug", "mt7615_down: skip "..devname..", config not exist") + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7615*.need_reload") +end + +function mt7615_reload(devname) + local nixio = require("nixio") + nixio.syslog("debug", "mt7615_reload called!") + mt7615_down(devname) + os.execute("rmmod mt7615") + os.execute("modprobe mt7615") + mt7615_up(devname) +end + +function mt7615_reset(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7615_reset called!") + if mtkwifi.exists("/rom/etc/wireless/mt7615/") then + os.execute("rm -rf /etc/wireless/mt7615/") + os.execute("cp -rf /rom/etc/wireless/mt7615/ /etc/wireless/") + mt7615_reload(devname) + else + nixio.syslog("debug", "mt7615_reset: /rom"..profile.." missing, unable to reset!") + end +end + +function mt7615_status(devname) + return wifi_common_status() +end + +function mt7615_detect(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7615_detect called!") + + for _,dev in ipairs(mtkwifi.get_all_devs()) do + local relname = string.format("%s%d%d",dev.maindev,dev.mainidx,dev.subidx) + print([[ +config wifi-device ]]..relname.."\n"..[[ + option type mt7615 + option vendor ralink +]]) + for _,vif in ipairs(dev.vifs) do + print([[ +config wifi-iface + option device ]]..relname.."\n"..[[ + option ifname ]]..vif.vifname.."\n"..[[ + option network lan + option mode ap + option ssid ]]..vif.__ssid.."\n") + end + end +end diff --git a/drivers/mt7615/mt7615-config.in b/drivers/mt7615/mt7615-config.in new file mode 100755 index 0000000..e69de29 diff --git a/drivers/mt7620/Makefile b/drivers/mt7620/Makefile new file mode 100755 index 0000000..0cc1978 --- /dev/null +++ b/drivers/mt7620/Makefile @@ -0,0 +1,47 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=mt7620 +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:=base-files +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Hua Shao +PKG_URLS:=http://nossiac.com/download/mtk-wifi-ko \ + http://119.23.148.191:8888/mtk-wifi-ko + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/mt7620 + CATEGORY:=MTK Properties + SUBMENU:=Drivers + TITLE:=MTK MT7620 WiFi AP driver + AUTOLOAD:=$(call AutoProbe,mt7620) +endef + + +define Package/mt7620/config-notyet + config MT7620_USING_LUA_SCRIPT + bool "use lua script to init/config driver" + depends on PACKAGE_mt7620 + default y +endef + +define Build/Compile + for PKG_URL in $(PKG_URLS); do \ + wget $$$${PKG_URL}/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + -O $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko; \ + if [ "$$$$?" != "0" ]; then continue; else break; fi \ + done +endef + +define Package/mt7620/install + $(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION) + -$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + $(1)/lib/modules/$(LINUX_VERSION)/$(PKG_NAME).ko + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,mt7620)) diff --git a/drivers/mt7620/files/etc/wireless/mt7620/mt7620.dat b/drivers/mt7620/files/etc/wireless/mt7620/mt7620.dat new file mode 100755 index 0000000..2118bab --- /dev/null +++ b/drivers/mt7620/files/etc/wireless/mt7620/mt7620.dat @@ -0,0 +1,132 @@ +#The word of "Default" must not be removed +Default +CountryRegion=1 +CountryRegionABand=0 +CountryCode= +BssidNum=1 +SSID1=wifi-mt7620 +SSID2= +SSID3= +SSID4= +WirelessMode=9 +TxRate=0 +Channel=6 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +DisableOLBC=0 +BGProtection=0 +MaxStaNum=0 +TxPreamble=0 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=1 +PktAggregate=0 +TurboRate=0 +WmmCapable=1 +APSDCapable=1 +DLSCapable=0 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +StationKeepAlive=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=0 +CSPeriod=10 +WirelessEvent=0 +IdsEnable=0 +AuthFloodThreshold=32 +AssocReqFloodThreshold=32 +ReassocReqFloodThreshold=32 +ProbeReqFloodThreshold=32 +DisassocFloodThreshold=32 +DeauthFloodThreshold=32 +EapReqFooldThreshold=32 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +RekeyInterval=0 +RekeyMethod=DISABLE +PMKCachePeriod=10 +WPAPSK1= +WPAPSK2= +WPAPSK3= +WPAPSK4= +DefaultKeyID=1 +Key1Type=1;1;1;1 +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key2Type=1;1;1;1 +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key3Type=1;1;1;1 +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key4Type=1;1;1;1 +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +HSCounter=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +WdsEnable=0 +WdsEncrypType=NONE +WdsList=EOF +WdsKey= +RADIUS_Server=192.168.2.3 +RADIUS_Port=1812 +RADIUS_Key=ralink +own_ip_addr=192.168.5.234 +EAPifname=br-lan +PreAuthifname=br-lan +HT_HTC=0 +HT_RDG=0 +HT_EXTCHA=0 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_BW=1 +HT_AutoBA=1 +HT_AMSDU=0 +HT_BAWinSize=64 +HT_GI=1 +HT_MCS=33 + +# WPS stuff +# 1 = enrollee, 2 = proxy, 4 = registrar (bitmask) +# This value is enabled later on, for WPA only +WscConfMode=0 +# 1 = disabled, 2 = enabled +WscConfStatus=2 +# 2 = PBC, 1 = PIN +WscMode = 2 + +HT_TxStream=2 +HT_RxStream=2 diff --git a/drivers/mt7620/files/lib/wifi/mt7620.lua b/drivers/mt7620/files/lib/wifi/mt7620.lua new file mode 100755 index 0000000..3d373d6 --- /dev/null +++ b/drivers/mt7620/files/lib/wifi/mt7620.lua @@ -0,0 +1,151 @@ +#!/usr/bin/lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + + +local function esc(x) + return (x:gsub('%%', '%%%%') + :gsub('^%^', '%%^') + :gsub('%$$', '%%$') + :gsub('%(', '%%(') + :gsub('%)', '%%)') + :gsub('%.', '%%.') + :gsub('%[', '%%[') + :gsub('%]', '%%]') + :gsub('%*', '%%*') + :gsub('%+', '%%+') + :gsub('%-', '%%-') + :gsub('%?', '%%?')) +end + +function add_vif_into_lan(vif) + local mtkwifi = require("mtkwifi") + local brvifs = mtkwifi.__trim( + mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, esc(vif)) then + nixio.syslog("debug", "add "..vif.." into lan") + brvifs = brvifs.." "..vif + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + -- os.execute("brctl addif br-lan "..vif) + os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end +end + +function mt7620_up(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7620_up called!") + + -- 7620 is always the 1st card and it takes "ra" and "apcli" prefix. + -- for multi-bssid, we must bring up ra0 first. ra0 will create ra1, ra2,... + if not mtkwifi.exists("/sys/class/net/ra0") then + nixio.syslog("err", "unable to detect ra0, abort!") + return + end + os.execute("ifconfig ra0 up") + add_vif_into_lan("ra0") + + -- then we bring up ra1, ra2,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra[1-9][0-9]*") then + os.execute("ifconfig "..vif.." up") + if not string.find(vif, "apcli") then + add_vif_into_lan(vif) + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + -- then we bring up apcli0, apcli1,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") then + os.execute("ifconfig "..vif.." up") + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7620*.need_reload") +end + +function mt7620_down(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7620_down called!") + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") then + os.execute("ifconfig "..vif.." down") + end + end + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra%d+") then + os.execute("ifconfig "..vif.." down") + local brvifs = mtkwifi.read_pipe("uci get network.lan.ifname") + if string.match(brvifs, vif) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, vif, "")) + nixio.syslog("debug", "remove "..vif.." from lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7620*.need_reload") +end + +function mt7620_reload(devname) + local nixio = require("nixio") + nixio.syslog("debug", "mt7620_reload called!") + mt7620_down() + os.execute("rmmod mt7620") + os.execute("modprobe mt7620") + mt7620_up() +end + +function mt7620_reset(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7620_reset called!") + if mtkwifi.exists("/rom/etc/wireless/mt7620/") then + os.execute("rm -rf /etc/wireless/mt7620/") + os.execute("cp -rf /rom/etc/wireless/mt7620/ /etc/wireless/") + mt7620_reload() + else + nixio.syslog("debug", "/rom"..profile.." missing, unable to reset!") + end +end + +function mt7620_status(devname) + return wifi_common_status() +end + +function mt7620_detect(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7620_detect called!") + + for _,dev in ipairs(mtkwifi.get_all_devs()) do + print([[ +config wifi-device ]]..dev.maindev.."\n"..[[ + option type mt7620 + option vendor ralink +]]) + for _,vif in ipairs(dev.vifs) do + print([[ +config wifi-iface + option device ]]..dev.maindev.."\n"..[[ + option ifname ]]..vif.vifname.."\n"..[[ + option network lan + option mode ap + option ssid ]]..vif.__ssid.."\n") + end + end +end diff --git a/drivers/mt7628/Makefile b/drivers/mt7628/Makefile new file mode 100755 index 0000000..b17046f --- /dev/null +++ b/drivers/mt7628/Makefile @@ -0,0 +1,49 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=mt7628 +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:=base-files +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Hua Shao +PKG_URLS:=http://nossiac.com/download/mtk-wifi-ko \ + http://119.23.148.191:8888/mtk-wifi-ko + + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/kernel.mk + +define Package/mt7628 + CATEGORY:=MTK Properties + SUBMENU:=Drivers + TITLE:=MTK MT7628 WiFi AP driver + AUTOLOAD:=$(call AutoProbe,mt7628) +endef + + +define Package/mt7628/config-notyet + config MT7628_USING_LUA_SCRIPT + bool "use lua script to init/config driver" + depends on PACKAGE_mt7628 + default y +endef + + +define Build/Compile + for PKG_URL in $(PKG_URLS); do \ + wget $$$${PKG_URL}/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + -O $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko; \ + if [ "$$$$?" != "0" ]; then continue; else break; fi \ + done +endef + +define Package/mt7628/install + $(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION) + -$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME)-linux-$(LINUX_VERSION).ko \ + $(1)/lib/modules/$(LINUX_VERSION)/$(PKG_NAME).ko + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,mt7628)) diff --git a/drivers/mt7628/files/etc/wireless/mt7628/mt7628.dat b/drivers/mt7628/files/etc/wireless/mt7628/mt7628.dat new file mode 100755 index 0000000..927823b --- /dev/null +++ b/drivers/mt7628/files/etc/wireless/mt7628/mt7628.dat @@ -0,0 +1,132 @@ +#The word of "Default" must not be removed +Default +CountryRegion=1 +CountryRegionABand=0 +CountryCode= +BssidNum=1 +SSID1=wifi-mt7628 +SSID2= +SSID3= +SSID4= +WirelessMode=9 +TxRate=0 +Channel=6 +BasicRate=15 +BeaconPeriod=100 +DtimPeriod=1 +TxPower=100 +DisableOLBC=0 +BGProtection=0 +MaxStaNum=0 +TxPreamble=0 +RTSThreshold=2347 +FragThreshold=2346 +TxBurst=0 +PktAggregate=0 +TurboRate=0 +WmmCapable=1 +APSDCapable=1 +DLSCapable=0 +APAifsn=3;7;1;1 +APCwmin=4;4;3;2 +APCwmax=6;10;4;3 +APTxop=0;0;94;47 +APACM=0;0;0;0 +BSSAifsn=3;7;2;2 +BSSCwmin=4;4;3;2 +BSSCwmax=10;10;4;3 +BSSTxop=0;0;94;47 +BSSACM=0;0;0;0 +AckPolicy=0;0;0;0 +NoForwarding=0 +NoForwardingBTNBSSID=0 +HideSSID=0 +StationKeepAlive=0 +ShortSlot=1 +AutoChannelSelect=0 +IEEE8021X=0 +IEEE80211H=0 +CSPeriod=10 +WirelessEvent=0 +IdsEnable=0 +AuthFloodThreshold=32 +AssocReqFloodThreshold=32 +ReassocReqFloodThreshold=32 +ProbeReqFloodThreshold=32 +DisassocFloodThreshold=32 +DeauthFloodThreshold=32 +EapReqFooldThreshold=32 +PreAuth=0 +AuthMode=OPEN +EncrypType=NONE +RekeyInterval=0 +RekeyMethod=DISABLE +PMKCachePeriod=10 +WPAPSK1= +WPAPSK2= +WPAPSK3= +WPAPSK4= +DefaultKeyID=1 +Key1Type=1;1;1;1 +Key1Str1= +Key1Str2= +Key1Str3= +Key1Str4= +Key2Type=1;1;1;1 +Key2Str1= +Key2Str2= +Key2Str3= +Key2Str4= +Key3Type=1;1;1;1 +Key3Str1= +Key3Str2= +Key3Str3= +Key3Str4= +Key4Type=1;1;1;1 +Key4Str1= +Key4Str2= +Key4Str3= +Key4Str4= +HSCounter=0 +AccessPolicy0=0 +AccessControlList0= +AccessPolicy1=0 +AccessControlList1= +AccessPolicy2=0 +AccessControlList2= +AccessPolicy3=0 +AccessControlList3= +WdsEnable=0 +WdsEncrypType=NONE +WdsList=EOF +WdsKey= +RADIUS_Server=192.168.2.3 +RADIUS_Port=1812 +RADIUS_Key=ralink +own_ip_addr=192.168.5.234 +EAPifname=br-lan +PreAuthifname=br-lan +HT_HTC=0 +HT_RDG=0 +HT_EXTCHA=0 +HT_LinkAdapt=0 +HT_OpMode=0 +HT_MpduDensity=5 +HT_BW=1 +HT_AutoBA=1 +HT_AMSDU=0 +HT_BAWinSize=64 +HT_GI=1 +HT_MCS=33 + +# WPS stuff +# 1 = enrollee, 2 = proxy, 4 = registrar (bitmask) +# This value is enabled later on, for WPA only +WscConfMode=0 +# 1 = disabled, 2 = enabled +WscConfStatus=2 +# 2 = PBC, 1 = PIN +WscMode = 2 + +HT_TxStream=2 +HT_RxStream=2 diff --git a/drivers/mt7628/files/lib/wifi/mt7628.lua b/drivers/mt7628/files/lib/wifi/mt7628.lua new file mode 100755 index 0000000..f7b4ee7 --- /dev/null +++ b/drivers/mt7628/files/lib/wifi/mt7628.lua @@ -0,0 +1,151 @@ +#!/usr/bin/lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + + +local function esc(x) + return (x:gsub('%%', '%%%%') + :gsub('^%^', '%%^') + :gsub('%$$', '%%$') + :gsub('%(', '%%(') + :gsub('%)', '%%)') + :gsub('%.', '%%.') + :gsub('%[', '%%[') + :gsub('%]', '%%]') + :gsub('%*', '%%*') + :gsub('%+', '%%+') + :gsub('%-', '%%-') + :gsub('%?', '%%?')) +end + +function add_vif_into_lan(vif) + local mtkwifi = require("mtkwifi") + local brvifs = mtkwifi.__trim( + mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, esc(vif)) then + nixio.syslog("debug", "add "..vif.." into lan") + brvifs = brvifs.." "..vif + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + -- os.execute("brctl addif br-lan "..vif) + os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end +end + +function mt7628_up(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7628_up called!") + + -- 7628 is always the 1st card and it takes "ra" and "apcli" prefix. + -- for multi-bssid, we must bring up ra0 first. ra0 will create ra1, ra2,... + if not mtkwifi.exists("/sys/class/net/ra0") then + nixio.syslog("err", "unable to detect ra0, abort!") + return + end + os.execute("ifconfig ra0 up") + add_vif_into_lan("ra0") + + -- then we bring up ra1, ra2,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra[1-9][0-9]*") then + os.execute("ifconfig "..vif.." up") + if not string.find(vif, "apcli") then + add_vif_into_lan(vif) + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + -- then we bring up apcli0, apcli1,... + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") then + os.execute("ifconfig "..vif.." up") + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7628*.need_reload") +end + +function mt7628_down(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7628_down called!") + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") then + os.execute("ifconfig "..vif.." down") + end + end + + for _,vif in mtkwifi.__spairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra%d+") then + os.execute("ifconfig "..vif.." down") + local brvifs = mtkwifi.read_pipe("uci get network.lan.ifname") + if string.match(brvifs, vif) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, vif, "")) + nixio.syslog("debug", "remove "..vif.." from lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vif.."\\\"}\"") + end + -- else nixio.syslog("debug", "skip "..vif..", prefix not match "..pre[1]) + end + end + + os.execute(" rm -rf /tmp/mtk/wifi/mt7628*.need_reload") +end + +function mt7628_reload(devname) + local nixio = require("nixio") + nixio.syslog("debug", "mt7628_reload called!") + mt7628_down() + os.execute("rmmod mt7628") + os.execute("modprobe mt7628") + mt7628_up() +end + +function mt7628_reset(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7628_reset called!") + if mtkwifi.exists("/rom/etc/wireless/mt7628/") then + os.execute("rm -rf /etc/wireless/mt7628/") + os.execute("cp -rf /rom/etc/wireless/mt7628/ /etc/wireless/") + mt7628_reload() + else + nixio.syslog("debug", "/rom"..profile.." missing, unable to reset!") + end +end + +function mt7628_status(devname) + return wifi_common_status() +end + +function mt7628_detect(devname) + local nixio = require("nixio") + local mtkwifi = require("mtkwifi") + nixio.syslog("debug", "mt7628_detect called!") + + for _,dev in ipairs(mtkwifi.get_all_devs()) do + print([[ +config wifi-device ]]..dev.maindev.."\n"..[[ + option type mt7628 + option vendor ralink +]]) + for _,vif in ipairs(dev.vifs) do + print([[ +config wifi-iface + option device ]]..dev.maindev.."\n"..[[ + option ifname ]]..vif.vifname.."\n"..[[ + option network lan + option mode ap + option ssid ]]..vif.__ssid.."\n") + end + end +end diff --git a/mtk-luci-plugin/Makefile b/mtk-luci-plugin/Makefile new file mode 100755 index 0000000..44d4d09 --- /dev/null +++ b/mtk-luci-plugin/Makefile @@ -0,0 +1,75 @@ +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/version.mk + +PKG_NAME:=mtk-luci-plugin +PKG_RELEASE:=1 +PKG_BUILD_DEPENDS:=base-files +PKG_FILE_DEPENDS:= +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Hua Shao + +include $(INCLUDE_DIR)/package.mk + +HTDOCS = /www +LUA_LIBRARYDIR = /usr/lib/lua +LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci + + +define Package/mtk-luci-plugin + SECTION:=MTK Properties + CATEGORY:=MTK Properties + SUBMENU:=Misc + DEPENDS:=+lua + TITLE:=MTK's LuCI plugins. + VERSION:=$(PKG_RELEASE)-$(REVISION) +endef + + +define Package/mtk-luci-plugin/config + config LUCI_APP_MTKWIFI + bool "luci-app-mtkwifi" + depends on PACKAGE_mtk-luci-plugin + default y + help + "LuCI plugin to manipulate MTK WiFi drivers" + + config LUCI_APP_WEBCONSOLE + bool "luci-app-webconsole" + depends on PACKAGE_mtk-luci-plugin + default y + help + "LuCI plugin for access shell from web" +endef + +define Build/Compile + +endef + +define Package/common/install + if [ -d $(2)/luasrc ]; then \ + $(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR); \ + cp -pR ./$(2)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/; \ + else true; fi + if [ -d $(2)/htdocs ]; then \ + $(INSTALL_DIR) $(1)$(HTDOCS); \ + cp -pR ./$(2)/htdocs/* $(1)$(HTDOCS)/; \ + else true; fi + if [ -d $(2)/root ]; then \ + $(INSTALL_DIR) $(1)/; \ + cp -pR ./$(2)/root/* $(1)/; \ + else true; fi + if [ -d $(2)/src ]; then \ + $(call Build/Install/Default) \ + $(CP) ./$(PKG_INSTALL_DIR)/* $(1)/; \ + else true; fi +endef + + +define Package/mtk-luci-plugin/install + $(call Package/common/install,$(1),luci-app-mtkwifi) + $(call Package/common/install,$(1),luci-app-webconsole) +endef + + +$(eval $(call BuildPackage,mtk-luci-plugin)) diff --git a/mtk-luci-plugin/luci-app-mtkwifi/Makefile b/mtk-luci-plugin/luci-app-mtkwifi/Makefile new file mode 100755 index 0000000..2ba0b6f --- /dev/null +++ b/mtk-luci-plugin/luci-app-mtkwifi/Makefile @@ -0,0 +1,19 @@ +include $(TOPDIR)/rules.mk + +PKG_LICENSE:=GPLv2 +PKG_MAINTAINER:=Hua Shao + +LUCI_TITLE:=Manipulate mtk's proprietary wifi driver. +LUCI_DEPENDS:= + +# earlier version of luci put "luci.mk" somewhere else... +LUCI_MK_OLDPATH:=$(shell test -e ../luci.mk && echo "old") +LUCI_MK_NEWPATH:=$(shell test -e ../../luci.mk && echo "new") +ifeq ($(LUCI_MK_OLDPATH),old) +include ../luci.mk +endif +ifeq ($(LUCI_MK_NEWPATH),new) +include ../../luci.mk +endif + +# call BuildPackage - OpenWrt buildroot signature diff --git a/mtk-luci-plugin/luci-app-mtkwifi/luasrc/controller/mtkwifi.lua b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/controller/mtkwifi.lua new file mode 100755 index 0000000..bd6078f --- /dev/null +++ b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/controller/mtkwifi.lua @@ -0,0 +1,1209 @@ +-- This module is a demo to configure MTK' proprietary WiFi driver. +-- Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly. +-- LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to +-- translate uci into MTK's WiFi profile (like we did in "uci2dat"). +-- And you will get your hands dirty. +-- +-- Hua Shao + +module("luci.controller.mtkwifi", package.seeall) +local http = require("luci.http") +local mtkwifi = require("mtkwifi") + +function debug_write(...) + local ff = io.open("/tmp/dbgmsg", "a") + local vars = {...} + for _, v in pairs(vars) do + ff:write(v.." ") + end + ff:write("\n") + ff:close() + nixio.syslog("debug", ...) +end + +function index() + entry({"admin", "mtk"}, alias({"admin", "mtk", "console"}), _("MTK"), 80) + entry({"admin", "mtk", "wifi"}, template("admin_mtk/mtk_wifi_overview"), _("WiFi configuration"), 1) + entry({"admin", "mtk", "wifi", "dev_cfg_view"}, template("admin_mtk/mtk_wifi_dev_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "dev_cfg"}, call("dev_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "dev_cfg_reset"}, call("dev_cfg_reset")).leaf = true + entry({"admin", "mtk", "wifi", "dev_cfg_raw"}, call("dev_cfg_raw")).leaf = true + entry({"admin", "mtk", "wifi", "vif_cfg_view"}, template("admin_mtk/mtk_wifi_vif_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "vif_cfg"}, call("vif_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "vif_add_view"}, template("admin_mtk/mtk_wifi_vif_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "vif_add"}, call("vif_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "vif_del"}, call("vif_del")).leaf = true + entry({"admin", "mtk", "wifi", "vif_disable"}, call("vif_disable")).leaf = true + entry({"admin", "mtk", "wifi", "vif_enable"}, call("vif_enable")).leaf = true + entry({"admin", "mtk", "wifi", "get_station_list"}, call("get_station_list")) + entry({"admin", "mtk", "wifi", "get_country_region_list"}, call("get_country_region_list")).leaf = true + entry({"admin", "mtk", "wifi", "get_channel_list"}, call("get_channel_list")) + entry({"admin", "mtk", "wifi", "get_HT_ext_channel_list"}, call("get_HT_ext_channel_list")) + entry({"admin", "mtk", "wifi", "get_5G_2nd_80Mhz_channel_list"}, call("get_5G_2nd_80Mhz_channel_list")) + entry({"admin", "mtk", "wifi", "reset"}, call("reset_wifi")).leaf = true + entry({"admin", "mtk", "wifi", "reload"}, call("reload_wifi")).leaf = true + entry({"admin", "mtk", "wifi", "get_raw_profile"}, call("get_raw_profile")) + entry({"admin", "mtk", "wifi", "apcli_cfg_view"}, template("admin_mtk/mtk_wifi_apcli")).leaf = true + entry({"admin", "mtk", "wifi", "apcli_cfg"}, call("apcli_cfg")).leaf = true + entry({"admin", "mtk", "wifi", "apcli_disconnect"}, call("apcli_disconnect")).leaf = true + entry({"admin", "mtk", "wifi", "apcli_connect"}, call("apcli_connect")).leaf = true + entry({"admin", "mtk", "wifi", "get_wps_info"}, call("get_WPS_Info")).leaf = true + entry({"admin", "mtk", "wifi", "get_wifi_pin"}, call("get_wifi_pin")).leaf = true + entry({"admin", "mtk", "wifi", "set_wifi_gen_pin"}, call("set_wifi_gen_pin")).leaf = true + entry({"admin", "mtk", "wifi", "set_wifi_wps_oob"}, call("set_wifi_wps_oob")).leaf = true + entry({"admin", "mtk", "wifi", "set_wifi_do_wps"}, call("set_wifi_do_wps")).leaf = true + entry({"admin", "mtk", "wifi", "get_wps_security"}, call("get_wps_security")).leaf = true + entry({"admin", "mtk", "wifi", "apcli_get_wps_status"}, call("apcli_get_wps_status")).leaf = true; + entry({"admin", "mtk", "wifi", "apcli_do_enr_pin_wps"}, call("apcli_do_enr_pin_wps")).leaf = true; + entry({"admin", "mtk", "wifi", "apcli_do_enr_pbc_wps"}, call("apcli_do_enr_pbc_wps")).leaf = true; + entry({"admin", "mtk", "wifi", "apcli_cancel_wps"}, call("apcli_cancel_wps")).leaf = true; + entry({"admin", "mtk", "wifi", "apcli_wps_gen_pincode"}, call("apcli_wps_gen_pincode")).leaf = true; + entry({"admin", "mtk", "wifi", "apcli_wps_get_pincode"}, call("apcli_wps_get_pincode")).leaf = true; + entry({"admin", "mtk", "wifi", "apcli_scan"}, call("apcli_scan")).leaf = true; +end + +function dev_cfg(devname) + local profiles = mtkwifi.search_dev_and_profile() + assert(profiles[devname]) + local cfgs = mtkwifi.load_profile(profiles[devname]) + + for k,v in pairs(http.formvalue()) do + if type(v) ~= type("") and type(v) ~= type(0) then + nixio.syslog("err", "dev_cfg, invalid value type for "..k..","..type(v)) + elseif string.byte(k) == string.byte("_") then + nixio.syslog("err", "dev_cfg, special: "..k.."="..v) + else + cfgs[k] = v or "" + end + end + + if mtkwifi.band(cfgs.WirelessMode) == "5G" then + cfgs.CountryRegionABand = http.formvalue("__cr"); + else + cfgs.CountryRegion = http.formvalue("__cr"); + end + + if cfgs.Channel == "0" then -- Auto Channel Select + cfgs.AutoChannelSelect = "3" + else + cfgs.AutoChannelSelect = "0" + end + + if http.formvalue("__bw") == "20" then + cfgs.HT_BW = 0 + cfgs.VHT_BW = 0 + elseif http.formvalue("__bw") == "40" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 0 + cfgs.HT_BSSCoexistence = 0 + elseif http.formvalue("__bw") == "60" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 0 + cfgs.HT_BSSCoexistence = 1 + elseif http.formvalue("__bw") == "80" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 1 + elseif http.formvalue("__bw") == "160" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 2 + elseif http.formvalue("__bw") == "161" then + cfgs.HT_BW = 1 + cfgs.VHT_BW = 3 + cfgs.VHT_Sec80_Channel = http.formvalue("VHT_Sec80_Channel") or "" + end + + if cfgs.ApCliAuthMode == "WEP" then + cfgs.ApCliEncrypType = http.formvalue("__apcli_wep_enctype") + else + cfgs.ApCliEncrypType = http.formvalue("__apcli_wpa_enctype") + end + + local mimo = http.formvalue("__mimo") + if mimo == "0" then + cfgs.ETxBfEnCond=1 + cfgs.MUTxRxEnable=0 + cfgs.ITxBfEn=0 + elseif mimo == "1" then + cfgs.ETxBfEnCond=0 + cfgs.MUTxRxEnable=0 + cfgs.ITxBfEn=1 + elseif mimo == "2" then + cfgs.ETxBfEnCond=1 + cfgs.MUTxRxEnable=0 + cfgs.ITxBfEn=1 + elseif mimo == "3" then + cfgs.ETxBfEnCond=1 + if tonumber(cfgs.ApCliEnable) == 1 then + cfgs.MUTxRxEnable=3 + else + cfgs.MUTxRxEnable=1 + end + cfgs.ITxBfEn=0 + elseif mimo == "4" then + cfgs.ETxBfEnCond=1 + if tonumber(cfgs.ApCliEnable) == 1 then + cfgs.MUTxRxEnable=3 + else + cfgs.MUTxRxEnable=1 + end + cfgs.ITxBfEn=1 + else + cfgs.ETxBfEnCond=0 + cfgs.MUTxRxEnable=0 + cfgs.ITxBfEn=0 + end + +-- if cfgs.ApCliEnable == "1" then +-- cfgs.Channel = http.formvalue("__apcli_channel") +-- end + + -- VOW + -- ATC should actually be scattered into each SSID, but I'm just lazy. + if cfgs.VOW_Airtime_Fairness_En then + for i = 1,tonumber(cfgs.BssidNum) do + __atc_tp = http.formvalue("__atc_vif"..i.."_tp") or "0" + __atc_min_tp = http.formvalue("__atc_vif"..i.."_min_tp") or "0" + __atc_max_tp = http.formvalue("__atc_vif"..i.."_max_tp") or "0" + __atc_at = http.formvalue("__atc_vif"..i.."_at") or "0" + __atc_min_at = http.formvalue("__atc_vif"..i.."_min_at") or "0" + __atc_max_at = http.formvalue("__atc_vif"..i.."_max_at") or "0" + + nixio.syslog("info", "ATC.__atc_tp ="..i..__atc_tp ); + nixio.syslog("info", "ATC.__atc_min_tp ="..i..__atc_min_tp ); + nixio.syslog("info", "ATC.__atc_max_tp ="..i..__atc_max_tp ); + nixio.syslog("info", "ATC.__atc_at ="..i..__atc_at ); + nixio.syslog("info", "ATC.__atc_min_at ="..i..__atc_min_at ); + nixio.syslog("info", "ATC.__atc_max_at ="..i..__atc_max_at ); + + cfgs.VOW_Rate_Ctrl_En = mtkwifi.token_set(cfgs.VOW_Rate_Ctrl_En, i, __atc_tp) + cfgs.VOW_Group_Min_Rate = mtkwifi.token_set(cfgs.VOW_Group_Min_Rate, i, __atc_min_tp) + cfgs.VOW_Group_Max_Rate = mtkwifi.token_set(cfgs.VOW_Group_Max_Rate, i, __atc_max_tp) + + cfgs.VOW_Airtime_Ctrl_En = mtkwifi.token_set(cfgs.VOW_Airtime_Ctrl_En, i, __atc_at) + cfgs.VOW_Group_Min_Ratio = mtkwifi.token_set(cfgs.VOW_Group_Min_Ratio, i, __atc_min_at) + cfgs.VOW_Group_Max_Ratio = mtkwifi.token_set(cfgs.VOW_Group_Max_Ratio, i, __atc_max_at) + end + + cfgs.VOW_RX_En = http.formvalue("VOW_RX_En") or "0" + end + + -- http.write_json(http.formvalue()) + mtkwifi.save_profile(cfgs, profiles[devname]) + + if http.formvalue("__apply") then + os.execute("/sbin/mtkwifi reload "..devname) + os.execute("rm -f /tmp/mtk/wifi/"..devname..".need_reload") + else + os.execute("touch /tmp/mtk/wifi/"..devname..".need_reload") + end + + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi", "dev_cfg_view",devname)) +end + +function dev_cfg_raw(devname) + -- http.write_json(http.formvalue()) + local profiles = mtkwifi.search_dev_and_profile() + assert(profiles[devname]) + + local raw = http.formvalue("raw") + raw = string.gsub(raw, "\r\n", "\n") + local cfgs = mtkwifi.load_profile(nil, raw) + mtkwifi.save_profile(cfgs, profiles[devname]) + + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi", "dev_cfg_view", devname)) +end + +function dev_cfg_reset(devname) + -- http.write_json(http.formvalue()) + local profiles = mtkwifi.search_dev_and_profile() + assert(profiles[devname]) + + local fd = io.open("/rom"..profiles[devname], "r") + if fd then + fd:close() -- just to test if file exists. + os.execute("cp -f /rom"..profiles[devname].." "..profiles[devname]) + else + debug_write("unable to find /rom"..profiles[devname]) + end + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi", "dev_cfg_view", devname)) +end + +function vif_del(dev, vif) + debug_write("vif_del("..dev..vif..")") + local devname,vifname = dev, vif + debug_write("devname="..devname) + debug_write("vifname="..vifname) + local devs = mtkwifi.get_all_devs() + local idx = devs[devname]["vifs"][vifname].vifidx -- or tonumber(string.match(vifname, "%d+")) + 1 + debug_write("idx="..idx, devname, vifname) + local profile = devs[devname].profile + assert(profile) + if idx and tonumber(idx) >= 0 then + local cfgs = mtkwifi.load_profile(profile) + if cfgs then + debug_write("ssid"..idx.."="..cfgs["SSID"..idx].."
") + cfgs["SSID"..idx] = "" + debug_write("ssid"..idx.."="..cfgs["SSID"..idx].."
") + debug_write("wpapsk"..idx.."="..cfgs["WPAPSK"..idx].."
") + cfgs["WPAPSK"..idx] = "" + local ssidlist = {} + local j = 1 + for i = 1,16 do + if cfgs["SSID"..i] ~= "" then + ssidlist[j] = cfgs["SSID"..i] + j = j + 1 + end + end + for i,v in ipairs(ssidlist) do + debug_write("ssidlist"..i.."="..v) + end + debug_write("cfgs.BssidNum="..cfgs.BssidNum.." #ssidlist="..#ssidlist) + assert(tonumber(cfgs.BssidNum) == #ssidlist + 1, "Please delete vif from larger idx.") + cfgs.BssidNum = #ssidlist + for i = 1,16 do + if i <= cfgs.BssidNum then + cfgs["SSID"..i] = ssidlist[i] + elseif cfgs["SSID"..i] then + cfgs["SSID"..i] = "" + end + end + + mtkwifi.save_profile(cfgs, profile) + os.execute("touch /tmp/mtk/wifi/"..devname..".need_reload") + else + debug_write(profile.." cannot be found!") + end + end + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function vif_disable(iface) + os.execute("ifconfig "..iface.." down") + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function vif_enable(iface) + os.execute("ifconfig "..iface.." up") + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + + +--[[ +-- security config in mtk wifi is quite complicated! +-- cfgs listed below are attached with vif and combined like "0;0;0;0". They need specicial treatment. + TxRate, WmmCapable, NoForwarding, + HideSSID, IEEE8021X, PreAuth, + AuthMode, EncrypType, RekeyMethod, + RekeyInterval, PMKCachePeriod, + DefaultKeyId, Key{n}Type, HT_EXTCHA, + RADIUS_Server, RADIUS_Port, +]] + +local function conf_wep_keys(cfgs,vifidx) + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vifidx, http.formvalue("__DefaultKeyID") or 1) + cfgs["Key1Str"..vifidx] = http.formvalue("Key1Str"..vifidx) + cfgs["Key2Str"..vifidx] = http.formvalue("Key2Str"..vifidx) + cfgs["Key3Str"..vifidx] = http.formvalue("Key3Str"..vifidx) + cfgs["Key4Str"..vifidx] = http.formvalue("Key4Str"..vifidx) + + cfgs["Key1Type"]=mtkwifi.token_set(cfgs["Key1Type"],vifidx, http.formvalue("WEP1Type"..vifidx)) + cfgs["Key2Type"]=mtkwifi.token_set(cfgs["Key2Type"],vifidx, http.formvalue("WEP2Type"..vifidx)) + cfgs["Key3Type"]=mtkwifi.token_set(cfgs["Key3Type"],vifidx, http.formvalue("WEP3Type"..vifidx)) + cfgs["Key4Type"]=mtkwifi.token_set(cfgs["Key4Type"],vifidx, http.formvalue("WEP4Type"..vifidx)) + + return cfgs +end + +local function __security_cfg(cfgs, vif_idx) + debug_write("__security_cfg, before, HideSSID="..tostring(cfgs.HideSSID)) + debug_write("__security_cfg, before, NoForwarding="..tostring(cfgs.NoForwarding)) + debug_write("__security_cfg, before, WmmCapable="..tostring(cfgs.WmmCapable)) + debug_write("__security_cfg, before, TxRate="..tostring(cfgs.TxRate)) + debug_write("__security_cfg, before, RekeyInterval="..tostring(cfgs.RekeyInterval)) + debug_write("__security_cfg, before, AuthMode="..tostring(cfgs.AuthMode)) + debug_write("__security_cfg, before, EncrypType="..tostring(cfgs.EncrypType)) + debug_write("__security_cfg, before, WscModeOption="..tostring(cfgs.WscModeOption)) + debug_write("__security_cfg, before, RekeyMethod="..tostring(cfgs.RekeyMethod)) + debug_write("__security_cfg, before, IEEE8021X="..tostring(cfgs.IEEE8021X)) + debug_write("__security_cfg, before, DefaultKeyID="..tostring(cfgs.DefaultKeyID)) + debug_write("__security_cfg, before, PMFMFPC="..tostring(cfgs.PMFMFPC)) + debug_write("__security_cfg, before, PMFMFPR="..tostring(cfgs.PMFMFPR)) + debug_write("__security_cfg, before, PMFSHA256="..tostring(cfgs.PMFSHA256)) + debug_write("__security_cfg, before, RADIUS_Server="..tostring(cfgs.RADIUS_Server)) + debug_write("__security_cfg, before, RADIUS_Port="..tostring(cfgs.RADIUS_Port)) + debug_write("__security_cfg, before, session_timeout_interval="..tostring(cfgs.session_timeout_interval)) + debug_write("__security_cfg, before, PMKCachePeriod="..tostring(cfgs.PMKCachePeriod)) + debug_write("__security_cfg, before, PreAuth="..tostring(cfgs.PreAuth)) + debug_write("__security_cfg, before, Wapiifname="..tostring(cfgs.Wapiifname)) + + cfgs.HideSSID = mtkwifi.token_set(cfgs.HideSSID, vif_idx, http.formvalue("__hidessid") or "0") + cfgs.NoForwarding = mtkwifi.token_set(cfgs.NoForwarding, vif_idx, http.formvalue("__noforwarding") or "0") + cfgs.WmmCapable = mtkwifi.token_set(cfgs.WmmCapable, vif_idx, http.formvalue("__wmmcapable") or "0") + cfgs.TxRate = mtkwifi.token_set(cfgs.TxRate, vif_idx, http.formvalue("__txrate") or "0"); + cfgs.RekeyInterval = mtkwifi.token_set(cfgs.RekeyInterval, vif_idx, http.formvalue("__rekeyinterval") or "0"); + + local __authmode = http.formvalue("__authmode") or "Disable" + cfgs.AuthMode = mtkwifi.token_set(cfgs.AuthMode, vif_idx, __authmode) + + --[[ need to handle disable case as it conflicts with OPENWEP + case = disable; authmode = OPEN, encryption = NONE + case = open/OPENWEP; authmode = OPEN, encryption = WEP + ]] + if __authmode == "Disable" then + cfgs.AuthMode = mtkwifi.token_set(cfgs.AuthMode, vif_idx, "OPEN") + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "NONE") + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "DISABLE") + elseif __authmode == "OPEN" or __authmode == "SHARED" or __authmode == "WEPAUTO" then + --[[ the following required cfgs are already set in loop above + cfgs.Key{n}Str, ... + cfgs.Key{n}Type, ... + cfgs.DefaultKeyID + ]] + cfgs.WscModeOption = "0" + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "WEP") + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "DISABLE") + cfgs = conf_wep_keys(cfgs,vif_idx) + cfgs.WscConfMode = mtkwifi.token_set(cfgs.WscConfMode, vif_idx, 0) + elseif __authmode == "WPAPSK" or __authmode == "WPAPSKWPA2PSK" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + ]] + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "NONE") + --cfgs["WPAPSK"..vif_idx] = http.formvalue("WPAPSK"..vif_idx) + elseif __authmode == "WPA2PSK" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + ]] + -- for DOT11W_PMF_SUPPORT + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "0") + if cfgs.PMFMFPC then + cfgs.PMFMFPC = mtkwifi.token_set(cfgs.PMFMFPC, vif_idx, http.formvalue("__pmfmfpc") or "0") + end + if cfgs.PMFMFPR then + cfgs.PMFMFPR = mtkwifi.token_set(cfgs.PMFMFPR, vif_idx, http.formvalue("__pmfmfpr") or "0") + end + if cfgs.PMFSHA256 then + cfgs.PMFSHA256 = mtkwifi.token_set(cfgs.PMFSHA256, vif_idx, http.formvalue("__pmfsha256") or "0") + end + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + elseif __authmode == "WPA" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + cfgs.RADIUS_Key + ]] + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "0") + cfgs.RADIUS_Server = mtkwifi.token_set(cfgs.RADIUS_Server, vif_idx, http.formvalue("__radius_server") or "0") + cfgs.RADIUS_Port = mtkwifi.token_set(cfgs.RADIUS_Port, vif_idx, http.formvalue("__radius_port") or "0") + cfgs.session_timeout_interval = mtkwifi.token_set(cfgs.session_timeout_interval, vif_idx, http.formvalue("__session_timeout_interval") or "0") + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + elseif __authmode == "WPA2" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + cfgs.RADIUS_Key + ]] + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "0") + cfgs.RADIUS_Server = mtkwifi.token_set(cfgs.RADIUS_Server, vif_idx, http.formvalue("__radius_server") or "0") + cfgs.RADIUS_Port = mtkwifi.token_set(cfgs.RADIUS_Port, vif_idx, http.formvalue("__radius_port") or "0") + cfgs.session_timeout_interval = mtkwifi.token_set(cfgs.session_timeout_interval, vif_idx, http.formvalue("__session_timeout_interval") or "0") + cfgs.PMKCachePeriod = mtkwifi.token_set(cfgs.PMKCachePeriod, vif_idx, http.formvalue("__pmkcacheperiod") or "0") + cfgs.PreAuth = mtkwifi.token_set(cfgs.PreAuth, vif_idx, http.formvalue("__preauth") or "0") + -- for DOT11W_PMF_SUPPORT + if cfgs.PMFMFPC then + cfgs.PMFMFPC = mtkwifi.token_set(cfgs.PMFMFPC, vif_idx, http.formvalue("__pmfmfpc") or "0") + end + if cfgs.PMFMFPR then + cfgs.PMFMFPR = mtkwifi.token_set(cfgs.PMFMFPR, vif_idx, http.formvalue("__pmfmfpr") or "0") + end + if cfgs.PMFSHA256 then + cfgs.PMFSHA256 = mtkwifi.token_set(cfgs.PMFSHA256, vif_idx, http.formvalue("__pmfsha256") or "0") + end + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + elseif __authmode == "WPA1WPA2" then + --[[ the following required cfgs are already set in loop above + cfgs.WPAPSK{n}, ... + cfgs.RekeyInterval + cfgs.RADIUS_Key + ]] + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, http.formvalue("__wpa_encrypttype") or "0") + cfgs.RADIUS_Server = mtkwifi.token_set(cfgs.RADIUS_Server, vif_idx, http.formvalue("__radius_server") or "0") + cfgs.RADIUS_Port = mtkwifi.token_set(cfgs.RADIUS_Port, vif_idx, http.formvalue("__radius_port") or "1812") + cfgs.session_timeout_interval = mtkwifi.token_set(cfgs.session_timeout_interval, vif_idx, http.formvalue("__session_timeout_interval") or "0") + cfgs.PMKCachePeriod = mtkwifi.token_set(cfgs.PMKCachePeriod, vif_idx, http.formvalue("__pmkcacheperiod") or "0") + cfgs.PreAuth = mtkwifi.token_set(cfgs.PreAuth, vif_idx, http.formvalue("__preauth") or "0") + + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "TIME") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "0") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, vif_idx, "2") + elseif __authmode == "IEEE8021X" then + cfgs.RekeyMethod = mtkwifi.token_set(cfgs.RekeyMethod, vif_idx, "DISABLE") + cfgs.AuthMode = mtkwifi.token_set(cfgs.AuthMode, vif_idx, "OPEN") + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, vif_idx, "1") + cfgs.RADIUS_Server = mtkwifi.token_set(cfgs.RADIUS_Server, vif_idx, http.formvalue("__radius_server") or "0") + cfgs.RADIUS_Port = mtkwifi.token_set(cfgs.RADIUS_Port, vif_idx, http.formvalue("__radius_port") or "0") + cfgs.session_timeout_interval = mtkwifi.token_set(cfgs.session_timeout_interval, vif_idx, http.formvalue("__session_timeout_interval") or "0") + if http.formvalue("__8021x_wep") then + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "WEP") + else + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "NONE") + end + elseif __authmode == "WAICERT" then + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "SMS4") + cfgs.Wapiifname = mtkwifi.token_set(cfgs.Wapiifname, vif_idx, "br-lan") + -- cfgs.wapicert_asipaddr + -- cfgs.WapiAsPort + -- cfgs.wapicert_ascert + -- cfgs.wapicert_usercert + elseif __authmode == "WAIPSK" then + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, vif_idx, "SMS4") + -- cfgs.wapipsk_keytype + -- cfgs.wapipsk_prekey + end + + debug_write("__security_cfg, after, HideSSID="..tostring(cfgs.HideSSID)) + debug_write("__security_cfg, after, NoForwarding="..tostring(cfgs.NoForwarding)) + debug_write("__security_cfg, after, WmmCapable="..tostring(cfgs.WmmCapable)) + debug_write("__security_cfg, after, TxRate="..tostring(cfgs.TxRate)) + debug_write("__security_cfg, after, RekeyInterval="..tostring(cfgs.RekeyInterval)) + debug_write("__security_cfg, after, AuthMode="..tostring(cfgs.AuthMode)) + debug_write("__security_cfg, after, EncrypType="..tostring(cfgs.EncrypType)) + debug_write("__security_cfg, after, WscModeOption="..tostring(cfgs.WscModeOption)) + debug_write("__security_cfg, after, RekeyMethod="..tostring(cfgs.RekeyMethod)) + debug_write("__security_cfg, after, IEEE8021X="..tostring(cfgs.IEEE8021X)) + debug_write("__security_cfg, after, DefaultKeyID="..tostring(cfgs.DefaultKeyID)) + debug_write("__security_cfg, after, PMFMFPC="..tostring(cfgs.PMFMFPC)) + debug_write("__security_cfg, after, PMFMFPR="..tostring(cfgs.PMFMFPR)) + debug_write("__security_cfg, after, PMFSHA256="..tostring(cfgs.PMFSHA256)) + debug_write("__security_cfg, after, RADIUS_Server="..tostring(cfgs.RADIUS_Server)) + debug_write("__security_cfg, after, RADIUS_Port="..tostring(cfgs.RADIUS_Port)) + debug_write("__security_cfg, after, session_timeout_interval="..tostring(cfgs.session_timeout_interval)) + debug_write("__security_cfg, after, PMKCachePeriod="..tostring(cfgs.PMKCachePeriod)) + debug_write("__security_cfg, after, PreAuth="..tostring(cfgs.PreAuth)) + debug_write("__security_cfg, after, Wapiifname="..tostring(cfgs.Wapiifname)) +end + +function initialize_multiBssParameters(cfgs,vif_idx) + cfgs["WPAPSK"..vif_idx]="12345678" + cfgs["Key1Type"]=mtkwifi.token_set(cfgs["Key1Type"],vif_idx,"0") + cfgs["Key2Type"]=mtkwifi.token_set(cfgs["Key2Type"],vif_idx,"0") + cfgs["Key3Type"]=mtkwifi.token_set(cfgs["Key3Type"],vif_idx,"0") + cfgs["Key4Type"]=mtkwifi.token_set(cfgs["Key4Type"],vif_idx,"0") + cfgs["RADIUS_Server"]=mtkwifi.token_set(cfgs["RADIUS_Server"],vif_idx,"0") + cfgs["RADIUS_Key"..vif_idx]="ralink" + cfgs["DefaultKeyID"]=mtkwifi.token_set(cfgs["DefaultKeyID"],vif_idx,"1") + cfgs["IEEE8021X"]=mtkwifi.token_set(cfgs["IEEE8021X"],vif_idx,"0") + cfgs["WscConfMode"]=mtkwifi.token_set(cfgs["WscConfMode"],vif_idx,"0") + cfgs["PreAuth"]=mtkwifi.token_set(cfgs["PreAuth"],vif_idx,"0") + return cfgs +end + +function __wps_ap_pbc_start_all(ifname) + os.execute("iwpriv "..ifname.." set WscMode=2"); + os.execute("iwpriv "..ifname.." set WscGetConf=1"); +end + +function __wps_ap_pin_start_all(ifname, pincode) + os.execute("iwpriv "..ifname.." set WscMode=1") + os.execute("iwpriv "..ifname.." set WscPinCode="..pincode) + os.execute("iwpriv "..ifname.." set WscGetConf=1") +end + +--Landen: CP functions from wireless for Ajax, reloading page is not required when DBDC ssid changed. + +function __restart_hotspot_daemon() + os.execute("killall hs") + os.execute("hs -d 1 -v 2 -f/etc_ro/hotspot_ap.conf") + os.execute("rm -rf /tmp/hotspot*") +end + +function __restart_8021x(devname) + mtkwifi.restart_8021x(devname) + __restart_hotspot_daemon() +end + +function __set_wifi_wpsconf(cfgs, wsc_enable, devname, ifname) + local ssid_index; + local devs = mtkwifi.get_all_devs() + local profile = devs[devname].profile + assert(profile) + + ssid_index = devs[devname]["vifs"][ifname].vifidx + + if(wsc_enable == "1") then + debug_write(cfgs["WscConfMode"]) + cfgs["WscConfMode"] = mtkwifi.token_set(cfgs["WscConfMode"], ssid_index, "7") + else + cfgs["WscConfMode"] = mtkwifi.token_set(cfgs["WscConfMode"], ssid_index, "0") + end + + cfgs = mtkwifi.__restart_if_wps(devname, ifname, cfgs) + os.execute("miniupnpd.sh init") + debug_write("miniupnpd.sh init") + return cfgs +end + +function vif_cfg(dev, vif) + local devname, vifname = dev, vif + if not devname then devname = vif end + debug_write("devname="..devname) + debug_write("vifname="..(vifname or "")) + local devs = mtkwifi.get_all_devs() + local profile = devs[devname].profile + assert(profile) + + local cfgs = mtkwifi.load_profile(profile) + + for k,v in pairs(http.formvalue()) do + if type(v) == type("") or type(v) == type(0) then + nixio.syslog("debug", "post."..k.."="..tostring(v)) + else + nixio.syslog("debug", "post."..k.." invalid, type="..type(v)) + end + end + + -- sometimes vif_idx start from 0, like AccessPolicy0 + -- sometimes it starts from 1, like WPAPSK1. nice! + local vif_idx + local to_url + if http.formvalue("__action") == "vif_cfg_view" then + vif_idx = devs[devname]["vifs"][vifname].vifidx + debug_write("vif_idx=", vif_idx, devname, vifname) + to_url = luci.dispatcher.build_url("admin", "mtk", "wifi", "vif_cfg_view", devname, vifname) + elseif http.formvalue("__action") == "vif_add_view" then + cfgs.BssidNum = tonumber(cfgs.BssidNum) + 1 + vif_idx = tonumber(cfgs.BssidNum) + to_url = luci.dispatcher.build_url("admin", "mtk", "wifi") + -- initializing ; separated parameters for the new interface + cfgs = initialize_multiBssParameters(cfgs, vif_idx) + + end + + if http.formvalue("__activeTab") == "WPS" then + __set_wifi_wpsconf(cfgs, http.formvalue("WPSRadio"), dev, vif) + else + -- "__" should not be in the name if user wants to copy formvalue data directly in the dat file variable + for k,v in pairs(http.formvalue()) do + if type(v) ~= type("") and type(v) ~= type(0) then + nixio.syslog("err", "vif_cfg, invalid value type for "..k..","..type(v)) + elseif string.byte(k) ~= string.byte("_") then + debug_write("copying values for "..k) + cfgs[k] = v or "" + end + end + + cfgs["AccessPolicy"..vif_idx-1] = http.formvalue("__accesspolicy") + local t = mtkwifi.parse_mac(http.formvalue("__maclist")) + cfgs["AccessControlList"..vif_idx-1] = table.concat(t, ";") + + __security_cfg(cfgs, vif_idx) + end + + debug_write(devname, profile) + mtkwifi.save_profile(cfgs, profile) + if http.formvalue("__apply") then + os.execute("/sbin/mtkwifi reload "..devname) + os.execute("rm -f /tmp/mtk/wifi/"..devname..".need_reload") + else + os.execute("touch /tmp/mtk/wifi/"..devname..".need_reload") + end + return luci.http.redirect(to_url) +end + +function get_WPS_Info(vif) + local WPS_details = {} + WPS_details = c_getCurrentWscProfile(vif) + http.write_json(WPS_details) +end + +function get_wifi_pin(ifname) + local pin = "" + pin = c_getApPin(ifname) + http.write_json(pin) +end + +function set_wifi_gen_pin(ifname,devname) + local devs = mtkwifi.get_all_devs() + local ssid_index = devs[devname]["vifs"][ifname].vifidx + local profile = devs[devname].profile + assert(profile) + + local cfgs = mtkwifi.load_profile(profile) + + os.execute("iwpriv "..ifname.." set WscGenPinCode") + + pin = c_getApPin(ifname) + cfgs["WscVendorPinCode"]=pin["genpincode"] + + --existing c code... done nothing for this segment as it read flash data and write to related .dat file. + -- no concept of nvram zones here + --if (nvram == RT2860_NVRAM) + -- do_system("ralink_init make_wireless_config rt2860"); + --else + -- do_system("ralink_init make_wireless_config rtdev"); + + mtkwifi.save_profile(cfgs, profile) + http.write_json(pin) +end + +function set_wifi_wps_oob(devname, ifname) + local SSID, mac = "" + local ssid_index = 0 + local devs = mtkwifi.get_all_devs() + local profile = devs[devname].profile + assert(profile) + + local cfgs = mtkwifi.load_profile(profile) + + ssid_index = devs[devname]["vifs"][ifname].vifidx + mac = c_get_macaddr(ifname) + http.write_json("ssid index "..ssid_index.." mac address "..mac["macaddr"]) + if (mac["macaddr"] ~= "") then + SSID = "RalinkInitAP"..(ssid_index-1).."_"..mac["macaddr"] + else + SSID = "RalinkInitAP"..(ssid_index-1).."_unknown" + end + + cfgs["SSID"..ssid_index]=SSID + cfgs.WscConfStatus = mtkwifi.token_set(cfgs.WscConfStatus, ssid_index, "1") + cfgs.AuthMode = mtkwifi.token_set(cfgs.AuthMode, ssid_index, "WPA2PSK") + cfgs.EncrypType = mtkwifi.token_set(cfgs.EncrypType, ssid_index, "AES") + cfgs.DefaultKeyID = mtkwifi.token_set(cfgs.DefaultKeyID, ssid_index, "2") + + cfgs["WPAPSK"..ssid_index]="12345678" + cfgs["WPAPSK"]="" + cfgs.IEEE8021X = mtkwifi.token_set(cfgs.IEEE8021X, ssid_index, "0") + + os.execute("iwpriv "..ifname.." set SSID="..SSID ) + debug_write("iwpriv "..ifname.." set SSID="..SSID ) + os.execute("iwpriv "..ifname.." set AuthMode=WPA2PSK") + debug_write("iwpriv "..ifname.." set AuthMode=WPA2PSK") + os.execute("iwpriv "..ifname.." set EncrypType=AES") + debug_write("iwpriv "..ifname.." set EncrypType=AES") + os.execute("iwpriv "..ifname.." set WPAPSK=12345678") + debug_write("iwpriv "..ifname.." set WPAPSK=12345678") + os.execute("iwpriv "..ifname.." set SSID="..SSID) + debug_write("iwpriv "..ifname.." set SSID="..SSID) + + __restart_8021x(devname) + + cfgs = mtkwifi.__restart_if_wps(devname, ifname, cfgs) + os.execute("miniupnpd.sh init") + debug_write("miniupnpd.sh init") + + os.execute("iwpriv "..ifname.." set WscConfStatus=1") + mtkwifi.save_profile(cfgs, profile) + http.write("{\"wps_oob\":\"OK\"}") +end + +function set_wifi_do_wps(ifname, devname, wsc_pin_code_w) + local devs = mtkwifi.get_all_devs() + local ssid_index = devs[devname]["vifs"][ifname].vifidx + local profile = devs[devname].profile + local wsc_mode = 0 + local wsc_conf_mode + assert(profile) + + local cfgs = mtkwifi.load_profile(profile) + + if(wsc_pin_code_w == "nopin") then + wsc_mode=2 + else + wsc_mode=1 + end + + wsc_conf_mode = mtkwifi.token_get(cfgs["WscConfMode"], ssid_index, nil) + + if (wsc_conf_mode == 0) then + print("{\"wps_start\":\"WPS_NOT_ENABLED\"}") + DBG_MSG("WPS is not enabled before do PBC/PIN.\n") + return + end + + if (wsc_mode == 1) then + __wps_ap_pin_start_all(ifname, wsc_pin_code_w) + + elseif (wsc_mode == 2) then + __wps_ap_pbc_start_all(ifname) + else + http.write_json("{\"wps_start\":\"NG\"}") + return + end + cfgs["WscStartIF"] = ifname + + -- execute wps_action.lua file to send signal for current interface + os.execute("lua wps_action.lua "..ifname) + + http.write_json("{\"wps_start\":\"OK\"}") +end + +function get_wps_security(ifname, devname) + local devs = mtkwifi.get_all_devs() + local ssid_index = devs[devname]["vifs"][ifname].vifidx + local profile = devs[devname].profile + assert(profile) + local output = {} + local cfgs = mtkwifi.load_profile(profile) + + output["AuthMode"] = mtkwifi.token_get(cfgs.AuthMode,ssid_index) + output["IEEE8021X"] = mtkwifi.token_get(cfgs.IEEE8021X,ssid_index) + + http.write_json(output) +end + +function apcli_get_wps_status(ifname, devname) + local output = {} + local ssid_index = 0 + local devs = mtkwifi.get_all_devs() + local profile = devs[devname].profile + assert(profile) + + -- apcli interface has a different structure as compared to other vifs + ssid_index = devs[devname][ifname].vifidx + output = c_apcli_get_wps_status(ifname) + if (output.wps_port_secured == "YES") then + local cfgs = mtkwifi.load_profile(profile) + cfgs.ApCliSsid = mtkwifi.token_set(cfgs.ApCliSsid, ssid_index, output.enr_SSID) + cfgs.ApCliEnable = mtkwifi.token_set(cfgs.ApCliEnable, ssid_index, "1") + cfgs.ApCliAuthMode = mtkwifi.token_set(cfgs.ApCliAuthMode, ssid_index, output.enr_AuthMode) + cfgs.ApCliEncrypType = mtkwifi.token_set(cfgs.ApCliEncrypType, ssid_index, output.enr_EncrypType) + cfgs.ApCliDefaultKeyID = mtkwifi.token_set(cfgs.ApCliDefaultKeyID, ssid_index, output.enr_DefaultKeyID) + + if(output.enr_EncrypType == "WEP") then + for i = 1, 4 do + cfgs["ApCliKey"..i.."Type"] = mtkwifi.token_set(cfgs["ApCliKey"..i.."Type"], ssid_index, output["Key"..i.."Type"]) + end + if(ssid_index == "0") then + cfgs["ApCliKey"..output.enr_DefaultKeyID.."Str"] = output.enr_KeyStr + else + cfgs["ApCliKey"..output.enr_DefaultKeyID.."Str"..ssid_index] = output.enr_KeyStr + end + elseif(output.enr_EncrypType == "TKIP") or (output.enr_EncrypType == "AES") or (output.enr_EncrypType == "TKIPAES") then + if(output.enr_AuthMode ~= "WPAPSKWPA2PSK") then + if(ssid_index == "0") then + cfgs["ApCliWPAPSK"] = output.enr_WPAPSK + else + cfgs["ApCliKey"..ssid_index] = output.enr_WPAPSK + end + end + end + mtkwifi.save_profile(cfgs, profile) + end + http.write_json(output); +end + +function string.tohex(str) + return (str:gsub('.', function (c) + return string.format('%02X', string.byte(c)) + end)) +end + +function unencode_ssid(raw_ssid) + local c + local output = "" + local convertNext = 0 + for c in raw_ssid:gmatch"." do + if(convertNext == 0) then + if(c == '+') then + output = output..' ' + elseif(c == '%') then + convertNext = 1 + else + output = output..c + end + else + output = output..string.tohex(c) + convertNext = 0 + end + end + return output +end + +function decode_ssid(raw_ssid) + local output = raw_ssid + output = output:gsub("&", "&") + output = output:gsub("<", "<") + output = output:gsub(">", ">") + output = output:gsub(""", "\"") + output = output:gsub("'", "'") + output = output:gsub(" ", " ") + for codenum in raw_ssid:gmatch("&#(%d+);") do + output = output:gsub("&#"..codenum..";", string.char(tonumber(codenum))) + end + return output +end + +function apcli_do_enr_pin_wps(ifname, devname, raw_ssid) + local target_ap_ssid = "" + local ret_value = {} + if(raw_ssid == "") then + ret_value["apcli_do_enr_pin_wps"] = "GET_SSID_NG" + end + ret_value["raw_ssid"] = raw_ssid + target_ap_ssid = decode_ssid(raw_ssid) + target_ap_ssid = ''..mtkwifi.__handleSpecialChars(target_ap_ssid) + ret_value["target_ap_ssid"] = target_ap_ssid + if(target_ap_ssid == "") then + ret_value["apcli_do_enr_pin_wps"] = "GET_SSID_NG" + else + ret_value["apcli_do_enr_pin_wps"] = "OK" + end + --os.execute("iwpriv "..ifname.." set ApCliAutoConnect=1") + --os.execute("iwpriv "..ifname.." set ApCliEnable=1") + --debug_write("iwpriv "..ifname.." set ApCliEnable=1") + --os.execute("ifconfig "..ifname.." up") + --debug_write("ifconfig "..ifname.." up") + --os.execute("brctl addif br0 "..ifname) + --debug_write("brctl addif br0 "..ifname) + --os.execute("iwpriv "..ifname.." set WscConfMode=0") + os.execute("iwpriv "..ifname.." set WscConfMode=1") + debug_write("iwpriv "..ifname.." set WscConfMode=1") + os.execute("iwpriv "..ifname.." set WscMode=1") + debug_write("iwpriv "..ifname.." set WscMode=1") + os.execute("iwpriv "..ifname.." set ApCliWscSsid=\""..target_ap_ssid.."\"") + debug_write("iwpriv "..ifname.." set ApCliWscSsid=\""..target_ap_ssid.."\"") + os.execute("iwpriv "..ifname.." set WscGetConf=1") + debug_write("iwpriv "..ifname.." set WscGetConf=1") + -- check interface value to correlate with nvram as values will be like apclixxx + os.execute("wps_action.lua "..ifname) + http.write_json(ret_value) +end + +function apcli_do_enr_pbc_wps(ifname, devname) + local ret_value = {} + + --os.execute("iwpriv "..ifname.." set ApCliAutoConnect=1") + --os.execute("iwpriv "..ifname.." set ApCliEnable=1") + --os.execute("ifconfig "..ifname.." up") + --os.execute("brctl addif br0 "..ifname) + --os.execute("iwpriv "..ifname.." set WscConfMode=0") + os.execute("iwpriv "..ifname.." set WscConfMode=1") + os.execute("iwpriv "..ifname.." set WscMode=2") + os.execute("iwpriv "..ifname.." set WscGetConf=1") + -- check interface value to correlate with nvram as values will be like apclixxx + os.execute("wps_action.lua "..ifname) + + --debug_write("iwpriv "..ifname.." set ApCliEnable=1") + --debug_write("brctl addif br0 "..ifname) + --debug_write("ifconfig "..ifname.." up") + debug_write("iwpriv "..ifname.." set WscConfMode=1") + debug_write("iwpriv "..ifname.." set WscMode=2") + debug_write("iwpriv "..ifname.." set WscGetConf=1") + ret_value["apcli_do_enr_pbc_wps"] = "OK" + http.write_json(ret_value) +end + +function apcli_cancel_wps(ifname) + local ret_value = {} + os.execute("iwpriv "..ifname.." set WscStop=1") + os.execute("miniupnpd.sh init") + -- check interface value to correlate with nvram as values will be like apclixxx + os.execute("wps_action.lua "..ifname) + ret_value["apcli_cancel_wps"] = "OK" + http.write_json(ret_value) +end + +function apcli_wps_gen_pincode(ifname) + local ret_value = {} + os.execute("iwpriv "..ifname.." set WscGenPinCode") + ret_value["apcli_wps_gen_pincode"] = "OK" + http.write_json(ret_value) +end + +function apcli_wps_get_pincode(ifname) + local output = c_apcli_wps_get_pincode(ifname) + http.write_json(output) +end + +function apcli_scan(ifname) + local aplist = mtkwifi.scan_ap(ifname) + local convert=""; + for i=1, #aplist do + convert = c_convert_string_display(aplist[i]["ssid"]) + aplist[i]["original_ssid"] = aplist[i]["ssid"] + aplist[i]["ssid"] = convert["output"] + end + http.write_json(aplist) +end + +function get_station_list() + http.write("get_station_list") +end + +function reset_wifi(devname) + if devname then + os.execute("cp -f /rom/etc/wireless/"..devname.."/ /etc/wireless/") + else + os.execute("cp -rf /rom/etc/wireless /etc/") + end + return luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function reload_wifi(devname) + os.execute("mkdir -p /tmp/mtk") + os.execute("/sbin/mtkwifi reload "..(devname or "").." >> /tmp/mtk/wifi.log 2>&1") + return luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function get_raw_profile() + local sid = http.formvalue("sid") + http.write_json("get_raw_profile") +end + +function get_country_region_list() + local mode = http.formvalue("mode") + local cr_list; + + if mtkwifi.band(mode) == "5G" then + cr_list = mtkwifi.CountryRegionList_5G_All + else + cr_list = mtkwifi.CountryRegionList_2G_All + end + + http.write_json(cr_list) +end + +function remove_ch_by_region(ch_list, region) + for i = #ch_list,2,-1 do + if not ch_list[i].region[region] then + table.remove(ch_list, i) + end + end +end + +function get_channel_list() + local mode = http.formvalue("mode") + local region = tonumber(http.formvalue("country_region")) or 1 + local ch_list + + if mtkwifi.band(mode) == "5G" then + ch_list = mtkwifi.ChannelList_5G_All + else + ch_list = mtkwifi.ChannelList_2G_All + end + + remove_ch_by_region(ch_list, region) + http.write_json(ch_list) +end + +function get_HT_ext_channel_list() + local ch_cur = tonumber(http.formvalue("ch_cur")) + local region = tonumber(http.formvalue("country_region")) or 1 + local ext_ch_list = {} + + if ch_cur <= 14 then -- 2.4G Channel + local ch_list = mtkwifi.ChannelList_2G_All + local below_ch = ch_cur - 4 + local above_ch = ch_cur + 4 + local i = 1 + + if below_ch > 0 and ch_list[below_ch + 1].region[region] then + ext_ch_list[i] = {} + ext_ch_list[i].val = 0 + ext_ch_list[i].text = ch_list[below_ch + 1].text + i = i + 1 + end + + if above_ch <= 14 and ch_list[above_ch + 1].region[region] then + ext_ch_list[i] = {} + ext_ch_list[i].val = 1 + ext_ch_list[i].text = ch_list[above_ch + 1].text + end + else -- 5G Channel + local ch_list = mtkwifi.ChannelList_5G_All + local ext_ch_idx = -1 + local len = 0 + + for k, v in ipairs(ch_list) do + len = len + 1 + if v.channel == ch_cur then + ext_ch_idx = (k % 2 == 0) and k + 1 or k - 1 + end + end + + if ext_ch_idx > 0 and ext_ch_idx < len and ch_list[ext_ch_idx].region[region] then + ext_ch_list[1] = {} + ext_ch_list[1].val = ext_ch_idx % 2 + ext_ch_list[1].text = ch_list[ext_ch_idx].text + end + end + + http.write_json(ext_ch_list) +end + +function get_5G_2nd_80Mhz_channel_list() + local ch_cur = tonumber(http.formvalue("ch_cur")) + local region = tonumber(http.formvalue("country_region")) + local ch_list = mtkwifi.ChannelList_5G_2nd_80MHZ_ALL + local ch_list_5g = mtkwifi.ChannelList_5G_All + local i, j, test_ch, test_idx + local bw80_1st_idx = -1 + + -- remove adjacent freqencies starting from list tail. + for i = #ch_list,1,-1 do + for j = 0,3 do + if ch_list[i].channel == -1 then + break + end + + test_ch = ch_list[i].channel + j * 4 + test_idx = ch_list[i].chidx + j + + if test_ch == ch_cur then + if i + 1 <= #ch_list and ch_list[i + 1] then + table.remove(ch_list, i + 1) + end + table.remove(ch_list, i) + bw80_1st_idx = i + break + end + + if i == (bw80_1st_idx - 1) or (not ch_list_5g[test_idx].region[region]) then + table.remove(ch_list, i) + break + end + end + end + + -- remove unused channel. + for i = #ch_list,1,-1 do + if ch_list[i].channel == -1 then + table.remove(ch_list, i) + end + end + http.write_json(ch_list) +end + +function apcli_cfg(dev, vif) + local devname = dev + debug_write(devname) + local profiles = mtkwifi.search_dev_and_profile() + debug_write(profiles[devname]) + assert(profiles[devname]) + + local cfgs = mtkwifi.load_profile(profiles[devname]) + + for k,v in pairs(http.formvalue()) do + if type(v) ~= type("") and type(v) ~= type(0) then + nixio.syslog("err", "apcli_cfg, invalid value type for "..k..","..type(v)) + elseif string.byte(k) ~= string.byte("_") then + cfgs[k] = v or "" + end + end + + cfgs.ApCliSsid = ''..mtkwifi.__handleSpecialChars(http.formvalue("ApCliSsid")) + local __authmode = http.formvalue("ApCliAuthMode") + if __authmode == "Disable" then + cfgs.ApCliAuthMode = "OPEN" + cfgs.ApCliEncrypType = "NONE" + elseif __authmode == "OPEN" or __authmode == "SHARED" then + cfgs.ApCliAuthMode = __authmode + cfgs.ApCliEncrypType = http.formvalue("wep_ApCliEncrypType") + else + cfgs.ApCliAuthMode = __authmode + cfgs.ApCliEncrypType = http.formvalue("wpa_ApCliEncrypType") + end + + mtkwifi.save_profile(cfgs, profiles[devname]) + + if http.formvalue("__apply") then + os.execute("/sbin/mtkwifi reload "..devname) + os.execute("rm -f /tmp/mtk/wifi/"..devname..".need_reload") + else + os.execute("touch /tmp/mtk/wifi/"..devname..".need_reload") + end + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi", "apcli_cfg_view", dev, vif)) +end + +function apcli_connect(dev, vif) + -- dev_vif can be + -- 1. mt7620.apcli0 # simple case + -- 2. mt7615e.1.apclix0 # multi-card + -- 3. mt7615e.1.2G.apclix0 # multi-card & multi-profile + local devname,vifname = dev, vif + debug_write("devname=", dev, "vifname=", vif) + debug_write(devname) + debug_write(vifname) + local profiles = mtkwifi.search_dev_and_profile() + debug_write(profiles[devname]) + assert(profiles[devname]) + + local cfgs = mtkwifi.load_profile(profiles[devname]) + cfgs.ApCliEnable = "1" + mtkwifi.save_profile(cfgs, profiles[devname]) + + os.execute("ifconfig "..vifname.." up") + local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname")) + if not string.match(brvifs, vifname) then + brvifs = brvifs.." "..vifname + nixio.syslog("debug", "add "..vifname.." into lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vifname.."\\\"}\"") + end + + os.execute("iwpriv "..vifname.." set MACRepeaterEn="..cfgs.MACRepeaterEn) + os.execute("iwpriv "..vifname.." set ApCliEnable=0") + os.execute("iwpriv "..vifname.." set Channel="..cfgs.Channel) + os.execute("iwpriv "..vifname.." set ApCliAuthMode="..cfgs.ApCliAuthMode) + os.execute("iwpriv "..vifname.." set ApCliEncrypType="..cfgs.ApCliEncrypType) + if cfgs.ApCliAuthMode == "WEP" then + os.execute("#iwpriv "..vifname.." set ApCliDefaultKeyID="..cfgs.ApCliDefaultKeyID) + os.execute("#iwpriv "..vifname.." set ApCliKey1="..cfgs.ApCliKey1Str) + elseif cfgs.ApCliAuthMode == "WPAPSK" + or cfgs.ApCliAuthMode == "WPA2PSK" + or cfgs.ApCliAuthMode == "WPA1PSKWPA2PSK" then + os.execute("iwpriv "..vifname.." set ApCliWPAPSK="..cfgs.ApCliWPAPSK) + end + os.execute("iwpriv "..vifname.." set ApCliSsid=\""..cfgs.ApCliSsid.."\"") + os.execute("iwpriv "..vifname.." set ApCliEnable=1") + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + +function apcli_disconnect(dev, vif) + -- dev_vif can be + -- 1. mt7620.apcli0 # simple case + -- 2. mt7615e.1.apclix0 # multi-card + -- 3. mt7615e.1.2G.apclix0 # multi-card & multi-profile + local devname,vifname = dev, vif + debug_write("devname=", dev, "vifname", vif) + debug_write(devname) + debug_write(vifname) + local profiles = mtkwifi.search_dev_and_profile() + debug_write(profiles[devname]) + assert(profiles[devname]) + + local cfgs = mtkwifi.load_profile(profiles[devname]) + cfgs.ApCliEnable = "1" + mtkwifi.save_profile(cfgs, profiles[devname]) + + os.execute("iwpriv "..vifname.." set ApCliEnable=0") + + local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname")) + if string.match(brvifs, vifname) then + brvifs = mtkwifi.__trim(string.gsub(brvifs, vifname, "")) + nixio.syslog("debug", "add "..vifname.." into lan") + os.execute("uci set network.lan.ifname=\""..brvifs.."\"") + os.execute("uci commit") + os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vifname.."\\\"}\"") + end + os.execute("ifconfig "..vifname.." down") + + luci.http.redirect(luci.dispatcher.build_url("admin", "mtk", "wifi")) +end + diff --git a/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm new file mode 100755 index 0000000..ecee7a2 --- /dev/null +++ b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm @@ -0,0 +1,461 @@ + +<%+header%> + +<% +local disp = require "luci.dispatcher" +-- local request = disp.context.path +local request = disp.context.request +local mtkwifi = require("mtkwifi") +--local devname = string.match(request[5], "(mt.+)%.") +local devname = request[5] +local devs = mtkwifi.get_all_devs() +local dev = {} +local vif = {} +local vifidx +for _,v in ipairs(devs) do + if v.devname == devname then + dev = v + end +end + +local vifname = request[6] or dev.apcli.vifname +assert(vifname) +vif = dev and dev.vifs[vifname] or nil +vifidx = vif and vif.vifidx or nil +--print(devs, dev, dev.apcli, devname, vifname) + +local cfgs = mtkwifi.load_profile(dev.profile) +local debug = 0 +%> + + + + + +
" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="off"> + +
+ Wireless Repeater - <%=devname.."@"..vifname%> +
Help:
+        iwpriv <%=vifname%> set ApCliEnable=0              // disable sta mode first
+        iwpriv <%=vifname%> set ApCliAuthMode=             // root ap authentication mode
+        iwpriv <%=vifname%> set ApCliEncrypType=           // root ap encryption type
+        iwpriv <%=vifname%> set ApCliWPAPSK=               // root ap password
+        iwpriv <%=vifname%> set ApCliWirelessMode=         // root ap wifi mode
+        iwpriv <%=vifname%> set ApCliSsid=                 // root ap ssid
+        iwpriv <%=vifname%> set ApCliEnable=1              // enable sta mode
+
+

+ +

+ +
+ +
+
+
+ Connection Configurations + + + + + + + + + + + + + + + + + + + + + + + + + style="display: none;"<% end %>> + + + + + + + + + + + + style="display: none;"<% end %>> + + + + + + + + + + + +
MAC Repeater Mode + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Root AP SSID + +
Root AP Channel + + This will overwrite ap channel.
Root AP Authentication Mode + +
Root AP Encryption + +
Root AP WPA Key + +
Root AP Encryption + +
Root AP WEP Key + + +
+
+ +
+ + + +
+
+ + + +<%+footer%> diff --git a/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_dev_cfg.htm b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_dev_cfg.htm new file mode 100755 index 0000000..9b28df2 --- /dev/null +++ b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_dev_cfg.htm @@ -0,0 +1,851 @@ + +<%+header%> + + +<% +local disp = require "luci.dispatcher" +-- local request = disp.context.path +local request = disp.context.request +local mtkwifi = require("mtkwifi") +local devname = request[5] +local devs = mtkwifi.get_all_devs() +local dev = {} +for _,v in ipairs(devs) do + if v.devname == devname then + dev = v + end +end + +local cfgs = mtkwifi.load_profile(dev.profile) + +%> + + + + + + +
" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="false"> +
+ Device Configurations - <%=devname%> +<% +local fd = io.open("/tmp/mtk/wifi/"..dev.devname..".need_reload","r") +if fd then +%> + ('">reload to apply changes) +<% +fd:close() +end +%> + + + + + + + + + + + + + + + + + + + + + + + + <% if cfgs.HT_OpMode then %> + + + + + + <% end %> + <% if cfgs.HT_GI then %> + + + + + + <% end %> + + + + + + <% if cfgs.VHT_BW then %> + + + + + + + + + + + <% end %> + <% if cfgs.HT_STBC then %> + + + + + + <% end %> + <% if cfgs.HT_AMSDU then %> + + + + + + <% end %> + <% if cfgs.HT_AutoBA then %> + + + + + + <% end %> + <% if cfgs.HT_BADecline then %> + + + + + + <% end %> + <% if cfgs.HT_DisallowTKIP then %> + + + + + + <% end %> + <% if cfgs.HT_LDPC then %> + + + + + + <% end %> + <% if cfgs.VHT_SGI then %> + + + + + + <% end %> + <% if cfgs.VHT_STBC then %> + + + + + + <% end %> + <% if cfgs.VHT_BW_SIGNAL then %> + + + + + + <% end %> + <% if cfgs.VHT_LDPC then %> + + + + + + <% end %> + <% if cfgs.BGProtection then %> + + + + + + <% end %> + <% if cfgs.VHT_BW then %> + + + + + + <% end %> + <% if cfgs.BeaconPeriod then %> + + + + + + <% end %> + <% if cfgs.DtimPeriod then %> + + + + + + <% end %> + <% if cfgs.FragThreshold then %> + + + + + + <% end %> + <% if cfgs.RTSThreshold then %> + + + + + + <% end %> + <% if cfgs.TxPower then %> + + + + + + <% end %> + <% if cfgs.TxPreamble then %> + + + + + + <% end %> + <% if cfgs.ShortSlot then %> + + + + + + <% end %> + <% if cfgs.TxBurst then %> + + + + + + <% end %> + <% if cfgs.PktAggregate then %> + + + + + + <% end %> + <% if cfgs.IEEE80211H then %> + + + + + + <% end %> +
Mode + +
Channel + + <% if cfgs.ApCliEnable == "1" then %> APClient/Repeater Mode. <% end %>
Country Code + +
Country Region + +
Operating Mode + +
HT Guard Interval + +
Channel BandWidth + +
2G 40Mhz Ext Channel + + <% if cfgs.ApCliEnable == "1" then %> APClient/Repeater Mode. <% end %>
5G 2nd 80Mhz Channel + + <% if cfgs.ApCliEnable == "1" then %> APClient/Repeater Mode. <% end %>
STBC + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
A-MSDU + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Auto Block ACK + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Decline BA Request + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
HT Disallow TKIP + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
HT LDPC + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
VHT Short GI + +
VHT STBC + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
VHT BW Signaling + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable + checked="checked"<% end %>/> Dynamic +
VHT LDPC + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
BG Protection Mode + +
HT Protection + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Beacon Interval + ms(range 20-999, default 100) +
Data Beacon Rate (DTIM) + ms(range 1-255, default 1) +
Fragment Threshold + (range 256-2346, default 2346) +
RTS Threshold + (range 256-2347, default 2347) +
TX Power + dbm(range 1-100, default 100) +
Short Preamble + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Short Slot + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
TX Burst + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
Packet Aggregate + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
802.11H + checked="checked"<% end %>/> Enable + checked="checked"<% end %>/> Disable +
+ + +
+
+ + + +
+
+ + +
" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="off"> +
+ Raw Configurations ( Edit WiFi profile directly ) +

WARNING : DO NOT MESS WITH IT IF YOU DON'T UNDERSTAND IT!

+ +
+
+ '" type="button"> + + '"> +
+
+ + + + +<%+footer%> diff --git a/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_overview.htm b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_overview.htm new file mode 100755 index 0000000..fbac9f5 --- /dev/null +++ b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_overview.htm @@ -0,0 +1,174 @@ +<%+header%> + +<% +local mtkwifi = require("mtkwifi") +local devs = mtkwifi.get_all_devs() +%> +

Wireless Overview

+ + + + <% if #devs == 0 then %> +
+ No wireless device found. +
+ <% end %> + + + + + <% for _,dev in ipairs(devs) do %> +
+ + + + + + + + + + + <% for _,vif in ipairs(dev.vifs) do %> + + + + + + + <% end %> + + + <% if dev.apcli then %> + + + + + + + <% end %> + + +
+ + + <%=dev.devname%> + <% + local fd = io.open("/tmp/mtk/wifi/"..dev.devname..".need_reload","r") + if fd then + %> + * need reload to apply changes + <% + fd:close() + end + %> +
+ work mode: <% if dev.ApCliEnable == "1" then %> APCli <% else %> AP<% end %> +
+ + '"> + '"> +
+ <% if vif.state == "up" then %> + + <% else %> + + <% end %> + Interface: <%=vif.vifname%> | Type: AP | SSID: <%=vif.__ssid%> | Channel: <%=vif.__channel or dev.Channel%> +
+ <% if vif.state == "up" then %> + BSSID::<%=vif.__bssid%> | Mode: <%=dev.WirelessModeList[tonumber(vif.__wirelessmode or dev.WirelessMode)]%> + <% else %> + Wireless is disabled or not associated + <% end %> +
+ <% if not vif.state then %> + + <% elseif vif.state == "up" then %> + '"> + <% else %> + '"> + <% end %> + '"> + '"> +
+ <% if dev.apcli.state == "up" then %> + + <% else %> + + <% end %> + Interface: <%=dev.apcli.devname%> | Type: STA | Status: <%=dev.apcli.status%> +
+ <% if dev.apcli.status == "Connected" then %> + BSSID::<%=dev.apcli.bssid%> | + SSID::<%=dev.apcli.ssid%> + <% else %> + Wireless is disabled or not associated + <% end %> +
+ <% if dev.apcli.state == "up" then %> + '"> + <% else %> + '"> + <% end %> + + <% if dev.apcli.status == "Connected" then %> + + <% else %> + + <% end %> + + '"> +
+
+ <% end %> + + + <%+footer%> + + \ No newline at end of file diff --git a/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm new file mode 100755 index 0000000..ce30d19 --- /dev/null +++ b/mtk-luci-plugin/luci-app-mtkwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm @@ -0,0 +1,602 @@ + +<%+header%> + +<% +function any_wsc_enabled(wsc_conf_mode) + if (wsc_conf_mode == "7") then + return 1; + end + if (wsc_conf_mode == "4") then + return 1; + end + if (wsc_conf_mode == "2") then + return 1; + end + if (wsc_conf_mode == "1") then + return 1; + end + return 0; +end + +local disp = require "luci.dispatcher" +local path = disp.context.path +local request = disp.context.request +local mtkwifi = require("mtkwifi") +local devname +local vifname, vifidx +local dev = {} +local vif = {} + +if request[4] == "vif_add_view" then + devname, vifname = request[5], request[6] + local devs = mtkwifi.get_all_devs() + dev = devs and devs[devname] + vifname = vifname..#dev.vifs + vifidx = #dev.vifs + 1 + +elseif request[4] == "vif_cfg_view" then + devname, vifname = request[5], request[6] + local devs = mtkwifi.get_all_devs() + dev = devs and devs[devname] or nil + vif = dev and dev.vifs[vifname] or nil + vifidx = vif and vif.vifidx or nil +end + +local cfgs = mtkwifi.load_profile(dev.profile) +local WscValue = mtkwifi.token_get(cfgs["WscConfMode"], vifidx, "0") or "0" +%> + + + + + +
" enctype="multipart/form-data" onsubmit="return validate_security(<%=vifidx%>,<%=cfgs["HT_DisallowTKIP"]%>)" autocomplete="off"> +<% if not dev or not vif then%> +
+ Interface Not Exist - <%=vifname and devname.."@"..vifname or devname%> + +
+<% else %> +
+ Interface Configurations - <%=vifname and devname.."@"..vifname or devname%> +<% +local fd = io.open("/tmp/mtk/wifi/"..dev.devname..".need_reload","r") +if fd then +%> +('">reload to apply changes) +<% +fd:close() +end +%> + + + + + + + + <% if dev.DBDC_MODE == "0" then %> + + + + + <% end %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SSID + " required > + +
Channel + +
Auth Mode + +
Hidden + + checked="checked" + <% end %> type="checkbox"> +
AP Isolation + + checked="checked" + <% end %> type="checkbox"> +
WMM Capable + + checked="checked" + <% end %> type="checkbox"> +
TX Rate + +
+ +
+# 1. one MAC one line.
+# 2. empty lines will be ignored.
+# 3. lines start with "#" will be ignored.
+# 4. invalid MAC will be ignored.
+
+11:22:33:44:55:66
+AA:BB:CC:DD:EE:FF
+11:22:33:aa:bb:cc
+ + +
+ +
+ + + +
+<% end %> +
+ +<%+footer%> diff --git a/mtk-luci-plugin/luci-app-mtkwifi/root/sbin/mtkwifi b/mtk-luci-plugin/luci-app-mtkwifi/root/sbin/mtkwifi new file mode 100755 index 0000000..a954165 --- /dev/null +++ b/mtk-luci-plugin/luci-app-mtkwifi/root/sbin/mtkwifi @@ -0,0 +1,199 @@ +#!/usr/bin/env lua +-- Alternative for OpenWrt's /sbin/wifi. +-- Copyright Not Reserved. +-- Hua Shao + +package.path = '/lib/wifi/?.lua;'..package.path + +local mtkwifi = require("mtkwifi") +local nixio = require("nixio") + +function usage() + print("wifi [devname]") +end + + +function wifi_common_up(devname) + nixio.syslog("debug", "wifi_common_up "..tostring(devname)) + + -- need to find out the vif prefix for this device + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "ra%a-%d+") then + os.execute("ifconfig "..vif.." up") + end + end + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%a-%d+") then + os.execute("ifconfig "..vif.." up") + end + end + + if devname then + os.execute("rm -f /tmp/mtk/wifi/"..devname.."*.need_reload") + else + os.execute("rm -f /tmp/mtk/wifi/*.need_reload") + end +end + + +function wifi_common_down(devname) + nixio.syslog("debug", "wifi_common_down "..tostring(devname)) + + -- need to find out the vif prefix for this device + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) + do + if string.match(vif, "apcli%d+") + or string.match(vif, "apclii%d+") then + os.execute("ifconfig "..vif.." down") + end + end + for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), " ")) + do + if string.match(vif, "ra%d+") + or string.match(vif, "rai%d+") + or string.match(vif, "rae%d+") + or string.match(vif, "rax%d+") then + os.execute("ifconfig "..vif.." down") + end + end +end + +function wifi_common_reload(devname) + nixio.syslog("debug", "wifi_common_reload "..tostring(devname)) + wifi_common_up() + wifi_common_down() +end + +function wifi_common_reset(devname) + nixio.syslog("debug", "wifi_common_reset called!") + local curpath = "/etc/wireless/" + if devname then + curpath = curpath..devname.."/" + end + local defpath = "/rom"..defpath + if mtkwifi.exists(defpath) then + os.execute("rm -rf "..curpath) + os.execute("cp -rf "..defpath.." "..curpath) + wifi_common_reload() + else + nixio.syslog("debug", defpath.." missing, unable to reset!") + end +end + +function wifi_common_status(devname) + nixio.syslog("debug", "wifi_common_status "..tostring(devname)) + print(mtkwifi.read_pipe("iwconfig")) + print(mtkwifi.read_pipe("ifconfig -a")) +end + +function wifi_common_detect(devname) + nixio.syslog("debug", "wifi_common_detect "..tostring(devname)) + local devs = mtkwifi.getdevs() + for _,dev in ipairs(devs) do + print("config wifi-device "..dev.devname.. + "\n\toption type "..dev.devname.. + "\n\toption vendor ralink".. + "\n\toption channel "..dev.Channel) + for _,vif in ipairs(dev.vifs) do + print("\nconfig wifi-iface".. + "\n\toption device"..dev.devname.. + "\n\toption ifname"..vif.vifname.. + "\n\toption network lan".. + "\n\toption mode ap") + end + end +end + +for _,f in ipairs(string.split(mtkwifi.read_pipe("find /lib/wifi/ -name \"*.lua\" 2>/dev/null"), "\n")) do + dofile(f) +end + +function wifi(cmd, devname) + local mtkwifi = require("mtkwifi") + local devs, l1parser = mtkwifi.__get_l1dat() + if not devs or not l1parser then + return wifi_orig(cmd, devname) + end + + if devname then + local dev = devs.devname_ridx[devname] + assert(mtkwifi.exists(dev.init_script)) + local compatname = dev.init_compatible + assert(compatname) + + if _G[compatname.."_"..cmd] then + nixio.syslog("info", "call "..compatname.."_"..cmd.."("..devname..")") + _G[compatname.."_"..cmd](devname) + end + return + end + + -- if devname not not specified + for devname, dev in pairs(devs.devname_ridx) do + local compatname = dev.init_compatible + nixio.syslog("info", "call "..compatname.."_"..cmd.."("..devname..")") + _G[compatname.."_"..cmd](devname) + end +end + +function wifi_orig(cmd,devname) + local relname = nil + if devname then + relname = string.split(devname,".")[1] + end + + if relname then + if _G[relname.."_"..cmd] then + nixio.syslog("info", "call "..relname.."_"..cmd.."("..devname..")") + _G[relname.."_"..cmd](devname) + end + else + local devinfo = mtkwifi.search_dev_and_profile() + local done = {} + for __devname in pairs(devinfo) do + local __relname = string.split(__devname,".")[1] + repeat + -- common case + if done[__relname] then break else done[__relname] = true end + if _G[__relname.."_"..cmd] then + nixio.syslog("info", "call "..__relname.."_"..cmd.."("..__devname..")") + _G[__relname.."_"..cmd](__devname) + break + end + -- try shell + local dev_shell = "/lib/wifi/"..__relname..".sh" + if mtkwifi.exists(dev_shell) then + local cmd = "source "..dev_shell.."; "..__relname.."_"..cmd.." > /dev/null" + nixio.syslog("info", cmd) + if os.execute(cmd) ~= 0 then + nixio.syslog("err", cmd) + end + break + end + -- fall back on common api + nixio.syslog("info", "no scripts for "..__relname.." found, fall back on common api!") + _G["wifi_common_"..cmd](__devname) + until true + end + end +end + +cmd = arg[1] +dev = arg[2] + +if cmd == "up" +or cmd == "down" +or cmd == "status" +or cmd == "detect" +or cmd == "reload" +or cmd == "reset" then + wifi(cmd, dev) +elseif cmd == "reload_legacy" then + nixio.syslog("info", "legacy command "..cmd) + wifi("up", dev) +else + usage() +end + diff --git a/mtk-luci-plugin/luci-app-mtkwifi/root/usr/lib/lua/mtkwifi.lua b/mtk-luci-plugin/luci-app-mtkwifi/root/usr/lib/lua/mtkwifi.lua new file mode 100755 index 0000000..6d1947d --- /dev/null +++ b/mtk-luci-plugin/luci-app-mtkwifi/root/usr/lib/lua/mtkwifi.lua @@ -0,0 +1,959 @@ +#!/usr/bin/env lua + +--[[ + * A lua library to manipulate mtk's wifi driver. used in luci-app-mtk. + * + * Hua Shao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. +]] + +local mtkwifi = {} + +function debug_write(...) + -- luci.http.write(...) + local ff = io.open("/tmp/mtkwifi", "a") + local vars = {...} + for _, v in pairs(vars) do + ff:write(v.." ") + end + ff:write("\n") + ff:close() + nixio.syslog("debug", ...) +end + +function string:split(sep) + local sep, fields = sep or ":", {} + local pattern = string.format("([^%s]+)", sep) + self:gsub(pattern, function(c) fields[#fields+1] = c end) + return fields +end + +function mtkwifi.__trim(s) + if s then return (s:gsub("^%s*(.-)%s*$", "%1")) end +end + +function mtkwifi.__handleSpecialChars(s) + s = s:gsub("\\", "\\\\") + s = s:gsub("\"", "\\\"") + s = mtkwifi.__trim(s) + return s +end + +-- if order function given, sort by it by passing the table and keys a, b, +-- otherwise just sort the keys +function mtkwifi.__spairs(t, order) + -- collect the keys + local keys = {} + for k in pairs(t) do keys[#keys+1] = k end + table.sort(keys, order) + -- return the iterator function + local i = 0 + return function() + i = i + 1 + if keys[i] then + return keys[i], t[keys[i]] + end + end +end + +function mtkwifi.__lines(str) + local t = {} + local function helper(line) table.insert(t, line) return "" end + helper((str:gsub("(.-)\r?\n", helper))) + return t +end + +function mtkwifi.__get_l1dat() + if not pcall(require, "l1dat_parser") then + return + end + + local parser = require("l1dat_parser") + local l1dat = parser.load_l1_profile(parser.L1_DAT_PATH) + + return l1dat, parser +end + +function mtkwifi.sleep(s) + local ntime = os.clock() + s + repeat until os.clock() > ntime +end + +function mtkwifi.deepcopy(orig) + local orig_type = type(orig) + local copy + if orig_type == 'table' then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[mtkwifi.deepcopy(orig_key)] = mtkwifi.deepcopy(orig_value) + end + setmetatable(copy, mtkwifi.deepcopy(getmetatable(orig))) + else -- number, string, boolean, etc + copy = orig + end + return copy +end + +function mtkwifi.read_pipe(pipe) + local fp = io.popen(pipe) + local txt = fp:read("*a") + fp:close() + return txt +end + +function mtkwifi.load_profile(path, raw) + local cfgs = {} + local content + + if path then + local fd = io.open(path, "r") + if not fd then return end + content = fd:read("*all") + fd:close() + elseif raw then + content = raw + else + return + end + + -- convert profile into lua table + for _,line in ipairs(mtkwifi.__lines(content)) do + line = mtkwifi.__trim(line) + if string.byte(line) ~= string.byte("#") then + local i = string.find(line, "=") + if i then + local k,v + k = string.sub(line, 1, i-1) + v = string.sub(line, i+1) + if cfgs[mtkwifi.__trim(k)] then + nixio.syslog("warning", "skip repeated key"..line) + end + cfgs[mtkwifi.__trim(k)] = mtkwifi.__trim(v) or "" + else + nixio.syslog("warning", "skip line without '=' "..line) + end + else + nixio.syslog("warning", "skip comment line "..line) + end + end + return cfgs +end + + +function mtkwifi.save_profile(cfgs, path) + + if not cfgs then + debug_write("configuration was empty, nothing saved") + return + end + -- keep a backup for last commit + local bak = string.match(path, "([^/]+).dat") + os.execute("mkdir -p /tmp/mtk/wifi") + os.execute("cp -f "..path.." /tmp/mtk/wifi/"..bak..".last") + + local fd = io.open(path, "w") + table.sort(cfgs, function(a,b) return a/dev/null")) or 0 + vifs[j].state = flags%2 == 1 and "up" or "down" + end + vifs[j].__ssid = cfgs["SSID"..j] + vifs[j].__bssid = mtkwifi.read_pipe("cat /sys/class/net/"..prefix..(j-1).."/address 2>/dev/null") or "?" + if dbdc then + vifs[j].__channel = mtkwifi.token_get(cfgs.Channel, j, 0) + vifs[j].__wirelessmode = mtkwifi.token_get(cfgs.WirelessMode, j, 0) + end + + vifs[j].__authmode = mtkwifi.token_get(cfgs.AuthMode, j, "OPEN") + vifs[j].__encrypttype = mtkwifi.token_get(cfgs.EncrypType, j, "NONE") + vifs[j].__hidessid = mtkwifi.token_get(cfgs.HideSSID, j, 0) + vifs[j].__noforwarding = mtkwifi.token_get(cfgs.NoForwarding, j, 0) + vifs[j].__wmmcapable = mtkwifi.token_get(cfgs.WmmCapable, j, 0) + vifs[j].__txrate = mtkwifi.token_get(cfgs.TxRate, j, 0) + vifs[j].__ieee8021x = mtkwifi.token_get(cfgs.IEEE8021X, j, 0) + vifs[j].__preauth = mtkwifi.token_get(cfgs.PreAuth, j, 0) + vifs[j].__rekeymethod = mtkwifi.token_get(cfgs.RekeyMethod, j, 0) + vifs[j].__rekeyinterval = mtkwifi.token_get(cfgs.RekeyInterval, j, 0) + vifs[j].__pmkcacheperiod = mtkwifi.token_get(cfgs.PMKCachePeriod, j, 0) + vifs[j].__ht_extcha = mtkwifi.token_get(cfgs.HT_EXTCHA, j, 0) + vifs[j].__radius_server = mtkwifi.token_get(cfgs.RADIUS_Server, j, 0) + vifs[j].__radius_port = mtkwifi.token_get(cfgs.RADIUS_Port, j, 0) + vifs[j].__wepkey_id = mtkwifi.token_get(cfgs.DefaultKeyID, j, 0) + vifs[j].__wscconfmode = mtkwifi.token_get(cfgs.WscConfMode, j, 0) + vifs[j].__wepkeys = { + cfgs["Key"..j.."Str1"], + cfgs["Key"..j.."Str2"], + cfgs["Key"..j.."Str3"], + cfgs["Key"..j.."Str4"], + } + vifs[j].__wpapsk = cfgs["WPAPSK"..j] + + -- VoW + vifs[j].__atc_tp = mtkwifi.token_get(cfgs.VOW_Rate_Ctrl_En, j, 0) + vifs[j].__atc_min_tp = mtkwifi.token_get(cfgs.VOW_Group_Min_Rate, j, "") + vifs[j].__atc_max_tp = mtkwifi.token_get(cfgs.VOW_Group_Max_Rate, j, "") + vifs[j].__atc_at = mtkwifi.token_get(cfgs.VOW_Airtime_Ctrl_En, j, 0) + vifs[j].__atc_min_at = mtkwifi.token_get(cfgs.VOW_Group_Min_Ratio, j, "") + vifs[j].__atc_max_at = mtkwifi.token_get(cfgs.VOW_Group_Max_Ratio, j, "") + + -- TODO index by vifname + vifs[vifs[j].vifname] = vifs[j] + end + + return vifs +end + +function mtkwifi.__setup_apcli(cfgs, devname, mainidx, subidx) + local l1dat, l1 = mtkwifi.__get_l1dat() + local dridx = l1dat and l1.DEV_RINDEX + + local apcli = {} + local dev_idx = string.match(devname, "(%w+)") + local apcli_prefix = l1dat and l1dat[dridx][devname].apcli_ifname or + dbdc_apcli_prefix[mainidx][subidx] + + local apcli_name = apcli_prefix.."0" + + if mtkwifi.exists("/sys/class/net/"..apcli_name) then + apcli.vifname = apcli_name + apcli.vifidx = "1" + local iwapcli = mtkwifi.read_pipe("iwconfig "..apcli_name.." | grep ESSID 2>/dev/null") + + local _,_,ssid = string.find(iwapcli, "ESSID:\"(.*)\"") + local flags = tonumber(mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/flags 2>/dev/null")) or 0 + apcli.state = flags%2 == 1 and "up" or "down" + if not ssid or ssid == "" then + apcli.status = "Disconnected" + else + apcli.ssid = ssid + apcli.status = "Connected" + end + apcli.devname = apcli_name + apcli.bssid = mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/address 2>/dev/null") or "?" + local flags = tonumber(mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/flags 2>/dev/null")) or 0 + apcli.ifstatus = flags%2 == 1 and "up" or "" + return apcli + else + return + end +end + +function mtkwifi.get_all_devs() + local nixio = require("nixio") + local devs = {} + local i = 1 -- dev idx + local profiles = mtkwifi.search_dev_and_profile() + local wpa_support = 0 + local wapi_support = 0 + + for devname,profile in pairs(profiles) do + debug_write("debug", "checking "..profile) + + local fd = io.open(profile,"r") + if not fd then + nixio.syslog("debug", "cannot find "..profile) + else + fd:close() + nixio.syslog("debug", "load "..profile) + debug_write("loading profile"..profile) + local cfgs = mtkwifi.load_profile(profile) + if not cfgs then + debug_write("error loading profile"..profile) + nixio.syslog("err", "error loading "..profile) + return + end + devs[i] = {} + devs[i].vifs = {} + devs[i].apcli = {} + devs[i].devname = devname + devs[i].profile = profile + local tmp = "" + tmp = string.split(devname, ".") + devs[i].maindev = tmp[1] + devs[i].mainidx = tonumber(tmp[2]) or 1 + devs[i].subdev = devname + devs[i].subidx = string.match(tmp[3] or "", "(%d+)")=="2" and 2 or 1 + devs[i].devband = tonumber(tmp[3]) + if devs[i].devband then + devs[i].multiprofile = true + devs[i].dbdc = true + end + devs[i].version = mtkwifi.read_pipe("cat /etc/wireless/"..devs[i].maindev.."/version 2>/dev/null") or "unknown" + devs[i].ApCliEnable = cfgs.ApCliEnable + devs[i].WirelessMode = cfgs.WirelessMode + devs[i].WirelessModeList = {} + for key, value in pairs(DevicePropertyMap) do + local found = string.find(string.upper(devname), string.upper(value.device)) + if found then + for k=1,#value.band do + devs[i].WirelessModeList[tonumber(value.band[k])] = WirelessModeList[tonumber(value.band[k])] + end + end + end + devs[i].WscConfMode = cfgs.WscConfMode + devs[i].AuthModeList = AuthModeList + devs[i].WpsEnableAuthModeList = WpsEnableAuthModeList + + if wpa_support == 1 then + table.insert(devs[i].AuthModeList,"WPAPSK") + table.insert(devs[i].AuthModeList,"WPA") + end + + if wapi_support == 1 then + table.insert(devs[i].AuthModeList,"WAIPSK") + table.insert(devs[i].AuthModeList,"WAICERT") + end + devs[i].ApCliAuthModeList = ApCliAuthModeList + devs[i].WPA_Enc_List = WPA_Enc_List + devs[i].WEP_Enc_List = WEP_Enc_List + devs[i].Channel = tonumber(cfgs.Channel) + devs[i].DBDC_MODE = tonumber(cfgs.DBDC_MODE) + devs[i].band = devs[i].devband or mtkwifi.band(cfgs.WirelessMode) + + if cfgs.MUTxRxEnable then + if tonumber(cfgs.ETxBfEnCond)==1 + and tonumber(cfgs.MUTxRxEnable)==0 + and tonumber(cfgs.ITxBfEn)==0 + then devs[i].__mimo = 0 + elseif tonumber(cfgs.ETxBfEnCond)==0 + and tonumber(cfgs.MUTxRxEnable)==0 + and tonumber(cfgs.ITxBfEn)==1 + then devs[i].__mimo = 1 + elseif tonumber(cfgs.ETxBfEnCond)==1 + and tonumber(cfgs.MUTxRxEnable)==0 + and tonumber(cfgs.ITxBfEn)==1 + then devs[i].__mimo = 2 + elseif tonumber(cfgs.ETxBfEnCond)==1 + and tonumber(cfgs.MUTxRxEnable)>0 + and tonumber(cfgs.ITxBfEn)==0 + then devs[i].__mimo = 3 + elseif tonumber(cfgs.ETxBfEnCond)==1 + and tonumber(cfgs.MUTxRxEnable)>0 + and tonumber(cfgs.ITxBfEn)==1 + then devs[i].__mimo = 4 + else devs[i].__mimo = 5 + end + end + + if cfgs.HT_BW == "0" or not cfgs.HT_BW then + devs[i].__bw = "20" + elseif cfgs.HT_BW == "1" and cfgs.VHT_BW == "0" or not cfgs.VHT_BW then + if cfgs.HT_BSSCoexistence == "0" or not cfgs.HT_BSSCoexistence then + devs[i].__bw = "40" + else + devs[i].__bw = "60" -- 20/40 coexist + end + elseif cfgs.HT_BW == "1" and cfgs.VHT_BW == "1" then + devs[i].__bw = "80" + elseif cfgs.HT_BW == "1" and cfgs.VHT_BW == "2" then + devs[i].__bw = "160" + elseif cfgs.HT_BW == "1" and cfgs.VHT_BW == "3" then + devs[i].__bw = "161" + end + + devs[i].vifs = mtkwifi.__setup_vifs(cfgs, devname, devs[i].mainidx, devs[i].subidx) + devs[i].apcli = mtkwifi.__setup_apcli(cfgs, devname, devs[i].mainidx, devs[i].subidx) + + -- Setup reverse indices by devname + devs[devname] = devs[i] + + if devs[i].apcli then + devs[i][devs[i].apcli.devname] = devs[i].apcli + end + + i = i + 1 + end + end + return devs +end + +function mtkwifi.exists(path) + local fp = io.open(path, "rb") + if fp then fp:close() end + return fp ~= nil +end + +function mtkwifi.parse_mac(str) + local macs = {} + local pat = "^[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]$" + + local function ismac(str) + if str:match(pat) then return str end + end + + if not str then return macs end + local t = str:split("\n") + for _,v in pairs(t) do + local mac = ismac(mtkwifi.__trim(v)) + if mac then + table.insert(macs, mac) + end + end + + return macs + -- body +end + + +function mtkwifi.scan_ap(vifname) + os.execute("iwpriv "..vifname.." set SiteSurvey=0") + os.execute("sleep 10") -- depends on your env + local scan_result = mtkwifi.read_pipe("iwpriv "..vifname.." get_site_survey 2>/dev/null") + + local aplist = {} + local xx = {} + for i, line in ipairs(mtkwifi.__lines(scan_result)) do + if #line>40 and string.match(line, " BSSID ") then + xx.Ch = {string.find(line, "Ch "),3} + xx.SSID = {string.find(line, "SSID "),32} + xx.BSSID = {string.find(line, "BSSID "),17} + xx.Security = {string.find(line, "Security "),22} + xx.Signal = {string.find(line, "Sig%a%al"),4} + xx.Mode = {string.find(line, "W-Mode"),5} + xx.ExtCh = {string.find(line, "ExtCH"),6} + xx.WPS = {string.find(line, "WPS"),3} + xx.NT = {string.find(line, "NT"),2} + end + + local tmp = {} + if #line>40 and not string.match(line, " BSSID ") then + tmp = {} + tmp.channel = mtkwifi.__trim(string.sub(line, xx.Ch[1], xx.Ch[1]+xx.Ch[2])) + tmp.ssid = mtkwifi.__trim(string.sub(line, xx.SSID[1], xx.SSID[1]+xx.SSID[2])) + tmp.bssid = string.upper(mtkwifi.__trim(string.sub(line, xx.BSSID[1], xx.BSSID[1]+xx.BSSID[2]))) + tmp.security = mtkwifi.__trim(string.sub(line, xx.Security[1], xx.Security[1]+xx.Security[2])) + tmp.authmode = mtkwifi.__trim(string.split(tmp.security, "/")[1]) + tmp.encrypttype = mtkwifi.__trim(string.split(tmp.security, "/")[2] or "NONE") + tmp.rssi = mtkwifi.__trim(string.sub(line, xx.Signal[1], xx.Signal[1]+xx.Signal[2])) + tmp.extch = mtkwifi.__trim(string.sub(line, xx.ExtCh[1], xx.ExtCh[1]+xx.ExtCh[2])) + tmp.mode = mtkwifi.__trim(string.sub(line, xx.Mode[1], xx.Mode[1]+xx.Mode[2])) + tmp.wps = mtkwifi.__trim(string.sub(line, xx.WPS[1], xx.WPS[1]+xx.WPS[2])) + tmp.nt = mtkwifi.__trim(string.sub(line, xx.NT[1], xx.NT[1]+xx.NT[2])) + table.insert(aplist, tmp) + end + end + + return aplist +end + +function mtkwifi.__any_wsc_enabled(wsc_conf_mode) + if (wsc_conf_mode == "") then + return 0; + end + if (wsc_conf_mode == "7") then + return 1; + end + if (wsc_conf_mode == "4") then + return 1; + end + if (wsc_conf_mode == "2") then + return 1; + end + if (wsc_conf_mode == "1") then + return 1; + end + return 0; +end + +function mtkwifi.__restart_if_wps(devname, ifname, cfgs) + local devs = mtkwifi.get_all_devs() + local ssid_index = devs[devname]["vifs"][ifname].vifidx + local wsc_conf_mode = "" + + wsc_conf_mode=mtkwifi.token_get(cfgs["WscConfMode"], ssid_index, "") + + os.execute("iwpriv "..ifname.." set WscConfMode=0") + debug_write("iwpriv "..ifname.." set WscConfMode=0") + os.execute("route delete 239.255.255.250") + debug_write("route delete 239.255.255.250") + if(mtkwifi.__any_wsc_enabled(wsc_conf_mode)) then + os.execute("iwpriv "..ifname.." set WscConfMode=7") + debug_write("iwpriv "..ifname.." set WscConfMode=7") + os.execute("route add -host 239.255.255.250 dev br0") + debug_write("route add -host 239.255.255.250 dev br0") + end + + -- execute wps_action.lua file to send signal for current interface + os.execute("lua wps_action.lua "..ifname) + debug_write("lua wps_action.lua "..ifname) + return cfgs +end + +function mtkwifi.restart_8021x(devname, devices) + local l1dat, l1 = mtkwifi.__get_l1dat() + local dridx = l1dat and l1.DEV_RINDEX + + local devs = devices or mtkwifi.get_all_devs() + local dev = devs[devname] + local main_ifname = l1dat and l1dat[dridx][devname].main_ifname or dbdc_prefix[mainidx][subidx].."0" + local prefix = l1dat and l1dat[dridx][devname].ext_ifname or dbdc_prefix[mainidx][subidx] + + local ps_cmd = "ps | grep -v grep | grep rt2860apd | grep "..main_ifname.." | awk '{print $1}'" + local pid_cmd = "cat /var/run/rt2860apd_"..devs[devname].vifs[1].vifname..".pid" + local apd_pid = mtkwifi.read_pipe(pid_cmd) or mtkwifi.read_pipe(ps_cmd) + if tonumber(apd_pid) then + os.execute("kill "..apd_pid) + end + + local cfgs = mtkwifi.load_profile(devs[devname].profile) + local auth_mode = cfgs['AuthMode'] + local ieee8021x = cfgs['IEEE8021X'] + local pat_auth_mode = {"WPA$", "WPA;", "WPA2$", "WPA2;", "WPA1WPA2$", "WPA1WPA2;"} + local pat_ieee8021x = {"1$", "1;"} + local apd_en = false + + for _, pat in ipairs(pat_auth_mode) do + if string.find(auth_mode, pat) then + apd_en = true + end + end + + for _, pat in ipairs(pat_ieee8021x) do + if string.find(ieee8021x, pat) then + apd_en = true + end + end + + if not apd_en then + return + end + + os.execute("rt2860apd -i "..main_ifname.." -p "..prefix) +end + +return mtkwifi diff --git a/mtk-luci-plugin/luci-app-webconsole/Makefile b/mtk-luci-plugin/luci-app-webconsole/Makefile new file mode 100755 index 0000000..3594622 --- /dev/null +++ b/mtk-luci-plugin/luci-app-webconsole/Makefile @@ -0,0 +1,19 @@ +include $(TOPDIR)/rules.mk + +PKG_LICENSE:=GPLv2 +PKG_MAINTAINER:=Hua Shao + +LUCI_TITLE:=A simple web console. +LUCI_DEPENDS:= + +# earlier version of luci put "luci.mk" somewhere else... +LUCI_MK_OLDPATH:=$(shell test -e ../luci.mk && echo "old") +LUCI_MK_NEWPATH:=$(shell test -e ../../luci.mk && echo "new") +ifeq ($(LUCI_MK_OLDPATH),old) +include ../luci.mk +endif +ifeq ($(LUCI_MK_NEWPATH),new) +include ../../luci.mk +endif + +# call BuildPackage - OpenWrt buildroot signature diff --git a/mtk-luci-plugin/luci-app-webconsole/luasrc/controller/webconsole.lua b/mtk-luci-plugin/luci-app-webconsole/luasrc/controller/webconsole.lua new file mode 100755 index 0000000..5ec0bd1 --- /dev/null +++ b/mtk-luci-plugin/luci-app-webconsole/luasrc/controller/webconsole.lua @@ -0,0 +1,23 @@ +-- A simple web console in case you don't have access to the shell +-- +-- Hua Shao + +module("luci.controller.webconsole", package.seeall) +local http = require("luci.http") +function index() + entry({"admin", "mtk", "console"}, template("mtk_web_console"), _("Web Console"), 4) + entry({"admin", "mtk", "webcmd"}, call("webcmd")) +end + +function webcmd() + local cmd = http.formvalue("cmd") + if cmd then + local fp = io.popen(tostring(cmd).." 2>&1") + local result = fp:read("*a") + fp:close() + result = result:gsub("<", "<") + http.write(tostring(result)) + else + http.write_json(http.formvalue()) + end +end diff --git a/mtk-luci-plugin/luci-app-webconsole/luasrc/view/mtk_web_console.htm b/mtk-luci-plugin/luci-app-webconsole/luasrc/view/mtk_web_console.htm new file mode 100755 index 0000000..c3aa421 --- /dev/null +++ b/mtk-luci-plugin/luci-app-webconsole/luasrc/view/mtk_web_console.htm @@ -0,0 +1,51 @@ +<%+header%> + +

Web Console

+
+
+ Execute shell commands or scripts as root. Be Careful. +

Press Enter to execute. Press Shift+Enter to start a new line.

+

+

+ + + + + + + +


+    
+
+ + + +<%+footer%> +