home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / lan / soss.arj / RPC / IN.H < prev    next >
C/C++ Source or Header  |  1991-02-22  |  5KB  |  185 lines

  1. /*
  2.  * Copyright (c) 1982, 1986 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)in.h 1.15 88/02/08 SMI; from UCB 7.4 12/7/87
  7.  */
  8.  
  9. /*
  10.  * Constants and structures defined by the internet system,
  11.  * Per RFC 790, September 1981.
  12.  */
  13. #define    _IN_
  14.  
  15. /*
  16.  * Protocols
  17.  */
  18. #define    IPPROTO_IP        0        /* dummy for IP */
  19. #define    IPPROTO_ICMP        1        /* control message protocol */
  20. #define IPPROTO_IGMP        2        /* group control protocol */
  21. #define    IPPROTO_GGP        3        /* gateway^2 (deprecated) */
  22. #define    IPPROTO_TCP        6        /* tcp */
  23. #define    IPPROTO_EGP        8        /* exterior gateway protocol */
  24. #define    IPPROTO_PUP        12        /* pup */
  25. #define    IPPROTO_UDP        17        /* user datagram protocol */
  26. #define    IPPROTO_IDP        22        /* xns idp */
  27. #define    IPPROTO_ND        77        /* UNOFFICIAL net disk proto */
  28.  
  29. #define    IPPROTO_RAW        255        /* raw IP packet */
  30. #define    IPPROTO_MAX        256
  31.  
  32. /*
  33.  * Port/socket numbers: network standard functions
  34.  */
  35. #define    IPPORT_ECHO        7
  36. #define    IPPORT_DISCARD        9
  37. #define    IPPORT_SYSTAT        11
  38. #define    IPPORT_DAYTIME        13
  39. #define    IPPORT_NETSTAT        15
  40. #define    IPPORT_FTP        21
  41. #define    IPPORT_TELNET        23
  42. #define    IPPORT_SMTP        25
  43. #define    IPPORT_TIMESERVER    37
  44. #define    IPPORT_NAMESERVER    42
  45. #define    IPPORT_WHOIS        43
  46. #define    IPPORT_MTP        57
  47.  
  48. /*
  49.  * Port/socket numbers: host specific functions
  50.  */
  51. #define    IPPORT_TFTP        69
  52. #define    IPPORT_RJE        77
  53. #define    IPPORT_FINGER        79
  54. #define    IPPORT_TTYLINK        87
  55. #define    IPPORT_SUPDUP        95
  56.  
  57. /*
  58.  * UNIX TCP sockets
  59.  */
  60. #define    IPPORT_EXECSERVER    512
  61. #define    IPPORT_LOGINSERVER    513
  62. #define    IPPORT_CMDSERVER    514
  63. #define    IPPORT_EFSSERVER    520
  64.  
  65. /*
  66.  * UNIX UDP sockets
  67.  */
  68. #define    IPPORT_BIFFUDP        512
  69. #define    IPPORT_WHOSERVER    513
  70. #define    IPPORT_ROUTESERVER    520    /* 520+1 also used */
  71.  
  72. /*
  73.  * Ports < IPPORT_RESERVED are reserved for
  74.  * privileged processes (e.g. root).
  75.  * Ports > IPPORT_USERRESERVED are reserved
  76.  * for servers, not necessarily privileged.
  77.  */
  78. #define    IPPORT_RESERVED        1024
  79. #define    IPPORT_USERRESERVED    5000
  80.  
  81. /*
  82.  * Link numbers
  83.  */
  84. #define    IMPLINK_IP        155
  85. #define    IMPLINK_LOWEXPER    156
  86. #define    IMPLINK_HIGHEXPER    158
  87.  
  88. /*
  89.  * Internet address
  90.  *    This definition contains obsolete fields for compatibility
  91.  *    with SunOS 3.x and 4.2bsd.  The presence of subnets renders
  92.  *    divisions into fixed fields misleading at best.  New code
  93.  *    should use only the s_addr field.
  94.  */
  95. struct in_addr {
  96.     union {
  97.         struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
  98.         struct { u_short s_w1,s_w2; } S_un_w;
  99.         long S_addr;
  100.     } S_un;
  101. #define    s_addr    S_un.S_addr        /* should be used for all code */
  102. #define    s_host    S_un.S_un_b.s_b2    /* OBSOLETE: host on imp */
  103. #define    s_net    S_un.S_un_b.s_b1    /* OBSOLETE: network */
  104. #define    s_imp    S_un.S_un_w.s_w2    /* OBSOLETE: imp */
  105. #define    s_impno    S_un.S_un_b.s_b4    /* OBSOLETE: imp # */
  106. #define    s_lh    S_un.S_un_b.s_b3    /* OBSOLETE: logical host */
  107. };
  108.  
  109. /*
  110.  * Definitions of bits in internet address integers.
  111.  * On subnets, the decomposition of addresses to host and net parts
  112.  * is done according to subnet mask, not the masks here.
  113.  */
  114. #define    IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
  115. #define    IN_CLASSA_NET        0xff000000
  116. #define    IN_CLASSA_NSHIFT    24
  117. #define    IN_CLASSA_HOST        0x00ffffff
  118. #define    IN_CLASSA_MAX        128
  119.  
  120. #define    IN_CLASSB(i)        (((long)(i) & 0xc0000000) == 0x80000000)
  121. #define    IN_CLASSB_NET        0xffff0000
  122. #define    IN_CLASSB_NSHIFT    16
  123. #define    IN_CLASSB_HOST        0x0000ffff
  124. #define    IN_CLASSB_MAX        65536
  125.  
  126. #define    IN_CLASSC(i)        (((long)(i) & 0xe0000000) == 0xc0000000)
  127. #define    IN_CLASSC_NET        0xffffff00
  128. #define    IN_CLASSC_NSHIFT    8
  129. #define    IN_CLASSC_HOST        0x000000ff
  130.  
  131. #define    IN_CLASSD(i)        (((long)(i) & 0xf0000000) == 0xe0000000)
  132. #define    IN_MULTICAST(i)        IN_CLASSD(i)
  133.  
  134. #define    IN_EXPERIMENTAL(i)    (((long)(i) & 0xe0000000) == 0xe0000000)
  135. #define    IN_BADCLASS(i)        (((long)(i) & 0xf0000000) == 0xf0000000)
  136.  
  137. #define    INADDR_ANY        (u_long)0x00000000
  138. #define    INADDR_LOOPBACK        (u_long)0x7F000001
  139. #define    INADDR_BROADCAST    (u_long)0xffffffff    /* must be masked */
  140.  
  141. #define    IN_LOOPBACKNET        127            /* official! */
  142.  
  143. /*
  144.  * Define a macro to stuff the loopback address into an Internet address
  145.  */
  146. #define IN_SET_LOOPBACK_ADDR(a)    {(a)->sin_addr.s_addr  = htonl(INADDR_LOOPBACK); \
  147.     (a)->sin_family = AF_INET;}
  148.  
  149. /*
  150.  * Socket address, internet style.
  151.  */
  152. struct sockaddr_in {
  153.     short    sin_family;
  154.     unsigned    sin_port;
  155.     struct    in_addr sin_addr;
  156.     char    sin_zero[8];
  157. };
  158.  
  159. /*
  160.  * Options for use with [gs]etsockopt at the IP level.
  161.  */
  162. #define    IP_OPTIONS    1        /* set/get IP per-packet options */
  163.  
  164. /*
  165.  * Macros for number representation conversion.
  166.  */
  167.  
  168. extern    int ntohs( int x );
  169.  
  170. #define htons(x) ntohs(x)
  171.  
  172. #if !defined(ntohl) && (defined(vax) || defined(lint) || defined(i386))
  173. u_short    ntohs(), htons();
  174. u_long    ntohl(), htonl();
  175. #endif
  176.  
  177. #ifdef KERNEL
  178. extern    struct domain inetdomain;
  179. extern    struct protosw inetsw[];
  180. struct    in_addr in_makeaddr();
  181. u_long    in_netof(), in_lnaof();
  182. #endif
  183.  
  184.  
  185.