yet another torek fix
[unix-history] / usr / src / sys / netinet / in.h
CommitLineData
8ae0e4b4 1/*
bab61b5b 2 * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
2b6b6284 3 * All rights reserved.
8ae0e4b4 4 *
dbf0c423 5 * %sccs.include.redist.c%
2b6b6284 6 *
45889c65 7 * @(#)in.h 7.11 (Berkeley) %G%
8ae0e4b4 8 */
8958351e
BJ
9
10/*
11 * Constants and structures defined by the internet system,
12 * Per RFC 790, September 1981.
13 */
14
15/*
16 * Protocols
17 */
55f549b4 18#define IPPROTO_IP 0 /* dummy for IP */
8958351e 19#define IPPROTO_ICMP 1 /* control message protocol */
8114dc67 20#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
8958351e 21#define IPPROTO_TCP 6 /* tcp */
c49e68cc 22#define IPPROTO_EGP 8 /* exterior gateway protocol */
8958351e
BJ
23#define IPPROTO_PUP 12 /* pup */
24#define IPPROTO_UDP 17 /* user datagram protocol */
55f549b4 25#define IPPROTO_IDP 22 /* xns idp */
b4dc7708
KS
26#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
27#define IPPROTO_EON 80 /* ISO cnlp */
8958351e 28
13ab51b7 29#define IPPROTO_RAW 255 /* raw IP packet */
eb44bfb2
BJ
30#define IPPROTO_MAX 256
31
becdab37
BJ
32
33/*
bab61b5b 34 * Local port number conventions:
becdab37
BJ
35 * Ports < IPPORT_RESERVED are reserved for
36 * privileged processes (e.g. root).
f44e5691
MK
37 * Ports > IPPORT_USERRESERVED are reserved
38 * for servers, not necessarily privileged.
becdab37 39 */
1aa87517 40#define IPPORT_RESERVED 1024
f44e5691 41#define IPPORT_USERRESERVED 5000
1aa87517 42
8958351e 43/*
e4dfb782 44 * Internet address (a structure for historical reasons)
8958351e 45 */
2b4b57cd 46struct 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 */
8011f5df 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
8011f5df 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
b4f9e9c7 67#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
a8d3bf7f
BJ
68#define IN_CLASSC_NET 0xffffff00
69#define IN_CLASSC_NSHIFT 8
70#define IN_CLASSC_HOST 0x000000ff
ae34128e 71
b4f9e9c7
MK
72#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
73#define IN_MULTICAST(i) IN_CLASSD(i)
74
75#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
76#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
77
8011f5df
MK
78#define INADDR_ANY (u_long)0x00000000
79#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
b410e761
MK
80#ifndef KERNEL
81#define INADDR_NONE 0xffffffff /* -1 return */
82#endif
3adde5ac 83
b4f9e9c7
MK
84#define IN_LOOPBACKNET 127 /* official! */
85
2b4b57cd
BJ
86/*
87 * Socket address, internet style.
88 */
89struct sockaddr_in {
b4dc7708
KS
90 u_char sin_len;
91 u_char sin_family;
2b4b57cd
BJ
92 u_short sin_port;
93 struct in_addr sin_addr;
94 char sin_zero[8];
95};
eb2e4af9 96
bab61b5b
MK
97/*
98 * Structure used to describe IP options.
99 * Used to store options internally, to pass them to a process,
100 * or to restore options retrieved earlier.
101 * The ip_dst is used for the first-hop gateway when using a source route
102 * (this gets put into the header proper).
103 */
104struct ip_opts {
105 struct in_addr ip_dst; /* first hop, 0 w/o src rt */
106 char ip_opts[40]; /* actually variable in size */
107};
108
55f549b4
MK
109/*
110 * Options for use with [gs]etsockopt at the IP level.
bab61b5b 111 * First word of comment is data type; bool is stored in int.
55f549b4 112 */
bab61b5b
MK
113#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP per-packet options */
114#define IP_HDRINCL 2 /* int; header is included with data (raw) */
115#define IP_TOS 3 /* int; IP type of service and precedence */
116#define IP_TTL 4 /* int; IP time to live */
117#define IP_RECVOPTS 5 /* bool; receive all IP options w/datagram */
118#define IP_RECVRETOPTS 6 /* bool; receive IP options for response */
119#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/datagram */
120#define IP_RETOPTS 8 /* ip_opts; set/get IP per-packet options */
55f549b4 121
59965020 122#ifdef KERNEL
e4dfb782 123struct in_addr in_makeaddr();
8011f5df 124u_long in_netof(), in_lnaof();
59965020 125#endif