00001 /* 00002 netinet/in.h 00003 */ 00004 00005 #ifndef _NETINET__IN_H 00006 #define _NETINET__IN_H 00007 00008 /* Can we include <stdint.h> here or do we need an additional header that is 00009 * safe to include? 00010 */ 00011 #include <stdint.h> 00012 00013 /* Open Group Base Specifications Issue 6 (not complete) */ 00014 #define INADDR_ANY (uint32_t)0x00000000 00015 #define INADDR_BROADCAST (uint32_t)0xFFFFFFFF 00016 #define INADDR_LOOPBACK (uint32_t)0x7F000001 00017 00018 #define IN_LOOPBACKNET 127 00019 00020 #define IPPORT_RESERVED 1024 00021 00022 typedef uint16_t in_port_t; 00023 00024 #ifndef _IN_ADDR_T 00025 #define _IN_ADDR_T 00026 typedef uint32_t in_addr_t; 00027 #endif /* _IN_ADDR_T */ 00028 00029 #ifndef _SA_FAMILY_T 00030 #define _SA_FAMILY_T 00031 /* Should match corresponding typedef in <sys/socket.h> */ 00032 typedef uint8_t sa_family_t; 00033 #endif /* _SA_FAMILY_T */ 00034 00035 /* Protocols */ 00036 #define IPPROTO_IP 0 /* Dummy protocol */ 00037 #define IPPROTO_ICMP 1 /* ICMP */ 00038 #define IPPROTO_TCP 6 /* TCP */ 00039 #define IPPROTO_EGP 8 /* exterior gateway protocol */ 00040 #define IPPROTO_UDP 17 /* UDP */ 00041 00042 /* setsockopt options at IP level */ 00043 #define IP_ADD_MEMBERSHIP 12 00044 #define IP_DROP_MEMBERSHIP 13 00045 00046 #ifndef _STRUCT_IN_ADDR 00047 #define _STRUCT_IN_ADDR 00048 struct in_addr 00049 { 00050 in_addr_t s_addr; 00051 }; 00052 #endif 00053 00054 struct sockaddr_in 00055 { 00056 sa_family_t sin_family; 00057 in_port_t sin_port; 00058 struct in_addr sin_addr; 00059 }; 00060 00061 struct ip_mreq 00062 { 00063 struct in_addr imr_multiaddr; 00064 struct in_addr imr_interface; 00065 }; 00066 00067 /* 00068 * IPv6 is not supported, but some programs need these declarations 00069 * nevertheless; these declarations are based on 00070 * http://www.opengroup.org/onlinepubs/000095399/basedefs/netinet/in.h.html 00071 */ 00072 struct in6_addr 00073 { 00074 uint8_t s6_addr[16]; 00075 }; 00076 00077 struct sockaddr_in6 00078 { 00079 sa_family_t sin6_family; 00080 in_port_t sin6_port; 00081 uint32_t sin6_flowinfo; 00082 struct in6_addr sin6_addr; 00083 uint32_t sin6_scope_id; 00084 }; 00085 00086 #define INET6_ADDRSTRLEN 46 00087 00088 /* Definitions that are not part of the Open Group Base Specifications */ 00089 #define IN_CLASSA(i) (((uint32_t)(i) & 0x80000000) == 0) 00090 #define IN_CLASSA_NET 0xff000000 00091 #define IN_CLASSA_NSHIFT 24 00092 00093 #define IN_CLASSB(i) (((uint32_t)(i) & 0xc0000000) == 0x80000000) 00094 #define IN_CLASSB_NET 0xffff0000 00095 #define IN_CLASSB_NSHIFT 16 00096 00097 #define IN_CLASSC(i) (((uint32_t)(i) & 0xe0000000) == 0xc0000000) 00098 #define IN_CLASSC_NET 0xffffff00 00099 #define IN_CLASSC_NSHIFT 8 00100 00101 #define IN_CLASSD(i) (((uint32_t)(i) & 0xf0000000) == 0xe0000000) 00102 #define IN_CLASSD_NET 0xf0000000 00103 #define IN_CLASSD_NSHIFT 28 00104 00105 #endif /* _NETINET__IN_H */
1.5.8