xref: /csrg-svn/sys/netinet/in.h (revision 23556)
1 /*
2  * Copyright (c) 1982 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)in.h	6.6 (Berkeley) 06/19/85
7  */
8 
9 /*
10  * Constants and structures defined by the internet system,
11  * Per RFC 790, September 1981.
12  */
13 
14 /*
15  * Protocols
16  */
17 #define	IPPROTO_ICMP		1		/* control message protocol */
18 #define	IPPROTO_GGP		2		/* gateway^2 (deprecated) */
19 #define	IPPROTO_TCP		6		/* tcp */
20 #define	IPPROTO_EGP		8		/* exterior gateway protocol */
21 #define	IPPROTO_PUP		12		/* pup */
22 #define	IPPROTO_UDP		17		/* user datagram protocol */
23 
24 #define	IPPROTO_RAW		255		/* raw IP packet */
25 #define	IPPROTO_MAX		256
26 
27 
28 /*
29  * Ports < IPPORT_RESERVED are reserved for
30  * privileged processes (e.g. root).
31  */
32 #define	IPPORT_RESERVED		1024
33 
34 /*
35  * Link numbers
36  */
37 #define	IMPLINK_IP		155
38 #define	IMPLINK_LOWEXPER	156
39 #define	IMPLINK_HIGHEXPER	158
40 
41 /*
42  * Internet address (a structure for historical reasons)
43  */
44 struct in_addr {
45 	u_long s_addr;
46 };
47 
48 /*
49  * Definitions of bits in internet address integers.
50  * On subnets, the decomposition of addresses to host and net parts
51  * is done according to subnet mask, not the masks here.
52  */
53 #define	IN_CLASSA(i)		((((long)(i))&0x80000000)==0)
54 #define	IN_CLASSA_NET		0xff000000
55 #define	IN_CLASSA_NSHIFT	24
56 #define	IN_CLASSA_HOST		0x00ffffff
57 #define	IN_CLASSA_MAX		128
58 
59 #define	IN_CLASSB(i)		((((long)(i))&0xc0000000)==0x80000000)
60 #define	IN_CLASSB_NET		0xffff0000
61 #define	IN_CLASSB_NSHIFT	16
62 #define	IN_CLASSB_HOST		0x0000ffff
63 #define	IN_CLASSB_MAX		65536
64 
65 #define	IN_CLASSC(i)		((((long)(i))&0xc0000000)==0xc0000000)
66 #define	IN_CLASSC_NET		0xffffff00
67 #define	IN_CLASSC_NSHIFT	8
68 #define	IN_CLASSC_HOST		0x000000ff
69 
70 #define	INADDR_ANY		0x00000000
71 #define	INADDR_BROADCAST	0xffffffff		/* must be masked */
72 
73 /*
74  * Socket address, internet style.
75  */
76 struct sockaddr_in {
77 	short	sin_family;
78 	u_short	sin_port;
79 	struct	in_addr sin_addr;
80 	char	sin_zero[8];
81 };
82 
83 #if !defined(vax)
84 /*
85  * Macros for number representation conversion.
86  */
87 #define	ntohl(x)	(x)
88 #define	ntohs(x)	(x)
89 #define	htonl(x)	(x)
90 #define	htons(x)	(x)
91 #endif
92 
93 #ifdef KERNEL
94 extern	struct domain inetdomain;
95 extern	struct protosw inetsw[];
96 struct	in_addr in_makeaddr();
97 #endif
98