diff --git a/apps/netutils/uiplib/uip_setmacaddr.c b/apps/netutils/uiplib/uip_setmacaddr.c index 28188b7f8e..f6cbe41326 100644 --- a/apps/netutils/uiplib/uip_setmacaddr.c +++ b/apps/netutils/uiplib/uip_setmacaddr.c @@ -1,8 +1,8 @@ /**************************************************************************** * netutils/uiplib/uip_setmacaddr.c * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2007-2009, 2011-2012 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 diff --git a/nuttx/include/net/if.h b/nuttx/include/net/if.h index 0733b699ca..247254786e 100644 --- a/nuttx/include/net/if.h +++ b/nuttx/include/net/if.h @@ -69,7 +69,7 @@ struct lifreq 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 */ + struct sockaddr lifru_hwaddr; /* MAC address */ int lifru_count; /* Number of devices */ int lifru_mtu; /* MTU size */ } lifr_ifru; diff --git a/nuttx/net/netdev_ioctl.c b/nuttx/net/netdev_ioctl.c index f78fc958a1..4b5876efa0 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 83fb7df33d..567e11617c 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++;