2 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
5 * Copyright (c) 1982, 1986 Regents of the University of California.
8 * Redistribution and use in source and binary forms are permitted
9 * provided that this notice is preserved and that due credit is given
10 * to the University of California at Berkeley. The name of the University
11 * may not be used to endorse or promote products derived from this
12 * software without specific prior written permission. This software
13 * is provided ``as is'' without express or implied warranty.
17 * Constants and structures defined by the internet system,
18 * Per RFC 790, September 1981.
24 #pragma ident "%Z%%M% %I% %E% SMI"
29 #define IPPROTO_IP 0 /* dummy for IP */
30 #define IPPROTO_ICMP 1 /* control message protocol */
31 #define IPPROTO_IGMP 2 /* group control protocol */
32 #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
33 #define IPPROTO_TCP 6 /* tcp */
34 #define IPPROTO_EGP 8 /* exterior gateway protocol */
35 #define IPPROTO_PUP 12 /* pup */
36 #define IPPROTO_UDP 17 /* user datagram protocol */
37 #define IPPROTO_IDP 22 /* xns idp */
38 #define IPPROTO_HELLO 63 /* "hello" routing protocol */
39 #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
41 #define IPPROTO_RAW 255 /* raw IP packet */
42 #define IPPROTO_MAX 256
45 * Port/socket numbers: network standard functions
48 #define IPPORT_DISCARD 9
49 #define IPPORT_SYSTAT 11
50 #define IPPORT_DAYTIME 13
51 #define IPPORT_NETSTAT 15
53 #define IPPORT_TELNET 23
54 #define IPPORT_SMTP 25
55 #define IPPORT_TIMESERVER 37
56 #define IPPORT_NAMESERVER 42
57 #define IPPORT_WHOIS 43
61 * Port/socket numbers: host specific functions
63 #define IPPORT_TFTP 69
65 #define IPPORT_FINGER 79
66 #define IPPORT_TTYLINK 87
67 #define IPPORT_SUPDUP 95
72 #define IPPORT_EXECSERVER 512
73 #define IPPORT_LOGINSERVER 513
74 #define IPPORT_CMDSERVER 514
75 #define IPPORT_EFSSERVER 520
80 #define IPPORT_BIFFUDP 512
81 #define IPPORT_WHOSERVER 513
82 #define IPPORT_ROUTESERVER 520 /* 520+1 also used */
85 * Ports < IPPORT_RESERVED are reserved for
86 * privileged processes (e.g. root).
87 * Ports > IPPORT_USERRESERVED are reserved
88 * for servers, not necessarily privileged.
90 #define IPPORT_RESERVED 1024
91 #define IPPORT_USERRESERVED 5000
96 #define IMPLINK_IP 155
97 #define IMPLINK_LOWEXPER 156
98 #define IMPLINK_HIGHEXPER 158
102 * This definition contains obsolete fields for compatibility
103 * with SunOS 3.x and 4.2bsd. The presence of subnets renders
104 * divisions into fixed fields misleading at best. New code
105 * should use only the s_addr field.
109 struct { u_char s_b1
,s_b2
,s_b3
,s_b4
; } S_un_b
;
110 struct { u_short s_w1
,s_w2
; } S_un_w
;
113 #define s_addr S_un.S_addr /* should be used for all code */
114 #define s_host S_un.S_un_b.s_b2 /* OBSOLETE: host on imp */
115 #define s_net S_un.S_un_b.s_b1 /* OBSOLETE: network */
116 #define s_imp S_un.S_un_w.s_w2 /* OBSOLETE: imp */
117 #define s_impno S_un.S_un_b.s_b4 /* OBSOLETE: imp # */
118 #define s_lh S_un.S_un_b.s_b3 /* OBSOLETE: logical host */
122 * Definitions of bits in internet address integers.
123 * On subnets, the decomposition of addresses to host and net parts
124 * is done according to subnet mask, not the masks here.
126 * Note that with the introduction of CIDR, IN_CLASSA, IN_CLASSB,
127 * IN_CLASSC, IN_CLASSD and IN_CLASSE macros have become "de-facto obsolete".
128 * IN_MULTICAST macro should be used to test if a address is a
131 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
132 #define IN_CLASSA_NET 0xff000000
133 #define IN_CLASSA_NSHIFT 24
134 #define IN_CLASSA_HOST 0x00ffffff
135 #define IN_CLASSA_MAX 128
137 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
138 #define IN_CLASSB_NET 0xffff0000
139 #define IN_CLASSB_NSHIFT 16
140 #define IN_CLASSB_HOST 0x0000ffff
141 #define IN_CLASSB_MAX 65536
143 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
144 #define IN_CLASSC_NET 0xffffff00
145 #define IN_CLASSC_NSHIFT 8
146 #define IN_CLASSC_HOST 0x000000ff
148 #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
149 #define IN_MULTICAST(i) IN_CLASSD(i)
151 #define IN_CLASSE(i) (((long)(i) & 0xf0000000) == 0xf0000000)
153 #define IN_CLASSE_NET 0xffffffff
156 * We have removed CLASS E checks from the kernel
157 * But we preserve these defines for userland in order
158 * to avoid compile breakage of some 3rd party piece of software
161 #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
162 #define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
165 #define INADDR_ANY (u_long)0x00000000
166 #define INADDR_LOOPBACK (u_long)0x7F000001
167 #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
169 #define IN_LOOPBACKNET 127 /* official! */
172 * Define a macro to stuff the loopback address into an Internet address
174 #define IN_SET_LOOPBACK_ADDR(a) {(a)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); \
175 (a)->sin_family = AF_INET;}
178 * Socket address, internet style.
183 struct in_addr sin_addr
;
188 * Options for use with [gs]etsockopt at the IP level.
190 #define IP_OPTIONS 1 /* set/get IP per-packet options */
192 #if !defined(vax) && !defined(ntohl) && !defined(lint) && !defined(i386)
194 * Macros for number representation conversion.
202 #if !defined(ntohl) && (defined(vax) || defined(lint) || defined(i386))
203 u_short
ntohs(), htons();
204 u_long
ntohl(), htonl();
208 extern struct domain inetdomain
;
209 extern struct protosw inetsw
[];
210 struct in_addr
in_makeaddr();
211 u_long
in_netof(), in_lnaof();
214 #endif /* !_netinet_in_h */