home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / netinet / in.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  6.3 KB  |  186 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    in.h,v $
  29.  * Revision 2.1  92/04/21  17:14:22  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*
  36.  * Copyright (c) 1982, 1986, 1990 Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * Redistribution and use in source and binary forms, with or without
  40.  * modification, are permitted provided that the following conditions
  41.  * are met:
  42.  * 1. Redistributions of source code must retain the above copyright
  43.  *    notice, this list of conditions and the following disclaimer.
  44.  * 2. Redistributions in binary form must reproduce the above copyright
  45.  *    notice, this list of conditions and the following disclaimer in the
  46.  *    documentation and/or other materials provided with the distribution.
  47.  * 3. All advertising materials mentioning features or use of this software
  48.  *    must display the following acknowledgement:
  49.  *    This product includes software developed by the University of
  50.  *    California, Berkeley and its contributors.
  51.  * 4. Neither the name of the University nor the names of its contributors
  52.  *    may be used to endorse or promote products derived from this software
  53.  *    without specific prior written permission.
  54.  *
  55.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  56.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  57.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  58.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  59.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  61.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  62.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  63.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  64.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  65.  * SUCH DAMAGE.
  66.  *
  67.  *    @(#)in.h    7.11 (Berkeley) 4/20/91
  68.  */
  69.  
  70. /*
  71.  * Constants and structures defined by the internet system,
  72.  * Per RFC 790, September 1981.
  73.  */
  74.  
  75. /*
  76.  * Protocols
  77.  */
  78. #define    IPPROTO_IP        0        /* dummy for IP */
  79. #define    IPPROTO_ICMP        1        /* control message protocol */
  80. #define    IPPROTO_GGP        3        /* gateway^2 (deprecated) */
  81. #define    IPPROTO_TCP        6        /* tcp */
  82. #define    IPPROTO_EGP        8        /* exterior gateway protocol */
  83. #define    IPPROTO_PUP        12        /* pup */
  84. #define    IPPROTO_UDP        17        /* user datagram protocol */
  85. #define    IPPROTO_IDP        22        /* xns idp */
  86. #define    IPPROTO_TP        29         /* tp-4 w/ class negotiation */
  87. #define    IPPROTO_EON        80        /* ISO cnlp */
  88.  
  89. #define    IPPROTO_RAW        255        /* raw IP packet */
  90. #define    IPPROTO_MAX        256
  91.  
  92.  
  93. /*
  94.  * Local port number conventions:
  95.  * Ports < IPPORT_RESERVED are reserved for
  96.  * privileged processes (e.g. root).
  97.  * Ports > IPPORT_USERRESERVED are reserved
  98.  * for servers, not necessarily privileged.
  99.  */
  100. #define    IPPORT_RESERVED        1024
  101. #define    IPPORT_USERRESERVED    5000
  102.  
  103. /*
  104.  * Internet address (a structure for historical reasons)
  105.  */
  106. struct in_addr {
  107.     u_long s_addr;
  108. };
  109.  
  110. /*
  111.  * Definitions of bits in internet address integers.
  112.  * On subnets, the decomposition of addresses to host and net parts
  113.  * is done according to subnet mask, not the masks here.
  114.  */
  115. #define    IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
  116. #define    IN_CLASSA_NET        0xff000000
  117. #define    IN_CLASSA_NSHIFT    24
  118. #define    IN_CLASSA_HOST        0x00ffffff
  119. #define    IN_CLASSA_MAX        128
  120.  
  121. #define    IN_CLASSB(i)        (((long)(i) & 0xc0000000) == 0x80000000)
  122. #define    IN_CLASSB_NET        0xffff0000
  123. #define    IN_CLASSB_NSHIFT    16
  124. #define    IN_CLASSB_HOST        0x0000ffff
  125. #define    IN_CLASSB_MAX        65536
  126.  
  127. #define    IN_CLASSC(i)        (((long)(i) & 0xe0000000) == 0xc0000000)
  128. #define    IN_CLASSC_NET        0xffffff00
  129. #define    IN_CLASSC_NSHIFT    8
  130. #define    IN_CLASSC_HOST        0x000000ff
  131.  
  132. #define    IN_CLASSD(i)        (((long)(i) & 0xf0000000) == 0xe0000000)
  133. #define    IN_MULTICAST(i)        IN_CLASSD(i)
  134.  
  135. #define    IN_EXPERIMENTAL(i)    (((long)(i) & 0xe0000000) == 0xe0000000)
  136. #define    IN_BADCLASS(i)        (((long)(i) & 0xf0000000) == 0xf0000000)
  137.  
  138. #define    INADDR_ANY        (u_long)0x00000000
  139. #define    INADDR_BROADCAST    (u_long)0xffffffff    /* must be masked */
  140. #ifndef KERNEL
  141. #define    INADDR_NONE        0xffffffff        /* -1 return */
  142. #endif
  143.  
  144. #define    IN_LOOPBACKNET        127            /* official! */
  145.  
  146. /*
  147.  * Socket address, internet style.
  148.  */
  149. struct sockaddr_in {
  150.     u_char    sin_len;
  151.     u_char    sin_family;
  152.     u_short    sin_port;
  153.     struct    in_addr sin_addr;
  154.     char    sin_zero[8];
  155. };
  156.  
  157. /*
  158.  * Structure used to describe IP options.
  159.  * Used to store options internally, to pass them to a process,
  160.  * or to restore options retrieved earlier.
  161.  * The ip_dst is used for the first-hop gateway when using a source route
  162.  * (this gets put into the header proper).
  163.  */
  164. struct ip_opts {
  165.     struct    in_addr ip_dst;        /* first hop, 0 w/o src rt */
  166.     char    ip_opts[40];        /* actually variable in size */
  167. };
  168.  
  169. /*
  170.  * Options for use with [gs]etsockopt at the IP level.
  171.  * First word of comment is data type; bool is stored in int.
  172.  */
  173. #define    IP_OPTIONS    1    /* buf/ip_opts; set/get IP per-packet options */
  174. #define    IP_HDRINCL    2    /* int; header is included with data (raw) */
  175. #define    IP_TOS        3    /* int; IP type of service and precedence */
  176. #define    IP_TTL        4    /* int; IP time to live */
  177. #define    IP_RECVOPTS    5    /* bool; receive all IP options w/datagram */
  178. #define    IP_RECVRETOPTS    6    /* bool; receive IP options for response */
  179. #define    IP_RECVDSTADDR    7    /* bool; receive IP dst addr w/datagram */
  180. #define    IP_RETOPTS    8    /* ip_opts; set/get IP per-packet options */
  181.  
  182. #ifdef KERNEL
  183. struct    in_addr in_makeaddr();
  184. u_long    in_netof(), in_lnaof();
  185. #endif
  186.