summaryrefslogtreecommitdiff
path: root/nuttx/net
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-15 14:21:11 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-15 14:21:11 -0600
commit9985a45d382240fb0cca302e5105de638783cbf5 (patch)
treec69dd84f992b39a7d6e36acd7606d482b288d2fc /nuttx/net
parentf04137c57b07fa2669d77e9fdc9746d5e61db6f9 (diff)
downloadnuttx-9985a45d382240fb0cca302e5105de638783cbf5.tar.gz
nuttx-9985a45d382240fb0cca302e5105de638783cbf5.tar.bz2
nuttx-9985a45d382240fb0cca302e5105de638783cbf5.zip
Network: netdev_register() must assign the device name appropriately according to the link layer type
Diffstat (limited to 'nuttx/net')
-rw-r--r--nuttx/net/netdev/netdev_register.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/nuttx/net/netdev/netdev_register.c b/nuttx/net/netdev/netdev_register.c
index dd3ab2c7d..9c8b95a11 100644
--- a/nuttx/net/netdev/netdev_register.c
+++ b/nuttx/net/netdev/netdev_register.c
@@ -60,10 +60,13 @@
* Pre-processor Definitions
****************************************************************************/
-#ifdef CONFIG_NET_SLIP
-# define NETDEV_FORMAT "sl%d"
-#else
-# define NETDEV_FORMAT "eth%d"
+#define NETDEV_SLIP_FORMAT "sl%d"
+#define NETDEV_ETH_FORMAT "eth%d"
+
+#if defined(CONFIG_NET_SLIP)
+# define NETDEV_DEFAULT_FORMAT NETDEV_SLIP_FORMAT
+#elif defined(CONFIG_NET_ETHERNET)
+# define NETDEV_DEFAULT_FORMAT NETDEV_ETH_FORMAT
#endif
/****************************************************************************
@@ -114,6 +117,7 @@ struct net_driver_s *g_netdevices = NULL;
int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
{
+ FAR const char *devfmt;
int devnum;
if (dev)
@@ -130,18 +134,21 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
#ifdef CONFIG_NET_ETHERNET
case NET_LL_ETHERNET: /* Ethernet */
dev->d_llhdrlen = ETH_HDRLEN;
+ devfmt = NETDEV_ETH_FORMAT;
break;
#endif
#ifdef CONFIG_NET_SLIP
case NET_LL_SLIP: /* Serial Line Internet Protocol (SLIP) */
dev->d_llhdrlen = 0;
+ devfmt = NETDEV_SLIP_FORMAT;
break;
#endif
#if 0 /* REVISIT: Not yet supported */
case NET_LL_PPP: /* Point-to-Point Protocol (PPP) */
dev->d_llhdrlen = 0;
+ devfmt = NETDEV_PPP_FORMAT;
break;
#endif
@@ -159,13 +166,18 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
/* Remember the verified link type */
dev->d_lltype = (uint8_t)lltype;
+
+#else
+ /* Use the default device name */
+
+ devfmt = NETDEV_DEFAULT_FORMAT;
#endif
/* Assign a device name to the interface */
netdev_semtake();
devnum = g_next_devnum++;
- snprintf(dev->d_ifname, IFNAMSIZ, NETDEV_FORMAT, devnum );
+ snprintf(dev->d_ifname, IFNAMSIZ, devfmt, devnum );
/* Add the device to the list of known network devices */