forked from Archive/PX4-Autopilot
More IPv6 rambling
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4815 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
parent
33ef092bdd
commit
2f382d0878
|
@ -1,8 +1,8 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* netutils/uiplib/uip_setmacaddr.c
|
* netutils/uiplib/uip_setmacaddr.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct lifreq
|
||||||
struct sockaddr_storage lifru_dstaddr; /* P-to-P Address */
|
struct sockaddr_storage lifru_dstaddr; /* P-to-P Address */
|
||||||
struct sockaddr_storage lifru_broadaddr; /* Broadcast address */
|
struct sockaddr_storage lifru_broadaddr; /* Broadcast address */
|
||||||
struct sockaddr_storage lifru_netmask; /* Netmask */
|
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_count; /* Number of devices */
|
||||||
int lifru_mtu; /* MTU size */
|
int lifru_mtu; /* MTU size */
|
||||||
} lifr_ifru;
|
} lifr_ifru;
|
||||||
|
|
|
@ -77,35 +77,55 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ioctl_getipaddr / ioctl_setipaddr
|
* Name: ioctl_getipaddr
|
||||||
*
|
*
|
||||||
* Description:
|
* 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
|
#ifdef CONFIG_NET_IPv6
|
||||||
struct sockaddr_in6 *dest = (struct sockaddr_in6 *)outaddr;
|
FAR struct sockaddr_in6 *dest = (FAR struct sockaddr_in6 *)outaddr;
|
||||||
dest->sin_family = AF_INET6;
|
dest->sin_family = AF_INET6;
|
||||||
dest->sin_port = 0;
|
dest->sin_port = 0;
|
||||||
memcpy(dest->sin6_addr.in6_u.u6_addr8, inaddr, 16);
|
memcpy(dest->sin6_addr.in6_u.u6_addr8, inaddr, 16);
|
||||||
#else
|
#else
|
||||||
struct sockaddr_in *dest = (struct sockaddr_in *)outaddr;
|
FAR struct sockaddr_in *dest = (FAR struct sockaddr_in *)outaddr;
|
||||||
dest->sin_family = AF_INET;
|
dest->sin_family = AF_INET;
|
||||||
dest->sin_port = 0;
|
dest->sin_port = 0;
|
||||||
dest->sin_addr.s_addr = *inaddr;
|
dest->sin_addr.s_addr = *inaddr;
|
||||||
#endif
|
#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
|
#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);
|
memcpy(outaddr, src->sin6_addr.in6_u.u6_addr8, 16);
|
||||||
#else
|
#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;
|
*outaddr = src->sin_addr.s_addr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,7 +461,7 @@ void uip_input(struct uip_driver_s *dev)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!uip_ipaddr_cmp(pbuf->destipaddr, dev->d_ipaddr) &&
|
if (!uip_ipaddr_cmp(pbuf->destipaddr, dev->d_ipaddr) &&
|
||||||
pbuf->destipaddr & HTONL(0xffff0000) != HTONL(0xff020000))
|
(pbuf->destipaddr[0] & 0xffff) != 0xff02)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NET_STATISTICS
|
#ifdef CONFIG_NET_STATISTICS
|
||||||
uip_stat.ip.drop++;
|
uip_stat.ip.drop++;
|
||||||
|
|
Loading…
Reference in New Issue