home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lansystk.zip / INCLUDE / MPTN / NETINET / IN.H < prev    next >
C/C++ Source or Header  |  1998-05-08  |  4KB  |  120 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. /*
  23.  * Protocols
  24.  */
  25. #define IPPROTO_IP              0               /* dummy for IP */
  26. #define IPPROTO_ICMP            1               /* control message protocol */
  27. #define IPPROTO_GGP             3               /* gateway^2 (deprecated) */
  28. #define IPPROTO_TCP             6               /* tcp */
  29. #define IPPROTO_EGP             8               /* exterior gateway protocol */
  30. #define IPPROTO_PUP             12              /* pup */
  31. #define IPPROTO_UDP             17              /* user datagram protocol */
  32. #define IPPROTO_IDP             22              /* xns idp */
  33.  
  34. #define IPPROTO_RAW             255             /* raw IP packet */
  35. #define IPPROTO_MAX             256
  36.  
  37.  
  38. /*
  39.  * Ports < IPPORT_RESERVED are reserved for
  40.  * privileged processes (e.g. root).
  41.  * Ports > IPPORT_USERRESERVED are reserved
  42.  * for servers, not necessarily privileged.
  43.  */
  44. #define IPPORT_RESERVED         1024
  45. #define IPPORT_USERRESERVED     5000
  46.  
  47. /*
  48.  * Link numbers
  49.  */
  50. #define IMPLINK_IP              155
  51. #define IMPLINK_LOWEXPER        156
  52. #define IMPLINK_HIGHEXPER       158
  53.  
  54. /*
  55.  * Internet address (a structure for historical reasons)
  56.  */
  57. struct in_addr {
  58.         unsigned long s_addr;
  59. };
  60.  
  61. /*
  62.  * Definitions of bits in internet address integers.
  63.  * On subnets, the decomposition of addresses to host and net parts
  64.  * is done according to subnet mask, not the masks here.
  65.  */
  66. #define IN_CLASSA(i)            (((long)(i) & 0x80000000L) == 0)
  67. #define IN_CLASSA_NET           0xff000000L
  68. #define IN_CLASSA_NSHIFT        24
  69. #define IN_CLASSA_HOST          0x00ffffffL
  70. #define IN_CLASSA_MAX           128
  71.  
  72. #define IN_CLASSB(i)            (((long)(i) & 0xc0000000L) == 0x80000000L)
  73. #define IN_CLASSB_NET           0xffff0000L
  74. #define IN_CLASSB_NSHIFT        16
  75. #define IN_CLASSB_HOST          0x0000ffffL
  76. #define IN_CLASSB_MAX           65536L
  77.  
  78. #define IN_CLASSC(i)            (((long)(i) & 0xe0000000L) == 0xc0000000L)
  79. #define IN_CLASSC_NET           0xffffff00L
  80. #define IN_CLASSC_NSHIFT        8
  81. #define IN_CLASSC_HOST          0x000000ffL
  82.  
  83. #define IN_CLASSD(i)            (((long)(i) & 0xf0000000L) == 0xe0000000L)
  84. #define IN_MULTICAST(i)         IN_CLASSD(i)
  85.  
  86. #define IN_EXPERIMENTAL(i)      (((long)(i) & 0xe0000000L) == 0xe0000000L)
  87. #define IN_BADCLASS(i)          (((long)(i) & 0xf0000000L) == 0xf0000000L)
  88.  
  89. #define INADDR_ANY              (unsigned long)0x00000000L
  90. #define INADDR_BROADCAST        (unsigned long)0xffffffffL     /* must be masked */
  91. #ifndef KERNEL
  92. #define INADDR_NONE             0xffffffffL             /* -1 return */
  93. #endif
  94.  
  95. #define IN_LOOPBACKNET          127                     /* official! */
  96.  
  97. /*
  98.  * Socket address, internet style.
  99.  */
  100. struct sockaddr_in {
  101.         short   sin_family;
  102.         unsigned short sin_port;
  103.         struct  in_addr sin_addr;
  104.         char    sin_zero[8];
  105. };
  106.  
  107. /*
  108.  * Options for use with [gs]etsockopt at the IP level.
  109.  */
  110. #define IP_OPTIONS      1               /* set/get IP per-packet options */
  111.  
  112. unsigned long _System inet_addr(char *);
  113. struct in_addr _System inet_makeaddr(unsigned long, unsigned long);
  114. unsigned long _System inet_network(char *);
  115. char * _System inet_ntoa(struct in_addr);
  116. unsigned long _System inet_lnaof(struct in_addr);
  117. unsigned long _System inet_netof(struct in_addr);
  118.  
  119. #endif /* __IN_32H */
  120.