home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / internet.def < prev    next >
Text File  |  1997-08-23  |  8KB  |  177 lines

  1. <* M2EXTENSIONS + *>
  2.  
  3. DEFINITION MODULE ["SysCall"] Internet;
  4.  
  5.         (********************************************************)
  6.         (*                                                      *)
  7.         (*       Definitions related to Internet sockets.       *)
  8.         (*     This module is imported by the Sockets module.   *)
  9.         (*                                                      *)
  10.         (*  Constants and structures defined by the internet    *)
  11.         (*  system, Per RFC 790, September 1981.                *)
  12.         (*                                                      *)
  13.         (*  Programmer:         P. Moylan                       *)
  14.         (*  Started:            18 August 1997                  *)
  15.         (*  Last edited:        23 August 1997                  *)
  16.         (*  Status:             Just started                    *)
  17.         (*                                                      *)
  18.         (*      This doesn't do much yet, it's just a           *)
  19.         (*      test whether I can talk properly to the API     *)
  20.         (*                                                      *)
  21.         (********************************************************)
  22.  
  23. (********************************************************************************)
  24. (* This module is derived in part from the in.h file that comes with OS/2       *)
  25. (* Warp 4, and that file carries the following copyright notice:                *)
  26. (*                                                                              *)
  27. (* Copyright (c) 1982, 1985, 1986 Regents of the University of California.      *)
  28. (* All rights reserved.                                                         *)
  29. (*                                                                              *)
  30. (* Redistribution and use in source and binary forms are permitted              *)
  31. (* provided that this notice is preserved and that due credit is given          *)
  32. (* to the University of California at Berkeley. The name of the University      *)
  33. (* may not be used to endorse or promote products derived from this             *)
  34. (* software without specific prior written permission. This software            *)
  35. (* is provided ``as is'' without express or implied warranty.                   *)
  36. (*                                                                              *)
  37. (*      @(#)in.h        7.5 (Berkeley) 2/22/88                                  *)
  38. (*                                                                              *)
  39. (********************************************************************************)
  40.  
  41. FROM SYSTEM IMPORT CARD8, CARD16, CARD32;
  42.  
  43. TYPE EightByte = ARRAY [0..7] OF CARD8;
  44. CONST Zero8 = EightByte {0, 0, 0, 0, 0, 0, 0, 0};
  45.  
  46. CONST
  47.     INADDR_ANY = 0;
  48.  
  49. TYPE
  50.     InternetSocketAddress = RECORD
  51.                                 port: CARD16;
  52.                                 addr: CARD32;
  53.                                 zero: EightByte;   (* Must be zero *)
  54.                             END (*RECORD*);
  55.  
  56.     (* Remark: for a "bind" call, you can set the port to zero if you don't     *)
  57.     (* care which port you get - the system then assigns you a free port.       *)
  58.  
  59. (********************************************************************************)
  60.  
  61. PROCEDURE ["SysCall"] inet_addr (value: ARRAY OF CHAR): CARD32;
  62.  
  63.     (* Translates an IP address from the dotted notation (e.g. "123.45.6.78")   *)
  64.     (* to 32-bit binary in Internet byte order (MSB first).                     *)
  65.  
  66. END Internet.
  67.  
  68. (************************************************************************)
  69. (*   THE FOLLOWING HAS NOT YET BEEN TRANSLATED                          *)
  70. (************************************************************************)
  71.  
  72. /*
  73.  * Protocols
  74.  */
  75. #define IPPROTO_IP              0               /* dummy for IP */
  76. #define IPPROTO_ICMP            1               /* control message protocol */
  77. #define IPPROTO_IGMP            2               /* group management protocol*/
  78. #define IPPROTO_GGP             3               /* gateway^2 (deprecated) */
  79. #define IPPROTO_TCP             6               /* tcp */
  80. #define IPPROTO_EGP             8               /* exterior gateway protocol */
  81. #define IPPROTO_PUP             12              /* pup */
  82. #define IPPROTO_UDP             17              /* user datagram protocol */
  83. #define IPPROTO_IDP             22              /* xns idp */
  84.  
  85. #define IPPROTO_RAW             255             /* raw IP packet */
  86. #define IPPROTO_MAX             256
  87.  
  88.  
  89. /*
  90.  * Ports < IPPORT_RESERVED are reserved for
  91.  * privileged processes (e.g. root).
  92.  * Ports > IPPORT_USERRESERVED are reserved
  93.  * for servers, not necessarily privileged.
  94.  */
  95. #define IPPORT_RESERVED         1024
  96. #define IPPORT_USERRESERVED     5000
  97.  
  98. /*
  99.  * Link numbers
  100.  */
  101. #define IMPLINK_IP              155
  102. #define IMPLINK_LOWEXPER        156
  103. #define IMPLINK_HIGHEXPER       158
  104.  
  105. /*
  106.  * Definitions of bits in internet address integers.
  107.  * On subnets, the decomposition of addresses to host and net parts
  108.  * is done according to subnet mask, not the masks here.
  109.  */
  110. #define IN_CLASSA(i)            (((long)(i) & 0x80000000L) == 0)
  111. #define IN_CLASSA_NET           0xff000000L
  112. #define IN_CLASSA_NSHIFT        24
  113. #define IN_CLASSA_HOST          0x00ffffffL
  114. #define IN_CLASSA_MAX           128
  115.  
  116. #define IN_CLASSB(i)            (((long)(i) & 0xc0000000L) == 0x80000000L)
  117. #define IN_CLASSB_NET           0xffff0000L
  118. #define IN_CLASSB_NSHIFT        16
  119. #define IN_CLASSB_HOST          0x0000ffffL
  120. #define IN_CLASSB_MAX           65536L
  121.  
  122. #define IN_CLASSC(i)            (((long)(i) & 0xe0000000L) == 0xc0000000L)
  123. #define IN_CLASSC_NET           0xffffff00L
  124. #define IN_CLASSC_NSHIFT        8
  125. #define IN_CLASSC_HOST          0x000000ffL
  126.  
  127. #define IN_CLASSD(i)            (((long)(i) & 0xf0000000L) == 0xe0000000L)
  128. #define IN_CLASSD_NET           0xffffffffL
  129. #define IN_CLASSD_HOST          0x00000000L
  130. #define IN_MULTICAST(i)         IN_CLASSD(i)
  131.  
  132. #define IN_EXPERIMENTAL(i)      (((long)(i) & 0xe0000000L) == 0xe0000000L)
  133. #define IN_BADCLASS(i)          (((long)(i) & 0xf0000000L) == 0xf0000000L)
  134.  
  135. #define INADDR_BROADCAST        (unsigned long)0xffffffffL     /* must be masked */
  136.  
  137. #define INADDR_UNSPEC_GROUP     (unsigned long )0xe0000000      /* 224.0.0.0   */
  138. #define INADDR_ALLHOSTS_GROUP   (unsigned long)0xe0000001      /* 224.0.0.1   */
  139. #define INADDR_MAX_LOCAL_GROUP  (unsigned long)0xe00000ff      /* 224.0.0.255 */
  140.  
  141. #ifndef KERNEL
  142. #define INADDR_NONE             0xffffffffL             /* -1 return */
  143. #endif
  144.  
  145. #define IN_LOOPBACKNET          127                     /* official! */
  146.  
  147. /*
  148.  * Options for use with [gs]etsockopt at the IP level.
  149.  */
  150. #define IP_OPTIONS      1               /* set/get IP per-packet options */
  151.  
  152. #define IP_MULTICAST_IF    2            /* set/get IP multicast interface*/
  153. #define IP_MULTICAST_TTL   3            /* set/get IP multicast timetolive*/
  154. #define IP_MULTICAST_LOOP  4            /* set/get IP multicast loopback */
  155. #define IP_ADD_MEMBERSHIP  5            /* add  an IP group membership   */
  156. #define IP_DROP_MEMBERSHIP 6            /* drop an IP group membership   */
  157.  
  158. #define IP_DEFAULT_MULTICAST_TTL  1     /* normally limit m'casts to 1 hop */
  159. #define IP_DEFAULT_MULTICAST_LOOP 1     /* normally hear sends if a member */
  160. #define IP_MAX_MEMBERSHIPS       20     /* per socket; must fit in one mbuf*/
  161.  
  162. /*
  163.  * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
  164.  */
  165. struct ip_mreq {
  166.         struct in_addr  imr_multiaddr;  /* IP multicast address of group */
  167.         struct in_addr  imr_interface;  /* local IP address of interface */
  168. };
  169.  
  170. struct in_addr _System inet_makeaddr(unsigned long, unsigned long);
  171. unsigned long _System inet_network(char *);
  172. char * _System inet_ntoa(struct in_addr);
  173. unsigned long _System inet_lnaof(struct in_addr);
  174. unsigned long _System inet_netof(struct in_addr);
  175.  
  176.  
  177.