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