update copyrights, rm unnecessary inet includes
[unix-history] / usr / src / sys / netinet / in.h
CommitLineData
8ae0e4b4 1/*
0880b18e 2 * Copyright (c) 1982, 1986 Regents of the University of California.
2b6b6284 3 * All rights reserved.
8ae0e4b4 4 *
2b6b6284
KB
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 *
8114dc67 12 * @(#)in.h 7.5 (Berkeley) %G%
8ae0e4b4 13 */
8958351e
BJ
14
15/*
16 * Constants and structures defined by the internet system,
17 * Per RFC 790, September 1981.
18 */
19
20/*
21 * Protocols
22 */
55f549b4 23#define IPPROTO_IP 0 /* dummy for IP */
8958351e 24#define IPPROTO_ICMP 1 /* control message protocol */
8114dc67 25#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
8958351e 26#define IPPROTO_TCP 6 /* tcp */
c49e68cc 27#define IPPROTO_EGP 8 /* exterior gateway protocol */
8958351e
BJ
28#define IPPROTO_PUP 12 /* pup */
29#define IPPROTO_UDP 17 /* user datagram protocol */
55f549b4 30#define IPPROTO_IDP 22 /* xns idp */
8958351e 31
13ab51b7 32#define IPPROTO_RAW 255 /* raw IP packet */
eb44bfb2
BJ
33#define IPPROTO_MAX 256
34
becdab37
BJ
35
36/*
37 * Ports < IPPORT_RESERVED are reserved for
38 * privileged processes (e.g. root).
f44e5691
MK
39 * Ports > IPPORT_USERRESERVED are reserved
40 * for servers, not necessarily privileged.
becdab37 41 */
1aa87517 42#define IPPORT_RESERVED 1024
f44e5691 43#define IPPORT_USERRESERVED 5000
1aa87517 44
8958351e
BJ
45/*
46 * Link numbers
47 */
48#define IMPLINK_IP 155
49#define IMPLINK_LOWEXPER 156
50#define IMPLINK_HIGHEXPER 158
51
52/*
e4dfb782 53 * Internet address (a structure for historical reasons)
8958351e 54 */
2b4b57cd 55struct in_addr {
e4dfb782 56 u_long s_addr;
8958351e 57};
2b4b57cd 58
ae34128e 59/*
a8d3bf7f 60 * Definitions of bits in internet address integers.
14c6a3d7
MK
61 * On subnets, the decomposition of addresses to host and net parts
62 * is done according to subnet mask, not the masks here.
ae34128e 63 */
8011f5df 64#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
a8d3bf7f
BJ
65#define IN_CLASSA_NET 0xff000000
66#define IN_CLASSA_NSHIFT 24
67#define IN_CLASSA_HOST 0x00ffffff
3adde5ac 68#define IN_CLASSA_MAX 128
a8d3bf7f 69
8011f5df 70#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
a8d3bf7f
BJ
71#define IN_CLASSB_NET 0xffff0000
72#define IN_CLASSB_NSHIFT 16
73#define IN_CLASSB_HOST 0x0000ffff
3adde5ac 74#define IN_CLASSB_MAX 65536
ae34128e 75
b4f9e9c7 76#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
a8d3bf7f
BJ
77#define IN_CLASSC_NET 0xffffff00
78#define IN_CLASSC_NSHIFT 8
79#define IN_CLASSC_HOST 0x000000ff
ae34128e 80
b4f9e9c7
MK
81#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
82#define IN_MULTICAST(i) IN_CLASSD(i)
83
84#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
85#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
86
8011f5df
MK
87#define INADDR_ANY (u_long)0x00000000
88#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
b410e761
MK
89#ifndef KERNEL
90#define INADDR_NONE 0xffffffff /* -1 return */
91#endif
3adde5ac 92
b4f9e9c7
MK
93#define IN_LOOPBACKNET 127 /* official! */
94
2b4b57cd
BJ
95/*
96 * Socket address, internet style.
97 */
98struct sockaddr_in {
99 short sin_family;
100 u_short sin_port;
101 struct in_addr sin_addr;
102 char sin_zero[8];
103};
eb2e4af9 104
55f549b4
MK
105/*
106 * Options for use with [gs]etsockopt at the IP level.
107 */
108#define IP_OPTIONS 1 /* set/get IP per-packet options */
109
59965020
BJ
110#ifdef KERNEL
111extern struct domain inetdomain;
112extern struct protosw inetsw[];
e4dfb782 113struct in_addr in_makeaddr();
8011f5df 114u_long in_netof(), in_lnaof();
59965020 115#endif