9
0
Fork 0

First round of compile fixes for IPv6

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4813 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-06-07 22:00:19 +00:00
parent 501a39032d
commit 40fc33c718
17 changed files with 133 additions and 65 deletions

View File

@ -92,7 +92,6 @@ int uip_gethostaddr(const char *ifname, struct in_addr *addr)
if (!ret)
{
#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));

View File

@ -96,7 +96,6 @@ int uip_setdraddr(const char *ifname, const struct in_addr *addr)
/* 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;

View File

@ -96,7 +96,6 @@ int uip_sethostaddr(const char *ifname, const struct in_addr *addr)
/* 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;

View File

@ -95,7 +95,6 @@ int uip_setnetmask(const char *ifname, const struct in_addr *addr)
/* 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;

View File

@ -1226,11 +1226,12 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
FAR char *address;
FAR char *lpath;
FAR char *rpath;
FAR struct sockaddr_in *sin;
bool badarg = false;
#ifdef CONFIG_NET_IPv6
FAR struct sockaddr_in6 *sin;
struct in6_addr inaddr;
#else
FAR struct sockaddr_in *sin;
struct in_addr inaddr;
#endif
bool tcp = false;
@ -1346,11 +1347,19 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
memset(&data, 0, sizeof(data));
#ifdef CONFIG_NET_IPv6
sin = (FAR struct sockaddr_in6 *)&data.addr;
sin->sin_family = AF_INET6;
sin->sin_port = htons(NFS_PMAPPORT);
memcpy(&sin->sin6_addr, &inaddr, sizeof(struct in6_addr));
data.addrlen = sizeof(struct sockaddr_in6);
#else
sin = (FAR struct sockaddr_in *)&data.addr;
sin->sin_family = AF_INET;
sin->sin_port = htons(NFS_PMAPPORT);
sin->sin_addr = inaddr;
data.addrlen = sizeof(struct sockaddr_in);
#endif
data.version = NFS_ARGSVERSION;
data.sotype = (tcp) ? SOCK_STREAM : SOCK_DGRAM;

View File

@ -1182,8 +1182,10 @@ int mountnfs(struct nfs_args *argp, void **handle)
nmp->nm_acregmax = NFS_MAXATTRTIMO;
nmp->nm_acdirmin = NFS_MINATTRTIMO;
nmp->nm_acdirmax = NFS_MAXATTRTIMO;
strncpy(nmp->nm_path, argp->path, 90);
nmp->nm_nam = argp->addr;
memcpy(&nmp->nm_nam, &argp->addr, argp->addrlen);
nfs_decode_args(nmp, argp);
/* Set up the sockets and per-host congestion */

View File

@ -1,4 +1,4 @@
/****************************************************************************
/*******************************************************************************************
* include/net/if.h
*
* Copyright (C) 2007, 2008, 2012 Gregory Nutt. All rights reserved.
@ -31,20 +31,20 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
*******************************************************************************************/
#ifndef __NET_IF_H
#define __NET_IF_H
/****************************************************************************
/*******************************************************************************************
* Included Files
****************************************************************************/
*******************************************************************************************/
#include <sys/socket.h>
/****************************************************************************
/*******************************************************************************************
* Pre-Processor Definitions
****************************************************************************/
*******************************************************************************************/
/* Sizing parameters */
@ -52,35 +52,82 @@
#define IF_NAMESIZE 6 /* Newer naming standard */
#define IFHWADDRLEN 6
/****************************************************************************
/*******************************************************************************************
* Public Type Definitions
****************************************************************************/
*******************************************************************************************/
struct ifreq
/* This is the newer form if the I/F request structure that can be used with both IPv4
* and IPv6.
*/
struct lifreq
{
char ifr_name[IFNAMSIZ]; /* Network device name (e.g. "eth0") */
char lifr_name[IFNAMSIZ]; /* Network device name (e.g. "eth0") */
union
{
struct sockaddr ifru_addr; /* IP Address */
struct sockaddr ifru_dstaddr; /* P-to-P Address */
struct sockaddr ifru_broadaddr; /* Broadcast address */
struct sockaddr ifru_netmask; /* Netmask */
struct sockaddr ifru_hwaddr; /* MAC address */
int ifru_count; /* Number of devices */
int ifru_mtu; /* MTU size */
struct sockaddr_storage lifru_addr; /* IP Address */
struct sockaddr_storage lifru_dstaddr; /* P-to-P Address */
struct sockaddr_storage lifru_broadaddr; /* Broadcast address */
struct sockaddr_storage lifru_netmask; /* Netmask */
struct sockaddr_storage lifru_hwaddr; /* MAC address */
int lifru_count; /* Number of devices */
int lifru_mtu; /* MTU size */
} lifr_ifru;
};
#define lifr_addr lifr_ifru.lifru_addr /* IP address */
#define lifr_dstaddr lifr_ifru.lifru_dstaddr /* P-to-P Address */
#define lifr_broadaddr lifr_ifru.lifru_broadaddr /* Broadcast address */
#define lifr_netmask lifr_ifru.lifru_netmask /* Interface net mask */
#define lifr_hwaddr lifr_ifru.lifru_hwaddr /* MAC address */
#define lifr_mtu lifr_ifru.lifru_mtu /* MTU */
#define lifr_count lifr_ifru.lifru_count /* Number of devices */
/* This is the older I/F request that should only be used with IPv4. However, since
* NuttX only supports IPv4 or 6 (not both), we can force the older structure to
* be compatible when IPv6 is enabled.
*/
#ifndef CONFIG_NET_IPv6
struct ifreq
{
char ifr_name[IFNAMSIZ]; /* Network device name (e.g. "eth0") */
union
{
struct sockaddr ifru_addr; /* IP Address */
struct sockaddr ifru_dstaddr; /* P-to-P Address */
struct sockaddr ifru_broadaddr; /* Broadcast address */
struct sockaddr ifru_netmask; /* Netmask */
struct sockaddr ifru_hwaddr; /* MAC address */
int ifru_count; /* Number of devices */
int ifru_mtu; /* MTU size */
} ifr_ifru;
};
#define ifr_addr ifr_ifru.ifru_addr /* IP address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* P-to-P Address */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* Broadcast address */
#define ifr_netmask ifr_ifru.ifru_netmask /* Interface net mask */
#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
#define ifr_mtu ifr_ifru.ifru_mtu /* MTU */
#define ifr_count ifr_ifru.ifru_count /* Number of devices */
#define ifr_addr ifr_ifru.ifru_addr /* IP address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* P-to-P Address */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* Broadcast address */
#define ifr_netmask ifr_ifru.ifru_netmask /* Interface net mask */
#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
#define ifr_mtu ifr_ifru.ifru_mtu /* MTU */
#define ifr_count ifr_ifru.ifru_count /* Number of devices */
/****************************************************************************
#else /* CONFIG_NET_IPv6 */
#define ifreq lifreq /* Replace ifreq with lifreq */
#define ifr_name lifr_name /* Network device name */
#define ifr_addr lifr_ifru.lifru_addr /* IP address */
#define ifr_dstaddr lifr_ifru.lifru_dstaddr /* P-to-P Address */
#define ifr_broadaddr lifr_ifru.lifru_broadaddr /* Broadcast address */
#define ifr_netmask lifr_ifru.lifru_netmask /* Interface net mask */
#define ifr_hwaddr lifr_ifru.lifru_hwaddr /* MAC address */
#define ifr_mtu lifr_ifru.lifru_mtu /* MTU */
#define ifr_count lifr_ifru.lifru_count /* Number of devices */
#endif /* CONFIG_NET_IPv6 */
/*******************************************************************************************
* Public Function Prototypes
****************************************************************************/
*******************************************************************************************/
#endif /* __NET_IF_H */

View File

@ -63,26 +63,26 @@
struct nfs_args
{
uint8_t version; /* Args structure version number */
uint8_t addrlen; /* Length of address */
uint8_t sotype; /* Socket type */
uint8_t proto; /* and Protocol */
int flags; /* Flags */
int wsize; /* Write size in bytes */
int rsize; /* Read size in bytes */
int readdirsize; /* readdir size in bytes */
int timeo; /* Initial timeout in .1 secs */
int retrans; /* Times to retry send */
//int maxgrouplist; /* Max. size of group list */
//int readahead; /* # of blocks to readahead */
//int leaseterm; /* Term (sec) of lease */
//int deadthresh; /* Retrans threshold */
char *path; /* Server's path of the directory being mount */
int acregmin; /* Cache attrs for reg files min time */
int acregmax; /* Cache attrs for reg files max time */
int acdirmin; /* Cache attrs for dirs min time */
int acdirmax; /* Cache attrs for dirs max time */
struct sockaddr addr; /* File server address (requires 32-bit alignment) */
uint8_t version; /* Args structure version number */
uint8_t addrlen; /* Length of address */
uint8_t sotype; /* Socket type */
uint8_t proto; /* and Protocol */
int flags; /* Flags */
int wsize; /* Write size in bytes */
int rsize; /* Read size in bytes */
int readdirsize; /* readdir size in bytes */
int timeo; /* Initial timeout in .1 secs */
int retrans; /* Times to retry send */
//int maxgrouplist; /* Max. size of group list */
//int readahead; /* # of blocks to readahead */
//int leaseterm; /* Term (sec) of lease */
//int deadthresh; /* Retrans threshold */
char *path; /* Server's path of the directory being mount */
int acregmin; /* Cache attrs for reg files min time */
int acregmax; /* Cache attrs for reg files max time */
int acdirmin; /* Cache attrs for dirs min time */
int acdirmax; /* Cache attrs for dirs max time */
struct sockaddr_storage addr; /* File server address (requires 32-bit alignment) */
};
/****************************************************************************

View File

@ -71,6 +71,20 @@
#define SIOCGIPMSFILTER _SIOC(0x000e) /* Retrieve source filter addresses */
#define SIOCSIPMSFILTER _SIOC(0x000f) /* Set source filter content */
/* Newer interface ioctls that use the struct lifreq. Can be used for
* both IPv4 and IPv6.
*/
#define SIOCGLIFADDR SIOCGIFADDR /* Get IP address */
#define SIOCSLIFADDR SIOCSIFADDR /* Set IP address */
#define SIOCGLIFDSTADDR SIOCSIFDSTADDR /* Get P-to-P address */
#define SIOCSLIFDSTADDR SIOCSIFDSTADDR /* Set P-to-P address */
#define SIOCGLIFBRDADDR SIOCGIFBRDADDR /* Get broadcast IP address */
#define SIOCSLIFBRDADDR SIOCSIFBRDADDR /* Set broadcast IP address */
#define SIOCGLIFNETMASK SIOCGIFNETMASK /* Get network mask */
#define SIOCSLIFNETMASK SIOCSIFNETMASK /* Set network mask */
#define SIOCGLIFMTU SIOCGIFMTU /* Get MTU size */
/* Wireless ioctl commands **************************************************/
#define SIOCSIWCOMMIT _SIOC(0x0010) /* Commit pending changes to driver */

View File

@ -109,7 +109,7 @@ FAR const char *inet_ntop(int af, FAR const void *src, FAR char *dst, socklen_t
sprintf(dst, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);
return dst;
#else
FAR const in6_addr *in6_addr;
FAR const struct in6_addr *in6_addr;
uint16_t warray[8];
int offset;
int entry;
@ -131,7 +131,7 @@ FAR const char *inet_ntop(int af, FAR const void *src, FAR char *dst, socklen_t
goto errout;
}
in6_addr = (FAR const in6_addr *)src;
in6_addr = (FAR const struct in6_addr *)src;
entry = -1;
maxentry = -1;
maxcount = 0;

View File

@ -273,14 +273,14 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
if (!rtime)
{
ip[(nsep << 1) + 0] = (uint8_t)(value >> 8)) & 0xff;
ip[(nsep << 1) + 1] = (uint8_t)(value >> 0)) & 0xff;
ip[(nsep << 1) + 0] = (uint8_t)((value >> 8) & 0xff);
ip[(nsep << 1) + 1] = (uint8_t)((value >> 0) & 0xff);
nsep++;
}
else
{
rip[(nrsep << 1) + 0] = (uint8_t)(value >> 8)) & 0xff;
rip[(nrsep << 1) + 1] = (uint8_t)(value >> 0)) & 0xff;
rip[(nrsep << 1) + 0] = (uint8_t)((value >> 8) & 0xff);
rip[(nrsep << 1) + 1] = (uint8_t)((value >> 0) & 0xff);
nrsep++;
}

View File

@ -108,7 +108,7 @@ static inline void accept_tcpsender(FAR struct uip_conn *conn,
{
addr->sin_family = AF_INET6;
addr->sin_port = conn->rport;
uip_ipaddr_copy(addr->sin_addr.s_addr, conn->ripaddr);
uip_ipaddr_copy(addr->sin6_addr.s6_addr, conn->ripaddr);
}
}
#else

View File

@ -42,6 +42,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <errno.h>
#include <nuttx/net/net.h>
@ -194,7 +195,6 @@ int getsockname(int sockfd, FAR struct sockaddr *addr, FAR socklen_t *addrlen)
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
#ifdef CONFIG_NET_IPv6
#error "Not big enough for IPv6 address"
outaddr->sin_family = AF_INET6;
memcpy(outaddr->sin6_addr.in6_u.u6_addr8, dev->d_ipaddr, 16);
*addrlen = sizeof(struct sockaddr_in6);

View File

@ -81,6 +81,7 @@ static inline bool netdev_maskcmp(const uip_ipaddr_t *ipaddr,
return (*ipaddr & *netmask) == (*raddr & *netmask);
#else
# warning "Not implemented for IPv6"
return false;
#endif
}

View File

@ -87,7 +87,6 @@
static void ioctl_getipaddr(struct sockaddr *outaddr, uip_ipaddr_t *inaddr)
{
#ifdef CONFIG_NET_IPv6
#error "Not big enough for IPv6 address"
struct sockaddr_in6 *dest = (struct sockaddr_in6 *)outaddr;
dest->sin_family = AF_INET6;
dest->sin_port = 0;

View File

@ -1,8 +1,8 @@
/****************************************************************************
* net/netdev_txnotify.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions

View File

@ -429,7 +429,7 @@ static inline void recvfrom_tcpsender(struct uip_driver_s *dev, struct recvfrom_
infrom->sin_port = TCPBUF->srcport;
#ifdef CONFIG_NET_IPv6
uip_ipaddr_copy(infrom->sin_addr.s_addr, TCPBUF->srcipaddr);
uip_ipaddr_copy(infrom->sin6_addr.s6_addr, TCPBUF->srcipaddr);
#else
uip_ipaddr_copy(infrom->sin_addr.s_addr, uip_ip4addr_conv(TCPBUF->srcipaddr));
#endif
@ -626,7 +626,7 @@ static inline void recvfrom_udpsender(struct uip_driver_s *dev, struct recvfrom_
infrom->sin_port = UDPBUF->srcport;
#ifdef CONFIG_NET_IPv6
uip_ipaddr_copy(infrom->sin_addr.s_addr, UDPBUF->srcipaddr);
uip_ipaddr_copy(infrom->sin6_addr.s6_addr, UDPBUF->srcipaddr);
#else
uip_ipaddr_copy(infrom->sin_addr.s_addr, uip_ip4addr_conv(UDPBUF->srcipaddr));
#endif