mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
Correct some issues with IP/MAC address handling
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@355 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
|
||||
#include <net/uip/uip.h>
|
||||
#include <net/uip/dhcpc.h>
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
@@ -192,7 +193,7 @@ static void create_msg(struct dhcpc_state_internal *pdhcpc, struct dhcp_msg *pms
|
||||
pmsg->secs = 0;
|
||||
pmsg->flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */
|
||||
|
||||
uip_gethostaddr( "eth0", &addr);
|
||||
uip_gethostaddr("eth0", &addr);
|
||||
memcpy(&pmsg->ciaddr, &addr.s_addr, sizeof(pmsg->ciaddr));
|
||||
memset(pmsg->yiaddr, 0, sizeof(pmsg->yiaddr));
|
||||
memset(pmsg->siaddr, 0, sizeof(pmsg->siaddr));
|
||||
|
||||
@@ -34,4 +34,5 @@
|
||||
############################################################################
|
||||
|
||||
UIPLIB_ASRCS =
|
||||
UIPLIB_CSRCS = uiplib.c uip-sethostaddr.c uip-gethostaddr.c uip-setdraddr.c uip-setnetmask.c
|
||||
UIPLIB_CSRCS = uiplib.c uip-setmacaddr.c uip-getmacaddr.c uip-sethostaddr.c \
|
||||
uip-gethostaddr.c uip-setdraddr.c uip-setnetmask.c
|
||||
|
||||
@@ -47,19 +47,25 @@
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uip_sethostaddr
|
||||
* Name: uip_gethostaddr
|
||||
*
|
||||
* Description:
|
||||
* Get the network driver IP address
|
||||
*
|
||||
* Parameters:
|
||||
* ifname The name of the interface to use
|
||||
* ipaddr The address to set
|
||||
* ipaddr The location to return the IP address
|
||||
*
|
||||
* Return:
|
||||
* 0 on sucess; -1 on failure
|
||||
@@ -83,7 +89,12 @@ int uip_gethostaddr(const char *ifname, struct in_addr *addr)
|
||||
ret = ioctl(sockfd, SIOCSIFADDR, (unsigned long)&req);
|
||||
if (!ret)
|
||||
{
|
||||
memcpy(addr, &req.ifr_addr, sizeof(addr));
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#error "req.ifr_addr.s_addr not big enough for IPv6 address"
|
||||
memcpy(addr, &req.ifr_addr, sizeof(struct in6_addr));
|
||||
#else
|
||||
memcpy(addr, &req.ifr_addr, sizeof(struct in_addr));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/****************************************************************************
|
||||
* netutils/uiplib/uip-getmacaddr.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uip_getmacaddr
|
||||
*
|
||||
* Description:
|
||||
* Get the network driver IP address
|
||||
*
|
||||
* Parameters:
|
||||
* ifname The name of the interface to use
|
||||
* macaddr The location to return the MAC address
|
||||
*
|
||||
* Return:
|
||||
* 0 on sucess; -1 on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int uip_getmacaddr(const char *ifname, uint8 *macaddr)
|
||||
{
|
||||
int ret = ERROR;
|
||||
if (ifname && macaddr)
|
||||
{
|
||||
/* Get a socket (only so that we get access to the INET subsystem) */
|
||||
|
||||
int sockfd = socket(PF_INET, SOCK_DGRAM, 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 get the MAC address */
|
||||
|
||||
ret = ioctl(sockfd, SIOCGIFHWADDR, (unsigned long)&req);
|
||||
if (!ret)
|
||||
{
|
||||
/* Return the MAC address */
|
||||
|
||||
memcpy(macaddr, &req.ifr_hwaddr.sa_data, IFHWADDRLEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
@@ -43,10 +43,13 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
@@ -72,18 +75,41 @@ int uip_setdraddr(const char *ifname, const struct in6_addr *addr)
|
||||
int uip_setdraddr(const char *ifname, const struct in_addr *addr)
|
||||
#endif
|
||||
{
|
||||
int ret = ERROR;
|
||||
if (ifname && addr)
|
||||
{
|
||||
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
struct ifreq req;
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct sockaddr_in6 *inaddr;
|
||||
#else
|
||||
struct sockaddr_in *inaddr;
|
||||
#endif
|
||||
/* Add the device name to the request */
|
||||
|
||||
strncpy(req.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&req.ifr_addr, addr, sizeof(addr));
|
||||
return ioctl(sockfd, SIOCSIFDSTADDR, (unsigned long)&req);
|
||||
|
||||
/* Add the INET address to the request */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#error "req.ifr_addr.s_addr not big enough for IPv6 address"
|
||||
inaddr = (struct sockaddr_in6 *)&req.ifr_addr;
|
||||
inaddr->sin_family = AF_INET6;
|
||||
inaddr->sin_port = 0;
|
||||
memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr));
|
||||
#else
|
||||
inaddr = (struct sockaddr_in *)&req.ifr_addr;
|
||||
inaddr->sin_family = AF_INET;
|
||||
inaddr->sin_port = 0;
|
||||
memcpy(&inaddr->sin_addr, addr, sizeof(struct in_addr));
|
||||
#endif
|
||||
ret = ioctl(sockfd, SIOCSIFDSTADDR, (unsigned long)&req);
|
||||
close(sockfd);
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
|
||||
@@ -43,10 +43,13 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
@@ -72,18 +75,41 @@ int uip_sethostaddr(const char *ifname, const struct in6_addr *addr)
|
||||
int uip_sethostaddr(const char *ifname, const struct in_addr *addr)
|
||||
#endif
|
||||
{
|
||||
int ret = ERROR;
|
||||
if (ifname && addr)
|
||||
{
|
||||
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
struct ifreq req;
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct sockaddr_in6 *inaddr;
|
||||
#else
|
||||
struct sockaddr_in *inaddr;
|
||||
#endif
|
||||
/* Add the device name to the request */
|
||||
|
||||
strncpy(req.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&req.ifr_addr, addr, sizeof(addr));
|
||||
return ioctl(sockfd, SIOCSIFADDR, (unsigned long)&req);
|
||||
|
||||
/* Add the INET address to the request */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#error "req.ifr_addr.s_addr not big enough for IPv6 address"
|
||||
inaddr = (struct sockaddr_in6 *)&req.ifr_addr;
|
||||
inaddr->sin_family = AF_INET6;
|
||||
inaddr->sin_port = 0;
|
||||
memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr));
|
||||
#else
|
||||
inaddr = (struct sockaddr_in *)&req.ifr_addr;
|
||||
inaddr->sin_family = AF_INET;
|
||||
inaddr->sin_port = 0;
|
||||
memcpy(&inaddr->sin_addr, addr, sizeof(struct in_addr));
|
||||
#endif
|
||||
ret = ioctl(sockfd, SIOCSIFADDR, (unsigned long)&req);
|
||||
close(sockfd);
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/****************************************************************************
|
||||
* netutils/uiplib/uip-setmacaddr.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
# define AF_INETX AF_INET6
|
||||
#else
|
||||
# define AF_INETX AF_INET
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uip_setmacaddr
|
||||
*
|
||||
* Description:
|
||||
* Set the network driver MAC address
|
||||
*
|
||||
* Parameters:
|
||||
* ifname The name of the interface to use
|
||||
* macaddr MAC address to set, size must be IFHWADDRLEN
|
||||
*
|
||||
* Return:
|
||||
* 0 on sucess; -1 on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int uip_setmacaddr(const char *ifname, const uint8 *macaddr)
|
||||
{
|
||||
int ret = ERROR;
|
||||
if (ifname && macaddr)
|
||||
{
|
||||
/* Get a socket (only so that we get access to the INET subsystem) */
|
||||
|
||||
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
struct ifreq req;
|
||||
|
||||
/* Put the driver name into the request */
|
||||
|
||||
strncpy(req.ifr_name, ifname, IFNAMSIZ);
|
||||
|
||||
/* Put the new MAC address into the request */
|
||||
|
||||
req.ifr_hwaddr.sa_family = AF_INETX;
|
||||
memcpy(&req.ifr_hwaddr.sa_data, macaddr, IFHWADDRLEN);
|
||||
|
||||
/* Perforom the ioctl to set the MAC address */
|
||||
|
||||
ret = ioctl(sockfd, SIOCSIFHWADDR, (unsigned long)&req);
|
||||
close(sockfd);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
@@ -43,10 +43,13 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
@@ -72,18 +75,41 @@ int uip_setnetmask(const char *ifname, const struct in6_addr *addr)
|
||||
int uip_setnetmask(const char *ifname, const struct in_addr *addr)
|
||||
#endif
|
||||
{
|
||||
int ret = ERROR;
|
||||
if (ifname && addr)
|
||||
{
|
||||
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
struct ifreq req;
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct sockaddr_in6 *inaddr;
|
||||
#else
|
||||
struct sockaddr_in *inaddr;
|
||||
#endif
|
||||
/* Add the device name to the request */
|
||||
|
||||
strncpy(req.ifr_name, ifname, IFNAMSIZ);
|
||||
memcpy(&req.ifr_addr, addr, sizeof(addr));
|
||||
return ioctl(sockfd, SIOCGIFNETMASK, (unsigned long)&req);
|
||||
|
||||
/* Add the INET address to the request */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#error "req.ifr_addr.s_addr not big enough for IPv6 address"
|
||||
inaddr = (struct sockaddr_in6 *)&req.ifr_addr;
|
||||
inaddr->sin_family = AF_INET6;
|
||||
inaddr->sin_port = 0;
|
||||
memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr));
|
||||
#else
|
||||
inaddr = (struct sockaddr_in *)&req.ifr_addr;
|
||||
inaddr->sin_family = AF_INET;
|
||||
inaddr->sin_port = 0;
|
||||
memcpy(&inaddr->sin_addr, addr, sizeof(struct in_addr));
|
||||
#endif
|
||||
ret = ioctl(sockfd, SIOCSIFNETMASK, (unsigned long)&req);
|
||||
close(sockfd);
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
|
||||
@@ -44,8 +44,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <net/uip/uip.h>
|
||||
|
||||
#include "uiplib.h"
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
|
||||
{
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/****************************************************************************
|
||||
* netutils/uiplib/uiplib.h
|
||||
* Various uIP library functions.
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Based on uIP which also has a BSD style license:
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __UIPLIB_H__
|
||||
#define __UIPLIB_H__
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
/* Convert a textual representation of an IP address to a numerical representation.
|
||||
*
|
||||
* This function takes a textual representation of an IP address in
|
||||
* the form a.b.c.d and converts it into a 4-byte array that can be
|
||||
* used by other uIP functions.
|
||||
*
|
||||
* addrstr A pointer to a string containing the IP address in
|
||||
* textual form.
|
||||
*
|
||||
* addr A pointer to a 4-byte array that will be filled in with
|
||||
* the numerical representation of the address.
|
||||
*
|
||||
* Return: 0 If the IP address could not be parsed.
|
||||
* Return: Non-zero If the IP address was parsed.
|
||||
*/
|
||||
|
||||
extern unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr);
|
||||
|
||||
/* Get and set IP addresses */
|
||||
|
||||
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);
|
||||
|
||||
#endif /* __UIPLIB_H__ */
|
||||
@@ -56,8 +56,8 @@
|
||||
#include <net/uip/uip.h>
|
||||
#include <net/uip/resolv.h>
|
||||
|
||||
#include "uiplib/uiplib.h"
|
||||
#include <net/uip/uip-arch.h>
|
||||
#include <net/uip/uip-lib.h>
|
||||
|
||||
#include "webclient.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user