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 _CYGWIN_IN_H 19 #define _CYGWIN_IN_H 20 21 #include <cygwin/types.h> 22 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 */ 34 35 IPPROTO_RAW = 255, /* Raw IP packets */ 36 IPPROTO_MAX 37 }; 38 39 /* Standard well-known ports. *//* from winsup/include/netinet/in.h */ 40 enum 41 { 42 IPPORT_ECHO = 7, /* Echo service. */ 43 IPPORT_DISCARD = 9, /* Discard transmissions service. */ 44 IPPORT_SYSTAT = 11, /* System status service. */ 45 IPPORT_DAYTIME = 13, /* Time of day service. */ 46 IPPORT_NETSTAT = 15, /* Network status service. */ 47 IPPORT_FTP = 21, /* File Transfer Protocol. */ 48 IPPORT_TELNET = 23, /* Telnet protocol. */ 49 IPPORT_SMTP = 25, /* Simple Mail Transfer Protocol. */ 50 IPPORT_TIMESERVER = 37, /* Timeserver service. */ 51 IPPORT_NAMESERVER = 42, /* Domain Name Service. */ 52 IPPORT_WHOIS = 43, /* Internet Whois service. */ 53 IPPORT_MTP = 57, 54 55 IPPORT_TFTP = 69, /* Trivial File Transfer Protocol. */ 56 IPPORT_RJE = 77, 57 IPPORT_FINGER = 79, /* Finger service. */ 58 IPPORT_TTYLINK = 87, 59 IPPORT_SUPDUP = 95, /* SUPDUP protocol. */ 60 61 62 IPPORT_EXECSERVER = 512, /* execd service. */ 63 IPPORT_LOGINSERVER = 513, /* rlogind service. */ 64 IPPORT_CMDSERVER = 514, 65 IPPORT_EFSSERVER = 520, 66 67 /* UDP ports. */ 68 IPPORT_BIFFUDP = 512, 69 IPPORT_WHOSERVER = 513, 70 IPPORT_ROUTESERVER = 520, 71 72 /* Ports less than this value are reserved for privileged processes. */ 73 IPPORT_RESERVED = 1024, 74 75 /* Ports greater this value are reserved for (non-privileged) servers. */ 76 IPPORT_USERRESERVED = 5000 77 }; 78 79 80 /* Internet address. */ 81 struct in_addr { 82 unsigned int s_addr; 83 }; 84 85 /* Request struct for multicast socket ops */ 86 87 struct ip_mreq 88 { 89 struct in_addr imr_multiaddr; /* IP multicast address of group */ 90 struct in_addr imr_interface; /* local IP address of interface */ 91 }; 92 93 94 /* Structure describing an Internet (IP) socket address. */ 95 #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ 96 struct sockaddr_in { 97 short int sin_family; /* Address family */ 98 unsigned short int sin_port; /* Port number */ 99 struct in_addr sin_addr; /* Internet address */ 100 101 /* Pad to size of `struct sockaddr'. */ 102 unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) - 103 sizeof(unsigned short int) - sizeof(struct in_addr)]; 104 }; 105 #define sin_zero __pad /* for BSD UNIX comp. -FvK */ 106 107 108 /* 109 * Definitions of the bits in an Internet address integer. 110 * On subnets, host and network parts are found according 111 * to the subnet mask, not these masks. 112 */ 113 #define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0) 114 #define IN_CLASSA_NET 0xff000000 115 #define IN_CLASSA_NSHIFT 24 116 #define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) 117 #define IN_CLASSA_MAX 128 118 119 #define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000) 120 #define IN_CLASSB_NET 0xffff0000 121 #define IN_CLASSB_NSHIFT 16 122 #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) 123 #define IN_CLASSB_MAX 65536 124 125 #define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000) 126 #define IN_CLASSC_NET 0xffffff00 127 #define IN_CLASSC_NSHIFT 8 128 #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) 129 130 #define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) 131 #define IN_MULTICAST(a) IN_CLASSD(a) 132 #define IN_MULTICAST_NET 0xF0000000 133 134 #define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) == 0xe0000000) 135 #define IN_BADCLASS(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) 136 137 /* Address to accept any incoming messages. */ 138 #define INADDR_ANY ((unsigned long int) 0x00000000) 139 140 /* Address to send to all hosts. */ 141 #define INADDR_BROADCAST ((unsigned long int) 0xffffffff) 142 143 /* Address indicating an error return. */ 144 #define INADDR_NONE 0xffffffff 145 146 /* Network number for local host loopback. */ 147 #define IN_LOOPBACKNET 127 148 149 /* Address to loopback in software to local host. */ 150 #define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ 151 #define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000) 152 153 /* Defines for Multicast INADDR */ 154 #define INADDR_UNSPEC_GROUP 0xe0000000 /* 224.0.0.0 */ 155 #define INADDR_ALLHOSTS_GROUP 0xe0000001 /* 224.0.0.1 */ 156 #define INADDR_MAX_LOCAL_GROUP 0xe00000ff /* 224.0.0.255 */ 157 158 /* <asm/byteorder.h> contains the htonl type stuff.. */ 159 160 #include <asm/byteorder.h> 161 162 /* Some random defines to make it easier in the kernel.. */ 163 #ifdef __KERNEL__ 164 165 #define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000)) 166 #define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000)) 167 168 #endif 169 170 /* 171 * IPv6 definitions as we start to include them. This is just 172 * a beginning dont get excited 8) 173 */ 174 175 struct in6_addr 176 { 177 unsigned char s6_addr[16]; 178 }; 179 180 struct sockaddr_in6 181 { 182 unsigned short sin6_family; 183 unsigned short sin6_port; 184 unsigned long sin6_flowinfo; 185 struct in6_addr sin6_addr; 186 }; 187 188 #endif /* _CYGWIN_IN_H */ |