xref: /titanic_52/usr/src/lib/libbc/inc/include/netinet/in.h (revision 0eb822a1c0c2bea495647510b75f77f0e57633eb)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that this notice is preserved and that due credit is given
7  * to the University of California at Berkeley. The name of the University
8  * may not be used to endorse or promote products derived from this
9  * software without specific prior written permission. This software
10  * is provided ``as is'' without express or implied warranty.
11  */
12 
13 /*
14  * Constants and structures defined by the internet system,
15  * Per RFC 790, September 1981.
16  */
17 
18 #ifndef _netinet_in_h
19 #define _netinet_in_h
20 
21 #pragma ident	"%Z%%M%	%I%	%E% SMI"
22 
23 /*
24  * Protocols
25  */
26 #define	IPPROTO_IP		0		/* dummy for IP */
27 #define	IPPROTO_ICMP		1		/* control message protocol */
28 #define IPPROTO_IGMP		2		/* group control protocol */
29 #define	IPPROTO_GGP		3		/* gateway^2 (deprecated) */
30 #define	IPPROTO_TCP		6		/* tcp */
31 #define	IPPROTO_EGP		8		/* exterior gateway protocol */
32 #define	IPPROTO_PUP		12		/* pup */
33 #define	IPPROTO_UDP		17		/* user datagram protocol */
34 #define	IPPROTO_IDP		22		/* xns idp */
35 #define IPPROTO_HELLO		63		/* "hello" routing protocol */
36 #define	IPPROTO_ND		77		/* UNOFFICIAL net disk proto */
37 
38 #define	IPPROTO_RAW		255		/* raw IP packet */
39 #define	IPPROTO_MAX		256
40 
41 /*
42  * Port/socket numbers: network standard functions
43  */
44 #define	IPPORT_ECHO		7
45 #define	IPPORT_DISCARD		9
46 #define	IPPORT_SYSTAT		11
47 #define	IPPORT_DAYTIME		13
48 #define	IPPORT_NETSTAT		15
49 #define	IPPORT_FTP		21
50 #define	IPPORT_TELNET		23
51 #define	IPPORT_SMTP		25
52 #define	IPPORT_TIMESERVER	37
53 #define	IPPORT_NAMESERVER	42
54 #define	IPPORT_WHOIS		43
55 #define	IPPORT_MTP		57
56 
57 /*
58  * Port/socket numbers: host specific functions
59  */
60 #define	IPPORT_TFTP		69
61 #define	IPPORT_RJE		77
62 #define	IPPORT_FINGER		79
63 #define	IPPORT_TTYLINK		87
64 #define	IPPORT_SUPDUP		95
65 
66 /*
67  * UNIX TCP sockets
68  */
69 #define	IPPORT_EXECSERVER	512
70 #define	IPPORT_LOGINSERVER	513
71 #define	IPPORT_CMDSERVER	514
72 #define	IPPORT_EFSSERVER	520
73 
74 /*
75  * UNIX UDP sockets
76  */
77 #define	IPPORT_BIFFUDP		512
78 #define	IPPORT_WHOSERVER	513
79 #define	IPPORT_ROUTESERVER	520	/* 520+1 also used */
80 
81 /*
82  * Ports < IPPORT_RESERVED are reserved for
83  * privileged processes (e.g. root).
84  * Ports > IPPORT_USERRESERVED are reserved
85  * for servers, not necessarily privileged.
86  */
87 #define	IPPORT_RESERVED		1024
88 #define	IPPORT_USERRESERVED	5000
89 
90 /*
91  * Link numbers
92  */
93 #define	IMPLINK_IP		155
94 #define	IMPLINK_LOWEXPER	156
95 #define	IMPLINK_HIGHEXPER	158
96 
97 /*
98  * Internet address
99  *	This definition contains obsolete fields for compatibility
100  *	with SunOS 3.x and 4.2bsd.  The presence of subnets renders
101  *	divisions into fixed fields misleading at best.  New code
102  *	should use only the s_addr field.
103  */
104 struct in_addr {
105 	union {
106 		struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
107 		struct { u_short s_w1,s_w2; } S_un_w;
108 		u_long S_addr;
109 	} S_un;
110 #define	s_addr	S_un.S_addr		/* should be used for all code */
111 #define	s_host	S_un.S_un_b.s_b2	/* OBSOLETE: host on imp */
112 #define	s_net	S_un.S_un_b.s_b1	/* OBSOLETE: network */
113 #define	s_imp	S_un.S_un_w.s_w2	/* OBSOLETE: imp */
114 #define	s_impno	S_un.S_un_b.s_b4	/* OBSOLETE: imp # */
115 #define	s_lh	S_un.S_un_b.s_b3	/* OBSOLETE: logical host */
116 };
117 
118 /*
119  * Definitions of bits in internet address integers.
120  * On subnets, the decomposition of addresses to host and net parts
121  * is done according to subnet mask, not the masks here.
122  */
123 #define	IN_CLASSA(i)		(((long)(i) & 0x80000000) == 0)
124 #define	IN_CLASSA_NET		0xff000000
125 #define	IN_CLASSA_NSHIFT	24
126 #define	IN_CLASSA_HOST		0x00ffffff
127 #define	IN_CLASSA_MAX		128
128 
129 #define	IN_CLASSB(i)		(((long)(i) & 0xc0000000) == 0x80000000)
130 #define	IN_CLASSB_NET		0xffff0000
131 #define	IN_CLASSB_NSHIFT	16
132 #define	IN_CLASSB_HOST		0x0000ffff
133 #define	IN_CLASSB_MAX		65536
134 
135 #define	IN_CLASSC(i)		(((long)(i) & 0xe0000000) == 0xc0000000)
136 #define	IN_CLASSC_NET		0xffffff00
137 #define	IN_CLASSC_NSHIFT	8
138 #define	IN_CLASSC_HOST		0x000000ff
139 
140 #define	IN_CLASSD(i)		(((long)(i) & 0xf0000000) == 0xe0000000)
141 #define	IN_MULTICAST(i)		IN_CLASSD(i)
142 
143 #define	IN_EXPERIMENTAL(i)	(((long)(i) & 0xe0000000) == 0xe0000000)
144 #define	IN_BADCLASS(i)		(((long)(i) & 0xf0000000) == 0xf0000000)
145 
146 #define	INADDR_ANY		(u_long)0x00000000
147 #define	INADDR_LOOPBACK		(u_long)0x7F000001
148 #define	INADDR_BROADCAST	(u_long)0xffffffff	/* must be masked */
149 
150 #define	IN_LOOPBACKNET		127			/* official! */
151 
152 /*
153  * Define a macro to stuff the loopback address into an Internet address
154  */
155 #define IN_SET_LOOPBACK_ADDR(a)	{(a)->sin_addr.s_addr  = htonl(INADDR_LOOPBACK); \
156 	(a)->sin_family = AF_INET;}
157 
158 /*
159  * Socket address, internet style.
160  */
161 struct sockaddr_in {
162 	short	sin_family;
163 	u_short	sin_port;
164 	struct	in_addr sin_addr;
165 	char	sin_zero[8];
166 };
167 
168 /*
169  * Options for use with [gs]etsockopt at the IP level.
170  */
171 #define	IP_OPTIONS	1		/* set/get IP per-packet options */
172 
173 #if !defined(vax) && !defined(ntohl) && !defined(lint) && !defined(i386)
174 /*
175  * Macros for number representation conversion.
176  */
177 #define	ntohl(x)	(x)
178 #define	ntohs(x)	(x)
179 #define	htonl(x)	(x)
180 #define	htons(x)	(x)
181 #endif
182 
183 #if !defined(ntohl) && (defined(vax) || defined(lint) || defined(i386))
184 u_short	ntohs(), htons();
185 u_long	ntohl(), htonl();
186 #endif
187 
188 #ifdef KERNEL
189 extern	struct domain inetdomain;
190 extern	struct protosw inetsw[];
191 struct	in_addr in_makeaddr();
192 u_long	in_netof(), in_lnaof();
193 #endif
194 
195 #endif /*!_netinet_in_h*/
196