home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / header45.zip / stack16 / netinet / in.h < prev    next >
Text File  |  1999-05-11  |  6KB  |  158 lines

  1. #ifndef __IN_32H
  2. #define __IN_32H
  3. /*
  4.  * Copyright (c) 1982, 1986 Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms are permitted
  8.  * provided that this notice is preserved and that due credit is given
  9.  * to the University of California at Berkeley. The name of the University
  10.  * may not be used to endorse or promote products derived from this
  11.  * software without specific prior written permission. This software
  12.  * is provided ``as is'' without express or implied warranty.
  13.  *
  14.  *      @(#)in.h        7.5 (Berkeley) 2/22/88
  15.  */
  16.  
  17. /*
  18.  * Constants and structures defined by the internet system,
  19.  * Per RFC 790, September 1981.
  20.  */
  21.  
  22. #ifdef __BORLANDC__           /* DRC01 - changed _System to _syscall */
  23. #ifndef _System               /* DRC01 */
  24. #define _System _syscall      /* DRC01 */
  25. #endif                        /* DRC01 */
  26. #endif                        /* DRC01 */
  27.  
  28. #ifdef __HIGHC__              /* DRC02 */
  29. #define _System
  30. #endif
  31.  
  32. /*
  33.  * Protocols
  34.  */
  35. #define IPPROTO_IP              0               /* dummy for IP */
  36. #define IPPROTO_ICMP            1               /* control message protocol */
  37. #define IPPROTO_IGMP            2               /* group management protocol*/
  38. #define IPPROTO_GGP             3               /* gateway^2 (deprecated) */
  39. #define IPPROTO_TCP             6               /* tcp */
  40. #define IPPROTO_EGP             8               /* exterior gateway protocol */
  41. #define IPPROTO_PUP             12              /* pup */
  42. #define IPPROTO_UDP             17              /* user datagram protocol */
  43. #define IPPROTO_IDP             22              /* xns idp */
  44.  
  45. #define IPPROTO_RAW             255             /* raw IP packet */
  46. #define IPPROTO_MAX             256
  47.  
  48.  
  49. /*
  50.  * Ports < IPPORT_RESERVED are reserved for
  51.  * privileged processes (e.g. root).
  52.  * Ports > IPPORT_USERRESERVED are reserved
  53.  * for servers, not necessarily privileged.
  54.  */
  55. #define IPPORT_RESERVED         1024
  56. #define IPPORT_USERRESERVED     5000
  57.  
  58. /*
  59.  * Link numbers
  60.  */
  61. #define IMPLINK_IP              155
  62. #define IMPLINK_LOWEXPER        156
  63. #define IMPLINK_HIGHEXPER       158
  64.  
  65. /*
  66.  * Internet address (a structure for historical reasons)
  67.  */
  68. struct in_addr {
  69.         unsigned long s_addr;
  70. };
  71.  
  72. /*
  73.  * Definitions of bits in internet address integers.
  74.  * On subnets, the decomposition of addresses to host and net parts
  75.  * is done according to subnet mask, not the masks here.
  76.  */
  77. #define IN_CLASSA(i)            (((long)(i) & 0x80000000L) == 0)
  78. #define IN_CLASSA_NET           0xff000000L
  79. #define IN_CLASSA_NSHIFT        24
  80. #define IN_CLASSA_HOST          0x00ffffffL
  81. #define IN_CLASSA_MAX           128
  82.  
  83. #define IN_CLASSB(i)            (((long)(i) & 0xc0000000L) == 0x80000000L)
  84. #define IN_CLASSB_NET           0xffff0000L
  85. #define IN_CLASSB_NSHIFT        16
  86. #define IN_CLASSB_HOST          0x0000ffffL
  87. #define IN_CLASSB_MAX           65536L
  88.  
  89. #define IN_CLASSC(i)            (((long)(i) & 0xe0000000L) == 0xc0000000L)
  90. #define IN_CLASSC_NET           0xffffff00L
  91. #define IN_CLASSC_NSHIFT        8
  92. #define IN_CLASSC_HOST          0x000000ffL
  93.  
  94. #define IN_CLASSD(i)            (((long)(i) & 0xf0000000L) == 0xe0000000L)
  95. #define IN_CLASSD_NET           0xffffffffL
  96. #define IN_CLASSD_HOST          0x00000000L
  97. #define IN_MULTICAST(i)         IN_CLASSD(i)
  98.  
  99. #define IN_EXPERIMENTAL(i)      (((long)(i) & 0xe0000000L) == 0xe0000000L)
  100. #define IN_BADCLASS(i)          (((long)(i) & 0xf0000000L) == 0xf0000000L)
  101.  
  102. #define INADDR_ANY              (unsigned long)0x00000000L
  103. #define INADDR_BROADCAST        (unsigned long)0xffffffffL     /* must be masked */
  104.  
  105. #define INADDR_UNSPEC_GROUP     (unsigned long )0xe0000000      /* 224.0.0.0   */
  106. #define INADDR_ALLHOSTS_GROUP   (unsigned long)0xe0000001      /* 224.0.0.1   */
  107. #define INADDR_MAX_LOCAL_GROUP  (unsigned long)0xe00000ff      /* 224.0.0.255 */
  108.  
  109. #ifndef KERNEL
  110. #define INADDR_NONE             0xffffffffL             /* -1 return */
  111. #endif
  112.  
  113. #define IN_LOOPBACKNET          127                     /* official! */
  114.  
  115. /*
  116.  * Socket address, internet style.
  117.  */
  118.  
  119. struct sockaddr_in {
  120.         short   sin_family;
  121.         unsigned short sin_port;
  122.         struct  in_addr sin_addr;
  123.         char    sin_zero[8];
  124. };
  125.  
  126. /*
  127.  * Options for use with [gs]etsockopt at the IP level.
  128.  */
  129. #define IP_OPTIONS      1               /* set/get IP per-packet options */
  130.  
  131. #define IP_MULTICAST_IF    2            /* set/get IP multicast interface*/
  132. #define IP_MULTICAST_TTL   3            /* set/get IP multicast timetolive*/
  133. #define IP_MULTICAST_LOOP  4            /* set/get IP multicast loopback */
  134. #define IP_ADD_MEMBERSHIP  5            /* add  an IP group membership   */
  135. #define IP_DROP_MEMBERSHIP 6            /* drop an IP group membership   */
  136.  
  137. #define IP_DEFAULT_MULTICAST_TTL  1     /* normally limit m'casts to 1 hop */
  138. #define IP_DEFAULT_MULTICAST_LOOP 1     /* normally hear sends if a member */
  139. #define IP_MAX_MEMBERSHIPS       20     /* per socket; must fit in one mbuf*/
  140.  
  141. /*
  142.  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
  143.  */
  144. struct ip_mreq {
  145.         struct in_addr  imr_multiaddr;  /* IP multicast address of group */
  146.         struct in_addr  imr_interface;  /* local IP address of interface */
  147. };
  148.  
  149. unsigned long _System inet_addr(char *);
  150. struct in_addr _System inet_makeaddr(unsigned long, unsigned long);
  151. unsigned long _System inet_network(char *);
  152. char * _System inet_ntoa(struct in_addr);
  153. unsigned long _System inet_lnaof(struct in_addr);
  154. unsigned long _System inet_netof(struct in_addr);
  155.  
  156. #endif /* __IN_32H */
  157.  
  158.