Linux 2.2.0
[davej-history.git] / include / linux / in.h
blob0dc2231a4d53b444726862e70915c14fad042219
1 /*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * Definitions of the Internet Protocol.
8 * Version: @(#)in.h 1.0.1 04/21/93
10 * Authors: Original taken from the GNU Project <netinet/in.h> file.
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
18 #ifndef _LINUX_IN_H
19 #define _LINUX_IN_H
21 #include <linux/types.h>
23 /* Standard well-defined IP protocols. */
24 enum {
25 IPPROTO_IP = 0, /* Dummy protocol for TCP */
26 IPPROTO_ICMP = 1, /* Internet Control Message Protocol */
27 IPPROTO_IGMP = 2, /* Internet Group Management Protocol */
28 IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */
29 IPPROTO_TCP = 6, /* Transmission Control Protocol */
30 IPPROTO_EGP = 8, /* Exterior Gateway Protocol */
31 IPPROTO_PUP = 12, /* PUP protocol */
32 IPPROTO_UDP = 17, /* User Datagram Protocol */
33 IPPROTO_IDP = 22, /* XNS IDP protocol */
34 IPPROTO_RSVP = 46, /* RSVP protocol */
35 IPPROTO_GRE = 47, /* Cisco GRE tunnels (rfc 1701,1702) */
37 IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */
39 IPPROTO_PIM = 103, /* Protocol Independent Multicast */
41 IPPROTO_RAW = 255, /* Raw IP packets */
42 IPPROTO_MAX
46 /* Internet address. */
47 struct in_addr {
48 __u32 s_addr;
51 #define IP_TOS 1
52 #define IP_TTL 2
53 #define IP_HDRINCL 3
54 #define IP_OPTIONS 4
55 #define IP_ROUTER_ALERT 5
56 #define IP_RECVOPTS 6
57 #define IP_RETOPTS 7
58 #define IP_PKTINFO 8
59 #define IP_PKTOPTIONS 9
60 #define IP_MTU_DISCOVER 10
61 #define IP_RECVERR 11
62 #define IP_RECVTTL 12
63 #define IP_RECVTOS 13
64 #define IP_MTU 14
66 /* BSD compatibility */
67 #define IP_RECVRETOPTS IP_RETOPTS
69 /* IP_MTU_DISCOVER values */
70 #define IP_PMTUDISC_DONT 0 /* Never send DF frames */
71 #define IP_PMTUDISC_WANT 1 /* Use per route hints */
72 #define IP_PMTUDISC_DO 2 /* Always DF */
74 #define IP_MULTICAST_IF 32
75 #define IP_MULTICAST_TTL 33
76 #define IP_MULTICAST_LOOP 34
77 #define IP_ADD_MEMBERSHIP 35
78 #define IP_DROP_MEMBERSHIP 36
80 /* These need to appear somewhere around here */
81 #define IP_DEFAULT_MULTICAST_TTL 1
82 #define IP_DEFAULT_MULTICAST_LOOP 1
83 #define IP_MAX_MEMBERSHIPS 20
85 /* Request struct for multicast socket ops */
87 struct ip_mreq
89 struct in_addr imr_multiaddr; /* IP multicast address of group */
90 struct in_addr imr_interface; /* local IP address of interface */
93 struct ip_mreqn
95 struct in_addr imr_multiaddr; /* IP multicast address of group */
96 struct in_addr imr_address; /* local IP address of interface */
97 int imr_ifindex; /* Interface index */
100 struct in_pktinfo
102 int ipi_ifindex;
103 struct in_addr ipi_spec_dst;
104 struct in_addr ipi_addr;
107 /* Structure describing an Internet (IP) socket address. */
108 #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
109 struct sockaddr_in {
110 sa_family_t sin_family; /* Address family */
111 unsigned short int sin_port; /* Port number */
112 struct in_addr sin_addr; /* Internet address */
114 /* Pad to size of `struct sockaddr'. */
115 unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) -
116 sizeof(unsigned short int) - sizeof(struct in_addr)];
118 #define sin_zero __pad /* for BSD UNIX comp. -FvK */
122 * Definitions of the bits in an Internet address integer.
123 * On subnets, host and network parts are found according
124 * to the subnet mask, not these masks.
126 #define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0)
127 #define IN_CLASSA_NET 0xff000000
128 #define IN_CLASSA_NSHIFT 24
129 #define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
130 #define IN_CLASSA_MAX 128
132 #define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000)
133 #define IN_CLASSB_NET 0xffff0000
134 #define IN_CLASSB_NSHIFT 16
135 #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
136 #define IN_CLASSB_MAX 65536
138 #define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000)
139 #define IN_CLASSC_NET 0xffffff00
140 #define IN_CLASSC_NSHIFT 8
141 #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
143 #define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
144 #define IN_MULTICAST(a) IN_CLASSD(a)
145 #define IN_MULTICAST_NET 0xF0000000
147 #define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
148 #define IN_BADCLASS(a) IN_EXPERIMENTAL((a))
150 /* Address to accept any incoming messages. */
151 #define INADDR_ANY ((unsigned long int) 0x00000000)
153 /* Address to send to all hosts. */
154 #define INADDR_BROADCAST ((unsigned long int) 0xffffffff)
156 /* Address indicating an error return. */
157 #define INADDR_NONE ((unsigned long int) 0xffffffff)
159 /* Network number for local host loopback. */
160 #define IN_LOOPBACKNET 127
162 /* Address to loopback in software to local host. */
163 #define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */
164 #define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000)
166 /* Defines for Multicast INADDR */
167 #define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */
168 #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
169 #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
170 #define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
173 /* <asm/byteorder.h> contains the htonl type stuff.. */
174 #include <asm/byteorder.h>
176 #ifdef __KERNEL__
177 /* Some random defines to make it easier in the kernel.. */
178 #define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000))
179 #define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
180 #define BADCLASS(x) (((x) & htonl(0xf0000000)) == htonl(0xf0000000))
181 #define ZERONET(x) (((x) & htonl(0xff000000)) == htonl(0x00000000))
182 #define LOCAL_MCAST(x) (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
184 #endif
186 #endif /* _LINUX_IN_H */