Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

463 lines
12 KiB

  1. /*
  2. * sesskey.h
  3. *
  4. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the class CSessKeyContainer. This class
  8. * manages the data associated with a Session Key. Session Keys are used
  9. * to uniquely identify an Application Protocol Session. The Application
  10. * Protocol is identified by an Object Key and the particular session
  11. * identified by an optional session ID. The CSessKeyContainer class uses an
  12. * CObjectKey container to maintain the object key data internally. An
  13. * unsigned short integer is used to hold the optional session ID.
  14. *
  15. * Caveats:
  16. * None.
  17. *
  18. * Author:
  19. * jbo
  20. */
  21. #ifndef _SESSION_KEY_DATA_
  22. #define _SESSION_KEY_DATA_
  23. #include "objkey.h"
  24. /*
  25. * This is the typedef for the structure used to hold the session key data
  26. * internally.
  27. */
  28. typedef struct
  29. {
  30. CObjectKeyContainer *application_protocol_key;
  31. GCCSessionID session_id;
  32. }
  33. SESSION_KEY;
  34. /*
  35. * Class definition:
  36. */
  37. class CSessKeyContainer : public CRefCount
  38. {
  39. public:
  40. CSessKeyContainer(PGCCSessionKey, PGCCError);
  41. CSessKeyContainer(PSessionKey, PGCCError);
  42. CSessKeyContainer(CSessKeyContainer *, PGCCError);
  43. ~CSessKeyContainer(void);
  44. UINT LockSessionKeyData(void);
  45. void UnLockSessionKeyData(void);
  46. UINT GetGCCSessionKeyData(PGCCSessionKey, LPBYTE memory);
  47. GCCError GetSessionKeyDataPDU(PSessionKey);
  48. void FreeSessionKeyDataPDU(void);
  49. BOOL IsThisYourApplicationKey(PGCCObjectKey);
  50. BOOL IsThisYourApplicationKeyPDU(PKey);
  51. BOOL IsThisYourSessionKeyPDU(PSessionKey);
  52. #if 0 // LONCHANC: no one use them
  53. BOOL IsThisYourSessionID(PSessionKey pSessKey)
  54. {
  55. return (m_InternalSessKey.session_id == pSessKey->session_id);
  56. }
  57. BOOL IsThisYourSessionID(PGCCSessionKey pGccSessKey)
  58. {
  59. return (m_InternalSessKey.session_id == pGccSessKey->session_id);
  60. }
  61. BOOL IsThisYourSessionID(UINT nSessionID)
  62. {
  63. return ((UINT) m_InternalSessKey.session_id == nSessionID);
  64. }
  65. #endif
  66. friend BOOL operator== (const CSessKeyContainer&, const CSessKeyContainer&);
  67. protected:
  68. SESSION_KEY m_InternalSessKey;
  69. UINT m_cbDataSize;
  70. SessionKey m_SessionKeyPDU;
  71. BOOL m_fValidSessionKeyPDU;
  72. };
  73. /*
  74. * Comments explaining the public and protected class member functions
  75. */
  76. /*
  77. * CSessKeyContainer ( PGCCSessionKey session_key,
  78. * PGCCError return_value);
  79. *
  80. * Public member function of CSessKeyContainer.
  81. *
  82. * Function Description:
  83. * This is the constructor for the CSessKeyContainer class which takes as
  84. * input the "API" version of session key data, GCCSessionKey.
  85. *
  86. * Formal Parameters:
  87. * session_key (i) The session key data to store.
  88. * return_value (o) The output parameter used to indicate errors.
  89. *
  90. * Return Value:
  91. * GCC_NO_ERROR - No error.
  92. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  93. * "new" operator.
  94. * GCC_BAD_SESSION_KEY - An invalid session key passed in.
  95. *
  96. * Side Effects:
  97. * None.
  98. *
  99. * Caveats:
  100. * None.
  101. */
  102. /*
  103. * CSessKeyContainer ( PSessionKey session_key,
  104. * PGCCError return_value);
  105. *
  106. * Public member function of CSessKeyContainer.
  107. *
  108. * Function Description:
  109. * This is the constructor for the CSessKeyContainer class which takes as
  110. * input the "PDU" version of session key data, SessionKey.
  111. *
  112. * Formal Parameters:
  113. * session_key (i) The session key data to store.
  114. * return_value (o) The output parameter used to indicate errors.
  115. *
  116. * Return Value:
  117. * GCC_NO_ERROR - No error.
  118. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  119. * "new" operator.
  120. * GCC_BAD_SESSION_KEY - An invalid session key passed in.
  121. *
  122. * Side Effects:
  123. * None.
  124. *
  125. * Caveats:
  126. * None.
  127. */
  128. /*
  129. * CSessKeyContainer(CSessKeyContainer *session_key,
  130. * PGCCError return_value);
  131. *
  132. * Public member function of CSessKeyContainer.
  133. *
  134. * Function Description:
  135. * This is the copy constructor for the CSessKeyContainer class which takes
  136. * as input another CSessKeyContainer object.
  137. *
  138. * Formal Parameters:
  139. * session_key (i) The CSessKeyContainer object to copy.
  140. * return_value (o) The output parameter used to indicate errors.
  141. *
  142. * Return Value:
  143. * GCC_NO_ERROR - No error.
  144. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  145. * "new" operator.
  146. * GCC_BAD_SESSION_KEY - An invalid session key passed in.
  147. *
  148. * Side Effects:
  149. * None.
  150. *
  151. * Caveats:
  152. * None.
  153. */
  154. /*
  155. * ~SessionKeyData();
  156. *
  157. * Public member function of CSessKeyContainer.
  158. *
  159. * Function Description:
  160. * This is the destructor for the CSessKeyContainer class. It is used to
  161. * clean up any memory allocated during the life of this object.
  162. *
  163. * Formal Parameters:
  164. * None.
  165. *
  166. * Return Value:
  167. * None.
  168. *
  169. * Side Effects:
  170. * None.
  171. *
  172. * Caveats:
  173. * None.
  174. */
  175. /*
  176. * UINT LockSessionKeyData ();
  177. *
  178. * Public member function of CSessKeyContainer.
  179. *
  180. * Function Description:
  181. * This routine is used to "lock" the "API" data for this object. This
  182. * results in the lock count for this object being incremented. When the
  183. * lock count transitions from 0 to 1, a calculation is made to determine
  184. * how much memory will be needed to hold any "API" data which will
  185. * be referenced by, but not held in, the GCCSessionKey structure
  186. * which is filled in on a call to GetGCCSessionKeyData. This is the
  187. * value returned by this routine in order to allow the calling object to
  188. * allocate that amount of memory in preparation for the call to
  189. * GetGCCSessionKeyData.
  190. *
  191. * Formal Parameters:
  192. * None.
  193. *
  194. * Return Value:
  195. * The amount of memory, if any, which will be needed to hold "API" data
  196. * which is referenced by, but not held in, the GCCSessionKey structure
  197. * provided as an output parameter to the GetGCCSessionKeyData call.
  198. *
  199. * Side Effects:
  200. * The internal lock count is incremented.
  201. *
  202. * Caveats:
  203. * The internal lock count is used in conjuction with an internal "free"
  204. * flag as a mechanism for ensuring that this object remains in existance
  205. * until all interested parties are through with it. The object remains
  206. * valid (unless explicity deleted) until the lock count is zero and the
  207. * "free" flag is set through a call to FreeSessionKeyData. This allows
  208. * other objects to lock this object and be sure that it remains valid
  209. * until they call UnLock which will decrement the internal lock count. A
  210. * typical usage scenerio for this object would be: A CSessKeyContainer
  211. * object is constructed and then passed off to any interested parties
  212. * through a function call. On return from the function call, the
  213. * FreeSessionKeyData call is made which will set the internal "free"
  214. * flag. If no other parties have locked the object with a Lock call,
  215. * then the CSessKeyContainer object will automatically delete itself when
  216. * the FreeSessionKeyData call is made. If, however, any number of
  217. * other parties has locked the object, it will remain in existence until
  218. * each of them has unlocked the object through a call to UnLock.
  219. */
  220. /*
  221. * UINT GetGCCSessionKeyData (
  222. * PGCCSessionKey session_key,
  223. * LPSTR memory);
  224. *
  225. * Public member function of CSessKeyContainer.
  226. *
  227. * Function Description:
  228. * This routine is used to retrieve the session key data from the
  229. * CSessKeyContainer object in the "API" form of a GCCSessionKey.
  230. *
  231. * Formal Parameters:
  232. * session_key (o) The GCCSessionKey structure to fill in.
  233. * memory (o) The memory used to hold any data referenced by,
  234. * but not held in, the output structure.
  235. *
  236. * Return Value:
  237. * The amount of data, if any, written into the bulk memory block provided.
  238. *
  239. * Side Effects:
  240. * None.
  241. *
  242. * Caveats:
  243. * None.
  244. */
  245. /*
  246. * void UnLockSessionKeyData ();
  247. *
  248. * Public member function of CSessKeyContainer.
  249. *
  250. * Function Description:
  251. * This routine is used to "unlock" the "API" data for this object. This
  252. * results in the lock count for this object being decremented. When the
  253. * lock count transitions from 1 to 0, a check is made to determine
  254. * whether the object has been freed through a call to
  255. * FreeSessionKeyData. If so, the object will automatically delete
  256. * itself.
  257. *
  258. * Formal Parameters:
  259. * None.
  260. *
  261. * Return Value:
  262. * None.
  263. *
  264. * Side Effects:
  265. * The internal lock count is decremented.
  266. *
  267. * Caveats:
  268. * It is the responsibility of any party which locks a CSessKeyContainer
  269. * object by calling Lock to also unlock the object with a call to UnLock.
  270. * If the party calling UnLock did not construct the CSessKeyContainer
  271. * object, it should assume the object to be invalid thereafter.
  272. */
  273. /*
  274. * GCCError GetSessionKeyDataPDU (
  275. * PSessionKey session_key);
  276. *
  277. * Public member function of CSessKeyContainer.
  278. *
  279. * Function Description:
  280. * This routine is used to retrieve the session key data from the
  281. * CSessKeyContainer object in the "PDU" form of a SessionKey.
  282. *
  283. * Formal Parameters:
  284. * session_key (o) The SessionKey structure to fill in.
  285. *
  286. * Return Value:
  287. * GCC_NO_ERROR - No error.
  288. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  289. * "new" operator.
  290. *
  291. * Side Effects:
  292. * None.
  293. *
  294. * Caveats:
  295. * None.
  296. */
  297. /*
  298. * void FreeSessionKeyDataPDU ();
  299. *
  300. * Public member function of CSessKeyContainer.
  301. *
  302. * Function Description:
  303. * This routine is used to "free" the "PDU" data allocated for this object
  304. * which is held internally in a Key structure.
  305. *
  306. * Formal Parameters:
  307. * None.
  308. *
  309. * Return Value:
  310. * None.
  311. *
  312. * Side Effects:
  313. * The internal "free" flag is set.
  314. *
  315. * Caveats:
  316. * This object should be assumed invalid after a call to
  317. * FreeSessionKeyDataPDU has been made.
  318. */
  319. /*
  320. * BOOL IsThisYourApplicationKey (
  321. * PGCCObjectKey application_key);
  322. *
  323. * Public member function of CSessKeyContainer.
  324. *
  325. * Function Description:
  326. * This routine is used to determine whether the specified application key
  327. * is held within this session key object. The application key is
  328. * provided in "API" form.
  329. *
  330. * Formal Parameters:
  331. * application_key (i) The application key to use for comparison.
  332. *
  333. * Return Value:
  334. * TRUE - The specified application key is contained
  335. * within this session key object.
  336. * FALSE - The specified application key is not contained
  337. * within this session key object.
  338. *
  339. * Side Effects:
  340. * None.
  341. *
  342. * Caveats:
  343. * None.
  344. */
  345. /*
  346. * BOOL IsThisYourApplicationKeyPDU (
  347. * PKey application_key);
  348. *
  349. * Public member function of CSessKeyContainer.
  350. *
  351. * Function Description:
  352. * This routine is used to determine whether the specified application key
  353. * is held within this session key object. The application key is
  354. * provided in "PDU" form.
  355. *
  356. * Formal Parameters:
  357. * application_key (i) The application key to use for comparison.
  358. *
  359. * Return Value:
  360. * TRUE - The specified application key is contained
  361. * within this session key object.
  362. * FALSE - The specified application key is not contained
  363. * within this session key object.
  364. *
  365. * Side Effects:
  366. * None.
  367. *
  368. * Caveats:
  369. * None.
  370. */
  371. /*
  372. * BOOL IsThisYourSessionKeyPDU (
  373. * PSessionKey session_key);
  374. *
  375. * Public member function of CSessKeyContainer.
  376. *
  377. * Function Description:
  378. * This routine is used to determine whether the specified session key
  379. * is equal in value to the session key maintained by this object.
  380. *
  381. * Formal Parameters:
  382. * session_key (i) The session key to use for comparison.
  383. *
  384. * Return Value:
  385. * TRUE - The specified session key is equal in value to
  386. * the session key maintained by this object.
  387. * FALSE - The specified session key is not equal in value
  388. * to the session key maintained by this
  389. * object.
  390. *
  391. * Side Effects:
  392. * None.
  393. *
  394. * Caveats:
  395. * None.
  396. */
  397. /*
  398. * friend BOOL operator== (const CSessKeyContainer& session_key_1,
  399. * const CSessKeyContainer& session_key_2);
  400. *
  401. * Public member function of CSessKeyContainer.
  402. *
  403. * Function Description:
  404. * This routine is used to compare two CSessKeyContainer objects to determine
  405. * whether or not they are equal in value.
  406. *
  407. * Formal Parameters:
  408. * session_key_1 (i) The first CSessKeyContainer object to compare.
  409. * session_key_2 (i) The other CSessKeyContainer object to compare.
  410. *
  411. * Return Value:
  412. * TRUE - The two objects are equal in value.
  413. * FALSE - The two objects are not equal in value.
  414. *
  415. * Side Effects:
  416. * None.
  417. *
  418. * Caveats:
  419. * None.
  420. */
  421. #endif