Commit | Line | Data |
---|---|---|
8ae0e4b4 | 1 | /* |
0880b18e | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
2b6b6284 | 3 | * All rights reserved. |
8ae0e4b4 | 4 | * |
2b6b6284 | 5 | * Redistribution and use in source and binary forms are permitted |
616d42db KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
2b6b6284 | 16 | * |
616d42db | 17 | * @(#)in.h 7.6 (Berkeley) %G% |
8ae0e4b4 | 18 | */ |
8958351e BJ |
19 | |
20 | /* | |
21 | * Constants and structures defined by the internet system, | |
22 | * Per RFC 790, September 1981. | |
23 | */ | |
24 | ||
25 | /* | |
26 | * Protocols | |
27 | */ | |
55f549b4 | 28 | #define IPPROTO_IP 0 /* dummy for IP */ |
8958351e | 29 | #define IPPROTO_ICMP 1 /* control message protocol */ |
8114dc67 | 30 | #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ |
8958351e | 31 | #define IPPROTO_TCP 6 /* tcp */ |
c49e68cc | 32 | #define IPPROTO_EGP 8 /* exterior gateway protocol */ |
8958351e BJ |
33 | #define IPPROTO_PUP 12 /* pup */ |
34 | #define IPPROTO_UDP 17 /* user datagram protocol */ | |
55f549b4 | 35 | #define IPPROTO_IDP 22 /* xns idp */ |
8958351e | 36 | |
13ab51b7 | 37 | #define IPPROTO_RAW 255 /* raw IP packet */ |
eb44bfb2 BJ |
38 | #define IPPROTO_MAX 256 |
39 | ||
becdab37 BJ |
40 | |
41 | /* | |
42 | * Ports < IPPORT_RESERVED are reserved for | |
43 | * privileged processes (e.g. root). | |
f44e5691 MK |
44 | * Ports > IPPORT_USERRESERVED are reserved |
45 | * for servers, not necessarily privileged. | |
becdab37 | 46 | */ |
1aa87517 | 47 | #define IPPORT_RESERVED 1024 |
f44e5691 | 48 | #define IPPORT_USERRESERVED 5000 |
1aa87517 | 49 | |
8958351e BJ |
50 | /* |
51 | * Link numbers | |
52 | */ | |
53 | #define IMPLINK_IP 155 | |
54 | #define IMPLINK_LOWEXPER 156 | |
55 | #define IMPLINK_HIGHEXPER 158 | |
56 | ||
57 | /* | |
e4dfb782 | 58 | * Internet address (a structure for historical reasons) |
8958351e | 59 | */ |
2b4b57cd | 60 | struct in_addr { |
e4dfb782 | 61 | u_long s_addr; |
8958351e | 62 | }; |
2b4b57cd | 63 | |
ae34128e | 64 | /* |
a8d3bf7f | 65 | * Definitions of bits in internet address integers. |
14c6a3d7 MK |
66 | * On subnets, the decomposition of addresses to host and net parts |
67 | * is done according to subnet mask, not the masks here. | |
ae34128e | 68 | */ |
8011f5df | 69 | #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) |
a8d3bf7f BJ |
70 | #define IN_CLASSA_NET 0xff000000 |
71 | #define IN_CLASSA_NSHIFT 24 | |
72 | #define IN_CLASSA_HOST 0x00ffffff | |
3adde5ac | 73 | #define IN_CLASSA_MAX 128 |
a8d3bf7f | 74 | |
8011f5df | 75 | #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) |
a8d3bf7f BJ |
76 | #define IN_CLASSB_NET 0xffff0000 |
77 | #define IN_CLASSB_NSHIFT 16 | |
78 | #define IN_CLASSB_HOST 0x0000ffff | |
3adde5ac | 79 | #define IN_CLASSB_MAX 65536 |
ae34128e | 80 | |
b4f9e9c7 | 81 | #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) |
a8d3bf7f BJ |
82 | #define IN_CLASSC_NET 0xffffff00 |
83 | #define IN_CLASSC_NSHIFT 8 | |
84 | #define IN_CLASSC_HOST 0x000000ff | |
ae34128e | 85 | |
b4f9e9c7 MK |
86 | #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) |
87 | #define IN_MULTICAST(i) IN_CLASSD(i) | |
88 | ||
89 | #define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) | |
90 | #define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) | |
91 | ||
8011f5df MK |
92 | #define INADDR_ANY (u_long)0x00000000 |
93 | #define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */ | |
b410e761 MK |
94 | #ifndef KERNEL |
95 | #define INADDR_NONE 0xffffffff /* -1 return */ | |
96 | #endif | |
3adde5ac | 97 | |
b4f9e9c7 MK |
98 | #define IN_LOOPBACKNET 127 /* official! */ |
99 | ||
2b4b57cd BJ |
100 | /* |
101 | * Socket address, internet style. | |
102 | */ | |
103 | struct sockaddr_in { | |
104 | short sin_family; | |
105 | u_short sin_port; | |
106 | struct in_addr sin_addr; | |
107 | char sin_zero[8]; | |
108 | }; | |
eb2e4af9 | 109 | |
55f549b4 MK |
110 | /* |
111 | * Options for use with [gs]etsockopt at the IP level. | |
112 | */ | |
113 | #define IP_OPTIONS 1 /* set/get IP per-packet options */ | |
114 | ||
59965020 BJ |
115 | #ifdef KERNEL |
116 | extern struct domain inetdomain; | |
117 | extern struct protosw inetsw[]; | |
e4dfb782 | 118 | struct in_addr in_makeaddr(); |
8011f5df | 119 | u_long in_netof(), in_lnaof(); |
59965020 | 120 | #endif |