home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / comm / amitcp-sdk-4.0.lha / AmiTCP-SDK / netinclude / netinet / in.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-06  |  4.0 KB  |  142 lines

  1. #ifndef NET_IN_H
  2. #define NET_IN_H \
  3.        "$Id: in.h,v 4.2 1994/10/05 23:12:24 ppessi Exp $"
  4. /*
  5.  *      Generic internet definitions
  6.  *
  7.  *      Copyright © 1994 AmiTCP/IP Group,
  8.  *                       Network Solutions Development, Inc.
  9.  *                       All rights reserved.
  10.  */
  11.  
  12. #define IN_H XXX - compatibility
  13.  
  14. /*
  15.  * Macros for network/external number representation conversion.
  16.  */
  17. #ifndef ntohl
  18. #define    ntohl(x)    (x)
  19. #define    ntohs(x)    (x)
  20. #define    htonl(x)    (x)
  21. #define    htons(x)    (x)
  22.  
  23. #define    NTOHL(x)    (x)
  24. #define    NTOHS(x)    (x)
  25. #define    HTONL(x)    (x)
  26. #define    HTONS(x)    (x)
  27. #endif
  28.  
  29. /*
  30.  * Constants and structures defined by the internet system,
  31.  * Per RFC 790, September 1981.
  32.  */
  33.  
  34. /*
  35.  * Protocols
  36.  */
  37. #define    IPPROTO_IP        0        /* dummy for IP */
  38. #define    IPPROTO_ICMP        1        /* control message protocol */
  39. #define    IPPROTO_GGP        3        /* gateway^2 (deprecated) */
  40. #define    IPPROTO_TCP        6        /* tcp */
  41. #define    IPPROTO_EGP        8        /* exterior gateway protocol */
  42. #define    IPPROTO_PUP        12        /* pup */
  43. #define    IPPROTO_UDP        17        /* user datagram protocol */
  44. #define    IPPROTO_IDP        22        /* xns idp */
  45. #define    IPPROTO_TP        29         /* tp-4 w/ class negotiation */
  46. #define    IPPROTO_EON        80        /* ISO cnlp */
  47.  
  48. #define    IPPROTO_RAW        255        /* raw IP packet */
  49. #define    IPPROTO_MAX        256
  50.  
  51.  
  52. /*
  53.  * Local port number conventions:
  54.  * Ports < IPPORT_RESERVED are reserved for
  55.  * privileged processes (e.g. root).
  56.  * Ports > IPPORT_USERRESERVED are reserved
  57.  * for servers, not necessarily privileged.
  58.  */
  59. #define    IPPORT_RESERVED        1024
  60. #define    IPPORT_USERRESERVED    5000
  61.  
  62. /*
  63.  * Internet address (a structure for historical reasons)
  64.  */
  65. struct in_addr {
  66.     u_long s_addr;
  67. };
  68.  
  69. /*
  70.  * Definitions of bits in internet address integers.
  71.  * On subnets, the decomposition of addresses to host and net parts
  72.  * is done according to subnet mask, not the masks here.
  73.  */
  74. #define    IN_CLASSA(i)        (((long)(i) & 0x80000000) == 0)
  75. #define    IN_CLASSA_NET        0xff000000
  76. #define    IN_CLASSA_NSHIFT    24
  77. #define    IN_CLASSA_HOST        0x00ffffff
  78. #define    IN_CLASSA_MAX        128
  79.  
  80. #define    IN_CLASSB(i)        (((long)(i) & 0xc0000000) == 0x80000000)
  81. #define    IN_CLASSB_NET        0xffff0000
  82. #define    IN_CLASSB_NSHIFT    16
  83. #define    IN_CLASSB_HOST        0x0000ffff
  84. #define    IN_CLASSB_MAX        65536
  85.  
  86. #define    IN_CLASSC(i)        (((long)(i) & 0xe0000000) == 0xc0000000)
  87. #define    IN_CLASSC_NET        0xffffff00
  88. #define    IN_CLASSC_NSHIFT    8
  89. #define    IN_CLASSC_HOST        0x000000ff
  90.  
  91. #define    IN_CLASSD(i)        (((long)(i) & 0xf0000000) == 0xe0000000)
  92. #define    IN_MULTICAST(i)        IN_CLASSD(i)
  93.  
  94. #define    IN_EXPERIMENTAL(i)    (((long)(i) & 0xe0000000) == 0xe0000000)
  95. #define    IN_BADCLASS(i)        (((long)(i) & 0xf0000000) == 0xf0000000)
  96.  
  97. #define    INADDR_ANY        (u_long)0x00000000
  98. #define    INADDR_BROADCAST    (u_long)0xffffffff    /* must be masked */
  99. #if !defined(KERNEL) || defined(AMITCP)
  100. #define    INADDR_NONE        0xffffffff        /* -1 return */
  101. #endif
  102.  
  103. #define    IN_LOOPBACKNET        127            /* official! */
  104.  
  105. /*
  106.  * Socket address, internet style.
  107.  */
  108. struct sockaddr_in {
  109.     u_char    sin_len;
  110.     u_char    sin_family;
  111.     u_short    sin_port;
  112.     struct    in_addr sin_addr;
  113.     char    sin_zero[8];
  114. };
  115.  
  116. /*
  117.  * Structure used to describe IP options.
  118.  * Used to store options internally, to pass them to a process,
  119.  * or to restore options retrieved earlier.
  120.  * The ip_dst is used for the first-hop gateway when using a source route
  121.  * (this gets put into the header proper).
  122.  */
  123. struct ip_opts {
  124.     struct    in_addr ip_dst;        /* first hop, 0 w/o src rt */
  125.     char    ip_opts[40];        /* actually variable in size */
  126. };
  127.  
  128. /*
  129.  * Options for use with [gs]etsockopt at the IP level.
  130.  * First word of comment is data type; bool is stored in int.
  131.  */
  132. #define    IP_OPTIONS    1    /* buf/ip_opts; set/get IP per-packet options */
  133. #define    IP_HDRINCL    2    /* int; header is included with data (raw) */
  134. #define    IP_TOS        3    /* int; IP type of service and precedence */
  135. #define    IP_TTL        4    /* int; IP time to live */
  136. #define    IP_RECVOPTS    5    /* bool; receive all IP options w/datagram */
  137. #define    IP_RECVRETOPTS    6    /* bool; receive IP options for response */
  138. #define    IP_RECVDSTADDR    7    /* bool; receive IP dst addr w/datagram */
  139. #define    IP_RETOPTS    8    /* ip_opts; set/get IP per-packet options */
  140.  
  141. #endif /* !IN_H */
  142.