Main Page | Class List | File List | Class Members | File Members

in.h

Go to the documentation of this file.
00001 /* 00002 * INET An implementation of the TCP/IP protocol suite for the LINUX 00003 * operating system. INET is implemented using the BSD Socket 00004 * interface as the means of communication with the user level. 00005 * 00006 * Definitions of the Internet Protocol. 00007 * 00008 * Version: @(#)in.h 1.0.1 04/21/93 00009 * 00010 * Authors: Original taken from the GNU Project <netinet/in.h> file. 00011 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 00012 * 00013 * This program is free software; you can redistribute it and/or 00014 * modify it under the terms of the GNU General Public License 00015 * as published by the Free Software Foundation; either version 00016 * 2 of the License, or (at your option) any later version. 00017 */ 00018 #ifndef _LINUX_IN_H 00019 #define _LINUX_IN_H 00020 00021 #include <linux/types.h> 00022 #include <linux/socket.h> 00023 00024 /* Standard well-defined IP protocols. */ 00025 enum { 00026 IPPROTO_IP = 0, /* Dummy protocol for TCP */ 00027 IPPROTO_ICMP = 1, /* Internet Control Message Protocol */ 00028 IPPROTO_IGMP = 2, /* Internet Group Management Protocol */ 00029 IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */ 00030 IPPROTO_TCP = 6, /* Transmission Control Protocol */ 00031 IPPROTO_EGP = 8, /* Exterior Gateway Protocol */ 00032 IPPROTO_PUP = 12, /* PUP protocol */ 00033 IPPROTO_UDP = 17, /* User Datagram Protocol */ 00034 IPPROTO_IDP = 22, /* XNS IDP protocol */ 00035 IPPROTO_RSVP = 46, /* RSVP protocol */ 00036 IPPROTO_GRE = 47, /* Cisco GRE tunnels (rfc 1701,1702) */ 00037 00038 IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */ 00039 00040 IPPROTO_PIM = 103, /* Protocol Independent Multicast */ 00041 00042 IPPROTO_ESP = 50, /* Encapsulation Security Payload protocol */ 00043 IPPROTO_AH = 51, /* Authentication Header protocol */ 00044 IPPROTO_COMP = 108, /* Compression Header protocol */ 00045 IPPROTO_SCTP = 132, /* Stream Control Transport Protocol */ 00046 00047 IPPROTO_RAW = 255, /* Raw IP packets */ 00048 IPPROTO_MAX 00049 }; 00050 00051 00052 /* Internet address. */ 00053 struct in_addr { 00054 __u32 s_addr; 00055 }; 00056 00057 #define IP_TOS 1 00058 #define IP_TTL 2 00059 #define IP_HDRINCL 3 00060 #define IP_OPTIONS 4 00061 #define IP_ROUTER_ALERT 5 00062 #define IP_RECVOPTS 6 00063 #define IP_RETOPTS 7 00064 #define IP_PKTINFO 8 00065 #define IP_PKTOPTIONS 9 00066 #define IP_MTU_DISCOVER 10 00067 #define IP_RECVERR 11 00068 #define IP_RECVTTL 12 00069 #define IP_RECVTOS 13 00070 #define IP_MTU 14 00071 #define IP_FREEBIND 15 00072 00073 /* BSD compatibility */ 00074 #define IP_RECVRETOPTS IP_RETOPTS 00075 00076 /* IP_MTU_DISCOVER values */ 00077 #define IP_PMTUDISC_DONT 0 /* Never send DF frames */ 00078 #define IP_PMTUDISC_WANT 1 /* Use per route hints */ 00079 #define IP_PMTUDISC_DO 2 /* Always DF */ 00080 00081 #define IP_MULTICAST_IF 32 00082 #define IP_MULTICAST_TTL 33 00083 #define IP_MULTICAST_LOOP 34 00084 #define IP_ADD_MEMBERSHIP 35 00085 #define IP_DROP_MEMBERSHIP 36 00086 #define IP_UNBLOCK_SOURCE 37 00087 #define IP_BLOCK_SOURCE 38 00088 #define IP_ADD_SOURCE_MEMBERSHIP 39 00089 #define IP_DROP_SOURCE_MEMBERSHIP 40 00090 #define IP_MSFILTER 41 00091 #define MCAST_JOIN_GROUP 42 00092 #define MCAST_BLOCK_SOURCE 43 00093 #define MCAST_UNBLOCK_SOURCE 44 00094 #define MCAST_LEAVE_GROUP 45 00095 #define MCAST_JOIN_SOURCE_GROUP 46 00096 #define MCAST_LEAVE_SOURCE_GROUP 47 00097 #define MCAST_MSFILTER 48 00098 00099 #define MCAST_EXCLUDE 0 00100 #define MCAST_INCLUDE 1 00101 00102 /* These need to appear somewhere around here */ 00103 #define IP_DEFAULT_MULTICAST_TTL 1 00104 #define IP_DEFAULT_MULTICAST_LOOP 1 00105 00106 /* Request struct for multicast socket ops */ 00107 00108 struct ip_mreq 00109 { 00110 struct in_addr imr_multiaddr; /* IP multicast address of group */ 00111 struct in_addr imr_interface; /* local IP address of interface */ 00112 }; 00113 00114 struct ip_mreqn 00115 { 00116 struct in_addr imr_multiaddr; /* IP multicast address of group */ 00117 struct in_addr imr_address; /* local IP address of interface */ 00118 int imr_ifindex; /* Interface index */ 00119 }; 00120 00121 struct ip_mreq_source { 00122 __u32 imr_multiaddr; 00123 __u32 imr_interface; 00124 __u32 imr_sourceaddr; 00125 }; 00126 00127 struct ip_msfilter { 00128 __u32 imsf_multiaddr; 00129 __u32 imsf_interface; 00130 __u32 imsf_fmode; 00131 __u32 imsf_numsrc; 00132 __u32 imsf_slist[1]; 00133 }; 00134 00135 #define IP_MSFILTER_SIZE(numsrc) \ 00136 (sizeof(struct ip_msfilter) - sizeof(__u32) \ 00137 + (numsrc) * sizeof(__u32)) 00138 00139 struct group_req 00140 { 00141 __u32 gr_interface; /* interface index */ 00142 struct __kernel_sockaddr_storage gr_group; /* group address */ 00143 }; 00144 00145 struct group_source_req 00146 { 00147 __u32 gsr_interface; /* interface index */ 00148 struct __kernel_sockaddr_storage gsr_group; /* group address */ 00149 struct __kernel_sockaddr_storage gsr_source; /* source address */ 00150 }; 00151 00152 struct group_filter 00153 { 00154 __u32 gf_interface; /* interface index */ 00155 struct __kernel_sockaddr_storage gf_group; /* multicast address */ 00156 __u32 gf_fmode; /* filter mode */ 00157 __u32 gf_numsrc; /* number of sources */ 00158 struct __kernel_sockaddr_storage gf_slist[1]; /* interface index */ 00159 }; 00160 00161 #define GROUP_FILTER_SIZE(numsrc) \ 00162 (sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) \ 00163 + (numsrc) * sizeof(struct __kernel_sockaddr_storage)) 00164 00165 struct in_pktinfo 00166 { 00167 int ipi_ifindex; 00168 struct in_addr ipi_spec_dst; 00169 struct in_addr ipi_addr; 00170 }; 00171 00172 /* Structure describing an Internet (IP) socket address. */ 00173 #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ 00174 struct sockaddr_in { 00175 sa_family_t sin_family; /* Address family */ 00176 unsigned short int sin_port; /* Port number */ 00177 struct in_addr sin_addr; /* Internet address */ 00178 00179 /* Pad to size of `struct sockaddr'. */ 00180 unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) - 00181 sizeof(unsigned short int) - sizeof(struct in_addr)]; 00182 }; 00183 #define sin_zero __pad /* for BSD UNIX comp. -FvK */ 00184 00185 00186 /* 00187 * Definitions of the bits in an Internet address integer. 00188 * On subnets, host and network parts are found according 00189 * to the subnet mask, not these masks. 00190 */ 00191 #define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0) 00192 #define IN_CLASSA_NET 0xff000000 00193 #define IN_CLASSA_NSHIFT 24 00194 #define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) 00195 #define IN_CLASSA_MAX 128 00196 00197 #define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000) 00198 #define IN_CLASSB_NET 0xffff0000 00199 #define IN_CLASSB_NSHIFT 16 00200 #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) 00201 #define IN_CLASSB_MAX 65536 00202 00203 #define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000) 00204 #define IN_CLASSC_NET 0xffffff00 00205 #define IN_CLASSC_NSHIFT 8 00206 #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) 00207 00208 #define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) 00209 #define IN_MULTICAST(a) IN_CLASSD(a) 00210 #define IN_MULTICAST_NET 0xF0000000 00211 00212 #define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) 00213 #define IN_BADCLASS(a) IN_EXPERIMENTAL((a)) 00214 00215 /* Address to accept any incoming messages. */ 00216 #define INADDR_ANY ((unsigned long int) 0x00000000) 00217 00218 /* Address to send to all hosts. */ 00219 #define INADDR_BROADCAST ((unsigned long int) 0xffffffff) 00220 00221 /* Address indicating an error return. */ 00222 #define INADDR_NONE ((unsigned long int) 0xffffffff) 00223 00224 /* Network number for local host loopback. */ 00225 #define IN_LOOPBACKNET 127 00226 00227 /* Address to loopback in software to local host. */ 00228 #define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ 00229 #define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000) 00230 00231 /* Defines for Multicast INADDR */ 00232 #define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */ 00233 #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */ 00234 #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */ 00235 #define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */ 00236 00237 00238 /* <asm/byteorder.h> contains the htonl type stuff.. */ 00239 #include <asm/byteorder.h> 00240 00241 #ifdef __KERNEL__ 00242 /* Some random defines to make it easier in the kernel.. */ 00243 #define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000)) 00244 #define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000)) 00245 #define BADCLASS(x) (((x) & htonl(0xf0000000)) == htonl(0xf0000000)) 00246 #define ZERONET(x) (((x) & htonl(0xff000000)) == htonl(0x00000000)) 00247 #define LOCAL_MCAST(x) (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000)) 00248 00249 #endif 00250 00251 #endif /* _LINUX_IN_H */

Generated on Wed Dec 1 21:25:30 2004 for Linux 2.4.23 Networking by doxygen 1.3.8