📄 in.h
字号:
__SOCKADDR_COMMON (sin_); in_port_t sin_port; /* Port number. */ struct in_addr sin_addr; /* Internet address. */ /* Pad to size of `struct sockaddr'. */ unsigned char sin_zero[sizeof (struct sockaddr) - __SOCKADDR_COMMON_SIZE - sizeof (in_port_t) - sizeof (struct in_addr)]; };/* Ditto, for IPv6. */struct sockaddr_in6 { __SOCKADDR_COMMON (sin6_); in_port_t sin6_port; /* Transport layer port # */ uint32_t sin6_flowinfo; /* IPv6 flow information */ struct in6_addr sin6_addr; /* IPv6 address */ uint32_t sin6_scope_id; /* IPv6 scope-id */ };#ifdef __USE_GNUstruct __sockaddr_in6_rfc2133 { __SOCKADDR_COMMON (sin6_); in_port_t sin6_port; /* Transport layer port # */ uint32_t sin6_flowinfo; /* IPv6 flow information */ struct in6_addr sin6_addr; /* IPv6 address */ };#endif/* IPv6 multicast request. */struct ipv6_mreq { /* IPv6 multicast address of group */ struct in6_addr ipv6mr_multiaddr; /* local interface */ unsigned int ipv6mr_interface; };/* IPv6 anycast request. */struct ipv6_areq { /* IPv6 anycast address of group */ struct in6_addr ipv6ar_anyaddr; /* local interface */ unsigned int ipv6ar_interface; };/* Get system-specific definitions. */#include <bits/in.h>/* Functions to convert between host and network byte order. Please note that these functions normally take `unsigned long int' or `unsigned short int' values as arguments and also return them. But this was a short-sighted decision since on different systems the types may have different representations but the values are always the same. */extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__));extern uint16_t ntohs (uint16_t __netshort) __THROW __attribute__ ((__const__));extern uint32_t htonl (uint32_t __hostlong) __THROW __attribute__ ((__const__));extern uint16_t htons (uint16_t __hostshort) __THROW __attribute__ ((__const__));#include <endian.h>/* Get machine dependent optimized versions of byte swapping functions. */#include <bits/byteswap.h>#ifdef __OPTIMIZE__/* We can optimize calls to the conversion functions. Either nothing has to be done or we are using directly the byte-swapping functions which often can be inlined. */# if __BYTE_ORDER == __BIG_ENDIAN/* The host byte order is the same as network byte order, so these functions are all just identity. */# define ntohl(x) (x)# define ntohs(x) (x)# define htonl(x) (x)# define htons(x) (x)# else# if __BYTE_ORDER == __LITTLE_ENDIAN# define ntohl(x) __bswap_32 (x)# define ntohs(x) __bswap_16 (x)# define htonl(x) __bswap_32 (x)# define htons(x) __bswap_16 (x)# endif# endif#endif#define IN6_IS_ADDR_UNSPECIFIED(a) \ (((__const uint32_t *) (a))[0] == 0 \ && ((__const uint32_t *) (a))[1] == 0 \ && ((__const uint32_t *) (a))[2] == 0 \ && ((__const uint32_t *) (a))[3] == 0)#define IN6_IS_ADDR_LOOPBACK(a) \ (((__const uint32_t *) (a))[0] == 0 \ && ((__const uint32_t *) (a))[1] == 0 \ && ((__const uint32_t *) (a))[2] == 0 \ && ((__const uint32_t *) (a))[3] == htonl (1))#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)#define IN6_IS_ADDR_LINKLOCAL(a) \ ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ == htonl (0xfe800000))#define IN6_IS_ADDR_SITELOCAL(a) \ ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ == htonl (0xfec00000))#define IN6_IS_ADDR_V4MAPPED(a) \ ((((__const uint32_t *) (a))[0] == 0) \ && (((__const uint32_t *) (a))[1] == 0) \ && (((__const uint32_t *) (a))[2] == htonl (0xffff)))#define IN6_IS_ADDR_V4COMPAT(a) \ ((((__const uint32_t *) (a))[0] == 0) \ && (((__const uint32_t *) (a))[1] == 0) \ && (((__const uint32_t *) (a))[2] == 0) \ && (ntohl (((__const uint32_t *) (a))[3]) > 1))#define IN6_ARE_ADDR_EQUAL(a,b) \ ((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \ && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \ && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \ && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))/* Bind socket to a privileged IP port. */extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW;/* The IPv6 version of this function. */extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in) __THROW;#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))/* IPv6 packet information. */struct in6_pktinfo { struct in6_addr ipi6_addr; /* src/dst IPv6 address */ unsigned int ipi6_ifindex; /* send/recv interface index */ };/* RFC2292 / RFC2292bis things */#define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. XXX old spec */#define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. XXX old spec */#define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */struct cmsghdr;extern int inet6_option_space (int _nbytes) __THROW;extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp, int __type) __THROW;extern int inet6_option_append (struct cmsghdr *__cmsg, const uint8_t *typep, int __multx, int __plusy) __THROW;extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen, int __multx, int __plusy) __THROW;extern int inet6_option_next (const struct cmsghdr *__cmsg, uint8_t **__tptrp) __THROW;extern int inet6_option_find (const struct cmsghdr *__cmsg, uint8_t **__tptrp, int __type) __THROW;extern socklen_t inet6_rthdr_space (int __type, int __segments) __THROW;extern struct cmsghdr *inet6_rthdr_init (void *__bp, int __type) __THROW;extern int inet6_rthdr_add (struct cmsghdr *__cmsg, const struct in6_addr *__addr, unsigned int __flags) __THROW;extern int inet6_rthdr_lasthop (struct cmsghdr *__cmsg, unsigned int __flags) __THROW;extern int inet6_rthdr_reverse (const struct cmsghdr *__in, struct cmsghdr *__out) __THROW;extern int inet6_rthdr_segments (const struct cmsghdr *__cmsg) __THROW;extern struct in6_addr *inet6_rthdr_getaddr (struct cmsghdr *__cmsg, int __index) __THROW;extern int inet6_rthdr_getflags (const struct cmsghdr *__cmsg, int __index) __THROW;#ifdef __USE_RFC3542extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __THROW;extern int inet6_opt_append (void *__extbuf, socklen_t __extlen, int __prevlen, uint8_t __type, socklen_t __len, uint8_t __align, void **__databufp) __THROW;extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __prevlen) __THROW;extern int inet6_opt_set_val (void *__extbuf, socklen_t __extlen, void *__val, int __vallen) __THROW;extern int inet6_opt_next (void *__extbuf, socklen_t __extlen, int __prevlen, uint8_t *__typep, socklen_t *__lenp, void **__databufp) __THROW;extern int inet6_opt_find (void *__extbuf, socklen_t __extlen, int __prevlen, uint8_t __type, socklen_t *__lenp, void **__databufp) __THROW;extern int inet6_opt_get_val (void *__databuf, socklen_t __offset, void *__val, int __vallen) __THROW;extern socklen_t inet6_rth_space (int __type, int __segments) __THROW;extern void *inet6_rth_init (void *__bp, int __bp_len, int __type, int __segments) __THROW;extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __THROW;extern int inet6_rth_reverse (const void *__in, void *__out) __THROW;extern int inet6_rth_segments (const void *__bp) __THROW;extern struct in6_addr *inet6_rth_getaddr (const void *__bp, int __index) __THROW;#endif__END_DECLS#endif /* netinet/in.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -