[PATCH v2 41/45] RTEMS: Introduce <machine/_kernel_in6.h>

Sebastian Huber <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
This helps to avoid Newlib updates due to FreeBSD kernel space changes.

Signed-off-by: Sebastian Huber <[email protected]>
---
 newlib/libc/sys/rtems/include/netinet6/in6.h | 170 ++-------------------------
 1 file changed, 7 insertions(+), 163 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/netinet6/in6.h b/newlib/libc/sys/rtems/include/netinet6/in6.h
index 461d55795..ddf2207b8 100644
--- a/newlib/libc/sys/rtems/include/netinet6/in6.h
+++ b/newlib/libc/sys/rtems/include/netinet6/in6.h
@@ -103,11 +103,6 @@ struct in6_addr {
 };
 
 #define s6_addr   __u6_addr.__u6_addr8
-#ifdef _KERNEL	/* XXX nonstandard */
-#define s6_addr8  __u6_addr.__u6_addr8
-#define s6_addr16 __u6_addr.__u6_addr16
-#define s6_addr32 __u6_addr.__u6_addr32
-#endif
 
 #define INET6_ADDRSTRLEN	46
 
@@ -132,56 +127,6 @@ struct sockaddr_in6 {
 };
 
 /*
- * Local definition for masks
- */
-#ifdef _KERNEL	/* XXX nonstandard */
-#define IN6MASK0	{{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}}
-#define IN6MASK32	{{{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, \
-			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
-#define IN6MASK64	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
-			    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
-#define IN6MASK96	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
-			    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}}
-#define IN6MASK128	{{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
-			    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }}}
-#endif
-
-#ifdef _KERNEL
-extern const struct sockaddr_in6 sa6_any;
-
-extern const struct in6_addr in6mask0;
-extern const struct in6_addr in6mask32;
-extern const struct in6_addr in6mask64;
-extern const struct in6_addr in6mask96;
-extern const struct in6_addr in6mask128;
-#endif /* _KERNEL */
-
-/*
- * Macros started with IPV6_ADDR is KAME local
- */
-#ifdef _KERNEL	/* XXX nonstandard */
-#if _BYTE_ORDER == _BIG_ENDIAN
-#define IPV6_ADDR_INT32_ONE	1
-#define IPV6_ADDR_INT32_TWO	2
-#define IPV6_ADDR_INT32_MNL	0xff010000
-#define IPV6_ADDR_INT32_MLL	0xff020000
-#define IPV6_ADDR_INT32_SMP	0x0000ffff
-#define IPV6_ADDR_INT16_ULL	0xfe80
-#define IPV6_ADDR_INT16_USL	0xfec0
-#define IPV6_ADDR_INT16_MLL	0xff02
-#elif _BYTE_ORDER == _LITTLE_ENDIAN
-#define IPV6_ADDR_INT32_ONE	0x01000000
-#define IPV6_ADDR_INT32_TWO	0x02000000
-#define IPV6_ADDR_INT32_MNL	0x000001ff
-#define IPV6_ADDR_INT32_MLL	0x000002ff
-#define IPV6_ADDR_INT32_SMP	0xffff0000
-#define IPV6_ADDR_INT16_ULL	0x80fe
-#define IPV6_ADDR_INT16_USL	0xc0fe
-#define IPV6_ADDR_INT16_MLL	0x02ff
-#endif
-#endif
-
-/*
  * Definition of some useful macros to handle IP6 addresses
  */
 #if __BSD_VISIBLE
@@ -223,15 +168,10 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
  * does not supply memcmp().  For userland memcmp() is preferred as it is
  * in ANSI standard.
  */
-#ifdef _KERNEL
-#define IN6_ARE_ADDR_EQUAL(a, b)			\
-    (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
-#else
 #if __BSD_VISIBLE
 #define IN6_ARE_ADDR_EQUAL(a, b)			\
     (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
 #endif
-#endif
 
 /*
  * Unspecified
@@ -273,14 +213,7 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
  * KAME Scope Values
  */
 
-#ifdef _KERNEL	/* XXX nonstandard */
-#define IPV6_ADDR_SCOPE_NODELOCAL	0x01
-#define IPV6_ADDR_SCOPE_INTFACELOCAL	0x01
-#define IPV6_ADDR_SCOPE_LINKLOCAL	0x02
-#define IPV6_ADDR_SCOPE_SITELOCAL	0x05
-#define IPV6_ADDR_SCOPE_ORGLOCAL	0x08	/* just used in this file */
-#define IPV6_ADDR_SCOPE_GLOBAL		0x0e
-#else
+#ifndef _KERNEL
 #define __IPV6_ADDR_SCOPE_NODELOCAL	0x01
 #define __IPV6_ADDR_SCOPE_INTFACELOCAL	0x01
 #define __IPV6_ADDR_SCOPE_LINKLOCAL	0x02
@@ -303,35 +236,14 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
  */
 #define IN6_IS_ADDR_MULTICAST(a)	((a)->s6_addr[0] == 0xff)
 
-#ifdef _KERNEL	/* XXX nonstandard */
-#define IPV6_ADDR_MC_SCOPE(a)		((a)->s6_addr[1] & 0x0f)
-#else
+#ifndef _KERNEL
 #define __IPV6_ADDR_MC_SCOPE(a)		((a)->s6_addr[1] & 0x0f)
 #endif
 
 /*
  * Multicast Scope
  */
-#ifdef _KERNEL	/* refers nonstandard items */
-#define IN6_IS_ADDR_MC_NODELOCAL(a)	\
-	(IN6_IS_ADDR_MULTICAST(a) &&	\
-	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL))
-#define IN6_IS_ADDR_MC_INTFACELOCAL(a)	\
-	(IN6_IS_ADDR_MULTICAST(a) &&	\
-	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_INTFACELOCAL))
-#define IN6_IS_ADDR_MC_LINKLOCAL(a)	\
-	(IN6_IS_ADDR_MULTICAST(a) &&	\
-	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
-#define IN6_IS_ADDR_MC_SITELOCAL(a)	\
-	(IN6_IS_ADDR_MULTICAST(a) &&	\
-	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
-#define IN6_IS_ADDR_MC_ORGLOCAL(a)	\
-	(IN6_IS_ADDR_MULTICAST(a) &&	\
-	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
-#define IN6_IS_ADDR_MC_GLOBAL(a)	\
-	(IN6_IS_ADDR_MULTICAST(a) &&	\
-	 (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
-#else
+#ifndef _KERNEL
 #define IN6_IS_ADDR_MC_NODELOCAL(a)	\
 	(IN6_IS_ADDR_MULTICAST(a) &&	\
 	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL))
@@ -349,28 +261,6 @@ extern const struct in6_addr in6addr_linklocal_allv2routers;
 	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL))
 #endif
 
-#ifdef _KERNEL	/* nonstandard */
-/*
- * KAME Scope
- */
-#define IN6_IS_SCOPE_LINKLOCAL(a)	\
-	((IN6_IS_ADDR_LINKLOCAL(a)) ||	\
-	 (IN6_IS_ADDR_MC_LINKLOCAL(a)))
-#define	IN6_IS_SCOPE_EMBED(a)			\
-	((IN6_IS_ADDR_LINKLOCAL(a)) ||		\
-	 (IN6_IS_ADDR_MC_LINKLOCAL(a)) ||	\
-	 (IN6_IS_ADDR_MC_INTFACELOCAL(a)))
-
-#define IFA6_IS_DEPRECATED(a) \
-	((a)->ia6_lifetime.ia6t_pltime != ND6_INFINITE_LIFETIME && \
-	 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
-	 (a)->ia6_lifetime.ia6t_pltime)
-#define IFA6_IS_INVALID(a) \
-	((a)->ia6_lifetime.ia6t_vltime != ND6_INFINITE_LIFETIME && \
-	 (u_int32_t)((time_uptime - (a)->ia6_updatetime)) > \
-	 (a)->ia6_lifetime.ia6t_vltime)
-#endif /* _KERNEL */
-
 /*
  * IP6 route structure
  */
@@ -391,11 +281,6 @@ struct route_in6 {
 };
 #endif
 
-#ifdef _KERNEL
-#define MTAG_ABI_IPV6		1444287380	/* IPv6 ABI */
-#define IPV6_TAG_DIRECT		0		/* direct-dispatch IPv6 */
-#endif /* _KERNEL */
-
 /*
  * Options for use with [gs]etsockopt at the IPV6 level.
  * First word of comment is data type; bool is stored in int.
@@ -417,16 +302,6 @@ struct route_in6 {
 #define IPV6_LEAVE_GROUP	13 /* ipv6_mreq; leave a group membership */
 #define IPV6_PORTRANGE		14 /* int; range to choose for unspec port */
 #define ICMP6_FILTER		18 /* icmp6_filter; icmp6 filter */
-/* RFC2292 options */
-#ifdef _KERNEL
-#define IPV6_2292PKTINFO	19 /* bool; send/recv if, src/dst addr */
-#define IPV6_2292HOPLIMIT	20 /* bool; hop limit */
-#define IPV6_2292NEXTHOP	21 /* bool; next hop addr */
-#define IPV6_2292HOPOPTS	22 /* bool; hop-by-hop option */
-#define IPV6_2292DSTOPTS	23 /* bool; destinaion option */
-#define IPV6_2292RTHDR		24 /* bool; routing header */
-#define IPV6_2292PKTOPTIONS	25 /* buf/cmsghdr; set/get IPv6 options */
-#endif
 
 #define IPV6_CHECKSUM		26 /* int; checksum offset for raw socket */
 #define IPV6_V6ONLY		27 /* bool; make AF_INET6 sockets v6 only */
@@ -452,9 +327,6 @@ struct route_in6 {
 #define IPV6_RECVRTHDR		38 /* bool; recv routing header */
 #define IPV6_RECVHOPOPTS	39 /* bool; recv hop-by-hop option */
 #define IPV6_RECVDSTOPTS	40 /* bool; recv dst option after rthdr */
-#ifdef _KERNEL
-#define IPV6_RECVRTHDRDSTOPTS	41 /* bool; recv dst option before rthdr */
-#endif
 
 #define IPV6_USE_MIN_MTU	42 /* bool; send packets at the minimum MTU */
 #define IPV6_RECVPATHMTU	43 /* bool; notify an according MTU */
@@ -660,38 +532,6 @@ struct ip6_mtuinfo {
 #define	M_RTALERT_MLD		M_PROTO8
 #define	M_FRAGMENTED		M_PROTO9	/* contained fragment header */
 
-#ifdef _KERNEL
-struct cmsghdr;
-struct ip6_hdr;
-
-int	in6_cksum_pseudo(struct ip6_hdr *, uint32_t, uint8_t, uint16_t);
-int	in6_cksum(struct mbuf *, u_int8_t, u_int32_t, u_int32_t);
-int	in6_cksum_partial(struct mbuf *, u_int8_t, u_int32_t, u_int32_t,
-			  u_int32_t);
-int	in6_localaddr(struct in6_addr *);
-int	in6_localip(struct in6_addr *);
-int	in6_ifhasaddr(struct ifnet *, struct in6_addr *);
-int	in6_addrscope(const struct in6_addr *);
-char	*ip6_sprintf(char *, const struct in6_addr *);
-struct	in6_ifaddr *in6_ifawithifp(struct ifnet *, struct in6_addr *);
-extern void in6_if_up(struct ifnet *);
-struct sockaddr;
-extern	u_char	ip6_protox[];
-
-void	in6_sin6_2_sin(struct sockaddr_in *sin,
-			    struct sockaddr_in6 *sin6);
-void	in6_sin_2_v4mapsin6(struct sockaddr_in *sin,
-				 struct sockaddr_in6 *sin6);
-void	in6_sin6_2_sin_in_sock(struct sockaddr *nam);
-void	in6_sin_2_v4mapsin6_in_sock(struct sockaddr **nam);
-extern void addrsel_policy_init(void);
-
-#define	satosin6(sa)	((struct sockaddr_in6 *)(sa))
-#define	sin6tosa(sin6)	((struct sockaddr *)(sin6))
-#define	ifatoia6(ifa)	((struct in6_ifaddr *)(ifa))
-
-#endif /* _KERNEL */
-
 #ifndef _SIZE_T_DECLARED
 typedef	__size_t	size_t;
 #define	_SIZE_T_DECLARED
@@ -748,4 +588,8 @@ __END_DECLS
 
 #endif /* __BSD_VISIBLE */
 
+#ifdef _KERNEL
+/* Header file provided outside of Newlib */
+#include <machine/_kernel_in6.h>
+#endif
 #endif /* !_NETINET6_IN6_H_ */
-- 
2.13.7
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.