* Added missing IPv6 defines and in6addr_any, in6addr_loopback exports.
* This should get most IPv6 applications to link (they just can't open IPv6 sockets yet, as the protocol is missing). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35326 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e342a98a08
commit
e054bfbf08
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2006-2010, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _NETINET6_IN6_H_
|
||||
@ -14,10 +14,7 @@ struct in6_addr {
|
||||
uint8_t s6_addr[16];
|
||||
};
|
||||
|
||||
/*
|
||||
* IP Version 6 socket address.
|
||||
*/
|
||||
|
||||
/* IP Version 6 socket address. */
|
||||
struct sockaddr_in6 {
|
||||
uint8_t sin6_len;
|
||||
uint8_t sin6_family;
|
||||
@ -28,14 +25,81 @@ struct sockaddr_in6 {
|
||||
};
|
||||
|
||||
|
||||
#define IN6ADDR_ANY_INIT \
|
||||
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
|
||||
#define IN6ADDR_LOOPBACK_INIT \
|
||||
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
|
||||
#define IN6ADDR_ANY_INIT {{ \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
|
||||
#define IN6ADDR_LOOPBACK_INIT {{ \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
|
||||
|
||||
extern const struct in6_addr in6addr_any;
|
||||
extern const struct in6_addr in6addr_loopback;
|
||||
|
||||
|
||||
/* Non-standard helper defines (same as in FreeBSD, though) */
|
||||
#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
|
||||
#define __IPV6_ADDR_SCOPE_GLOBAL 0x0e
|
||||
|
||||
#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
|
||||
|
||||
|
||||
#define IN6_IS_ADDR_UNSPECIFIED(a) \
|
||||
(!memcmp((a)->s6_addr, in6addr_any.s6_addr, sizeof(struct in6_addr)))
|
||||
|
||||
#define IN6_IS_ADDR_LOOPBACK(a) \
|
||||
(!memcmp((a)->s6_addr, in6addr_loopback.s6_addr, sizeof(struct in6_addr)))
|
||||
|
||||
#define IN6_IS_ADDR_MULTICAST(a) \
|
||||
((a)->s6_addr[0] == 0xff)
|
||||
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
||||
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
|
||||
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) \
|
||||
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
|
||||
|
||||
#define IN6_IS_ADDR_V4MAPPED(a) \
|
||||
((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 \
|
||||
&& (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 \
|
||||
&& (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 \
|
||||
&& (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 \
|
||||
&& (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 \
|
||||
&& (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
|
||||
|
||||
#define IN6_IS_ADDR_V4COMPAT(a) \
|
||||
((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 \
|
||||
&& (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 \
|
||||
&& (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 \
|
||||
&& (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 \
|
||||
&& (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 \
|
||||
&& (a)->s6_addr[10] == 0x00 && (a)->s6_addr[11] == 0x01)
|
||||
|
||||
#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_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)
|
||||
|
||||
/* maximal length of the string representation of an IPv6 address */
|
||||
#define INET6_ADDRSTRLEN 46
|
||||
|
||||
|
||||
#endif /* _NETINET6_IN6_H_ */
|
||||
|
@ -52,8 +52,8 @@ const char *isc_strerror(int);
|
||||
#endif
|
||||
#define HAS_INET6_STRUCTS 1
|
||||
#define HAVE_SIN6_SCOPE_ID 1
|
||||
#define NEED_IN6ADDR_ANY 1
|
||||
#undef HAS_IN_ADDR6
|
||||
#undef NEED_IN6ADDR_ANY
|
||||
#define HAS_IN_ADDR6
|
||||
#define HAVE_SOCKADDR_STORAGE 1
|
||||
#undef NEED_GETTIMEOFDAY
|
||||
#define HAVE_STRNDUP 1
|
||||
@ -86,11 +86,6 @@ const char *isc_strerror(int);
|
||||
#define PF_INET6 AF_INET6
|
||||
#endif
|
||||
|
||||
#ifdef HAS_IN_ADDR6
|
||||
/* Map to pre-RFC structure. */
|
||||
#define in6_addr in_addr6
|
||||
#endif
|
||||
|
||||
#ifndef HAS_INET6_STRUCTS
|
||||
/* Replace with structure from later rev of O/S if known. */
|
||||
struct in6_addr {
|
||||
@ -138,6 +133,11 @@ struct sockaddr_in6 {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __HAIKU__
|
||||
#define isc_in6addr_any in6addr_any
|
||||
#define isc_in6addr_loopback in6addr_loopback
|
||||
#endif
|
||||
|
||||
#ifndef IN6ADDR_ANY_INIT
|
||||
#ifdef s6_addr
|
||||
#define IN6ADDR_ANY_INIT \
|
||||
|
Loading…
Reference in New Issue
Block a user