Skip to content

Set MAC address at runtime in application #39252

Discussion options

You must be logged in to vote

The dev->data is the device driver private data, the driver can store the mac address in its context if needed, this is not really relevant to your question. Only way to set the MAC address in the driver so that the rest of the system knows about it is to use net_if_set_link_addr().

I just realized you actually wanted something different, from the application you can do it like this

	ret = net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, iface,
		       &params, sizeof(struct ethernet_req_params));

For example usage, see tests/net/ethernet_mgmt/src/main.c for details. Note that Ethernet driver needs to implement set_config API function and handle the MAC address setting in it, like how it …

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@VineetaNarkhede-eaton
Comment options

Comment options

You must be logged in to vote
1 reply
@VineetaNarkhede-eaton
Comment options

Answer selected by VineetaNarkhede-eaton
Comment options

You must be logged in to vote
4 replies
@jukkar
Comment options

jukkar Oct 13, 2021
Collaborator

@VineetaNarkhede-eaton
Comment options

@jukkar
Comment options

jukkar Oct 13, 2021
Collaborator

@VineetaNarkhede-eaton
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants