Import 2.0.2
[davej-history.git] / include / linux / in.h
blob10da486f1f089d0e76f8ca50e23bdecc9bc2a91e
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 Gateway 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 */
35 IPPROTO_RAW =255,/* Raw IP packets */
36 IPPROTO_MAX
40 /* Internet address. */
41 struct in_addr {
42 __u32 s_addr;
45 /* Request struct for multicast socket ops */
47 struct ip_mreq
49 struct in_addr imr_multiaddr;/* IP multicast address of group */
50 struct in_addr imr_interface;/* local IP address of interface */
54 /* Structure describing an Internet (IP) socket address. */
55 #define __SOCK_SIZE__ 16/* sizeof(struct sockaddr) */
56 struct sockaddr_in {
57 short int sin_family;/* Address family */
58 unsigned short int sin_port;/* Port number */
59 struct in_addr sin_addr;/* Internet address */
61 /* Pad to size of `struct sockaddr'. */
62 unsigned char __pad[__SOCK_SIZE__ -sizeof(short int) -
63 sizeof(unsigned short int) -sizeof(struct in_addr)];
65 #define sin_zero __pad/* for BSD UNIX comp. -FvK */
69 * Definitions of the bits in an Internet address integer.
70 * On subnets, host and network parts are found according
71 * to the subnet mask, not these masks.
73 #define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0)
74 #define IN_CLASSA_NET 0xff000000
75 #define IN_CLASSA_NSHIFT 24
76 #define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
77 #define IN_CLASSA_MAX 128
79 #define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000)
80 #define IN_CLASSB_NET 0xffff0000
81 #define IN_CLASSB_NSHIFT 16
82 #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
83 #define IN_CLASSB_MAX 65536
85 #define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000)
86 #define IN_CLASSC_NET 0xffffff00
87 #define IN_CLASSC_NSHIFT 8
88 #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
90 #define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
91 #define IN_MULTICAST(a) IN_CLASSD(a)
92 #define IN_MULTICAST_NET 0xF0000000
94 #define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) == 0xe0000000)
95 #define IN_BADCLASS(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
97 /* Address to accept any incoming messages. */
98 #define INADDR_ANY ((unsigned long int) 0x00000000)
100 /* Address to send to all hosts. */
101 #define INADDR_BROADCAST ((unsigned long int) 0xffffffff)
103 /* Address indicating an error return. */
104 #define INADDR_NONE ((unsigned long int) 0xffffffff)
106 /* Network number for local host loopback. */
107 #define IN_LOOPBACKNET 127
109 /* Address to loopback in software to local host. */
110 #define INADDR_LOOPBACK 0x7f000001/* 127.0.0.1 */
111 #define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000)
113 /* Defines for Multicast INADDR */
114 #define INADDR_UNSPEC_GROUP 0xe0000000/* 224.0.0.0 */
115 #define INADDR_ALLHOSTS_GROUP 0xe0000001/* 224.0.0.1 */
116 #define INADDR_MAX_LOCAL_GROUP 0xe00000ff/* 224.0.0.255 */
118 /* <asm/byteorder.h> contains the htonl type stuff.. */
120 #include <asm/byteorder.h>
122 /* Some random defines to make it easier in the kernel.. */
123 #ifdef __KERNEL__
125 #define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000))
126 #define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
128 #endif
131 * IPv6 definitions as we start to include them. This is just
132 * a beginning -- don't get excited 8)
135 struct in_addr6
137 unsigned char s6_addr[16];
140 struct sockaddr_in6
142 unsigned short sin6_family;
143 unsigned short sin6_port;
144 unsigned long sin6_flowinfo;
145 struct in_addr6 sin6_addr;
149 #endif/* _LINUX_IN_H */
close