00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef INET_IN_H_
00012 #define INET_IN_H_
00013
00014
00015
00016
00017 #define IPPROTO_IP 0
00018 #define IPPROTO_HOPOPTS 0
00019 #define IPPROTO_ICMP 1
00020 #define IPPROTO_IGMP 2
00021 #define IPPROTO_GGP 3
00022 #define IPPROTO_IPV4 4
00023 #define IPPROTO_IPIP 4
00024 #define IPPROTO_TCP 6
00025 #define IPPROTO_EGP 8
00026 #define IPPROTO_PUP 12
00027 #define IPPROTO_UDP 17
00028 #define IPPROTO_IDP 22
00029 #define IPPROTO_TP 29
00030 #define IPPROTO_IPV6 41
00031 #define IPPROTO_ROUTING 43
00032 #define IPPROTO_FRAGMENT 44
00033 #define IPPROTO_RSVP 46
00034 #define IPPROTO_GRE 47
00035 #define IPPROTO_ESP 50
00036 #define IPPROTO_AH 51
00037 #define IPPROTO_MOBILE 55
00038 #define IPPROTO_IPV6_ICMP 58
00039 #define IPPROTO_ICMPV6 58
00040 #define IPPROTO_NONE 59
00041 #define IPPROTO_DSTOPTS 60
00042 #define IPPROTO_EON 80
00043 #define IPPROTO_ENCAP 98
00044 #define IPPROTO_PIM 103
00045 #define IPPROTO_IPCOMP 108
00046 #define IPPROTO_VRRP 112
00047
00048 #define IPPROTO_RAW 255
00049 #define IPPROTO_MAX 256
00050
00051
00052 enum {
00053 IPPORT_ECHO = 7,
00054 IPPORT_DISCARD = 9,
00055 IPPORT_SYSTAT = 11,
00056 IPPORT_DAYTIME = 13,
00057 IPPORT_NETSTAT = 15,
00058 IPPORT_FTP = 21,
00059 IPPORT_TELNET = 23,
00060 IPPORT_SMTP = 25,
00061 IPPORT_TIMESERVER = 37,
00062 IPPORT_NAMESERVER = 42,
00063 IPPORT_WHOIS = 43,
00064 IPPORT_MTP = 57,
00065
00066 IPPORT_TFTP = 69,
00067 IPPORT_RJE = 77,
00068 IPPORT_FINGER = 79,
00069 IPPORT_TTYLINK = 87,
00070 IPPORT_SUPDUP = 95,
00071
00072
00073 IPPORT_EXECSERVER = 512,
00074 IPPORT_LOGINSERVER = 513,
00075 IPPORT_CMDSERVER = 514,
00076 IPPORT_EFSSERVER = 520,
00077
00078
00079 IPPORT_BIFFUDP = 512,
00080 IPPORT_WHOSERVER = 513,
00081 IPPORT_ROUTESERVER = 520,
00082
00083
00084 IPPORT_RESERVED = 1024,
00085
00086
00087 IPPORT_USERRESERVED = 5000
00088 };
00089
00090
00091
00092
00093
00094 #define INET_ADDRSTRLEN 16
00095
00096 #define IP_ADDR_SIZE 4
00097
00098
00099 struct in_addr {
00100 in_addr_t s_addr;
00101 };
00102
00103 struct sockaddr_in {
00104 u_int8_t sin_len;
00105 u_int8_t sin_family;
00106 u_int16_t sin_port;
00107 struct in_addr sin_addr;
00108 u_int8_t sin_zero[8];
00109 };
00110
00111
00112
00113
00114
00115
00116 #define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
00117 #define IN_CLASSA_NET 0xff000000
00118 #define IN_CLASSA_NSHIFT 24
00119 #define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
00120 #define IN_CLASSA_MAX 128
00121
00122 #define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
00123 #define IN_CLASSB_NET 0xffff0000
00124 #define IN_CLASSB_NSHIFT 16
00125 #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
00126 #define IN_CLASSB_MAX 65536
00127
00128 #define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
00129 #define IN_CLASSC_NET 0xffffff00
00130 #define IN_CLASSC_NSHIFT 8
00131 #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
00132
00133 #define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
00134 #define IN_MULTICAST(a) IN_CLASSD(a)
00135
00136 #define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
00137 #define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
00138
00139
00140 #define INADDR_ANY ((in_addr_t) 0x00000000)
00141
00142 #define INADDR_BROADCAST ((in_addr_t) 0xffffffff)
00143
00144 #define INADDR_NONE ((in_addr_t) 0xffffffff)
00145
00146
00147 #define IN_LOOPBACKNET 127
00148
00149 #ifndef INADDR_LOOPBACK
00150 # define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
00151 #endif
00152
00153
00154 #define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000)
00155 #define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001)
00156 #define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002)
00157 #define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff)
00158
00159 #endif