[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Changing MAC address of network interface?

From: Noam Weissman
Subject: Re: [lwip-users] Changing MAC address of network interface?
Date: Thu, 7 Apr 2016 14:10:47 +0000


MAC address should not be changed. This should be a onetime setup per device.
Meaning you set a real MAC address that is assigned to you and that's all.

This is done before calling netif_add function. Here is a portion of the 
initializing code
I am using:
static void prvEthernetConfigureInterface(void * param)
  struct ip_addr xIpAddr;
  struct ip_addr xNetMast;
  struct ip_addr xGateway;  
  u8 i, MACadd[6] = {0};
  /* Parameters are not used - suppress compiler error. */
  ( void ) param;
  /* Create and configure the EMAC interface, IP, GateWay and Mask values. */
  xIpAddr.addr = GetIpAddDword();
  xNetMast.addr = GetIpMaskDword();
  xGateway.addr = GetIpGwDword();         

  /* set MAC hardware address length */
  s_EMAC_if.hwaddr_len = ETHARP_HWADDR_LEN;

  /* Get MAC hardware address */
  // copy the default MAC address to the netif stracture
  for(i=0; i<ETHARP_HWADDR_LEN; i++)
    s_EMAC_if.hwaddr[i] = MACadd[i];
  // add the new interface to the list of interfaces after initializing it.   
  netif_add(&s_EMAC_if, &xIpAddr, &xNetMast, &xGateway, NULL, ethernetif_init, 
  // make it the default interface 

  // Set the link callback function, this function is called on change of link 
  // ETH_link_callback function is declared in stm32fxxx_eth.c or similar...
  netif_set_link_callback(&s_EMAC_if, ETH_link_callback);   
  // When USE_DHCP is not defined or when DHCP is off ...
#ifdef USE_DHCP  
  if(GetTcpIpMode() == FALSE)


The above code is loaded once when device is rebooted.

IP address, MAC etc... are loaded from FLASH.


-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Freddie Chopin
Sent: Thursday, April 07, 2016 1:54 PM
To: lwip-users
Subject: [lwip-users] Changing MAC address of network interface?


I was wondering what is the proper way to change MAC address of network 
interface. Can I just change the contents of netif.hwaddr[] and expect 
everything to still work correctly (assuming I also change the MAC address in 
the driver)? Maybe I have to bring the netif completely down, remove it, change 
the configuration (MAC address only), add it again and bring it up?

Thanks for any help!


lwip-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]