diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-10-26 21:21:34 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-10-26 21:21:34 +0000 |
commit | a7e644a852025eeb8af8648f73aac7c9ffc315bd (patch) | |
tree | 437e4ba77b328999defee6771e5432bf6e135f07 /nuttx/net | |
parent | 7326b1166b618ddc6b3eb9e9224b1f5ded5515a5 (diff) | |
download | px4-nuttx-a7e644a852025eeb8af8648f73aac7c9ffc315bd.tar.gz px4-nuttx-a7e644a852025eeb8af8648f73aac7c9ffc315bd.tar.bz2 px4-nuttx-a7e644a852025eeb8af8648f73aac7c9ffc315bd.zip |
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
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/netdev-ioctl.c | 17 | ||||
-rw-r--r-- | nuttx/net/uip/uip.c | 13 |
2 files changed, 25 insertions, 5 deletions
diff --git a/nuttx/net/netdev-ioctl.c b/nuttx/net/netdev-ioctl.c index cdc7c80b8..1abc84105 100644 --- a/nuttx/net/netdev-ioctl.c +++ b/nuttx/net/netdev-ioctl.c @@ -56,6 +56,12 @@ * Definitions ****************************************************************************/ +#ifdef CONFIG_NET_IPv6 +# define AF_INETX AF_INET6 +#else +# define AF_INETX AF_INET +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -71,10 +77,15 @@ static void _get_ipaddr(struct sockaddr *outaddr, uip_ipaddr_t *inaddr) { #ifdef CONFIG_NET_IPv6 +#error " big enough for IPv6 address" struct sockaddr_in6 *dest = (struct sockaddr_in6 *)outaddr; - memcpy(&dest->sin6_addr.in6_u, inaddr, IFHWADDRLEN); + dest->sin_family = AF_INET6; + dest->sin_port = 0; + memcpy(dest->sin6_addr.in6_u.u6_addr8, inaddr, 16); #else struct sockaddr_in *dest = (struct sockaddr_in *)outaddr; + dest->sin_family = AF_INET; + dest->sin_port = 0; dest->sin_addr.s_addr = *inaddr; #endif } @@ -83,7 +94,7 @@ static void _set_ipaddr(uip_ipaddr_t *outaddr, struct sockaddr *inaddr) { #ifdef CONFIG_NET_IPv6 struct sockaddr_in6 *src = (struct sockaddr_in6 *)inaddr; - memcpy(outaddr, &src->sin6_addr.in6_u, IFHWADDRLEN); + memcpy(outaddr, src->sin6_addr.in6_u.u6_addr8, 16); #else struct sockaddr_in *src = (struct sockaddr_in *)inaddr; *outaddr = src->sin_addr.s_addr; @@ -187,10 +198,12 @@ int netdev_ioctl(int sockfd, int cmd, struct ifreq *req) break; case SIOCGIFHWADDR: /* Get hardware address */ + req->ifr_hwaddr.sa_family = AF_INETX; memcpy(req->ifr_hwaddr.sa_data, dev->d_mac.addr, IFHWADDRLEN); break; case SIOCSIFHWADDR: /* Set hardware address */ + req->ifr_hwaddr.sa_family = AF_INETX; memcpy(dev->d_mac.addr, req->ifr_hwaddr.sa_data, IFHWADDRLEN); break; diff --git a/nuttx/net/uip/uip.c b/nuttx/net/uip/uip.c index 3cfb37b2a..3c8e8001e 100644 --- a/nuttx/net/uip/uip.c +++ b/nuttx/net/uip/uip.c @@ -87,13 +87,20 @@ #include <string.h> -#if UIP_LOGGING == 1 -#include <stdio.h> +/* Check if logging of network events should be compiled in. + * + * This is useful mostly for debugging. The function uip_log() + * must be implemented to suit the architecture of the project, if + * logging is turned on. + */ + +#ifdef CONFIG_NET_LOGGING +# include <stdio.h> extern void uip_log(char *msg); # define UIP_LOG(m) uip_log(m) #else # define UIP_LOG(m) -#endif /* UIP_LOGGING == 1 */ +#endif #include "uip-internal.h" |