diff options
Diffstat (limited to 'apps/netutils')
-rw-r--r-- | apps/netutils/uiplib/uip_getifflag.c | 23 | ||||
-rw-r--r-- | apps/netutils/uiplib/uip_setifflag.c | 10 |
2 files changed, 13 insertions, 20 deletions
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 <gnutt@nuttx.org> * * 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 <gnutt@nuttx.org> * * 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; } |