diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-06-08 01:53:26 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-06-08 01:53:26 +0000 |
commit | 2b2d2098a82f38861d4eb5147afa58be5697a2c0 (patch) | |
tree | 5193b6052c38185828210d5de539f2d476b3f8e9 /nuttx/net | |
parent | baf6287aa6309c19058f3987abe77e60ac2119a1 (diff) | |
download | px4-nuttx-2b2d2098a82f38861d4eb5147afa58be5697a2c0.tar.gz px4-nuttx-2b2d2098a82f38861d4eb5147afa58be5697a2c0.tar.bz2 px4-nuttx-2b2d2098a82f38861d4eb5147afa58be5697a2c0.zip |
More IPv6 rambling
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4815 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/netdev_ioctl.c | 46 | ||||
-rw-r--r-- | nuttx/net/uip/uip_input.c | 2 |
2 files changed, 34 insertions, 14 deletions
diff --git a/nuttx/net/netdev_ioctl.c b/nuttx/net/netdev_ioctl.c index f78fc958a..4b5876efa 100644 --- a/nuttx/net/netdev_ioctl.c +++ b/nuttx/net/netdev_ioctl.c @@ -77,35 +77,55 @@ ****************************************************************************/ /**************************************************************************** - * Name: ioctl_getipaddr / ioctl_setipaddr + * Name: ioctl_getipaddr * * Description: - * Copy IP addresses into and out of device structure + * Copy IP addresses from device structure to user memory. + * + * Input Parameters: + * outaddr - Pointer to the user-provided memory to receive the address. + * Actual type may be either 'struct sockaddr' (IPv4 only) or type + * 'struct sockaddr_storage' (both IPv4 and IPv6). + * inaddr - The source IP adress in the device structure. * ****************************************************************************/ -static void ioctl_getipaddr(struct sockaddr *outaddr, uip_ipaddr_t *inaddr) +static void ioctl_getipaddr(FAR void *outaddr, FAR const uip_ipaddr_t *inaddr) { #ifdef CONFIG_NET_IPv6 - struct sockaddr_in6 *dest = (struct sockaddr_in6 *)outaddr; - dest->sin_family = AF_INET6; - dest->sin_port = 0; + FAR struct sockaddr_in6 *dest = (FAR struct sockaddr_in6 *)outaddr; + 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; + FAR struct sockaddr_in *dest = (FAR struct sockaddr_in *)outaddr; + dest->sin_family = AF_INET; + dest->sin_port = 0; + dest->sin_addr.s_addr = *inaddr; #endif } -static void ioctl_setipaddr(uip_ipaddr_t *outaddr, struct sockaddr *inaddr) +/**************************************************************************** + * Name: ioctl_setipaddr + * + * Description: + * Copy IP addresses from user memory into the device structure + * + * Input Parameters: + * outaddr - Pointer to the source IP address in the device structure. + * inaddr - Pointer to the user-provided memory to containing the new IP + * address. Actual type may be either 'struct sockaddr' (IPv4 only) or + * type 'struct sockaddr_storage' (both IPv4 and IPv6). + * + ****************************************************************************/ + +static void ioctl_setipaddr(FAR uip_ipaddr_t *outaddr, FAR const void *inaddr) { #ifdef CONFIG_NET_IPv6 - struct sockaddr_in6 *src = (struct sockaddr_in6 *)inaddr; + FAR const struct sockaddr_in6 *src = (FAR const struct sockaddr_in6 *)inaddr; memcpy(outaddr, src->sin6_addr.in6_u.u6_addr8, 16); #else - struct sockaddr_in *src = (struct sockaddr_in *)inaddr; + FAR const struct sockaddr_in *src = (FAR const struct sockaddr_in *)inaddr; *outaddr = src->sin_addr.s_addr; #endif } diff --git a/nuttx/net/uip/uip_input.c b/nuttx/net/uip/uip_input.c index 83fb7df33..567e11617 100644 --- a/nuttx/net/uip/uip_input.c +++ b/nuttx/net/uip/uip_input.c @@ -461,7 +461,7 @@ void uip_input(struct uip_driver_s *dev) */ if (!uip_ipaddr_cmp(pbuf->destipaddr, dev->d_ipaddr) && - pbuf->destipaddr & HTONL(0xffff0000) != HTONL(0xff020000)) + (pbuf->destipaddr[0] & 0xffff) != 0xff02) { #ifdef CONFIG_NET_STATISTICS uip_stat.ip.drop++; |