home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / nb_agent / nba.h < prev    next >
C/C++ Source or Header  |  1992-07-09  |  3KB  |  91 lines

  1. /*
  2. ----------------------------------------------------------------------------
  3.  
  4.         Copyright (C) 1990 Novell, Inc.
  5.     
  6.         This software may be freely copied and distributed, provided the 
  7.         above copyright notice is included. It may not be sold, in whole
  8.         or in part, without the prior written consent of Novell, Inc.
  9.  
  10. ----------------------------------------------------------------------------
  11.  
  12.      NBA.H   header file for nba.c
  13.  
  14. */
  15.  
  16. /******* "ignore" this stuff ******/
  17. #ifndef FD_SET
  18. #define    NBBY    8        /* number of bits in a byte */
  19. /*
  20.  * Select uses bit masks of file descriptors in longs.
  21.  * These macros manipulate such bit fields (the filesystem macros use chars).
  22.  * FD_SETSIZE may be defined by the user, but the default here
  23.  * should be >= NOFILE (param.h).
  24.  */
  25. #ifndef    FD_SETSIZE
  26. #define    FD_SETSIZE    32
  27. #endif
  28.  
  29. typedef long    fd_mask;
  30. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  31. #ifndef howmany
  32. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  33. #endif
  34.  
  35. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  36. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  37. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  38. #define FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  39. #endif
  40. /**************** real stuff below here *****************/
  41.  
  42.  
  43.  
  44. typedef      unsigned short         USHORT;
  45. typedef      unsigned long          ULONG;
  46. typedef      unsigned                 BOOL;
  47.  
  48. #define        TRUE                        1
  49. #define        FALSE                     0
  50.  
  51. #define         NBA_WK_PORT              3000           /* an unassigned port */
  52. #define         BAQSIZE                    100 
  53. #define         BAPKTLIFE                5           /* packet life */
  54. #define        SZ_NCBNAME                16
  55. #define         SOCKADDRSIZE              sizeof(struct sockaddr_in)
  56. #define         AGENT_NAME_LEN         11 
  57. #define         FILE_NAME_LEN          80 
  58.  
  59.  
  60. /* BA status codes */
  61. #define         BA_SEND                    0
  62. #define         BA_REPLY                 1
  63. #define         BA_ERROR                    -1
  64.  
  65. #define         NS_RES_MASK                0x8000    /* mask for the NS response bit */
  66.  
  67. /* conversion macros */
  68.     /* convert network order long to network order short */
  69. #define         NLtoNS(x)                htons((USHORT)ntohl(x)) 
  70.     /* convert network order short to network order long */
  71. #define         NStoNL(x)                htonl((ULONG)ntohs(x))
  72.  
  73. struct ba_header {
  74.     ULONG       status;                /* command codes for BA agents */
  75.     ULONG          time;                    /* time stamp for packet expiration */
  76.     ULONG     ns_tid;                /* name service transaction id */
  77.     ULONG     ba_tid;                /* BA agent transaction id */
  78.     ULONG      host_addr;            /* BA agent address */
  79.     ULONG     client_addr;        /* NS client address   */
  80.     ULONG     client_port;        /* NS client port */
  81. #define         BAHEADERSIZE            sizeof(struct ba_header)
  82. };
  83.  
  84. struct ba_pkt {
  85.     struct     ba_header baheader;
  86.     struct     namepkt   namepkt;
  87. #define         BAPKTSIZE                sizeof(struct ba_header) + SZ_BUFFER
  88. };
  89.  
  90.  
  91.