From d559bea3ebb08291f2312551bfb43c91ba03c18c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 2 Jul 2014 16:52:02 -0600 Subject: NET: Rename functions in apps/netutils/netlib to begin with netlib_ vs uip_ --- apps/netutils/netlib/Makefile | 2 +- apps/netutils/netlib/netlib_gethostaddr.c | 8 +- apps/netutils/netlib/netlib_getifflag.c | 107 --------------------- apps/netutils/netlib/netlib_getifstatus.c | 107 +++++++++++++++++++++ apps/netutils/netlib/netlib_getmacaddr.c | 6 +- apps/netutils/netlib/netlib_ipmsfilter.c | 2 +- apps/netutils/netlib/netlib_listenon.c | 6 +- apps/netutils/netlib/netlib_parsehttpurl.c | 6 +- apps/netutils/netlib/netlib_server.c | 8 +- apps/netutils/netlib/netlib_setdraddr.c | 8 +- apps/netutils/netlib/netlib_sethostaddr.c | 8 +- apps/netutils/netlib/netlib_setifflag.c | 145 ----------------------------- apps/netutils/netlib/netlib_setifstatus.c | 145 +++++++++++++++++++++++++++++ apps/netutils/netlib/netlib_setmacaddr.c | 6 +- apps/netutils/netlib/netlib_setnetmask.c | 8 +- 15 files changed, 286 insertions(+), 286 deletions(-) delete mode 100644 apps/netutils/netlib/netlib_getifflag.c create mode 100644 apps/netutils/netlib/netlib_getifstatus.c delete mode 100644 apps/netutils/netlib/netlib_setifflag.c create mode 100644 apps/netutils/netlib/netlib_setifstatus.c (limited to 'apps/netutils/netlib') diff --git a/apps/netutils/netlib/Makefile b/apps/netutils/netlib/Makefile index b42607134..7eb376646 100644 --- a/apps/netutils/netlib/Makefile +++ b/apps/netutils/netlib/Makefile @@ -42,7 +42,7 @@ include $(APPDIR)/Make.defs ASRCS = CSRCS = netlib.c netlib_sethostaddr.c netlib_gethostaddr.c CSRCS += netlib_setdraddr.c netlib_setnetmask.c netlib_parsehttpurl.c -CSRCS += netlib_setifflag.c netlib_getifflag.c +CSRCS += netlib_setifstatus.c netlib_getifstatus.c # These require TCP support diff --git a/apps/netutils/netlib/netlib_gethostaddr.c b/apps/netutils/netlib/netlib_gethostaddr.c index e354ca9de..b772b1ee4 100644 --- a/apps/netutils/netlib/netlib_gethostaddr.c +++ b/apps/netutils/netlib/netlib_gethostaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_gethostaddr.c + * netutils/netlib/netlib_gethostaddr.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -61,7 +61,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: uip_gethostaddr + * Name: netlib_gethostaddr * * Description: * Get the network driver IP address @@ -76,9 +76,9 @@ ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -int uip_gethostaddr(const char *ifname, struct in6_addr *addr) +int netlib_gethostaddr(const char *ifname, struct in6_addr *addr) #else -int uip_gethostaddr(const char *ifname, struct in_addr *addr) +int netlib_gethostaddr(const char *ifname, struct in_addr *addr) #endif { int ret = ERROR; diff --git a/apps/netutils/netlib/netlib_getifflag.c b/apps/netutils/netlib/netlib_getifflag.c deleted file mode 100644 index 8e82afe03..000000000 --- a/apps/netutils/netlib/netlib_getifflag.c +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** - * netutils/netlib/uip_getifflag.c - * - * 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 - * 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 - -/**************************************************************************** - * Global Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: uip_getifstatus - * - * Description: - * Get the network driver ifup/ifdown status - * - * Parameters: - * ifname The name of the interface to use - * flags The interface flags returned by SIOCGIFFLAGS - * - * Return: - * 0 on sucess; -1 on failure - * - ****************************************************************************/ - -int uip_getifstatus(FAR const char *ifname, FAR uint8_t *flags) -{ - int ret = ERROR; - if (ifname) - { - /* Get a socket (only so that we get access to the INET subsystem) */ - - int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0); - if (sockfd >= 0) - { - struct ifreq req; - memset (&req, 0, sizeof(struct ifreq)); - - /* Put the driver name into the request */ - - strncpy(req.ifr_name, ifname, IFNAMSIZ); - - /* Perform the ioctl to ifup or ifdown status */ - - ret = ioctl(sockfd, SIOCGIFFLAGS, (unsigned long)&req); - if (!ret) - { - *flags = req.ifr_flags; - } - - close(sockfd); - } - } - - return ret; -} - -#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/apps/netutils/netlib/netlib_getifstatus.c b/apps/netutils/netlib/netlib_getifstatus.c new file mode 100644 index 000000000..ae0c760fc --- /dev/null +++ b/apps/netutils/netlib/netlib_getifstatus.c @@ -0,0 +1,107 @@ +/**************************************************************************** + * netutils/netlib/netlib_getifflag.c + * + * 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 + * 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 + +/**************************************************************************** + * Global Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: netlib_getifstatus + * + * Description: + * Get the network driver ifup/ifdown status + * + * Parameters: + * ifname The name of the interface to use + * flags The interface flags returned by SIOCGIFFLAGS + * + * Return: + * 0 on sucess; -1 on failure + * + ****************************************************************************/ + +int netlib_getifstatus(FAR const char *ifname, FAR uint8_t *flags) +{ + int ret = ERROR; + if (ifname) + { + /* Get a socket (only so that we get access to the INET subsystem) */ + + int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0); + if (sockfd >= 0) + { + struct ifreq req; + memset (&req, 0, sizeof(struct ifreq)); + + /* Put the driver name into the request */ + + strncpy(req.ifr_name, ifname, IFNAMSIZ); + + /* Perform the ioctl to ifup or ifdown status */ + + ret = ioctl(sockfd, SIOCGIFFLAGS, (unsigned long)&req); + if (!ret) + { + *flags = req.ifr_flags; + } + + close(sockfd); + } + } + + return ret; +} + +#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/apps/netutils/netlib/netlib_getmacaddr.c b/apps/netutils/netlib/netlib_getmacaddr.c index 8923f4bb1..da0e64e6d 100644 --- a/apps/netutils/netlib/netlib_getmacaddr.c +++ b/apps/netutils/netlib/netlib_getmacaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_getmacaddr.c + * netutils/netlib/netlib_getmacaddr.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -57,7 +57,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: uip_getmacaddr + * Name: netlib_getmacaddr * * Description: * Get the network driver IP address @@ -71,7 +71,7 @@ * ****************************************************************************/ -int uip_getmacaddr(const char *ifname, uint8_t *macaddr) +int netlib_getmacaddr(const char *ifname, uint8_t *macaddr) { int ret = ERROR; if (ifname && macaddr) diff --git a/apps/netutils/netlib/netlib_ipmsfilter.c b/apps/netutils/netlib/netlib_ipmsfilter.c index 1068d0804..a5fc96398 100644 --- a/apps/netutils/netlib/netlib_ipmsfilter.c +++ b/apps/netutils/netlib/netlib_ipmsfilter.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_setmultiaddr.c + * netutils/netlib/netlib_setipmsfilter.c * * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/apps/netutils/netlib/netlib_listenon.c b/apps/netutils/netlib/netlib_listenon.c index cacea174b..5037632d4 100644 --- a/apps/netutils/netlib/netlib_listenon.c +++ b/apps/netutils/netlib/netlib_listenon.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_listenon.c + * netutils/netlib/netlib_listenon.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -59,7 +59,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: uip_listenon + * Name: netlib_listenon * * Description: * Implement basic server listening @@ -72,7 +72,7 @@ * ****************************************************************************/ -int uip_listenon(uint16_t portno) +int netlib_listenon(uint16_t portno) { struct sockaddr_in myaddr; int listensd; diff --git a/apps/netutils/netlib/netlib_parsehttpurl.c b/apps/netutils/netlib/netlib_parsehttpurl.c index efc88956a..a4d4c7051 100644 --- a/apps/netutils/netlib/netlib_parsehttpurl.c +++ b/apps/netutils/netlib/netlib_parsehttpurl.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_parsehttpurl.c + * netutils/netlib/netlib_parsehttpurl.c * * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -57,10 +57,10 @@ const char g_http[] = "http://"; *****************************************************************************/ /**************************************************************************** - * Name: uip_parsehttpurl + * Name: netlib_parsehttpurl ****************************************************************************/ -int uip_parsehttpurl(const char *url, uint16_t *port, +int netlib_parsehttpurl(const char *url, uint16_t *port, char *hostname, int hostlen, char *filename, int namelen) { diff --git a/apps/netutils/netlib/netlib_server.c b/apps/netutils/netlib/netlib_server.c index c6b3d1631..d2c9ee3e9 100644 --- a/apps/netutils/netlib/netlib_server.c +++ b/apps/netutils/netlib/netlib_server.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_server.c + * netutils/netlib/netlib_server.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -62,7 +62,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: uip_server + * Name: netlib_server * * Description: * Implement basic server logic @@ -78,7 +78,7 @@ * ****************************************************************************/ -void uip_server(uint16_t portno, pthread_startroutine_t handler, int stacksize) +void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksize) { struct sockaddr_in myaddr; #ifdef CONFIG_NET_HAVE_SOLINGER @@ -93,7 +93,7 @@ void uip_server(uint16_t portno, pthread_startroutine_t handler, int stacksize) /* Create a new TCP socket to use to listen for connections */ - listensd = uip_listenon(portno); + listensd = netlib_listenon(portno); if (listensd < 0) { return; diff --git a/apps/netutils/netlib/netlib_setdraddr.c b/apps/netutils/netlib/netlib_setdraddr.c index bdc19d624..a0b3d77c3 100644 --- a/apps/netutils/netlib/netlib_setdraddr.c +++ b/apps/netutils/netlib/netlib_setdraddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_setdraddr.c + * netutils/netlib/netlib_setdraddr.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -57,7 +57,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: uip_setdraddr + * Name: netlib_setdraddr * * Description: * Set the default router IP address @@ -72,9 +72,9 @@ ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -int uip_setdraddr(const char *ifname, const struct in6_addr *addr) +int netlib_setdraddr(const char *ifname, const struct in6_addr *addr) #else -int uip_setdraddr(const char *ifname, const struct in_addr *addr) +int netlib_setdraddr(const char *ifname, const struct in_addr *addr) #endif { int ret = ERROR; diff --git a/apps/netutils/netlib/netlib_sethostaddr.c b/apps/netutils/netlib/netlib_sethostaddr.c index ada4431f5..a0f76cb27 100644 --- a/apps/netutils/netlib/netlib_sethostaddr.c +++ b/apps/netutils/netlib/netlib_sethostaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_sethostaddr.c + * netutils/netlib/netlib_sethostaddr.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -57,7 +57,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: uip_sethostaddr + * Name: netlib_sethostaddr * * Description: * Set the network driver IP address @@ -72,9 +72,9 @@ ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -int uip_sethostaddr(const char *ifname, const struct in6_addr *addr) +int netlib_sethostaddr(const char *ifname, const struct in6_addr *addr) #else -int uip_sethostaddr(const char *ifname, const struct in_addr *addr) +int netlib_sethostaddr(const char *ifname, const struct in_addr *addr) #endif { int ret = ERROR; diff --git a/apps/netutils/netlib/netlib_setifflag.c b/apps/netutils/netlib/netlib_setifflag.c deleted file mode 100644 index c7a6dfb73..000000000 --- a/apps/netutils/netlib/netlib_setifflag.c +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** - * netutils/netlib/uip_setifflag.c - * - * 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 - * 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 - -/**************************************************************************** - * Global Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: uip_ifup - * - * Description: - * Set the network interface UP - * - * Parameters: - * ifname The name of the interface to use - * - * Return: - * 0 on sucess; -1 on failure - * - ****************************************************************************/ - -int uip_ifup(const char *ifname) -{ - int ret = ERROR; - if (ifname) - { - /* Get a socket (only so that we get access to the INET subsystem) */ - - int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0); - if (sockfd >= 0) - { - struct ifreq req; - memset (&req, 0, sizeof(struct ifreq)); - - /* Put the driver name into the request */ - - strncpy(req.ifr_name, ifname, IFNAMSIZ); - - /* Perform the ioctl to ifup flag */ - - req.ifr_flags |= IFF_UP; - - ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req); - close(sockfd); - } - } - - return ret; -} - -/**************************************************************************** - * Name: uip_ifdown - * - * Description: - * Set the network interface DOWN - * - * Parameters: - * ifname The name of the interface to use - * - * Return: - * 0 on sucess; -1 on failure - * - ****************************************************************************/ - -int uip_ifdown(const char *ifname) -{ - int ret = ERROR; - if (ifname) - { - /* Get a socket (only so that we get access to the INET subsystem) */ - - int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0); - if (sockfd >= 0) - { - struct ifreq req; - memset (&req, 0, sizeof(struct ifreq)); - - /* Put the driver name into the request */ - - strncpy(req.ifr_name, ifname, IFNAMSIZ); - - /* Perform the ioctl to ifup flag */ - - req.ifr_flags |= IFF_DOWN; - - ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req); - close(sockfd); - } - } - - return ret; -} - -#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/apps/netutils/netlib/netlib_setifstatus.c b/apps/netutils/netlib/netlib_setifstatus.c new file mode 100644 index 000000000..e20f2240b --- /dev/null +++ b/apps/netutils/netlib/netlib_setifstatus.c @@ -0,0 +1,145 @@ +/**************************************************************************** + * netutils/netlib/netlib_setifstatus.c + * + * 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 + * 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 + +/**************************************************************************** + * Global Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: netlib_ifup + * + * Description: + * Set the network interface UP + * + * Parameters: + * ifname The name of the interface to use + * + * Return: + * 0 on sucess; -1 on failure + * + ****************************************************************************/ + +int netlib_ifup(const char *ifname) +{ + int ret = ERROR; + if (ifname) + { + /* Get a socket (only so that we get access to the INET subsystem) */ + + int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0); + if (sockfd >= 0) + { + struct ifreq req; + memset (&req, 0, sizeof(struct ifreq)); + + /* Put the driver name into the request */ + + strncpy(req.ifr_name, ifname, IFNAMSIZ); + + /* Perform the ioctl to ifup flag */ + + req.ifr_flags |= IFF_UP; + + ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req); + close(sockfd); + } + } + + return ret; +} + +/**************************************************************************** + * Name: netlib_ifdown + * + * Description: + * Set the network interface DOWN + * + * Parameters: + * ifname The name of the interface to use + * + * Return: + * 0 on sucess; -1 on failure + * + ****************************************************************************/ + +int netlib_ifdown(const char *ifname) +{ + int ret = ERROR; + if (ifname) + { + /* Get a socket (only so that we get access to the INET subsystem) */ + + int sockfd = socket(PF_INET, NETLIB_SOCK_IOCTL, 0); + if (sockfd >= 0) + { + struct ifreq req; + memset (&req, 0, sizeof(struct ifreq)); + + /* Put the driver name into the request */ + + strncpy(req.ifr_name, ifname, IFNAMSIZ); + + /* Perform the ioctl to ifup flag */ + + req.ifr_flags |= IFF_DOWN; + + ret = ioctl(sockfd, SIOCSIFFLAGS, (unsigned long)&req); + close(sockfd); + } + } + + return ret; +} + +#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/apps/netutils/netlib/netlib_setmacaddr.c b/apps/netutils/netlib/netlib_setmacaddr.c index d35034a69..47fb463a3 100644 --- a/apps/netutils/netlib/netlib_setmacaddr.c +++ b/apps/netutils/netlib/netlib_setmacaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_setmacaddr.c + * netutils/netlib/netlib_setmacaddr.c * * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -67,7 +67,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: uip_setmacaddr + * Name: netlib_setmacaddr * * Description: * Set the network driver MAC address @@ -81,7 +81,7 @@ * ****************************************************************************/ -int uip_setmacaddr(const char *ifname, const uint8_t *macaddr) +int netlib_setmacaddr(const char *ifname, const uint8_t *macaddr) { int ret = ERROR; diff --git a/apps/netutils/netlib/netlib_setnetmask.c b/apps/netutils/netlib/netlib_setnetmask.c index 8b3f9651c..45d4dee25 100644 --- a/apps/netutils/netlib/netlib_setnetmask.c +++ b/apps/netutils/netlib/netlib_setnetmask.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/uip_setnetmask.c + * netutils/netlib/netlib_setnetmask.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -56,7 +56,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: uip_setnetmask + * Name: netlib_setnetmask * * Description: * Set the netmask @@ -71,9 +71,9 @@ ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -int uip_setnetmask(const char *ifname, const struct in6_addr *addr) +int netlib_setnetmask(const char *ifname, const struct in6_addr *addr) #else -int uip_setnetmask(const char *ifname, const struct in_addr *addr) +int netlib_setnetmask(const char *ifname, const struct in_addr *addr) #endif { int ret = ERROR; -- cgit v1.2.3