1 /* in.h 4.12 82/06/05 */ 2 3 /* 4 * Constants and structures defined by the internet system, 5 * Per RFC 790, September 1981. 6 */ 7 8 /* 9 * Protocols 10 */ 11 #define IPPROTO_ICMP 1 /* control message protocol */ 12 #define IPPROTO_GGP 2 /* gateway^2 (deprecated) */ 13 #define IPPROTO_TCP 6 /* tcp */ 14 #define IPPROTO_PUP 12 /* pup */ 15 #define IPPROTO_UDP 17 /* user datagram protocol */ 16 17 #define IPPROTO_RAW 255 /* raw IP packet */ 18 #define IPPROTO_MAX 256 19 20 /* 21 * Port/socket numbers: network standard functions 22 */ 23 #define IPPORT_ECHO 7 24 #define IPPORT_DISCARD 9 25 #define IPPORT_SYSTAT 11 26 #define IPPORT_DAYTIME 13 27 #define IPPORT_NETSTAT 15 28 #define IPPORT_FTP 21 29 #define IPPORT_TELNET 23 30 #define IPPORT_SMTP 25 31 #define IPPORT_TIMESERVER 37 32 #define IPPORT_NAMESERVER 42 33 #define IPPORT_WHOIS 43 34 #define IPPORT_MTP 57 35 36 /* 37 * Port/socket numbers: host specific functions 38 */ 39 #define IPPORT_TFTP 69 40 #define IPPORT_RJE 77 41 #define IPPORT_FINGER 79 42 #define IPPORT_TTYLINK 87 43 #define IPPORT_SUPDUP 95 44 45 /* 46 * UNIX TCP sockets 47 */ 48 #define IPPORT_EXECSERVER 512 49 #define IPPORT_LOGINSERVER 513 50 #define IPPORT_CMDSERVER 514 51 52 /* 53 * UNIX UDP sockets 54 */ 55 #define IPPORT_BIFFUDP 512 56 #define IPPORT_WHOSERVER 513 57 58 /* 59 * Ports < IPPORT_RESERVED are reserved for 60 * privileged processes (e.g. root). 61 */ 62 #define IPPORT_RESERVED 1024 63 64 /* 65 * Link numbers 66 */ 67 #define IMPLINK_IP 155 68 #define IMPLINK_LOWEXPER 156 69 #define IMPLINK_HIGHEXPER 158 70 71 /* 72 * Internet address (old style... should be updated) 73 */ 74 struct in_addr { 75 union { 76 struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; 77 struct { u_short s_w1,s_w2; } S_un_w; 78 u_long S_addr; 79 } S_un; 80 #define s_addr S_un.S_addr /* can be used for most tcp & ip code */ 81 #ifdef vax 82 #define s_host S_un.S_un_b.s_b2 /* host on imp */ 83 #define s_net S_un.S_un_b.s_b1 /* network */ 84 #define s_imp S_un.S_un_w.s_w2 /* imp */ 85 #define s_impno S_un.S_un_b.s_b4 /* imp # */ 86 #define s_lh S_un.S_un_b.s_b3 /* logical host */ 87 #endif 88 }; 89 90 /* 91 * Macros for dealing with Class A/B/C network 92 * numbers. High 3 bits of uppermost byte indicates 93 * how to interpret the remainder of the 32-bit 94 * Internet address. 95 */ 96 #ifdef vax || pdp11 97 #define IN_CLASSA_NET 0x000000ff /* 8 bits of net # */ 98 #define IN_CLASSA_LNA 0xffffff00 99 #define IN_CLASSB 0x00000008 100 #define IN_CLASSB_NET 0x0000ffff /* 16 bits of net # */ 101 #define IN_CLASSB_LNA 0xffff0000 102 #define IN_CLASSC 0x0000000c 103 #define IN_CLASSC_NET 0x00ffffff /* 24 bits of net # */ 104 #define IN_CLASSC_LNA 0xff000000 105 #endif 106 107 #define inetpart(in) \ 108 ((((in).s_addr&IN_CLASSC)==IN_CLASSC)?((in).s_addr&IN_CLASSC_NET):\ 109 ((((in).s_addr&IN_CLASSB)==IN_CLASSB)?((in).s_addr&IN_CLASSB_NET):\ 110 ((in).s_addr&IN_CLASSA_NET))) 111 #define lnapart(in) \ 112 ((((in).s_addr&IN_CLASSC)==IN_CLASSC)?((in).s_addr&IN_CLASSC_LNA) : \ 113 ((((in).s_addr&IN_CLASSB)==IN_CLASSB)?((in).s_addr&IN_CLASSB_LNA) : \ 114 ((in).s_addr&IN_CLASSA_LNA))) 115 116 #define INADDR_ANY 0x00000000 117 118 /* 119 * Socket address, internet style. 120 */ 121 struct sockaddr_in { 122 short sin_family; 123 u_short sin_port; 124 struct in_addr sin_addr; 125 char sin_zero[8]; 126 }; 127