home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / djgpp / contrib / dvx / inc / netinet / in.h
Encoding:
C/C++ Source or Header  |  1993-07-15  |  4.0 KB  |  137 lines

  1. /*
  2.  * DESQview/X Socket Library. 
  3.  * Copyright (c) 1991,1992,1993 Quarterdeck Office Systems.
  4.  *
  5.  *
  6.  * Copyright (c) 1983 Regents of the University of California.
  7.  * All rights reserved.  The Berkeley software License Agreement
  8.  * specifies the terms and conditions for redistribution.
  9.  */
  10.  
  11. /*
  12.  * Constants and structures defined by the internet system,
  13.  * Per RFC 790, September 1981.
  14.  */
  15.  
  16. #ifndef _NETINET_IN_H_
  17. #define _NETINET_IN_H_
  18.  
  19. /*
  20.  * Protocols
  21.  */
  22. #define IPPROTO_TCP        6        /* tcp */
  23. #define IPPROTO_UDP        17        /* user datagram protocol */
  24. /*
  25.  * Local port number conventions:
  26.  * Ports < IPPORT_RESERVED are reserved for
  27.  * privileged processes (e.g. root).
  28.  * Ports > IPPORT_USERRESERVED are reserved
  29.  * for servers, not necessarily privileged.
  30.  */
  31. #define IPPORT_RESERVED         1024
  32. #define IPPORT_USERRESERVED     5000
  33.  
  34. /*
  35.  * Definitions of bits in internet address integers.
  36.  * On subnets, the decomposition of addresses to host and net parts
  37.  * is done according to subnet mask, not the masks here.
  38.  */
  39. #define IN_CLASSA(i)            (((long)(i) & 0x80000000) == 0)
  40. #define IN_CLASSA_NET           0xff000000
  41. #define IN_CLASSA_NSHIFT        24
  42. #define IN_CLASSA_HOST          0x00ffffff
  43. #define IN_CLASSA_MAX           128
  44.  
  45. #define IN_CLASSB(i)            (((long)(i) & 0xc0000000) == 0x80000000)
  46. #define IN_CLASSB_NET           0xffff0000
  47. #define IN_CLASSB_NSHIFT        16
  48. #define IN_CLASSB_HOST          0x0000ffff
  49. #define IN_CLASSB_MAX           65536
  50.  
  51. #define IN_CLASSC(i)            (((long)(i) & 0xe0000000) == 0xc0000000)
  52. #define IN_CLASSC_NET           0xffffff00
  53. #define IN_CLASSC_NSHIFT        8
  54. #define IN_CLASSC_HOST          0x000000ff
  55.  
  56. #define IN_CLASSD(i)            (((long)(i) & 0xf0000000) == 0xe0000000)
  57. #define IN_MULTICAST(i)         IN_CLASSD(i)
  58.  
  59. #define IN_EXPERIMENTAL(i)      (((long)(i) & 0xe0000000) == 0xe0000000)
  60. #define IN_BADCLASS(i)          (((long)(i) & 0xf0000000) == 0xf0000000)
  61.  
  62.  
  63. /* Internet Address structure
  64. */
  65. struct in_addr {
  66.     union {
  67.         struct { char s_b1,s_b2,s_b3,s_b4; } S_un_b;
  68.         struct { unsigned short s_w1,s_w2; } S_un_w;
  69.         long S_addr;
  70.     } S_un;
  71. #define    s_addr  S_un.S_addr        /* can be used for most tcp & ip code */
  72. #define    s_host  S_un.S_un_b.s_b2   /* host on imp */
  73. #define    s_net   S_un.S_un_b.s_b1   /* network */
  74. #define    s_imp   S_un.S_un_w.s_w2   /* imp */
  75. #define    s_impno S_un.S_un_b.s_b4   /* imp # */
  76. #define    s_lh    S_un.S_un_b.s_b3   /* logical host */
  77. #define    S_baddr S_un.S_un_b
  78. };
  79.  
  80. #define    INADDR_ANY              (u_long)0x00000000
  81. #define    INADDR_BROADCAST        (u_long)0xffffffff      /* must be masked */
  82.  
  83. struct sockaddr_in {
  84.         short        sin_family;
  85.         unsigned short    sin_port;
  86.         struct in_addr    sin_addr;
  87.         char        sin_zero[8];
  88. };
  89.  
  90. #ifndef NO_PROTO
  91.  
  92. #ifdef __cplusplus                      /* for C++ V2.0 */
  93.   extern "C" {   /* do not leave open across includes */
  94. #endif /* __cplusplus */
  95.  
  96. /* Network and machine order conversion routines */
  97.  
  98.   unsigned short htons(unsigned short);
  99.   unsigned short ntohs(unsigned short);
  100.   unsigned long  htonl(unsigned long);
  101.   unsigned long  ntohl(unsigned long);
  102.  
  103. /* Inet C functions    */
  104.  
  105.   unsigned long  inet_addr(const char *);
  106.   unsigned long  inet_network(const char *);
  107.   char           *inet_ntoa(struct in_addr);
  108.   struct in_addr inet_makeaddr(long, long);
  109.   unsigned long  inet_lnaof(struct in_addr);
  110.   unsigned long  inet_netof(struct in_addr);
  111.  
  112. #ifdef __cplusplus                      /* for C++ V2.0 */
  113.   }
  114. #endif /* __cplusplus */
  115.  
  116. #else /* NO_PROTO */
  117.  
  118. /* Network and machine order conversion routines */
  119.  
  120.   unsigned short htons();
  121.   unsigned short ntohs();
  122.   unsigned long  htonl();
  123.   unsigned long  ntohl();
  124.  
  125. /* Inet C functions    */
  126.  
  127.   unsigned long  inet_addr();
  128.   unsigned long  inet_network();
  129.   char           *inet_ntoa();
  130.   struct in_addr inet_makeaddr();
  131.   unsigned long  inet_lnaof();
  132.   unsigned long  inet_netof();
  133.  
  134. #endif /* NO_PROTO */
  135.  
  136. #endif /* _NETINET_IN_H_ */
  137.