Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

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 
00023 /* Standard well-defined IP protocols.  */
00024 enum {
00025   IPPROTO_IP = 0,               /* Dummy protocol for TCP               */
00026   IPPROTO_ICMP = 1,             /* Internet Control Message Protocol    */
00027   IPPROTO_IGMP = 2,             /* Internet Group Management Protocol   */
00028   IPPROTO_IPIP = 4,             /* IPIP tunnels (older KA9Q tunnels use 94) */
00029   IPPROTO_TCP = 6,              /* Transmission Control Protocol        */
00030   IPPROTO_EGP = 8,              /* Exterior Gateway Protocol            */
00031   IPPROTO_PUP = 12,             /* PUP protocol                         */
00032   IPPROTO_UDP = 17,             /* User Datagram Protocol               */
00033   IPPROTO_IDP = 22,             /* XNS IDP protocol                     */
00034   IPPROTO_RSVP = 46,            /* RSVP protocol                        */
00035   IPPROTO_GRE = 47,             /* Cisco GRE tunnels (rfc 1701,1702)    */
00036 
00037   IPPROTO_IPV6   = 41,          /* IPv6-in-IPv4 tunnelling              */
00038 
00039   IPPROTO_PIM    = 103,         /* Protocol Independent Multicast       */
00040 
00041   IPPROTO_ESP = 50,            /* Encapsulation Security Payload protocol */
00042   IPPROTO_AH = 51,             /* Authentication Header protocol       */
00043   IPPROTO_COMP   = 108,                /* Compression Header protocol */
00044 
00045   IPPROTO_RAW    = 255,         /* Raw IP packets                       */
00046   IPPROTO_MAX
00047 };
00048 
00049 
00050 /* Internet address. */
00051 struct in_addr {
00052         __u32   s_addr;
00053 };
00054 
00055 #define IP_TOS          1
00056 #define IP_TTL          2
00057 #define IP_HDRINCL      3
00058 #define IP_OPTIONS      4
00059 #define IP_ROUTER_ALERT 5
00060 #define IP_RECVOPTS     6
00061 #define IP_RETOPTS      7
00062 #define IP_PKTINFO      8
00063 #define IP_PKTOPTIONS   9
00064 #define IP_MTU_DISCOVER 10
00065 #define IP_RECVERR      11
00066 #define IP_RECVTTL      12
00067 #define IP_RECVTOS      13
00068 #define IP_MTU          14
00069 
00070 /* BSD compatibility */
00071 #define IP_RECVRETOPTS  IP_RETOPTS
00072 
00073 /* IP_MTU_DISCOVER values */
00074 #define IP_PMTUDISC_DONT                0       /* Never send DF frames */
00075 #define IP_PMTUDISC_WANT                1       /* Use per route hints  */
00076 #define IP_PMTUDISC_DO                  2       /* Always DF            */
00077 
00078 #define IP_MULTICAST_IF                 32
00079 #define IP_MULTICAST_TTL                33
00080 #define IP_MULTICAST_LOOP               34
00081 #define IP_ADD_MEMBERSHIP               35
00082 #define IP_DROP_MEMBERSHIP              36
00083 
00084 /* These need to appear somewhere around here */
00085 #define IP_DEFAULT_MULTICAST_TTL        1
00086 #define IP_DEFAULT_MULTICAST_LOOP       1
00087 
00088 /* Request struct for multicast socket ops */
00089 
00090 struct ip_mreq 
00091 {
00092         struct in_addr imr_multiaddr;   /* IP multicast address of group */
00093         struct in_addr imr_interface;   /* local IP address of interface */
00094 };
00095 
00096 struct ip_mreqn
00097 {
00098         struct in_addr  imr_multiaddr;          /* IP multicast address of group */
00099         struct in_addr  imr_address;            /* local IP address of interface */
00100         int             imr_ifindex;            /* Interface index */
00101 };
00102 
00103 struct in_pktinfo
00104 {
00105         int             ipi_ifindex;
00106         struct in_addr  ipi_spec_dst;
00107         struct in_addr  ipi_addr;
00108 };
00109 
00110 /* Structure describing an Internet (IP) socket address. */
00111 #define __SOCK_SIZE__   16              /* sizeof(struct sockaddr)      */
00112 struct sockaddr_in {
00113   sa_family_t           sin_family;     /* Address family               */
00114   unsigned short int    sin_port;       /* Port number                  */
00115   struct in_addr        sin_addr;       /* Internet address             */
00116 
00117   /* Pad to size of `struct sockaddr'. */
00118   unsigned char         __pad[__SOCK_SIZE__ - sizeof(short int) -
00119                         sizeof(unsigned short int) - sizeof(struct in_addr)];
00120 };
00121 #define sin_zero        __pad           /* for BSD UNIX comp. -FvK      */
00122 
00123 
00124 /*
00125  * Definitions of the bits in an Internet address integer.
00126  * On subnets, host and network parts are found according
00127  * to the subnet mask, not these masks.
00128  */
00129 #define IN_CLASSA(a)            ((((long int) (a)) & 0x80000000) == 0)
00130 #define IN_CLASSA_NET           0xff000000
00131 #define IN_CLASSA_NSHIFT        24
00132 #define IN_CLASSA_HOST          (0xffffffff & ~IN_CLASSA_NET)
00133 #define IN_CLASSA_MAX           128
00134 
00135 #define IN_CLASSB(a)            ((((long int) (a)) & 0xc0000000) == 0x80000000)
00136 #define IN_CLASSB_NET           0xffff0000
00137 #define IN_CLASSB_NSHIFT        16
00138 #define IN_CLASSB_HOST          (0xffffffff & ~IN_CLASSB_NET)
00139 #define IN_CLASSB_MAX           65536
00140 
00141 #define IN_CLASSC(a)            ((((long int) (a)) & 0xe0000000) == 0xc0000000)
00142 #define IN_CLASSC_NET           0xffffff00
00143 #define IN_CLASSC_NSHIFT        8
00144 #define IN_CLASSC_HOST          (0xffffffff & ~IN_CLASSC_NET)
00145 
00146 #define IN_CLASSD(a)            ((((long int) (a)) & 0xf0000000) == 0xe0000000)
00147 #define IN_MULTICAST(a)         IN_CLASSD(a)
00148 #define IN_MULTICAST_NET        0xF0000000
00149 
00150 #define IN_EXPERIMENTAL(a)      ((((long int) (a)) & 0xf0000000) == 0xf0000000)
00151 #define IN_BADCLASS(a)          IN_EXPERIMENTAL((a))
00152 
00153 /* Address to accept any incoming messages. */
00154 #define INADDR_ANY              ((unsigned long int) 0x00000000)
00155 
00156 /* Address to send to all hosts. */
00157 #define INADDR_BROADCAST        ((unsigned long int) 0xffffffff)
00158 
00159 /* Address indicating an error return. */
00160 #define INADDR_NONE             ((unsigned long int) 0xffffffff)
00161 
00162 /* Network number for local host loopback. */
00163 #define IN_LOOPBACKNET          127
00164 
00165 /* Address to loopback in software to local host.  */
00166 #define INADDR_LOOPBACK         0x7f000001      /* 127.0.0.1   */
00167 #define IN_LOOPBACK(a)          ((((long int) (a)) & 0xff000000) == 0x7f000000)
00168 
00169 /* Defines for Multicast INADDR */
00170 #define INADDR_UNSPEC_GROUP     0xe0000000U     /* 224.0.0.0   */
00171 #define INADDR_ALLHOSTS_GROUP   0xe0000001U     /* 224.0.0.1   */
00172 #define INADDR_ALLRTRS_GROUP    0xe0000002U     /* 224.0.0.2 */
00173 #define INADDR_MAX_LOCAL_GROUP  0xe00000ffU     /* 224.0.0.255 */
00174 
00175 
00176 /* <asm/byteorder.h> contains the htonl type stuff.. */
00177 #include <asm/byteorder.h> 
00178 
00179 #ifdef __KERNEL__
00180 /* Some random defines to make it easier in the kernel.. */
00181 #define LOOPBACK(x)     (((x) & htonl(0xff000000)) == htonl(0x7f000000))
00182 #define MULTICAST(x)    (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
00183 #define BADCLASS(x)     (((x) & htonl(0xf0000000)) == htonl(0xf0000000))
00184 #define ZERONET(x)      (((x) & htonl(0xff000000)) == htonl(0x00000000))
00185 #define LOCAL_MCAST(x)  (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
00186 
00187 #endif
00188 
00189 #endif  /* _LINUX_IN_H */