From 8388961f5ffae7cb5f2904b606d797d76c678257 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 21 Jan 2014 10:21:45 -0600 Subject: Networking: Improved status reporting and new carrier management interfaces. From Max Holtzberg --- apps/ChangeLog.txt | 3 + apps/include/netutils/uiplib.h | 44 +++++------ apps/netutils/uiplib/uip_getifflag.c | 23 ++---- apps/netutils/uiplib/uip_setifflag.c | 10 ++- apps/nshlib/nsh_netcmds.c | 25 +++++-- nuttx/ChangeLog | 3 + nuttx/drivers/net/encx24j600.c | 47 ++++++++---- nuttx/include/net/if.h | 7 +- nuttx/include/nuttx/net/uip/uip-arch.h | 29 ++++--- nuttx/net/Makefile | 3 +- nuttx/net/netdev_carrier.c | 133 +++++++++++++++++++++++++++++++++ nuttx/net/netdev_ioctl.c | 29 ++----- 12 files changed, 259 insertions(+), 97 deletions(-) create mode 100644 nuttx/net/netdev_carrier.c diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 0e2fe2d66..7583a09b9 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -804,3 +804,6 @@ immediately (2014-1-17). * apps/system/vi: Add support for a tiny, VI work-alike editor. This is still very much a work-in-progress on initial check-in (2014-1-20). + * apps/netutils/uiplib: Support new definitions and state passing for + network device status. From Maz Holtzberg (2014-1-21). + diff --git a/apps/include/netutils/uiplib.h b/apps/include/netutils/uiplib.h index 8e66fb970..9d13ed3ff 100644 --- a/apps/include/netutils/uiplib.h +++ b/apps/include/netutils/uiplib.h @@ -80,7 +80,8 @@ #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" -extern "C" { +extern "C" +{ #else #define EXTERN extern #endif @@ -101,44 +102,45 @@ extern "C" { * Return: Non-zero If the IP address was parsed. */ -EXTERN bool uiplib_ipaddrconv(const char *addrstr, uint8_t *addr); -EXTERN bool uiplib_hwmacconv(const char *hwstr, uint8_t *hw); +bool uiplib_ipaddrconv(FAR const char *addrstr, uint8_t *addr); +bool uiplib_hwmacconv(FAR const char *hwstr, uint8_t *hw); /* Get and set IP/MAC addresses (Ethernet L2 only) */ #ifdef CONFIG_NET_ETHERNET -EXTERN int uip_setmacaddr(const char *ifname, const uint8_t *macaddr); -EXTERN int uip_getmacaddr(const char *ifname, uint8_t *macaddr); +int uip_setmacaddr(FAR const char *ifname, const uint8_t *macaddr); +int uip_getmacaddr(FAR const char *ifname, uint8_t *macaddr); #endif /* IP address support */ #ifdef CONFIG_NET_IPv6 -EXTERN int uip_gethostaddr(const char *ifname, struct in6_addr *addr); -EXTERN int uip_sethostaddr(const char *ifname, const struct in6_addr *addr); -EXTERN int uip_setdraddr(const char *ifname, const struct in6_addr *addr); -EXTERN int uip_setnetmask(const char *ifname, const struct in6_addr *addr); +int uip_gethostaddr(FAR const char *ifname, struct in6_addr *addr); +int uip_sethostaddr(FAR const char *ifname, const struct in6_addr *addr); +int uip_setdraddr(FAR const char *ifname, const struct in6_addr *addr); +int uip_setnetmask(FAR const char *ifname, const struct in6_addr *addr); #else -EXTERN int uip_gethostaddr(const char *ifname, struct in_addr *addr); -EXTERN int uip_sethostaddr(const char *ifname, const struct in_addr *addr); -EXTERN int uip_setdraddr(const char *ifname, const struct in_addr *addr); -EXTERN int uip_setnetmask(const char *ifname, const struct in_addr *addr); +int uip_gethostaddr(FAR const char *ifname, struct in_addr *addr); +int uip_sethostaddr(FAR const char *ifname, const struct in_addr *addr); +int uip_setdraddr(FAR const char *ifname, const struct in_addr *addr); +int uip_setnetmask(FAR const char *ifname, const struct in_addr *addr); #endif /* HTTP support */ -EXTERN int uip_parsehttpurl(const char *url, uint16_t *port, - char *hostname, int hostlen, - char *filename, int namelen); +int uip_parsehttpurl(FAR const char *url, uint16_t *port, + FAR char *hostname, int hostlen, + FAR char *filename, int namelen); /* Generic server logic */ -EXTERN int uip_listenon(uint16_t portno); -EXTERN void uip_server(uint16_t portno, pthread_startroutine_t handler, int stacksize); +int uip_listenon(uint16_t portno); +void uip_server(uint16_t portno, pthread_startroutine_t handler, + int stacksize); -EXTERN int uip_getifstatus(const char *ifname, bool *status); -EXTERN int uip_ifup(const char *ifname); -EXTERN int uip_ifdown(const char *ifname); +int uip_getifstatus(FAR const char *ifname, FAR uint8_t *flags); +int uip_ifup(FAR const char *ifname); +int uip_ifdown(FAR const char *ifname); #undef EXTERN #ifdef __cplusplus diff --git a/apps/netutils/uiplib/uip_getifflag.c b/apps/netutils/uiplib/uip_getifflag.c index 8574d331a..0f292e4a1 100644 --- a/apps/netutils/uiplib/uip_getifflag.c +++ b/apps/netutils/uiplib/uip_getifflag.c @@ -1,7 +1,7 @@ /**************************************************************************** * netutils/uiplib/uip_getifflag.c * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -65,14 +65,14 @@ * * Parameters: * ifname The name of the interface to use - * status interface flag ifup or ifdown status + * flags The interface flags returned by SIOCGIFFLAGS * * Return: * 0 on sucess; -1 on failure * ****************************************************************************/ -int uip_getifstatus(const char *ifname, bool *status) +int uip_getifstatus(const char *ifname, uint8_t *flags) { int ret = ERROR; if (ifname) @@ -94,24 +94,13 @@ int uip_getifstatus(const char *ifname, bool *status) ret = ioctl(sockfd, SIOCGIFFLAGS, (unsigned long)&req); if (!ret) { - /* Return the ifup or ifdown status */ - - if ((req.ifr_flags & IF_FLAG_IFUP) == (req.ifr_flags & IF_FLAG_IFDOWN)) - { - ret = ERROR; - } - else if(req.ifr_flags & IF_FLAG_IFUP) - { - *status = true; - } - else - { - *status = false; - } + *flags = req.ifr_flags; } + close(sockfd); } } + return ret; } diff --git a/apps/netutils/uiplib/uip_setifflag.c b/apps/netutils/uiplib/uip_setifflag.c index 317ddcce1..f18ad00e4 100644 --- a/apps/netutils/uiplib/uip_setifflag.c +++ b/apps/netutils/uiplib/uip_setifflag.c @@ -1,7 +1,7 @@ /**************************************************************************** * netutils/uiplib/uip_setifflag.c * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -88,12 +88,14 @@ int uip_ifup(const char *ifname) strncpy(req.ifr_name, ifname, IFNAMSIZ); /* Perform the ioctl to ifup flag */ - req.ifr_flags |= IF_FLAG_IFUP; + + req.ifr_flags |= IFF_UP; ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req); close(sockfd); } } + return ret; } @@ -129,12 +131,14 @@ int uip_ifdown(const char *ifname) strncpy(req.ifr_name, ifname, IFNAMSIZ); /* Perform the ioctl to ifup flag */ - req.ifr_flags |= IF_FLAG_IFDOWN; + + req.ifr_flags |= IFF_DOWN; ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req); close(sockfd); } } + return ret; } diff --git a/apps/nshlib/nsh_netcmds.c b/apps/nshlib/nsh_netcmds.c index 5c76aca0e..024fb248e 100644 --- a/apps/nshlib/nsh_netcmds.c +++ b/apps/nshlib/nsh_netcmds.c @@ -54,6 +54,7 @@ #include #include +#include #include #include @@ -225,9 +226,9 @@ static inline void uip_statistics(FAR struct nsh_vtbl_s *vtbl) nsh_output(vtbl, "\n"); #ifdef CONFIG_NET_TCP - nsh_output(vtbl, " TCP ACK: %04x SYN: %04x\n", + nsh_output(vtbl, " TCP ACK: %04x SYN: %04x\n", uip_stat.tcp.ackerr, uip_stat.tcp.syndrop); - nsh_output(vtbl, " RST: %04x %04x\n", + nsh_output(vtbl, " RST: %04x %04x\n", uip_stat.tcp.rst, uip_stat.tcp.synrst); #endif @@ -282,18 +283,32 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg) { struct nsh_vtbl_s *vtbl = (struct nsh_vtbl_s*)arg; struct in_addr addr; - bool is_running = false; + uint8_t iff; + const char *status; int ret; - ret = uip_getifstatus(dev->d_ifname,&is_running); + ret = uip_getifstatus(dev->d_ifname, &iff); if (ret != OK) { nsh_output(vtbl, "\tGet %s interface flags error: %d\n", dev->d_ifname, ret); } + if (iff & IFF_RUNNING) + { + status = "RUNNING"; + } + else if (iff & IFF_UP) + { + status = "UP"; + } + else + { + status = "DOWN"; + } + nsh_output(vtbl, "%s\tHWaddr %s at %s\n", - dev->d_ifname, ether_ntoa(&dev->d_mac), (is_running)?"UP":"DOWN"); + dev->d_ifname, ether_ntoa(&dev->d_mac), status); addr.s_addr = dev->d_ipaddr; nsh_output(vtbl, "\tIPaddr:%s ", inet_ntoa(addr)); diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index c6e19b7ac..650e3d8d1 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -6489,4 +6489,7 @@ getopt() make like the optind variable in an undefined state (2014-1-20). * configs/olimex-stm32-p107: Failes to build is SPI3 for UEXT is not remapped. From Max Holtzberg (2014-1-21). + * Several network related files: Changes from Max Holtzberg to improve + how network status is reported. New controls to manage carrier + detect. (2014-1-21). diff --git a/nuttx/drivers/net/encx24j600.c b/nuttx/drivers/net/encx24j600.c index e8c4a1df2..548340e97 100644 --- a/nuttx/drivers/net/encx24j600.c +++ b/nuttx/drivers/net/encx24j600.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/net/encx24j600.c * - * Copyright (C) 2013 UVC Ingenieure. All rights reserved. + * Copyright (C) 2013-1014 UVC Ingenieure. All rights reserved. * Author: Max Holtzberg * * References: @@ -208,7 +208,8 @@ enum enc_state_e { ENCSTATE_UNINIT = 0, /* The interface is in an uninitialized state */ ENCSTATE_DOWN, /* The interface is down */ - ENCSTATE_UP /* The interface is up */ + ENCSTATE_UP, /* The interface is up */ + ENCSTATE_RUNNING /* The interface is has a cable plugged in and is ready to use */ }; struct enc_descr_s @@ -1241,8 +1242,6 @@ static void enc_linkstatus(FAR struct enc_driver_s *priv) { uint16_t regval; - nllvdbg("link status changed\n"); - /* Before transmitting the first packet after link establishment or * auto-negotiation, the MAC duplex configuration must be manually set to * match the duplex configuration of the PHY. To do this, configure @@ -1251,19 +1250,30 @@ static void enc_linkstatus(FAR struct enc_driver_s *priv) regval = enc_rdreg(priv, ENC_ESTAT); - if (regval & ESTAT_PHYDPX) + if (regval & ESTAT_PHYLNK) { - /* Configure full-duplex */ + if (regval & ESTAT_PHYDPX) + { + /* Configure full-duplex */ + + enc_wrreg(priv, ENC_MABBIPG, 0x15); + enc_bfs(priv, ENC_MACON2, MACON2_FULDPX); + } + else + { + /* Configure half-duplex */ + + enc_wrreg(priv, ENC_MABBIPG, 0x12); + enc_bfc(priv, ENC_MACON2, MACON2_FULDPX); + } - enc_wrreg(priv, ENC_MABBIPG, 0x15); - enc_bfs(priv, ENC_MACON2, MACON2_FULDPX); + netdev_carrier_on(&priv->dev); + priv->ifstate = ENCSTATE_RUNNING; } else { - /* Configure half-duplex */ - - enc_wrreg(priv, ENC_MABBIPG, 0x12); - enc_bfc(priv, ENC_MACON2, MACON2_FULDPX); + netdev_carrier_off(&priv->dev); + priv->ifstate = ENCSTATE_UP; } } @@ -2175,10 +2185,7 @@ static int enc_ifup(struct uip_driver_s *dev) ret = enc_reset(priv); if (ret == OK) { - enc_setmacaddr(priv); - /* enc_pwrfull(priv); */ - /* Enable interrupts at the ENCX24J600. Interrupts are still disabled * at the interrupt controller. @@ -2302,7 +2309,7 @@ static int enc_txavail(struct uip_driver_s *dev) /* Ignore the notification if the interface is not yet up */ flags = irqsave(); - if (priv->ifstate == ENCSTATE_UP) + if (priv->ifstate == ENCSTATE_RUNNING) { /* Check if the hardware is ready to send another packet. The driver * starts a transmission process by setting ECON1.TXRTS. When the packet is @@ -2735,11 +2742,19 @@ static int enc_reset(FAR struct enc_driver_s *priv) enc_wrreg(priv, ENC_MAMXFL, CONFIG_NET_BUFSIZE + 4); ret = enc_waitreg(priv, ENC_ESTAT, ESTAT_PHYLNK, ESTAT_PHYLNK); + + if (ret == OK) + { + enc_linkstatus(priv); + } + +#if 0 if (ret != OK) { nlldbg("ERROR: encx24j600 failed to establish link\n"); return -ENODEV; } +#endif return OK; } diff --git a/nuttx/include/net/if.h b/nuttx/include/net/if.h index 1ff8ebc38..9c1f2a551 100644 --- a/nuttx/include/net/if.h +++ b/nuttx/include/net/if.h @@ -52,9 +52,10 @@ #define IF_NAMESIZE 6 /* Newer naming standard */ #define IFHWADDRLEN 6 -#define IFF_RUNNING (1 << 0) -#define IF_FLAG_IFUP (1 << 0) -#define IF_FLAG_IFDOWN (2 << 0) +#define IFF_DOWN (1 << 0) +#define IFF_UP (1 << 1) +#define IFF_RUNNING (1 << 2) + /******************************************************************************************* * Public Type Definitions diff --git a/nuttx/include/nuttx/net/uip/uip-arch.h b/nuttx/include/nuttx/net/uip/uip-arch.h index 7704a7f34..65c86db27 100644 --- a/nuttx/include/nuttx/net/uip/uip-arch.h +++ b/nuttx/include/nuttx/net/uip/uip-arch.h @@ -252,7 +252,7 @@ struct uip_driver_s * } */ -extern int uip_input(struct uip_driver_s *dev); +int uip_input(struct uip_driver_s *dev); /* Polling of connections * @@ -305,8 +305,19 @@ extern int uip_input(struct uip_driver_s *dev); */ typedef int (*uip_poll_callback_t)(struct uip_driver_s *dev); -extern int uip_poll(struct uip_driver_s *dev, uip_poll_callback_t callback); -extern int uip_timer(struct uip_driver_s *dev, uip_poll_callback_t callback, int hsec); +int uip_poll(struct uip_driver_s *dev, uip_poll_callback_t callback); +int uip_timer(struct uip_driver_s *dev, uip_poll_callback_t callback, int hsec); + +/* Carrier detection + * Call netdev_carrier_on when the carrier has become available and the device + * is ready to receive/transmit packets. + * + * Call detdev_carrier_off when the carrier disappeared and the device has moved + * into non operational state. + */ + +int netdev_carrier_on(FAR struct uip_driver_s *dev); +int netdev_carrier_off(FAR struct uip_driver_s *dev); /* By defining UIP_ARCH_CHKSUM, the architecture can replace up_incr32 * with hardware assisted solutions. @@ -321,7 +332,7 @@ extern int uip_timer(struct uip_driver_s *dev, uip_poll_callback_t callback, int * op16 - A 16-bit integer in host byte order. */ -extern void uip_incr32(uint8_t *op32, uint16_t op16); +void uip_incr32(uint8_t *op32, uint16_t op16); /* Calculate the Internet checksum over a buffer. * @@ -342,7 +353,7 @@ extern void uip_incr32(uint8_t *op32, uint16_t op16); * Return: The Internet checksum of the buffer. */ -extern uint16_t uip_chksum(uint16_t *buf, uint16_t len); +uint16_t uip_chksum(uint16_t *buf, uint16_t len); /* Calculate the IP header checksum of the packet header in d_buf. * @@ -353,7 +364,7 @@ extern uint16_t uip_chksum(uint16_t *buf, uint16_t len); * buffer. */ -extern uint16_t uip_ipchksum(struct uip_driver_s *dev); +uint16_t uip_ipchksum(struct uip_driver_s *dev); /* Calculate the TCP checksum of the packet in d_buf and d_appdata. * @@ -368,10 +379,10 @@ extern uint16_t uip_ipchksum(struct uip_driver_s *dev); * to by d_appdata. */ -extern uint16_t uip_tcpchksum(struct uip_driver_s *dev); +uint16_t uip_tcpchksum(struct uip_driver_s *dev); -extern uint16_t uip_udpchksum(struct uip_driver_s *dev); -extern uint16_t uip_icmpchksum(struct uip_driver_s *dev, int len); +uint16_t uip_udpchksum(struct uip_driver_s *dev); +uint16_t uip_icmpchksum(struct uip_driver_s *dev, int len); #endif /* __INCLUDE_NUTTX_NET_UIP_UIP_ARCH_H */ diff --git a/nuttx/net/Makefile b/nuttx/net/Makefile index fe2d35624..7c92bb21a 100644 --- a/nuttx/net/Makefile +++ b/nuttx/net/Makefile @@ -92,7 +92,8 @@ endif NETDEV_ASRCS = NETDEV_CSRCS = netdev_register.c netdev_ioctl.c net_poll.c netdev_txnotify.c \ netdev_findbyname.c netdev_findbyaddr.c netdev_count.c \ - netdev_foreach.c netdev_unregister.c netdev_sem.c + netdev_foreach.c netdev_unregister.c netdev_sem.c \ + netdev_carrier.c ifeq ($(CONFIG_NET_RXAVAIL),y) NETDEV_CSRCS += netdev_rxnotify.c diff --git a/nuttx/net/netdev_carrier.c b/nuttx/net/netdev_carrier.c new file mode 100644 index 000000000..b32c1d666 --- /dev/null +++ b/nuttx/net/netdev_carrier.c @@ -0,0 +1,133 @@ +/**************************************************************************** + * net/netdev_carrier.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Max Holtzberg + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0 + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "net_internal.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Global Functions + ****************************************************************************/ + +/**************************************************************************** + * Function: netdev_carrier_on + * + * Description: + * Notifies the uip layer about an available carrier. + * (e.g. a cable was plugged in) + * + * Parameters: + * dev - The device driver structure + * + * Returned Value: + * 0:Success; negated errno on failure + * + ****************************************************************************/ + +int netdev_carrier_on(FAR struct uip_driver_s *dev) +{ + if (dev) + { + dev->d_flags |= IFF_RUNNING; + return OK; + } + + return -EINVAL; +} + +/**************************************************************************** + * Function: netdev_carrier_off + * + * Description: + * Notifies the uip layer about an disappeared carrier. + * (e.g. a cable was unplugged) + * + * Parameters: + * dev - The device driver structure + * + * Returned Value: + * 0:Success; negated errno on failure + * + ****************************************************************************/ + +int netdev_carrier_off(FAR struct uip_driver_s *dev) +{ + if (dev) + { + dev->d_flags &= ~IFF_RUNNING; + return OK; + } + + return -EINVAL; +} + +#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/nuttx/net/netdev_ioctl.c b/nuttx/net/netdev_ioctl.c index ff94ed5c2..a8394edb2 100644 --- a/nuttx/net/netdev_ioctl.c +++ b/nuttx/net/netdev_ioctl.c @@ -150,7 +150,7 @@ static void ioctl_ifup(FAR struct uip_driver_s *dev) { /* Is the interface already up? */ - if ((dev->d_flags & IFF_RUNNING) == 0) + if ((dev->d_flags & IFF_UP) == 0) { /* No, bring the interface up now */ @@ -158,7 +158,7 @@ static void ioctl_ifup(FAR struct uip_driver_s *dev) { /* Mark the interface as up */ - dev->d_flags |= IFF_RUNNING; + dev->d_flags |= IFF_UP; } } } @@ -172,7 +172,7 @@ static void ioctl_ifdown(FAR struct uip_driver_s *dev) { /* Is the interface already down? */ - if ((dev->d_flags & IFF_RUNNING) != 0) + if ((dev->d_flags & IFF_UP) != 0) { /* No, take the interface down now */ @@ -180,7 +180,7 @@ static void ioctl_ifdown(FAR struct uip_driver_s *dev) { /* Mark the interface as down */ - dev->d_flags &= ~IFF_RUNNING; + dev->d_flags &= ~IFF_UP; } } } @@ -326,7 +326,7 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd, dev = netdev_ifrdev(req); if (dev) { - if (req->ifr_flags & IF_FLAG_IFUP) + if (req->ifr_flags & IFF_UP) { /* Yes.. bring the interface up */ @@ -335,7 +335,7 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd, /* Is this a request to take the interface down? */ - else if (req->ifr_flags & IF_FLAG_IFDOWN) + else if (req->ifr_flags & IFF_DOWN) { /* Yes.. take the interface down */ @@ -352,22 +352,7 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd, dev = netdev_ifrdev(req); if (dev) { - req->ifr_flags = 0; - - /* Is the interface running? */ - - if (dev->d_flags & IFF_RUNNING) - { - /* Yes.. report interface up */ - - req->ifr_flags |= IF_FLAG_IFUP; - } - else - { - /* No.. report interface down */ - - req->ifr_flags |= IF_FLAG_IFDOWN; - } + req->ifr_flags = dev->d_flags; } ret = OK; -- cgit v1.2.3