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. 5 * 6 * Definitions of the Internet Protocol. 7 * 8 * Version: @(#)in.h 1.0.1 04/21/93 9 * 10 * Authors: Original taken from the GNU Project <netinet/in.h> file. 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 12 * 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. 17 */ 18#ifndef _LINUX_IN_H 19#define _LINUX_IN_H 20 21#include <linux/types.h> 22 23/* Standard well-defined IP protocols. */ 24enum { 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) */ 36 37 IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */ 38 39 IPPROTO_PIM = 103, /* Protocol Independent Multicast */ 40 41 IPPROTO_ESP = 50, /* Encapsulation Security Payload protocol */ 42 IPPROTO_AH = 51, /* Authentication Header protocol */ 43 IPPROTO_COMP = 108, /* Compression Header protocol */ 44 45 IPPROTO_RAW = 255, /* Raw IP packets */ 46 IPPROTO_MAX 47}; 48 49 50/* Internet address. */ 51struct in_addr { 52 __u32 s_addr; 53}; 54 55#define IP_TOS 1 56#define IP_TTL 2 57#define IP_HDRINCL 3 58#define IP_OPTIONS 4 59#define IP_ROUTER_ALERT 5 60#define IP_RECVOPTS 6 61#define IP_RETOPTS 7 62#define IP_PKTINFO 8 63#define IP_PKTOPTIONS 9 64#define IP_MTU_DISCOVER 10 65#define IP_RECVERR 11 66#define IP_RECVTTL 12 67#define IP_RECVTOS 13 68#define IP_MTU 14 69#define IP_FREEBIND 15 70 71/* BSD compatibility */ 72#define IP_RECVRETOPTS IP_RETOPTS 73 74/* IP_MTU_DISCOVER values */ 75#define IP_PMTUDISC_DONT 0 /* Never send DF frames */ 76#define IP_PMTUDISC_WANT 1 /* Use per route hints */ 77#define IP_PMTUDISC_DO 2 /* Always DF */ 78 79#define IP_MULTICAST_IF 32 80#define IP_MULTICAST_TTL 33 81#define IP_MULTICAST_LOOP 34 82#define IP_ADD_MEMBERSHIP 35 83#define IP_DROP_MEMBERSHIP 36 84 85/* These need to appear somewhere around here */ 86#define IP_DEFAULT_MULTICAST_TTL 1 87#define IP_DEFAULT_MULTICAST_LOOP 1 88 89/* Request struct for multicast socket ops */ 90 91struct ip_mreq 92{ 93 struct in_addr imr_multiaddr; /* IP multicast address of group */ 94 struct in_addr imr_interface; /* local IP address of interface */ 95}; 96 97struct ip_mreqn 98{ 99 struct in_addr imr_multiaddr; /* IP multicast address of group */ 100 struct in_addr imr_address; /* local IP address of interface */ 101 int imr_ifindex; /* Interface index */ 102}; 103 104struct in_pktinfo 105{ 106 int ipi_ifindex; 107 struct in_addr ipi_spec_dst; 108 struct in_addr ipi_addr; 109}; 110 111/* Structure describing an Internet (IP) socket address. */ 112#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ 113struct sockaddr_in { 114 sa_family_t sin_family; /* Address family */ 115 unsigned short int sin_port; /* Port number */ 116 struct in_addr sin_addr; /* Internet address */ 117 118 /* Pad to size of `struct sockaddr'. */ 119 unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) - 120 sizeof(unsigned short int) - sizeof(struct in_addr)]; 121}; 122#define sin_zero __pad /* for BSD UNIX comp. -FvK */ 123 124 125/* 126 * Definitions of the bits in an Internet address integer. 127 * On subnets, host and network parts are found according 128 * to the subnet mask, not these masks. 129 */ 130#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0) 131#define IN_CLASSA_NET 0xff000000 132#define IN_CLASSA_NSHIFT 24 133#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) 134#define IN_CLASSA_MAX 128 135 136#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000) 137#define IN_CLASSB_NET 0xffff0000 138#define IN_CLASSB_NSHIFT 16 139#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) 140#define IN_CLASSB_MAX 65536 141 142#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000) 143#define IN_CLASSC_NET 0xffffff00 144#define IN_CLASSC_NSHIFT 8 145#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) 146 147#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) 148#define IN_MULTICAST(a) IN_CLASSD(a) 149#define IN_MULTICAST_NET 0xF0000000 150 151#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) 152#define IN_BADCLASS(a) IN_EXPERIMENTAL((a)) 153 154/* Address to accept any incoming messages. */ 155#define INADDR_ANY ((unsigned long int) 0x00000000) 156 157/* Address to send to all hosts. */ 158#define INADDR_BROADCAST ((unsigned long int) 0xffffffff) 159 160/* Address indicating an error return. */ 161#define INADDR_NONE ((unsigned long int) 0xffffffff) 162 163/* Network number for local host loopback. */ 164#define IN_LOOPBACKNET 127 165 166/* Address to loopback in software to local host. */ 167#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ 168#define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000) 169 170/* Defines for Multicast INADDR */ 171#define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */ 172#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */ 173#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */ 174#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */ 175 176 177/* <asm/byteorder.h> contains the htonl type stuff.. */ 178#include <asm/byteorder.h> 179 180#ifdef __KERNEL__ 181/* Some random defines to make it easier in the kernel.. */ 182#define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000)) 183#define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000)) 184#define BADCLASS(x) (((x) & htonl(0xf0000000)) == htonl(0xf0000000)) 185#define ZERONET(x) (((x) & htonl(0xff000000)) == htonl(0x00000000)) 186#define LOCAL_MCAST(x) (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000)) 187 188#endif 189 190#endif /* _LINUX_IN_H */ 191