abis/mlibc: Added sin_zero to struct sockaddr_in for BSD compatibility.
options/glibc: Added resolv.h. options/posix: Implemented a bunch of inet related macros. Signed-off-by: Dennisbonke <admin@dennisbonke.com>
This commit is contained in:
parent
e38eaa8f67
commit
d13d7e4b7e
|
@ -19,6 +19,7 @@ struct sockaddr_in {
|
|||
struct in_addr sin_addr;
|
||||
uint8_t pad[8];
|
||||
};
|
||||
#define sin_zero pad /* for BSD Unix compatibility */
|
||||
|
||||
struct in6_addr {
|
||||
uint8_t s6_addr[16];
|
||||
|
|
6
options/glibc/include/resolv.h
Normal file
6
options/glibc/include/resolv.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef _RESOLV_H
|
||||
#define _RESOLV_H
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#endif // _RESOLV_H
|
|
@ -12,7 +12,8 @@ if not no_headers
|
|||
'include/stdio_ext.h',
|
||||
'include/err.h',
|
||||
'include/paths.h',
|
||||
'include/sysexits.h'
|
||||
'include/sysexits.h',
|
||||
'include/resolv.h'
|
||||
)
|
||||
install_headers(
|
||||
'include/sys/ioctl.h',
|
||||
|
|
|
@ -10,7 +10,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IN6_IS_ADDR_UNSPECIFIED 1
|
||||
#define IN6_IS_ADDR_UNSPECIFIED(a) ({ \
|
||||
uint32_t *_a = (uint32_t *)((a)->s6_addr); \
|
||||
!_a[0] && \
|
||||
!_a[1] && \
|
||||
!_a[2] && \
|
||||
!_a[3]; \
|
||||
})
|
||||
#define IN6_IS_ADDR_LOOPBACK(a) ({ \
|
||||
uint32_t *_a = (uint32_t *)((a)->s6_addr); \
|
||||
!_a[0] && \
|
||||
|
@ -18,9 +24,15 @@ extern "C" {
|
|||
!_a[2] && \
|
||||
_a[3] == htonl(0x0001); \
|
||||
})
|
||||
#define IN6_IS_ADDR_MULTICAST 3
|
||||
#define IN6_IS_ADDR_LINKLOCAL 4
|
||||
#define IN6_IS_ADDR_SITELOCAL 5
|
||||
#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) ({ \
|
||||
uint32_t *_a = (uint32_t *)((a)->s6_addr); \
|
||||
_a[0] & htonl(0xffc00000) == htonl(0xfe800000); \
|
||||
})
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) ({ \
|
||||
uint32_t *_a = (uint32_t *)((a)->s6_addr); \
|
||||
_a[0] & htonl(0xffc00000) == htonl(0xfec00000); \
|
||||
})
|
||||
#define IN6_IS_ADDR_V4MAPPED(a) ({ \
|
||||
uint32_t *_a = (uint32_t *)((a)->s6_addr); \
|
||||
!_a[0] && \
|
||||
|
@ -34,11 +46,29 @@ extern "C" {
|
|||
__ARE_4_BYTE_EQUAL((const uint32_t *)(a), (const uint32_t *)(b))
|
||||
|
||||
#define IN6_IS_ADDR_V4COMPAT 7
|
||||
#define IN6_IS_ADDR_MC_NODELOCAL 8
|
||||
#define IN6_IS_ADDR_MC_LINKLOCAL 9
|
||||
#define IN6_IS_ADDR_MC_SITELOCAL 10
|
||||
#define IN6_IS_ADDR_MC_ORGLOCAL 11
|
||||
#define IN6_IS_ADDR_MC_GLOBAL 12
|
||||
#define IN6_IS_ADDR_MC_NODELOCAL(a) ({ \
|
||||
(IN6_IS_ADDR_MULTICAST(a) && \
|
||||
((((const uint8_t *)(a))[1] & 0xf) == 0x1)); \
|
||||
})
|
||||
#define IN6_IS_ADDR_MC_LINKLOCAL(a) ({ \
|
||||
(IN6_IS_ADDR_MULTICAST(a) && \
|
||||
((((const uint8_t *)(a))[1] & 0xf) == 0x2)); \
|
||||
})
|
||||
#define IN6_IS_ADDR_MC_SITELOCAL(a) ({ \
|
||||
(IN6_IS_ADDR_MULTICAST(a) && \
|
||||
((((const uint8_t *)(a))[1] & 0xf) == 0x5)); \
|
||||
})
|
||||
#define IN6_IS_ADDR_MC_ORGLOCAL(a) ({ \
|
||||
(IN6_IS_ADDR_MULTICAST(a) && \
|
||||
((((const uint8_t *)(a))[1] & 0xf) == 0x8)); \
|
||||
})
|
||||
#define IN6_IS_ADDR_MC_GLOBAL(a) ({ \
|
||||
(IN6_IS_ADDR_MULTICAST(a) && \
|
||||
((((const uint8_t *)(a))[1] & 0xf) == 0xe)); \
|
||||
})
|
||||
|
||||
#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
|
||||
#define IN_MULTICAST(a) IN_CLASSD(a)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue