Commit | Line | Data |
---|---|---|
8ae0e4b4 KM |
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 | * | |
c28628c9 | 6 | * @(#)in.h 6.8 (Berkeley) %G% |
8ae0e4b4 | 7 | */ |
8958351e BJ |
8 | |
9 | /* | |
10 | * Constants and structures defined by the internet system, | |
11 | * Per RFC 790, September 1981. | |
12 | */ | |
13 | ||
14 | /* | |
15 | * Protocols | |
16 | */ | |
55f549b4 | 17 | #define IPPROTO_IP 0 /* dummy for IP */ |
8958351e | 18 | #define IPPROTO_ICMP 1 /* control message protocol */ |
1aa87517 | 19 | #define IPPROTO_GGP 2 /* gateway^2 (deprecated) */ |
8958351e | 20 | #define IPPROTO_TCP 6 /* tcp */ |
c49e68cc | 21 | #define IPPROTO_EGP 8 /* exterior gateway protocol */ |
8958351e BJ |
22 | #define IPPROTO_PUP 12 /* pup */ |
23 | #define IPPROTO_UDP 17 /* user datagram protocol */ | |
55f549b4 | 24 | #define IPPROTO_IDP 22 /* xns idp */ |
8958351e | 25 | |
13ab51b7 | 26 | #define IPPROTO_RAW 255 /* raw IP packet */ |
eb44bfb2 BJ |
27 | #define IPPROTO_MAX 256 |
28 | ||
becdab37 BJ |
29 | |
30 | /* | |
31 | * Ports < IPPORT_RESERVED are reserved for | |
32 | * privileged processes (e.g. root). | |
33 | */ | |
1aa87517 BJ |
34 | #define IPPORT_RESERVED 1024 |
35 | ||
8958351e BJ |
36 | /* |
37 | * Link numbers | |
38 | */ | |
39 | #define IMPLINK_IP 155 | |
40 | #define IMPLINK_LOWEXPER 156 | |
41 | #define IMPLINK_HIGHEXPER 158 | |
42 | ||
43 | /* | |
e4dfb782 | 44 | * Internet address (a structure for historical reasons) |
8958351e | 45 | */ |
2b4b57cd | 46 | struct in_addr { |
e4dfb782 | 47 | u_long s_addr; |
8958351e | 48 | }; |
2b4b57cd | 49 | |
ae34128e | 50 | /* |
a8d3bf7f | 51 | * Definitions of bits in internet address integers. |
14c6a3d7 MK |
52 | * On subnets, the decomposition of addresses to host and net parts |
53 | * is done according to subnet mask, not the masks here. | |
ae34128e | 54 | */ |
6e7edb25 | 55 | #define IN_CLASSA(i) ((((long)(i))&0x80000000)==0) |
a8d3bf7f BJ |
56 | #define IN_CLASSA_NET 0xff000000 |
57 | #define IN_CLASSA_NSHIFT 24 | |
58 | #define IN_CLASSA_HOST 0x00ffffff | |
3adde5ac | 59 | #define IN_CLASSA_MAX 128 |
a8d3bf7f | 60 | |
6e7edb25 | 61 | #define IN_CLASSB(i) ((((long)(i))&0xc0000000)==0x80000000) |
a8d3bf7f BJ |
62 | #define IN_CLASSB_NET 0xffff0000 |
63 | #define IN_CLASSB_NSHIFT 16 | |
64 | #define IN_CLASSB_HOST 0x0000ffff | |
3adde5ac | 65 | #define IN_CLASSB_MAX 65536 |
ae34128e | 66 | |
6e7edb25 | 67 | #define IN_CLASSC(i) ((((long)(i))&0xc0000000)==0xc0000000) |
a8d3bf7f BJ |
68 | #define IN_CLASSC_NET 0xffffff00 |
69 | #define IN_CLASSC_NSHIFT 8 | |
70 | #define IN_CLASSC_HOST 0x000000ff | |
ae34128e | 71 | |
e4dfb782 | 72 | #define INADDR_ANY 0x00000000 |
14c6a3d7 | 73 | #define INADDR_BROADCAST 0xffffffff /* must be masked */ |
3adde5ac | 74 | |
2b4b57cd BJ |
75 | /* |
76 | * Socket address, internet style. | |
77 | */ | |
78 | struct sockaddr_in { | |
79 | short sin_family; | |
80 | u_short sin_port; | |
81 | struct in_addr sin_addr; | |
82 | char sin_zero[8]; | |
83 | }; | |
eb2e4af9 | 84 | |
55f549b4 MK |
85 | /* |
86 | * Options for use with [gs]etsockopt at the IP level. | |
87 | */ | |
88 | #define IP_OPTIONS 1 /* set/get IP per-packet options */ | |
89 | ||
eb2e4af9 BJ |
90 | #if !defined(vax) |
91 | /* | |
92 | * Macros for number representation conversion. | |
93 | */ | |
94 | #define ntohl(x) (x) | |
95 | #define ntohs(x) (x) | |
96 | #define htonl(x) (x) | |
97 | #define htons(x) (x) | |
98 | #endif | |
59965020 BJ |
99 | |
100 | #ifdef KERNEL | |
101 | extern struct domain inetdomain; | |
102 | extern struct protosw inetsw[]; | |
e4dfb782 | 103 | struct in_addr in_makeaddr(); |
c28628c9 | 104 | u_long in_netof(); |
59965020 | 105 | #endif |