QCA9531--------------------------------------->
libra@SVN:/home/trolink/samba/QCA_SRC/OpenWrt/mac_src$ cat modify_mac.c
#include <stdio.h>
#include <syslog.h>
#include <stdarg.h>
#include <fcntl.h>
static int tr_system(char *command)
{
FILE *fp=NULL;
char result_buf[128]={0};
fp = popen(command, "r");
if (NULL == fp)
{
printf("popen ERR\n");
return -1;
}
while(fgets(result_buf, sizeof(result_buf), fp) != NULL)
{
}
pclose(fp);
return 0;
}
int main()
{
FILE* fd;
unsigned char wifi_mac[6]={0};
if(tr_system("dd if=/dev/mtd5 of=/tmp/art.bin") < 0)
{
printf("dd if tr_system err \n");
return -1;
}
fd = fopen("/tmp/art.bin","r+b");
if(!fd )
{
perror("open art.bin failed\n");
return -1;
}
fseek(fd,0x1002,SEEK_SET);
if(6 != fread(wifi_mac,1,6,fd))
{
printf("read art.bin failed\n");
fclose(fd);
return -1;
}
//printf("0. mac-addr=%x:%x:%x:%x:%x:%x\n",wifi_mac[0],wifi_mac[1],wifi_mac[2],wifi_mac[3],wifi_mac[4],wifi_mac[5]);
fseek(fd,0x00,SEEK_SET);
wifi_mac[5]++;
if(wifi_mac[5] == 0x00)
{
wifi_mac[4]++;