mirror of https://github.com/ARMmbed/mbed-os.git
Update EMAC connect logic with MAC address change
Do not fail EMAC interface during connect if MAC address change is not supported in the selected interface.pull/13902/head
parent
b1f65d2e68
commit
8f88cba705
|
@ -15,9 +15,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "EMACInterface.h"
|
#include "EMACInterface.h"
|
||||||
|
#include "mbed_trace.h"
|
||||||
|
|
||||||
using namespace mbed;
|
using namespace mbed;
|
||||||
|
|
||||||
|
#define TRACE_GROUP "EMACi"
|
||||||
|
|
||||||
/* Interface implementation */
|
/* Interface implementation */
|
||||||
EMACInterface::EMACInterface(EMAC &emac, OnboardNetworkStack &stack) :
|
EMACInterface::EMACInterface(EMAC &emac, OnboardNetworkStack &stack) :
|
||||||
_emac(emac),
|
_emac(emac),
|
||||||
|
@ -69,10 +72,17 @@ nsapi_error_t EMACInterface::set_dhcp(bool dhcp)
|
||||||
nsapi_error_t EMACInterface::connect()
|
nsapi_error_t EMACInterface::connect()
|
||||||
{
|
{
|
||||||
if (!_interface) {
|
if (!_interface) {
|
||||||
nsapi_error_t err;
|
nsapi_error_t err = NSAPI_ERROR_UNSUPPORTED;
|
||||||
|
|
||||||
if (_hw_mac_addr_set) {
|
if (_hw_mac_addr_set) {
|
||||||
err = _stack.add_ethernet_interface(_emac, true, &_interface, _hw_mac_addr);
|
err = _stack.add_ethernet_interface(_emac, true, &_interface, _hw_mac_addr);
|
||||||
} else {
|
if (err == NSAPI_ERROR_UNSUPPORTED) {
|
||||||
|
tr_error("Failed to set user MAC address");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err == NSAPI_ERROR_UNSUPPORTED)
|
||||||
|
{
|
||||||
err = _stack.add_ethernet_interface(_emac, true, &_interface);
|
err = _stack.add_ethernet_interface(_emac, true, &_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,9 @@ public:
|
||||||
* be unique globally. The address must be set before calling the interface
|
* be unique globally. The address must be set before calling the interface
|
||||||
* connect() method.
|
* connect() method.
|
||||||
*
|
*
|
||||||
* Not all interfaces are supporting MAC address set. A call to connect()
|
* Not all interfaces are supporting MAC address set and an error is not returned
|
||||||
* method will fail if MAC address is provided but not possible to use.
|
* for this method call. Verify the changed MAC address by analysing packet
|
||||||
|
* captures from the used network interface.
|
||||||
*
|
*
|
||||||
* 6-byte EUI-48 MAC addresses are used for Ethernet while Mesh interface is
|
* 6-byte EUI-48 MAC addresses are used for Ethernet while Mesh interface is
|
||||||
* using 8-byte EUI-64 address.
|
* using 8-byte EUI-64 address.
|
||||||
|
|
Loading…
Reference in New Issue