diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-08-06 10:12:10 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-08-06 10:12:10 -0600 |
commit | b31b8ea5db6e7b42eee4195b7f2811b9d9a87396 (patch) | |
tree | 7dfb1c7d434075dc97996d6a3be6052582b554e0 /apps/nshlib/nsh_netinit.c | |
parent | 5b6529f173e35f3c15438869ea33dbf80d3be036 (diff) | |
download | px4-nuttx-b31b8ea5db6e7b42eee4195b7f2811b9d9a87396.tar.gz px4-nuttx-b31b8ea5db6e7b42eee4195b7f2811b9d9a87396.tar.bz2 px4-nuttx-b31b8ea5db6e7b42eee4195b7f2811b9d9a87396.zip |
NSH Networking: Also add an option to let platform-specific logic select the MAC address.
Diffstat (limited to 'apps/nshlib/nsh_netinit.c')
-rw-r--r-- | apps/nshlib/nsh_netinit.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/nshlib/nsh_netinit.c b/apps/nshlib/nsh_netinit.c index d3340a0fc..c4e83d7e6 100644 --- a/apps/nshlib/nsh_netinit.c +++ b/apps/nshlib/nsh_netinit.c @@ -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 |