home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / dax1.exe / DAP / DAP.H < prev    next >
Text File  |  1992-07-15  |  13KB  |  313 lines

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      dap.h                                                 ║
  4. //   ║                                                                    ║
  5. //   ║  This software is provided as is and carries no warranty           ║
  6. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  7. //   ║  warranties of merchantability, title and fitness for a particular ║
  8. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  9. //   ║  your requirements or that the software is without defect or error ║
  10. //   ║  or that operation of the software will be uninterrupted.  You are ║
  11. //   ║  using the software at your risk.  The software is not a product   ║
  12. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  13. //   ║                                                                    ║
  14. //   ╟────────────────────────────────────────────────────────────────────╢
  15. //   ║ maintenance history:                                               ║
  16. //   ║ level    date      pi   description                                ║
  17. //   ╟────────────────────────────────────────────────────────────────────╢
  18. //   ║  001   01/23/92    kl   initial release.                           ║
  19. //   ╚════════════════════════════════════════════════════════════════════╝
  20.  
  21. #if !defined(DAPHEADER)
  22. #define DAPHEADER
  23.  
  24. #if defined(ENGINE)
  25. #include    <nwtypes.h>
  26. #elif defined(DOSCLIENT) || defined(WINCLIENT)
  27. #include    <nit.h>
  28. #elif defined(NLMCLIENT)
  29. #include    <nwtypes.h>
  30. #include    <nwbindry.h>
  31. #include    <nwconn.h>
  32. #include    <process.h>
  33. #endif
  34.  
  35. #include    "h/extypes.h"
  36. #include    "dap/config.h"
  37. #include    "dap/dapdbg.h"
  38.  
  39. #define DAPSIGNATURE    0x20504144      // 'DAP ' signature value
  40.  
  41. //
  42. //  The following constants are used in the packetType field of a 
  43. //  DAP Request or Reply packet.
  44. //
  45. //
  46. //  Future versions may support bi-directional requests, i.e.
  47. //  the client OR server can initiate a request.  Since, both
  48. //  requests and replies are de-multiplexed off of the same virtual
  49. //  session, the packettype field is used to indicate what type
  50. //  of data has been received.  The manifest constants below are
  51. //  valid 'packettype' values.
  52. //
  53. //!!
  54. //  Add a DAPCalloutAPI to the CP Layer so it can notify the DAP
  55. //  Layer of a communication failure for client cleanup purposes.
  56. //!!
  57.  
  58. #define DAPSERVICEREQUEST       0x0100
  59. #define DAPSERVICEREPLY         0x0200
  60. #define DAPSERVICEBROADCAST     0x0300
  61.  
  62. //
  63. //  The following constants define the actual function numbers of the
  64. //  various protocol packets supported by the application.
  65. //
  66.  
  67. #define DAPLOCATESERVER         0x1001
  68. #define DAPADVERTISESERVER      0x1002
  69. #define DAPALLOCATESESSION      0x1010
  70. #define DAPDEALLOCATESESSION    0x1011
  71. #define DAPADDOPERANDS          0x1012
  72. #define DAPSUBTRACTOPERANDS     0x1013
  73. #define DAPMULTIPLYOPERANDS     0x1014
  74. #define DAPDIVIDEOPERANDS       0x1015
  75. #define DAPRESETCALCULATOR      0x1016
  76. #define DAPSTOREVALUE           0x1017
  77. #define DAPRECALLVALUE          0x1018
  78.  
  79. //
  80. //  The following constants define the error codes returned by DAP APIs
  81. //
  82. //  Negative values reflect DAP request/reply processing errors as well
  83. //  as CP failures.  When the application receives one of these errors,
  84. //  it may need to re-establish communications with the application
  85. //  server.
  86. //
  87. //  Positive values are those which should be acted upon by the application.
  88. //  Things like "DIVIDE_BY_ZERO", "NUMERIC_OVERFLOW" and the like.  These
  89. //  types of errors are non-critical in nature, and the connection status
  90. //  remains intact.
  91. //
  92. //  Remember to update DAPERR.C if you add new error codes.
  93. //
  94.  
  95. #define DAP_SUCCESS             0
  96. #define DAP_CRITICAL_ERROR(x)   (x<DAP_LOW_FATAL_ERROR&&x>DAP_HI_FATAL_ERROR)
  97.  
  98. #define DAP_LOW_FATAL_ERROR     (-0x700)
  99. #define DAP_CANT_FIND_SERVER    (-0x701)
  100. #define DAP_CANT_CONNECT        (-0x702)
  101. #define DAP_PACKET_OUT_OF_SEQ   (-0x703)
  102. #define DAP_SEND_FAILURE        (-0x704)
  103. #define DAP_INVALID_REQUEST     (-0x705)
  104. #define DAP_INITFAILED          (-0x706)
  105. #define DAP_RESOURCE_ERROR      (-0x707)
  106. #define DAP_INTERNAL_ERROR      (-0x708)
  107. #define DAP_TIMEOUT             (-0x709)
  108. #define DAP_HI_FATAL_ERROR      (-0x7ff)
  109.  
  110. #define DAP_DIVIDE_BY_ZERO      0x701
  111. #define DAP_NUMERIC_OVERFLOW    0x702
  112.  
  113. #if !defined(DAPINCLSTRUC)
  114. //
  115. //  INCLSTRUC is defined when you want to get the actual structure
  116. //  definitions for internal structures.  Since this header file is
  117. //  included by the layer above here, we can 'hide' the structure
  118. //  definition by simply making DAPDATA a void data type.  When a module
  119. //  is going to reference the structures, it must define INCLSTRUC in
  120. //  order to get the actual structures declared.
  121. //
  122. typedef void    DAPDATA;
  123.  
  124. #else
  125.  
  126. //
  127. //  The following structures define the packet layout exchanged between
  128. //  the client and server DAP layer.  In the data portion, the layout
  129. //  is defined by each individual DAP.
  130. //
  131.  
  132. typedef struct {
  133.         UINT32      packetType;         // whether to/from server
  134.         UINT32      sequence;           // sequence number of request
  135.         UINT32      sessionID;          // client session number
  136.         UINT32      timesTried;         // number of times we've resent this
  137.         UINT32      requestCode;        // function request code
  138.         UINT8       data[DAPMAXDATA];   // the actual data
  139. }DAPRequest;
  140.  
  141. typedef struct {
  142.         UINT32      packetType;         // whether to/from server
  143.         UINT32      sequence;           // sequence number of reply
  144.         UINT32      returnCode;         // function return code
  145.         UINT8       data[DAPMAXDATA];   // the actual data
  146.         UINT32      dummy[2];           // keep structures the same length
  147. }DAPReply;
  148.  
  149. #if !defined(ENGINE)
  150.  
  151. //
  152. //  The following structure is used on the client side to keep track of
  153. //  the DAP operations.  DAPAllocateSession returns a pointer to one of
  154. //  these, and all subsequent DAP requests made by the client application
  155. //  pass the pointer to the API.
  156. //
  157. typedef struct  {
  158.         void        *CPid;          // data for comm proto layer
  159.         UINT32      sessionID;      // id between client server DAP Layer
  160.         UINT16      retryCount;     // retry count for this session
  161.         UINT16      responseDelay;  // units to wait for a reply
  162.         UINT16      timesTried;     // number of times we sent duplicate msg
  163.         UINT16      sendFailed;     // number of times the actual send failed
  164.         char        serverName[48];
  165.         UINT32      nextSequence;   // next sequence number to use
  166.         DAPRequest  dapRequest;
  167.         DAPReply    dapReply;
  168. }DAPDATA;
  169.  
  170. #else   // !defined(ENGINE)
  171.  
  172. //
  173. //  The following structure is used on the server side to keep track of
  174. //  a DAP session.  An array of these is maintained by the server application
  175. //  for each active session in progress.
  176. //
  177.  
  178. typedef struct  _dd{
  179.         //
  180.         //  These linked-list pointers are used to queue up requests.  When
  181.         //  the client sends in a request, the DAP layer queues this struct
  182.         //  onto a linked list for processing by a separate thread.  These
  183.         //  pointers are also used for queueing up this structure for an
  184.         //  outgoing message.
  185.         //
  186.         struct _dd  *next;          // pointer to next one in link
  187.         struct _dd  *prev;          // pointer to previous link
  188.         //
  189.         //  The CPid is obtained from the CP Layer when a new session is
  190.         //  established between the client and server.  This id is used
  191.         //  by the DAP layer when sending replies to the client.
  192.         //
  193.         UINT32      CPid;           // client id for comm proto layer
  194.         //!!
  195.         //      Need to be able to turn this state thing off!
  196.         //!!
  197.         //  Field:  DAPState
  198.         //  Type:   UINT32
  199.         //  This field is used to provide state information for this
  200.         //  client.  It is a bit field, whose definition is:
  201.         //
  202.         //  INUSE           0x1
  203.         //      - This DAP is currently in use servicing a client request.
  204.         //
  205.         //  RQSTQUEUE       0x2
  206.         //      - This DAP is sitting in the request queue.
  207.         //
  208.         //  DAP_RECEIVING   0x4
  209.         //      - The DAP is being processed by ServiceRequestQueue
  210.         //
  211.         //  DAP_SERVICE     0x8
  212.         //      - This DAP is active in DAPDispatchRequestAPI()
  213.         //
  214.         //  DAP_SENDQUEUE   0x10
  215.         //      - The DAP is sitting in the send queue.
  216.         //
  217.         //  DAP_SENDING     0x20
  218.         //      - The DAP is being serviced inside ServiceReplyQueue
  219.         //
  220.         //  DAP_CLIENTLOGIN 0x40
  221.         //      - The DAP has had a successful login to the engine
  222.         //
  223.         //  DAP_SLOTINUSE   0x8000
  224.         //      - This DAP is currently in use by a client.  Used when
  225.         //        we are trying to locate an emply slot in the DAP array.
  226.         //
  227.         #define     DAP_INUSE           0x1
  228.         #define     DAP_RQSTQUEUE       0x2
  229.         #define     DAP_RECEIVING       0x4
  230.         #define     DAP_SERVICE         0x8
  231.         #define     DAP_SENDQUEUE       0x10
  232.         #define     DAP_SENDING         0x20
  233.         #define     DAP_CLIENTLOGIN     0x40
  234.         #define     DAP_SLOTINUSE       0x8000
  235.         //
  236.         //  Macros to manipulate the DAPState field
  237.         //
  238.         #define     DAPStateON(x,y)     ((x)->DAPState |= y)
  239.         #define     DAPStateOFF(x,y)    ((x)->DAPState &= ~y)
  240.         #define     DAPStateActive(x,y) ((x)->DAPState & y)
  241.         #define     DAPInUse(x)         ((x)->DAPState & DAP_INUSE)
  242.         #define     DAPSlotInUse(x)     ((x)->DAPState & DAP_SLOTINUSE)
  243.         //
  244.         //  And finally, the definition of DAPState
  245.         //
  246.         UINT32      DAPState;
  247.         //
  248.         //  Field:  DAPFlags
  249.         //  Type:   UINT32
  250.         //  This field by whatever mechanisms need flags...
  251.         //
  252.         //  DAP_FREE_THIS_SLOT  0x1
  253.         //      - Used by the DeAllocateSession DAP to tell the
  254.         //        ServiceReplyQueue thread to free the slot after
  255.         //        sending a reply.
  256.         //
  257.         #define     DAP_FREE_THIS_SLOT  0x1
  258.         //
  259.         //  Macros to manipulate the 'flags'
  260.         //
  261.         #define     DAPSetFlag(x,y)     ((x)->DAPFlags |= y)
  262.         #define     DAPReSetFlag(x,y)   ((x)->DAPFlags &= ~y)
  263.         #define     DAPFlagIsSet(x,y)   ((x)->DAPFlags & y)
  264.         //
  265.         //  And finally, the definition of flags
  266.         //
  267.         UINT32      DAPFlags;
  268.         //
  269.         //  Allocate memory for both a dapRequest and dapReply structure
  270.         //  in here.  This provides temporary storage for incoming and
  271.         //  outgoing requests.
  272.         //
  273.         DAPRequest  dapRequest;
  274.         DAPReply    dapReply;
  275.         //
  276.         //  We have two options here on the server side. 
  277.         //      1.  define the structure needed by the application
  278.         //          inside this structure definition.
  279.         //      2.  have a pointer to the data structure stored only
  280.         //
  281.         //  if we define the structure here, then the DAP APIs will
  282.         //  be doing all the work themselves when they are called.
  283.         //  the pointer method would probably be used to call out to
  284.         //  a different layer (perhaps an application layer) that
  285.         //  would do some work for us.
  286.         //
  287.         //  if INCDATAAREA is TRUE, we just include the structure in
  288.         //  this structure.
  289.         //
  290.         //  if INCDATAAREA is FALSE, however, we just define a void ptr.
  291.         //
  292.         //  The source code uses the DAPGetApplDataAreaPtr() macro to
  293.         //  reference the applData field so it works for both methods.
  294.         //
  295.     #if INCDATAAREA
  296.         #define     DAPGetApplDataAreaPtr(x)    (&((x)->applData))
  297.         #define     DAPGetApplDataStructure(x)  ((x)->applData)
  298.         struct{
  299.         SINT32      lastResult;
  300.         SINT32      mailBox001;
  301.         }applData;
  302.     #else
  303.         #define     DAPGetApplDataAreaPtr(x)    ((x)->applData)
  304.         void        *applData;
  305.     #endif
  306. }DAPDATA;
  307.  
  308. #endif  //  !defined(ENGINE)
  309.  
  310. #endif  //  !defined(DAPINCLSTRUC)
  311.  
  312. #endif
  313.