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_addr0 |= 0x2;

switch (MacByte) {

case 0x1: /* choose bit23:20*/

wdev->if_addr2 = wdev->if_addr2 & MacMask;//clear high 4 bits,

wdev->if_addr2 = (wdev->if_addr2 | (idx << 4));

break;

case 0x2: /* choose bit31:28*/

wdev->if_addr3 = wdev->if_addr3 & MacMask;//clear high 4 bits,

wdev->if_addr3 = (wdev->if_addr3 | (idx << 4));

break;

case 0x3: /* choose bit39:36*/

wdev->if_addr4 = wdev->if_addr4 & MacMask;//clear high 4 bits,

wdev->if_addr4 = (wdev->if_addr4 | (idx << 4));

break;

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

wdev->if_addr5 = wdev->if_addr5 & MacMask;//clear high 4 bits,

wdev->if_addr5 = (wdev->if_addr5 | (idx << 4));

break;

default: /* choose bit15:12*/

wdev->if_addr1 = wdev->if_addr1 & MacMask;//clear high 4 bits,

wdev->if_addr1 = (wdev->if_addr1 | (idx << 4));

break;

}

}
else
{
unsigned char buf8={0};
if (kernel_read(file, 0, buf, 8) > 0)
{
wdev->if_addr0 =buf0 ;
wdev->if_addr1 =buf1;
wdev->if_addr2 =buf2;
wdev->if_addr3 =buf3;
wdev->if_addr4 =buf4 ;
wdev->if_addr5 =buf5;
printk("%d.mac-addr=%x:%x:%x:%x:%x:%x\n",idx,buf0,buf1,buf2,buf3,buf4,buf5);
}

}

}

}

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_addr8={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_addr0,&mac_addr1,&mac_addr2,&mac_addr3,&mac_addr4,&mac_addr5);
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_addr0,mac_addr1,mac_addr2,mac_addr3,mac_addr4,mac_addr5);
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

相关推荐
FlightYe11 分钟前
linux系统编程(八):阻塞与非阻塞IO对比
android·linux·运维·服务器·github·vim
淮北4941 小时前
ubuntu22 默认输入法调整频率
运维·服务器·git·ubuntu·elasticsearch
Percep_gan1 小时前
切割服务器日志
运维·服务器
骇客野人1 小时前
阿里云运维手册(通用生产版|云上运维标准化文档)
运维·阿里云·云计算
向阳是我1 小时前
两台 Mac 远程共享屏幕最佳方案:Tailscale + macOS 原生屏幕共享
macos
雾时之林2 小时前
Linux---计算机网络常见面试题
linux·运维·计算机网络
维核科技2 小时前
多卡集群频繁裂卡、通信报错?NVLink故障排查与运维优化方案
运维·服务器维修·gpu维修·算力卡维修·gpu故障·算力卡故障·服务器故障
10mAh2 小时前
【Linux】error while loading shared libraries 怎么解决?——ldd、RPATH 与动态链接排错
java·linux·前端
Promise微笑2 小时前
红外热像仪选型:3~5μm中波与8~14μm长波探测机理解析
运维
承渊政道2 小时前
飞牛NAS部署Immich:搭建家庭相册并实现远程访问
运维·服务器·docker·内网穿透·cpolar·nas·immich