For now, take out directory operation locking. Get rid of buffer
[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 *
d6fa15c2 7 * @(#)in.h 7.12 (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 */
d6fa15c2 20#define IPPROTO_IGMP 2 /* group mgmt protocol */
8114dc67 21#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
8958351e 22#define IPPROTO_TCP 6 /* tcp */
c49e68cc 23#define IPPROTO_EGP 8 /* exterior gateway protocol */
8958351e
BJ
24#define IPPROTO_PUP 12 /* pup */
25#define IPPROTO_UDP 17 /* user datagram protocol */
55f549b4 26#define IPPROTO_IDP 22 /* xns idp */
b4dc7708
KS
27#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */
28#define IPPROTO_EON 80 /* ISO cnlp */
8958351e 29
13ab51b7 30#define IPPROTO_RAW 255 /* raw IP packet */
eb44bfb2
BJ
31#define IPPROTO_MAX 256
32
becdab37
BJ
33
34/*
bab61b5b 35 * Local port number conventions:
becdab37
BJ
36 * Ports < IPPORT_RESERVED are reserved for
37 * privileged processes (e.g. root).
f44e5691
MK
38 * Ports > IPPORT_USERRESERVED are reserved
39 * for servers, not necessarily privileged.
becdab37 40 */
1aa87517 41#define IPPORT_RESERVED 1024
f44e5691 42#define IPPORT_USERRESERVED 5000
1aa87517 43
8958351e 44/*
e4dfb782 45 * Internet address (a structure for historical reasons)
8958351e 46 */
2b4b57cd 47struct in_addr {
e4dfb782 48 u_long s_addr;
8958351e 49};
2b4b57cd 50
ae34128e 51/*
a8d3bf7f 52 * Definitions of bits in internet address integers.
14c6a3d7
MK
53 * On subnets, the decomposition of addresses to host and net parts
54 * is done according to subnet mask, not the masks here.
ae34128e 55 */
8011f5df 56#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
a8d3bf7f
BJ
57#define IN_CLASSA_NET 0xff000000
58#define IN_CLASSA_NSHIFT 24
59#define IN_CLASSA_HOST 0x00ffffff
3adde5ac 60#define IN_CLASSA_MAX 128
a8d3bf7f 61
8011f5df 62#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
a8d3bf7f
BJ
63#define IN_CLASSB_NET 0xffff0000
64#define IN_CLASSB_NSHIFT 16
65#define IN_CLASSB_HOST 0x0000ffff
3adde5ac 66#define IN_CLASSB_MAX 65536
ae34128e 67
b4f9e9c7 68#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
a8d3bf7f
BJ
69#define IN_CLASSC_NET 0xffffff00
70#define IN_CLASSC_NSHIFT 8
71#define IN_CLASSC_HOST 0x000000ff
ae34128e 72
b4f9e9c7 73#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
d6fa15c2
KS
74#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
75#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
76#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
b4f9e9c7
MK
77#define IN_MULTICAST(i) IN_CLASSD(i)
78
79#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
80#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
81
8011f5df
MK
82#define INADDR_ANY (u_long)0x00000000
83#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
b410e761
MK
84#ifndef KERNEL
85#define INADDR_NONE 0xffffffff /* -1 return */
86#endif
3adde5ac 87
d6fa15c2
KS
88#define INADDR_UNSPEC_GROUP (u_long)0xe0000000 /* 224.0.0.0 */
89#define INADDR_ALLHOSTS_GROUP (u_long)0xe0000001 /* 224.0.0.1 */
90#define INADDR_MAX_LOCAL_GROUP (u_long)0xe00000ff /* 224.0.0.255 */
91
b4f9e9c7
MK
92#define IN_LOOPBACKNET 127 /* official! */
93
2b4b57cd
BJ
94/*
95 * Socket address, internet style.
96 */
97struct sockaddr_in {
b4dc7708
KS
98 u_char sin_len;
99 u_char sin_family;
2b4b57cd
BJ
100 u_short sin_port;
101 struct in_addr sin_addr;
102 char sin_zero[8];
103};
eb2e4af9 104
bab61b5b
MK
105/*
106 * Structure used to describe IP options.
107 * Used to store options internally, to pass them to a process,
108 * or to restore options retrieved earlier.
109 * The ip_dst is used for the first-hop gateway when using a source route
110 * (this gets put into the header proper).
111 */
112struct ip_opts {
113 struct in_addr ip_dst; /* first hop, 0 w/o src rt */
114 char ip_opts[40]; /* actually variable in size */
115};
116
55f549b4
MK
117/*
118 * Options for use with [gs]etsockopt at the IP level.
bab61b5b 119 * First word of comment is data type; bool is stored in int.
55f549b4 120 */
bab61b5b 121#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP per-packet options */
d6fa15c2
KS
122
123#define IP_MULTICAST_IF 2 /* set/get IP multicast interface */
124#define IP_MULTICAST_TTL 3 /* set/get IP multicast timetolive */
125#define IP_MULTICAST_LOOP 4 /* set/get IP multicast loopback */
126#define IP_ADD_MEMBERSHIP 5 /* add an IP group membership */
127#define IP_DROP_MEMBERSHIP 6 /* drop an IP group membership */
128
129#define IP_HDRINCL 7 /* int; header is included with data (raw) */
130#define IP_TOS 8 /* int; IP type of service and precedence */
131#define IP_TTL 9 /* int; IP time to live */
132#define IP_RECVOPTS 10 /* bool; receive all IP options w/datagram */
133#define IP_RECVRETOPTS 11 /* bool; receive IP options for response */
134#define IP_RECVDSTADDR 12 /* bool; receive IP dst addr w/datagram */
135#define IP_RETOPTS 13 /* ip_opts; set/get IP per-packet options */
136
137#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
138#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
139#define IP_MAX_MEMBERSHIPS 20 /* per socket */
140
141/*
142 * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
143 */
144struct ip_mreq {
145 struct in_addr imr_multiaddr; /* IP multicast address of group */
146 struct in_addr imr_interface; /* local IP address of interface */
147};
55f549b4 148
59965020 149#ifdef KERNEL
e4dfb782 150struct in_addr in_makeaddr();
8011f5df 151u_long in_netof(), in_lnaof();
59965020 152#endif