MT7628基于原厂的SDK包, 修改ra1网卡的MAC方法。

1、在/etc/config/wireless文件添加多个WIFI网卡的方法。
2、修改WIFI驱动,在src/embedded/ap/ap.c文件里面,从系统文件信息来修改ra1网卡的MAC内容,添加红色部分源代码。

RTMP_IO_WRITE32(pAd, RMAC_RMACDR, Value);

if (idx > 0)

{

struct file *file;
file = filp_open("/etc/mac.bin", O_RDONLY, 0);
if (IS_ERR(file))
{

/* MT7603, bit1 in byte0 shall always be b'1 for Multiple BSSID */

wdev->if_addr[0] |= 0x2;

switch (MacByte) {

case 0x1: /* choose bit[23:20]*/

wdev->if_addr[2] = wdev->if_addr[2] & MacMask;//clear high 4 bits,

wdev->if_addr[2] = (wdev->if_addr[2] | (idx << 4));

break;

case 0x2: /* choose bit[31:28]*/

wdev->if_addr[3] = wdev->if_addr[3] & MacMask;//clear high 4 bits,

wdev->if_addr[3] = (wdev->if_addr[3] | (idx << 4));

break;

case 0x3: /* choose bit[39:36]*/

wdev->if_addr[4] = wdev->if_addr[4] & MacMask;//clear high 4 bits,

wdev->if_addr[4] = (wdev->if_addr[4] | (idx << 4));

break;

case 0x4: /* choose bit [47:44]*/

wdev->if_addr[5] = wdev->if_addr[5] & MacMask;//clear high 4 bits,

wdev->if_addr[5] = (wdev->if_addr[5] | (idx << 4));

break;

default: /* choose bit[15:12]*/

wdev->if_addr[1] = wdev->if_addr[1] & MacMask;//clear high 4 bits,

wdev->if_addr[1] = (wdev->if_addr[1] | (idx << 4));

break;

}

}
else
{
unsigned char buf[8]={0};
if (kernel_read(file, 0, buf, 8) > 0)
{
wdev->if_addr[0] =buf[0] ;
wdev->if_addr[1] =buf[1];
wdev->if_addr[2] =buf[2];
wdev->if_addr[3] =buf[3];
wdev->if_addr[4] =buf[4] ;
wdev->if_addr[5] =buf[5];
printk("%d.mac-addr=%x:%x:%x:%x:%x:%x\n",idx,buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]);
}

}

}

}

3、开发应用程序,用于写MAC信息到文件里面。

libra@SVN:~/openwrt_mtk_4G/ra1_MAC$ cat Write_MAC.c
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <netdb.h>
#include <sys/types.h>
#include <arpa/inet.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#define MAC_ADDR_DATA "/etc/mac.bin"

int main()
{
unsigned char mac_addr[8]={0};
FILE *outfile=NULL;
int rc=0;
printf("Please enter the MAC data(0x20 0x15 0x12 0x07 0x00 0x00):\n");
scanf("%x%x%x%x%x%x",&mac_addr[0],&mac_addr[1],&mac_addr[2],&mac_addr[3],&mac_addr[4],&mac_addr[5]);
outfile = fopen(MAC_ADDR_DATA, "wb" );
if( outfile == NULL)
{
printf("fopen %s, %s\n",MAC_ADDR_DATA,"not exit/n");
return -1;
}
fseek(outfile,0x0,SEEK_SET);
rc=fwrite(mac_addr, 1, 6, outfile );
fclose(outfile);
printf("The starting position of MAC is:%x:%x:%x:%x:%x:%x\n",mac_addr[0],mac_addr[1],mac_addr[2],mac_addr[3],mac_addr[4],mac_addr[5]);
return rc;
}

libra@SVN:~/openwrt_mtk_4G/ra1_MAC cat make.sh rm -rf Write_MAC /home/libra/openwrt_mtk_4G/openwrt-sdk/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc Write_MAC.c -o Write_MAC libra@SVN:\~/openwrt_mtk_4G/ra1_MAC

相关推荐
ximy13352 小时前
AI服务器工作之服务器的种类分类
运维·服务器
恒创科技HK2 小时前
香港服务器CPU中E5和Gold的区别
运维·服务器
一张假钞4 小时前
Ubuntu SSH 免密码登陆
linux·ubuntu·ssh
Wang's Blog5 小时前
Linux小课堂: 文件操作警惕高危删除命令与深入文件链接机制
linux·运维·服务器
水月wwww6 小时前
操作系统——进程管理
linux·操作系统·vim·进程·进程调度
2501_915909066 小时前
iOS 混淆实战,多工具组合完成 IPA 混淆与加固(源码 + 成品 + 运维一体化方案)
android·运维·ios·小程序·uni-app·iphone·webview
我科绝伦(Huanhuan Zhou)6 小时前
分享一个可以一键制作在线yum源的脚本
linux·运维
爱宇阳7 小时前
禅道社区版 Docker Compose 服务迁移教程
运维·docker·容器
Paper_Love7 小时前
Linux-查看硬件接口软件占用
linux·运维·服务器
wydaicls7 小时前
Linux 系统下 ZONE 区域的划分
linux·运维·服务器