这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 怎样修改目标板的mac地址?先谢谢了!

共7条 1/1 1 跳转至

怎样修改目标板的mac地址?先谢谢了!

菜鸟
2005-06-17 16:26:29     打赏
谢谢



关键词: 怎样     修改     目标     地址     先谢     谢了    

菜鸟
2005-06-17 23:30:00     打赏
2楼

很久以前本论坛有一篇帖子,讲过如何动态修改mac地址。

找找看。


菜鸟
2005-06-18 00:16:00     打赏
3楼

void MacSet(int port) { char* buf; int length;

if (sysNvRamGet((UINT8 *)&npeMacAddr.macAddress, IX_IEEE803_MAC_ADDRESS_SIZE, nvRamNpeMacAddr[port]) == ERROR) { printf("ixe %d - Unable to read MAC address from non-volatile storage!\n" , port );

} /* Check for a valid MAC address - Only compare first three bytes */ npeMacAddr.macAddress[5] += port;

printf("ixe ETH PHY %d Hard Coded MAC address is: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n" , port ,npeMacAddr.macAddress[0], npeMacAddr.macAddress[1] ,npeMacAddr.macAddress[2], npeMacAddr.macAddress[3] ,npeMacAddr.macAddress[4], npeMacAddr.macAddress[5]);

printf ("npeMacAddr.macAddress0\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[0]=atoi(buf); printf ("npeMacAddr.macAddress1\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[1]=atoi(buf);

printf ("npeMacAddr.macAddress2\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[2]=atoi(buf);

printf ("npeMacAddr.macAddress3\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[3]=atoi(buf);

printf ("npeMacAddr.macAddress4\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[4]=atoi(buf);

printf ("npeMacAddr.macAddress5\n"); length = read (STD_IN, buf, sizeof(buf) - 1); npeMacAddr.macAddress[5]=atoi(buf);

npeMacAddr.macAddress[5] += port;

printf("ixe ETH PHY %d Hard Coded MAC address is: %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n" , port ,npeMacAddr.macAddress[0], npeMacAddr.macAddress[1] ,npeMacAddr.macAddress[2], npeMacAddr.macAddress[3] ,npeMacAddr.macAddress[4], npeMacAddr.macAddress[5]); }


菜鸟
2005-06-18 00:17:00     打赏
4楼
上面是我修改Mac的代码,可是修改后,重启系统,MAC还是原来的,帮忙侃侃,先谢谢了

菜鸟
2005-06-18 03:12:00     打赏
5楼

不能提供你源代码,提供一个思路,我们就是这么做的。

将mac地址保存在flash上的一个固定地址处,每次更改flash就重新写到这里,需要用地址的时候就从这里读取,写连个操作flash的接口就好了,另外就是修改地址时逻辑判断的一个函数,在那个函数中调用写接口写进去。


菜鸟
2005-06-21 04:22:00     打赏
6楼

兄弟,帮忙啊,谢谢


菜鸟
2005-06-21 18:19:00     打赏
7楼

通过ipmacset命令后,ip地址改了,MAC 也改了,可是这里去ping不通, 并且bootline中的目标板的地址却还是原来的,启动时显示的mac还是原来的,奇怪!!

-> ipmacset

ixe0 MAC address: 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:69

ixe0 IP address: 169.254.113.143 ixe1 IP address: 169.254.113.144

Any Changes (y/n)> y

Change a MAC address (y/n)> y ixe0 MAC address: 00:02:b3:3c:16:68 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:69 00:02:b3:3c:16:64

Change ixe IP address (y/n)> y ixe0 IP address: 169.254.113.143 169.254.113.146 ixe1 IP address: 169.254.113.144 169.254.113.147

ixe0 MAC address: 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:64

ixe0 IP address: 169.254.113.146 ixe1 IP address: 169.254.113.147

Any Changes (y/n)> y

Change a MAC address (y/n)> n

Change ixe IP address (y/n)> n

ixe0 MAC address: 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:64

ixe0 IP address: 169.254.113.146 ixe1 IP address: 169.254.113.147

Any Changes (y/n)> n

Writing interface data to non-volatile storage... New configuration written, changes will take effect after a reboot value = 0 = 0x0 -> reboot 系统重新启动后。。。

-> ipmacset

ixe0 MAC address: 00:02:b3:3c:16:68 ixe1 MAC address: 00:02:b3:3c:16:64

ixe0 IP address: 169.254.113.146 ixe1 IP address: 169.254.113.147

Any Changes (y/n)> n value = 0 = 0x0 ->

-> ping "169.254.113.146",1,0 ping: timeout no answer from 169.254.113.146 value = -1 = 0xffffffff -> ping "169.254.113.147",1,0 ping: timeout no answer from 169.254.113.147 value = -1 = 0xffffffff -> ip地址从这里看是改了,MAC 也改了,可是这里去ping不通, 并且bootline中的目标板的地址却还是原来的,奇怪!! '.' = clear field; '-' = go to previous field; ^D = quit

boot device : ixe1 processor number : 0 host name : host file name : vxworks inet on ethernet (e) : 169.254.113.144 inet on backplane (b): host inet (h) : 169.254.113.140 gateway inet (g) : user (u) : xjb ftp password (pw) (blank = use rsh): 1 flags (f) : 0x0 target name (tn) : startup script (s) : other (o) : ixe0 value = 0 = 0x0


共7条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]