add EGP
[unix-history] / usr / src / sys / netinet / in.h
CommitLineData
c49e68cc 1/* in.h 6.3 84/07/31 */
8958351e
BJ
2
3/*
4 * Constants and structures defined by the internet system,
5 * Per RFC 790, September 1981.
6 */
7
8/*
9 * Protocols
10 */
11#define IPPROTO_ICMP 1 /* control message protocol */
1aa87517 12#define IPPROTO_GGP 2 /* gateway^2 (deprecated) */
8958351e 13#define IPPROTO_TCP 6 /* tcp */
c49e68cc 14#define IPPROTO_EGP 8 /* exterior gateway protocol */
8958351e
BJ
15#define IPPROTO_PUP 12 /* pup */
16#define IPPROTO_UDP 17 /* user datagram protocol */
3d7e280a 17#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
8958351e 18
13ab51b7 19#define IPPROTO_RAW 255 /* raw IP packet */
eb44bfb2
BJ
20#define IPPROTO_MAX 256
21
8958351e
BJ
22/*
23 * Port/socket numbers: network standard functions
24 */
25#define IPPORT_ECHO 7
26#define IPPORT_DISCARD 9
27#define IPPORT_SYSTAT 11
28#define IPPORT_DAYTIME 13
29#define IPPORT_NETSTAT 15
30#define IPPORT_FTP 21
31#define IPPORT_TELNET 23
32#define IPPORT_SMTP 25
33#define IPPORT_TIMESERVER 37
34#define IPPORT_NAMESERVER 42
35#define IPPORT_WHOIS 43
36#define IPPORT_MTP 57
37
38/*
39 * Port/socket numbers: host specific functions
40 */
41#define IPPORT_TFTP 69
42#define IPPORT_RJE 77
43#define IPPORT_FINGER 79
44#define IPPORT_TTYLINK 87
45#define IPPORT_SUPDUP 95
46
becdab37
BJ
47/*
48 * UNIX TCP sockets
49 */
50#define IPPORT_EXECSERVER 512
51#define IPPORT_LOGINSERVER 513
52#define IPPORT_CMDSERVER 514
40f07a3b 53#define IPPORT_EFSSERVER 520
becdab37
BJ
54
55/*
56 * UNIX UDP sockets
57 */
58#define IPPORT_BIFFUDP 512
59#define IPPORT_WHOSERVER 513
40f07a3b 60#define IPPORT_ROUTESERVER 520 /* 520+1 also used */
becdab37
BJ
61
62/*
63 * Ports < IPPORT_RESERVED are reserved for
64 * privileged processes (e.g. root).
65 */
1aa87517
BJ
66#define IPPORT_RESERVED 1024
67
8958351e
BJ
68/*
69 * Link numbers
70 */
71#define IMPLINK_IP 155
72#define IMPLINK_LOWEXPER 156
73#define IMPLINK_HIGHEXPER 158
74
75/*
76 * Internet address (old style... should be updated)
77 */
2b4b57cd 78struct in_addr {
8958351e
BJ
79 union {
80 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
81 struct { u_short s_w1,s_w2; } S_un_w;
1a88ef94 82 u_long S_addr;
8958351e 83 } S_un;
1a88ef94 84#define s_addr S_un.S_addr /* can be used for most tcp & ip code */
8958351e
BJ
85#define s_host S_un.S_un_b.s_b2 /* host on imp */
86#define s_net S_un.S_un_b.s_b1 /* network */
87#define s_imp S_un.S_un_w.s_w2 /* imp */
1e25d807
BJ
88#define s_impno S_un.S_un_b.s_b4 /* imp # */
89#define s_lh S_un.S_un_b.s_b3 /* logical host */
8958351e 90};
2b4b57cd 91
ae34128e 92/*
a8d3bf7f 93 * Definitions of bits in internet address integers.
ae34128e 94 */
6e7edb25 95#define IN_CLASSA(i) ((((long)(i))&0x80000000)==0)
a8d3bf7f
BJ
96#define IN_CLASSA_NET 0xff000000
97#define IN_CLASSA_NSHIFT 24
98#define IN_CLASSA_HOST 0x00ffffff
3adde5ac 99#define IN_CLASSA_MAX 128
a8d3bf7f 100
6e7edb25 101#define IN_CLASSB(i) ((((long)(i))&0xc0000000)==0x80000000)
a8d3bf7f
BJ
102#define IN_CLASSB_NET 0xffff0000
103#define IN_CLASSB_NSHIFT 16
104#define IN_CLASSB_HOST 0x0000ffff
3adde5ac 105#define IN_CLASSB_MAX 65536
ae34128e 106
6e7edb25 107#define IN_CLASSC(i) ((((long)(i))&0xc0000000)==0xc0000000)
a8d3bf7f
BJ
108#define IN_CLASSC_NET 0xffffff00
109#define IN_CLASSC_NSHIFT 8
110#define IN_CLASSC_HOST 0x000000ff
ae34128e 111
1aa87517
BJ
112#define INADDR_ANY 0x00000000
113
3adde5ac
MK
114/*
115 * Macros for subnetworks. A subnet is distinguished by
116 * (1) the network number is a `local' network number, and
117 * (2) the most significant bit of the host part is set.
118 * Such addresses include one additional byte in the network number,
119 * and use one less byte in the host part (i.e., a subnet of a Class A
120 * network uses the rules for Class B net/host number extraction,
121 * a Class B subnet is dealt with as if it were a Class C net).
122 * Subnets of Class C nets are not supported.
123 */
124#define SUBNETSHIFT 8 /* used to get main net number from subnet */
125
126#define IN_SUBNETA(i) ((((long)(i))&0x80800000)==0x00800000)
127#define IN_CLASSA_SUBNET 0xffff0000
128#define IN_CLASSA_SUBNSHIFT (IN_CLASSA_NSHIFT - SUBNETSHIFT)
129#define IN_CLASSA_SUBHOST 0x0000ffff
130
131#define IN_SUBNETB(i) ((((long)(i))&0xc0008000)==0x80008000)
132#define IN_CLASSB_SUBNET 0xffffff00
133#define IN_CLASSB_SUBNSHIFT (IN_CLASSB_NSHIFT - SUBNETSHIFT)
134#define IN_CLASSA_SUBHOST 0x0000ffff
135#define IN_CLASSB_SUBHOST 0x000000ff
136
2b4b57cd
BJ
137/*
138 * Socket address, internet style.
139 */
140struct sockaddr_in {
141 short sin_family;
142 u_short sin_port;
143 struct in_addr sin_addr;
144 char sin_zero[8];
145};
eb2e4af9
BJ
146
147#if !defined(vax)
148/*
149 * Macros for number representation conversion.
150 */
151#define ntohl(x) (x)
152#define ntohs(x) (x)
153#define htonl(x) (x)
154#define htons(x) (x)
155#endif
59965020
BJ
156
157#ifdef KERNEL
158extern struct domain inetdomain;
159extern struct protosw inetsw[];
160#endif