QCA9531与MT7621,从无线MAC更新到以太网口MAC的源代码

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]++;
             

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值