NSH Networking: Also add an option to let platform-specific logic select the MAC address.

This commit is contained in:
Gregory Nutt
2014-08-06 10:12:10 -06:00
parent 16b2090ca0
commit d4aa9e7b6d
3 changed files with 316 additions and 247 deletions

View File

@@ -108,23 +108,35 @@
int nsh_netinit(void)
{
struct in_addr addr;
struct in_addr addr;
#if defined(CONFIG_NSH_DHCPC)
FAR void *handle;
FAR void *handle;
#endif
#if (defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_NOMAC)) && !defined(CONFIG_NET_SLIP)
uint8_t mac[IFHWADDRLEN];
uint8_t mac[IFHWADDRLEN];
#endif
/* Many embedded network interfaces must have a software assigned MAC */
/* Many embedded network interfaces must have a software assigned MAC */
#if defined(CONFIG_NSH_NOMAC) && !defined(CONFIG_NET_SLIP)
#ifdef CONFIG_NSH_ARCHMAC
/* Let platform-specific logic assign the MAC address. */
(void)nsh_arch_macaddress(mac);
#else
/* Use the configured, fixed MAC address */
mac[0] = (CONFIG_NSH_MACADDR >> (8 * 5)) & 0xff;
mac[1] = (CONFIG_NSH_MACADDR >> (8 * 4)) & 0xff;
mac[2] = (CONFIG_NSH_MACADDR >> (8 * 3)) & 0xff;
mac[3] = (CONFIG_NSH_MACADDR >> (8 * 2)) & 0xff;
mac[4] = (CONFIG_NSH_MACADDR >> (8 * 1)) & 0xff;
mac[5] = (CONFIG_NSH_MACADDR >> (8 * 0)) & 0xff;
#endif
/* Set the MAC address */
netlib_setmacaddr(NET_DEVNAME, mac);
#endif