Compare commits
107 Commits
v21.02.6
...
openwrt-21
| Author | SHA1 | Date | |
|---|---|---|---|
| d00fd3b54b | |||
| 185a0e6595 | |||
| 243863bdec | |||
| 3f5ca9566e | |||
|
|
fc9fe90e5a | ||
|
|
86f718d98b | ||
|
|
4f16c1abea | ||
|
|
d1dca8343b | ||
|
|
4a1d8ef55c | ||
|
|
c31872bad8 | ||
|
|
754dfab01c | ||
|
|
74212e7be3 | ||
|
|
ded99ab483 | ||
|
|
c5cb4287b8 | ||
|
|
66c2715a56 | ||
|
|
b3baba3854 | ||
|
|
90c8c47188 | ||
|
|
18f12e6f69 | ||
|
|
42374bcee6 | ||
|
|
f24a029c3e | ||
|
|
ed68908f58 | ||
|
|
0bd0306b05 | ||
|
|
c5dc0e01df | ||
|
|
41d3d25142 | ||
|
|
0ab1007528 | ||
|
|
ddc361f1a6 | ||
|
|
9431f3625b | ||
|
|
683751adda | ||
|
|
cd655a8b30 | ||
|
|
7c89acbebf | ||
|
|
faec1771f6 | ||
|
|
9bc1deec7f | ||
|
|
e5a48ffa59 | ||
|
|
ac52e2013a | ||
|
|
c989b26be4 | ||
|
|
b6dd058ff1 | ||
|
|
a8bbadefaf | ||
|
|
383ae905a2 | ||
|
|
caf6177269 | ||
|
|
0c5aa06824 | ||
|
|
949f0dd900 | ||
|
|
15bb8c3461 | ||
|
|
1db1d6b729 | ||
|
|
0be61f5268 | ||
|
|
b205996838 | ||
|
|
9d206fa4dd | ||
|
|
1f7ca00f45 | ||
|
|
448883d45d | ||
|
|
6a5ee91aa1 | ||
|
|
5be1746bbd | ||
|
|
1209f4c2f0 | ||
|
|
721cd12977 | ||
|
|
804b511fa3 | ||
|
|
f68568c2ab | ||
|
|
a798decbc7 | ||
|
|
dd689d9d24 | ||
|
|
12f16fb68a | ||
|
|
a8938ee909 | ||
|
|
892fdbb966 | ||
|
|
29e16763f5 | ||
|
|
b5cb9442f4 | ||
|
|
995a843c84 | ||
|
|
3b28d4231c | ||
|
|
a76f816d04 | ||
|
|
170d9e447d | ||
|
|
4ceaf439a5 | ||
|
|
67603f2a9e | ||
|
|
40d838ff6b | ||
|
|
064779f9c2 | ||
|
|
47054075e2 | ||
|
|
04ee513ede | ||
|
|
30d8cc5eab | ||
|
|
f5fbde4c11 | ||
|
|
edcc069409 | ||
|
|
fff279f4a7 | ||
|
|
7f06e5f7f2 | ||
|
|
64261da739 | ||
|
|
1d206bcd71 | ||
|
|
18a5301858 | ||
|
|
de6c207899 | ||
|
|
3267c28531 | ||
|
|
7125dd1654 | ||
|
|
3f4a88db29 | ||
|
|
66cf99e2e1 | ||
|
|
eb8cae5391 | ||
|
|
39c00a9bdd | ||
|
|
2e05d5a036 | ||
|
|
7cf6696120 | ||
|
|
0c9a28e9e0 | ||
|
|
8d858460fe | ||
|
|
8715c83b9d | ||
|
|
17c880c005 | ||
|
|
d3af1f168b | ||
|
|
d7d319a6d2 | ||
|
|
eccc9ff34c | ||
|
|
294ae1013b | ||
|
|
f9e0e9d841 | ||
|
|
739fd7532f | ||
|
|
175c24ea94 | ||
|
|
25f66d9c49 | ||
|
|
491b784141 | ||
|
|
32e60759e6 | ||
|
|
7e8f2a2d6a | ||
|
|
47a7e9ae6f | ||
|
|
c744089871 | ||
|
|
c694aa3326 | ||
|
|
6114723dd1 |
@@ -45,15 +45,15 @@ To build your own firmware you need a GNU/Linux, BSD or MacOSX system (case sens
|
||||
```
|
||||
|
||||
Note:
|
||||
- For the for love of god please do __not__ use ROOT user to build your image.
|
||||
- Do everything as an unprivileged user, not root, without sudo.
|
||||
- Using CPUs based on other architectures should be fine to compile ImmortalWrt, but more hacks are needed - No warranty at all.
|
||||
- You must __not__ have spaces in PATH or in the work folders on the drive.
|
||||
- You must __not__ have spaces or non-ascii characters in PATH or in the work folders on the drive.
|
||||
- If you're using Windows Subsystem for Linux (or WSL), removing Windows folders from PATH is required, please see [Build system setup WSL](https://openwrt.org/docs/guide-developer/build-system/wsl) documentation.
|
||||
- Using macOS as the host build OS is __not__ recommended. No warranty at all. You can get tips from [Build system setup macOS](https://openwrt.org/docs/guide-developer/build-system/buildroot.exigence.macosx) documentation.
|
||||
- For more details, please see [Build system setup](https://openwrt.org/docs/guide-developer/build-system/install-buildsystem) documentation.
|
||||
|
||||
### Quickstart
|
||||
1. Run `git clone -b <branch> --single-branch https://github.com/immortalwrt/immortalwrt` to clone the source code.
|
||||
1. Run `git clone -b <branch> --single-branch --filter=blob:none https://github.com/immortalwrt/immortalwrt` to clone the source code.
|
||||
2. Run `cd immortalwrt` to enter source directory.
|
||||
3. Run `./scripts/feeds update -a` to obtain all the latest package definitions defined in feeds.conf / feeds.conf.default
|
||||
4. Run `./scripts/feeds install -a` to install symlinks for all obtained packages into package/feeds/
|
||||
@@ -86,6 +86,6 @@ ImmortalWrt is licensed under [GPL-2.0-only](https://spdx.org/licenses/GPL-2.0-o
|
||||
<tr>
|
||||
<td><a href="https://dlercloud.com/"><img src="https://user-images.githubusercontent.com/22235437/111103249-f9ec6e00-8588-11eb-9bfc-67cc55574555.png" width="183" height="52" border="0" alt="Dler Cloud"></a></td>
|
||||
<td><a href="https://www.jetbrains.com/"><img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_square.png" width="120" height="120" border="0" alt="JetBrains Black Box Logo logo"></a></td>
|
||||
<td><a href="https://osdn.net/"><img src="https://osdn.net/sflogo.php?group_id=13647&type=2" width="125" height="39" border="0" alt="OSDN"></a></td>
|
||||
<td><a href="https://sourceforge.net/"><img src="https://sourceforge.net/sflogo.php?type=17&group_id=3663829" alt="SourceForge" width=200></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
749
build_openwrt.sh
Executable file
749
build_openwrt.sh
Executable file
@@ -0,0 +1,749 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#====================================================
|
||||
# OpenWrt 构建管理脚本
|
||||
# 功能:提供交互式菜单,可选择执行特定操作
|
||||
# 更新:2025-04-05
|
||||
#====================================================
|
||||
|
||||
#---------------基础配置---------------#
|
||||
# 日志目录设置
|
||||
LOGS_ROOT="openwrt_logs"
|
||||
SESSION_DIR="${LOGS_ROOT}/$(date +%Y%m%d_%H%M%S)"
|
||||
LOG_FILE="${SESSION_DIR}/main_build_script.log" # 主脚本日志文件名更改,更清晰
|
||||
|
||||
#---------------清理配置---------------#
|
||||
# 需要移除的目录列表 (示例,根据你的需要添加)
|
||||
declare -a REMOVE_DIRS=(
|
||||
# "feeds/packages/net/v2ray-geodata" # 示例
|
||||
)
|
||||
|
||||
# 需要移除的包列表 (示例,根据你的需要添加)
|
||||
declare -a REMOVE_PACKAGES=(
|
||||
# "package/feeds/luci/luci-app-example" # 示例
|
||||
)
|
||||
|
||||
#---------------自定义包配置---------------#
|
||||
# 定义自定义包配置,格式:[包名]=[目标目录]=[仓库URL]=[分支]=[是否使用--depth 1]
|
||||
declare -A CUSTOM_PACKAGES=(
|
||||
["partexp"]="package/luci-app-partexp=https://github.com/sirpdboy/luci-app-partexp=main=false"
|
||||
["openclash"]="package/openclash=https://github.com/vernesong/OpenClash=dev=true"
|
||||
["zerotier"]="package/luci-app-zerotier=https://github.com/Firsgith/luci-app-zerotier.git=main=false"
|
||||
["5gsupport"]="package/5G-Modem-Support=https://nanako.site/gitea/Nanako/openwrt-app-actions.git=main=false"
|
||||
["pcat"]="package/pcat-manager=https://github.com/photonicat/rockchip_rk3568_pcat_manager.git=master=true"
|
||||
)
|
||||
|
||||
#---------------日志系统---------------#
|
||||
# 保存原始的标准输出和错误输出文件描述符
|
||||
exec {STDOUT_ORIG}>&1
|
||||
exec {STDERR_ORIG}>&2
|
||||
|
||||
# 全局变量标记日志是否启用
|
||||
LOGGING_ENABLED=false # 初始为 false,由 init_logger 启用
|
||||
|
||||
# 初始化日志系统
|
||||
init_logger() {
|
||||
# 创建日志目录结构
|
||||
mkdir -p "$SESSION_DIR" || {
|
||||
echo "错误: 无法创建日志目录: $SESSION_DIR" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
LOGGING_ENABLED=true
|
||||
echo "日志将保存在: $SESSION_DIR"
|
||||
echo "主脚本日志: $LOG_FILE"
|
||||
|
||||
# 重定向主脚本的 stdout 和 stderr 到 tee,同时输出到控制台和主日志文件
|
||||
# 使用 process substitution 和 tee
|
||||
exec > >(tee -a "$LOG_FILE")
|
||||
exec 2> >(tee -a "$LOG_FILE" >&2)
|
||||
|
||||
# 记录初始信息到日志
|
||||
echo "[$(date "+%Y-%m-%d %H:%M:%S")] [INFO]: 日志系统初始化完成。主日志文件: $LOG_FILE"
|
||||
}
|
||||
|
||||
# 创建新的特定构建阶段的日志文件
|
||||
create_build_log() {
|
||||
local build_type=$1
|
||||
local timestamp=$(date +%Y%m%d_%H%M%S)
|
||||
# 使用更明确的文件名
|
||||
BUILD_LOG_FILE="${SESSION_DIR}/${build_type}_build_${timestamp}.log"
|
||||
# 确保文件被创建,即使命令没有输出
|
||||
touch "$BUILD_LOG_FILE" || {
|
||||
log "ERROR" "无法创建构建日志文件: $BUILD_LOG_FILE"
|
||||
return 1
|
||||
}
|
||||
# 返回创建的日志文件名
|
||||
echo "$BUILD_LOG_FILE"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 禁用日志重定向 (用于 menuconfig 等交互场景)
|
||||
disable_logging() {
|
||||
if [ "$LOGGING_ENABLED" = true ]; then
|
||||
log "DEBUG" "禁用日志重定向,恢复原始标准输出/错误。"
|
||||
exec >&$STDOUT_ORIG
|
||||
exec 2>&$STDERR_ORIG
|
||||
LOGGING_ENABLED=false # 标记为禁用
|
||||
fi
|
||||
}
|
||||
|
||||
# 启用日志重定向 (恢复)
|
||||
enable_logging() {
|
||||
# 仅在之前被禁用的情况下才重新启用
|
||||
if [ "$LOGGING_ENABLED" = false ]; then
|
||||
# 重新应用重定向到主日志
|
||||
exec > >(tee -a "$LOG_FILE")
|
||||
exec 2> >(tee -a "$LOG_FILE" >&2)
|
||||
LOGGING_ENABLED=true # 标记为启用
|
||||
log "DEBUG" "重新启用日志重定向到主日志。"
|
||||
fi
|
||||
}
|
||||
|
||||
# 设置终端颜色
|
||||
setup_colors() {
|
||||
if [[ -t 1 ]]; then # 检查标准输出是否连接到终端
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
else
|
||||
RED='' GREEN='' YELLOW='' BLUE='' NC=''
|
||||
fi
|
||||
}
|
||||
|
||||
# 记录日志函数 - 使用此函数来明确日志级别
|
||||
# 注意:此函数输出会经过 init_logger 设置的全局重定向
|
||||
log() {
|
||||
local level=$1
|
||||
local message=$2
|
||||
local timestamp
|
||||
timestamp=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
local color="" level_str=""
|
||||
|
||||
case $level in
|
||||
"INFO") color="$GREEN"; level_str="INFO " ;; # 加空格对齐
|
||||
"WARN") color="$YELLOW"; level_str="WARN " ;;
|
||||
"ERROR") color="$RED"; level_str="ERROR" ;;
|
||||
"DEBUG") color="$BLUE"; level_str="DEBUG" ;;
|
||||
*) color=""; level_str="LOG " ;; # 默认级别
|
||||
esac
|
||||
|
||||
# 使用 printf 保证原子写入,减少并发问题
|
||||
printf "[%s] %b[%s]%b: %s\n" "$timestamp" "$color" "$level_str" "$NC" "$message"
|
||||
}
|
||||
|
||||
# 同时记录消息到主日志和特定的构建日志
|
||||
log_to_both() {
|
||||
local level=$1
|
||||
local message=$2
|
||||
local build_log_file=$3 # 明确参数名
|
||||
|
||||
# 1. 输出到主日志(通过全局重定向和 log 函数)
|
||||
log "$level" "$message"
|
||||
|
||||
# 2. 追加到指定的构建日志文件
|
||||
local timestamp
|
||||
timestamp=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
# 直接追加,不需要颜色代码
|
||||
printf "[%s] [%s]: %s\n" "$timestamp" "$level" "$message" >> "$build_log_file"
|
||||
}
|
||||
|
||||
|
||||
#---------------自定义包管理函数---------------#
|
||||
# 更新单个自定义包
|
||||
update_single_package() {
|
||||
local pkg_name=$1
|
||||
local config=$2
|
||||
|
||||
# 解析配置 (保持 cut 的方式,假设路径/URL/分支名不含 '=')
|
||||
# 如果遇到问题,可以切换到 IFS/read
|
||||
local target_dir repo_url branch use_depth
|
||||
target_dir=$(echo "$config" | cut -d= -f1)
|
||||
repo_url=$(echo "$config" | cut -d= -f2)
|
||||
branch=$(echo "$config" | cut -d= -f3)
|
||||
use_depth=$(echo "$config" | cut -d= -f4)
|
||||
|
||||
# 基础验证
|
||||
if [ -z "$target_dir" ] || [ -z "$repo_url" ]; then
|
||||
log "ERROR" "包 '$pkg_name' 的配置无效: $config"
|
||||
return 1
|
||||
fi
|
||||
|
||||
log "INFO" "更新自定义包: $pkg_name..."
|
||||
|
||||
# 检查目标目录的父目录是否存在
|
||||
local parent_dir
|
||||
parent_dir=$(dirname "$target_dir")
|
||||
if [ ! -d "$parent_dir" ]; then
|
||||
log "INFO" "创建父目录: $parent_dir"
|
||||
mkdir -p "$parent_dir" || {
|
||||
log "ERROR" "无法创建父目录: $parent_dir"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# 移除现有目录
|
||||
if [ -d "$target_dir" ]; then
|
||||
log "INFO" "移除现有目录: $target_dir"
|
||||
rm -rf "$target_dir" || {
|
||||
log "ERROR" "无法删除目录: $target_dir"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# 准备 git clone 命令参数数组 (移除 eval)
|
||||
local git_options=("--progress") # 总是显示进度
|
||||
# 处理分支
|
||||
if [ -n "$branch" ] && [ "$branch" != "master" ]; then
|
||||
git_options+=("-b" "$branch")
|
||||
fi
|
||||
# 处理 depth
|
||||
if [ "$use_depth" = "true" ]; then
|
||||
git_options+=("--depth" "1")
|
||||
fi
|
||||
|
||||
# 执行克隆
|
||||
log "INFO" "执行: git clone ${git_options[*]} $repo_url $target_dir"
|
||||
if git clone "${git_options[@]}" "$repo_url" "$target_dir"; then
|
||||
log "INFO" "包 '$pkg_name' 更新成功"
|
||||
return 0
|
||||
else
|
||||
log "ERROR" "克隆包 '$pkg_name' 失败 (仓库: $repo_url)"
|
||||
# 尝试给出更具体的错误提示
|
||||
log "ERROR" "请检查网络连接、仓库 URL、分支名称以及目标目录权限。"
|
||||
# 保留可能存在的空目录或部分克隆,让用户检查
|
||||
# rm -rf "$target_dir" # 不再自动删除失败的克隆
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 更新所有自定义包的主函数
|
||||
update_custom_package() {
|
||||
local failed_packages=()
|
||||
local success_count=0
|
||||
local total_packages=${#CUSTOM_PACKAGES[@]}
|
||||
|
||||
if [ "$total_packages" -eq 0 ]; then
|
||||
log "INFO" "没有配置自定义包,跳过更新。"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log "INFO" "开始更新 $total_packages 个自定义包..."
|
||||
|
||||
for pkg_name in "${!CUSTOM_PACKAGES[@]}"; do
|
||||
# 使用 subshell 执行,避免污染当前环境的变量,但这里影响不大
|
||||
if update_single_package "$pkg_name" "${CUSTOM_PACKAGES[$pkg_name]}"; then
|
||||
((success_count++))
|
||||
else
|
||||
failed_packages+=("$pkg_name")
|
||||
fi
|
||||
done
|
||||
|
||||
# 显示更新结果
|
||||
if [ ${#failed_packages[@]} -eq 0 ]; then
|
||||
log "INFO" "所有自定义包更新成功 ($success_count/$total_packages)"
|
||||
return 0
|
||||
else
|
||||
log "WARN" "部分自定义包更新失败 (成功: $success_count/$total_packages)"
|
||||
log "ERROR" "更新失败的包: ${failed_packages[*]}"
|
||||
return 1 # 返回失败状态码
|
||||
fi
|
||||
}
|
||||
|
||||
# 更新特定自定义包
|
||||
update_specific_package() {
|
||||
local pkg_name=$1
|
||||
|
||||
if [ -z "$pkg_name" ]; then
|
||||
log "ERROR" "未指定包名"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "${CUSTOM_PACKAGES[$pkg_name]}" ]; then
|
||||
log "ERROR" "未找到包配置:'$pkg_name'"
|
||||
log "INFO" "可用的包名: ${!CUSTOM_PACKAGES[*]}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
update_single_package "$pkg_name" "${CUSTOM_PACKAGES[$pkg_name]}"
|
||||
}
|
||||
|
||||
#---------------基础功能函数---------------#
|
||||
# 清理工作区 (make clean 的替代方案,更彻底)
|
||||
clean_workspace() {
|
||||
log "INFO" "开始彻底清理工作区..."
|
||||
|
||||
# 清理 feeds (可选,如果 feeds 内容经常变动或出问题可以启用)
|
||||
# log "INFO" "执行 ./scripts/feeds clean ..."
|
||||
# ./scripts/feeds clean || log "WARN" "./scripts/feeds clean 执行时遇到问题。"
|
||||
|
||||
# 清理编译产物和临时文件
|
||||
log "INFO" "执行 rm -rf ./tmp ./logs ./staging_dir ./build_dir ./bin ..."
|
||||
# 注意:这里移除了 logs 目录,但我们的脚本日志在 openwrt_logs 下,不会被删
|
||||
# 如果 OpenWrt 自身有 logs 目录且需要保留,则从下面移除 ./logs
|
||||
rm -rf ./tmp ./logs ./staging_dir ./build_dir ./bin || {
|
||||
log "ERROR" "删除部分工作区目录失败,请检查权限或文件占用。"
|
||||
return 1
|
||||
}
|
||||
|
||||
log "INFO" "工作区清理完成。"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 清理编译临时文件 (make clean 的快速版)
|
||||
clean_build_temp() {
|
||||
log "INFO" "开始清理编译临时文件..."
|
||||
|
||||
log "INFO" "执行 rm -rf ./tmp ./staging_dir ./build_dir ..."
|
||||
rm -rf ./tmp ./staging_dir ./build_dir || {
|
||||
log "ERROR" "删除部分编译临时目录失败。"
|
||||
return 1
|
||||
}
|
||||
|
||||
log "INFO" "编译临时文件清理完成。"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 更新源码
|
||||
update_source() {
|
||||
log "INFO" "开始更新 OpenWrt 源码 (git pull)..."
|
||||
if git pull --rebase; then # 使用 rebase 避免不必要的 merge commit
|
||||
log "INFO" "源码更新完成"
|
||||
return 0
|
||||
else
|
||||
log "ERROR" "源码更新失败 (git pull --rebase)"
|
||||
log "WARN" "请检查本地是否有未提交的修改,或尝试手动解决 Git 冲突。"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 更新并安装 feeds
|
||||
update_feeds() {
|
||||
log "INFO" "开始更新 Feeds (update -a)..."
|
||||
if ./scripts/feeds update -a; then
|
||||
log "INFO" "Feeds 更新成功,开始安装 (install -a)..."
|
||||
if ./scripts/feeds install -a; then
|
||||
log "INFO" "Feeds 安装成功"
|
||||
return 0
|
||||
else
|
||||
log "ERROR" "Feeds 安装失败 (install -a)"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
log "ERROR" "Feeds 更新失败 (update -a)"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 执行构建相关命令,并将 stdout 重定向到日志,stderr 同时输出到控制台和日志
|
||||
run_build_command() {
|
||||
local cmd=$1 # 要执行的命令字符串
|
||||
local log_file=$2 # 目标日志文件
|
||||
local description=$3 # 操作描述
|
||||
|
||||
log_to_both "INFO" "开始执行: $description" "$log_file"
|
||||
log "DEBUG" "命令详情: $cmd" # 只记录到主日志
|
||||
|
||||
# 执行命令
|
||||
# stdout (>>) 追加到日志文件
|
||||
# stderr (2>) 通过管道给 tee
|
||||
# tee -a "$log_file" 将 stderr 追加到日志文件
|
||||
# tee 默认将其标准输入复制到标准输出,这里即脚本的 stderr,因此会显示在控制台
|
||||
local start_time end_time duration
|
||||
start_time=$(date +%s)
|
||||
if eval "$cmd" >> "$log_file" 2> >(tee -a "$log_file" >&2); then
|
||||
end_time=$(date +%s)
|
||||
duration=$((end_time - start_time))
|
||||
log_to_both "INFO" "$description 完成 (耗时: ${duration}s)" "$log_file"
|
||||
return 0 # 成功返回 0
|
||||
else
|
||||
end_time=$(date +%s)
|
||||
duration=$((end_time - start_time))
|
||||
local exit_code=$? # 获取命令的退出码
|
||||
# 错误信息已经通过 stderr 的 tee 输出到控制台了
|
||||
log_to_both "ERROR" "$description 失败 (退出码: $exit_code, 耗时: ${duration}s)" "$log_file"
|
||||
log "ERROR" "详细错误请查看控制台输出以及日志文件: $log_file"
|
||||
return $exit_code # 失败返回命令的退出码
|
||||
fi
|
||||
}
|
||||
|
||||
# 编译固件
|
||||
build_firmware() {
|
||||
# 创建新的固件编译日志文件
|
||||
local current_log
|
||||
current_log=$(create_build_log "firmware") || return 1 # 创建失败则退出
|
||||
|
||||
log "INFO" "开始编译固件..."
|
||||
log "INFO" "详细编译日志将保存在: $current_log"
|
||||
|
||||
# 1. 下载依赖包
|
||||
local download_cmd="make download -j$(nproc) V=s"
|
||||
run_build_command "$download_cmd" "$current_log" "下载依赖包" || {
|
||||
log "ERROR" "依赖包下载失败,编译中止。"
|
||||
# 即使下载失败,日志文件也已包含错误信息
|
||||
return 1
|
||||
}
|
||||
|
||||
# 2. 多线程编译
|
||||
local cpu_cores
|
||||
cpu_cores=$(nproc)
|
||||
log "INFO" "检测到 $cpu_cores 个 CPU 核心,开始多线程编译..."
|
||||
local build_cmd="make -j${cpu_cores} V=s"
|
||||
|
||||
if run_build_command "$build_cmd" "$current_log" "固件编译 (多线程)"; then
|
||||
log "INFO" "${GREEN}固件编译成功完成!${NC}"
|
||||
log "INFO" "固件输出目录: ./bin/targets/"
|
||||
return 0 # 编译成功
|
||||
else
|
||||
# 多线程编译失败,询问用户是否重试
|
||||
log "WARN" "多线程编译失败。"
|
||||
local retry_choice
|
||||
# -r: raw input, -p: prompt, -n 1: read only one char (optional but nice), -t 15: timeout (optional)
|
||||
# Default to No
|
||||
read -rp "$(echo -e ${YELLOW}"是否尝试使用单线程重新编译? (y/N): "${NC})" -n 1 -t 30 retry_choice
|
||||
echo # Add a newline after read -n
|
||||
|
||||
if [[ "$retry_choice" =~ ^[Yy]$ ]]; then
|
||||
log "INFO" "用户选择使用单线程重试编译..."
|
||||
|
||||
# 3. 单线程编译重试
|
||||
local build_cmd_single="make -j1 V=s"
|
||||
if run_build_command "$build_cmd_single" "$current_log" "固件编译 (单线程重试)"; then
|
||||
log "INFO" "${GREEN}单线程编译成功完成!${NC}"
|
||||
log "INFO" "固件输出目录: ./bin/targets/"
|
||||
return 0 # 单线程编译成功
|
||||
else
|
||||
log "ERROR" "${RED}单线程编译也失败了。${NC}"
|
||||
log "ERROR" "请仔细检查控制台错误输出以及日志文件: $current_log"
|
||||
return 1 # 最终编译失败
|
||||
fi
|
||||
else
|
||||
log "INFO" "用户选择不进行单线程重试编译。"
|
||||
log "ERROR" "${RED}编译失败,未进行单线程重试。${NC}"
|
||||
log "ERROR" "请仔细检查控制台错误输出以及日志文件: $current_log"
|
||||
return 1 # 用户取消重试,编译失败
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# 清理配置文件中指定的旧包/目录
|
||||
clean_packages() {
|
||||
log "INFO" "开始清理配置文件中指定的旧包和目录..."
|
||||
local removed_count=0
|
||||
local failed_count=0
|
||||
local total_to_remove=$((${#REMOVE_DIRS[@]} + ${#REMOVE_PACKAGES[@]}))
|
||||
|
||||
if [ "$total_to_remove" -eq 0 ]; then
|
||||
log "INFO" "配置文件中未指定需要移除的包或目录。"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 清理目录
|
||||
for dir in "${REMOVE_DIRS[@]}"; do
|
||||
if [ -e "$dir" ]; then # 使用 -e 检查文件或目录是否存在
|
||||
log "INFO" "正在删除目录: $dir"
|
||||
if rm -rf "$dir"; then
|
||||
log "INFO" "已删除: $dir"
|
||||
((removed_count++))
|
||||
else
|
||||
log "ERROR" "删除失败: $dir (请检查权限或是否被占用)"
|
||||
((failed_count++))
|
||||
fi
|
||||
else
|
||||
log "WARN" "指定的目录不存在,跳过: $dir"
|
||||
fi
|
||||
done
|
||||
|
||||
# 清理包 (通常包也是目录)
|
||||
for pkg in "${REMOVE_PACKAGES[@]}"; do
|
||||
if [ -e "$pkg" ]; then
|
||||
log "INFO" "正在删除包/目录: $pkg"
|
||||
if rm -rf "$pkg"; then
|
||||
log "INFO" "已删除: $pkg"
|
||||
((removed_count++))
|
||||
else
|
||||
log "ERROR" "删除失败: $pkg (请检查权限或是否被占用)"
|
||||
((failed_count++))
|
||||
fi
|
||||
else
|
||||
log "WARN" "指定的包/目录不存在,跳过: $pkg"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $failed_count -eq 0 ]; then
|
||||
log "INFO" "旧包/目录清理完成,共处理 $removed_count 个项目。"
|
||||
return 0
|
||||
else
|
||||
log "WARN" "旧包/目录清理部分完成 (成功: $removed_count, 失败: $failed_count)"
|
||||
return 1 # 返回失败状态码
|
||||
fi
|
||||
}
|
||||
|
||||
# 更新所有组件 (源码 -> 清理旧包 -> 自定义包 -> feeds)
|
||||
update_all_components() {
|
||||
log "INFO" "开始更新所有组件..."
|
||||
local success=true # 假设成功
|
||||
|
||||
# 1. 更新源码
|
||||
log "INFO" "[1/4] 更新 OpenWrt 源码..."
|
||||
update_source || success=false
|
||||
|
||||
# 2. 清理旧包 (即使上一步失败也尝试清理)
|
||||
log "INFO" "[2/4] 清理配置文件指定的旧包/目录..."
|
||||
clean_packages || log "WARN" "清理旧包/目录时遇到问题,继续执行..." # 清理失败通常不阻止后续
|
||||
|
||||
# 3. 更新自定义包 (只有在源码更新成功时才执行较好)
|
||||
if [ "$success" = true ]; then
|
||||
log "INFO" "[3/4] 更新自定义包..."
|
||||
update_custom_package || success=false
|
||||
else
|
||||
log "WARN" "[3/4] 跳过更新自定义包,因为源码更新失败。"
|
||||
fi
|
||||
|
||||
# 4. 更新 Feeds (只有在源码和自定义包都成功时执行较好)
|
||||
if [ "$success" = true ]; then
|
||||
log "INFO" "[4/4] 更新 Feeds..."
|
||||
update_feeds || success=false
|
||||
else
|
||||
log "WARN" "[4/4] 跳过更新 Feeds,因为之前的步骤失败。"
|
||||
fi
|
||||
|
||||
# 总结
|
||||
if [ "$success" = true ]; then
|
||||
log "INFO" "所有组件更新完成!"
|
||||
return 0
|
||||
else
|
||||
log "ERROR" "部分或全部组件更新失败,请检查上面的日志。"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 菜单配置 (make menuconfig)
|
||||
menuconfig() {
|
||||
log "INFO" "准备进入菜单配置 (make menuconfig)..."
|
||||
log "INFO" "注意:日志重定向将暂时禁用以进行交互。"
|
||||
|
||||
# 禁用日志重定向,否则 menuconfig 界面可能显示不正常
|
||||
disable_logging
|
||||
|
||||
# 执行 menuconfig
|
||||
if make menuconfig; then
|
||||
# 配置成功后重新启用日志
|
||||
enable_logging
|
||||
log "INFO" "菜单配置完成。新配置已保存到 .config"
|
||||
# 询问是否保存 defconfig (可选)
|
||||
# read -p "是否将当前配置保存为 defconfig? (y/N): " save_defconfig
|
||||
# if [[ "$save_defconfig" =~ ^[Yy]$ ]]; then
|
||||
# ./scripts/diffconfig.sh > my_defconfig
|
||||
# log "INFO" "当前配置已保存到 my_defconfig"
|
||||
# fi
|
||||
return 0
|
||||
else
|
||||
# 配置失败或被取消,也要恢复日志
|
||||
enable_logging
|
||||
log "WARN" "菜单配置未完成或被取消。"
|
||||
return 1 # 返回失败状态码
|
||||
fi
|
||||
}
|
||||
|
||||
#---------------组合功能函数---------------#
|
||||
# 完整构建流程
|
||||
full_build() {
|
||||
log "INFO" "启动完整构建流程..."
|
||||
local step=1
|
||||
local total_steps=6 # 预估步骤数
|
||||
|
||||
# 1. 清理工作区
|
||||
log "INFO" "[${step}/${total_steps}] 清理工作区..."
|
||||
clean_workspace || { log "WARN" "工作区清理可能不完整,尝试继续..."; } # 清理失败通常不致命
|
||||
((step++))
|
||||
|
||||
# 2. 更新源码
|
||||
log "INFO" "[${step}/${total_steps}] 更新源码..."
|
||||
update_source || { log "ERROR" "源码更新失败,终止构建流程。"; return 1; }
|
||||
((step++))
|
||||
|
||||
# 3. 清理旧包
|
||||
log "INFO" "[${step}/${total_steps}] 清理配置文件指定的旧包..."
|
||||
clean_packages || log "WARN" "清理旧包时遇到问题,继续执行..."
|
||||
((step++))
|
||||
|
||||
# 4. 更新自定义包
|
||||
log "INFO" "[${step}/${total_steps}] 更新自定义包..."
|
||||
update_custom_package || { log "ERROR" "自定义包更新失败,终止构建流程。"; return 1; }
|
||||
((step++))
|
||||
|
||||
# 5. 更新 Feeds
|
||||
log "INFO" "[${step}/${total_steps}] 更新 Feeds..."
|
||||
update_feeds || { log "ERROR" "Feeds 更新失败,终止构建流程。"; return 1; }
|
||||
((step++))
|
||||
|
||||
# 6. 菜单配置
|
||||
log "INFO" "[${step}/${total_steps}] 进入菜单配置 (make menuconfig)..."
|
||||
menuconfig || { log "WARN" "菜单配置未完成或取消,但继续尝试编译..."; } # 允许使用现有配置编译
|
||||
((step++)) # 无论成功与否,都算一步
|
||||
|
||||
# 7. 编译固件 (独立步骤,不计入前面的 total_steps)
|
||||
log "INFO" "所有准备工作完成,开始编译固件..."
|
||||
if build_firmware; then
|
||||
log "INFO" "${GREEN}完整构建流程成功完成!${NC}"
|
||||
return 0
|
||||
else
|
||||
log "ERROR" "${RED}完整构建流程失败于编译阶段。${NC}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#---------------菜单函数---------------#
|
||||
# 打印主菜单
|
||||
print_menu() {
|
||||
echo -e "\n${BLUE}======= OpenWrt 构建管理菜单 =======${NC}"
|
||||
echo -e " ${YELLOW}会话日志目录: ${SESSION_DIR}${NC}"
|
||||
echo -e "${GREEN} 1.${NC} ${BOLD}完整构建流程${NC} (清理 > 更新源码/包/feeds > 配置 > 编译)"
|
||||
echo -e "${GREEN} 2.${NC} 清理工作区 (删除 tmp, bin, build_dir 等)"
|
||||
echo -e "${GREEN} 3.${NC} 更新所有组件 (源码 + 旧包清理 + 自定义包 + feeds)"
|
||||
echo -e "${GREEN} 4.${NC} 清理配置文件指定的旧包/目录"
|
||||
echo -e "${GREEN} 5.${NC} ${BOLD}编译固件${NC} (make V=s)"
|
||||
echo -e "${GREEN} 6.${NC} 调整配置 (make menuconfig)"
|
||||
echo -e "${GREEN} 7.${NC} 更新所有自定义包"
|
||||
echo -e "${GREEN} 8.${NC} 更新特定的自定义包"
|
||||
echo -e "${GREEN} 9.${NC} 更新 OpenWrt 源码 (git pull)"
|
||||
echo -e "${GREEN}10.${NC} 更新并安装 Feeds"
|
||||
echo -e "-------------------------------------"
|
||||
echo -e "${GREEN} 0.${NC} 退出脚本"
|
||||
echo -e "${BLUE}====================================${NC}"
|
||||
# 使用 read -p 提供提示
|
||||
read -rp "请输入选项 [0-10]: " choice
|
||||
}
|
||||
|
||||
# 打印并选择特定自定义包进行更新
|
||||
select_specific_package() {
|
||||
local pkg_names=("${!CUSTOM_PACKAGES[@]}") # 获取所有包名
|
||||
local num_packages=${#pkg_names[@]}
|
||||
|
||||
if [ "$num_packages" -eq 0 ]; then
|
||||
log "WARN" "没有配置任何自定义包。"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "\n${BLUE}--- 选择要更新的自定义包 ---${NC}"
|
||||
local i=1
|
||||
# 使用 sort 命令让包名按字母排序显示
|
||||
local sorted_pkg_names=($(printf "%s\n" "${pkg_names[@]}" | sort))
|
||||
|
||||
for pkg_name in "${sorted_pkg_names[@]}"; do
|
||||
echo -e " ${GREEN}$i.${NC} $pkg_name"
|
||||
((i++))
|
||||
done
|
||||
echo -e " ${GREEN}0.${NC} 返回主菜单"
|
||||
echo -e "${BLUE}----------------------------${NC}"
|
||||
|
||||
local choice_pkg
|
||||
read -rp "请输入包的序号 [0-$num_packages]: " choice_pkg
|
||||
|
||||
# 验证选择
|
||||
if [[ ! "$choice_pkg" =~ ^[0-9]+$ ]]; then
|
||||
log "ERROR" "无效输入,请输入数字。"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$choice_pkg" -eq 0 ]; then
|
||||
log "INFO" "返回主菜单。"
|
||||
return 0 # 返回成功,表示正常退出选择
|
||||
elif [ "$choice_pkg" -ge 1 ] && [ "$choice_pkg" -le "$num_packages" ]; then
|
||||
local selected_pkg=${sorted_pkg_names[$((choice_pkg-1))]}
|
||||
log "INFO" "选择更新包: $selected_pkg"
|
||||
update_specific_package "$selected_pkg" # 调用更新函数
|
||||
return $? # 返回更新函数的执行结果
|
||||
else
|
||||
log "ERROR" "无效的选择序号: $choice_pkg"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#---------------主函数---------------#
|
||||
main() {
|
||||
# 0. 设置颜色变量
|
||||
setup_colors
|
||||
|
||||
# 1. 初始化日志系统 (会进行第一次输出重定向)
|
||||
init_logger || exit 1 # 初始化失败则退出
|
||||
|
||||
# 2. 检查运行环境和依赖
|
||||
log "INFO" "检查运行环境..."
|
||||
local dep_missing=false
|
||||
if [ ! -f "Makefile" ] || [ ! -d "scripts" ] || [ ! -d ".git" ]; then
|
||||
log "ERROR" "脚本必须在 OpenWrt 源码的根目录下运行 (需要存在 Makefile, scripts, .git)。"
|
||||
dep_missing=true
|
||||
fi
|
||||
for cmd in git make nproc tee cut dirname mkdir rm git date printf sort read; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
log "ERROR" "缺少必要的系统命令: $cmd"
|
||||
dep_missing=true
|
||||
fi
|
||||
done
|
||||
if [ "$dep_missing" = true ]; then
|
||||
log "ERROR" "环境或依赖检查失败,请修正后重试。"
|
||||
# 恢复原始输出,避免后续可能的错误信息无法显示
|
||||
exec >&$STDOUT_ORIG
|
||||
exec 2>&$STDERR_ORIG
|
||||
exit 1
|
||||
fi
|
||||
log "INFO" "环境检查通过。"
|
||||
|
||||
# 记录脚本启动信息
|
||||
log "INFO" "${BOLD}OpenWrt 构建管理脚本已启动${NC}"
|
||||
log "INFO" "PID: $$"
|
||||
log "INFO" "会话日志目录: $SESSION_DIR"
|
||||
|
||||
# 3. 主菜单循环
|
||||
local choice # 提前声明 choice
|
||||
while true; do
|
||||
print_menu # 显示菜单并获取输入到 choice 变量
|
||||
log "DEBUG" "用户选择了: $choice" # 记录用户选择
|
||||
|
||||
# 根据选择执行操作
|
||||
case $choice in
|
||||
1) full_build ;;
|
||||
2) clean_workspace ;;
|
||||
3) update_all_components ;;
|
||||
4) clean_packages ;;
|
||||
5) build_firmware ;;
|
||||
6) menuconfig ;;
|
||||
7) update_custom_package ;;
|
||||
8) select_specific_package ;;
|
||||
9) update_source ;;
|
||||
10) update_feeds ;;
|
||||
0)
|
||||
log "INFO" "收到退出命令,正在退出脚本..."
|
||||
# 恢复原始输出流 (好习惯)
|
||||
exec >&$STDOUT_ORIG
|
||||
exec 2>&$STDERR_ORIG
|
||||
echo -e "${GREEN}脚本已退出。${NC}"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
log "WARN" "无效的选项: '$choice',请输入 0 到 10 之间的数字。"
|
||||
;;
|
||||
esac
|
||||
|
||||
local last_exit_code=$? # 获取上一个命令的退出状态码
|
||||
# 操作完成后暂停,给用户查看结果的时间
|
||||
if [[ $choice != 0 ]]; then
|
||||
if [ $last_exit_code -eq 0 ]; then
|
||||
echo -e "\n${GREEN}操作 '$choice' 执行完成。${NC}"
|
||||
else
|
||||
echo -e "\n${RED}操作 '$choice' 执行时遇到错误 (退出码: $last_exit_code)。${NC}"
|
||||
fi
|
||||
echo -e "${YELLOW}按 Enter 键返回主菜单...${NC}"
|
||||
read -r # 等待用户按回车
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#---------------脚本入口---------------#
|
||||
# 将所有主逻辑放入 main 函数,并在最后调用它
|
||||
# "$@" 将所有命令行参数传递给 main 函数 (虽然本脚本目前未使用)
|
||||
main "$@"
|
||||
BIN
dl/datconf-6bb733f7.tar.bz2
Normal file
BIN
dl/datconf-6bb733f7.tar.bz2
Normal file
Binary file not shown.
BIN
dl/mt7981-7.6.7.0-20221209-b9c02f-obj.tar.xz
Normal file
BIN
dl/mt7981-7.6.7.0-20221209-b9c02f-obj.tar.xz
Normal file
Binary file not shown.
BIN
dl/mt7981_20220425-4c770b-obj.tar.xz
Normal file
BIN
dl/mt7981_20220425-4c770b-obj.tar.xz
Normal file
Binary file not shown.
BIN
dl/mt7986-7.6.7.0-20221209-b9c02f-obj.tar.xz
Normal file
BIN
dl/mt7986-7.6.7.0-20221209-b9c02f-obj.tar.xz
Normal file
Binary file not shown.
BIN
dl/mt798x-7.6.6.1-src.tar.xz
Normal file
BIN
dl/mt798x-7.6.6.1-src.tar.xz
Normal file
Binary file not shown.
BIN
dl/warp_20220425-d15d0a-obj.tar.xz
Normal file
BIN
dl/warp_20220425-d15d0a-obj.tar.xz
Normal file
Binary file not shown.
BIN
dl/warp_20221209-3e6ae1-src.tar.xz
Normal file
BIN
dl/warp_20221209-3e6ae1-src.tar.xz
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
src-git-full packages https://github.com/immortalwrt/packages.git^78236a450b95e62d515cfe8ae26345c6ab7e4580
|
||||
src-git-full luci https://github.com/immortalwrt/luci.git^09e14b2b116e3f59b9d8e40448841b368e525aef
|
||||
src-git-full routing https://github.com/openwrt/routing.git^8071852b4556a02533cacb7a0f6a432df3507302
|
||||
src-git-full telephony https://github.com/openwrt/telephony.git^920fbc5c0a2e4badf51bceff42e9a1e3eb693462
|
||||
src-git-full packages https://github.com/immortalwrt/packages.git;openwrt-21.02
|
||||
src-git-full luci https://github.com/immortalwrt/luci.git;openwrt-21.02
|
||||
src-git-full routing https://github.com/openwrt/routing.git;openwrt-21.02
|
||||
src-git-full telephony https://github.com/openwrt/telephony.git;openwrt-21.02
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
LINUX_VERSION-5.4 = .242
|
||||
LINUX_KERNEL_HASH-5.4.242 = 142f9aed1c9f2e409dd72c5c490ad824dddf31f955ed2097d5989c4b5074fc28
|
||||
LINUX_VERSION-5.4 = .255
|
||||
LINUX_KERNEL_HASH-5.4.255 = 34d5ed902f47d90f27b9d5d6b8db0d3fa660834111f9452e166d920968a4a061
|
||||
|
||||
@@ -23,13 +23,13 @@ PKG_CONFIG_DEPENDS += \
|
||||
sanitize = $(call tolower,$(subst _,-,$(subst $(space),-,$(1))))
|
||||
|
||||
VERSION_NUMBER:=$(call qstrip,$(CONFIG_VERSION_NUMBER))
|
||||
VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),21.02.6)
|
||||
VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),21.02-SNAPSHOT)
|
||||
|
||||
VERSION_CODE:=$(call qstrip,$(CONFIG_VERSION_CODE))
|
||||
VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),r20007-6e54cb5d37)
|
||||
VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),$(REVISION))
|
||||
|
||||
VERSION_REPO:=$(call qstrip,$(CONFIG_VERSION_REPO))
|
||||
VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://downloads.immortalwrt.org/releases/21.02.6)
|
||||
VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://downloads.immortalwrt.org/releases/21.02-SNAPSHOT)
|
||||
|
||||
VERSION_DIST:=$(call qstrip,$(CONFIG_VERSION_DIST))
|
||||
VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),ImmortalWrt)
|
||||
|
||||
1
package/5G-Modem-Support
Submodule
1
package/5G-Modem-Support
Submodule
Submodule package/5G-Modem-Support added at 547c0005d6
@@ -92,6 +92,10 @@ $(curdir)/index: FORCE
|
||||
$(call ERROR_MESSAGE,WARNING: Applying padding in $$d/Packages to workaround usign SHA-512 bug!); \
|
||||
{ echo ""; echo ""; } >> Packages;; \
|
||||
esac; \
|
||||
echo -n '{"architecture": "$(ARCH_PACKAGES)", "packages":{' > index.json; \
|
||||
sed -n -e 's/^Package: \(.*\)$$/"\1":/p' -e 's/^Version: \(.*\)$$/"\1",/p' Packages | tr '\n' ' ' >> index.json; \
|
||||
echo '}}' >> index.json; \
|
||||
sed -i 's/, }}/}}/' index.json; \
|
||||
gzip -9nc Packages > Packages.gz; \
|
||||
); done
|
||||
ifdef CONFIG_SIGNED_PACKAGES
|
||||
|
||||
@@ -23,6 +23,7 @@ PKG_LICENSE:=GPL-2.0
|
||||
PKG_CONFIG_DEPENDS += \
|
||||
CONFIG_SIGNED_PACKAGES CONFIG_TARGET_INIT_PATH CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE \
|
||||
CONFIG_NAND_SUPPORT \
|
||||
CONFIG_EMMC_SUPPORT \
|
||||
CONFIG_CLEAN_IPKG \
|
||||
CONFIG_PER_FEED_REPO \
|
||||
$(foreach feed,$(FEEDS_AVAILABLE),CONFIG_FEED_$(feed))
|
||||
@@ -124,10 +125,18 @@ ifeq ($(CONFIG_NAND_SUPPORT),)
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EMMC_SUPPORT),)
|
||||
define Package/base-files/emmc-support
|
||||
rm -f $(1)/lib/upgrade/emmc.sh
|
||||
endef
|
||||
endif
|
||||
|
||||
|
||||
define Package/base-files/install
|
||||
$(CP) ./files/* $(1)/
|
||||
$(Package/base-files/install-key)
|
||||
$(Package/base-files/nand-support)
|
||||
$(Package/base-files/emmc-support)
|
||||
if [ -d $(GENERIC_PLATFORM_DIR)/base-files/. ]; then \
|
||||
$(CP) $(GENERIC_PLATFORM_DIR)/base-files/* $(1)/; \
|
||||
fi
|
||||
|
||||
@@ -313,6 +313,25 @@ find_mtd_part() {
|
||||
echo "${INDEX:+$PREFIX$INDEX}"
|
||||
}
|
||||
|
||||
find_mmc_part() {
|
||||
local DEVNAME PARTNAME ROOTDEV
|
||||
|
||||
if grep -q "$1" /proc/mtd; then
|
||||
echo "" && return 0
|
||||
fi
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
ROOTDEV="$2"
|
||||
else
|
||||
ROOTDEV="mmcblk*"
|
||||
fi
|
||||
|
||||
for DEVNAME in /sys/block/$ROOTDEV/mmcblk*p*; do
|
||||
PARTNAME="$(grep PARTNAME ${DEVNAME}/uevent | cut -f2 -d'=')"
|
||||
[ "$PARTNAME" = "$1" ] && echo "/dev/$(basename $DEVNAME)" && return 0
|
||||
done
|
||||
}
|
||||
|
||||
group_add() {
|
||||
local name="$1"
|
||||
local gid="$2"
|
||||
|
||||
@@ -48,6 +48,19 @@ caldata_extract_ubi() {
|
||||
caldata_die "failed to extract calibration data from $ubi"
|
||||
}
|
||||
|
||||
caldata_extract_mmc() {
|
||||
local part=$1
|
||||
local offset=$(($2))
|
||||
local count=$(($3))
|
||||
local mmc_part
|
||||
|
||||
mmc_part=$(find_mmc_part $part)
|
||||
[ -n "$mmc_part" ] || caldata_die "no mmc partition found for partition $part"
|
||||
|
||||
caldata_dd $mmc_part /lib/firmware/$FIRMWARE $count $offset || \
|
||||
caldata_die "failed to extract calibration data from $mmc_part"
|
||||
}
|
||||
|
||||
caldata_extract_reverse() {
|
||||
local part=$1
|
||||
local offset=$2
|
||||
|
||||
@@ -135,6 +135,15 @@ mtd_get_part_size() {
|
||||
done < /proc/mtd
|
||||
}
|
||||
|
||||
mmc_get_mac_binary() {
|
||||
local part_name="$1"
|
||||
local offset="$2"
|
||||
local part
|
||||
|
||||
part=$(find_mmc_part "$part_name")
|
||||
get_mac_binary "$part" "$offset"
|
||||
}
|
||||
|
||||
macaddr_add() {
|
||||
local mac=$1
|
||||
local val=$2
|
||||
@@ -145,6 +154,14 @@ macaddr_add() {
|
||||
echo $oui:$nic
|
||||
}
|
||||
|
||||
macaddr_generate_from_mmc_cid() {
|
||||
local mmc_dev=$1
|
||||
|
||||
local sd_hash=$(sha256sum /sys/class/block/$mmc_dev/device/cid)
|
||||
local mac_base=$(macaddr_canonicalize "$(echo "${sd_hash}" | dd bs=1 count=12 2>/dev/null)")
|
||||
echo "$(macaddr_unsetbit_mc "$(macaddr_setbit_la "${mac_base}")")"
|
||||
}
|
||||
|
||||
macaddr_geteui() {
|
||||
local mac=$1
|
||||
local sep=$2
|
||||
|
||||
@@ -135,6 +135,30 @@ get_magic_fat32() {
|
||||
(get_image "$@" | dd bs=1 count=5 skip=82) 2>/dev/null
|
||||
}
|
||||
|
||||
identify_magic_long() {
|
||||
local magic=$1
|
||||
case "$magic" in
|
||||
"55424923")
|
||||
echo "ubi"
|
||||
;;
|
||||
"31181006")
|
||||
echo "ubifs"
|
||||
;;
|
||||
"68737173")
|
||||
echo "squashfs"
|
||||
;;
|
||||
"d00dfeed")
|
||||
echo "fit"
|
||||
;;
|
||||
"4349"*)
|
||||
echo "combined"
|
||||
;;
|
||||
*)
|
||||
echo "unknown $magic"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
part_magic_efi() {
|
||||
local magic=$(get_magic_gpt "$@")
|
||||
[ "$magic" = "EFI PART" ]
|
||||
|
||||
67
package/base-files/files/lib/upgrade/emmc.sh
Normal file
67
package/base-files/files/lib/upgrade/emmc.sh
Normal file
@@ -0,0 +1,67 @@
|
||||
# Copyright (C) 2021 OpenWrt.org
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
emmc_upgrade_tar() {
|
||||
local tar_file="$1"
|
||||
[ "$CI_KERNPART" -a -z "$EMMC_KERN_DEV" ] && export EMMC_KERN_DEV="$(find_mmc_part $CI_KERNPART $CI_ROOTDEV)"
|
||||
[ "$CI_ROOTPART" -a -z "$EMMC_ROOT_DEV" ] && export EMMC_ROOT_DEV="$(find_mmc_part $CI_ROOTPART $CI_ROOTDEV)"
|
||||
[ "$CI_DATAPART" -a -z "$EMMC_DATA_DEV" ] && export EMMC_DATA_DEV="$(find_mmc_part $CI_DATAPART $CI_ROOTDEV)"
|
||||
local has_kernel
|
||||
local has_rootfs
|
||||
local board_dir=$(tar tf "$tar_file" | grep -m 1 '^sysupgrade-.*/$')
|
||||
board_dir=${board_dir%/}
|
||||
|
||||
tar tf "$tar_file" ${board_dir}/kernel 1>/dev/null 2>/dev/null && has_kernel=1
|
||||
tar tf "$tar_file" ${board_dir}/root 1>/dev/null 2>/dev/null && has_rootfs=1
|
||||
|
||||
[ "$has_kernel" = 1 -a "$EMMC_KERN_DEV" ] &&
|
||||
export EMMC_KERNEL_BLOCKS=$(($(tar xf "$tar_file" ${board_dir}/kernel -O | dd of="$EMMC_KERN_DEV" bs=512 2>&1 | grep "records out" | cut -d' ' -f1)))
|
||||
|
||||
[ "$has_rootfs" = 1 -a "$EMMC_ROOT_DEV" ] && {
|
||||
export EMMC_ROOTFS_BLOCKS=$(($(tar xf "$tar_file" ${board_dir}/root -O | dd of="$EMMC_ROOT_DEV" bs=512 2>&1 | grep "records out" | cut -d' ' -f1)))
|
||||
# Account for 64KiB ROOTDEV_OVERLAY_ALIGN in libfstools
|
||||
EMMC_ROOTFS_BLOCKS=$(((EMMC_ROOTFS_BLOCKS + 127) & ~127))
|
||||
}
|
||||
|
||||
if [ -z "$UPGRADE_BACKUP" ]; then
|
||||
if [ "$EMMC_DATA_DEV" ]; then
|
||||
dd if=/dev/zero of="$EMMC_DATA_DEV" bs=512 count=8
|
||||
elif [ "$EMMC_ROOTFS_BLOCKS" ]; then
|
||||
dd if=/dev/zero of="$EMMC_ROOT_DEV" bs=512 seek=$EMMC_ROOTFS_BLOCKS count=8
|
||||
elif [ "$EMMC_KERNEL_BLOCKS" ]; then
|
||||
dd if=/dev/zero of="$EMMC_KERN_DEV" bs=512 seek=$EMMC_KERNEL_BLOCKS count=8
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
emmc_upgrade_fit() {
|
||||
local fit_file="$1"
|
||||
[ "$CI_KERNPART" -a -z "$EMMC_KERN_DEV" ] && export EMMC_KERN_DEV="$(find_mmc_part $CI_KERNPART $CI_ROOTDEV)"
|
||||
|
||||
if [ "$EMMC_KERN_DEV" ]; then
|
||||
export EMMC_KERNEL_BLOCKS=$(($(get_image "$fit_file" | fwtool -i /dev/null -T - | dd of="$EMMC_KERN_DEV" bs=512 2>&1 | grep "records out" | cut -d' ' -f1)))
|
||||
|
||||
[ -z "$UPGRADE_BACKUP" ] && dd if=/dev/zero of="$EMMC_KERN_DEV" bs=512 seek=$EMMC_KERNEL_BLOCKS count=8
|
||||
fi
|
||||
}
|
||||
|
||||
emmc_copy_config() {
|
||||
if [ "$EMMC_DATA_DEV" ]; then
|
||||
dd if="$UPGRADE_BACKUP" of="$EMMC_DATA_DEV" bs=512
|
||||
elif [ "$EMMC_ROOTFS_BLOCKS" ]; then
|
||||
dd if="$UPGRADE_BACKUP" of="$EMMC_ROOT_DEV" bs=512 seek=$EMMC_ROOTFS_BLOCKS
|
||||
elif [ "$EMMC_KERNEL_BLOCKS" ]; then
|
||||
dd if="$UPGRADE_BACKUP" of="$EMMC_KERN_DEV" bs=512 seek=$EMMC_KERNEL_BLOCKS
|
||||
fi
|
||||
}
|
||||
|
||||
emmc_do_upgrade() {
|
||||
local file_type=$(identify_magic_long "$(get_magic_long "$1")")
|
||||
|
||||
case "$file_type" in
|
||||
"fit") emmc_upgrade_fit $1;;
|
||||
*) emmc_upgrade_tar $1;;
|
||||
esac
|
||||
}
|
||||
@@ -63,37 +63,12 @@ get_magic_long_tar() {
|
||||
( tar xf $1 $2 -O | dd bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2> /dev/null
|
||||
}
|
||||
|
||||
identify_magic() {
|
||||
local magic=$1
|
||||
case "$magic" in
|
||||
"55424923")
|
||||
echo "ubi"
|
||||
;;
|
||||
"31181006")
|
||||
echo "ubifs"
|
||||
;;
|
||||
"68737173")
|
||||
echo "squashfs"
|
||||
;;
|
||||
"d00dfeed")
|
||||
echo "fit"
|
||||
;;
|
||||
"4349"*)
|
||||
echo "combined"
|
||||
;;
|
||||
*)
|
||||
echo "unknown $magic"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
identify() {
|
||||
identify_magic $(nand_get_magic_long "$1" "${2:-0}")
|
||||
identify_magic_long $(nand_get_magic_long "$1" "${2:-0}")
|
||||
}
|
||||
|
||||
identify_tar() {
|
||||
identify_magic $(get_magic_long_tar "$1" "$2")
|
||||
identify_magic_long $(get_magic_long_tar "$1" "$2")
|
||||
}
|
||||
|
||||
nand_restore_config() {
|
||||
|
||||
@@ -183,7 +183,7 @@ if VERSIONOPT
|
||||
config VERSION_REPO
|
||||
string
|
||||
prompt "Release repository"
|
||||
default "https://downloads.immortalwrt.org/releases/21.02.6"
|
||||
default "https://downloads.immortalwrt.org/releases/21.02-SNAPSHOT"
|
||||
help
|
||||
This is the repository address embedded in the image, it defaults
|
||||
to the trunk snapshot repo; the url may contain the following placeholders:
|
||||
@@ -259,7 +259,7 @@ if VERSIONOPT
|
||||
config VERSION_CODE_FILENAMES
|
||||
bool
|
||||
prompt "Revision code in filenames"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Enable this to include the revision identifier or the configured
|
||||
version code into the firmware image, SDK- and Image Builder archive
|
||||
|
||||
@@ -10,6 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=at91bootstrap
|
||||
PKG_VERSION:=v3.9.3
|
||||
PKG_CPE_ID:=cpe:/a:linux4sam:at91bootstrap
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
@@ -7,9 +7,9 @@ PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://git.openwrt.org/project/bcm63xx/u-boot.git
|
||||
PKG_SOURCE_DATE:=2022-03-15
|
||||
PKG_SOURCE_VERSION:=0625aad74d1f5b6f9c068955ad3fd7f6df635e50
|
||||
PKG_MIRROR_HASH:=0602e0e4f101ead206940eccca832b75191905c1e81290340a89b07dbee7a6ce
|
||||
PKG_SOURCE_DATE:=2022-12-08
|
||||
PKG_SOURCE_VERSION:=4435700d18a791dca0d8d767e5414dfac9df4451
|
||||
PKG_MIRROR_HASH:=6062ce611d7222eb3b9768bb4944ff1c7bcf26b997280adf5ea8d7afe83f28a8
|
||||
|
||||
include $(INCLUDE_DIR)/u-boot.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@@ -61,6 +61,7 @@ MAKE_FLAGS += \
|
||||
define Package/uboot-envtools/conffiles
|
||||
/etc/config/ubootenv
|
||||
/etc/fw_env.config
|
||||
/etc/fw_sys.config
|
||||
endef
|
||||
|
||||
define Package/uboot-envtools/install
|
||||
|
||||
@@ -18,15 +18,21 @@ zyxel,gs1900-10hp)
|
||||
idx="$(find_mtd_index u-boot-env)"
|
||||
[ -n "$idx" ] && \
|
||||
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x400" "0x10000"
|
||||
idx2="$(find_mtd_index u-boot-env2)"
|
||||
[ -n "$idx2" ] && \
|
||||
ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x1000" "0x10000"
|
||||
;;
|
||||
*)
|
||||
idx="$(find_mtd_index u-boot-env)"
|
||||
[ -n "$idx" ] && \
|
||||
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000"
|
||||
idx2="$(find_mtd_index u-boot-env2)"
|
||||
[ -n "$idx2" ] && \
|
||||
ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x1000" "0x10000"
|
||||
;;
|
||||
esac
|
||||
|
||||
config_load ubootenv
|
||||
config_foreach ubootenv_add_app_config ubootenv
|
||||
config_foreach ubootenv_add_app_config
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -3,34 +3,44 @@
|
||||
# Copyright (C) 2011-2012 OpenWrt.org
|
||||
#
|
||||
|
||||
ubootenv_add_uci_config() {
|
||||
local dev=$1
|
||||
local offset=$2
|
||||
local envsize=$3
|
||||
local secsize=$4
|
||||
local numsec=$5
|
||||
_ubootenv_add_uci_config() {
|
||||
local cfgtype=$1
|
||||
local dev=$2
|
||||
local offset=$3
|
||||
local envsize=$4
|
||||
local secsize=$5
|
||||
local numsec=$6
|
||||
uci batch <<EOF
|
||||
add ubootenv ubootenv
|
||||
set ubootenv.@ubootenv[-1].dev='$dev'
|
||||
set ubootenv.@ubootenv[-1].offset='$offset'
|
||||
set ubootenv.@ubootenv[-1].envsize='$envsize'
|
||||
set ubootenv.@ubootenv[-1].secsize='$secsize'
|
||||
set ubootenv.@ubootenv[-1].numsec='$numsec'
|
||||
add ubootenv $cfgtype
|
||||
set ubootenv.@$cfgtype[-1].dev='$dev'
|
||||
set ubootenv.@$cfgtype[-1].offset='$offset'
|
||||
set ubootenv.@$cfgtype[-1].envsize='$envsize'
|
||||
set ubootenv.@$cfgtype[-1].secsize='$secsize'
|
||||
set ubootenv.@$cfgtype[-1].numsec='$numsec'
|
||||
EOF
|
||||
uci commit ubootenv
|
||||
}
|
||||
|
||||
ubootenv_add_uci_config() {
|
||||
_ubootenv_add_uci_config "ubootenv" "$@"
|
||||
}
|
||||
|
||||
ubootenv_add_uci_sys_config() {
|
||||
_ubootenv_add_uci_config "ubootsys" "$@"
|
||||
}
|
||||
|
||||
ubootenv_add_app_config() {
|
||||
local cfgtype
|
||||
local dev
|
||||
local offset
|
||||
local envsize
|
||||
local secsize
|
||||
local numsec
|
||||
config_get cfgtype "$1" TYPE
|
||||
config_get dev "$1" dev
|
||||
config_get offset "$1" offset
|
||||
config_get envsize "$1" envsize
|
||||
config_get secsize "$1" secsize
|
||||
config_get numsec "$1" numsec
|
||||
grep -q "^[[:space:]]*${dev}[[:space:]]*${offset}" /etc/fw_env.config || echo "$dev $offset $envsize $secsize $numsec" >>/etc/fw_env.config
|
||||
grep -q "^[[:space:]]*${dev}[[:space:]]*${offset}" "/etc/fw_${cfgtype#uboot}.config" || echo "$dev $offset $envsize $secsize $numsec" >>"/etc/fw_${cfgtype#uboot}.config"
|
||||
}
|
||||
|
||||
|
||||
@@ -22,18 +22,21 @@ start() {
|
||||
uci set network.@globals[0].packet_steering="1"
|
||||
uci commit network
|
||||
|
||||
for i in $(ip address | awk -F ': ' '/eth[0-9]+/ {print $2}' | xargs)
|
||||
for i in $(ip address | awk -F ': ' '/eth[0-9]+/ {print $2}' | grep -v '@' | xargs)
|
||||
do
|
||||
{
|
||||
ethtool -K "$i" rx-checksum on
|
||||
ethtool -K "$i" tx-checksum-ip-generic on || {
|
||||
ethtool -K "$i" tx-checksum-ipv4 on
|
||||
ethtool -K "$i" tx-checksum-ipv6 on
|
||||
}
|
||||
ethtool -K "$i" tx-scatter-gather on
|
||||
ethtool -K "$i" gso on
|
||||
ethtool -K "$i" tso on
|
||||
ethtool -K "$i" ufo on
|
||||
ethtool -K "$i" rx-checksum on
|
||||
ethtool -K "$i" tx-checksum-ip-generic on || {
|
||||
ethtool -K "$i" tx-checksum-ipv4 on
|
||||
ethtool -K "$i" tx-checksum-ipv6 on
|
||||
}
|
||||
ethtool -K "$i" tx-scatter-gather on
|
||||
ethtool -K "$i" gso on
|
||||
ethtool -K "$i" tso on
|
||||
ethtool -K "$i" ufo on
|
||||
|
||||
if ethtool -i "$i" | grep -q "driver: igc"; then
|
||||
ethtool -G "$i" rx "$(ethtool -g "$i" | awk '/^RX:/ {print $2; exit}')"
|
||||
ethtool -G "$i" tx "$(ethtool -g "$i" | awk '/^TX:/ {print $2; exit}')"
|
||||
fi
|
||||
done
|
||||
} >"/dev/null" 2>&1
|
||||
|
||||
@@ -22,6 +22,7 @@ define Package/default-settings
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
TITLE:=LuCI support for Default Settings
|
||||
DEPENDS:=+luci
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+luci-lib-base
|
||||
endef
|
||||
|
||||
@@ -1,28 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci set luci.main.lang=auto
|
||||
uci commit luci
|
||||
uci -q get system.@imm_init[0] > "/dev/null" || uci -q add system imm_init > "/dev/null"
|
||||
|
||||
uci set fstab.@global[0].anon_mount=1
|
||||
uci commit fstab
|
||||
if ! uci -q get system.@imm_init[0].lang > "/dev/null"; then
|
||||
uci -q set luci.main.lang="auto"
|
||||
uci -q commit luci
|
||||
|
||||
rm -f /www/luci-static/resources/view/status/include/50_dsl.js
|
||||
rm -f /www/luci-static/resources/view/status/include/70_ddns.js
|
||||
rm -f /www/luci-static/resources/view/status/include/80_minidlna.js
|
||||
rm -f /www/luci-static/resources/view/status/include/80_upnp.js
|
||||
uci -q set system.@imm_init[0].lang="1"
|
||||
uci -q commit system
|
||||
fi
|
||||
|
||||
ln -sf /sbin/ip /usr/bin/ip
|
||||
if ! uci -q get system.@imm_init[0].anon_mount > "/dev/null"; then
|
||||
uci -q set fstab.@global[0].anon_mount="1"
|
||||
uci -q commit fstab
|
||||
|
||||
[ -f '/bin/bash' ] && sed -i 's|root:x:0:0:root:/root:/bin/ash|root:x:0:0:root:/root:/bin/bash|g' /etc/passwd
|
||||
uci -q set system.@imm_init[0].anon_mount="1"
|
||||
uci -q commit system
|
||||
fi
|
||||
|
||||
sed -i '/option disabled/d' /etc/config/wireless
|
||||
sed -i '/set wireless.radio${devidx}.disabled/d' /lib/wifi/mac80211.sh
|
||||
wifi up
|
||||
ln -sf "/sbin/ip" "/usr/bin/ip"
|
||||
|
||||
sed -i '/log-facility/d' /etc/dnsmasq.conf
|
||||
echo 'log-facility=/dev/null' >> /etc/dnsmasq.conf
|
||||
[ ! -e "/bin/bash" ] || sed -i "s|root:x:0:0:root:/root:/bin/ash|root:x:0:0:root:/root:/bin/bash|g" "/etc/passwd"
|
||||
|
||||
rm -rf /tmp/luci-modulecache/
|
||||
rm -f /tmp/luci-indexcache
|
||||
sed -i "/log-facility/d" "/etc/dnsmasq.conf"
|
||||
echo "log-facility=/dev/null" >> "/etc/dnsmasq.conf"
|
||||
|
||||
rm -rf "/tmp/luci-modulecache"
|
||||
rm -f "/tmp/luci-indexcache"
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF
|
||||
set system.@system[0].timezone='CST-8'
|
||||
set system.@system[0].zonename='Asia/Shanghai'
|
||||
uci -q get system.@imm_init[0] > "/dev/null" || uci -q add system imm_init > "/dev/null"
|
||||
|
||||
delete system.ntp.server
|
||||
add_list system.ntp.server='ntp.tencent.com'
|
||||
add_list system.ntp.server='ntp1.aliyun.com'
|
||||
add_list system.ntp.server='ntp.ntsc.ac.cn'
|
||||
add_list system.ntp.server='cn.ntp.org.cn'
|
||||
EOF
|
||||
uci commit system
|
||||
if ! uci -q get system.@imm_init[0].system_chn > "/dev/null"; then
|
||||
uci -q batch <<-EOF
|
||||
set system.@system[0].timezone="CST-8"
|
||||
set system.@system[0].zonename="Asia/Shanghai"
|
||||
|
||||
sed -i 's,downloads.immortalwrt.org,mirrors.vsean.net/openwrt,g' /etc/opkg/distfeeds.conf
|
||||
delete system.ntp.server
|
||||
add_list system.ntp.server="ntp.tencent.com"
|
||||
add_list system.ntp.server="ntp1.aliyun.com"
|
||||
add_list system.ntp.server="ntp.ntsc.ac.cn"
|
||||
add_list system.ntp.server="cn.ntp.org.cn"
|
||||
|
||||
set system.@imm_init[0].system_chn="1"
|
||||
commit system
|
||||
EOF
|
||||
fi
|
||||
|
||||
sed -i.bak "s,downloads.immortalwrt.org,mirrors.vsean.net/openwrt,g" "/etc/opkg/distfeeds.conf"
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
|
||||
if [ "$ACTION" != "ifup" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
config_load network
|
||||
config_get tunnelid $INTERFACE tunnelid
|
||||
config_get username $INTERFACE username
|
||||
config_get password $INTERFACE password
|
||||
config_get tunnelid "$INTERFACE" tunnelid
|
||||
config_get username "$INTERFACE" username
|
||||
config_get password "$INTERFACE" password
|
||||
|
||||
if [ "$tunnelid" != "" ]; then
|
||||
wget -O - https://$username:$password@ipv4.tunnelbroker.net/nic/update?hostname=$tunnelid --no-check-certificate
|
||||
wget -O - "https://$username:$password@ipv4.tunnelbroker.net/nic/update?hostname=$tunnelid"
|
||||
fi
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci set dhcp.lan.ra='hybrid'
|
||||
uci set dhcp.lan.ndp='hybrid'
|
||||
uci set dhcp.lan.dhcpv6='hybrid'
|
||||
uci set dhcp.lan.ra_management='1'
|
||||
uci commit dhcp
|
||||
uci -q get system.@imm_init[0] > "/dev/null" || uci -q add system imm_init > "/dev/null"
|
||||
uci -q get system.@imm_init[0].ipv6 > "/dev/null" && exit 0
|
||||
|
||||
uci -q set dhcp.lan.ra="hybrid"
|
||||
uci -q set dhcp.lan.ndp="hybrid"
|
||||
uci -q set dhcp.lan.dhcpv6="hybrid"
|
||||
uci -q set dhcp.lan.ra_management="1"
|
||||
uci -q commit dhcp
|
||||
|
||||
uci -q set system.@imm_init[0].ipv6="1"
|
||||
uci -q commit system
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=intel-microcode
|
||||
PKG_VERSION:=20220809
|
||||
PKG_VERSION:=20230808
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=intel-microcode_3.$(PKG_VERSION).1.tar.xz
|
||||
PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/non-free/i/intel-microcode/
|
||||
PKG_HASH:=4cf6c3638bb52d9d45c1916af866fd0929628a6f459daac3edfd369149e9c665
|
||||
PKG_SOURCE_URL:=@DEBIAN/pool/non-free-firmware/i/intel-microcode/
|
||||
PKG_HASH:=29e77c275b3f60a691832c0844f70effbd94a4594d04af21e0c2e6e0c1ac1894
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/intel-microcode-3.$(PKG_VERSION).1
|
||||
PKG_CPE_ID:=cpe:/a:intel:microcode
|
||||
|
||||
PKG_BUILD_DEPENDS:=iucode-tool/host
|
||||
|
||||
|
||||
@@ -7,6 +7,13 @@ define Package/ibt-firmware/install
|
||||
endef
|
||||
$(eval $(call BuildPackage,ibt-firmware))
|
||||
|
||||
Package/iwlwifi-firmware-ax200 = $(call Package/firmware-default,Intel AX200 firmware)
|
||||
define Package/iwlwifi-firmware-ax200/install
|
||||
$(INSTALL_DIR) $(1)/lib/firmware
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/iwlwifi-cc-a0-62.ucode $(1)/lib/firmware
|
||||
endef
|
||||
$(eval $(call BuildPackage,iwlwifi-firmware-ax200))
|
||||
|
||||
Package/iwl3945-firmware = $(call Package/firmware-default,Intel IWL3945 firmware)
|
||||
define Package/iwl3945-firmware/install
|
||||
$(INSTALL_DIR) $(1)/lib/firmware
|
||||
|
||||
@@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=i40e
|
||||
PKG_VERSION:=2.22.18
|
||||
PKG_VERSION:=2.23.17
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/e1000/i40e%20stable/$(PKG_VERSION)/
|
||||
PKG_HASH:=ba3fed07b178bc78bfeab3ba309f812243cbc88032333edca891eb74022468f6
|
||||
PKG_HASH:=7d5a107a49e0c2cede2facba93086dde6fa5cbf529a92dbe57c5407b62d3c31d
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
|
||||
28
package/kernel/i40e/patches/100-dcb-condition.patch
Normal file
28
package/kernel/i40e/patches/100-dcb-condition.patch
Normal file
@@ -0,0 +1,28 @@
|
||||
--- a/src/i40e_virtchnl_pf.c
|
||||
+++ b/src/i40e_virtchnl_pf.c
|
||||
@@ -6661,7 +6661,6 @@ int i40e_get_vf_stats(struct net_device
|
||||
#endif /* HAVE_VF_STATS */
|
||||
#endif /* IFLA_VF_MAX */
|
||||
#ifdef HAVE_NDO_SET_VF_LINK_STATE
|
||||
-#ifdef CONFIG_DCB
|
||||
#ifdef CONFIG_PCI_IOV
|
||||
/**
|
||||
* i40e_configure_vf_link
|
||||
@@ -6739,6 +6738,7 @@ error_out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
+#ifdef CONFIG_DCB
|
||||
/**
|
||||
* i40e_enable_vf_queues
|
||||
* @vsi: PCI device information struct
|
||||
@@ -6792,8 +6792,8 @@ int i40e_enable_vf_queues(struct i40e_vs
|
||||
err_out:
|
||||
return ret;
|
||||
}
|
||||
-#endif /* PCI_IOV */
|
||||
#endif /* CONFIG_DCB */
|
||||
+#endif /* PCI_IOV */
|
||||
/**
|
||||
* i40e_get_vlan_anti_spoof
|
||||
* @pdev: PCI device information struct
|
||||
@@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=iavf
|
||||
PKG_VERSION:=4.8.2
|
||||
PKG_VERSION:=4.9.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/e1000/iavf%20stable/$(PKG_VERSION)/
|
||||
PKG_HASH:=78d986de9667f260e806a3d0962dfee32ac35a686a672c15c209a29252d42d48
|
||||
PKG_HASH:=6bf25bd7179b5bca1b10168f57ca4ce9fe54d08574e8d7613fad7c15800c7f71
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
|
||||
55
package/kernel/ice/Makefile
Normal file
55
package/kernel/ice/Makefile
Normal file
@@ -0,0 +1,55 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Copyright (C) 2023 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=ice
|
||||
PKG_VERSION:=1.12.6
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/e1000/ice%20stable/$(PKG_VERSION)/
|
||||
PKG_HASH:=55a7fb96c516c178180e07451beb621997148301f1b1be0bc52bf970850bc5cc
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/ice-vendor
|
||||
SUBMENU:=Network Devices
|
||||
TITLE:=Intel(R) Ethernet Controller E810 Family support (vendor driver)
|
||||
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
|
||||
DEPENDS:=@PCI_SUPPORT +kmod-ptp @TARGET_x86
|
||||
CONFLICTS:=kmod-ice
|
||||
FILES:=$(PKG_BUILD_DIR)/src/ice.ko
|
||||
AUTOLOAD:=$(call AutoProbe,ice)
|
||||
endef
|
||||
|
||||
define KernelPackage/ice-vendor/description
|
||||
Kernel modules for Intel(R) Ethernet Controller E810 Series
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
( \
|
||||
pushd $(PKG_BUILD_DIR)/src ; \
|
||||
KSRC=$(LINUX_DIR) \
|
||||
OUT=kcompat_generated_defs.h \
|
||||
CONFFILE=$(LINUX_DIR)/include/generated/autoconf.h \
|
||||
bash kcompat-generator.sh ; \
|
||||
popd ; \
|
||||
)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
+$(KERNEL_MAKE) $(PKG_JOBS) \
|
||||
M=$(PKG_BUILD_DIR)/src \
|
||||
modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,ice-vendor))
|
||||
@@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=igb
|
||||
PKG_VERSION:=5.13.16
|
||||
PKG_VERSION:=5.14.16
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/e1000/igb%20stable/$(PKG_VERSION)/
|
||||
PKG_HASH:=23731b9d3630e20ecdbe6c5db06475f07c8b2d080a374635550957747db96183
|
||||
PKG_HASH:=59969b19ce0286f4dc8143895ecff16ac18de30e71a5afc8ed73cc16af219db3
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
|
||||
@@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=ixgbe
|
||||
PKG_VERSION:=5.18.11
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=5.19.6
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/e1000/ixgbe%20stable/$(PKG_VERSION)/
|
||||
PKG_HASH:=4ca9cc8d9041b8c9b4fdbbab4fe079e5da422fa1697ca5a58ebfa95d21e62daa
|
||||
PKG_HASH:=a844f1fea8064e30b276792455c3b286c1d7af26731e8f865d4a4e9ed1dcf4ab
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
@@ -35,6 +35,17 @@ define KernelPackage/ixgbe-vendor/description
|
||||
Kernel modules for Intel(R) 82598/82599 PCI-Express 10 Gigabit Ethernet adapters.
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
( \
|
||||
pushd $(PKG_BUILD_DIR)/src ; \
|
||||
KSRC=$(LINUX_DIR) \
|
||||
OUT=kcompat_generated_defs.h \
|
||||
CONFFILE=$(LINUX_DIR)/include/generated/autoconf.h \
|
||||
bash kcompat-generator.sh ; \
|
||||
popd ; \
|
||||
)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
+$(KERNEL_MAKE) $(PKG_JOBS) \
|
||||
M=$(PKG_BUILD_DIR)/src \
|
||||
|
||||
11
package/kernel/ixgbe/patches/010-VXLAN_HEADROOM-header.patch
Normal file
11
package/kernel/ixgbe/patches/010-VXLAN_HEADROOM-header.patch
Normal file
@@ -0,0 +1,11 @@
|
||||
--- a/src/ixgbe_main.c
|
||||
+++ b/src/ixgbe_main.c
|
||||
@@ -9869,7 +9869,7 @@ static void ixgbe_atr(struct ixgbe_ring
|
||||
struct ixgbe_adapter *adapter = q_vector->adapter;
|
||||
|
||||
if (unlikely(skb_tail_pointer(skb) < hdr.network +
|
||||
- VXLAN_HEADROOM))
|
||||
+ vxlan_headroom(0)))
|
||||
return;
|
||||
|
||||
/* verify the port is recognized as VXLAN or GENEVE*/
|
||||
@@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=ixgbevf
|
||||
PKG_VERSION:=4.17.11
|
||||
PKG_VERSION:=4.18.7
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/e1000/ixgbevf%20stable/$(PKG_VERSION)/
|
||||
PKG_HASH:=59813a6f92e699b4cb6983b70b91137eece4609a113fa7bb60db0be9889d2b46
|
||||
PKG_HASH:=90f6cd614008839b6fc748ae0f4ad3503435f8b788318d4f40cfc83c7029025e
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_LICENSE:=GPL-2.0-only
|
||||
@@ -35,6 +35,17 @@ define KernelPackage/ixgbevf-vendor/description
|
||||
Kernel modules for Intel(R) 82599 Virtual Function Ethernet adapters.
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
( \
|
||||
pushd $(PKG_BUILD_DIR)/src ; \
|
||||
KSRC=$(LINUX_DIR) \
|
||||
OUT=kcompat_generated_defs.h \
|
||||
CONFFILE=$(LINUX_DIR)/include/generated/autoconf.h \
|
||||
bash kcompat-generator.sh ; \
|
||||
popd ; \
|
||||
)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
+$(KERNEL_MAKE) $(PKG_JOBS) \
|
||||
M=$(PKG_BUILD_DIR)/src \
|
||||
|
||||
@@ -744,6 +744,22 @@ endef
|
||||
$(eval $(call KernelPackage,iavf))
|
||||
|
||||
|
||||
define KernelPackage/ice
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Intel(R) Ethernet Controller E810 Series support
|
||||
DEPENDS:=@PCI_SUPPORT +kmod-ptp
|
||||
KCONFIG:=CONFIG_ICE
|
||||
FILES:=$(LINUX_DIR)/drivers/net/ethernet/intel/ice/ice.ko
|
||||
AUTOLOAD:=$(call AutoProbe,ice)
|
||||
endef
|
||||
|
||||
define KernelPackage/ice/description
|
||||
Kernel modules for Intel(R) Ethernet Controller E810 Series
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,ice))
|
||||
|
||||
|
||||
define KernelPackage/b44
|
||||
TITLE:=Broadcom 44xx driver
|
||||
KCONFIG:=CONFIG_B44
|
||||
@@ -1180,12 +1196,13 @@ define KernelPackage/mlx5-core
|
||||
CONFIG_MLX5_EN_IPSEC=n \
|
||||
CONFIG_MLX5_EN_RXNFC=y \
|
||||
CONFIG_MLX5_EN_TLS=n \
|
||||
CONFIG_MLX5_ESWITCH=n \
|
||||
CONFIG_MLX5_ESWITCH=y \
|
||||
CONFIG_MLX5_FPGA=n \
|
||||
CONFIG_MLX5_FPGA_IPSEC=n \
|
||||
CONFIG_MLX5_FPGA_TLS=n \
|
||||
CONFIG_MLX5_MPFS=y \
|
||||
CONFIG_MLX5_SW_STEERING=n \
|
||||
CONFIG_MLX5_CLS_ACT=n \
|
||||
CONFIG_MLX5_TC_CT=n \
|
||||
CONFIG_MLX5_TLS=n
|
||||
AUTOLOAD:=$(call AutoProbe,mlx5_core)
|
||||
@@ -1198,6 +1215,50 @@ endef
|
||||
$(eval $(call KernelPackage,mlx5-core))
|
||||
|
||||
|
||||
define KernelPackage/qlcnic
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
DEPENDS:=@PCI_SUPPORT +kmod-hwmon-core
|
||||
TITLE:=QLogic QLE8240 and QLE8242 device support
|
||||
KCONFIG:= \
|
||||
CONFIG_QLCNIC \
|
||||
CONFIG_QLCNIC_HWMON=y \
|
||||
CONFIG_QLCNIC_SRIOV=y
|
||||
FILES:=$(LINUX_DIR)/drivers/net/ethernet/qlogic/qlcnic/qlcnic.ko
|
||||
AUTOLOAD:=$(call AutoProbe,qlcnic)
|
||||
endef
|
||||
|
||||
define KernelPackage/qlcnic/description
|
||||
This driver supports QLogic QLE8240 and QLE8242 Converged Ethernet
|
||||
devices.
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,qlcnic))
|
||||
|
||||
|
||||
define KernelPackage/qede
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
DEPENDS:=@PCI_SUPPORT +kmod-ptp +kmod-lib-crc8 +kmod-lib-zlib-inflate
|
||||
TITLE:=QLogic FastLinQ 10/25/40/100Gb Ethernet NIC device support
|
||||
KCONFIG:= \
|
||||
CONFIG_QED \
|
||||
CONFIG_QED_SRIOV=y \
|
||||
CONFIG_QEDE \
|
||||
CONFIG_QEDF=n \
|
||||
CONFIG_QEDI=n
|
||||
FILES:= \
|
||||
$(LINUX_DIR)/drivers/net/ethernet/qlogic/qed/qed.ko \
|
||||
$(LINUX_DIR)/drivers/net/ethernet/qlogic/qede/qede.ko
|
||||
AUTOLOAD:=$(call AutoProbe,qed qede)
|
||||
endef
|
||||
|
||||
define KernelPackage/qede/description
|
||||
This driver supports QLogic FastLinQ 25/40/100Gb Ethernet NIC
|
||||
devices.
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,qede))
|
||||
|
||||
|
||||
define KernelPackage/sfp
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=SFP cage support
|
||||
|
||||
@@ -174,7 +174,7 @@ detect_mac80211() {
|
||||
set wireless.radio${devidx}.channel=${channel}
|
||||
set wireless.radio${devidx}.band=${mode_band}
|
||||
set wireless.radio${devidx}.htmode=$htmode
|
||||
set wireless.radio${devidx}.country=US
|
||||
set wireless.radio${devidx}.country=CN
|
||||
set wireless.radio${devidx}.disabled=0
|
||||
|
||||
set wireless.default_radio${devidx}=wifi-iface
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From: Chukun Pan <amadeus@jmu.edu.cn>
|
||||
To: Jakub Kicinski <kubakici@wp.pl>
|
||||
Cc: Kalle Valo <kvalo@kernel.org>,
|
||||
"David S . Miller" <davem@davemloft.net>,
|
||||
Eric Dumazet <edumazet@google.com>,
|
||||
Paolo Abeni <pabeni@redhat.com>,
|
||||
Matthias Brugger <matthias.bgg@gmail.com>,
|
||||
Lintel Huang <lintel.huang@gmail.com>,
|
||||
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
|
||||
linux-kernel@vger.kernel.org, Chukun Pan <amadeus@jmu.edu.cn>
|
||||
Subject: [PATCH] wifi: mt7601u: Add AP mode support
|
||||
Date: Tue, 26 Jul 2022 00:16:03 +0800 [thread overview]
|
||||
Message-ID: <20220725161603.15201-1-amadeus@jmu.edu.cn> (raw)
|
||||
|
||||
Add AP mode support to mt7601u chipset.
|
||||
Simply tested it with firmware version
|
||||
201302052146 and it seems working fine.
|
||||
|
||||
Run-tested-by: Lintel Huang <lintel.huang@gmail.com>
|
||||
Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
|
||||
---
|
||||
drivers/net/wireless/mediatek/mt7601u/init.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/wireless/mediatek/mt7601u/init.c
|
||||
+++ b/drivers/net/wireless/mediatek/mt7601u/init.c
|
||||
@@ -609,7 +609,8 @@ int mt7601u_register_device(struct mt760
|
||||
SET_IEEE80211_PERM_ADDR(hw, dev->macaddr);
|
||||
|
||||
wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR;
|
||||
- wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
|
||||
+ wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
|
||||
+ BIT(NL80211_IFTYPE_AP);
|
||||
wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS;
|
||||
|
||||
wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
|
||||
22
package/kernel/r8152/patches/010-kernel-5.4.252.patch
Normal file
22
package/kernel/r8152/patches/010-kernel-5.4.252.patch
Normal file
@@ -0,0 +1,22 @@
|
||||
--- a/compatibility.h
|
||||
+++ b/compatibility.h
|
||||
@@ -21,7 +21,6 @@
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) */
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) */
|
||||
|
||||
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0)
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0)
|
||||
#define PHY_MAC_INTERRUPT PHY_IGNORE_INTERRUPT
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0)
|
||||
@@ -608,11 +607,6 @@
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0) */
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0) */
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0) */
|
||||
- static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|
||||
- {
|
||||
- memcpy(dev->dev_addr, addr, 6);
|
||||
- }
|
||||
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0) */
|
||||
|
||||
#ifndef FALSE
|
||||
#define TRUE 1
|
||||
21
package/kernel/rtl8189es/patches/030-kernel-5.4.252.patch
Normal file
21
package/kernel/rtl8189es/patches/030-kernel-5.4.252.patch
Normal file
@@ -0,0 +1,21 @@
|
||||
--- a/include/osdep_service_linux.h
|
||||
+++ b/include/osdep_service_linux.h
|
||||
@@ -220,18 +220,6 @@ typedef void *timer_hdl_context;
|
||||
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
|
||||
#endif
|
||||
|
||||
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
|
||||
-/* Porting from linux kernel commits
|
||||
-48eab831ae8b9f7002a533fa4235eed63ea1f1a3
|
||||
-3f6cffb8604b537e3d7ea040d7f4368689638eaf
|
||||
-adeef3e32146a8d2a73c399dc6f5d76a449131b1
|
||||
-*/
|
||||
-static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|
||||
-{
|
||||
- memcpy(dev->dev_addr, addr, ETH_ALEN);
|
||||
-}
|
||||
-#endif
|
||||
-
|
||||
typedef unsigned long systime;
|
||||
typedef struct tasklet_struct _tasklet;
|
||||
|
||||
17
package/kernel/rtl8192eu/patches/040-kernel-5.4.252.patch
Normal file
17
package/kernel/rtl8192eu/patches/040-kernel-5.4.252.patch
Normal file
@@ -0,0 +1,17 @@
|
||||
--- a/include/osdep_service_linux.h
|
||||
+++ b/include/osdep_service_linux.h
|
||||
@@ -217,14 +217,6 @@ typedef void *timer_hdl_context;
|
||||
|
||||
typedef unsigned long systime;
|
||||
|
||||
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
|
||||
-/* Porting from linux kernel v5.15-rc1 48eab831ae8b9f7002a533fa4235eed63ea1f1a3 */
|
||||
-static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr)
|
||||
-{
|
||||
- memcpy(dev->dev_addr, addr, ETH_ALEN);
|
||||
-}
|
||||
-#endif
|
||||
-
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22))
|
||||
/* Porting from linux kernel, for compatible with old kernel. */
|
||||
static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
|
||||
@@ -19,6 +19,7 @@ PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
PKG_CPE_ID:=cpe:/a:gmplib:gmp
|
||||
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ PKG_HASH:=34b8adc726883d0e85b3118fa13605e179a62b31ba51f676136ecb2d0bc1a887
|
||||
|
||||
PKG_LICENSE:=BSD-4-Clause
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
PKG_CPE_ID:=cpe:/a:freedesktop:libbsd
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
@@ -18,6 +18,7 @@ PKG_HASH:=0cd13be008923528687af6c6b860f35392d49251c04ee0648282d36b1faec1cf
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
PKG_CPE_ID:=cpe:/a:netfilter:libnetfilter_conntrack
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
@@ -16,6 +16,7 @@ PKG_SOURCE_URL:=http://www.tcpdump.org/release/
|
||||
PKG_HASH:=635237637c5b619bcceba91900666b64d56ecb7be63f298f601ec786ce087094
|
||||
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
PKG_CPE_ID:=cpe:/a:tcpdump:libpcap
|
||||
|
||||
PKG_ASLR_PIE_REGULAR:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
@@ -9,9 +9,9 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=openssl
|
||||
PKG_BASE:=1.1.1
|
||||
PKG_BUGFIX:=t
|
||||
PKG_BUGFIX:=w
|
||||
PKG_VERSION:=$(PKG_BASE)$(PKG_BUGFIX)
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
ENGINES_DIR=engines-1.1
|
||||
|
||||
@@ -28,7 +28,7 @@ PKG_SOURCE_URL:= \
|
||||
ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/ \
|
||||
ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/old/$(PKG_BASE)/
|
||||
|
||||
PKG_HASH:=8dee9b24bdb1dcbf0c3d1e9b02fb8f6bf22165e807f45adeb7c9677536859d3b
|
||||
PKG_HASH:=cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8
|
||||
|
||||
PKG_LICENSE:=OpenSSL
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
@@ -338,6 +338,7 @@ define Build/Configure
|
||||
--libdir=lib \
|
||||
--openssldir=/etc/ssl \
|
||||
--cross-compile-prefix="$(TARGET_CROSS)" \
|
||||
$(TARGET_CFLAGS) \
|
||||
$(TARGET_CPPFLAGS) \
|
||||
$(TARGET_LDFLAGS) \
|
||||
$(OPENSSL_OPTIONS) && \
|
||||
|
||||
@@ -1,214 +0,0 @@
|
||||
From 879f7080d7e141f415c79eaa3a8ac4a3dad0348b Mon Sep 17 00:00:00 2001
|
||||
From: Pauli <pauli@openssl.org>
|
||||
Date: Wed, 8 Mar 2023 15:28:20 +1100
|
||||
Subject: [PATCH] x509: excessive resource use verifying policy constraints
|
||||
|
||||
A security vulnerability has been identified in all supported versions
|
||||
of OpenSSL related to the verification of X.509 certificate chains
|
||||
that include policy constraints. Attackers may be able to exploit this
|
||||
vulnerability by creating a malicious certificate chain that triggers
|
||||
exponential use of computational resources, leading to a denial-of-service
|
||||
(DoS) attack on affected systems.
|
||||
|
||||
Fixes CVE-2023-0464
|
||||
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20569)
|
||||
|
||||
diff --git a/crypto/x509v3/pcy_local.h b/crypto/x509v3/pcy_local.h
|
||||
index 5daf78de45..344aa06765 100644
|
||||
--- a/crypto/x509v3/pcy_local.h
|
||||
+++ b/crypto/x509v3/pcy_local.h
|
||||
@@ -111,6 +111,11 @@ struct X509_POLICY_LEVEL_st {
|
||||
};
|
||||
|
||||
struct X509_POLICY_TREE_st {
|
||||
+ /* The number of nodes in the tree */
|
||||
+ size_t node_count;
|
||||
+ /* The maximum number of nodes in the tree */
|
||||
+ size_t node_maximum;
|
||||
+
|
||||
/* This is the tree 'level' data */
|
||||
X509_POLICY_LEVEL *levels;
|
||||
int nlevel;
|
||||
@@ -159,7 +164,8 @@ X509_POLICY_NODE *tree_find_sk(STACK_OF(X509_POLICY_NODE) *sk,
|
||||
X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_DATA *data,
|
||||
X509_POLICY_NODE *parent,
|
||||
- X509_POLICY_TREE *tree);
|
||||
+ X509_POLICY_TREE *tree,
|
||||
+ int extra_data);
|
||||
void policy_node_free(X509_POLICY_NODE *node);
|
||||
int policy_node_match(const X509_POLICY_LEVEL *lvl,
|
||||
const X509_POLICY_NODE *node, const ASN1_OBJECT *oid);
|
||||
diff --git a/crypto/x509v3/pcy_node.c b/crypto/x509v3/pcy_node.c
|
||||
index e2d7b15322..d574fb9d66 100644
|
||||
--- a/crypto/x509v3/pcy_node.c
|
||||
+++ b/crypto/x509v3/pcy_node.c
|
||||
@@ -59,10 +59,15 @@ X509_POLICY_NODE *level_find_node(const X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
X509_POLICY_DATA *data,
|
||||
X509_POLICY_NODE *parent,
|
||||
- X509_POLICY_TREE *tree)
|
||||
+ X509_POLICY_TREE *tree,
|
||||
+ int extra_data)
|
||||
{
|
||||
X509_POLICY_NODE *node;
|
||||
|
||||
+ /* Verify that the tree isn't too large. This mitigates CVE-2023-0464 */
|
||||
+ if (tree->node_maximum > 0 && tree->node_count >= tree->node_maximum)
|
||||
+ return NULL;
|
||||
+
|
||||
node = OPENSSL_zalloc(sizeof(*node));
|
||||
if (node == NULL) {
|
||||
X509V3err(X509V3_F_LEVEL_ADD_NODE, ERR_R_MALLOC_FAILURE);
|
||||
@@ -70,7 +75,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
node->data = data;
|
||||
node->parent = parent;
|
||||
- if (level) {
|
||||
+ if (level != NULL) {
|
||||
if (OBJ_obj2nid(data->valid_policy) == NID_any_policy) {
|
||||
if (level->anyPolicy)
|
||||
goto node_error;
|
||||
@@ -90,7 +95,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
}
|
||||
|
||||
- if (tree) {
|
||||
+ if (extra_data) {
|
||||
if (tree->extra_data == NULL)
|
||||
tree->extra_data = sk_X509_POLICY_DATA_new_null();
|
||||
if (tree->extra_data == NULL){
|
||||
@@ -103,6 +108,7 @@ X509_POLICY_NODE *level_add_node(X509_POLICY_LEVEL *level,
|
||||
}
|
||||
}
|
||||
|
||||
+ tree->node_count++;
|
||||
if (parent)
|
||||
parent->nchild++;
|
||||
|
||||
diff --git a/crypto/x509v3/pcy_tree.c b/crypto/x509v3/pcy_tree.c
|
||||
index 6e8322cbc5..6c7fd35405 100644
|
||||
--- a/crypto/x509v3/pcy_tree.c
|
||||
+++ b/crypto/x509v3/pcy_tree.c
|
||||
@@ -13,6 +13,18 @@
|
||||
|
||||
#include "pcy_local.h"
|
||||
|
||||
+/*
|
||||
+ * If the maximum number of nodes in the policy tree isn't defined, set it to
|
||||
+ * a generous default of 1000 nodes.
|
||||
+ *
|
||||
+ * Defining this to be zero means unlimited policy tree growth which opens the
|
||||
+ * door on CVE-2023-0464.
|
||||
+ */
|
||||
+
|
||||
+#ifndef OPENSSL_POLICY_TREE_NODES_MAX
|
||||
+# define OPENSSL_POLICY_TREE_NODES_MAX 1000
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* Enable this to print out the complete policy tree at various point during
|
||||
* evaluation.
|
||||
@@ -168,6 +180,9 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
return X509_PCY_TREE_INTERNAL;
|
||||
}
|
||||
|
||||
+ /* Limit the growth of the tree to mitigate CVE-2023-0464 */
|
||||
+ tree->node_maximum = OPENSSL_POLICY_TREE_NODES_MAX;
|
||||
+
|
||||
/*
|
||||
* http://tools.ietf.org/html/rfc5280#section-6.1.2, figure 3.
|
||||
*
|
||||
@@ -184,7 +199,7 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
level = tree->levels;
|
||||
if ((data = policy_data_new(NULL, OBJ_nid2obj(NID_any_policy), 0)) == NULL)
|
||||
goto bad_tree;
|
||||
- if (level_add_node(level, data, NULL, tree) == NULL) {
|
||||
+ if (level_add_node(level, data, NULL, tree, 1) == NULL) {
|
||||
policy_data_free(data);
|
||||
goto bad_tree;
|
||||
}
|
||||
@@ -243,7 +258,8 @@ static int tree_init(X509_POLICY_TREE **ptree, STACK_OF(X509) *certs,
|
||||
* Return value: 1 on success, 0 otherwise
|
||||
*/
|
||||
static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
- X509_POLICY_DATA *data)
|
||||
+ X509_POLICY_DATA *data,
|
||||
+ X509_POLICY_TREE *tree)
|
||||
{
|
||||
X509_POLICY_LEVEL *last = curr - 1;
|
||||
int i, matched = 0;
|
||||
@@ -253,13 +269,13 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
X509_POLICY_NODE *node = sk_X509_POLICY_NODE_value(last->nodes, i);
|
||||
|
||||
if (policy_node_match(last, node, data->valid_policy)) {
|
||||
- if (level_add_node(curr, data, node, NULL) == NULL)
|
||||
+ if (level_add_node(curr, data, node, tree, 0) == NULL)
|
||||
return 0;
|
||||
matched = 1;
|
||||
}
|
||||
}
|
||||
if (!matched && last->anyPolicy) {
|
||||
- if (level_add_node(curr, data, last->anyPolicy, NULL) == NULL)
|
||||
+ if (level_add_node(curr, data, last->anyPolicy, tree, 0) == NULL)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -272,7 +288,8 @@ static int tree_link_matching_nodes(X509_POLICY_LEVEL *curr,
|
||||
* Return value: 1 on success, 0 otherwise.
|
||||
*/
|
||||
static int tree_link_nodes(X509_POLICY_LEVEL *curr,
|
||||
- const X509_POLICY_CACHE *cache)
|
||||
+ const X509_POLICY_CACHE *cache,
|
||||
+ X509_POLICY_TREE *tree)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -280,7 +297,7 @@ static int tree_link_nodes(X509_POLICY_LEVEL *curr,
|
||||
X509_POLICY_DATA *data = sk_X509_POLICY_DATA_value(cache->data, i);
|
||||
|
||||
/* Look for matching nodes in previous level */
|
||||
- if (!tree_link_matching_nodes(curr, data))
|
||||
+ if (!tree_link_matching_nodes(curr, data, tree))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -311,7 +328,7 @@ static int tree_add_unmatched(X509_POLICY_LEVEL *curr,
|
||||
/* Curr may not have anyPolicy */
|
||||
data->qualifier_set = cache->anyPolicy->qualifier_set;
|
||||
data->flags |= POLICY_DATA_FLAG_SHARED_QUALIFIERS;
|
||||
- if (level_add_node(curr, data, node, tree) == NULL) {
|
||||
+ if (level_add_node(curr, data, node, tree, 1) == NULL) {
|
||||
policy_data_free(data);
|
||||
return 0;
|
||||
}
|
||||
@@ -373,7 +390,7 @@ static int tree_link_any(X509_POLICY_LEVEL *curr,
|
||||
}
|
||||
/* Finally add link to anyPolicy */
|
||||
if (last->anyPolicy &&
|
||||
- level_add_node(curr, cache->anyPolicy, last->anyPolicy, NULL) == NULL)
|
||||
+ level_add_node(curr, cache->anyPolicy, last->anyPolicy, tree, 0) == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -555,7 +572,7 @@ static int tree_calculate_user_set(X509_POLICY_TREE *tree,
|
||||
extra->qualifier_set = anyPolicy->data->qualifier_set;
|
||||
extra->flags = POLICY_DATA_FLAG_SHARED_QUALIFIERS
|
||||
| POLICY_DATA_FLAG_EXTRA_NODE;
|
||||
- node = level_add_node(NULL, extra, anyPolicy->parent, tree);
|
||||
+ node = level_add_node(NULL, extra, anyPolicy->parent, tree, 1);
|
||||
}
|
||||
if (!tree->user_policies) {
|
||||
tree->user_policies = sk_X509_POLICY_NODE_new_null();
|
||||
@@ -582,7 +599,7 @@ static int tree_evaluate(X509_POLICY_TREE *tree)
|
||||
|
||||
for (i = 1; i < tree->nlevel; i++, curr++) {
|
||||
cache = policy_cache_set(curr->cert);
|
||||
- if (!tree_link_nodes(curr, cache))
|
||||
+ if (!tree_link_nodes(curr, cache, tree))
|
||||
return X509_PCY_TREE_INTERNAL;
|
||||
|
||||
if (!(curr->flags & X509_V_FLAG_INHIBIT_ANY)
|
||||
@@ -1,48 +0,0 @@
|
||||
From b013765abfa80036dc779dd0e50602c57bb3bf95 Mon Sep 17 00:00:00 2001
|
||||
From: Matt Caswell <matt@openssl.org>
|
||||
Date: Tue, 7 Mar 2023 16:52:55 +0000
|
||||
Subject: [PATCH] Ensure that EXFLAG_INVALID_POLICY is checked even in leaf
|
||||
certs
|
||||
|
||||
Even though we check the leaf cert to confirm it is valid, we
|
||||
later ignored the invalid flag and did not notice that the leaf
|
||||
cert was bad.
|
||||
|
||||
Fixes: CVE-2023-0465
|
||||
|
||||
Reviewed-by: Hugo Landau <hlandau@openssl.org>
|
||||
Reviewed-by: Tomas Mraz <tomas@openssl.org>
|
||||
(Merged from https://github.com/openssl/openssl/pull/20588)
|
||||
|
||||
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
|
||||
index 925fbb5412..1dfe4f9f31 100644
|
||||
--- a/crypto/x509/x509_vfy.c
|
||||
+++ b/crypto/x509/x509_vfy.c
|
||||
@@ -1649,18 +1649,25 @@ static int check_policy(X509_STORE_CTX *ctx)
|
||||
}
|
||||
/* Invalid or inconsistent extensions */
|
||||
if (ret == X509_PCY_TREE_INVALID) {
|
||||
- int i;
|
||||
+ int i, cbcalled = 0;
|
||||
|
||||
/* Locate certificates with bad extensions and notify callback. */
|
||||
- for (i = 1; i < sk_X509_num(ctx->chain); i++) {
|
||||
+ for (i = 0; i < sk_X509_num(ctx->chain); i++) {
|
||||
X509 *x = sk_X509_value(ctx->chain, i);
|
||||
|
||||
if (!(x->ex_flags & EXFLAG_INVALID_POLICY))
|
||||
continue;
|
||||
+ cbcalled = 1;
|
||||
if (!verify_cb_cert(ctx, x, i,
|
||||
X509_V_ERR_INVALID_POLICY_EXTENSION))
|
||||
return 0;
|
||||
}
|
||||
+ if (!cbcalled) {
|
||||
+ /* Should not be able to get here */
|
||||
+ X509err(X509_F_CHECK_POLICY, ERR_R_INTERNAL_ERROR);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ /* The callback ignored the error so we return success */
|
||||
return 1;
|
||||
}
|
||||
if (ret == X509_PCY_TREE_FAILURE) {
|
||||
@@ -18,6 +18,7 @@ PKG_SOURCE_URL:= \
|
||||
http://rpm5.org/files/popt/
|
||||
PKG_HASH:=e728ed296fe9f069a0e005003c3d6b2dde3d9cad453422a10d6558616d304cc8
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_CPE_ID:=cpe:/a:popt_project:popt
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_REMOVE_FILES:=autogen.sh aclocal.m4
|
||||
|
||||
@@ -15,6 +15,7 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/linux-diag
|
||||
PKG_HASH:=e865de2c1f559fff0d3fc936e660c0efaf7afe662064f2fb97ccad1ec28d208a
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
PKG_CPE_ID:=cpe:/a:sysfsutils_project:sysfsutils
|
||||
|
||||
PKG_LICENSE:=LGPL-2.1
|
||||
PKG_LICENSE_FILES:=COPYING cmd/GPL lib/LGPL
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=wolfssl
|
||||
PKG_VERSION:=5.5.4-stable
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
PKG_VERSION:=5.6.3-stable
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/wolfSSL/wolfssl/archive/v$(PKG_VERSION)
|
||||
PKG_HASH:=b7ee150e49def77c765bc02aac92ddeb0bebefd4cb12aa263d8f95e405221fb8
|
||||
PKG_HASH:=2e74a397fa797c2902d7467d500de904907666afb4ff80f6464f6efd5afb114a
|
||||
|
||||
PKG_FIXUP:=libtool libtool-abiver
|
||||
PKG_INSTALL:=1
|
||||
@@ -151,6 +151,33 @@ CONFIGURE_ARGS += \
|
||||
--$(if $(CONFIG_WOLFSSL_HAS_ECC448),enable,disable)-curve448 \
|
||||
--$(if $(CONFIG_WOLFSSL_HAS_OPENVPN),enable,disable)-openvpn
|
||||
|
||||
define Package/libwolfsslcpu-crypto/preinst-aarch64
|
||||
#!/bin/sh
|
||||
exec >&2
|
||||
printf "[libwolfsslcpu-crypto] Checking for Arm v8-A Cryptographic Extension support: "
|
||||
if [ -n "$${IPKG_INSTROOT}" ]; then
|
||||
printf "...[offline]... "
|
||||
eval "$$(grep '^DISTRIB_TARGET=' "$${IPKG_INSTROOT}/etc/openwrt_release")"
|
||||
echo "$${DISTRIB_TARGET}" | grep '^bcm27xx/.*' > /dev/null && {
|
||||
echo "not supported"
|
||||
echo "Error: Target $${DISTRIB_TARGET} does not support Arm Cryptographic Extension."
|
||||
echo "Install the regular libwolfssl package instead of libwolfsslcpu-crypto."
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
grep -q '^Features.*\baes\b' /proc/cpuinfo || {
|
||||
echo "not supported"
|
||||
echo "Error: Arm v8-A Cryptographic Extension not supported."
|
||||
echo "Install the regular libwolfssl package instead of libwolfsslcpu-crypto."
|
||||
echo "Contents of /proc/cpuinfo:"
|
||||
cat /proc/cpuinfo
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
echo OK
|
||||
exit 0
|
||||
endef
|
||||
|
||||
ifeq ($(BUILD_VARIANT),regular)
|
||||
CONFIGURE_ARGS += \
|
||||
--$(if $(CONFIG_WOLFSSL_HAS_AFALG),enable,disable)-afalg \
|
||||
@@ -160,9 +187,7 @@ CONFIGURE_ARGS += \
|
||||
else ifdef CONFIG_aarch64
|
||||
CONFIGURE_ARGS += --enable-armasm
|
||||
TARGET_CFLAGS:=$(TARGET_CFLAGS:-mcpu%=-mcpu%+crypto)
|
||||
WOLFSSL_NOASM_REGEX:=^bcm27xx/.*
|
||||
Package/libwolfsslcpu-crypto/preinst=\
|
||||
$(subst @@WOLFSSL_NOASM_REGEX@@,$(WOLFSSL_NOASM_REGEX),$(file <preinst.arm-ce))
|
||||
Package/libwolfsslcpu-crypto/preinst=$(Package/libwolfsslcpu-crypto/preinst-aarch64)
|
||||
else ifdef CONFIG_TARGET_x86_64
|
||||
CONFIGURE_ARGS += --enable-intelasm
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
From 41d248461bd9ad44193a4806ecb5361513e8944e Mon Sep 17 00:00:00 2001
|
||||
From: jordan <jordan@wolfssl.com>
|
||||
Date: Tue, 27 Jun 2023 13:18:25 -0500
|
||||
Subject: [PATCH] fix detection of cut tool in configure.ac
|
||||
|
||||
---
|
||||
configure.ac | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -8723,10 +8723,11 @@ echo "extern \"C\" {" >> $OPTION_FILE
|
||||
echo "#endif" >> $OPTION_FILE
|
||||
echo "" >> $OPTION_FILE
|
||||
|
||||
-# check for supported command to trim option with
|
||||
+# Check for supported command to trim option with.
|
||||
+# note: cut requires an argument to exit with success.
|
||||
if colrm >/dev/null 2>&1 </dev/null; then
|
||||
TRIM="colrm 3"
|
||||
-elif cut >/dev/null 2>&1 </dev/null; then
|
||||
+elif cut --version >/dev/null 2>&1 </dev/null; then
|
||||
TRIM="cut -c1-2"
|
||||
else
|
||||
AC_MSG_ERROR([Could not find colrm or cut to make options file])
|
||||
@@ -1,10 +1,10 @@
|
||||
--- a/wolfssl/wolfcrypt/settings.h
|
||||
+++ b/wolfssl/wolfcrypt/settings.h
|
||||
@@ -2496,7 +2496,7 @@ extern void uITRON4_free(void *p) ;
|
||||
#endif
|
||||
@@ -2630,7 +2630,7 @@ extern void uITRON4_free(void *p) ;
|
||||
|
||||
/* warning for not using harden build options (default with ./configure) */
|
||||
-#ifndef WC_NO_HARDEN
|
||||
/* do not warn if big integer support is disabled */
|
||||
-#if !defined(WC_NO_HARDEN) && !defined(NO_BIG_INT)
|
||||
+#if 0
|
||||
#if (defined(USE_FAST_MATH) && !defined(TFM_TIMING_RESISTANT)) || \
|
||||
(defined(HAVE_ECC) && !defined(ECC_TIMING_RESISTANT)) || \
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/sh
|
||||
exec >&2
|
||||
printf "[libwolfsslcpu-crypto] Checking for Arm v8-A Cryptographic Extension support: "
|
||||
if [ -n "${IPKG_INSTROOT}" ]; then
|
||||
printf "...[offline]... "
|
||||
eval "$(grep '^DISTRIB_TARGET=' "${IPKG_INSTROOT}/etc/openwrt_release")"
|
||||
### @@WOLFSSL_NOASM_REGEX@@ is expanded from WOLFSSL_NOASM_REGEX in the Makefile
|
||||
echo "${DISTRIB_TARGET}" | grep '@@WOLFSSL_NOASM_REGEX@@' > /dev/null && {
|
||||
echo "not supported"
|
||||
echo "Error: Target ${DISTRIB_TARGET} does not support Arm Cryptographic Extension."
|
||||
echo "Install the regular libwolfssl package instead of libwolfsslcpu-crypto."
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
grep -q '^Features.*\baes\b' /proc/cpuinfo || {
|
||||
echo "not supported"
|
||||
echo "Error: Arm v8-A Cryptographic Extension not supported."
|
||||
echo "Install the regular libwolfssl package instead of libwolfsslcpu-crypto."
|
||||
echo "Contents of /proc/cpuinfo:"
|
||||
cat /proc/cpuinfo
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
echo OK
|
||||
exit 0
|
||||
1
package/luci-app-partexp
Submodule
1
package/luci-app-partexp
Submodule
Submodule package/luci-app-partexp added at 64eb0bd909
1
package/luci-app-zerotier
Submodule
1
package/luci-app-zerotier
Submodule
Submodule package/luci-app-zerotier added at 84061c8aff
92
package/mtk/applications/datconf/Makefile
Normal file
92
package/mtk/applications/datconf/Makefile
Normal file
@@ -0,0 +1,92 @@
|
||||
#
|
||||
# Copyright (C) 2019
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=datconf
|
||||
PKG_REVISION:=6bb733f7
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_REVISION).tar.bz2
|
||||
PKG_RELEASE:=1
|
||||
PKG_USE_NINJA:=0
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
PKG_MAINTAINER:=Weijie Gao <weijie.gao@mediatek.com>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
define Package/libkvcutil
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=C library for Key-value based config files
|
||||
endef
|
||||
|
||||
define Package/kvcedit
|
||||
SECTION:=util
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:=+libkvcutil
|
||||
TITLE:=Utility for editing key-value based config files
|
||||
endef
|
||||
|
||||
define Package/datconf
|
||||
SECTION:=MTK Properties
|
||||
CATEGORY:=MTK Properties
|
||||
SUBMENU:=Applications
|
||||
DEPENDS:=+kvcedit
|
||||
TITLE:=Utility for editing dat files used by MediaTek Wi-Fi drivers
|
||||
endef
|
||||
|
||||
define Package/datconf-lua
|
||||
SECTION:=MTK Properties
|
||||
CATEGORY:=MTK Properties
|
||||
SUBMENU:=Applications
|
||||
DEPENDS:=+datconf +liblua
|
||||
TITLE:=Lua plugin for datconf
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
|
||||
TARGET_LDFLAGS += -L$(STAGING_DIR)/usr/lib
|
||||
|
||||
CMAKE_OPTIONS = \
|
||||
-DLUAPATH=/usr/lib/lua
|
||||
|
||||
|
||||
define Package/libkvcutil/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/kvcutil/libkvcutil.so* $(1)/lib/
|
||||
endef
|
||||
|
||||
define Package/kvcedit/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/kvcutil/kvcedit $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
define Package/datconf/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/datconf/datconf $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
define Package/datconf-lua/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua
|
||||
$(CP) $(PKG_BUILD_DIR)/datconf/lua/datconf.so $(1)/usr/lib/lua/
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_BUILD_DIR)/kvcutil/libkvcutil.h $(1)/usr/include
|
||||
$(CP) $(PKG_BUILD_DIR)/datconf/libdatconf.h $(1)/usr/include
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/kvcutil/libkvcutil.so* $(1)/usr/lib
|
||||
-$(CP) $(PKG_BUILD_DIR)/datconf/libdatconf.a $(1)/usr/lib
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libkvcutil))
|
||||
$(eval $(call BuildPackage,kvcedit))
|
||||
$(eval $(call BuildPackage,datconf))
|
||||
$(eval $(call BuildPackage,datconf-lua))
|
||||
11
package/mtk/applications/luci-app-eqos-mtk/Makefile
Normal file
11
package/mtk/applications/luci-app-eqos-mtk/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for Easy QoS
|
||||
LUCI_DEPENDS:=+wget-ssl +tc +kmod-sched-core +kmod-ifb +ebtables-legacy-utils +ebtables-legacy @!PACKAGE_luci-app-eqos
|
||||
|
||||
PKG_MAINTAINER:=Jianhui Zhao <jianhuizhao329@gmail.com>
|
||||
PKG_NAME:=luci-app-eqos-mtk
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,96 @@
|
||||
'use strict';
|
||||
'require form';
|
||||
'require network';
|
||||
'require uci';
|
||||
'require view';
|
||||
|
||||
return view.extend({
|
||||
load: function() {
|
||||
return Promise.all([
|
||||
uci.load('eqos'),
|
||||
network.getHostHints()
|
||||
]);
|
||||
},
|
||||
|
||||
render: function(data) {
|
||||
var m, s, o;
|
||||
|
||||
m = new form.Map('eqos', _('EQoS'),
|
||||
_('Network speed control service.(Compatiable with Mediatek HNAT)'));
|
||||
|
||||
s = m.section(form.NamedSection, 'config', 'eqos');
|
||||
|
||||
o = s.option(form.Flag, 'enabled', _('Enable'));
|
||||
o.default = o.disabled;
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'interface', _('Load balance'),
|
||||
_('Please set a different gateway hop for each network interface before filling in the network interface name. Fill in PPPOE-WAN for dialing and eth1 for DHCP. Leaving it blank to disable it.Please use commas as interface name separators. Example: pppoe-wan,eth1'));
|
||||
o.rmempty = true;
|
||||
|
||||
o = s.option(form.Flag, 'ipv6enabled', _('IPV6Enable'));
|
||||
o.default = o.disabled;
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Flag, 'smarthqos', _('SMART_HWQOS'),
|
||||
_('Enabling fair queue will automatically perform hardware offloading for every local host'));
|
||||
o.default = o.disabled;
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'download', _('Download speed (Mbit/s)'),
|
||||
_('Total download bandwidth.'));
|
||||
o.datatype = 'and(uinteger,min(1))';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'upload', _('Upload speed (Mbit/s)'),
|
||||
_('Total upload bandwidth.'));
|
||||
o.datatype = 'and(uinteger,min(1))';
|
||||
o.rmempty = false;
|
||||
|
||||
|
||||
|
||||
s = m.section(form.TableSection, 'device', _('Speed limit and route choose based on IP address(Auto use hardware QOS)'));
|
||||
s.addremove = true;
|
||||
s.anonymous = true;
|
||||
s.sortable = true;
|
||||
|
||||
o = s.option(form.Flag, 'enabled', _('Enable'));
|
||||
o.default = o.enabled;
|
||||
|
||||
o = s.option(form.Value, 'ip', _('IPV4 address'));
|
||||
o.datatype = 'ip4addr';
|
||||
for (var i of Object.entries(data[1]?.hosts))
|
||||
for (var v in i[1].ipaddrs)
|
||||
if (i[1].ipaddrs[v]) {
|
||||
var ip_addr = i[1].ipaddrs[v], ip_host = i[1].name;
|
||||
o.value(ip_addr, ip_host ? String.format('%s (%s)', ip_host, ip_addr) : ip_addr)
|
||||
}
|
||||
o.rmempty = true;
|
||||
|
||||
var hosts = data[1]?.hosts;
|
||||
o = s.option(form.Value, 'mac', _('IPV6 host'));
|
||||
o.datatype = 'macaddr';
|
||||
Object.keys(hosts).forEach(function(mac) {
|
||||
var hint = hosts[mac].name || L.toArray(hosts[mac].ipaddrs || hosts[mac].ipv4)[0];
|
||||
o.value(mac, hint ? '%s (%s)'.format(mac, hint) : mac);
|
||||
});
|
||||
o.rmempty = true;
|
||||
|
||||
o = s.option(form.Value, 'download', _('Download speed (kbit/s)'));
|
||||
o.datatype = 'and(uinteger,min(0))';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'upload', _('Upload speed (kbit/s)'));
|
||||
o.datatype = 'and(uinteger,min(0))';
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'comment', _('Comment'));
|
||||
o.rmempty = true;
|
||||
|
||||
o = s.option(form.Value, 'interfacename', _('InterfaceName(start from 0)'));
|
||||
o.datatype = 'and(uinteger,min(0))';
|
||||
o.rmempty = true;
|
||||
|
||||
return m.render();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:87
|
||||
msgid "Comment"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:40
|
||||
msgid "Download speed (Mbit/s)"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:79
|
||||
msgid "Download speed (kbit/s)"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:18
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/root/usr/share/luci/menu.d/luci-app-eqos.json:3
|
||||
msgid "EQoS"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:23
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:57
|
||||
msgid "Enable"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:36
|
||||
msgid ""
|
||||
"Enabling fair queue will automatically perform hardware offloading "
|
||||
"forwarding for every local host "
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/root/usr/share/rpcd/acl.d/luci-app-eqos.json:3
|
||||
msgid "Grant UCI access for luci-app-eqos"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:60
|
||||
msgid "IPV4 address"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:71
|
||||
msgid "IPV6 host"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:31
|
||||
msgid "IPV6Enable"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:91
|
||||
msgid "InterfaceName(start from 0)"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:27
|
||||
msgid "Load balance"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:19
|
||||
msgid "Network speed control service.(Compatiable with Mediatek HNAT)"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:28
|
||||
msgid ""
|
||||
"Please set a different gateway hop for each network interface before filling "
|
||||
"in the network interface name. Fill in PPPOE-WAN for dialing and eth1 for "
|
||||
"DHCP. Leaving it blank to disable it.Please use commas as interface name "
|
||||
"separators. Example: pppoe-wan,eth1"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:35
|
||||
msgid "SMART_HWQOS"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:52
|
||||
msgid ""
|
||||
"Speed limit and route choose based on IP address(using unique comment less "
|
||||
"than 32 will enable hardware QOS)"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:41
|
||||
msgid "Total download bandwidth."
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:46
|
||||
msgid "Total upload bandwidth."
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:45
|
||||
msgid "Upload speed (Mbit/s)"
|
||||
msgstr ""
|
||||
|
||||
#: package/mtk/applications/luci-app-eqos-mtk/htdocs/luci-static/resources/view/eqos.js:83
|
||||
msgid "Upload speed (kbit/s)"
|
||||
msgstr ""
|
||||
@@ -0,0 +1,91 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: LuCi Chinese Translation\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Language: zh_Hans\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Pootle 2.0.6\n"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:64
|
||||
msgid "Comment"
|
||||
msgstr "编号"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:28
|
||||
msgid "Download speed (Mbit/s)"
|
||||
msgstr "下载速度 (Mbit/s)"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:18
|
||||
#: applications/luci-app-eqos/root/usr/share/luci/menu.d/luci-app-eqos.json:3
|
||||
msgid "EQoS"
|
||||
msgstr "网速控制"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:24
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:43
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "SMART_HWQOS"
|
||||
msgstr "智能硬件QOS"
|
||||
|
||||
msgid "Enabling fair queue will automatically perform hardware offloading for every local host"
|
||||
msgstr "启用硬件公平队列,局域网的每台设备将拥有相同的转发优先级,保证设备最低网速(仅对dhcp获得ip地址的设备生效,不兼容固定限速)"
|
||||
|
||||
msgid "IPV6Enable"
|
||||
msgstr "同时作用IPV6"
|
||||
|
||||
msgid "Load balance"
|
||||
msgstr "负载均衡"
|
||||
|
||||
msgid "Please set a different gateway hop for each network interface before filling in the network interface name. Fill in PPPOE-WAN for dialing and eth1 for DHCP. Leaving it blank to disable it.Please use commas as interface name separators. Example: pppoe-wan,eth1"
|
||||
msgstr "请先为每个网络接口设置不同的网关跃点后,再填写网络接口名。拨号填写pppoe-wan,DHCP则填写eth1。留空则不启用.请使用逗号作为接口名分隔符.例子:pppoe-wan, eth1"
|
||||
|
||||
#: applications/luci-app-eqos/root/usr/share/rpcd/acl.d/luci-app-eqos.json:3
|
||||
msgid "Grant UCI access for luci-app-eqos"
|
||||
msgstr "授予 luci-app-eqos 访问 UCI 配置的权限"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:46
|
||||
msgid "IPV4 address"
|
||||
msgstr "IPV4 地址"
|
||||
|
||||
msgid "IPV6 host"
|
||||
msgstr "IPV6 主机"
|
||||
|
||||
|
||||
msgid "Total download bandwidth."
|
||||
msgstr "总下载带宽。"
|
||||
|
||||
msgid "InterfaceName(start from 0)"
|
||||
msgstr "分流接口序号(从0开始,留空则负载均衡)"
|
||||
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:19
|
||||
msgid "Network speed control service.(Compatiable with Mediatek HNAT)"
|
||||
msgstr "网速控制服务(未设置限速主机可正常使用硬件加速)。"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:38
|
||||
msgid "Speed limit and route choose based on IP address(Auto use hardware QOS)"
|
||||
msgstr "基于 IP 分流限速(自动启用硬件QOS.速度设置为0则取消限速)"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:29
|
||||
msgid "Total download bandwidth."
|
||||
msgstr "总下载带宽。"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:34
|
||||
msgid "Total upload bandwidth."
|
||||
msgstr "总上传带宽。"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:33
|
||||
msgid "Upload speed (Mbit/s)"
|
||||
msgstr "上传速度 (Mbit/s)"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:56
|
||||
msgid "Download speed (kbit/s)"
|
||||
msgstr "下载速度 (kbit/s)"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:60
|
||||
msgid "Upload speed (kbit/s)"
|
||||
msgstr "上传速度 (kbit/s)"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# The bandwidth unit is Mbit/s
|
||||
config eqos 'config'
|
||||
option enabled 0
|
||||
option download 100
|
||||
option upload 20
|
||||
|
||||
# Limiting the bandwidth of a single Device
|
||||
#config device
|
||||
# option ip "192.168.1.100"
|
||||
# option download 10
|
||||
# option upload 5
|
||||
# option comment 1
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
/etc/init.d/eqos start
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/bin/sh
|
||||
|
||||
ACTION=$2
|
||||
MARK_FILE="/tmp/dhcp_mac_mark_mapping" # 存储MAC和MARK映射关系的文件
|
||||
LEASE_FILE="/tmp/dhcp.leases" # DHCP leases 文件
|
||||
MAX_MARK=31 # 限制mark值在1到31之间
|
||||
|
||||
# 定义哈希函数,将MAC地址转化为一个数值,限制在1到31之间
|
||||
hash_mac() {
|
||||
MAC=$1
|
||||
# 将MAC地址中的冒号去掉,转化为十六进制数值,取模限制在1到31之间
|
||||
MAC_HEX=$(echo "$MAC" | sed 's/://g')
|
||||
echo $(( 0x$MAC_HEX % MAX_MARK + 1 ))
|
||||
}
|
||||
|
||||
# 从文件中加载当前的MAC-MARK映射
|
||||
load_mapping() {
|
||||
if [ ! -f "$MARK_FILE" ]; then
|
||||
touch "$MARK_FILE"
|
||||
fi
|
||||
cat "$MARK_FILE"
|
||||
}
|
||||
|
||||
# 检查mark是否被占用
|
||||
is_mark_in_use() {
|
||||
MARK=$1
|
||||
grep -q " $MARK$" "$MARK_FILE"
|
||||
return $?
|
||||
}
|
||||
|
||||
# 分配一个可用的mark
|
||||
allocate_mark() {
|
||||
MAC=$1
|
||||
MARK=$(hash_mac $MAC)
|
||||
retries=0 # 记录重试次数
|
||||
max_retries=$((MAX_MARK - 1)) # 允许的最大重试次数
|
||||
|
||||
# 循环检查mark是否被占用,直到找到可用的mark
|
||||
while is_mark_in_use $MARK; do
|
||||
MARK=$((MARK + 1))
|
||||
retries=$((retries + 1))
|
||||
if [ "$MARK" -gt $MAX_MARK ]; then
|
||||
MARK=1
|
||||
fi
|
||||
# 如果重试次数达到最大值,退出循环,表示无法找到可用的MARK
|
||||
if [ "$retries" -ge "$max_retries" ]; then
|
||||
MARK=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
# 返回可用的MARK
|
||||
echo $MARK
|
||||
}
|
||||
|
||||
# 保存MAC和MARK的映射
|
||||
save_mapping() {
|
||||
MAC=$1
|
||||
MARK=$2
|
||||
echo "$MAC $MARK" >> "$MARK_FILE"
|
||||
}
|
||||
|
||||
# 删除MAC对应的MARK映射
|
||||
delete_mapping() {
|
||||
MAC=$1
|
||||
sed -i "/^$MAC /d" "$MARK_FILE"
|
||||
}
|
||||
|
||||
# 处理现有的DHCP记录,确保已有设备保留其MARK
|
||||
process_existing_leases() {
|
||||
while read -r line; do
|
||||
IP=$(echo "$line" | awk '{print $3}')
|
||||
MAC=$(echo "$line" | awk '{print $2}')
|
||||
EXISTING_MARK=$(grep "^$MAC " "$MARK_FILE" | awk '{print $2}')
|
||||
if [ -z "$EXISTING_MARK" ]; then
|
||||
# 如果没有记录,分配新的MARK
|
||||
MARK_VALUE=$(allocate_mark $MAC)
|
||||
save_mapping $MAC $MARK_VALUE
|
||||
else
|
||||
# 使用现有的MARK
|
||||
MARK_VALUE=$EXISTING_MARK
|
||||
fi
|
||||
idpair=$((MARK_VALUE+32))
|
||||
# 添加iptables规则,基于MAC和IP地址给这个设备打上MARK
|
||||
iptables -t mangle -D eqos -s $IP -j DSCP --set-dscp ${MARK_VALUE}
|
||||
iptables -t mangle -D eqos -d $IP -j DSCP --set-dscp ${idpair}
|
||||
ip6tables -t mangle -D eqos -m mac --mac-source $MAC -j MARK --set-mark ${MARK_VALUE}
|
||||
ebtables -t nat -D eqos -p ipv6 -d $MAC -j mark --mark-set ${idpair}
|
||||
iptables -t mangle -A eqos -s $IP -j DSCP --set-dscp ${MARK_VALUE}
|
||||
iptables -t mangle -A eqos -d $IP -j DSCP --set-dscp ${idpair}
|
||||
ip6tables -t mangle -A eqos -m mac --mac-source $MAC -j MARK --set-mark ${MARK_VALUE}
|
||||
ebtables -t nat -A eqos -A ipv6 -d $MAC -j mark --mark-set ${idpair}
|
||||
done < "$LEASE_FILE"
|
||||
}
|
||||
|
||||
if [ "$ACTION" = "init" ]; then
|
||||
rm /tmp/dhcp_mac_mark_mapping
|
||||
load_mapping
|
||||
iptables -t mangle -F eqos
|
||||
ip6tables -t mangle -F eqos
|
||||
ebtables -t nat -F eqos
|
||||
process_existing_leases
|
||||
fi
|
||||
|
||||
102
package/mtk/applications/luci-app-eqos-mtk/root/etc/init.d/eqos
Normal file
102
package/mtk/applications/luci-app-eqos-mtk/root/etc/init.d/eqos
Normal file
@@ -0,0 +1,102 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
START=50
|
||||
USE_PROCD=1
|
||||
|
||||
parse_device() {
|
||||
local cfg="$1"
|
||||
|
||||
local enabled
|
||||
config_get_bool enabled "$cfg" "enabled" "1"
|
||||
[ "$enabled" -eq "1" ] || return 1
|
||||
|
||||
|
||||
local ip download upload comment mac interfacename
|
||||
config_get ip "$cfg" ip
|
||||
config_get download "$cfg" "download"
|
||||
config_get upload "$cfg" "upload"
|
||||
config_get comment "$cfg" "comment"
|
||||
config_get mac "$cfg" "mac"
|
||||
config_get interfacename "$cfg" "interfacename"
|
||||
eqos add "$ip" "$download" "$upload" "$comment" "$mac" "$interfacename"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load "eqos"
|
||||
|
||||
local enabled
|
||||
config_get_bool enabled "config" "enabled" "0"
|
||||
[ "$enabled" -eq "1" ] || return 1
|
||||
|
||||
local download upload comment
|
||||
config_get download "config" "download"
|
||||
config_get upload "config" "upload"
|
||||
config_get comment "config" "comment"
|
||||
config_get smarthqos "config" "smarthqos"
|
||||
config_get interface "config" "interface"
|
||||
eqos start "$download" "$upload" "$comment"
|
||||
|
||||
local ipv6enabled
|
||||
config_get_bool ipv6enabled "config" "ipv6enabled" "0"
|
||||
ip6tables -t mangle -N eqos
|
||||
ip6tables -t mangle -F eqos
|
||||
ebtables -t nat -N eqos
|
||||
ebtables -t nat -F eqos
|
||||
if [ "$ipv6enabled" -eq "1" ]; then
|
||||
ebtables -t nat -D POSTROUTING -j eqos -p ipv6
|
||||
ebtables -t nat -A POSTROUTING -j eqos -p ipv6
|
||||
ip6tables -t mangle -D FORWARD -j eqos
|
||||
ip6tables -t mangle -A FORWARD -j eqos
|
||||
fi
|
||||
|
||||
if [ "$smarthqos" -eq "1" ]; then
|
||||
for i in $(seq 1 31); do
|
||||
if [ "$upload" -ne "0" ]; then
|
||||
echo 2 1 $(($upload*225)) 1 $(($upload*1000)) 4 1 > /sys/kernel/debug/hnat/qdma_txq$i
|
||||
fi
|
||||
done
|
||||
for i in $(seq 33 63); do
|
||||
if [ "$download" -ne "0" ]; then
|
||||
echo 3 1 $(($download*200)) 1 $(($download*1000)) 4 1 > /sys/kernel/debug/hnat/qdma_txq$i
|
||||
fi
|
||||
done
|
||||
fi
|
||||
iptables -t mangle -F PREROUTING
|
||||
if [ $interface ]; then
|
||||
bash /usr/sbin/loadbalance "$interface"
|
||||
fi
|
||||
config_foreach parse_device "device"
|
||||
if [ "$smarthqos" -eq "1" ]; then
|
||||
rm /etc/hotplug.d/dhcp/99-eqos
|
||||
cat << 'EOF' > /etc/hotplug.d/dhcp/99-eqos
|
||||
#!/bin/sh
|
||||
|
||||
# 只有在新增 DHCP 租约时才执行操作
|
||||
if [ "$ACTION" = "add" ]; then
|
||||
|
||||
# 执行指定的命令
|
||||
/etc/init.d/dhcp_mark.sh eqos init
|
||||
fi
|
||||
EOF
|
||||
|
||||
chmod +x /etc/hotplug.d/dhcp/99-eqos
|
||||
/etc/init.d/dnsmasq restart
|
||||
/etc/init.d/dhcp_mark.sh eqos init
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
eqos stop
|
||||
iptables -t mangle -F PREROUTING
|
||||
rm /etc/hotplug.d/dhcp/99-eqos
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "eqos"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@eqos[-1]
|
||||
add ucitrack eqos
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
187
package/mtk/applications/luci-app-eqos-mtk/root/usr/sbin/eqos
Normal file
187
package/mtk/applications/luci-app-eqos-mtk/root/usr/sbin/eqos
Normal file
@@ -0,0 +1,187 @@
|
||||
#!/bin/sh
|
||||
|
||||
dev=br-lan
|
||||
hash_file="/tmp/hash_records.txt"
|
||||
|
||||
generate_index() {
|
||||
local input="$1"
|
||||
local hash_value=$(echo -n "$input" | md5sum | cut -d' ' -f1)
|
||||
local decimal_value=$((0x${hash_value:0:8}))
|
||||
local index=$((decimal_value % 31 + 1))
|
||||
echo $index
|
||||
}
|
||||
|
||||
find_available_index() {
|
||||
local base_index=$(generate_index "$1")
|
||||
local index=$base_index
|
||||
|
||||
while true; do
|
||||
if grep -q "^$index$" "$hash_file"; then
|
||||
index=$((index % 31 + 1))
|
||||
if [[ $index -eq $base_index ]]; then
|
||||
echo "All slots are full. Returning 0."
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
echo $index >> "$hash_file"
|
||||
echo $index
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
}
|
||||
stop_qos() {
|
||||
tc qdisc del dev $dev root 2>/dev/null
|
||||
tc qdisc del dev $dev ingress 2>/dev/null
|
||||
tc qdisc del dev ${dev}-ifb root 2>/dev/null
|
||||
ip link del dev ${dev}-ifb 2>/dev/null
|
||||
}
|
||||
|
||||
start_qos() {
|
||||
local dl=$1
|
||||
local up=$2
|
||||
rm /tmp/hash_records.txt
|
||||
touch "$hash_file"
|
||||
tc qdisc add dev $dev root handle 1: htb
|
||||
tc class add dev $dev parent 1: classid 1:1 htb rate ${dl}mbit
|
||||
|
||||
ip link add dev ${dev}-ifb name ${dev}-ifb type ifb
|
||||
ip link set dev ${dev}-ifb up
|
||||
|
||||
tc qdisc add dev ${dev}-ifb root handle 1: htb
|
||||
tc class add dev ${dev}-ifb parent 1: classid 1:1 htb rate ${up}mbit
|
||||
|
||||
tc qdisc add dev $dev ingress
|
||||
tc filter add dev $dev parent ffff: protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ${dev}-ifb
|
||||
}
|
||||
|
||||
iptables_stop() {
|
||||
iptables -t mangle -D FORWARD -j eqos
|
||||
ip6tables -t mangle -D FORWARD -j eqos
|
||||
ebtables -t nat -D POSTROUTING -j eqos -p ipv6
|
||||
echo 0 > /sys/kernel/debug/hnat/qos_toggle
|
||||
sed -i '/\/etc\/init.d\/eqos start/d' /etc/firewall.user
|
||||
iptables -t mangle -D FORWARD -i br-lan -j DSCP --set-dscp 0
|
||||
iptables -t mangle -D FORWARD -o br-lan -j DSCP --set-dscp 0
|
||||
ip6tables -t mangle -D FORWARD -i br-lan -j DSCP --set-dscp 0
|
||||
ip6tables -t mangle -D FORWARD -o br-lan -j DSCP --set-dscp 0
|
||||
echo "10 0" > /sys/kernel/debug/hnat/hnat_setting
|
||||
echo "11 30" >/sys/kernel/debug/hnat/hnat_setting
|
||||
for i in $(seq 0 31); do
|
||||
echo 0 0 0 0 0 4 4 > /sys/kernel/debug/hnat/qdma_txq$i
|
||||
done
|
||||
for i in $(seq 32 63); do
|
||||
echo 1 0 0 0 0 4 4 > /sys/kernel/debug/hnat/qdma_txq$i
|
||||
done
|
||||
echo 0 wrr 25000000 > /sys/kernel/debug/hnat/qdma_sch0
|
||||
echo 0 wrr 25000000 > /sys/kernel/debug/hnat/qdma_sch1
|
||||
echo 0 wrr 25000000 > /sys/kernel/debug/hnat/qdma_sch2
|
||||
echo 0 wrr 25000000 > /sys/kernel/debug/hnat/qdma_sch3
|
||||
}
|
||||
|
||||
iptables_start_prepare() {
|
||||
iptables -t mangle -D FORWARD -i br-lan -j DSCP --set-dscp 0
|
||||
iptables -t mangle -D FORWARD -o br-lan -j DSCP --set-dscp 0
|
||||
iptables -t mangle -A FORWARD -i br-lan -j DSCP --set-dscp 0
|
||||
iptables -t mangle -A FORWARD -o br-lan -j DSCP --set-dscp 0
|
||||
ip6tables -t mangle -D FORWARD -i br-lan -j DSCP --set-dscp 0
|
||||
ip6tables -t mangle -D FORWARD -o br-lan -j DSCP --set-dscp 0
|
||||
ip6tables -t mangle -A FORWARD -i br-lan -j DSCP --set-dscp 0
|
||||
ip6tables -t mangle -A FORWARD -o br-lan -j DSCP --set-dscp 0
|
||||
}
|
||||
|
||||
iptables_start_inital() {
|
||||
iptables -t mangle -N eqos
|
||||
iptables -t mangle -F eqos
|
||||
iptables -t mangle -D FORWARD -j eqos
|
||||
iptables -t mangle -A FORWARD -j eqos
|
||||
echo 1 > /sys/kernel/debug/hnat/qos_toggle
|
||||
echo 0 wrr 25000000 > /sys/kernel/debug/hnat/qdma_sch0
|
||||
echo 0 wrr 25000000 > /sys/kernel/debug/hnat/qdma_sch1
|
||||
echo 0 0 0 0 0 0 0 > /sys/kernel/debug/hnat/qdma_txq0
|
||||
echo 1 0 0 0 0 0 0 > /sys/kernel/debug/hnat/qdma_txq32
|
||||
echo "11 5" >/sys/kernel/debug/hnat/hnat_setting
|
||||
uci -q set "turboacc.config.fastpath_mh_eth_hnat_bind_rate"="5"
|
||||
uci -q commit "turboacc"
|
||||
sed -i '/\/etc\/init.d\/eqos start/d' /etc/firewall.user
|
||||
echo "/etc/init.d/eqos start" >> /etc/firewall.user
|
||||
echo "10 1" > /sys/kernel/debug/hnat/hnat_setting
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
"stop")
|
||||
stop_qos
|
||||
iptables_stop
|
||||
;;
|
||||
"start")
|
||||
stop_qos
|
||||
iptables_start_prepare
|
||||
start_qos $2 $3
|
||||
iptables_start_inital
|
||||
echo 1 wrr $(($3*1000)) > /sys/kernel/debug/hnat/qdma_sch2
|
||||
echo 1 wrr $(($2*1000)) > /sys/kernel/debug/hnat/qdma_sch3
|
||||
;;
|
||||
"add")
|
||||
ip="$2"
|
||||
dl="$3"
|
||||
up="$4"
|
||||
macaddr="$6"
|
||||
cnt=$(tc class show dev $dev | wc -l)
|
||||
|
||||
interface="$7"
|
||||
if [ -n "$ip" ]; then
|
||||
id="$(find_available_index "$ip")"
|
||||
elif [ -n "$macaddr" ]; then
|
||||
id="$(find_available_index "$macaddr")"
|
||||
fi
|
||||
idpair=$((id+32))
|
||||
if [ $id -lt 32 ]; then
|
||||
iptables -t mangle -D eqos -s $ip -j DSCP --set-dscp ${id}
|
||||
iptables -t mangle -D eqos -d $ip -j DSCP --set-dscp ${idpair}
|
||||
ip6tables -t mangle -D eqos -m mac --mac-source $macaddr -j MARK --set-mark ${id}
|
||||
ebtables -t nat -D eqos -p ipv6 -d $macaddr -j mark --mark-set ${idpair}
|
||||
if [ $up -ne 0 ]; then
|
||||
echo 2 0 0 1 ${up} 4 1 > /sys/kernel/debug/hnat/qdma_txq${id}
|
||||
iptables -t mangle -A eqos -s $ip -j DSCP --set-dscp ${id}
|
||||
ip6tables -t mangle -A eqos -m mac --mac-source $macaddr -j MARK --set-mark ${id}
|
||||
fi
|
||||
if [ $dl -ne 0 ]; then
|
||||
echo 3 0 0 1 ${dl} 4 1 > /sys/kernel/debug/hnat/qdma_txq${idpair}
|
||||
iptables -t mangle -A eqos -d $ip -j DSCP --set-dscp ${idpair}
|
||||
ebtables -t nat -A eqos -p ipv6 -d $macaddr -j mark --mark-set ${idpair}
|
||||
fi
|
||||
else
|
||||
iptables -t mangle -D eqos -s $ip -j MARK --set-mark 0x99
|
||||
iptables -t mangle -D eqos -d $ip -j MARK --set-mark 0x99
|
||||
if [ $up -ne 0 ]; then
|
||||
iptables -t mangle -A eqos -s $ip -j MARK --set-mark 0x99
|
||||
fi
|
||||
if [ $dl -ne 0 ]; then
|
||||
iptables -t mangle -A eqos -d $ip -j MARK --set-mark 0x99
|
||||
fi
|
||||
fi
|
||||
if [ $id -gt 31 ]; then
|
||||
tc class add dev $dev parent 1:1 classid 1:1$cnt htb rate ${dl}kbit ceil ${dl}kbit
|
||||
tc filter add dev $dev parent 1:0 protocol ip u32 match ip dst $ip flowid 1:1$cnt
|
||||
|
||||
tc class add dev ${dev}-ifb parent 1:1 classid 1:1$cnt htb rate ${up}kbit ceil ${up}kbit
|
||||
tc filter add dev ${dev}-ifb parent 1:0 protocol ip u32 match ip src $ip flowid 1:1$cnt
|
||||
fi
|
||||
if [ $interface ]; then
|
||||
iptables -t mangle -D PREROUTING -s $ip -m conntrack --ctstate NEW -j MARK --set-mark 2"$interface"
|
||||
iptables -t mangle -A PREROUTING -s $ip -m conntrack --ctstate NEW -j MARK --set-mark 2"$interface"
|
||||
iptables -t mangle -D PREROUTING -i br-lan -m conntrack --ctstate ESTABLISHED,RELATED -j CONNMARK --restore-mark
|
||||
iptables -t mangle -A PREROUTING -i br-lan -m conntrack --ctstate ESTABLISHED,RELATED -j CONNMARK --restore-mark
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 <command> [options]"
|
||||
echo "Commands:"
|
||||
echo " start dl_rate up_rate #Total bandwidth (Mbit/s)"
|
||||
echo " stop"
|
||||
echo " add ip dl_rate up_rate #Limiting the bandwidth of a single IP (kbit/s)"
|
||||
echo "Example:"
|
||||
echo " $0 start 30 20 # Total bandwidth: down 30Mbit/s up 20Mbit/s"
|
||||
echo " $0 add 192.168.22.12 10 2 # down 10kbit/s up 2kbit/s"
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,45 @@
|
||||
interface=$1
|
||||
array=(${interface//,/ })
|
||||
PPP_NUM=0
|
||||
|
||||
for var in ${array[@]}
|
||||
do
|
||||
let PPP_NUM=PPP_NUM+1
|
||||
done
|
||||
|
||||
i=0
|
||||
for var in ${array[@]}
|
||||
do
|
||||
ipaddr=$(ip route show |grep default | grep $var | awk '{print $3 }')
|
||||
iptables -t mangle -D PREROUTING -i br-lan -m conntrack --ctstate NEW -m statistic --mode nth --every $PPP_NUM --packet $i -j CONNMARK --set-mark 2"$i"
|
||||
iptables -t mangle -D PREROUTING -i br-lan -m connmark --mark 2"$i" -j MARK --set-mark 2"$i"
|
||||
iptables -t mangle -A PREROUTING -i br-lan -m conntrack --ctstate NEW -m statistic --mode nth --every $PPP_NUM --packet $i -j CONNMARK --set-mark 2"$i"
|
||||
iptables -t mangle -A PREROUTING -i br-lan -m connmark --mark 2"$i" -j MARK --set-mark 2"$i"
|
||||
ip rule del table 2"$i"0
|
||||
ip rule add fwmark 2"$i" table 2"$i"0
|
||||
ip route del default table 2"$i"0
|
||||
ip route add default via $ipaddr dev $var table 2"$i"0
|
||||
let i=i+1
|
||||
done
|
||||
|
||||
|
||||
i=0
|
||||
for var in ${array[@]}
|
||||
do
|
||||
ipaddr=$(ip route show |grep default | grep $var | awk '{print $3 }')
|
||||
iptables -t mangle -D PREROUTING -m conntrack --ctstate NEW -d $ipaddr/24 -j MARK --set-mark 2"$i"
|
||||
iptables -t mangle -A PREROUTING -m conntrack --ctstate NEW -d $ipaddr/24 -j MARK --set-mark 2"$i"
|
||||
let i=i+1
|
||||
done
|
||||
|
||||
iptables -t mangle -D PREROUTING -p tcp --dport 443 -m conntrack --ctstate NEW -j MARK --set-mark 20
|
||||
iptables -t mangle -A PREROUTING -p tcp --dport 443 -m conntrack --ctstate NEW -j MARK --set-mark 20
|
||||
|
||||
iptables -t mangle -D PREROUTING -p udp --dport 443 -m conntrack --ctstate NEW -j MARK --set-mark 20
|
||||
iptables -t mangle -A PREROUTING -p udp --dport 443 -m conntrack --ctstate NEW -j MARK --set-mark 20
|
||||
|
||||
iptables -t mangle -D POSTROUTING -m conntrack --ctstate NEW -j CONNMARK --save-mark
|
||||
iptables -t mangle -A POSTROUTING -m conntrack --ctstate NEW -j CONNMARK --save-mark
|
||||
iptables -t mangle -D PREROUTING -i br-lan -m conntrack --ctstate ESTABLISHED,RELATED -j CONNMARK --restore-mark
|
||||
iptables -t mangle -A PREROUTING -i br-lan -m conntrack --ctstate ESTABLISHED,RELATED -j CONNMARK --restore-mark
|
||||
ip route flush cache
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"admin/network/eqos": {
|
||||
"title": "EQoS",
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "eqos"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-eqos" ],
|
||||
"uci": { "eqos": true }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-eqos": {
|
||||
"description": "Grant UCI access for luci-app-eqos",
|
||||
"read": {
|
||||
"uci": [ "eqos" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "eqos" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
15
package/mtk/applications/luci-app-mtk/Makefile
Normal file
15
package/mtk/applications/luci-app-mtk/Makefile
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# Copyright (C) Hua Shao <nossiac@163.com>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=MediaTek Proprietary Configuration.
|
||||
LUCI_DEPENDS:=+datconf-lua
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
198
package/mtk/applications/luci-app-mtk/NOTICE
Normal file
198
package/mtk/applications/luci-app-mtk/NOTICE
Normal file
@@ -0,0 +1,198 @@
|
||||
Copyright (C) 2016 Gion Kunz
|
||||
|
||||
The MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
1421
package/mtk/applications/luci-app-mtk/luasrc/controller/mtkwifi.lua
Normal file
1421
package/mtk/applications/luci-app-mtk/luasrc/controller/mtkwifi.lua
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,67 @@
|
||||
<%#
|
||||
File name : mtk_wifi_apply_reboot.htm
|
||||
This file is used in WebUI based on LuCI to handle the reboot event.
|
||||
%>
|
||||
<%+header%>
|
||||
<h2><a>Reboot Device</a><h2>
|
||||
<div id="div_reboot_warn">
|
||||
<p class="alert-message">
|
||||
As the driver does not support addition or deletion of interfaces on the fly,
|
||||
the settings which were changed during addition or deletion of interfaces have not been applied yet!
|
||||
<br /><br />
|
||||
<strong>
|
||||
The changed settings will be applied only after reboot of the device.
|
||||
Please click on the Reboot button.
|
||||
</strong>
|
||||
<br /><br />
|
||||
<strong>Tip:</strong><br />
|
||||
Add or delete as many interfaces as required before reboot so that you do not have to reboot the device again.<br />
|
||||
Please follow below instructions to add or delete an interface;</em><br />
|
||||
1. Go to <a href='<%=luci.dispatcher.build_url("admin", "network", "wifi")%>'>Wireless Overview</a> web-page.<br />
|
||||
2. Click on Add button to add a new interface or click on Remove button to delete an existing interface.<br />
|
||||
3. If you are are adding a new interface, then, click on <em>Save</em> button after filling out all the required fields such as SSID etc.<br />
|
||||
4. Once you are done with addition/deletion of interfaces, then please click on <em>Reload</em> button or
|
||||
<em>Save and Apply</em> button on any web-page which will redirect to this web-page to perform the reboot of the device.</br>
|
||||
</p>
|
||||
<input class="cbi-button cbi-button-apply" type="button" value="Reboot" onclick="init_reboot()" />
|
||||
</div>
|
||||
<h4 id="msg_on_reboot" class="alert-message warning" style="display:none">
|
||||
<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" />
|
||||
Please wait while the reboot of the device is on progress.
|
||||
</h4>
|
||||
<h4 id="unreach_msg" class="alert-message error" style="display:none">Device has not come on-line yet!</h4>
|
||||
<script type="text/javascript">
|
||||
function online()
|
||||
{
|
||||
location = '<%=controller%>';
|
||||
}
|
||||
|
||||
function ping(numPings)
|
||||
{
|
||||
var loadingImg = document.createElement('IMG');
|
||||
loadingImg.onload = online;
|
||||
loadingImg.src = '<%=resource%>/icons/loading.gif?' + Math.random();
|
||||
numPings -= 1;
|
||||
if(numPings <= 0){
|
||||
document.getElementById("msg_on_reboot").style.display = 'none';
|
||||
document.getElementById("unreach_msg").style.display = '';
|
||||
}
|
||||
else{
|
||||
window.setTimeout(ping, 10000, numPings);
|
||||
}
|
||||
}
|
||||
|
||||
function init_reboot_cb()
|
||||
{
|
||||
window.setTimeout(ping, 10000, 18);
|
||||
}
|
||||
|
||||
function init_reboot()
|
||||
{
|
||||
document.getElementById('div_reboot_warn').style.display = 'none';
|
||||
document.getElementById('msg_on_reboot').style.display = '';
|
||||
(new XHR()).post('<%=controller%>/admin/mtk/wifi/reboot', { token: '<%=token%>' }, init_reboot_cb);
|
||||
}
|
||||
|
||||
</script>
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,233 @@
|
||||
<%+header%>
|
||||
<!--
|
||||
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").
|
||||
|
||||
Hua Shao <nossiac@163.com>
|
||||
-->
|
||||
|
||||
<%
|
||||
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)
|
||||
%>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js?v=git-17.250.41546-90ac861"></script>
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
|
||||
<form method="post" name="cbi" action="<%=luci.dispatcher.build_url("admin", "network", "wifi", "chip_cfg", devname)%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, '<%:Some fields are invalid, cannot save values!%>') && ValidateAllSettings()" autocomplete="off">
|
||||
<fieldset class="cbi-section">
|
||||
<h2><%:Chip Configurations%> - <%=string.split(devname,".")[1]%>
|
||||
<%local diff = mtkwifi.diff_profile(dev.profile)%>
|
||||
<%if next(diff) ~= nil then%>
|
||||
<span style="color:red;">( <a href="javascript:location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>'"><%:Click here%></a> <%:to apply changes%>)</span>
|
||||
<%end%>
|
||||
</h2>
|
||||
|
||||
<table id="dev-cfg-basic" class="cbi-section-table">
|
||||
<tr>
|
||||
<td><%:Decline BA Request%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="HT_BADecline">
|
||||
<option value="1" <% if cfgs.HT_BADecline == "1" then %> selected="selected"<% end%>><%:Enable%></option>
|
||||
<option value="0" <% if cfgs.HT_BADecline == "0" then %> selected="selected"<% end%>><%:Disable%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Reverse Direction Grant (RDG)%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="HT_RDG">
|
||||
<option value="1" <% if cfgs.HT_RDG == "1" then %> selected="selected"<% end%>><%:Enable%></option>
|
||||
<option value="0" <% if cfgs.HT_RDG == "0" then %> selected="selected"<% end%>><%:Disable%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:BA Win size%> <% if string.split(cfgs.WirelessMode,";")[1] == "16" or string.split(cfgs.WirelessMode,";")[1] == "17" or string.split(cfgs.WirelessMode,";")[1] == "18" then %>(1-256)<% else %>(1-64)<% end %></td>
|
||||
<td>
|
||||
<input name="HT_BAWinSize" id="HT_BAWinSize" value="<%=cfgs.HT_BAWinSize%>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:HT Disallow TKIP%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="HT_DisallowTKIP">
|
||||
<option value="1" <% if cfgs.HT_DisallowTKIP == "1" then %> selected="selected"<% end%>><%:Enable%></option>
|
||||
<option value="0" <% if cfgs.HT_DisallowTKIP == "0" then %> selected="selected"<% end%>><%:Disable%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Wi-Fi HWNAT%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="WHNAT">
|
||||
<option value="1" <% if cfgs.WHNAT == "1" then %> selected="selected"<% end%>><%:Enable%></option>
|
||||
<option value="0" <% if cfgs.WHNAT ~= "1" then %> selected="selected"<% end%>><%:Disable%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:E2pAccessMode%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="E2pAccessMode">
|
||||
<option value="1" <% if cfgs.E2pAccessMode == "1" then %> selected="selected"<% end%>>EFUSE</option>
|
||||
<option value="2" <% if cfgs.E2pAccessMode == "2" then %> selected="selected"<% end%>>FLASH</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Beacon Interval%> (20-999)</td>
|
||||
<td>
|
||||
<input name="BeaconPeriod" id="BeaconPeriod" value="<%=cfgs.BeaconPeriod%>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Data Beacon Rate (DTIM)%> (1-255)</td>
|
||||
<td>
|
||||
<input name="DtimPeriod" id="DtimPeriod" value="<%=cfgs.DtimPeriod%>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:BG Protection Mode%></td>
|
||||
<td>
|
||||
<select name="BGProtection" style="width:auto">
|
||||
<option value="0" <% if cfgs.BGProtection == "0" then %>selected="selected"<% end %>><%:Auto%></option>
|
||||
<option value="1" <% if cfgs.BGProtection == "1" then %>selected="selected"<% end %>><%:Always On%></option>
|
||||
<option value="2" <% if cfgs.BGProtection == "2" then %>selected="selected"<% end %>><%:Always Off%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Short Preamble%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="TxPreamble">
|
||||
<option value="1" <% if cfgs.TxPreamble == "1" then %> selected="selected"<% end%>><%:Enable%></option>
|
||||
<option value="0" <% if cfgs.TxPreamble == "0" then %> selected="selected"<% end%>><%:Disable%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:TX Burst%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="TxBurst">
|
||||
<option value="1" <% if cfgs.TxBurst == "1" then %> selected="selected"<% end%>><%:Enable%></option>
|
||||
<option value="0" <% if cfgs.TxBurst == "0" then %> selected="selected"<% end%>><%:Disable%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Short Slot%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="ShortSlot">
|
||||
<option value="1" <% if cfgs.ShortSlot == "1" then %> selected="selected"<% end%>><%:Enable%></option>
|
||||
<option value="0" <% if cfgs.ShortSlot == "0" then %> selected="selected"<% end%>><%:Disable%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="cbi-page-actions">
|
||||
|
||||
<input class="cbi-button cbi-button-apply" name="__apply" value="<%:Save & Apply%>" type="submit">
|
||||
<input class="cbi-button cbi-button-apply" value="<%:Save%>" type="submit">
|
||||
<input class="cbi-button cbi-button-reset" value="<%:Reset%>" type="reset">
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function ValidateAdvancedSettings()
|
||||
{
|
||||
var tmpVal = document.getElementById("HT_BAWinSize").value;
|
||||
<% if string.split(cfgs.WirelessMode,";")[1] == "16" or string.split(cfgs.WirelessMode,";")[1] == "17" or string.split(cfgs.WirelessMode,";")[1] == "18" then %>
|
||||
if(isNaN(tmpVal) || !/^\d{1,3}$/.test(tmpVal) || parseInt(tmpVal) < 1 || parseInt(tmpVal) > 256){
|
||||
alert("BA Win SIze is incorrect!\nPlease enter an integer number between 1 to 256 inclusive.");
|
||||
document.getElementById("HT_BAWinSize").focus();
|
||||
document.getElementById("HT_BAWinSize").select();
|
||||
return false;
|
||||
}
|
||||
<% else %>
|
||||
if(isNaN(tmpVal) || !/^\d{1,2}$/.test(tmpVal) || parseInt(tmpVal) < 1 || parseInt(tmpVal) > 64){
|
||||
alert("BA Win Size is incorrect!\nPlease enter an integer number between 1 to 64 inclusive.");
|
||||
document.getElementById("HT_BAWinSize").focus();
|
||||
document.getElementById("HT_BAWinSize").select();
|
||||
return false;
|
||||
}
|
||||
<% end %>
|
||||
tmpVal = document.getElementById("BeaconPeriod").value;
|
||||
if(isNaN(tmpVal) || !/^\d{2,3}$/.test(tmpVal) || parseInt(tmpVal) < 20 || parseInt(tmpVal) > 999){
|
||||
alert("Beacon Interval is incorrect!\nPlease enter an integer number between 20 to 999 inclusive.");
|
||||
document.getElementById("BeaconPeriod").focus();
|
||||
document.getElementById("BeaconPeriod").select();
|
||||
return false;
|
||||
}
|
||||
tmpVal = document.getElementById("DtimPeriod").value;
|
||||
if(isNaN(tmpVal) || !/^\d{1,3}$/.test(tmpVal) || parseInt(tmpVal) < 1 || parseInt(tmpVal) > 255){
|
||||
alert("Data Beacon Rate (DTIM) is incorrect!\nPlease enter an integer number between 1 to 255 inclusive.");
|
||||
document.getElementById("DtimPeriod").focus();
|
||||
document.getElementById("DtimPeriod").select();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ValidateAllSettings(){
|
||||
if( !ValidateAdvancedSettings() ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_apply_status_cb(rsp)
|
||||
{
|
||||
try{
|
||||
var r = JSON.parse(rsp);
|
||||
}
|
||||
catch(e){
|
||||
return;
|
||||
}
|
||||
if(r.status == "ON_PROGRESS"){
|
||||
var u = confirm("Device is applying the saved settings now!\n" +
|
||||
"It is recommended to wait until all the saved settings are applied.\n" +
|
||||
"Please click on 'OK' button to wait for the device.\n" +
|
||||
"or click on 'Cancel' button to configure the settings available in current web-page.");
|
||||
if (u == true) {
|
||||
location = '<%=luci.dispatcher.build_url("admin", "network", "wifi", "loading")%>' + window.location.pathname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_apply_status()
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_apply_status")%>', null,
|
||||
function(x)
|
||||
{
|
||||
console.log(x);
|
||||
get_apply_status_cb(x.response);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
get_apply_status();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,769 @@
|
||||
|
||||
<%+header%>
|
||||
<!--
|
||||
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").
|
||||
|
||||
Hua Shao <nossiac@163.com>
|
||||
-->
|
||||
|
||||
<%
|
||||
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)
|
||||
local bands = mtkwifi.detect_triband()
|
||||
%>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js?v=git-17.250.41546-90ac861"></script>
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
|
||||
<form method="post" name="cbi" action="<%=luci.dispatcher.build_url("admin", "network", "wifi", "dev_cfg", devname)%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, '<%:Some fields are invalid, cannot save values!%>') && ValidateAllSettings()" autocomplete="off">
|
||||
<fieldset class="cbi-section">
|
||||
<h2><%:Device Configuration%> - <%=devname%>
|
||||
<%local diff = mtkwifi.diff_profile(dev.profile)%>
|
||||
<%if next(diff) ~= nil then%>
|
||||
<span style="color:red;"> (<a href="javascript:location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>'"><%:Click here%></a> <%:to apply changes%>)</span>
|
||||
<%end%>
|
||||
</h2>
|
||||
|
||||
<table id="dev-cfg-basic" class="cbi-section-table">
|
||||
<tr>
|
||||
<td><%:Enable wireless device%></td>
|
||||
<td>
|
||||
<input type="radio" name="DevEnable" value="1" <% if cfgs.DevEnable == "1" then %> checked="checked"<% end %>/><%:Enable%>
|
||||
<input type="radio" name="DevEnable" value="0" <% if cfgs.DevEnable == "0" then %> checked="checked"<% end %>/><%:Disable%>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Channel%></td>
|
||||
<td>
|
||||
<select style="width:auto; min-width:180px;" name="Channel" id="Channel" onchange="Channel_onchange(this.value)" <% if cfgs.ApCliEnable == "1" then %> disabled="disabled" <% end %>>
|
||||
</select>
|
||||
</td>
|
||||
<td><% if cfgs.ApCliEnable == "1" then %><%:APClient/Repeater Mode.%><% end %></td>
|
||||
</tr>
|
||||
<tr id="HT_EXTCHA_TR" style="display:none">
|
||||
<td><%:40MHz HT Ext Channel%></td>
|
||||
<td>
|
||||
<select style="width:auto; min-width:180px;" name="HT_EXTCHA" id="HT_EXTCHA" <% if cfgs.ApCliEnable == "1" or dev.__bw ~= "40" or dev.__bw ~= "60" then %> disabled="disabled" <% end %>>
|
||||
</select>
|
||||
</td>
|
||||
<td><% if cfgs.ApCliEnable == "1" then %><%:APClient/Repeater Mode.%><% end %></td>
|
||||
</tr>
|
||||
<tr id="VHT_Sec80_Channel_TR" style="display:none">
|
||||
<td><%:80MHz Second VHT Channel%></td>
|
||||
<td>
|
||||
<select style="width:auto; min-width:180px; " name="VHT_Sec80_Channel" id="VHT_Sec80_Channel" <% if cfgs.ApCliEnable == "1" or dev.__bw ~= "161" then %> disabled="disabled" <% end %>>
|
||||
</select>
|
||||
</td>
|
||||
<td><% if cfgs.ApCliEnable == "1" then %><%:APClient/Repeater Mode.%><% end %></td>
|
||||
</tr>
|
||||
<% if string.split(cfgs.WirelessMode,";")[1] == "16" or string.split(cfgs.WirelessMode,";")[1] == "17" or string.split(cfgs.WirelessMode,";")[1] == "18" then %>
|
||||
<tr>
|
||||
<td><%:BSS color%></td>
|
||||
<td>
|
||||
<input name="BssColor" id="BssColor" value="<%=cfgs.BSSColorValue%>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:TWT Support%></td>
|
||||
<td>
|
||||
<select name="TWTSupport" style="width:auto">
|
||||
<option value="0" <% if cfgs.TWTSupport == "0" then %> selected="selected" <% end %>><%:Disable%></option>
|
||||
<option value="1" <% if cfgs.TWTSupport == "1" then %> selected="selected" <% end %>><%:Enable%></option>
|
||||
<option value="2" <% if cfgs.TWTSupport == "2" then %> selected="selected" <% end %>><%:Mandatory%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<input type="hidden" id="WirelessMode" value="<%=string.split(cfgs.WirelessMode,";")[1]%>">
|
||||
<tr>
|
||||
<td><%:Country Code%></td>
|
||||
<td>
|
||||
<select name="CountryCode" style="width:auto" id="CountryCode" onchange="CountryCode_onchange()">
|
||||
<option value="US" id="advCountryCodeUS" <% if cfgs.CountryCode == "US" then %> selected="selected"<% end %>><%:US%></option>
|
||||
<option value="JP" id="advCountryCodeJP" <% if cfgs.CountryCode == "JP" then %> selected="selected"<% end %>><%:JP%></option>
|
||||
<option value="FR" id="advCountryCodeFR" <% if cfgs.CountryCode == "FR" then %> selected="selected"<% end %>><%:FR%></option>
|
||||
<option value="IE" id="advCountryCodeIE" <% if cfgs.CountryCode == "IE" then %> selected="selected"<% end %>><%:IE%></option>
|
||||
<option value="CN" id="advCountryCodeCN" <% if cfgs.CountryCode == "CN" then %> selected="selected"<% end %>><%:CN%></option>
|
||||
<option value="NONE" id="advCountryCodeNONE"<% if cfgs.CountryCode == "NONE" then %> selected="selected"<% end %>><%:NONE%></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Country Region%></td>
|
||||
<td>
|
||||
<select style="width:auto; min-width:180px;" name="__cr" id="__cr" onchange="CountryRegion_onchange(this.value)">
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:Channel BandWidth%></td>
|
||||
<td>
|
||||
<select style="width:auto" name="__bw" id="__bw" onchange="Bw_onchange(this.options[this.options.selectedIndex].value)">
|
||||
<option value="20" <% if dev.__bw == "20" then %> selected="selected"<% end%>>20 MHz</option>
|
||||
<option value="40" <% if dev.__bw == "40" then %> selected="selected"<% end%>>40 MHz</option>
|
||||
<option value="60" <% if dev.__bw == "60" then %> selected="selected"<% end%>>20/40 MHz</option>
|
||||
<option value="80" <% if dev.__bw == "80" then %> selected="selected"<% end%>>80 MHz</option>
|
||||
<option value="160" <% if dev.__bw == "160" then %> selected="selected"<% end%>>160 MHz</option>
|
||||
<option value="161" <% if dev.__bw == "161" then %> selected="selected"<% end%>>80+80 MHz</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:TX Stream%></td>
|
||||
<td>
|
||||
<select name="HT_TxStream" style="width:auto">
|
||||
<% if dev.maxTxStream then %>
|
||||
<% for txStreamVal=1,dev.maxTxStream do%>
|
||||
<option value="<%=txStreamVal%>" <% if tonumber(cfgs.HT_TxStream) == txStreamVal then %>selected="selected"<% end %>><%=txStreamVal%></option>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<option value="1" <% if cfgs.HT_TxStream == "1" then %>selected="selected"<% end %>>1</option>
|
||||
<option value="2" <% if cfgs.HT_TxStream == "2" then %>selected="selected"<% end %>>2</option>
|
||||
<option value="3" <% if cfgs.HT_TxStream == "3" then %>selected="selected"<% end %>>3</option>
|
||||
<option value="4" <% if cfgs.HT_TxStream == "4" then %>selected="selected"<% end %>>4</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:RX Stream%></td>
|
||||
<td>
|
||||
<select name="HT_RxStream" style="width:auto">
|
||||
<% if dev.maxRxStream then %>
|
||||
<% for rxStreamVal=1,dev.maxRxStream do%>
|
||||
<option value="<%=rxStreamVal%>" <% if tonumber(cfgs.HT_RxStream) == rxStreamVal then %>selected="selected"<% end %>><%=rxStreamVal%></option>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<option value="1" <% if cfgs.HT_RxStream == "1" then %>selected="selected"<% end %>>1</option>
|
||||
<option value="2" <% if cfgs.HT_RxStream == "2" then %>selected="selected"<% end %>>2</option>
|
||||
<option value="3" <% if cfgs.HT_RxStream == "3" then %>selected="selected"<% end %>>3</option>
|
||||
<option value="4" <% if cfgs.HT_RxStream == "4" then %>selected="selected"<% end %>>4</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:TX Power%> (1-100)</td>
|
||||
<td>
|
||||
<input name="TxPower" id="TxPower" value="<%=cfgs.TxPower%>" />
|
||||
</td>
|
||||
</tr>
|
||||
<% if mtkwifi.band(string.split(cfgs.WirelessMode,";")[1]) == "5G" then %>
|
||||
<tr>
|
||||
<td>802.11H</td>
|
||||
<td>
|
||||
<input type="radio" name="IEEE80211H" value="1" <% if cfgs.IEEE80211H == "1" then %> checked="checked"<% end %>/><%:Enable%>
|
||||
<input type="radio" name="IEEE80211H" value="0" <% if cfgs.IEEE80211H == "0" then %> checked="checked"<% end %>/><%:Disable%>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%:DFS%></td>
|
||||
<td>
|
||||
<input type="radio" name="DfsEnable" value="1" <% if cfgs.DfsEnable == "1" then %> checked="checked"<% end %>/><%:Enable%>
|
||||
<input type="radio" name="DfsEnable" value="0" <% if cfgs.DfsEnable == "0" then %> checked="checked"<% end %>/><%:Disable%>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if cfgs.MUTxRxEnable then %>
|
||||
<tr>
|
||||
<td><%:Beam Forming and MIMO Setting%></td>
|
||||
<td>
|
||||
<select name="__mimo" autocomplete="off" >
|
||||
<option value="0"<% if tonumber(dev.__mimo) == 0 then %> selected="selected"<% end %>> ETxBF + SU-MIMO </option>
|
||||
<option value="1"<% if tonumber(dev.__mimo) == 1 then %> selected="selected"<% end %>> ITxBF + SU-MIMO </option>
|
||||
<option value="2"<% if tonumber(dev.__mimo) == 2 then %> selected="selected"<% end %>> ITxBF + ETxBF + SU-MIMO </option>
|
||||
<% if not dev.mimoBand or dev.mimoBand == dev.dbdcBandName then %>
|
||||
<option value="3"<% if tonumber(dev.__mimo) == 3 then %> selected="selected"<% end %>> ETxBF + MU-MIMO </option>
|
||||
<option value="4"<% if tonumber(dev.__mimo) == 4 then %> selected="selected"<% end %>> ITxBF + ETxBF + MU-MIMO </option>
|
||||
<% end %>
|
||||
<option value="5"<% if tonumber(dev.__mimo) == 5 then %> selected="selected"<% end %>> <%:Disable%> TxBF </option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if string.split(cfgs.WirelessMode,";")[1] == "16" or string.split(cfgs.WirelessMode,";")[1] == "17" or string.split(cfgs.WirelessMode,";")[1] == "18" then %>
|
||||
<tr>
|
||||
<td><%:Spatial Reuse%></td>
|
||||
<td>
|
||||
<input type="radio" name="SREnable" value="1" <% if cfgs.SREnable == "1" then %> checked="checked"<% end %>/><%:Enable%>
|
||||
<input type="radio" name="SREnable" value="0" <% if cfgs.SREnable == "0" then %> checked="checked"<% end %>/><%:Disable%>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
</fieldset>
|
||||
<div class="cbi-page-actions">
|
||||
|
||||
<input class="cbi-button cbi-button-apply" name="__apply" value="<%:Save & Apply%>" type="submit">
|
||||
<input class="cbi-button cbi-button-apply" value="<%:Save%>" type="submit">
|
||||
<input class="cbi-button cbi-button-reset" value="<%:Reset%>" type="reset">
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function CountryCode_onchange(){
|
||||
var wMode = document.getElementById('WirelessMode').value;
|
||||
getCountryRegionList(wMode);
|
||||
}
|
||||
|
||||
function CountryRegion_onchange(country_region) {
|
||||
var wmode_o = document.getElementById('WirelessMode');
|
||||
var wmode;
|
||||
|
||||
if (wmode_o)
|
||||
wmode = wmode_o.value;
|
||||
|
||||
if (wmode == "")
|
||||
wmode = "<%=cfgs.WirelessMode%>";
|
||||
|
||||
getChannelList(wmode, country_region);
|
||||
}
|
||||
|
||||
function Channel_onchange (ch) {
|
||||
getBw(null, ch);
|
||||
}
|
||||
|
||||
function Bw_onchange(bw, ch) {
|
||||
var ch_val;
|
||||
|
||||
if (!ch){
|
||||
var ch_o = document.getElementById('Channel');
|
||||
|
||||
if (ch_o)
|
||||
ch_val = ch_o.value;
|
||||
if (ch_val == "")
|
||||
ch_val = "<%=cfgs.Channel%>";
|
||||
} else {
|
||||
ch_val = ch
|
||||
}
|
||||
|
||||
get5G2nd80MhzChannelList(bw, ch_val);
|
||||
getHTExtChannel(bw, ch_val);
|
||||
}
|
||||
|
||||
function disableCountryRegionAsPerCountryCode(){
|
||||
var wModeSelect = document.getElementById('WirelessMode');
|
||||
var wMode = wModeSelect.value;
|
||||
var cCode = document.getElementById('CountryCode').value;
|
||||
var cRegionSelect = document.getElementById('__cr');
|
||||
var invalidCR_2G = {
|
||||
US:[1,3,4,5,7,31,32,33],
|
||||
JP:[],
|
||||
FR:[4,5,31,33],
|
||||
IE:[4,5,31,33],
|
||||
CN:[4,5,31,33],
|
||||
NONE:[]
|
||||
};
|
||||
var invalidCR_5G = {
|
||||
US:[1,7,11,15,19,20,21,22,30,31,32,33,36,37],
|
||||
JP:[0,3,4,5,7,9,10,11,13,14,15,16,17,19,20,21,30,31,32,34,36,37],
|
||||
FR:[0,3,4,5,7,9,10,11,12,13,14,15,16,17,19,20,21,30,31,32,34,36,37],
|
||||
IE:[0,3,4,5,7,9,10,11,12,13,14,15,16,17,19,20,21,30,31,32,34,36,37],
|
||||
CN:[1,7,9,11,12,13,14,15,18,19,20,21,22,30,31,32,33,36,37],
|
||||
NONE:[]
|
||||
};
|
||||
if (is_mode_gband(wMode)){
|
||||
// Channel 14 should be disabled for all the Countries except JAPAN(JP) and NONE Country Code.
|
||||
// If WireleeMode is not in 'B only' mode, then Channel 14 should be disabled for Japan and NONE Country Code too.
|
||||
if(wMode != "1"){
|
||||
if(cCode == "JP"){
|
||||
invalidCR_2G["JP"]=[4,5,31,33];
|
||||
}
|
||||
else if(cCode == "NONE"){
|
||||
invalidCR_2G["NONE"]=[4,5,31,33];
|
||||
}
|
||||
}
|
||||
if((cCode == "JP" && invalidCR_2G["JP"].length > 0) ||
|
||||
(cCode == "NONE" && invalidCR_2G["NONE"].length > 0) ||
|
||||
((cCode != "JP") && (cCode != "NONE"))){
|
||||
for(var idx=0; idx < cRegionSelect.length; idx++){
|
||||
if(invalidCR_2G[cCode] && invalidCR_2G[cCode].indexOf(cRegionSelect.options[idx].value * 1) != -1){
|
||||
cRegionSelect.options[idx].disabled = true;
|
||||
cRegionSelect.options[idx].selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (is_mode_aband(wMode) && cCode != "NONE"){
|
||||
for(var idx=0; idx < cRegionSelect.length; idx++){
|
||||
if(invalidCR_5G[cCode] && invalidCR_5G[cCode].indexOf(cRegionSelect.options[idx].value * 1) != -1){
|
||||
cRegionSelect.options[idx].disabled = true;
|
||||
cRegionSelect.options[idx].selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cRegionSelect.value;
|
||||
}
|
||||
|
||||
function initCountryRegionList(list, mode){
|
||||
var select = document.getElementById('__cr');
|
||||
var cr = {};
|
||||
|
||||
if (is_mode_gband(mode))
|
||||
cr = "<%=cfgs.CountryRegion%>";
|
||||
else if (is_mode_aband(mode))
|
||||
cr = "<%=cfgs.CountryRegionABand%>";
|
||||
|
||||
var new_cr = initList(select, list, cr, "region");
|
||||
new_cr = disableCountryRegionAsPerCountryCode();
|
||||
|
||||
CountryRegion_onchange(new_cr);
|
||||
}
|
||||
|
||||
function getCountryRegionList(mode) {
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_country_region_list")%>', {mode:mode},
|
||||
function(x)
|
||||
{
|
||||
//console.log(x);
|
||||
//console.log(x.response);
|
||||
var json = eval(x.response);
|
||||
initCountryRegionList(json, mode);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function initChannelList(list) {
|
||||
/* choose auto select when no matching item in the lis */
|
||||
var select = document.getElementById('Channel');
|
||||
var ch = {};
|
||||
var new_ch = null;
|
||||
|
||||
ch.cval = select.value;
|
||||
ch.oval = "<%=cfgs.Channel%>";
|
||||
|
||||
var new_ch = initList(select, list, ch, "channel");
|
||||
Channel_onchange(new_ch);
|
||||
}
|
||||
|
||||
function getChannelList(mode, country_region) {
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_channel_list")%>', {mode:mode, country_region:country_region},
|
||||
function(x)
|
||||
{
|
||||
//console.log(x);
|
||||
//console.log(x.response);
|
||||
var json = eval(x.response);
|
||||
initChannelList(json);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function GetCountryRegion(mode) {
|
||||
var cr_o = document.getElementById('__cr');
|
||||
var cr = "";
|
||||
|
||||
if (cr_o) {
|
||||
cr = cr_o.value;
|
||||
}
|
||||
|
||||
if (cr == "") {
|
||||
if (is_mode_gband(mode)) {
|
||||
cr = "<%=cfgs.CountryRegion%>";
|
||||
} else if (is_mode_aband(mode)) {
|
||||
cr = "<%=cfgs.CountryRegionABand%>";
|
||||
} else {
|
||||
alert("Cannot get valid CountryRegion from invalid WireleeMode");
|
||||
}
|
||||
}
|
||||
|
||||
return cr;
|
||||
}
|
||||
|
||||
function getBw(mode, ch) {
|
||||
/* choose bw as wide as possible if modification is needed */
|
||||
var bw_sel = document.getElementById('__bw');
|
||||
var wModeSelect,wmode;
|
||||
|
||||
wModeSelect = document.getElementById('WirelessMode');
|
||||
if (!mode) {
|
||||
wmode = wModeSelect.value*1;
|
||||
} else {
|
||||
wmode = mode*1;
|
||||
}
|
||||
if( <%=string.split(cfgs.WirelessMode,";")[1]%> != 18 ){
|
||||
if (is_mode_legacy_only(wmode) || parseInt(ch) >= 165) {
|
||||
for (var idx=0; idx < bw_sel.length; idx++) {
|
||||
bw_sel.options[idx].disabled = false;
|
||||
|
||||
if (bw_sel.options[idx].value == 20)
|
||||
bw_sel.options[idx].selected = true;
|
||||
|
||||
if (bw_sel.options[idx].value > 20)
|
||||
bw_sel.options[idx].disabled = true;
|
||||
}
|
||||
} else if (is_ch_gband(ch)) {
|
||||
for (var idx=0; idx < bw_sel.length; idx++) {
|
||||
bw_sel.options[idx].disabled = false;
|
||||
|
||||
if ((bw_sel.options[idx].value == 60) && (bw_sel.selectedIndex > idx))
|
||||
bw_sel.options[idx].selected = true;
|
||||
|
||||
if (bw_sel.options[idx].value > 60)
|
||||
bw_sel.options[idx].disabled = true;
|
||||
}
|
||||
} else if (is_ch_aband(ch)) {
|
||||
var chosen60 = false;
|
||||
var bw160 = "<%=cfgs.VHT_BW%>"*1;
|
||||
|
||||
if (bw_sel.value == 60)
|
||||
chosen60 = 1;
|
||||
|
||||
for (var idx=0; idx < bw_sel.length; idx++) {
|
||||
bw_sel.options[idx].disabled = false;
|
||||
if (bw_sel.options[idx].value == 40 && chosen60 && bw160 == 0) {
|
||||
bw_sel.options[idx].selected = true;
|
||||
} else if (bw_sel.options[idx].value == 60) {
|
||||
bw_sel.options[idx].disabled = true;
|
||||
bw_sel.options[idx].selected = false;
|
||||
} else if (wmode == 8 && bw_sel.options[idx].value == 80) {
|
||||
bw_sel.options[idx].disabled = true;
|
||||
bw_sel.options[idx].selected = false;
|
||||
} else if (bw_sel.options[idx].value == 160 && chosen60 && bw160 == 1) {
|
||||
bw_sel.options[idx].selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var invalidChBwList = '<%=(dev.invalidChBwList and table.concat(dev.invalidChBwList,";"))%>'.split(";");
|
||||
if(invalidChBwList.length > 0){
|
||||
for (var idx=0; idx < bw_sel.length; idx++) {
|
||||
if(invalidChBwList.indexOf(bw_sel.options[idx].value) != -1){
|
||||
bw_sel.options[idx].disabled = true;
|
||||
bw_sel.options[idx].selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(wmode == 18 ) {
|
||||
for (var idx=0; idx < bw_sel.length; idx++) {
|
||||
bw_sel.options[idx].disabled = false;
|
||||
if(bw_sel.options[idx].value == 40 && ch>229){
|
||||
bw_sel.options[idx].disabled = true;
|
||||
bw_sel.options[idx].selected = false;
|
||||
}
|
||||
if(bw_sel.options[idx].value == 80 && ch>221){
|
||||
bw_sel.options[idx].disabled = true;
|
||||
bw_sel.options[idx].selected = false;
|
||||
}
|
||||
if(bw_sel.options[idx].value == 160 && ch>221){
|
||||
bw_sel.options[idx].disabled = true;
|
||||
bw_sel.options[idx].selected = false;
|
||||
}
|
||||
if(bw_sel.options[idx].value == 161 || bw_sel.options[idx].value == 60){
|
||||
bw_sel.options[idx].disabled = true;
|
||||
bw_sel.options[idx].selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Bw_onchange(bw_sel.value, ch);
|
||||
}
|
||||
|
||||
function init5G2nd80MhzChannelList(list,ch,cr) {
|
||||
var select = document.getElementById('VHT_Sec80_Channel');
|
||||
var ch2 = {};
|
||||
var new_ch2 = null;
|
||||
|
||||
ch2.cval = select.value;
|
||||
ch2.oval = "<%=cfgs.VHT_Sec80_Channel%>";
|
||||
|
||||
initList(select, list, ch2, "channel");
|
||||
|
||||
if (select.length > 0) {
|
||||
document.getElementById("VHT_Sec80_Channel_TR").style.display = "";
|
||||
select.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function get5G2nd80MhzChannelList(bw, ch) {
|
||||
document.getElementById("VHT_Sec80_Channel_TR").style.display = "none";
|
||||
var ch_5g_2nd = document.getElementById('VHT_Sec80_Channel');
|
||||
|
||||
ch_5g_2nd.disabled = true;
|
||||
|
||||
|
||||
if (ch == "0")
|
||||
return;
|
||||
|
||||
if (bw != "161" || ch == "0")
|
||||
return;
|
||||
|
||||
var mode = document.getElementById('WirelessMode');
|
||||
mode = mode.value*1;
|
||||
|
||||
var cr = GetCountryRegion(mode);
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_5G_2nd_80Mhz_channel_list")%>', {ch_cur:ch, country_region:cr},
|
||||
function(x)
|
||||
{
|
||||
//console.log(x);
|
||||
//console.log(x.response);
|
||||
var json = eval(x.response);
|
||||
init5G2nd80MhzChannelList(json,ch,cr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function initHTExtChannelList(list,ch,cr) {
|
||||
var select = document.getElementById('HT_EXTCHA');
|
||||
var ch2 = {};
|
||||
var new_ch2 = null;
|
||||
|
||||
ch2.cval = select.value;
|
||||
ch2.oval = "<%=cfgs.HT_EXTCHA%>";
|
||||
|
||||
initList(select, list, ch2, "val");
|
||||
|
||||
if (select.length > 0) {
|
||||
document.getElementById("HT_EXTCHA_TR").style.display = "";
|
||||
select.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getHTExtChannel(bw, ch) {
|
||||
document.getElementById("HT_EXTCHA_TR").style.display = "none";
|
||||
|
||||
var ch_2g_ext = document.getElementById('HT_EXTCHA');
|
||||
|
||||
ch_2g_ext.disabled = true;
|
||||
|
||||
if (bw != "40" && bw != "60")
|
||||
return;
|
||||
|
||||
var mode = document.getElementById('WirelessMode');
|
||||
mode = mode.value*1;
|
||||
|
||||
// skip auto channel
|
||||
if(mode==18){
|
||||
if (ch == "0" || parseInt(ch) > 229)
|
||||
return;
|
||||
}
|
||||
else{
|
||||
if (ch == "0" || parseInt(ch) >= 165)
|
||||
return;
|
||||
}
|
||||
|
||||
var cr = GetCountryRegion(mode);
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_HT_ext_channel_list")%>', {mode:mode, ch_cur:ch, country_region:cr},
|
||||
function(x)
|
||||
{
|
||||
//console.log(x);
|
||||
//console.log(x.response);
|
||||
var json = eval(x.response);
|
||||
initHTExtChannelList(json,ch,cr);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function is_mode_legacy_only(mode) {
|
||||
var imode = mode*1;
|
||||
|
||||
return ((imode >= 0) && (imode <= 4));
|
||||
}
|
||||
|
||||
function is_mode_gband(mode) {
|
||||
var imode = mode*1;
|
||||
var gband_mode_list = [0,1,4,6,7,9,16];
|
||||
var i;
|
||||
|
||||
for (i = 0; i < gband_mode_list.length; i++){
|
||||
if( gband_mode_list[i] == imode )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_mode_aband(mode) {
|
||||
var imode = mode*1;
|
||||
var aband_mode_list = [2,8,11,14,15,17,18];
|
||||
var i;
|
||||
|
||||
for (i = 0; i < aband_mode_list.length; i++){
|
||||
if( aband_mode_list[i] == imode )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_ch_gband(ch) {
|
||||
ch = ch*1;
|
||||
|
||||
if (ch == 0) {
|
||||
var wmode = document.getElementById('WirelessMode');
|
||||
|
||||
return is_mode_gband(wmode.value);
|
||||
}
|
||||
|
||||
return ((ch > 0) && (ch <= 14));
|
||||
}
|
||||
|
||||
function is_ch_aband(ch) {
|
||||
ch = ch*1;
|
||||
|
||||
if (ch == 0) {
|
||||
var wmode = document.getElementById('WirelessMode');
|
||||
|
||||
return is_mode_aband(wmode.value);
|
||||
}
|
||||
|
||||
return ((ch >= 36 ) && (ch <= 165));
|
||||
}
|
||||
|
||||
function initList(selobj, list, selvals, value, text){
|
||||
var sel = {};
|
||||
var id = selobj.id;
|
||||
var noChannelGrp = false;
|
||||
var only2G = false;
|
||||
|
||||
if (typeof(selvals) != "object")
|
||||
sel[0] = selvals;
|
||||
else
|
||||
sel = selvals;
|
||||
|
||||
selobj.innerHTML = "";
|
||||
for (var i in list) {
|
||||
if (value != "region") {
|
||||
<% if bands == 3 and mtkwifi.band(string.split(cfgs.WirelessMode,";")[1]) == "5G" then %>
|
||||
<% if cfgs.ChannelGrp == "0:0:1:1" then %>
|
||||
if (list[i].channel == 0 || list[i].channel >= 100){
|
||||
<% elseif cfgs.ChannelGrp == "1:1:0:0" then %>
|
||||
if (list[i].channel <= 64){
|
||||
<% else %>
|
||||
noChannelGrp = true;
|
||||
if (noChannelGrp){
|
||||
<% end %>
|
||||
var opt = document.createElement('option');
|
||||
|
||||
if(value)
|
||||
opt.value = list[i][value];
|
||||
else
|
||||
opt.value = list[i].value;
|
||||
|
||||
if(text)
|
||||
opt.text = list[i][text];
|
||||
else
|
||||
opt.text = list[i].text;
|
||||
|
||||
selobj.appendChild(opt);
|
||||
}
|
||||
<% else %>
|
||||
only2G = true;
|
||||
<% end %>
|
||||
}
|
||||
|
||||
if (only2G || value == "region"){
|
||||
var opt = document.createElement('option');
|
||||
|
||||
if(value)
|
||||
opt.value = list[i][value];
|
||||
else
|
||||
opt.value = list[i].value;
|
||||
|
||||
if(text)
|
||||
opt.text = list[i][text];
|
||||
else
|
||||
opt.text = list[i].text;
|
||||
|
||||
selobj.appendChild(opt);
|
||||
}
|
||||
}
|
||||
|
||||
var selv = null;
|
||||
for (var k in sel) {
|
||||
//console.log("[initList][" + id + "] sel[" + k + "]=" + sel[k]);
|
||||
for (var i=0; i < selobj.length; i++){
|
||||
if (selobj.options[i].value == sel[k]){
|
||||
selobj.options[i].selected = true;
|
||||
selv = sel[k];
|
||||
//console.log("[initList][" + id + "] found selv=" + selv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selv) break;
|
||||
}
|
||||
|
||||
if (!selv) {
|
||||
selv = selobj.value;
|
||||
//console.log("[initList][" + id + "] !selv, selv=" + selv);
|
||||
}
|
||||
|
||||
return selv;
|
||||
}
|
||||
|
||||
function ValidateAdvancedSettings()
|
||||
{
|
||||
var tmpVal = document.getElementById("TxPower").value;
|
||||
if(isNaN(tmpVal) || !/^\d{1,3}$/.test(tmpVal) || parseInt(tmpVal) < 1 || parseInt(tmpVal) > 100){
|
||||
alert("TX Power is incorrect!\nPlease enter an integer number between 1 to 100 inclusive.");
|
||||
document.getElementById("TxPower").focus();
|
||||
document.getElementById("TxPower").select();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function ValidateAllSettings(){
|
||||
if( !ValidateAdvancedSettings() ){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_apply_status_cb(rsp)
|
||||
{
|
||||
try{
|
||||
var r = JSON.parse(rsp);
|
||||
}
|
||||
catch(e){
|
||||
return;
|
||||
}
|
||||
if(r.status == "ON_PROGRESS"){
|
||||
var u = confirm("Device is applying the saved settings now!\n" +
|
||||
"It is recommended to wait until all the saved settings are applied.\n" +
|
||||
"Please click on 'OK' button to wait for the device.\n" +
|
||||
"or click on 'Cancel' button to configure the settings available in current web-page.");
|
||||
if (u == true) {
|
||||
location = '<%=luci.dispatcher.build_url("admin", "network", "wifi", "loading")%>' + window.location.pathname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_apply_status()
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_apply_status")%>', null,
|
||||
function(x)
|
||||
{
|
||||
console.log(x);
|
||||
get_apply_status_cb(x.response);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
var mode = '<%=string.split(cfgs.WirelessMode,";")[1]%>'
|
||||
var cr = GetCountryRegion(mode);
|
||||
getCountryRegionList(mode, cr);
|
||||
get_apply_status();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,90 @@
|
||||
<%#
|
||||
File name : mtk_wifi_loading.htm
|
||||
This file is used in WebUI based on LuCI to handle the loading event.
|
||||
%>
|
||||
<%+header%>
|
||||
<%
|
||||
local disp = require "luci.dispatcher"
|
||||
local request = disp.context.request
|
||||
local url = "/"..table.concat(request,'/',5)
|
||||
%>
|
||||
<h2><%:Wireless%></h2>
|
||||
<div class="alert-message" id="BusyMsg">
|
||||
<img src="<%=resource%>/icons/loading.gif" alt="" style="vertical-align:middle" />
|
||||
<big><strong><%:Please wait while the settings are being applied.%></strong></big>
|
||||
</div>
|
||||
<div class="alert-message error" id="TimeoutMsgDiv" style="display:none">
|
||||
<big><strong id="TimeoutMsg">Device is taking too much time to apply the settings!</strong></big>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function visit_url(url)
|
||||
{
|
||||
window.onbeforeunload = function() {};
|
||||
if(url && url.indexOf('<%=controller%>') != -1){
|
||||
location = url;
|
||||
}
|
||||
else{
|
||||
location = '<%=luci.dispatcher.build_url("admin", "network", "wifi")%>';
|
||||
}
|
||||
}
|
||||
|
||||
function get_apply_status_cb(rsp, remNumTries)
|
||||
{
|
||||
try{
|
||||
var r = JSON.parse(rsp);
|
||||
if(r.status == "DONE"){
|
||||
visit_url('<%=url%>');
|
||||
return;
|
||||
}
|
||||
else if(r.status == "REBOOT"){
|
||||
visit_url('<%=luci.dispatcher.build_url("admin", "network", "wifi", "apply_reboot")%>');
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(e){}
|
||||
finally{
|
||||
remNumTries -= 1;
|
||||
if(remNumTries > 0){
|
||||
window.setTimeout(get_apply_status, 5000, remNumTries);
|
||||
}
|
||||
else{
|
||||
show_header();
|
||||
document.getElementById("TimeoutMsgDiv").style.display = '';
|
||||
document.getElementById("BusyMsg").style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_apply_status(remNumTries)
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_apply_status")%>', null,
|
||||
function(x)
|
||||
{
|
||||
console.log(x);
|
||||
get_apply_status_cb(x.response, remNumTries);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function show_header()
|
||||
{
|
||||
document.getElementsByTagName("HEADER")[0].style.display = "block";
|
||||
}
|
||||
|
||||
function hide_header()
|
||||
{
|
||||
document.getElementsByTagName("HEADER")[0].style.display = "none";
|
||||
}
|
||||
|
||||
window.onload = function(){
|
||||
hide_header();
|
||||
window.setTimeout(get_apply_status, 5000, 180);
|
||||
}
|
||||
|
||||
window.onbeforeunload = function(evt) {
|
||||
evt.returnValue = "Saved data have not been applied yet! Are you sure?";
|
||||
return evt.returnValue;
|
||||
}
|
||||
</script>
|
||||
<%+footer%>
|
||||
@@ -0,0 +1,557 @@
|
||||
<%+header%>
|
||||
<!--
|
||||
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").
|
||||
|
||||
Hua Shao <nossiac@163.com>
|
||||
-->
|
||||
|
||||
<%
|
||||
local mtkwifi = require("mtkwifi")
|
||||
local devs = mtkwifi.get_all_devs()
|
||||
local l1dat, l1 = mtkwifi.__get_l1dat()
|
||||
local dridx = l1.DEV_RINDEX
|
||||
local main_ifname
|
||||
local chipname
|
||||
%>
|
||||
|
||||
<style>
|
||||
table,td,th
|
||||
{
|
||||
border-top:1px solid ;
|
||||
border-spacing: 0;
|
||||
border-color:#E0E0E0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<h2><%:Wireless%></h2>
|
||||
|
||||
<% if #devs == 0 then %>
|
||||
<div class="alert-message">
|
||||
<big><strong><%:No wireless device found!%></strong></big>
|
||||
</div>
|
||||
<% else %>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<table class="cbi-section-table" style="empty-cells:hide">
|
||||
<% for _,dev in ipairs(devs) do %>
|
||||
<% main_ifname = l1dat and l1dat[dridx][dev.devname].main_ifname or dbdc_prefix[mainidx][subidx].."0" %>
|
||||
<% if mtkwifi.exists("/sys/class/net/"..main_ifname) then %>
|
||||
<!-- physical device -->
|
||||
<tbody>
|
||||
<% if chipname ~= string.split(dev.devname,".")[1].."."..(dev.mainidx) then %>
|
||||
<% chipname = string.split(dev.devname,".")[1].."."..(dev.mainidx) %>
|
||||
<tr style="height:45px">
|
||||
<td style="padding:15px;">
|
||||
<img src="/luci-static/resources/icons/wifi_big.png">
|
||||
</td>
|
||||
<td colspan="2" style="text-align:left">
|
||||
<big><strong title="<%=dev.profile%>"> <%=string.split(dev.devname,".")[1]%></strong></big>
|
||||
<%if not dev.vifs then%>
|
||||
<span style="color:red;">* <%:FATAL ERROR: Incorrect Profile Settings%></span>
|
||||
<%end%>
|
||||
<br>
|
||||
<%if dev.version then%>
|
||||
<span> <%:Driver version%>: <%=dev.version%> <br/></span>
|
||||
<%end%>
|
||||
</td>
|
||||
<td style="width:310px;text-align:right">
|
||||
<div id="ActionBtns_<%=string.split(dev.devname,".")[1]%>">
|
||||
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=string.split(dev.devname,".")[1]%>',
|
||||
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "chip_cfg_view", dev.devname)%>')"><%:CONFIG%></button>
|
||||
</div>
|
||||
<div id="BusyText_<%=string.split(dev.devname,".")[1]%>" style="display:none">
|
||||
<big><strong><%:Processing request.%></strong></big>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td style="width:56px"></td>
|
||||
<td colspan="2" style="text-align:left;padding-left:25px;">
|
||||
<big><strong title="<%=dev.profile%>"><%=dev.devname%></strong></big>
|
||||
<%local diff = mtkwifi.diff_profile(dev.profile)%>
|
||||
<%if next(diff) ~= nil then%>
|
||||
<span style="color:red;">* <%:need reload to apply changes%></span>
|
||||
<%end%>
|
||||
<br>
|
||||
<%local cfgs = mtkwifi.load_profile(dev.profile)%>
|
||||
<span> <%:Current Band%>: <%=mtkwifi.band(string.split(cfgs.WirelessMode,";")[1])%> <br/> </span>
|
||||
<% if dev.Enable == "0" then%>
|
||||
<span style="color:red;"> <%:Wireless device is disabled%> </span>
|
||||
<%else%>
|
||||
<span> <%:Work mode%>: <% if dev.ApCliEnable == "1" then %> APCli <% else %> AP <% end %> <br/> </span>
|
||||
<%local temp = mtkwifi.get_temp(dev.devname)%>
|
||||
<%if temp then%>
|
||||
<span> <%:Tempature%>: <%=temp%>°C <br/> </span>
|
||||
<%end%>
|
||||
<%local txpwr = mtkwifi.get_txpwr(dev.devname)%>
|
||||
<%if txpwr then%>
|
||||
<span> <%:Tx Power%>: <%=txpwr%> dbm <br/> </span>
|
||||
<%end%>
|
||||
<%end%>
|
||||
</td>
|
||||
<td style="width:310px;text-align:right">
|
||||
<div id="ActionBtns_<%=dev.devname%>">
|
||||
<%if not dev.vifs then%>
|
||||
<button class="cbi-button cbi-button-apply" id="reset" onclick="visit_url('<%=dev.devname%>',
|
||||
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "reset_to_defaults", dev.devname)%>')"><%:Restore Profile to Factory Settings%></button>
|
||||
<%else%>
|
||||
<button class="cbi-button cbi-button-reset" onclick="visit_url_confirm('<%:Are you sure to RELOAD%> <%=dev.devname%>?',
|
||||
'<%=dev.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>')"><%:RELOAD%></button>
|
||||
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=dev.devname%>',
|
||||
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "dev_cfg_view", dev.devname)%>')"><%:CONFIG%></button>
|
||||
<button class="cbi-button cbi-button-add" onclick='add_vif("<%=dev.devname%>","<%=dev.vifs.__prefix%>","<%=dev.maxVif%>")'><%:ADD%></button>
|
||||
<%end%>
|
||||
</div>
|
||||
<div id="BusyText_<%=dev.devname%>" style="display:none">
|
||||
<big><strong><%:Processing request.%></strong></big>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- /physical device -->
|
||||
<% if dev.vifs and dev.Enable == "1" then%>
|
||||
<!-- network list -->
|
||||
<% for _,vif in ipairs(dev.vifs) do %>
|
||||
<tr class="cbi-section-table-row cbi-rowstyle-1">
|
||||
<td></td>
|
||||
<td class="cbi-value-field" style="width:16px; padding:3px;padding-left:40px;">
|
||||
<% if vif.state == "up" then %>
|
||||
<img src="/luci-static/resources/icons/signal-75-100.png">
|
||||
<% else %>
|
||||
<img src="/luci-static/resources/icons/signal-none.png">
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px">
|
||||
<strong><%:Interface%>:</strong> <%=vif.vifname%> |
|
||||
<strong><%:Type%>:</strong> AP |
|
||||
<strong>SSID:</strong>
|
||||
<span id="SSID_<%=vif.vifname%>">
|
||||
<% if vif.__ssid == "" then %>
|
||||
<span style="color:red;"><%:Error: value not present in dat file%></span>
|
||||
<% else %>
|
||||
<span> <%=vif.__ssid and vif.__ssid:gsub(" "," ") or nil%> <% end %> </span>
|
||||
</span> |
|
||||
<strong><%:Channel%>:</strong>
|
||||
<span id="CHANNEL_<%=vif.vifname%>"><%=vif.__channel or dev.Channel%></span>
|
||||
<br>
|
||||
<% if vif.state == "up" then %>
|
||||
<strong>BSSID:</strong> <span id="BSSID_<%=vif.vifname%>"><%=vif.__bssid%></span> | <strong><%:Wireless Mode%>:</strong> <span><%=dev.WirelessModeList[tonumber(vif.__wirelessmode)]%></span>
|
||||
<% else %>
|
||||
<%:Wireless is disabled or not associated%>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="cbi-value-field" style="text-align:right">
|
||||
<div id="ActionBtns_<%=vif.vifname%>">
|
||||
<% if not vif.state then %>
|
||||
<button class="cbi-button cbi-button-apply" onclick="alert('Please click on Reload button of ' + '<%=dev.devname%>' + ' device to enable this interface.')"><%:ENABLE%></button>
|
||||
<% elseif vif.state == "up" then %>
|
||||
<button class="cbi-button cbi-button-reset" onclick="visit_url_confirm('<%:Are you sure to DISABLE%> <%=vif.vifname%>?',
|
||||
'<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", vif.vifname)%>')"><%:DISABLE%></button>
|
||||
<% else %>
|
||||
<button class="cbi-button cbi-button-apply" onclick="visit_url('<%=vif.vifname%>',
|
||||
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", vif.vifname)%>')"><%:ENABLE%></button>
|
||||
<% end %>
|
||||
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=vif.vifname%>',
|
||||
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_cfg_view", dev.devname, vif.vifname)%>')"><%:CONFIG%></button>
|
||||
<button class="cbi-button cbi-button-remove" onclick="visit_url_confirm('<%:Are you sure to REMOVE%> <%=vif.vifname%>?',
|
||||
'<%=vif.vifname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_del", dev.devname, vif.vifname)%>')"><%:REMOVE%></button>
|
||||
</div>
|
||||
<div id="BusyText_<%=vif.vifname%>" style="display:none">
|
||||
<big><strong><%:Processing request.%></strong></big>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- /network list -->
|
||||
<!-- apcli list -->
|
||||
<% if dev.apcli then %>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="cbi-value-field" style="width:16px; padding:3px;padding-left:40px;">
|
||||
<% if dev.apcli.state == "up" then %>
|
||||
<img src="/luci-static/resources/icons/signal-75-100.png">
|
||||
<% else %>
|
||||
<img src="/luci-static/resources/icons/signal-none.png">
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px"><strong><%:Interface%>:</strong> <%=dev.apcli.devname%> | <strong><%:Type%>:</strong> STA | <strong><%:Status%>:</strong> <span id="ConnStatus_<%=dev.apcli.devname%>"><% if dev.ApCliEnable ~= "1" then %> <%:Disconnected%> <% end %></span>
|
||||
<br>
|
||||
<div id="LoadingBar_<%=dev.apcli.devname%>" <% if dev.ApCliEnable ~= "1" then %> style="display:none" <% end %>>
|
||||
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="width:20px;height:20px;vertical-align:middle;"/> <cite> <%:Loading connection information of%> <%=dev.apcli.devname%></cite>
|
||||
</div>
|
||||
<div id="ConnInfo_<%=dev.apcli.devname%>" style="display:none">
|
||||
<strong>BSSID:</strong> <span id="ApCliBssid_<%=dev.apcli.devname%>"></span> |
|
||||
<strong>SSID:</strong> <span id="ApCliSsid_<%=dev.apcli.devname%>"></span>
|
||||
</div>
|
||||
<span id="DisConnMsg_<%=dev.apcli.devname%>" <% if dev.ApCliEnable == "1" then %> style="display:none" <% end %>><%:Wireless is disabled or not associated%></span>
|
||||
</td>
|
||||
<td style="text-align:right">
|
||||
<div id="ActionBtns_<%=dev.apcli.devname%>">
|
||||
<% if dev.ApCliEnable ~= "1" then %>
|
||||
<% if dev.apcli.state == "up" then %>
|
||||
<button class="cbi-button cbi-button-reset" onclick="visit_url_confirm('<%:Are you sure to DISABLE%> <%=dev.apcli.devname%>?',
|
||||
'<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", dev.apcli.vifname)%>')"><%:DISABLE%></button>
|
||||
<button class="cbi-button cbi-button-reload" onclick="visit_url_confirm('<%:Are you sure to RECONNECT%> <%=dev.apcli.devname%>?',
|
||||
'<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>')"><%:RECONNECT%></button>
|
||||
<% end %>
|
||||
<button class="cbi-button cbi-button-edit" onclick="visit_url('<%=dev.apcli.devname%>',
|
||||
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>')"><%:CONFIG%></button>
|
||||
<% else %>
|
||||
<button class="cbi-button cbi-button-reset" style="display:none" id="ApCliDownBtn_<%=dev.apcli.devname%>" onclick="visit_url_confirm('<%:Are you sure to DISABLE%> <%=dev.apcli.devname%>?',
|
||||
'<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", dev.apcli.vifname)%>')"><%:DISABLE%></button>
|
||||
<button class="cbi-button cbi-button-apply" style="display:none" id="ApCliUpBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>',
|
||||
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", dev.apcli.vifname)%>')"><%:ENABLE%></button>
|
||||
<button class="cbi-button cbi-button-remove" style="display:none" id="ApCliDisConnBtn_<%=dev.apcli.devname%>" onclick="visit_url_confirm('<%:Are you sure to DISCONNECT%> <%=dev.apcli.devname%>?',
|
||||
'<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>')"><%:DISCONNECT%></button>
|
||||
<button class="cbi-button cbi-button-reload" style="display:none" id="ApCliConnBtn_<%=dev.apcli.devname%>" onclick="visit_url_confirm('<%:Are you sure to RECONNECT%> <%=dev.apcli.devname%>?',
|
||||
'<%=dev.apcli.devname%>','<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>')"><%:RECONNECT%></button>
|
||||
<button class="cbi-button cbi-button-edit" style="display:none" id="ApCliCfgBtn_<%=dev.apcli.devname%>" onclick="visit_url('<%=dev.apcli.devname%>',
|
||||
'<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>')"><%:CONFIG%></button>
|
||||
<% end %>
|
||||
</div>
|
||||
<div id="BusyText_<%=dev.apcli.devname%>" style="display:none">
|
||||
<big><strong><%:Processing request.%></strong></big>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<!-- /apcli list -->
|
||||
<% end %>
|
||||
</tbody>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<h2><%:Station List%></h2>
|
||||
<table class="cbi-section-table" style="margin: auto" id="iw-assoclist">
|
||||
<tr class="cbi-section-table-titles">
|
||||
<th class="cbi-section-table-cell"><%:Interface%></th>
|
||||
<th class="cbi-section-table-cell">SSID</th>
|
||||
<th class="cbi-section-table-cell"><%:MAC-Address%></th>
|
||||
<th class="cbi-section-table-cell"><%:Hostname%></th>
|
||||
<th class="cbi-section-table-cell"><%:Security%></th>
|
||||
<th class="cbi-section-table-cell"><%:Signal%> (dBm)</th>
|
||||
<th class="cbi-section-table-cell"><%:TX Rate%></th>
|
||||
<th class="cbi-section-table-cell"><%:RX Rate%></th>
|
||||
<th class="cbi-section-table-cell"><%:Connected Time%></th>
|
||||
</tr>
|
||||
<tr class="cbi-section-table-row cbi-rowstyle-2">
|
||||
<td class="cbi-value-field" colspan="9">
|
||||
<em><%:Collecting data...%></em>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
|
||||
function clean_stalist_table()
|
||||
{
|
||||
var table = document.getElementById('iw-assoclist');
|
||||
//console.log("clean_aplist_table.aplist len=" + table.rows.length);
|
||||
while(table.rows.length > 1)
|
||||
table.deleteRow(-1);
|
||||
}
|
||||
|
||||
function is_rssi_valid(rssi)
|
||||
{
|
||||
if (rssi == "-109" || rssi == "-127")
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function insert_stalist_table(ifname, ssid, sta_list)
|
||||
{
|
||||
var i, tr_row, td_cell;
|
||||
var rssi_str, host_str;
|
||||
var tableid = document.getElementById('iw-assoclist');
|
||||
|
||||
for (i = 0; sta_list[i] ; i++){
|
||||
//console.log(sta_list[i]);
|
||||
tr_row = tableid.insertRow(-1);
|
||||
|
||||
tr_row.align = "center";
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = ifname;
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = ssid;
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].MacAddr;
|
||||
|
||||
host_str = sta_list[i].hostname
|
||||
if (sta_list[i].ipv4 != "")
|
||||
host_str = host_str + ", " + sta_list[i].ipv4
|
||||
if (sta_list[i].ipv6 != "")
|
||||
host_str = host_str + "<br>" + sta_list[i].ipv6
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = host_str;
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].security;
|
||||
|
||||
rssi_str = sta_list[i].AvgRssi0;
|
||||
if (is_rssi_valid(sta_list[i].AvgRssi1))
|
||||
rssi_str = rssi_str + ", " + sta_list[i].AvgRssi1;
|
||||
if (is_rssi_valid(sta_list[i].AvgRssi2))
|
||||
rssi_str = rssi_str + ", " + sta_list[i].AvgRssi2;
|
||||
if (is_rssi_valid(sta_list[i].AvgRssi3))
|
||||
rssi_str = rssi_str + ", " + sta_list[i].AvgRssi3;
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = rssi_str;
|
||||
|
||||
//TxRate
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].TxRate + "Mbps," + sta_list[i].Bw+ "MHz" + "<br>" + sta_list[i].PhyMode + ", " + sta_list[i].Mcs + ", " + sta_list[i].Gi;
|
||||
|
||||
//RxRate
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].RxRate + "Mbps," + sta_list[i].LastBw + "MHz" + "<br>" + sta_list[i].LastPhyMode + ", " + sta_list[i].LastMcs + ", " + sta_list[i].LastGi;
|
||||
|
||||
td_cell = tr_row.insertCell(-1);
|
||||
td_cell.innerHTML = sta_list[i].Hr + ":" + sta_list[i].Min + ":" + sta_list[i].Sec;
|
||||
}
|
||||
}
|
||||
|
||||
function disable_all_buttons()
|
||||
{
|
||||
var inp = document.getElementsByTagName("BUTTON");
|
||||
for(var idx=0; idx < inp.length; idx++){
|
||||
inp[idx].disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function enable_all_buttons()
|
||||
{
|
||||
var inp = document.getElementsByTagName("BUTTON");
|
||||
for(var idx=0; idx < inp.length; idx++){
|
||||
inp[idx].disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function visit_url(idSuffix,to)
|
||||
{
|
||||
//disable_all_buttons();
|
||||
//document.getElementById("ActionBtns_"+idSuffix).style.display = "none";
|
||||
//document.getElementById("BusyText_"+idSuffix).style.display = "";
|
||||
location.href = to;
|
||||
}
|
||||
|
||||
function visit_url_confirm(msg, idSuffix, to) {
|
||||
var i = confirm(msg);
|
||||
if (i)
|
||||
visit_url(idSuffix,to);
|
||||
}
|
||||
|
||||
function add_vif(devName, vifPrefix, maxVif)
|
||||
{
|
||||
if (!confirm('<%:Are you sure to ADD wireless interface?%>'))
|
||||
return;
|
||||
disable_all_buttons();
|
||||
document.getElementById("ActionBtns_"+devName).style.display = "none";
|
||||
document.getElementById("BusyText_"+devName).style.display = "";
|
||||
if(isNaN(maxVif) || !/^\d{1,}$/.test(maxVif)){
|
||||
alert("Failed to add a new interface!\nERROR: Incorrect maximum supported VIF setting!\nmaxVif = " + maxVif);
|
||||
location.reload(true);
|
||||
return;
|
||||
}
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_bssid_num")%>/' + devName, null,
|
||||
function(x)
|
||||
{
|
||||
try{
|
||||
var resp = JSON.parse(x.response);
|
||||
if(resp["status"] == "SUCCESS"){
|
||||
if(isNaN(resp["bssidNum"]) || !/^\d{1,}$/.test(resp["bssidNum"]) || parseInt(resp["bssidNum"]) > parseInt(maxVif)){
|
||||
alert("Failed to add a new interface!\nERROR: Device settings have been corrupted!\nBssidNum in Response is: " + resp["bssidNum"]);
|
||||
location.reload(true);
|
||||
}
|
||||
else if(parseInt(resp["bssidNum"]) == parseInt(maxVif)){
|
||||
alert("As the Device " + devName + " supports maximum " + maxVif + " virtual interfaces, no more virtual interfaces can be added!");
|
||||
}
|
||||
else{
|
||||
location.href = '<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_add_view")%>/' + devName + '/' + vifPrefix;
|
||||
}
|
||||
}
|
||||
else{
|
||||
alert("Failed to add a new interface!\nERROR: " + resp["status"]);
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
alert("Failed to add a new interface!\nERROR: Incorrect response received!");
|
||||
console.log("Failed to add a new interface!\nERROR: [" + e.name + "] " + e.message);
|
||||
}
|
||||
finally{
|
||||
enable_all_buttons();
|
||||
document.getElementById("ActionBtns_"+devName).style.display = "";
|
||||
document.getElementById("BusyText_"+devName).style.display = "none";
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
var stainfo = [];
|
||||
var stainfo_inited = 0;
|
||||
function staInfoHandler()
|
||||
{
|
||||
for (var i=0; stainfo[i]; i++) {
|
||||
//console.log(stainfo[i].ifname);
|
||||
XHR.poll(3, "<%=luci.dispatcher.build_url("admin", "network", "wifi", "sta_info")%>/" + stainfo[i].ifname, null,
|
||||
function(x)
|
||||
{
|
||||
try{
|
||||
stainfo_inited = 1;
|
||||
//console.log(x.responseText);
|
||||
var response = JSON.parse(x.responseText);
|
||||
for (var j=0; stainfo[j]; j++) {
|
||||
if (response[0].ifname == stainfo[j].ifname) {
|
||||
response.shift(); //delete first item
|
||||
stainfo[j].sta = response;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e){}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function printstainfo()
|
||||
{
|
||||
if (stainfo.length == 0) {
|
||||
clean_stalist_table();
|
||||
return;
|
||||
}
|
||||
if (stainfo_inited) {
|
||||
//console.log(stainfo);
|
||||
clean_stalist_table();
|
||||
var stabuf = stainfo;
|
||||
for (var i=0; stabuf[i]; i++) {
|
||||
insert_stalist_table(stabuf[i].ifname, stabuf[i].ssid, stabuf[i].sta);
|
||||
}
|
||||
}
|
||||
setTimeout(printstainfo, 2000);
|
||||
}
|
||||
|
||||
function apcliInfoTimerHandler(vifNameList,idx,remSec)
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_apcli_conn_info")%>/' + vifNameList[idx], null,
|
||||
function(x)
|
||||
{
|
||||
try{
|
||||
updateApCliInfoCb(vifNameList,idx,remSec,JSON.parse(x.response));
|
||||
}
|
||||
catch(e){
|
||||
var y={conn_state:"Disconnected"};
|
||||
updateApCliInfoCb(vifNameList,idx,0,y);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
function updateApCliInfoCb(vifNameList,idx,remSec,connInfo)
|
||||
{
|
||||
var vifName = vifNameList[idx];
|
||||
if(connInfo.hasOwnProperty("conn_state") && connInfo["conn_state"] == "Connected"){
|
||||
document.getElementById("ConnStatus_"+vifName).innerHTML = "<%:Connected%>";
|
||||
document.getElementById("ApCliBssid_"+vifName).innerHTML = (connInfo.hasOwnProperty("bssid")) ? connInfo["bssid"] : "?";
|
||||
document.getElementById("ApCliSsid_"+vifName).innerHTML = (connInfo.hasOwnProperty("ssid")) ? connInfo["ssid"].replace(/ /g," ") : "";
|
||||
document.getElementById("LoadingBar_"+vifName).style.display = "none";
|
||||
document.getElementById("ApCliDownBtn_"+vifName).style.display = "";
|
||||
document.getElementById("ApCliDisConnBtn_"+vifName).style.display = "";
|
||||
document.getElementById("ApCliCfgBtn_"+vifName).style.display = "";
|
||||
document.getElementById("ConnInfo_"+vifName).style.display = "";
|
||||
if(idx < vifNameList.length - 1){
|
||||
setTimeout(apcliInfoTimerHandler,1000,vifNameList,idx+1,5);
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(remSec > 1){
|
||||
setTimeout(apcliInfoTimerHandler,1000,vifNameList,idx,remSec - 1);
|
||||
}
|
||||
else{
|
||||
if (connInfo.hasOwnProperty("conn_state") && (connInfo["conn_state"] == "Connected")) {
|
||||
document.getElementById("ConnStatus_"+vifName).innerHTML = "<%:Connected%>";
|
||||
} else {
|
||||
document.getElementById("ConnStatus_"+vifName).innerHTML = "<%:Disconnected%>";
|
||||
}
|
||||
document.getElementById("LoadingBar_"+vifName).style.display = "none";
|
||||
document.getElementById("DisConnMsg_"+vifName).style.display = "";
|
||||
if (connInfo.hasOwnProperty("infc_state") && connInfo["infc_state"] == "up"){
|
||||
document.getElementById("ApCliDownBtn_"+vifName).style.display = "";
|
||||
}
|
||||
else{
|
||||
document.getElementById("ApCliUpBtn_"+vifName).style.display = "";
|
||||
}
|
||||
document.getElementById("ApCliConnBtn_"+vifName).style.display = "";
|
||||
document.getElementById("ApCliCfgBtn_"+vifName).style.display = "";
|
||||
if(idx < vifNameList.length - 1){
|
||||
setTimeout(apcliInfoTimerHandler,1000,vifNameList,idx+1,5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function updateApCliInfo()
|
||||
{
|
||||
var apCliInfcList=[];
|
||||
<% for _,dev in ipairs(devs) do %>
|
||||
<% if dev.apcli and dev.ApCliEnable == "1" then %>
|
||||
apCliInfcList.push("<%=dev.apcli.devname%>");
|
||||
<% end %>
|
||||
<% end %>
|
||||
if (apCliInfcList.length >= 1 ){
|
||||
setTimeout(apcliInfoTimerHandler,1000,apCliInfcList,0,3);
|
||||
}
|
||||
}
|
||||
|
||||
function get_apply_status_cb(rsp)
|
||||
{
|
||||
try{
|
||||
var r = JSON.parse(rsp);
|
||||
}
|
||||
catch(e){
|
||||
return;
|
||||
}
|
||||
if(r.status == "ON_PROGRESS"){
|
||||
var u = confirm("Device is applying the saved settings now!\n" +
|
||||
"It is recommended to wait until all the saved settings are applied.\n" +
|
||||
"Please click on 'OK' button to wait for the device.\n" +
|
||||
"or click on 'Cancel' button to configure the settings available in current web-page.");
|
||||
if (u == true) {
|
||||
location = '<%=luci.dispatcher.build_url("admin", "network", "wifi", "loading")%>' + window.location.pathname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_apply_status()
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "network", "wifi", "get_apply_status")%>', null,
|
||||
function(x)
|
||||
{
|
||||
console.log(x);
|
||||
get_apply_status_cb(x.response);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
window.onload = function(){
|
||||
get_apply_status();
|
||||
updateApCliInfo();
|
||||
<% for _,dev in ipairs(devs) do %>
|
||||
<% if dev.vifs then%>
|
||||
<% for _,vif in ipairs(dev.vifs) do %>
|
||||
<% if vif.state == "up" then %>
|
||||
stainfo.push({"ifname": "<%=vif.vifname%>", "ssid": "<%=vif.__ssid%>", "sta": ""});
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
staInfoHandler(stainfo);
|
||||
printstainfo();
|
||||
}
|
||||
</script>
|
||||
<%+footer%>
|
||||
File diff suppressed because it is too large
Load Diff
515
package/mtk/applications/luci-app-mtk/po/zh_Hans/mtk.po
Normal file
515
package/mtk/applications/luci-app-mtk/po/zh_Hans/mtk.po
Normal file
@@ -0,0 +1,515 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "Auto"
|
||||
msgstr "自动"
|
||||
|
||||
msgid "Disable"
|
||||
msgstr "禁用"
|
||||
|
||||
msgid "US"
|
||||
msgstr "US (美国)"
|
||||
|
||||
msgid "JP"
|
||||
msgstr "JP (日本)"
|
||||
|
||||
msgid "FR"
|
||||
msgstr "FR (法国)"
|
||||
|
||||
msgid "IE"
|
||||
msgstr "IE (爱尔兰)"
|
||||
|
||||
msgid "CN"
|
||||
msgstr "CN (中国)"
|
||||
|
||||
msgid "NONE"
|
||||
msgstr "无"
|
||||
|
||||
msgid "Short"
|
||||
msgstr "Short (短)"
|
||||
|
||||
msgid "long"
|
||||
msgstr "Long (长)"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Mandatory"
|
||||
msgstr "强制"
|
||||
|
||||
msgid "Always On"
|
||||
msgstr "始终开启"
|
||||
|
||||
msgid "Always Off"
|
||||
msgstr "始终关闭"
|
||||
|
||||
msgid "Tempature"
|
||||
msgstr "温度"
|
||||
|
||||
msgid "Tx Power"
|
||||
msgstr "发射功率"
|
||||
|
||||
msgid "Driver version"
|
||||
msgstr "驱动版本"
|
||||
|
||||
msgid "Current Band"
|
||||
msgstr "当前频段"
|
||||
|
||||
msgid "Work mode"
|
||||
msgstr "工作模式"
|
||||
|
||||
msgid "CONFIG"
|
||||
msgstr "配置"
|
||||
|
||||
msgid "RELOAD"
|
||||
msgstr "重载"
|
||||
|
||||
msgid "ADD"
|
||||
msgstr "添加"
|
||||
|
||||
msgid "RECONNECT"
|
||||
msgstr "重连"
|
||||
|
||||
msgid "DISABLE"
|
||||
msgstr "禁用"
|
||||
|
||||
msgid "ENABLE"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "REMOVE"
|
||||
msgstr "移除"
|
||||
|
||||
msgid "Station List"
|
||||
msgstr "已连接站点"
|
||||
|
||||
msgid "Interface"
|
||||
msgstr "接口"
|
||||
|
||||
msgid "MAC-Address"
|
||||
msgstr "MAC地址"
|
||||
|
||||
msgid "Signal"
|
||||
msgstr "信号强度"
|
||||
|
||||
msgid "TX Rate"
|
||||
msgstr "发射速率"
|
||||
|
||||
msgid "Rx Rate"
|
||||
msgstr "接收速率"
|
||||
|
||||
msgid "Connected Time"
|
||||
msgstr "已连接时间"
|
||||
|
||||
msgid "Channel"
|
||||
msgstr "信道"
|
||||
|
||||
msgid "Security Mode"
|
||||
msgstr "加密方式"
|
||||
|
||||
msgid "Action"
|
||||
msgstr "动作"
|
||||
|
||||
msgid "Choose This"
|
||||
msgstr "选择"
|
||||
|
||||
msgid "40MHz HT Ext Channel"
|
||||
msgstr "HT 40MHz 扩展信道"
|
||||
|
||||
msgid "80MHz Second VHT Channel"
|
||||
msgstr "VHT 80MHz 第二信道"
|
||||
|
||||
msgid "Type"
|
||||
msgstr "接口类型"
|
||||
|
||||
msgid "Status"
|
||||
msgstr "状态"
|
||||
|
||||
msgid "DISCONNECT"
|
||||
msgstr "断开"
|
||||
|
||||
msgid "Connected"
|
||||
msgstr "已连接"
|
||||
|
||||
msgid "Disconnected"
|
||||
msgstr "未连接"
|
||||
|
||||
msgid "FATAL ERROR: Incorrect Profile Settings"
|
||||
msgstr "严重错误: 配置文件设置不正确"
|
||||
|
||||
msgid "Error: value not present in dat file"
|
||||
msgstr "错误:dat文件中未指定SSID值"
|
||||
|
||||
msgid "Wireless is disabled or not associated"
|
||||
msgstr "无线已禁用或未关联"
|
||||
|
||||
msgid "Processing request."
|
||||
msgstr "正在处理请求..."
|
||||
|
||||
msgid "need reload to apply changes"
|
||||
msgstr "请重启无线以应用设置"
|
||||
|
||||
msgid "Click here"
|
||||
msgstr "点击此处"
|
||||
|
||||
msgid "to apply changes"
|
||||
msgstr "以应用设置"
|
||||
|
||||
msgid "Wireless Mode"
|
||||
msgstr "无线模式"
|
||||
|
||||
msgid "Chip Configurations"
|
||||
msgstr "无线芯片设置"
|
||||
|
||||
msgid "Device Configuration"
|
||||
msgstr "无线设备设置"
|
||||
|
||||
msgid "Interface Configurations"
|
||||
msgstr "无线接口设置"
|
||||
|
||||
msgid "ApCli Configurations"
|
||||
msgstr "ApCli设置"
|
||||
|
||||
msgid "Loading connection information of"
|
||||
msgstr "正在加载连接信息"
|
||||
|
||||
msgid "ApCli Available Wireless Networks"
|
||||
msgstr "ApCli可用无线网络列表"
|
||||
|
||||
msgid "ApCli Connection Configurations"
|
||||
msgstr "ApCli连接设置"
|
||||
|
||||
msgid "Decline BA Request"
|
||||
msgstr "拒绝BlockAck请求"
|
||||
|
||||
msgid "Reverse Direction Grant (RDG)"
|
||||
msgstr "HT反向授权(RDG)"
|
||||
|
||||
msgid "BA Win size"
|
||||
msgstr "Block Ack窗口大小"
|
||||
|
||||
msgid "HT Disallow TKIP"
|
||||
msgstr "不允许HT TKIP"
|
||||
|
||||
msgid "Wi-Fi HWNAT"
|
||||
msgstr "启用Wi-Fi硬件加速"
|
||||
|
||||
msgid "E2pAccessMode"
|
||||
msgstr "EEPROM访问方式"
|
||||
|
||||
msgid "Beacon Interval"
|
||||
msgstr "Beacon间隔"
|
||||
|
||||
msgid "Data Beacon Rate (DTIM)"
|
||||
msgstr "DTIM周期"
|
||||
|
||||
msgid "BG Protection Mode"
|
||||
msgstr "BG保护模式"
|
||||
|
||||
msgid "Short Preamble"
|
||||
msgstr "启用短前导码"
|
||||
|
||||
msgid "TX Burst"
|
||||
msgstr "启用突发传输"
|
||||
|
||||
msgid "Short Slot"
|
||||
msgstr "启用短时槽"
|
||||
|
||||
msgid "Channel Auto"
|
||||
msgstr "自动信道"
|
||||
|
||||
msgid "BSS color"
|
||||
msgstr "BSS颜色代码"
|
||||
|
||||
msgid "TWT Support"
|
||||
msgstr "TWT节能机制"
|
||||
|
||||
msgid "Country Code"
|
||||
msgstr "国家代码"
|
||||
|
||||
msgid "Country Region"
|
||||
msgstr "国家区域"
|
||||
|
||||
msgid "Channel BandWidth"
|
||||
msgstr "信道宽度"
|
||||
|
||||
msgid "TX Stream"
|
||||
msgstr "发射空间流"
|
||||
|
||||
msgid "RX Stream"
|
||||
msgstr "接收空间流"
|
||||
|
||||
msgid "TX Power"
|
||||
msgstr "发射功率"
|
||||
|
||||
msgid "DFS"
|
||||
msgstr "动态频率选择(DFS)"
|
||||
|
||||
msgid "Beam Forming and MIMO Setting"
|
||||
msgstr "波束成形与MU-MIMO设置"
|
||||
|
||||
msgid "Spatial Reuse"
|
||||
msgstr "空间复用"
|
||||
|
||||
msgid "Auth Mode"
|
||||
msgstr "认证模式"
|
||||
|
||||
msgid "Encryption"
|
||||
msgstr "加密方式"
|
||||
|
||||
msgid "Key Renewal Interval"
|
||||
msgstr "组密钥更新周期"
|
||||
|
||||
msgid "Key"
|
||||
msgstr "密码"
|
||||
|
||||
msgid "MFPC"
|
||||
msgstr "兼容保护管理帧(MFPC)"
|
||||
|
||||
msgid "MFPR"
|
||||
msgstr "强制保护管理帧(MFPR)"
|
||||
|
||||
msgid "Hidden SSID"
|
||||
msgstr "隐藏SSID"
|
||||
|
||||
msgid "AP Isolation"
|
||||
msgstr "启用AP隔离"
|
||||
|
||||
msgid "WMM Capable"
|
||||
msgstr "启用WMM"
|
||||
|
||||
msgid "Fixed TX Rate"
|
||||
msgstr "固定发射速率"
|
||||
|
||||
msgid "HT STBC"
|
||||
msgstr "启用HT STBC"
|
||||
|
||||
msgid "HT LDPC"
|
||||
msgstr "启用HT LDPC"
|
||||
|
||||
msgid "VHT STBC"
|
||||
msgstr "启用VHT STBC"
|
||||
|
||||
msgid "VHT LDPC"
|
||||
msgstr "启用VHT LDPC"
|
||||
|
||||
msgid "DLS Capable"
|
||||
msgstr "启用终端直通(DLS)"
|
||||
|
||||
msgid "802.11k RRM"
|
||||
msgstr "启用 802.11k"
|
||||
|
||||
msgid "802.11r FT"
|
||||
msgstr "启用 802.11r"
|
||||
|
||||
msgid "APSD Capable"
|
||||
msgstr "启用节能模式(APSD)"
|
||||
|
||||
msgid "Fragment Threshold"
|
||||
msgstr "分片阈值"
|
||||
|
||||
msgid "RTS Threshold"
|
||||
msgstr "RTS阈值"
|
||||
|
||||
msgid "VHT Short GI"
|
||||
msgstr "VHT保护间隔(GI)"
|
||||
|
||||
msgid "VHT BW Signaling"
|
||||
msgstr "VHT动态频宽信令"
|
||||
|
||||
msgid "Dynamic"
|
||||
msgstr "动态"
|
||||
|
||||
msgid "HT Protection"
|
||||
msgstr "HT保护模式"
|
||||
|
||||
msgid "HT Guard Interval"
|
||||
msgstr "HT保护间隔(GI)"
|
||||
|
||||
msgid "HT Operating Mode"
|
||||
msgstr "HT操作模式"
|
||||
|
||||
msgid "HT Mixed Mode"
|
||||
msgstr "HT混合模式(Mixed)"
|
||||
|
||||
msgid "HT Green Field"
|
||||
msgstr "HT绿野模式(Green Field)"
|
||||
|
||||
msgid "Auto Block ACK"
|
||||
msgstr "自动块确认(BlockAck)"
|
||||
|
||||
msgid "Access Control"
|
||||
msgstr "访问控制"
|
||||
|
||||
msgid "Access Policy"
|
||||
msgstr "访问控制策略"
|
||||
|
||||
msgid "Access control MAC address list"
|
||||
msgstr "访问控制MAC地址列表"
|
||||
|
||||
msgid "White List"
|
||||
msgstr "白名单模式"
|
||||
|
||||
msgid "Black List"
|
||||
msgstr "黑名单模式"
|
||||
|
||||
msgid "Basic Settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "HE Settings"
|
||||
msgstr "HE设置"
|
||||
|
||||
msgid "DL OFDMA"
|
||||
msgstr "下行OFDMA"
|
||||
|
||||
msgid "UL OFDMA"
|
||||
msgstr "上行OFDMA"
|
||||
|
||||
msgid "DL MU-MIMO"
|
||||
msgstr "下行MU-MIMO"
|
||||
|
||||
msgid "UL MU-MIMO"
|
||||
msgstr "上行MU-MIMO"
|
||||
|
||||
msgid "Scan Wireless Network"
|
||||
msgstr "扫描无线网络"
|
||||
|
||||
msgid "ApClient Mode"
|
||||
msgstr "AP客户端模式"
|
||||
|
||||
msgid "APClient/Repeater Mode."
|
||||
msgstr "AP客户端中继模式。"
|
||||
|
||||
msgid "MAC Repeater Mode"
|
||||
msgstr "启用MAC中继模式"
|
||||
|
||||
msgid "Root AP SSID"
|
||||
msgstr "上级AP SSID"
|
||||
|
||||
msgid "Root AP Channel"
|
||||
msgstr "上级AP信道"
|
||||
|
||||
msgid "Root AP Authentication Mode"
|
||||
msgstr "上级AP认证方式"
|
||||
|
||||
msgid "Root AP Encryption"
|
||||
msgstr "上级AP加密方式"
|
||||
|
||||
msgid "Root AP WPA Key"
|
||||
msgstr "上级AP WPA密钥"
|
||||
|
||||
msgid "ApCli MFPC"
|
||||
msgstr "ApCli兼容保护管理帧(MFPC)"
|
||||
|
||||
msgid "ApCli MFPR"
|
||||
msgstr "ApCli强制保护管理帧(MFPR)"
|
||||
|
||||
msgid "ApCli MFPSHA256"
|
||||
msgstr "ApCli启用SHA256保护管理帧"
|
||||
|
||||
msgid "WEP Default Key"
|
||||
msgstr "WEP默认密钥ID"
|
||||
|
||||
msgid "Root AP WEP Key"
|
||||
msgstr "上级AP WEP密钥"
|
||||
|
||||
msgid "Length"
|
||||
msgstr "长度"
|
||||
|
||||
msgid "WEP Key"
|
||||
msgstr "WEP密钥"
|
||||
|
||||
msgid "WEP Key Type"
|
||||
msgstr "WEP密钥类型"
|
||||
|
||||
msgid "PMK Cache Period"
|
||||
msgstr "PMK缓存周期"
|
||||
|
||||
msgid "WEP for 8021X"
|
||||
msgstr "启用8021X WEP"
|
||||
|
||||
msgid "Pre-Authentication"
|
||||
msgstr "启用预认证"
|
||||
|
||||
msgid "Radius Server IP"
|
||||
msgstr "Radius认证服务器IP"
|
||||
|
||||
msgid "Radius Server Port"
|
||||
msgstr "Radius认证服务器端口"
|
||||
|
||||
msgid "Radius Key"
|
||||
msgstr "Radius密钥"
|
||||
|
||||
msgid "Radius Session Timeout"
|
||||
msgstr "Radius会话超时时间"
|
||||
|
||||
msgid "Radius Idle Timeout"
|
||||
msgstr "Radius空闲超时时间"
|
||||
|
||||
msgid "MFPSHA256"
|
||||
msgstr "启用SHA256保护管理帧"
|
||||
|
||||
msgid "Please wait while the settings are being applied."
|
||||
msgstr "正在应用设置,请稍候。"
|
||||
|
||||
msgid "Please wait while the request is being processed."
|
||||
msgstr "正在处理请求,请稍候。"
|
||||
|
||||
msgid "No wireless device found!"
|
||||
msgstr "未找到无线设备!"
|
||||
|
||||
msgid "Please input a valid radius server port number."
|
||||
msgstr "请输入有效的Radius服务器端口号。"
|
||||
|
||||
msgid "The radius shared secret contains invalid characters."
|
||||
msgstr "Radius密钥包含无效字符。"
|
||||
|
||||
msgid "Please input a valid session timeout number or u may have left it empty."
|
||||
msgstr "请输入有效的Radius会话超时时间。"
|
||||
|
||||
msgid "Radius session time out is empty."
|
||||
msgstr "Radius会话超时时间为空。"
|
||||
|
||||
msgid "Please input a valid idle timeout number or u may have left it empty."
|
||||
msgstr "请输入有效的Radius空闲超时时间。"
|
||||
|
||||
msgid "Radius idle time out is empty."
|
||||
msgstr "Radius空闲超时时间为空。"
|
||||
|
||||
msgid "IGMP Snooping"
|
||||
msgstr "IGMP 侦听"
|
||||
|
||||
msgid "Security"
|
||||
msgstr "安全性"
|
||||
|
||||
msgid "Restore Profile to Factory Settings"
|
||||
msgstr "恢复无线配置文件为出厂设置"
|
||||
|
||||
msgid "Are you sure to RELOAD"
|
||||
msgstr "你确认要重载"
|
||||
|
||||
msgid "Are you sure to DISABLE"
|
||||
msgstr "你确认要禁用"
|
||||
|
||||
msgid "Are you sure to REMOVE"
|
||||
msgstr "你确认要移除"
|
||||
|
||||
msgid "Are you sure to RECONNECT"
|
||||
msgstr "你确认要重新连接"
|
||||
|
||||
msgid "Are you sure to DISCONNECT"
|
||||
msgstr "你确认要断开"
|
||||
|
||||
msgid "Are you sure to ADD wireless interface?"
|
||||
msgstr "你确认要新增无线接口?"
|
||||
|
||||
msgid "Enable wireless device"
|
||||
msgstr "启用此无线设备"
|
||||
|
||||
msgid "Wireless device is disabled"
|
||||
msgstr "无线设备已禁用"
|
||||
|
||||
msgid "Kick STA Threshold"
|
||||
msgstr "弱信号剔除阈值"
|
||||
|
||||
msgid "STA Assoc Threshold"
|
||||
msgstr "弱信号接入阈值"
|
||||
177
package/mtk/applications/luci-app-mtk/root/sbin/l1dat
Normal file
177
package/mtk/applications/luci-app-mtk/root/sbin/l1dat
Normal file
@@ -0,0 +1,177 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
-- Constant Definition
|
||||
local FW_PATH = "/lib/firmware/"
|
||||
local MTD_PATH = "/dev/"
|
||||
local MTD_TABLE = "/proc/mtd"
|
||||
local E2P_PART_NAME = "Factory"
|
||||
local E2P_FILE_NAME = "e2p"
|
||||
|
||||
|
||||
function show_usage()
|
||||
print("Usage: l1dat genconfig | dbg | idx2if idx | if2zone ifname | if2dat ifname | zone2if zone | if2dbdcidx ifname")
|
||||
end
|
||||
|
||||
function print_err(msg)
|
||||
io.stderr:write("[ERR][l1dat] "..msg)
|
||||
end
|
||||
|
||||
if not pcall(require, "l1dat_parser") then
|
||||
if arg[1] == "dbg" then
|
||||
print_err("Load l1dat_parser module failed\n")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local l1parser = require("l1dat_parser")
|
||||
local l1dat = l1parser.load_l1_profile(l1parser.L1_DAT_PATH)
|
||||
|
||||
if not l1dat then
|
||||
if arg[1] == "dbg" then
|
||||
print_err("l1profile.dat is ivalid\n")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
function read_pipe(pipe)
|
||||
local fp = io.popen(pipe)
|
||||
local txt = fp:read("*a")
|
||||
fp:close()
|
||||
return txt
|
||||
end
|
||||
|
||||
function eeprom_extract(part, offset, size, bin_name)
|
||||
local part_name = part or E2P_PART_NAME
|
||||
local dump_name = bin_name or E2P_FILE_NAME
|
||||
|
||||
if not offset or not size or tonumber(offset) < 0 or tonumber(size) < 0 then
|
||||
print_err("Invalid offset or size value")
|
||||
return
|
||||
end
|
||||
local offset_decimal = string.format("%d", offset)
|
||||
local size_decimal = string.format("%d", size)
|
||||
|
||||
local cmd = "cat "..MTD_TABLE.." | grep "..part_name
|
||||
local mtd = read_pipe(cmd)
|
||||
if not mtd or mtd == "" then
|
||||
print_err("mtd partition "..part_name.." not found")
|
||||
return
|
||||
end
|
||||
|
||||
cmd = "[ -e "..FW_PATH.." ] || mkdir "..FW_PATH
|
||||
os.execute(cmd)
|
||||
|
||||
local mtd_node = "/dev/"..string.match(mtd, "(mtd[%d]+)")
|
||||
cmd = "dd if="..mtd_node.." of="..FW_PATH..dump_name.." bs=1 skip="..offset_decimal.." count="..size_decimal.." seek="..offset_decimal.." conv=notrunc 2>/dev/null"
|
||||
os.execute(cmd)
|
||||
end
|
||||
|
||||
local action0 = {
|
||||
["dbg"] = function()
|
||||
show_usage()
|
||||
end,
|
||||
|
||||
["genconfig"] = function()
|
||||
local seen = {}
|
||||
local dridx = l1parser.DEV_RINDEX
|
||||
local cmd = ""
|
||||
local dir = ""
|
||||
for name, dev in pairs(l1dat[dridx]) do
|
||||
if not seen[dev] then
|
||||
seen[dev] = true
|
||||
dir = string.match(dev["profile_path"], "^(.+)/")
|
||||
--print("mkdir -p "..dir)
|
||||
os.execute("mkdir -p "..dir)
|
||||
cmd = "ralink_init gen "..dev["nvram_zone"].." "..dev["profile_path"]
|
||||
--print(cmd)
|
||||
os.execute(cmd)
|
||||
|
||||
eeprom_extract(E2P_PART_NAME, dev.EEPROM_offset, dev.EEPROM_size, dev.EEPROM_name)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
["if2zone"] = function(ifname)
|
||||
if not ifname then return end
|
||||
|
||||
local zone = l1parser.l1_ifname_to_zone(ifname) or ""
|
||||
print(zone);
|
||||
end,
|
||||
|
||||
["if2dat"] = function(ifname)
|
||||
if not ifname then return end
|
||||
|
||||
local dat_path = l1parser.l1_ifname_to_datpath(ifname) or ""
|
||||
print(dat_path)
|
||||
end,
|
||||
|
||||
["zone2if"] = function(zone)
|
||||
if not zone then return end
|
||||
|
||||
local main_if, ext_if, apcli, wds, mesh = l1parser.l1_zone_to_ifname(zone)
|
||||
|
||||
if main_if then
|
||||
print(main_if.." "..ext_if.." "..apcli.." "..wds.." "..mesh)
|
||||
end
|
||||
end,
|
||||
|
||||
["idx2if"] = function(idx)
|
||||
if not idx then return end
|
||||
|
||||
idx = tonumber(idx)
|
||||
|
||||
local band_num = l1parser.MAX_NUM_DBDC_BAND
|
||||
local dbdc_if
|
||||
local count = 0
|
||||
for k, v in pairs(l1dat) do
|
||||
-- check if last dbdc exists
|
||||
dbdc_if = l1parser.token_get(v.main_ifname, band_num, nil)
|
||||
if dbdc_if then
|
||||
count = count + band_num;
|
||||
else
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
if not dbdc_if and count == idx then
|
||||
print(v.main_ifname)
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
if count >= idx then -- dbdc case
|
||||
local token_num = band_num - ( count - idx )
|
||||
print(l1parser.token_get(v.main_ifname, token_num, nil))
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
["if2dbdcidx"] = function(ifname)
|
||||
if not ifname then return end
|
||||
|
||||
local ridx = l1parser.IF_RINDEX
|
||||
|
||||
if not l1dat[ridx][ifname] then return end
|
||||
|
||||
print(l1dat[ridx][ifname]["subidx"] or "0")
|
||||
end
|
||||
}
|
||||
|
||||
if #arg == 0 then
|
||||
show_usage()
|
||||
return
|
||||
end
|
||||
|
||||
if action0[arg[1]] then
|
||||
if #arg == 1 then
|
||||
--print("#arg == 1", arg[1])
|
||||
action0[arg[1]]()
|
||||
elseif #arg == 2 then
|
||||
--print("#arg == 1", arg[1], arg[2])
|
||||
action0[arg[1]](arg[2])
|
||||
end
|
||||
else
|
||||
print_err("invalid arg \""..arg[1].."\"\n");
|
||||
end
|
||||
|
||||
@@ -0,0 +1,337 @@
|
||||
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table
|
||||
local inspect = {Options = {}, }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inspect._VERSION = 'inspect.lua 3.1.0'
|
||||
inspect._URL = 'http://github.com/kikito/inspect.lua'
|
||||
inspect._DESCRIPTION = 'human-readable representations of tables'
|
||||
inspect._LICENSE = [[
|
||||
MIT LICENSE
|
||||
|
||||
Copyright (c) 2022 Enrique García Cota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
]]
|
||||
inspect.KEY = setmetatable({}, { __tostring = function() return 'inspect.KEY' end })
|
||||
inspect.METATABLE = setmetatable({}, { __tostring = function() return 'inspect.METATABLE' end })
|
||||
|
||||
local tostring = tostring
|
||||
local rep = string.rep
|
||||
local match = string.match
|
||||
local char = string.char
|
||||
local gsub = string.gsub
|
||||
local fmt = string.format
|
||||
|
||||
local function rawpairs(t)
|
||||
return next, t, nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function smartQuote(str)
|
||||
if match(str, '"') and not match(str, "'") then
|
||||
return "'" .. str .. "'"
|
||||
end
|
||||
return '"' .. gsub(str, '"', '\\"') .. '"'
|
||||
end
|
||||
|
||||
|
||||
local shortControlCharEscapes = {
|
||||
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
|
||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\127"] = "\\127",
|
||||
}
|
||||
local longControlCharEscapes = { ["\127"] = "\127" }
|
||||
for i = 0, 31 do
|
||||
local ch = char(i)
|
||||
if not shortControlCharEscapes[ch] then
|
||||
shortControlCharEscapes[ch] = "\\" .. i
|
||||
longControlCharEscapes[ch] = fmt("\\%03d", i)
|
||||
end
|
||||
end
|
||||
|
||||
local function escape(str)
|
||||
return (gsub(gsub(gsub(str, "\\", "\\\\"),
|
||||
"(%c)%f[0-9]", longControlCharEscapes),
|
||||
"%c", shortControlCharEscapes))
|
||||
end
|
||||
|
||||
local function isIdentifier(str)
|
||||
return type(str) == "string" and not not str:match("^[_%a][_%a%d]*$")
|
||||
end
|
||||
|
||||
local flr = math.floor
|
||||
local function isSequenceKey(k, sequenceLength)
|
||||
return type(k) == "number" and
|
||||
flr(k) == k and
|
||||
1 <= (k) and
|
||||
k <= sequenceLength
|
||||
end
|
||||
|
||||
local defaultTypeOrders = {
|
||||
['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4,
|
||||
['function'] = 5, ['userdata'] = 6, ['thread'] = 7,
|
||||
}
|
||||
|
||||
local function sortKeys(a, b)
|
||||
local ta, tb = type(a), type(b)
|
||||
|
||||
|
||||
if ta == tb and (ta == 'string' or ta == 'number') then
|
||||
return (a) < (b)
|
||||
end
|
||||
|
||||
local dta = defaultTypeOrders[ta] or 100
|
||||
local dtb = defaultTypeOrders[tb] or 100
|
||||
|
||||
|
||||
return dta == dtb and ta < tb or dta < dtb
|
||||
end
|
||||
|
||||
local function getKeys(t)
|
||||
|
||||
local seqLen = 1
|
||||
while rawget(t, seqLen) ~= nil do
|
||||
seqLen = seqLen + 1
|
||||
end
|
||||
seqLen = seqLen - 1
|
||||
|
||||
local keys, keysLen = {}, 0
|
||||
for k in rawpairs(t) do
|
||||
if not isSequenceKey(k, seqLen) then
|
||||
keysLen = keysLen + 1
|
||||
keys[keysLen] = k
|
||||
end
|
||||
end
|
||||
table.sort(keys, sortKeys)
|
||||
return keys, keysLen, seqLen
|
||||
end
|
||||
|
||||
local function countCycles(x, cycles)
|
||||
if type(x) == "table" then
|
||||
if cycles[x] then
|
||||
cycles[x] = cycles[x] + 1
|
||||
else
|
||||
cycles[x] = 1
|
||||
for k, v in rawpairs(x) do
|
||||
countCycles(k, cycles)
|
||||
countCycles(v, cycles)
|
||||
end
|
||||
countCycles(getmetatable(x), cycles)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function makePath(path, a, b)
|
||||
local newPath = {}
|
||||
local len = #path
|
||||
for i = 1, len do newPath[i] = path[i] end
|
||||
|
||||
newPath[len + 1] = a
|
||||
newPath[len + 2] = b
|
||||
|
||||
return newPath
|
||||
end
|
||||
|
||||
|
||||
local function processRecursive(process,
|
||||
item,
|
||||
path,
|
||||
visited)
|
||||
if item == nil then return nil end
|
||||
if visited[item] then return visited[item] end
|
||||
|
||||
local processed = process(item, path)
|
||||
if type(processed) == "table" then
|
||||
local processedCopy = {}
|
||||
visited[item] = processedCopy
|
||||
local processedKey
|
||||
|
||||
for k, v in rawpairs(processed) do
|
||||
processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY), visited)
|
||||
if processedKey ~= nil then
|
||||
processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey), visited)
|
||||
end
|
||||
end
|
||||
|
||||
local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE), visited)
|
||||
if type(mt) ~= 'table' then mt = nil end
|
||||
setmetatable(processedCopy, mt)
|
||||
processed = processedCopy
|
||||
end
|
||||
return processed
|
||||
end
|
||||
|
||||
local function puts(buf, str)
|
||||
buf.n = buf.n + 1
|
||||
buf[buf.n] = str
|
||||
end
|
||||
|
||||
|
||||
|
||||
local Inspector = {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local Inspector_mt = { __index = Inspector }
|
||||
|
||||
local function tabify(inspector)
|
||||
puts(inspector.buf, inspector.newline .. rep(inspector.indent, inspector.level))
|
||||
end
|
||||
|
||||
function Inspector:getId(v)
|
||||
local id = self.ids[v]
|
||||
local ids = self.ids
|
||||
if not id then
|
||||
local tv = type(v)
|
||||
id = (ids[tv] or 0) + 1
|
||||
ids[v], ids[tv] = id, id
|
||||
end
|
||||
return tostring(id)
|
||||
end
|
||||
|
||||
function Inspector:putValue(v)
|
||||
local buf = self.buf
|
||||
local tv = type(v)
|
||||
if tv == 'string' then
|
||||
puts(buf, smartQuote(escape(v)))
|
||||
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or
|
||||
tv == 'cdata' or tv == 'ctype' then
|
||||
puts(buf, tostring(v))
|
||||
elseif tv == 'table' and not self.ids[v] then
|
||||
local t = v
|
||||
|
||||
if t == inspect.KEY or t == inspect.METATABLE then
|
||||
puts(buf, tostring(t))
|
||||
elseif self.level >= self.depth then
|
||||
puts(buf, '{...}')
|
||||
else
|
||||
if self.cycles[t] > 1 then puts(buf, fmt('<%d>', self:getId(t))) end
|
||||
|
||||
local keys, keysLen, seqLen = getKeys(t)
|
||||
|
||||
puts(buf, '{')
|
||||
self.level = self.level + 1
|
||||
|
||||
for i = 1, seqLen + keysLen do
|
||||
if i > 1 then puts(buf, ',') end
|
||||
if i <= seqLen then
|
||||
puts(buf, ' ')
|
||||
self:putValue(t[i])
|
||||
else
|
||||
local k = keys[i - seqLen]
|
||||
tabify(self)
|
||||
if isIdentifier(k) then
|
||||
puts(buf, k)
|
||||
else
|
||||
puts(buf, "[")
|
||||
self:putValue(k)
|
||||
puts(buf, "]")
|
||||
end
|
||||
puts(buf, ' = ')
|
||||
self:putValue(t[k])
|
||||
end
|
||||
end
|
||||
|
||||
local mt = getmetatable(t)
|
||||
if type(mt) == 'table' then
|
||||
if seqLen + keysLen > 0 then puts(buf, ',') end
|
||||
tabify(self)
|
||||
puts(buf, '<metatable> = ')
|
||||
self:putValue(mt)
|
||||
end
|
||||
|
||||
self.level = self.level - 1
|
||||
|
||||
if keysLen > 0 or type(mt) == 'table' then
|
||||
tabify(self)
|
||||
elseif seqLen > 0 then
|
||||
puts(buf, ' ')
|
||||
end
|
||||
|
||||
puts(buf, '}')
|
||||
end
|
||||
|
||||
else
|
||||
puts(buf, fmt('<%s %d>', tv, self:getId(v)))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function inspect.inspect(root, options)
|
||||
options = options or {}
|
||||
|
||||
local depth = options.depth or (math.huge)
|
||||
local newline = options.newline or '\n'
|
||||
local indent = options.indent or ' '
|
||||
local process = options.process
|
||||
|
||||
if process then
|
||||
root = processRecursive(process, root, {}, {})
|
||||
end
|
||||
|
||||
local cycles = {}
|
||||
countCycles(root, cycles)
|
||||
|
||||
local inspector = setmetatable({
|
||||
buf = { n = 0 },
|
||||
ids = {},
|
||||
cycles = cycles,
|
||||
depth = depth,
|
||||
level = 0,
|
||||
newline = newline,
|
||||
indent = indent,
|
||||
}, Inspector_mt)
|
||||
|
||||
inspector:putValue(root)
|
||||
|
||||
return table.concat(inspector.buf)
|
||||
end
|
||||
|
||||
setmetatable(inspect, {
|
||||
__call = function(_, root, options)
|
||||
return inspect.inspect(root, options)
|
||||
end,
|
||||
})
|
||||
|
||||
return inspect
|
||||
@@ -0,0 +1,349 @@
|
||||
#!/usr/bin/env lua
|
||||
|
||||
--[[
|
||||
* A lua library to manipulate mtk's wifi driver. used in luci-app-mtk.
|
||||
*
|
||||
* Copyright (C) 2016 MTK <support@mediatek.com>
|
||||
*
|
||||
* 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 l1dat_parser = {
|
||||
L1_DAT_PATH = "/etc/wireless/l1profile.dat",
|
||||
IF_RINDEX = "ifname_ridx",
|
||||
DEV_RINDEX = "devname_ridx",
|
||||
MAX_NUM_APCLI = 1,
|
||||
MAX_NUM_WDS = 4,
|
||||
MAX_NUM_MESH = 1,
|
||||
MAX_NUM_EXTIF = 16,
|
||||
MAX_NUM_DBDC_BAND = 2,
|
||||
}
|
||||
|
||||
local l1cfg_options = {
|
||||
ext_ifname="",
|
||||
apcli_ifname="apcli",
|
||||
wds_ifname="wds",
|
||||
mesh_ifname="mesh"
|
||||
}
|
||||
|
||||
function l1dat_parser.__trim(s)
|
||||
if s then return (s:gsub("^%s*(.-)%s*$", "%1")) end
|
||||
end
|
||||
|
||||
function l1dat_parser.__cfg2list(str)
|
||||
-- delimeter == ";"
|
||||
local i = 1
|
||||
local list = {}
|
||||
for k in string.gmatch(str, "([^;]+)") do
|
||||
list[i] = k
|
||||
i = i + 1
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
function l1dat_parser.token_get(str, n, v)
|
||||
-- n starts from 1
|
||||
-- v is the backup in case token n is nil
|
||||
if not str then return v end
|
||||
local tmp = l1dat_parser.__cfg2list(str)
|
||||
return tmp[tonumber(n)] or v
|
||||
end
|
||||
|
||||
function l1dat_parser.add_default_value(l1cfg)
|
||||
for k, v in ipairs(l1cfg) do
|
||||
|
||||
for opt, default in pairs(l1cfg_options) do
|
||||
if ( opt == "ext_ifname" ) then
|
||||
v[opt] = v[opt] or v["main_ifname"].."_"
|
||||
else
|
||||
v[opt] = v[opt] or default..k.."_"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return l1cfg
|
||||
end
|
||||
|
||||
function l1dat_parser.get_value_by_idx(devidx, mainidx, subidx, key)
|
||||
--print("Enter l1dat_parser.get_value_by_idx("..devidx..","..mainidx..", "..subidx..", "..key..")<br>")
|
||||
if not devidx or not mainidx or not key then return end
|
||||
|
||||
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||
if not devs then return end
|
||||
|
||||
local dev_ridx = l1dat_parser.DEV_RINDEX
|
||||
local sidx = subidx or 1
|
||||
local devname1 = devidx.."."..mainidx
|
||||
local devname2 = devidx.."."..mainidx.."."..sidx
|
||||
|
||||
--print("devnam1=", devname1, "devname2=", devname2, "<br>")
|
||||
return devs[dev_ridx][devname2] and devs[dev_ridx][devname2][key]
|
||||
or devs[dev_ridx][devname1] and devs[dev_ridx][devname1][key]
|
||||
end
|
||||
|
||||
-- path to zone is 1 to 1 mapping
|
||||
function l1dat_parser.l1_path_to_zone(path)
|
||||
--print("Enter l1dat_parser.l1_path_to_zone("..path..")<br>")
|
||||
if not path then return end
|
||||
|
||||
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||
if not devs then return end
|
||||
|
||||
for _, dev in pairs(devs[l1dat_parser.IF_RINDEX]) do
|
||||
if dev.profile_path == path then
|
||||
return dev.nvram_zone
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- zone to path is 1 to n mapping
|
||||
function l1dat_parser.l1_zone_to_path(zone)
|
||||
if not zone then return end
|
||||
|
||||
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||
if not devs then return end
|
||||
|
||||
local plist = {}
|
||||
for _, dev in pairs(devs[l1dat_parser.IF_RINDEX]) do
|
||||
if dev.nvram_zone == zone then
|
||||
if not next(plist) then
|
||||
table.insert(plist,dev.profile_path)
|
||||
else
|
||||
local plist_str = table.concat(plist)
|
||||
if not plist_str:match(dev.profile_path) then
|
||||
table.insert(plist,dev.profile_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return next(plist) and plist or nil
|
||||
end
|
||||
|
||||
function l1dat_parser.l1_ifname_to_datpath(ifname)
|
||||
if not ifname then return end
|
||||
|
||||
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||
if not devs then return end
|
||||
|
||||
local ridx = l1dat_parser.IF_RINDEX
|
||||
return devs[ridx][ifname] and devs[ridx][ifname].profile_path
|
||||
end
|
||||
|
||||
function l1dat_parser.l1_ifname_to_zone(ifname)
|
||||
if not ifname then return end
|
||||
|
||||
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||
if not devs then return end
|
||||
|
||||
local ridx = l1dat_parser.IF_RINDEX
|
||||
return devs[ridx][ifname] and devs[ridx][ifname].nvram_zone
|
||||
end
|
||||
|
||||
function l1dat_parser.l1_zone_to_ifname(zone)
|
||||
if not zone then return end
|
||||
|
||||
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||
if not devs then return end
|
||||
|
||||
local zone_dev
|
||||
for _, dev in pairs(devs[l1dat_parser.DEV_RINDEX]) do
|
||||
if dev.nvram_zone == zone then
|
||||
zone_dev = dev
|
||||
end
|
||||
end
|
||||
|
||||
if not zone_dev then
|
||||
return nil
|
||||
else
|
||||
return zone_dev.main_ifname, zone_dev.ext_ifname, zone_dev.apcli_ifname, zone_dev.wds_ifname, zone_dev.mesh_ifname
|
||||
end
|
||||
end
|
||||
|
||||
-- input: L1 profile path.
|
||||
-- output A table, devs, contains
|
||||
-- 1. devs[%d] = table of each INDEX# in the L1 profile
|
||||
-- 2. devs.ifname_ridx[ifname]
|
||||
-- = table of each ifname and point to relevant contain in dev[$d]
|
||||
-- 3. devs.devname_ridx[devname] similar to devs.ifnameridx, but use devname.
|
||||
-- devname = INDEX#_value.mainidx(.subidx)
|
||||
-- Using *_ridx do not need to handle name=k1;k2 case of DBDC card.
|
||||
function l1dat_parser.load_l1_profile(path)
|
||||
local devs = setmetatable({}, {__index=
|
||||
function(tbl, key)
|
||||
local util = require("luci.util")
|
||||
--print("metatable function:", util.serialize_data(tbl), key)
|
||||
--print("-----------------------------------------------")
|
||||
if ( string.match(key, "^%d+")) then
|
||||
tbl[key] = {}
|
||||
return tbl[key]
|
||||
end
|
||||
end
|
||||
})
|
||||
local nixio = require("nixio")
|
||||
local chipset_num = {}
|
||||
local dir = io.popen("ls /etc/wireless/")
|
||||
if not dir then return end
|
||||
local fd = io.open(path, "r")
|
||||
if not fd then return end
|
||||
|
||||
-- convert l1 profile into lua table
|
||||
for line in fd:lines() do
|
||||
line = l1dat_parser.__trim(line)
|
||||
if string.byte(line) ~= string.byte("#") then
|
||||
local i = string.find(line, "=")
|
||||
if i then
|
||||
local k, v, k1, k2
|
||||
k = l1dat_parser.__trim( string.sub(line, 1, i-1) )
|
||||
v = l1dat_parser.__trim( string.sub(line, i+1) )
|
||||
k1, k2 = string.match(k, "INDEX(%d+)_(.+)")
|
||||
if k1 then
|
||||
k1 = tonumber(k1) + 1
|
||||
if devs[k1][k2] then
|
||||
nixio.syslog("warning", "skip repeated key"..line)
|
||||
end
|
||||
devs[k1][k2] = v or ""
|
||||
else
|
||||
k1 = string.match(k, "INDEX(%d+)")
|
||||
k1 = tonumber(k1) + 1
|
||||
devs[k1]["INDEX"] = v
|
||||
|
||||
chipset_num[v] = (not chipset_num[v] and 1) or chipset_num[v] + 1
|
||||
devs[k1]["mainidx"] = chipset_num[v]
|
||||
end
|
||||
--else
|
||||
-- nixio.syslog("warning", "skip line without '=' "..line)
|
||||
end
|
||||
--else
|
||||
-- nixio.syslog("warning", "skip comment line "..line)
|
||||
end
|
||||
end
|
||||
|
||||
l1dat_parser.add_default_value(devs)
|
||||
--local util = require("luci.util")
|
||||
--local seen2 = {}
|
||||
-- print("Before setup ridx", util.serialize_data(devs, seen2))
|
||||
|
||||
-- Force to setup reverse indice for quick search.
|
||||
-- Benifit:
|
||||
-- 1. O(1) search with ifname, devname
|
||||
-- 2. Seperate DBDC name=k1;k2 format in the L1 profile into each
|
||||
-- ifname, devname.
|
||||
local dbdc_if = {}
|
||||
local ridx = l1dat_parser.IF_RINDEX
|
||||
local dridx = l1dat_parser.DEV_RINDEX
|
||||
local band_num = l1dat_parser.MAX_NUM_DBDC_BAND
|
||||
local k, v, dev, i , j, last
|
||||
local devname
|
||||
devs[ridx] = {}
|
||||
devs[dridx] = {}
|
||||
for _, dev in ipairs(devs) do
|
||||
dbdc_if[band_num] = l1dat_parser.token_get(dev.main_ifname, band_num, nil)
|
||||
if dbdc_if[band_num] then
|
||||
for i = 1, band_num - 1 do
|
||||
dbdc_if[i] = l1dat_parser.token_get(dev.main_ifname, i, nil)
|
||||
end
|
||||
for i = 1, band_num do
|
||||
devs[ridx][dbdc_if[i]] = {}
|
||||
devs[ridx][dbdc_if[i]]["subidx"] = i
|
||||
|
||||
for k, v in pairs(dev) do
|
||||
if k == "INDEX" or k == "EEPROM_offset" or k == "EEPROM_size"
|
||||
or k == "mainidx" then
|
||||
devs[ridx][dbdc_if[i]][k] = v
|
||||
else
|
||||
devs[ridx][dbdc_if[i]][k] = l1dat_parser.token_get(v, i, "")
|
||||
end
|
||||
end
|
||||
devname = dev.INDEX.."."..dev.mainidx.."."..devs[ridx][dbdc_if[i]]["subidx"]
|
||||
devs[dridx][devname] = devs[ridx][dbdc_if[i]]
|
||||
end
|
||||
|
||||
local apcli_if, wds_if, ext_if, mesh_if = {}, {}, {}, {}
|
||||
|
||||
for i = 1, band_num do
|
||||
ext_if[i] = l1dat_parser.token_get(dev.ext_ifname, i, nil)
|
||||
apcli_if[i] = l1dat_parser.token_get(dev.apcli_ifname, i, nil)
|
||||
wds_if[i] = l1dat_parser.token_get(dev.wds_ifname, i, nil)
|
||||
mesh_if[i] = l1dat_parser.token_get(dev.mesh_ifname, i, nil)
|
||||
end
|
||||
|
||||
for i = 1, l1dat_parser.MAX_NUM_EXTIF - 1 do -- ifname idx is from 0
|
||||
for j = 1, band_num do
|
||||
devs[ridx][ext_if[j]..i] = devs[ridx][dbdc_if[j]]
|
||||
end
|
||||
end
|
||||
|
||||
for i = 0, l1dat_parser.MAX_NUM_APCLI - 1 do
|
||||
for j = 1, band_num do
|
||||
devs[ridx][apcli_if[j]..i] = devs[ridx][dbdc_if[j]]
|
||||
end
|
||||
end
|
||||
|
||||
for i = 0, l1dat_parser.MAX_NUM_WDS - 1 do
|
||||
for j = 1, band_num do
|
||||
devs[ridx][wds_if[j]..i] = devs[ridx][dbdc_if[j]]
|
||||
end
|
||||
end
|
||||
|
||||
for i = 0, l1dat_parser.MAX_NUM_MESH - 1 do
|
||||
for j = 1, band_num do
|
||||
if mesh_if[j] then
|
||||
devs[ridx][mesh_if[j]..i] = devs[ridx][dbdc_if[j]]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
devs[ridx][dev.main_ifname] = dev
|
||||
|
||||
devname = dev.INDEX.."."..dev.mainidx
|
||||
devs[dridx][devname] = dev
|
||||
|
||||
for i = 1, l1dat_parser.MAX_NUM_EXTIF - 1 do -- ifname idx is from 0
|
||||
devs[ridx][dev.ext_ifname..i] = dev
|
||||
end
|
||||
|
||||
for i = 0, l1dat_parser.MAX_NUM_APCLI - 1 do -- ifname idx is from 0
|
||||
devs[ridx][dev.apcli_ifname..i] = dev
|
||||
end
|
||||
|
||||
for i = 0, l1dat_parser.MAX_NUM_WDS - 1 do -- ifname idx is from 0
|
||||
devs[ridx][dev.wds_ifname..i] = dev
|
||||
end
|
||||
|
||||
for i = 0, l1dat_parser.MAX_NUM_MESH - 1 do -- ifname idx is from 0
|
||||
devs[ridx][dev.mesh_ifname..i] = dev
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
fd:close()
|
||||
return devs
|
||||
end
|
||||
|
||||
function l1dat_parser.creat_link_for_nvram( )
|
||||
local devs = l1dat_parser.load_l1_profile(l1dat_parser.L1_DAT_PATH)
|
||||
for devname, dev in pairs(devs.devname_ridx) do
|
||||
local dev = devs.devname_ridx[devname]
|
||||
profile = dev.profile_path
|
||||
os.execute("mkdir -p /tmp/mtk/wifi/")
|
||||
if dev.nvram_zone == "dev1" then
|
||||
os.execute("ln -sf " ..profile.." /tmp/mtk/wifi/2860")
|
||||
elseif dev.nvram_zone == "dev2" then
|
||||
os.execute("ln -sf " ..profile.." /tmp/mtk/wifi/rtdev")
|
||||
elseif dev.nvram_zone == "dev3" then
|
||||
os.execute("ln -sf " ..profile.." /tmp/mtk/wifi/wifi3")
|
||||
end
|
||||
end
|
||||
end
|
||||
return l1dat_parser
|
||||
1764
package/mtk/applications/luci-app-mtk/root/usr/lib/lua/mtkwifi.lua
Normal file
1764
package/mtk/applications/luci-app-mtk/root/usr/lib/lua/mtkwifi.lua
Normal file
File diff suppressed because it is too large
Load Diff
130
package/mtk/applications/luci-app-mtk/root/usr/lib/lua/shuci.lua
Normal file
130
package/mtk/applications/luci-app-mtk/root/usr/lib/lua/shuci.lua
Normal file
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env lua
|
||||
|
||||
--[[
|
||||
* A pure lua library to translate between:
|
||||
* lua table <--> uci config
|
||||
*
|
||||
* For UCI: http://wiki.openwrt.org/doc/techref/uci
|
||||
* http://wiki.openwrt.org/doc/uci
|
||||
*
|
||||
* Copyright (C) 2015 Hua Shao <nossiac@163.com>
|
||||
*
|
||||
* 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 shuci = {}
|
||||
|
||||
function shuci.decode(path)
|
||||
function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
end
|
||||
local function linebreaker(str)
|
||||
local i,_ = string.find(str, "([^%s])")
|
||||
if not i then return nil end
|
||||
if string.find(str, "config%s+%w+") then
|
||||
local i,j,k,v = string.find(str, "config%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)")
|
||||
return "section", k, v
|
||||
elseif string.find(str, "option%s+%w+") then
|
||||
local i,j,k,v = string.find(str, "option%s+([%w-_]+)%s*['\"]([^'\"]+)['\"]")
|
||||
if not k or not v then
|
||||
i,j,k,v = string.find(str, "option%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)")
|
||||
end
|
||||
return "option", k, v
|
||||
elseif string.find(str, "list%s+%w+") then
|
||||
local i,j,k,v = string.find(str, "list%s+([%w-_]+)%s*['\"]([^'\"]+)['\"]")
|
||||
if not k or not v then
|
||||
i,j,k,v = string.find(str, "list%s+([%w-_]+)%s*['\"]*([^%s\'\"]*)")
|
||||
end
|
||||
return "list", k, v
|
||||
end
|
||||
end
|
||||
|
||||
if not file_exists(path) then
|
||||
return
|
||||
end
|
||||
|
||||
local _sect_ = nil
|
||||
local t = {}
|
||||
for line in io.lines(path) do
|
||||
local _type, _name, _value = linebreaker(line)
|
||||
if _type == "section" then
|
||||
if not t[_name] then
|
||||
t[_name] = {}
|
||||
end
|
||||
t[_name][#t[_name]+1] = {}
|
||||
_sect_ = t[_name][#t[_name]]
|
||||
if _value then
|
||||
_sect_[".name"] = _value
|
||||
end
|
||||
end
|
||||
if _type == "option" then
|
||||
if _name and _value then
|
||||
_sect_[_name] = _value
|
||||
end
|
||||
end
|
||||
if _type == "list" and _name and _value then
|
||||
local idx
|
||||
if not _sect_[_name] then
|
||||
_sect_[_name] = {}
|
||||
_sect_[_name][1] = _value
|
||||
else
|
||||
idx = #_sect_[_name]
|
||||
_sect_[_name][idx+1] = _value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return t
|
||||
end
|
||||
|
||||
|
||||
function shuci.encode(t, path)
|
||||
local dump = io.write
|
||||
if path then
|
||||
local fp = io.open(path, "w")
|
||||
dump = function(str) fp:write(str) end
|
||||
end
|
||||
for stype,ss in pairs(t) do
|
||||
if #ss > 0 then
|
||||
for _,s in ipairs(ss) do
|
||||
dump(string.format("config\t%s\t'%s'\n", stype, s[".name"] or ""))
|
||||
for k,v in pairs(s) do
|
||||
if type(v) == "table" then
|
||||
for _,vv in ipairs(v) do
|
||||
dump(string.format("\tlist\t%s\t'%s'\n",k,vv))
|
||||
end
|
||||
elseif type(v) == "string" and k ~= ".name" then
|
||||
dump(string.format("\toption\t%s\t'%s'\n",k,v))
|
||||
elseif type(v) == "number" and k ~= ".name" then
|
||||
dump(string.format("\toption\t%s\t'%s'\n",k,tonumber(v)))
|
||||
end
|
||||
end
|
||||
dump("\n")
|
||||
end
|
||||
else
|
||||
dump(string.format("config\t%s\t'%s'\n", stype, ss[".name"] or ""))
|
||||
for k,v in pairs(ss) do
|
||||
if type(v) == "table" then
|
||||
for _,vv in ipairs(v) do
|
||||
dump(string.format("\tlist\t%s\t'%s'\n",k,vv))
|
||||
end
|
||||
elseif type(v) == "string" and k ~= ".name" then
|
||||
dump(string.format("\toption\t%s\t'%s'\n",k,v))
|
||||
elseif type(v) == "number" and k ~= ".name" then
|
||||
dump(string.format("\toption\t%s\t'%s'\n",k,tonumber(v)))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return shuci
|
||||
24
package/mtk/applications/luci-app-mtk/src/Makefile
Normal file
24
package/mtk/applications/luci-app-mtk/src/Makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
OBJ_IOCTL = ioctl_helper.o rate_calc.o security.o
|
||||
CFLAGS += -I.
|
||||
CFLAGS += -I$(ROOTDIR)/user/luci/lua-5.1.5/src
|
||||
CFLAGS += -Wall -shared -fPIC
|
||||
LUCI_APP_MTK_TARGET = ioctl_helper
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
all: $(LUCI_APP_MTK_TARGET)
|
||||
|
||||
ioctl_helper: $(OBJ_IOCTL)
|
||||
$(CC) -o $@.so $^ $(CFLAGS)
|
||||
|
||||
compile: $(LUCI_APP_MTK_TARGET)
|
||||
|
||||
install: compile
|
||||
mkdir -p $(DESTDIR)/usr/lib/lua
|
||||
cp -pR ioctl_helper.so $(DESTDIR)/usr/lib/lua/
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so
|
||||
|
||||
romfs:
|
||||
629
package/mtk/applications/luci-app-mtk/src/ioctl_helper.c
Normal file
629
package/mtk/applications/luci-app-mtk/src/ioctl_helper.c
Normal file
@@ -0,0 +1,629 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/wireless.h>
|
||||
|
||||
#include "mtwifi.h"
|
||||
|
||||
int luaopen_ioctl_helper(lua_State *L)
|
||||
{
|
||||
lua_register(L,"c_get_macaddr",get_macaddr);
|
||||
lua_register(L,"c_convert_string_display",convert_string_display);
|
||||
lua_register(L,"c_StaInfo",StaInfo);
|
||||
lua_register(L,"c_getWMode",getWMOde);
|
||||
lua_register(L,"c_getTempature",getTempature);
|
||||
lua_register(L,"c_scanResult",scanResult);
|
||||
lua_register(L,"c_getTxPower",getTxPower);
|
||||
lua_register(L,"c_getChannel",getChannel);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int scanResult(lua_State *L)
|
||||
{
|
||||
int socket_id;
|
||||
const char *interface = luaL_checkstring(L, 1);
|
||||
const char *tmp_idx = luaL_checkstring(L, 2);
|
||||
struct iwreq wrq;
|
||||
char *data = NULL;
|
||||
unsigned int data_len = 5000;
|
||||
|
||||
if((data = (char *)malloc(data_len)) == NULL){
|
||||
fprintf(stderr, "%s: malloc failed\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
memset(data, 0, data_len);
|
||||
socket_id = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket_id < 0) {
|
||||
perror("socket() failed");
|
||||
free(data);
|
||||
return socket_id;
|
||||
}
|
||||
|
||||
snprintf(wrq.ifr_name, sizeof(wrq.ifr_name), "%s", interface);
|
||||
snprintf(data, data_len, "%s", tmp_idx);
|
||||
wrq.u.data.length = data_len;
|
||||
wrq.u.data.pointer = data;
|
||||
wrq.u.data.flags = 0;
|
||||
if (ioctl(socket_id, RTPRIV_IOCTL_GSITESURVEY, &wrq) < 0) {
|
||||
fprintf(stderr, "ioctl -> RTPRIV_IOCTL_GSITESURVEY Fail !");
|
||||
close(socket_id);
|
||||
free(data);
|
||||
return -1;
|
||||
}
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "scanresult"); /* push key */
|
||||
lua_pushstring(L, data); /* push value */
|
||||
lua_settable(L, -3);
|
||||
close(socket_id);
|
||||
free(data);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static unsigned int get_temp(const char *interface)
|
||||
{
|
||||
int socket_id;
|
||||
struct iwreq wrq;
|
||||
unsigned int tempature = 0;
|
||||
socket_id = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket_id < 0) {
|
||||
perror("socket() failed");
|
||||
return socket_id;
|
||||
}
|
||||
|
||||
snprintf(wrq.ifr_name, sizeof(wrq.ifr_name), "%s", interface);
|
||||
wrq.u.data.length = sizeof(tempature);
|
||||
wrq.u.data.pointer = &tempature;
|
||||
wrq.u.data.flags = OID_GET_CPU_TEMPERATURE;
|
||||
if( ioctl(socket_id, RT_PRIV_IOCTL, &wrq) == -1)
|
||||
fprintf(stderr, "%s: ioctl fail\n", __func__);
|
||||
close(socket_id);
|
||||
|
||||
return tempature;
|
||||
}
|
||||
|
||||
int getTempature(lua_State *L)
|
||||
{
|
||||
char tempstr[5] = {0};
|
||||
const char *interface = luaL_checkstring(L, 1);
|
||||
snprintf(tempstr, sizeof(tempstr), "%d", get_temp(interface));
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "tempature"); /* push key */
|
||||
lua_pushstring(L, tempstr); /* push value */
|
||||
lua_settable(L, -3);
|
||||
/* Returning one table which is already on top of Lua stack. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static unsigned int get_txpower(const char *interface)
|
||||
{
|
||||
int socket_id;
|
||||
struct iwreq wrq;
|
||||
int txpower = 0;
|
||||
socket_id = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket_id < 0) {
|
||||
perror("socket() failed");
|
||||
return socket_id;
|
||||
}
|
||||
|
||||
snprintf(wrq.ifr_name, sizeof(wrq.ifr_name), "%s", interface);
|
||||
wrq.u.txpower.flags = 0;
|
||||
|
||||
if(ioctl(socket_id, SIOCGIWTXPOW, &wrq) >= 0) {
|
||||
txpower = wrq.u.txpower.value;
|
||||
} else {
|
||||
fprintf(stderr, "%s: ioctl fail\n", __func__);
|
||||
}
|
||||
|
||||
close(socket_id);
|
||||
|
||||
return txpower;
|
||||
}
|
||||
|
||||
int getTxPower(lua_State *L)
|
||||
{
|
||||
char tempstr[5] = {0};
|
||||
const char *interface = luaL_checkstring(L, 1);
|
||||
snprintf(tempstr, sizeof(tempstr), "%d", get_txpower(interface));
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "txpower"); /* push key */
|
||||
lua_pushstring(L, tempstr); /* push value */
|
||||
lua_settable(L, -3);
|
||||
/* Returning one table which is already on top of Lua stack. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static unsigned int get_w_mode(const char *interface)
|
||||
{
|
||||
int socket_id;
|
||||
struct iwreq wrq;
|
||||
unsigned char data = 0;
|
||||
socket_id = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket_id < 0) {
|
||||
perror("socket() failed");
|
||||
return socket_id;
|
||||
}
|
||||
|
||||
snprintf(wrq.ifr_name, sizeof(wrq.ifr_name), "%s", interface);
|
||||
wrq.u.data.length = sizeof(data);
|
||||
wrq.u.data.pointer = &data;
|
||||
wrq.u.data.flags = OID_GET_WMODE;
|
||||
if( ioctl(socket_id, RT_PRIV_IOCTL, &wrq) == -1)
|
||||
fprintf(stderr, "%s: ioctl fail\n", __func__);
|
||||
close(socket_id);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
int get_macaddr(lua_State *L)
|
||||
{
|
||||
const char *ifname = luaL_checkstring(L, 1);
|
||||
struct ifreq ifr;
|
||||
char *ptr;
|
||||
int skfd;
|
||||
static char if_hw[18] = {0};
|
||||
|
||||
if((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
//printf(stderr, "%s: open socket error\n", __func__);
|
||||
return skfd;
|
||||
}
|
||||
snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", ifname);
|
||||
if(ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) {
|
||||
close(skfd);
|
||||
fprintf(stderr, "%s: ioctl fail\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptr = (char *)&ifr.ifr_addr.sa_data;
|
||||
sprintf(if_hw, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||
(ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
|
||||
(ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377));
|
||||
close(skfd);
|
||||
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "macaddr"); /* push key */
|
||||
lua_pushstring(L, if_hw); /* push value */
|
||||
lua_settable(L, -3);
|
||||
/* Returning one table which is already on top of Lua stack. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int get_channel(const char *interface)
|
||||
{
|
||||
int socket_id;
|
||||
struct iwreq wrq;
|
||||
int channel = -1;
|
||||
socket_id = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (socket_id < 0) {
|
||||
perror("socket() failed");
|
||||
return socket_id;
|
||||
}
|
||||
|
||||
snprintf(wrq.ifr_name, sizeof(wrq.ifr_name), "%s", interface);
|
||||
|
||||
if(ioctl(socket_id, SIOCGIWFREQ, &wrq) >= 0) {
|
||||
channel = wrq.u.freq.m;
|
||||
} else {
|
||||
fprintf(stderr, "%s: ioctl fail\n", __func__);
|
||||
}
|
||||
|
||||
close(socket_id);
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
int getChannel(lua_State *L)
|
||||
{
|
||||
char tempstr[5] = {0};
|
||||
const char *interface = luaL_checkstring(L, 1);
|
||||
|
||||
snprintf(tempstr, sizeof(tempstr), "%d", get_channel(interface));
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "channel"); /* push key */
|
||||
lua_pushstring(L, tempstr); /* push value */
|
||||
lua_settable(L, -3);
|
||||
/* Returning one table which is already on top of Lua stack. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int getWMOde(lua_State *L)
|
||||
{
|
||||
char w_mode[5];
|
||||
const char *interface = luaL_checkstring(L, 1);
|
||||
snprintf(w_mode, sizeof(w_mode), "%d", get_w_mode(interface));
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "getwmode"); /* push key */
|
||||
lua_pushstring(L, w_mode); /* push value */
|
||||
lua_settable(L, -3);
|
||||
/* Returning one table which is already on top of Lua stack. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
int convert_string_display(lua_State *L)
|
||||
{
|
||||
#define BUF_SIZE 256
|
||||
int len, i;
|
||||
char buffer[BUF_SIZE]; // 33(characters in SSID) * 6(maximum length of a HTML entity) = 198 + 1(null character) = 199
|
||||
char *pOut,*pBufLimit;
|
||||
const char *str = luaL_checkstring(L, 1);
|
||||
|
||||
memset(buffer,0,BUF_SIZE);
|
||||
len = strlen(str);
|
||||
pOut = &buffer[0];
|
||||
pBufLimit = &buffer[BUF_SIZE - 1];
|
||||
for (i = 0; i < len && (pBufLimit - pOut) >=7; i++) { // 6(maximum length of a HTML entity) + 1(null character) = 7
|
||||
switch (str[i]) {
|
||||
case 38:
|
||||
sprintf(pOut, "&"); // '&'
|
||||
pOut += 5;
|
||||
break;
|
||||
|
||||
case 60:
|
||||
sprintf(pOut, "<"); // '<'
|
||||
pOut += 4;
|
||||
break;
|
||||
|
||||
case 62:
|
||||
sprintf(pOut, ">"); // '>'
|
||||
pOut += 4;
|
||||
break;
|
||||
|
||||
case 34:
|
||||
sprintf(pOut, """); // '"'
|
||||
pOut += 5;
|
||||
break;
|
||||
|
||||
case 39:
|
||||
sprintf(pOut, "'"); // '''
|
||||
pOut += 5;
|
||||
break;
|
||||
case 32:
|
||||
sprintf(pOut, " "); // ' '
|
||||
pOut += 6;
|
||||
break;
|
||||
|
||||
default:
|
||||
if ((str[i]>=0) && (str[i]<=31)) {
|
||||
//Device Control Characters
|
||||
sprintf(pOut, "&#%02d;", str[i]);
|
||||
pOut += 5;
|
||||
} else if ((str[i]==39) || (str[i]==47) || (str[i]==59) || (str[i]==92)) {
|
||||
// ' / ; (backslash)
|
||||
sprintf(pOut, "&#%02d;", str[i]);
|
||||
pOut += 5;
|
||||
} else if (str[i]>=127) {
|
||||
//Device Control Characters
|
||||
sprintf(pOut, "&#%03d;", str[i]);
|
||||
pOut += 6;
|
||||
} else {
|
||||
*pOut = str[i];
|
||||
pOut++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*pOut = '\0';
|
||||
lua_newtable(L);
|
||||
lua_pushstring(L, "output"); /* push key */
|
||||
lua_pushstring(L, buffer); /* push value */
|
||||
lua_settable(L, -3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int StaInfo(lua_State *L)
|
||||
{
|
||||
int i, s;
|
||||
struct iwreq iwr;
|
||||
RT_802_11_MAC_TABLE_FIX *table;
|
||||
char tmpBuff[128] = {0};
|
||||
char *phyMode[12] = {"CCK", "OFDM", "MM", "GF", "VHT", "HE",
|
||||
"HE5G", "HE2G", "HE_SU", "HE_EXT_SU", "HE_TRIG", "HE_MU"};
|
||||
const char *interface = luaL_checkstring(L, 1);
|
||||
|
||||
table = (RT_802_11_MAC_TABLE_FIX *)malloc(sizeof(RT_802_11_MAC_TABLE_FIX));
|
||||
if (!table)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(table, 0, sizeof(RT_802_11_MAC_TABLE_FIX));
|
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
snprintf(iwr.ifr_name, IFNAMSIZ, "%s", interface);
|
||||
|
||||
iwr.u.data.pointer = table;
|
||||
|
||||
if (s < 0) {
|
||||
free(table);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ioctl(s, RTPRIV_IOCTL_GET_MAC_TABLE_STRUCT, &iwr) < 0) {
|
||||
free(table);
|
||||
close(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
close(s);
|
||||
|
||||
/* Creates parent table of size table.Num array elements: */
|
||||
lua_createtable(L, table->Num, 0);
|
||||
|
||||
for (i = 0; i < table->Num; i++) {
|
||||
|
||||
lua_pushnumber(L, i);
|
||||
|
||||
RT_802_11_MAC_ENTRY_FIX *pe = &(table->Entry[i]);
|
||||
|
||||
HTTRANSMIT_SETTING_FIX RxRate;
|
||||
HTTRANSMIT_SETTING_FIX TxRate;
|
||||
RxRate.word = pe->LastRxRate.word;
|
||||
TxRate.word = pe->TxRate.word;
|
||||
|
||||
unsigned int mcs = TxRate.field.MCS;
|
||||
unsigned int nss = 0;
|
||||
unsigned long DataRate = 0;
|
||||
|
||||
unsigned int mcs_r = RxRate.field.MCS;
|
||||
unsigned int nss_r = 0;
|
||||
unsigned long DataRate_r = 0;
|
||||
|
||||
int hr, min, sec;
|
||||
|
||||
hr = pe->ConnectedTime/3600;
|
||||
min = (pe->ConnectedTime % 3600)/60;
|
||||
sec = pe->ConnectedTime - hr*3600 - min*60;
|
||||
|
||||
/* Creates first child table of size 34 non-array elements: */
|
||||
lua_createtable(L, 0, 34);
|
||||
|
||||
// MAC Address
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%02X:%02X:%02X:%02X:%02X:%02X", pe->Addr[0], pe->Addr[1], pe->Addr[2], pe->Addr[3],
|
||||
pe->Addr[4], pe->Addr[5]);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "MacAddr");
|
||||
|
||||
// AID, Power Save mode, MIMO Power Save
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", pe->Aid);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Aid");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", pe->Psm);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Psm");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", pe->MimoPs);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "MimoPs");
|
||||
|
||||
// TX Rate NSS-MCS
|
||||
if (TxRate.field.MODE >= MODE_VHT) {
|
||||
nss = ((mcs & (0x3 << 4)) >> 4) + 1;
|
||||
mcs = mcs & 0xF;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%dSS-MCS%d", nss, mcs);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Mcs");
|
||||
} else {
|
||||
mcs = mcs & 0x3f;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", mcs);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Mcs");
|
||||
}
|
||||
|
||||
// TX BW
|
||||
if (TxRate.field.BW == BW_20) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 20);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Bw");
|
||||
} else if (TxRate.field.BW == BW_40) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 40);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Bw");
|
||||
} else if (TxRate.field.BW == BW_80) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 80);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Bw");
|
||||
} else if (TxRate.field.BW == BW_160) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 160);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Bw");
|
||||
}
|
||||
|
||||
//TX SGI
|
||||
if (TxRate.field.MODE < MODE_HTMIX) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", "LGI");
|
||||
} else if (TxRate.field.MODE >= MODE_HE) {
|
||||
if (TxRate.field.ShortGI == 0)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", "SGI");
|
||||
else if (TxRate.field.ShortGI == 1)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", "MGI");
|
||||
else if (TxRate.field.ShortGI == 2)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", "LGI");
|
||||
} else {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", TxRate.field.ShortGI ? "SGI" : "LGI");
|
||||
}
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Gi");
|
||||
|
||||
//TX phy mode
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", phyMode[TxRate.field.MODE]);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "PhyMode");
|
||||
|
||||
//TX STBC
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", TxRate.field.STBC? "STBC": " ");
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Stbc");
|
||||
|
||||
// TxBF configuration
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%c", TxRate.field.iTxBF ? 'I': '-');
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "iTxBF");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%c", TxRate.field.eTxBF ? 'E': '-');
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "eTxBF");
|
||||
|
||||
// RSSI
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", (int)(pe->AvgRssi0));
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "AvgRssi0");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", (int)(pe->AvgRssi1));
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "AvgRssi1");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", (int)(pe->AvgRssi2));
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "AvgRssi2");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", (int)(pe->AvgRssi3));
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "AvgRssi3");
|
||||
|
||||
// Per Stream SNR
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%0.1f", pe->StreamSnr[0]*0.25);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "StreamSnr0");
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%0.1f", pe->StreamSnr[1]*0.25); //mcs>7? pe->StreamSnr[1]*0.25: 0.0);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "StreamSnr1");
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%0.1f", pe->StreamSnr[2]*0.25); //mcs>15? pe->StreamSnr[2]*0.25: 0.0);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "StreamSnr2");
|
||||
|
||||
// Sounding Response SNR
|
||||
if (TxRate.field.eTxBF) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%0.1f", pe->SoundingRespSnr[0]*0.25);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "SoundingRespSnr0");
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%0.1f", pe->SoundingRespSnr[1]*0.25);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "SoundingRespSnr1");
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%0.1f", pe->SoundingRespSnr[2]*0.25);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "SoundingRespSnr2");
|
||||
}
|
||||
|
||||
// Last RX NSS-MCS
|
||||
if (RxRate.field.MODE >= MODE_VHT) {
|
||||
nss_r = (((mcs_r & (0x3 << 4)) >> 4) + 1) / (RxRate.field.STBC + 1);
|
||||
mcs_r = mcs_r & 0xF;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%dSS-MCS%d", nss_r, mcs_r);
|
||||
} else if (RxRate.field.MODE >= MODE_HTMIX) {
|
||||
mcs_r = mcs_r & 0x3f;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", mcs_r);
|
||||
} else if (RxRate.field.MODE == MODE_OFDM) {
|
||||
mcs_r = mcs_r & 0xf;
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", mcs_r);
|
||||
RxRate.field.MCS = mcs_r;
|
||||
} else if (RxRate.field.MODE == MODE_CCK) {
|
||||
mcs_r = cck_to_mcs(mcs_r & 0x7);
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "MCS%d", mcs_r);
|
||||
RxRate.field.MCS = mcs_r;
|
||||
}
|
||||
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastMcs");
|
||||
|
||||
if (RxRate.field.BW == BW_20) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 20);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastBw");
|
||||
} else if (RxRate.field.BW == BW_40) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 40);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastBw");
|
||||
} else if (RxRate.field.BW == BW_80) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 80);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastBw");
|
||||
} else if (RxRate.field.BW == BW_160) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%d", 160);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastBw");
|
||||
}
|
||||
|
||||
if (RxRate.field.MODE < MODE_HTMIX) {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", "LGI");
|
||||
} else if (RxRate.field.MODE >= MODE_HE) {
|
||||
if (RxRate.field.ShortGI == 0)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", "SGI");
|
||||
else if (RxRate.field.ShortGI == 1)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", "MGI");
|
||||
else if (RxRate.field.ShortGI == 2)
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", "LGI");
|
||||
} else {
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", RxRate.field.ShortGI ? "SGI" : "LGI");
|
||||
}
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastGi");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", phyMode[RxRate.field.MODE]);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastPhyMode");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", RxRate.field.STBC ? "STBC": " ");
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "LastStbc");
|
||||
|
||||
// Connect time
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%02d", hr);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Hr");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%02d", min);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Min");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%02d", sec);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "Sec");
|
||||
|
||||
if (TxRate.field.MODE >= MODE_HE) {
|
||||
get_rate_he((mcs & 0xf), TxRate.field.BW, nss, 0, &DataRate);
|
||||
if (TxRate.field.ShortGI == 1)
|
||||
DataRate = (DataRate * 967) >> 10;
|
||||
else if (TxRate.field.ShortGI == 2)
|
||||
DataRate = (DataRate * 870) >> 10;
|
||||
} else {
|
||||
getRate(TxRate, &DataRate);
|
||||
}
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%ld", DataRate);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "TxRate");
|
||||
|
||||
if (RxRate.field.MODE >= MODE_HE) {
|
||||
get_rate_he((mcs_r & 0xf), RxRate.field.BW, nss_r, 0, &DataRate_r);
|
||||
if (RxRate.field.ShortGI == 1)
|
||||
DataRate_r = (DataRate_r * 967) >> 10;
|
||||
else if (RxRate.field.ShortGI == 2)
|
||||
DataRate_r = (DataRate_r * 870) >> 10;
|
||||
} else {
|
||||
getRate(RxRate, &DataRate_r);
|
||||
}
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%ld", DataRate_r);
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "RxRate");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", GetEncryModeStr(pe->EncryMode));
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "EncryptMode");
|
||||
|
||||
snprintf(tmpBuff, sizeof(tmpBuff), "%s", GetAuthModeStr(pe->AuthMode));
|
||||
lua_pushstring(L, tmpBuff);
|
||||
lua_setfield(L, -2, "AuthMode");
|
||||
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
free(table);
|
||||
return 1;
|
||||
}
|
||||
221
package/mtk/applications/luci-app-mtk/src/mtwifi.h
Normal file
221
package/mtk/applications/luci-app-mtk/src/mtwifi.h
Normal file
@@ -0,0 +1,221 @@
|
||||
#ifndef __MTWIFI_H
|
||||
#define __MTWIFI_H
|
||||
|
||||
#define USHORT unsigned short
|
||||
#define UCHAR unsigned char
|
||||
#define ULONG unsigned long
|
||||
#define UINT8 unsigned char
|
||||
#define UINT16 unsigned short
|
||||
#define UINT32 unsigned int
|
||||
#define INT32 int
|
||||
#define INT int
|
||||
|
||||
#include <lua.h> /* Always include this */
|
||||
#include <lauxlib.h> /* Always include this */
|
||||
#include <lualib.h> /* Always include this */
|
||||
|
||||
typedef union _HTTRANSMIT_SETTING_FIX {
|
||||
struct {
|
||||
USHORT MCS:6;
|
||||
USHORT ldpc:1;
|
||||
USHORT BW:2;
|
||||
USHORT ShortGI:2;
|
||||
USHORT STBC:1;
|
||||
USHORT eTxBF:1;
|
||||
USHORT iTxBF:1;
|
||||
USHORT MODE:4;
|
||||
} field;
|
||||
UINT32 word;
|
||||
} HTTRANSMIT_SETTING_FIX, *PHTTRANSMIT_SETTING_FIX;
|
||||
|
||||
typedef struct _RT_802_11_MAC_ENTRY_FIX {
|
||||
unsigned char ApIdx;
|
||||
unsigned char Addr[6];
|
||||
unsigned short Aid;
|
||||
unsigned char Psm; // 0:PWR_ACTIVE, 1:PWR_SAVE
|
||||
unsigned char MimoPs; // 0:MMPS_STATIC, 1:MMPS_DYNAMIC, 3:MMPS_Enabled
|
||||
signed char AvgRssi0;
|
||||
signed char AvgRssi1;
|
||||
signed char AvgRssi2;
|
||||
signed char AvgRssi3;
|
||||
unsigned int ConnectedTime;
|
||||
HTTRANSMIT_SETTING_FIX TxRate;
|
||||
HTTRANSMIT_SETTING_FIX LastRxRate;
|
||||
short StreamSnr[3];
|
||||
short SoundingRespSnr[3];
|
||||
UINT32 EncryMode;
|
||||
UINT32 AuthMode;
|
||||
} RT_802_11_MAC_ENTRY_FIX;
|
||||
|
||||
#define MAX_NUMBER_OF_MAC 544
|
||||
|
||||
typedef struct _RT_802_11_MAC_TABLE {
|
||||
unsigned long Num;
|
||||
RT_802_11_MAC_ENTRY_FIX Entry[MAX_NUMBER_OF_MAC];
|
||||
} RT_802_11_MAC_TABLE_FIX;
|
||||
|
||||
#define IF_NAMESIZE 16
|
||||
#define SIOCIWFIRSTPRIV 0x8BE0
|
||||
#define RT_PRIV_IOCTL (SIOCIWFIRSTPRIV + 0x0E)
|
||||
#define RTPRIV_IOCTL_GET_MAC_TABLE_STRUCT (SIOCIWFIRSTPRIV + 0x1F)
|
||||
#define RTPRIV_IOCTL_GSITESURVEY (SIOCIWFIRSTPRIV + 0x0D)
|
||||
#define OID_GET_WMODE 0x099E
|
||||
#define OID_GET_CPU_TEMPERATURE 0x09A1
|
||||
|
||||
#define MODE_CCK 0
|
||||
#define MODE_OFDM 1
|
||||
#define MODE_HTMIX 2
|
||||
#define MODE_HTGREENFIELD 3
|
||||
#define MODE_VHT 4
|
||||
#define MODE_HE 5
|
||||
#define MODE_HE_5G 6
|
||||
#define MODE_HE_24G 7
|
||||
#define MODE_HE_SU 8
|
||||
#define MODE_HE_EXT_SU 9
|
||||
#define MODE_HE_TRIG 10
|
||||
#define MODE_HE_MU 11
|
||||
|
||||
#define TMI_TX_RATE_OFDM_6M 11
|
||||
#define TMI_TX_RATE_OFDM_9M 15
|
||||
#define TMI_TX_RATE_OFDM_12M 10
|
||||
#define TMI_TX_RATE_OFDM_18M 14
|
||||
#define TMI_TX_RATE_OFDM_24M 9
|
||||
#define TMI_TX_RATE_OFDM_36M 13
|
||||
#define TMI_TX_RATE_OFDM_48M 8
|
||||
#define TMI_TX_RATE_OFDM_54M 12
|
||||
|
||||
#define TMI_TX_RATE_CCK_1M_LP 0
|
||||
#define TMI_TX_RATE_CCK_2M_LP 1
|
||||
#define TMI_TX_RATE_CCK_5M_LP 2
|
||||
#define TMI_TX_RATE_CCK_11M_LP 3
|
||||
|
||||
#define TMI_TX_RATE_CCK_2M_SP 5
|
||||
#define TMI_TX_RATE_CCK_5M_SP 6
|
||||
#define TMI_TX_RATE_CCK_11M_SP 7
|
||||
|
||||
enum oid_bw {
|
||||
BAND_WIDTH_20,
|
||||
BAND_WIDTH_40,
|
||||
BAND_WIDTH_80,
|
||||
BAND_WIDTH_160,
|
||||
BAND_WIDTH_10,
|
||||
BAND_WIDTH_5,
|
||||
BAND_WIDTH_8080,
|
||||
BAND_WIDTH_BOTH,
|
||||
BAND_WIDTH_25,
|
||||
BAND_WIDTH_20_242TONE,
|
||||
BAND_WIDTH_NUM
|
||||
};
|
||||
|
||||
#define BW_20 BAND_WIDTH_20
|
||||
#define BW_40 BAND_WIDTH_40
|
||||
#define BW_80 BAND_WIDTH_80
|
||||
#define BW_160 BAND_WIDTH_160
|
||||
#define BW_10 BAND_WIDTH_10
|
||||
#define BW_5 BAND_WIDTH_5
|
||||
#define BW_8080 BAND_WIDTH_8080
|
||||
#define BW_25 BAND_WIDTH_25
|
||||
#define BW_20_242TONE BAND_WIDTH_20_242TONE
|
||||
#define BW_NUM BAND_WIDTH_NUM
|
||||
|
||||
typedef enum _SEC_CIPHER_MODE {
|
||||
SEC_CIPHER_NONE,
|
||||
SEC_CIPHER_WEP40,
|
||||
SEC_CIPHER_WEP104,
|
||||
SEC_CIPHER_WEP128,
|
||||
SEC_CIPHER_TKIP,
|
||||
SEC_CIPHER_CCMP128,
|
||||
SEC_CIPHER_CCMP256,
|
||||
SEC_CIPHER_GCMP128,
|
||||
SEC_CIPHER_GCMP256,
|
||||
SEC_CIPHER_BIP_CMAC128,
|
||||
SEC_CIPHER_BIP_CMAC256,
|
||||
SEC_CIPHER_BIP_GMAC128,
|
||||
SEC_CIPHER_BIP_GMAC256,
|
||||
SEC_CIPHER_WPI_SMS4, /* WPI SMS4 support */
|
||||
SEC_CIPHER_MAX /* Not a real mode, defined as upper bound */
|
||||
} SEC_CIPHER_MODE;
|
||||
|
||||
#define IS_CIPHER_NONE(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_NONE)) > 0)
|
||||
#define IS_CIPHER_WEP40(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_WEP40)) > 0)
|
||||
#define IS_CIPHER_WEP104(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_WEP104)) > 0)
|
||||
#define IS_CIPHER_WEP128(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_WEP128)) > 0)
|
||||
#define IS_CIPHER_WEP(_Cipher) (((_Cipher) & ((1 << SEC_CIPHER_WEP40) | (1 << SEC_CIPHER_WEP104) | (1 << SEC_CIPHER_WEP128))) > 0)
|
||||
#define IS_CIPHER_TKIP(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_TKIP)) > 0)
|
||||
#define IS_CIPHER_WEP_TKIP_ONLY(_Cipher) ((IS_CIPHER_WEP(_Cipher) || IS_CIPHER_TKIP(_Cipher)) && (_Cipher < (1 << SEC_CIPHER_CCMP128)))
|
||||
#define IS_CIPHER_CCMP128(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_CCMP128)) > 0)
|
||||
#define IS_CIPHER_CCMP256(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_CCMP256)) > 0)
|
||||
#define IS_CIPHER_GCMP128(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_GCMP128)) > 0)
|
||||
#define IS_CIPHER_GCMP256(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_GCMP256)) > 0)
|
||||
#define IS_CIPHER_BIP_CMAC128(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_BIP_CMAC128)) > 0)
|
||||
#define IS_CIPHER_BIP_CMAC256(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_BIP_CMAC256)) > 0)
|
||||
#define IS_CIPHER_BIP_GMAC128(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_BIP_GMAC128)) > 0)
|
||||
#define IS_CIPHER_BIP_GMAC256(_Cipher) (((_Cipher) & (1 << SEC_CIPHER_BIP_GMAC256)) > 0)
|
||||
|
||||
/* 802.11 authentication and key management */
|
||||
typedef enum _SEC_AKM_MODE {
|
||||
SEC_AKM_OPEN,
|
||||
SEC_AKM_SHARED,
|
||||
SEC_AKM_AUTOSWITCH,
|
||||
SEC_AKM_WPA1, /* Enterprise security over 802.1x */
|
||||
SEC_AKM_WPA1PSK,
|
||||
SEC_AKM_WPANone, /* For Win IBSS, directly PTK, no handshark */
|
||||
SEC_AKM_WPA2, /* Enterprise security over 802.1x */
|
||||
SEC_AKM_WPA2PSK,
|
||||
SEC_AKM_FT_WPA2,
|
||||
SEC_AKM_FT_WPA2PSK,
|
||||
SEC_AKM_WPA2_SHA256,
|
||||
SEC_AKM_WPA2PSK_SHA256,
|
||||
SEC_AKM_TDLS,
|
||||
SEC_AKM_SAE_SHA256,
|
||||
SEC_AKM_FT_SAE_SHA256,
|
||||
SEC_AKM_SUITEB_SHA256,
|
||||
SEC_AKM_SUITEB_SHA384,
|
||||
SEC_AKM_FT_WPA2_SHA384,
|
||||
SEC_AKM_WAICERT, /* WAI certificate authentication */
|
||||
SEC_AKM_WAIPSK, /* WAI pre-shared key */
|
||||
SEC_AKM_OWE,
|
||||
SEC_AKM_FILS_SHA256,
|
||||
SEC_AKM_FILS_SHA384,
|
||||
SEC_AKM_WPA3, /* WPA3(ent) = WPA2(ent) + PMF MFPR=1 => WPA3 code flow is same as WPA2, the usage of SEC_AKM_WPA3 is to force pmf on */
|
||||
SEC_AKM_MAX /* Not a real mode, defined as upper bound */
|
||||
} SEC_AKM_MODE;
|
||||
|
||||
#define IS_AKM_OPEN(_AKMMap) ((_AKMMap & (1 << SEC_AKM_OPEN)) > 0)
|
||||
#define IS_AKM_SHARED(_AKMMap) ((_AKMMap & (1 << SEC_AKM_SHARED)) > 0)
|
||||
#define IS_AKM_AUTOSWITCH(_AKMMap) ((_AKMMap & (1 << SEC_AKM_AUTOSWITCH)) > 0)
|
||||
#define IS_AKM_WPA1(_AKMMap) ((_AKMMap & (1 << SEC_AKM_WPA1)) > 0)
|
||||
#define IS_AKM_WPA1PSK(_AKMMap) ((_AKMMap & (1 << SEC_AKM_WPA1PSK)) > 0)
|
||||
#define IS_AKM_WPANONE(_AKMMap) ((_AKMMap & (1 << SEC_AKM_WPANone)) > 0)
|
||||
#define IS_AKM_WPA2(_AKMMap) ((_AKMMap & (1 << SEC_AKM_WPA2)) > 0)
|
||||
#define IS_AKM_WPA2PSK(_AKMMap) ((_AKMMap & (1 << SEC_AKM_WPA2PSK)) > 0)
|
||||
#define IS_AKM_FT_WPA2(_AKMMap) ((_AKMMap & (1 << SEC_AKM_FT_WPA2)) > 0)
|
||||
#define IS_AKM_FT_WPA2PSK(_AKMMap) ((_AKMMap & (1 << SEC_AKM_FT_WPA2PSK)) > 0)
|
||||
#define IS_AKM_WPA2_SHA256(_AKMMap) ((_AKMMap & (1 << SEC_AKM_WPA2_SHA256)) > 0)
|
||||
#define IS_AKM_WPA2PSK_SHA256(_AKMMap) ((_AKMMap & (1 << SEC_AKM_WPA2PSK_SHA256)) > 0)
|
||||
#define IS_AKM_TDLS(_AKMMap) ((_AKMMap & (1 << SEC_AKM_TDLS)) > 0)
|
||||
#define IS_AKM_SAE_SHA256(_AKMMap) ((_AKMMap & (1 << SEC_AKM_SAE_SHA256)) > 0)
|
||||
#define IS_AKM_FT_SAE_SHA256(_AKMMap) ((_AKMMap & (1 << SEC_AKM_FT_SAE_SHA256)) > 0)
|
||||
#define IS_AKM_SUITEB_SHA256(_AKMMap) ((_AKMMap & (1 << SEC_AKM_SUITEB_SHA256)) > 0)
|
||||
#define IS_AKM_SUITEB_SHA384(_AKMMap) ((_AKMMap & (1 << SEC_AKM_SUITEB_SHA384)) > 0)
|
||||
#define IS_AKM_FT_WPA2_SHA384(_AKMMap) ((_AKMMap & (1 << SEC_AKM_FT_WPA2_SHA384)) > 0)
|
||||
#define IS_AKM_WPA3(_AKMMap) ((_AKMMap & (1 << SEC_AKM_WPA3)) > 0)
|
||||
#define IS_AKM_WPA3PSK(_AKMMap) (IS_AKM_SAE_SHA256(_AKMMap))
|
||||
#define IS_AKM_WPA3_192BIT(_AKMMap) (IS_AKM_SUITEB_SHA384(_AKMMap))
|
||||
#define IS_AKM_OWE(_AKMMap) ((_AKMMap & (1 << SEC_AKM_OWE)) > 0)
|
||||
|
||||
int get_macaddr(lua_State *L);
|
||||
int convert_string_display(lua_State *L);
|
||||
int StaInfo(lua_State *L);
|
||||
int getWMOde(lua_State *L);
|
||||
int getTxPower(lua_State *L);
|
||||
int getTempature(lua_State *L);
|
||||
int getChannel(lua_State *L);
|
||||
int scanResult(lua_State *L);
|
||||
void getRate(HTTRANSMIT_SETTING_FIX HTSetting, ULONG *fLastTxRxRate);
|
||||
void get_rate_he(UINT8 mcs, UINT8 bw, UINT8 nss, UINT8 dcm, ULONG *last_tx_rate);
|
||||
UINT32 cck_to_mcs(UINT32 mcs);
|
||||
const char *GetEncryModeStr(UINT32 encryMode);
|
||||
const char *GetAuthModeStr(UINT32 authMode);
|
||||
|
||||
#endif
|
||||
479
package/mtk/applications/luci-app-mtk/src/rate_calc.c
Normal file
479
package/mtk/applications/luci-app-mtk/src/rate_calc.c
Normal file
@@ -0,0 +1,479 @@
|
||||
#include "mtwifi.h"
|
||||
|
||||
#define MAX_NUM_HE_BANDWIDTHS 4
|
||||
#define MAX_NUM_HE_SPATIAL_STREAMS 4
|
||||
#define MAX_NUM_HE_MCS_ENTRIES 12
|
||||
|
||||
UINT32 cck_to_mcs(UINT32 mcs) {
|
||||
UINT32 ret = 0;
|
||||
if (mcs == TMI_TX_RATE_CCK_1M_LP)
|
||||
ret = 0;
|
||||
else if (mcs == TMI_TX_RATE_CCK_2M_LP)
|
||||
ret = 1;
|
||||
else if (mcs == TMI_TX_RATE_CCK_5M_LP)
|
||||
ret = 2;
|
||||
else if (mcs == TMI_TX_RATE_CCK_11M_LP)
|
||||
ret = 3;
|
||||
else if (mcs == TMI_TX_RATE_CCK_2M_SP)
|
||||
ret = 1;
|
||||
else if (mcs == TMI_TX_RATE_CCK_5M_SP)
|
||||
ret = 2;
|
||||
else if (mcs == TMI_TX_RATE_CCK_11M_SP)
|
||||
ret = 3;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static UINT16 he_mcs_phyrate_mapping_table[MAX_NUM_HE_BANDWIDTHS][MAX_NUM_HE_SPATIAL_STREAMS][MAX_NUM_HE_MCS_ENTRIES] = {
|
||||
{ /*20 Mhz*/
|
||||
/* 1 SS */
|
||||
{
|
||||
/* DCM 0*/
|
||||
8,
|
||||
17,
|
||||
25,
|
||||
34,
|
||||
51,
|
||||
68,
|
||||
77,
|
||||
86,
|
||||
103,
|
||||
114,
|
||||
129,
|
||||
143
|
||||
},
|
||||
/* 2 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
17,
|
||||
34,
|
||||
51,
|
||||
68,
|
||||
103,
|
||||
137,
|
||||
154,
|
||||
172,
|
||||
206,
|
||||
229,
|
||||
258,
|
||||
286
|
||||
},
|
||||
/* 3 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
25,
|
||||
51,
|
||||
77,
|
||||
103,
|
||||
154,
|
||||
206,
|
||||
232,
|
||||
258,
|
||||
309,
|
||||
344,
|
||||
387,
|
||||
430
|
||||
},
|
||||
/* 4 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
34,
|
||||
68,
|
||||
103,
|
||||
137,
|
||||
206,
|
||||
275,
|
||||
309,
|
||||
344,
|
||||
412,
|
||||
458,
|
||||
516,
|
||||
573
|
||||
}
|
||||
},
|
||||
{ /*40 Mhz*/
|
||||
/* 1 SS */
|
||||
{
|
||||
/* DCM 0*/
|
||||
17,
|
||||
34,
|
||||
51,
|
||||
68,
|
||||
103,
|
||||
137,
|
||||
154,
|
||||
172,
|
||||
206,
|
||||
229,
|
||||
258,
|
||||
286
|
||||
},
|
||||
/* 2 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
34,
|
||||
68,
|
||||
103,
|
||||
137,
|
||||
206,
|
||||
275,
|
||||
309,
|
||||
344,
|
||||
412,
|
||||
458,
|
||||
516,
|
||||
573
|
||||
|
||||
},
|
||||
/* 3 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
51,
|
||||
103,
|
||||
154,
|
||||
206,
|
||||
309,
|
||||
412,
|
||||
464,
|
||||
516,
|
||||
619,
|
||||
688,
|
||||
774,
|
||||
860
|
||||
|
||||
},
|
||||
/* 4 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
68,
|
||||
137,
|
||||
206,
|
||||
275,
|
||||
412,
|
||||
550,
|
||||
619,
|
||||
688,
|
||||
825,
|
||||
917,
|
||||
1032,
|
||||
1147
|
||||
}
|
||||
},
|
||||
{ /*80 Mhz*/
|
||||
/* 1 SS */
|
||||
{
|
||||
/* DCM 0*/
|
||||
36,
|
||||
72,
|
||||
108,
|
||||
144,
|
||||
216,
|
||||
288,
|
||||
324,
|
||||
360,
|
||||
432,
|
||||
480,
|
||||
540,
|
||||
600
|
||||
},
|
||||
/* 2 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
72,
|
||||
144,
|
||||
216,
|
||||
288,
|
||||
432,
|
||||
576,
|
||||
648,
|
||||
720,
|
||||
864,
|
||||
960,
|
||||
1080,
|
||||
1201
|
||||
},
|
||||
/* 3 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
108,
|
||||
216,
|
||||
324,
|
||||
432,
|
||||
648,
|
||||
864,
|
||||
972,
|
||||
1080,
|
||||
1297,
|
||||
1441,
|
||||
1621,
|
||||
1801
|
||||
},
|
||||
/* 4 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
144,
|
||||
288,
|
||||
432,
|
||||
576,
|
||||
864,
|
||||
1152,
|
||||
1297,
|
||||
1141,
|
||||
1729,
|
||||
1921,
|
||||
2161,
|
||||
2401
|
||||
}
|
||||
},
|
||||
{ /*160 Mhz*/
|
||||
/* 1 SS */
|
||||
{
|
||||
/* DCM 0*/
|
||||
72,
|
||||
144,
|
||||
216,
|
||||
288,
|
||||
432,
|
||||
576,
|
||||
648,
|
||||
720,
|
||||
864,
|
||||
960,
|
||||
1080,
|
||||
1201
|
||||
},
|
||||
/* 2 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
144,
|
||||
288,
|
||||
432,
|
||||
576,
|
||||
864,
|
||||
1152,
|
||||
1297,
|
||||
1441,
|
||||
1729,
|
||||
1921,
|
||||
2161,
|
||||
2401
|
||||
},
|
||||
/* 3 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
216,
|
||||
432,
|
||||
648,
|
||||
864,
|
||||
1297,
|
||||
1729,
|
||||
1945,
|
||||
2161,
|
||||
2594,
|
||||
2882,
|
||||
3242,
|
||||
3602
|
||||
},
|
||||
/* 4 SS */
|
||||
{
|
||||
/* DCM 0 */
|
||||
288,
|
||||
576,
|
||||
864,
|
||||
1152,
|
||||
1729,
|
||||
2305,
|
||||
2594,
|
||||
2882,
|
||||
3458,
|
||||
3843,
|
||||
4323,
|
||||
4803
|
||||
},
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void get_rate_he(UINT8 mcs, UINT8 bw, UINT8 nss, UINT8 dcm, ULONG *last_tx_rate)
|
||||
{
|
||||
ULONG value = 0;
|
||||
|
||||
if (nss == 0)
|
||||
nss = 1;
|
||||
|
||||
if (mcs >= MAX_NUM_HE_MCS_ENTRIES)
|
||||
mcs = MAX_NUM_HE_MCS_ENTRIES - 1;
|
||||
|
||||
if (nss > MAX_NUM_HE_SPATIAL_STREAMS)
|
||||
nss = MAX_NUM_HE_SPATIAL_STREAMS;
|
||||
|
||||
if (bw >= MAX_NUM_HE_BANDWIDTHS)
|
||||
bw = MAX_NUM_HE_BANDWIDTHS - 1;
|
||||
|
||||
nss--;
|
||||
|
||||
value = he_mcs_phyrate_mapping_table[bw][nss][mcs];
|
||||
/*In spec data rate when DCM =1 is half of the data rate when DCM = 0*/
|
||||
if (dcm && value)
|
||||
value = value / 2 ;
|
||||
|
||||
*last_tx_rate = (ULONG)value;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static INT32 getLegacyOFDMMCSIndex(UINT8 MCS)
|
||||
{
|
||||
INT32 mcs_index = MCS;
|
||||
|
||||
if (MCS == 0xb)
|
||||
mcs_index = 0;
|
||||
else if (MCS == 0xf)
|
||||
mcs_index = 1;
|
||||
else if (MCS == 0xa)
|
||||
mcs_index = 2;
|
||||
else if (MCS == 0xe)
|
||||
mcs_index = 3;
|
||||
else if (MCS == 0x9)
|
||||
mcs_index = 4;
|
||||
else if (MCS == 0xd)
|
||||
mcs_index = 5;
|
||||
else if (MCS == 0x8)
|
||||
mcs_index = 6;
|
||||
else if (MCS == 0xc)
|
||||
mcs_index = 7;
|
||||
|
||||
return mcs_index;
|
||||
}
|
||||
|
||||
static INT MCSMappingRateTable[] = {
|
||||
2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 109, 110, 111, 112,/* CCK and OFDM */
|
||||
13, 26, 39, 52, 78, 104, 117, 130, 26, 52, 78, 104, 156, 208, 234, 260,
|
||||
39, 78, 117, 156, 234, 312, 351, 390, /* BW 20, 800ns GI, MCS 0~23 */
|
||||
27, 54, 81, 108, 162, 216, 243, 270, 54, 108, 162, 216, 324, 432, 486, 540,
|
||||
81, 162, 243, 324, 486, 648, 729, 810, /* BW 40, 800ns GI, MCS 0~23 */
|
||||
14, 29, 43, 57, 87, 115, 130, 144, 29, 59, 87, 115, 173, 230, 260, 288,
|
||||
43, 87, 130, 173, 260, 317, 390, 433, /* BW 20, 400ns GI, MCS 0~23 */
|
||||
30, 60, 90, 120, 180, 240, 270, 300, 60, 120, 180, 240, 360, 480, 540, 600,
|
||||
90, 180, 270, 360, 540, 720, 810, 900, /* BW 40, 400ns GI, MCS 0~23 */
|
||||
|
||||
/*for 11ac:20 Mhz 800ns GI*/
|
||||
6, 13, 19, 26, 39, 52, 58, 65, 78, 90, /*1ss mcs 0~8*/
|
||||
13, 26, 39, 52, 78, 104, 117, 130, 156, 180, /*2ss mcs 0~8*/
|
||||
19, 39, 58, 78, 117, 156, 175, 195, 234, 260, /*3ss mcs 0~9*/
|
||||
26, 52, 78, 104, 156, 208, 234, 260, 312, 360, /*4ss mcs 0~8*/
|
||||
|
||||
/*for 11ac:40 Mhz 800ns GI*/
|
||||
13, 27, 40, 54, 81, 108, 121, 135, 162, 180, /*1ss mcs 0~9*/
|
||||
27, 54, 81, 108, 162, 216, 243, 270, 324, 360, /*2ss mcs 0~9*/
|
||||
40, 81, 121, 162, 243, 324, 364, 405, 486, 540, /*3ss mcs 0~9*/
|
||||
54, 108, 162, 216, 324, 432, 486, 540, 648, 720, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:80 Mhz 800ns GI*/
|
||||
29, 58, 87, 117, 175, 234, 263, 292, 351, 390, /*1ss mcs 0~9*/
|
||||
58, 117, 175, 243, 351, 468, 526, 585, 702, 780, /*2ss mcs 0~9*/
|
||||
87, 175, 263, 351, 526, 702, 0, 877, 1053, 1170, /*3ss mcs 0~9*/
|
||||
117, 234, 351, 468, 702, 936, 1053, 1170, 1404, 1560, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:160 Mhz 800ns GI*/
|
||||
58, 117, 175, 234, 351, 468, 526, 585, 702, 780, /*1ss mcs 0~9*/
|
||||
117, 234, 351, 468, 702, 936, 1053, 1170, 1404, 1560, /*2ss mcs 0~9*/
|
||||
175, 351, 526, 702, 1053, 1404, 1579, 1755, 2160, 0, /*3ss mcs 0~8*/
|
||||
234, 468, 702, 936, 1404, 1872, 2106, 2340, 2808, 3120, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:20 Mhz 400ns GI*/
|
||||
7, 14, 21, 28, 43, 57, 65, 72, 86, 100, /*1ss mcs 0~8*/
|
||||
14, 28, 43, 57, 86, 115, 130, 144, 173, 200, /*2ss mcs 0~8*/
|
||||
21, 43, 65, 86, 130, 173, 195, 216, 260, 288, /*3ss mcs 0~9*/
|
||||
28, 57, 86, 115, 173, 231, 260, 288, 346, 400, /*4ss mcs 0~8*/
|
||||
|
||||
/*for 11ac:40 Mhz 400ns GI*/
|
||||
15, 30, 45, 60, 90, 120, 135, 150, 180, 200, /*1ss mcs 0~9*/
|
||||
30, 60, 90, 120, 180, 240, 270, 300, 360, 400, /*2ss mcs 0~9*/
|
||||
45, 90, 135, 180, 270, 360, 405, 450, 540, 600, /*3ss mcs 0~9*/
|
||||
60, 120, 180, 240, 360, 480, 540, 600, 720, 800, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:80 Mhz 400ns GI*/
|
||||
32, 65, 97, 130, 195, 260, 292, 325, 390, 433, /*1ss mcs 0~9*/
|
||||
65, 130, 195, 260, 390, 520, 585, 650, 780, 866, /*2ss mcs 0~9*/
|
||||
97, 195, 292, 390, 585, 780, 0, 975, 1170, 1300, /*3ss mcs 0~9*/
|
||||
130, 260, 390, 520, 780, 1040, 1170, 1300, 1560, 1733, /*4ss mcs 0~9*/
|
||||
|
||||
/*for 11ac:160 Mhz 400ns GI*/
|
||||
65, 130, 195, 260, 390, 520, 585, 650, 780, 866, /*1ss mcs 0~9*/
|
||||
130, 260, 390, 520, 780, 1040, 1170, 1300, 1560, 1733, /*2ss mcs 0~9*/
|
||||
195, 390, 585, 780, 1170, 1560, 1755, 1950, 2340, 0, /*3ss mcs 0~8*/
|
||||
260, 520, 780, 1040, 1560, 2080, 2340, 2600, 3120, 3466, /*4ss mcs 0~9*/
|
||||
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37
|
||||
}; /* 3*3 */
|
||||
|
||||
|
||||
void getRate(HTTRANSMIT_SETTING_FIX HTSetting, ULONG *fLastTxRxRate)
|
||||
{
|
||||
UINT8 Antenna = 0;
|
||||
UINT8 MCS = HTSetting.field.MCS;
|
||||
int rate_count = sizeof(MCSMappingRateTable) / sizeof(int);
|
||||
int rate_index = 0;
|
||||
int value = 0;
|
||||
|
||||
if (HTSetting.field.MODE >= MODE_VHT) {
|
||||
MCS = HTSetting.field.MCS & 0xf;
|
||||
Antenna = (HTSetting.field.MCS >> 4) + 1;
|
||||
|
||||
if (HTSetting.field.BW == BW_20) {
|
||||
rate_index = 112 + ((Antenna - 1) * 10) +
|
||||
((UCHAR)HTSetting.field.ShortGI * 160) +
|
||||
((UCHAR)MCS);
|
||||
} else if (HTSetting.field.BW == BW_40) {
|
||||
rate_index = 152 + ((Antenna - 1) * 10) +
|
||||
((UCHAR)HTSetting.field.ShortGI * 160) +
|
||||
((UCHAR)MCS);
|
||||
} else if (HTSetting.field.BW == BW_80) {
|
||||
rate_index = 192 + ((Antenna - 1) * 10) +
|
||||
((UCHAR)HTSetting.field.ShortGI * 160) +
|
||||
((UCHAR)MCS);
|
||||
} else if (HTSetting.field.BW == BW_160) {
|
||||
rate_index = 232 + ((Antenna - 1) * 10) +
|
||||
((UCHAR)HTSetting.field.ShortGI * 160) +
|
||||
((UCHAR)MCS);
|
||||
}
|
||||
} else {
|
||||
if (HTSetting.field.MODE >= MODE_HTMIX) {
|
||||
MCS = HTSetting.field.MCS;
|
||||
|
||||
if ((HTSetting.field.MODE == MODE_HTMIX)
|
||||
|| (HTSetting.field.MODE == MODE_HTGREENFIELD))
|
||||
Antenna = (MCS >> 3) + 1;
|
||||
|
||||
/* map back to 1SS MCS , multiply by antenna numbers later */
|
||||
if (MCS > 7)
|
||||
MCS %= 8;
|
||||
|
||||
rate_index = 16 + ((UCHAR)HTSetting.field.BW * 24) + ((UCHAR)HTSetting.field.ShortGI * 48) + ((UCHAR)MCS);
|
||||
} else {
|
||||
if (HTSetting.field.MODE == MODE_OFDM)
|
||||
rate_index = getLegacyOFDMMCSIndex(HTSetting.field.MCS) + 4;
|
||||
else if (HTSetting.field.MODE == MODE_CCK)
|
||||
rate_index = (UCHAR)(HTSetting.field.MCS);
|
||||
}
|
||||
}
|
||||
|
||||
if (rate_index < 0)
|
||||
rate_index = 0;
|
||||
|
||||
if (rate_index >= rate_count)
|
||||
rate_index = rate_count - 1;
|
||||
|
||||
if (HTSetting.field.MODE < MODE_VHT)
|
||||
value = (MCSMappingRateTable[rate_index] * 5) / 10;
|
||||
else
|
||||
value = MCSMappingRateTable[rate_index];
|
||||
|
||||
if (HTSetting.field.MODE >= MODE_HTMIX && HTSetting.field.MODE < MODE_VHT)
|
||||
value *= Antenna;
|
||||
|
||||
*fLastTxRxRate = (ULONG)value;
|
||||
return;
|
||||
}
|
||||
79
package/mtk/applications/luci-app-mtk/src/security.c
Normal file
79
package/mtk/applications/luci-app-mtk/src/security.c
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "mtwifi.h"
|
||||
|
||||
const char *GetEncryModeStr(UINT32 encryMode)
|
||||
{
|
||||
if (IS_CIPHER_NONE(encryMode))
|
||||
return "NONE";
|
||||
else if (IS_CIPHER_WEP(encryMode))
|
||||
return "WEP";
|
||||
else if (IS_CIPHER_TKIP(encryMode) && IS_CIPHER_CCMP128(encryMode))
|
||||
return "TKIPAES";
|
||||
else if (IS_CIPHER_TKIP(encryMode))
|
||||
return "TKIP";
|
||||
else if (IS_CIPHER_CCMP128(encryMode))
|
||||
return "AES";
|
||||
else if (IS_CIPHER_CCMP256(encryMode))
|
||||
return "CCMP256";
|
||||
else if (IS_CIPHER_GCMP128(encryMode))
|
||||
return "GCMP128";
|
||||
else if (IS_CIPHER_GCMP256(encryMode))
|
||||
return "GCMP256";
|
||||
else if (IS_CIPHER_BIP_CMAC128(encryMode))
|
||||
return "BIP-CMAC128";
|
||||
else if (IS_CIPHER_BIP_CMAC256(encryMode))
|
||||
return "BIP-CMAC256";
|
||||
else if (IS_CIPHER_BIP_GMAC128(encryMode))
|
||||
return "BIP-GMAC128";
|
||||
else if (IS_CIPHER_BIP_GMAC256(encryMode))
|
||||
return "BIP-GMAC256";
|
||||
else
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
const char *GetAuthModeStr(UINT32 authMode)
|
||||
{
|
||||
if (IS_AKM_OPEN(authMode))
|
||||
return "OPEN";
|
||||
else if (IS_AKM_SHARED(authMode))
|
||||
return "SHARED";
|
||||
else if (IS_AKM_AUTOSWITCH(authMode))
|
||||
return "WEPAUTO";
|
||||
else if (IS_AKM_WPANONE(authMode))
|
||||
return "WPANONE";
|
||||
else if (IS_AKM_FT_WPA2PSK(authMode) && IS_AKM_FT_SAE_SHA256(authMode))
|
||||
return "FT-WPA2PSKWPA3PSK";
|
||||
else if (IS_AKM_WPA1(authMode) && IS_AKM_WPA2(authMode))
|
||||
return "WPA1WPA2";
|
||||
else if (IS_AKM_WPA1PSK(authMode) && IS_AKM_WPA2PSK(authMode))
|
||||
return "WPAPSKWPA2PSK";
|
||||
else if (IS_AKM_WPA2PSK(authMode) && IS_AKM_WPA3PSK(authMode))
|
||||
return "WPA2PSKWPA3PSK";
|
||||
else if (IS_AKM_WPA2PSK(authMode) && IS_AKM_WPA2PSK_SHA256(authMode) && IS_AKM_WPA3PSK(authMode))
|
||||
return "WPA2PSKMIXWPA3PSK";
|
||||
else if (IS_AKM_FT_SAE_SHA256(authMode))
|
||||
return "FT-SAE";
|
||||
else if (IS_AKM_WPA3PSK(authMode))
|
||||
return "WPA3PSK";
|
||||
else if (IS_AKM_WPA1(authMode))
|
||||
return "WPA";
|
||||
else if (IS_AKM_WPA1PSK(authMode))
|
||||
return "WPAPSK";
|
||||
else if (IS_AKM_FT_WPA2(authMode))
|
||||
return "FT-WPA2";
|
||||
else if (IS_AKM_FT_WPA2PSK(authMode))
|
||||
return "FT-WPA2PSK";
|
||||
else if (IS_AKM_WPA3(authMode)) /* WPA3 will be always accompanied by WPA2, so it should put before the WPA2 */
|
||||
return "WPA3";
|
||||
else if (IS_AKM_WPA2(authMode))
|
||||
return "WPA2";
|
||||
else if (IS_AKM_WPA2(authMode) && IS_AKM_WPA2_SHA256(authMode))
|
||||
return "WPA2MIX";
|
||||
else if (IS_AKM_WPA2PSK(authMode))
|
||||
return "WPA2PSK";
|
||||
else if (IS_AKM_WPA3_192BIT(authMode))
|
||||
return "WPA3-192";
|
||||
else if (IS_AKM_OWE(authMode))
|
||||
return "OWE";
|
||||
else
|
||||
return "Unknown";
|
||||
}
|
||||
17
package/mtk/applications/luci-app-mtwifi-cfg/Makefile
Normal file
17
package/mtk/applications/luci-app-mtwifi-cfg/Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# Copyright (C) hanwckf <hanwckf@vip.qq.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for mtwifi-cfg
|
||||
LUCI_DEPENDS:=+mtwifi-cfg
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_VERSION:=1
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user