Leaked source code of windows server 2003
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.

529 lines
16 KiB

  1. /*
  2. * channel.h
  3. *
  4. * Copyright (c) 1993 - 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the Channel class. This class represents
  8. * both static and assigned channels within an MCS domain. This class is
  9. * also the base class for all other types of channels in MCS. It defines
  10. * the default behavior that can be inherited by these other classes.
  11. *
  12. * Instances of the Channel class have three primary responsibilities:
  13. * managing the join/leave process; sending data; and issuing merge
  14. * requests during a domain merger.
  15. *
  16. * When a user tries to join a channel, the request is sent to the Channel
  17. * object that represents the channel. The Channel object can then decide
  18. * whether or not to allow the join. By overriding the appropriate
  19. * member functions, derived classes can change the criteria by which
  20. * this decision is made.
  21. *
  22. * All Channel objects maintain an internal list of which attachments are
  23. * joined to the channel they represent. When data is sent on the channel,
  24. * the request is sent to the Channel object, who then knows how to route
  25. * the data. The data is sent to all the appropriate attachments.
  26. *
  27. * During a domain information base merger, all Channel objects will be
  28. * asked to issue a merge request upward toward the new top provider. The
  29. * merge request will be built using information contained in the Channel
  30. * object.
  31. *
  32. * All public member functions of this class are declared as virtual, so
  33. * that they can be overridden in case a derived class has to modify the
  34. * behavior.
  35. *
  36. * Caveats:
  37. * None.
  38. *
  39. * Author:
  40. * James P. Galvin, Jr.
  41. */
  42. #ifndef _CHANNEL_
  43. #define _CHANNEL_
  44. /*
  45. * This is a dictionary of channels that exist within the current domain.
  46. * The key to the dictionary is the channel ID, by which channels are
  47. * identified. The value is a pointer to an object of class Channel. By
  48. * definition, if a channel is in the list, then it exists and knows how
  49. * to respond to channel related activity. If a channel is not in the
  50. * list, then it does not exist (from the point-of-view of this MCS
  51. * provider).
  52. */
  53. /*
  54. * This is the class definition for class Channel.
  55. */
  56. class Channel
  57. {
  58. public:
  59. Channel (
  60. ChannelID channel_id,
  61. PDomain local_provider,
  62. PConnection top_provider,
  63. CChannelList2 *channel_list,
  64. CAttachmentList *attachment_list);
  65. Channel (
  66. ChannelID channel_id,
  67. PDomain local_provider,
  68. PConnection top_provider,
  69. CChannelList2 *channel_list,
  70. CAttachmentList *attachment_list,
  71. PConnection pConn);
  72. virtual ~Channel ();
  73. void SetTopProvider(PConnection top_provider) { m_pConnToTopProvider = top_provider; }
  74. BOOL IsTopProvider(void) { return (NULL == m_pConnToTopProvider); }
  75. virtual Channel_Type GetChannelType ();
  76. virtual BOOL IsValid ();
  77. virtual CAttachment *GetAttachment(void) { return NULL; }
  78. virtual Void IssueMergeRequest ();
  79. virtual Void ChannelJoinRequest (
  80. CAttachment *originator,
  81. UserID uidInitiator,
  82. ChannelID channel_id);
  83. Void ChannelJoinConfirm (
  84. CAttachment *originator,
  85. Result result,
  86. UserID uidInitiator,
  87. ChannelID requested_id,
  88. ChannelID channel_id);
  89. Void ChannelLeaveRequest (
  90. CAttachment *originator,
  91. CChannelIDList *channel_id_list);
  92. virtual Void SendDataRequest (
  93. CAttachment *originator,
  94. UINT type,
  95. PDataPacket data_packet);
  96. Void SendDataIndication (
  97. PConnection originator,
  98. UINT type,
  99. PDataPacket data_packet);
  100. protected:
  101. ChannelID Channel_ID;
  102. PDomain m_pDomain;
  103. PConnection m_pConnToTopProvider;
  104. CChannelList2 *m_pChannelList2;
  105. CAttachmentList *m_pAttachmentList;
  106. CAttachmentList m_JoinedAttachmentList;
  107. };
  108. /*
  109. * Channel (
  110. * ChannelID channel_id,
  111. * PDomain local_provider,
  112. * PConnection top_provider,
  113. * PChannelList channel_list,
  114. * PAttachmentList attachment_list)
  115. *
  116. * Functional Description:
  117. * This is the normal constructor for the Channel class. It simply
  118. * initializes the instance variables that identify the channel, the local
  119. * provider, and the top provider. The attachment list is empty by
  120. * default.
  121. *
  122. * Formal Parameters:
  123. * channel_id (i)
  124. * This is the ID of the channel object. By keeping track of this
  125. * internally, it doesn't have to be passed in for every operation.
  126. * local_provider (i)
  127. * This is the identity of the local provider. A Channel object
  128. * needs this since it issues MCS commands on behalf of the local
  129. * provider.
  130. * top_provider (i)
  131. * This is a pointer to the top provider. This is used by the
  132. * Channel object when it needs to issue a request to the Top
  133. * Provider. If NULL, then this is the top provider.
  134. * channel_list (i)
  135. * This is a pointer to the domain's channel list, which identifies
  136. * all valid channels in the domain. This is used by channel objects
  137. * to validate user IDs.
  138. * attachment_list (i)
  139. * This is a pointer to the domain's attachment list, which identifies
  140. * all valid attachments in the domain. This is used by channel
  141. * objects to validate joined attachments.
  142. *
  143. * Return Value:
  144. * None.
  145. *
  146. * Side Effects:
  147. * None.
  148. *
  149. * Caveats:
  150. * None.
  151. */
  152. /*
  153. * Channel (
  154. * ChannelID channel_id,
  155. * PDomain local_provider,
  156. * PConnection top_provider,
  157. * PChannelList channel_list,
  158. * PAttachmentList attachment_list,
  159. * PCommandTarget attachment)
  160. *
  161. * Functional Description:
  162. * This is a secondary version of the constructor that is used only during
  163. * merge operations. The only difference between this one and the one
  164. * above is that this one allows the specification of an initial
  165. * attachment. This allows a Channel object to be constructed with an
  166. * existing attachment, without the transmission of a ChannelJoinConfirm.
  167. *
  168. * Remember that if a Channel object is constructed, and then a join
  169. * request is used to add an attachment, a Channel object automatically
  170. * issues a join confirm. This constructor allows that to be bypassed
  171. * during a merger when a join confirm is inappropriate.
  172. *
  173. * Formal Parameters:
  174. * channel_id (i)
  175. * This is the ID of the channel object. By keeping track of this
  176. * internally, it doesn't have to be passed in for every operation.
  177. * local_provider (i)
  178. * This is the identity of the local provider. A Channel object
  179. * needs this since it issues MCS commands on behalf of the local
  180. * provider.
  181. * top_provider (i)
  182. * This is a pointer to the top provider. This is used by the
  183. * Channel object when it needs to issue a request to the Top
  184. * Provider. If NULL, then this is the top provider.
  185. * channel_list (i)
  186. * This is a pointer to the domain's channel list, which identifies
  187. * all valid channels in the domain. This is used by channel objects
  188. * to validate user IDs.
  189. * attachment_list (i)
  190. * This is a pointer to the domain's attachment list, which identifies
  191. * all valid attachments in the domain. This is used by channel
  192. * objects to validate joined attachments.
  193. * attachment (i)
  194. * This is the initial attachment for the channel. A channel join
  195. * confirm is NOT issued to the attachment.
  196. *
  197. * Return Value:
  198. * None.
  199. *
  200. * Side Effects:
  201. * None.
  202. *
  203. * Caveats:
  204. * None.
  205. */
  206. /*
  207. * ~Channel ()
  208. *
  209. * Functional Description:
  210. * This is the Channel class destructor. It clears the joined attachment
  211. * list, sending channel leave indications to any user that is locally
  212. * attached.
  213. *
  214. * Formal Parameters:
  215. * None.
  216. *
  217. * Return Value:
  218. * None.
  219. *
  220. * Side Effects:
  221. * None.
  222. *
  223. * Caveats:
  224. * None.
  225. */
  226. /*
  227. * Void SetTopProvider (
  228. * PConnection top_provider)
  229. *
  230. * Functional Description:
  231. * This member function is used to change the identity of the Top Provider
  232. * in an existing channel. The only time this will really occur is when
  233. * a provider that used to be the Top Provider merges into another
  234. * domain, and therefore ceases to be the Top Provider.
  235. *
  236. * Formal Parameters:
  237. * top_provider (i)
  238. * This is a pointer to the new Top Provider.
  239. *
  240. * Return Value:
  241. * None.
  242. *
  243. * Side Effects:
  244. * None.
  245. *
  246. * Caveats:
  247. * None.
  248. */
  249. /*
  250. * Channel_Type GetChannelType ()
  251. *
  252. * Functional Description:
  253. * This virtual member function returns the type of the channel. For this
  254. * class it will be either STATIC_CHANNEL or ASSIGNED_CHANNEL, depending
  255. * on the value of the channel ID.
  256. *
  257. * This member function should be overridden by all classes that inherit
  258. * from this one so that they return a different type.
  259. *
  260. * Formal Parameters:
  261. * None.
  262. *
  263. * Return Value:
  264. * STATIC_CHANNEL if the channel ID is 1000 or less.
  265. * ASSIGNED_CHANNEL if the channel ID is greater than 1000.
  266. *
  267. * Side Effects:
  268. * None.
  269. *
  270. * Caveats:
  271. * None.
  272. */
  273. /*
  274. * BOOL IsValid ()
  275. *
  276. * Functional Description:
  277. * This function returns TRUE if the channel is still valid, and FALSE if
  278. * it is ready for deletion. This is a virtual function allowing derived
  279. * classes to change the way this decision is made.
  280. *
  281. * This function will use the information in the domain's channel and
  282. * attachment lists to validate its own existence. For example, if a
  283. * channel is owned by a user, and that user detaches, the channel will
  284. * ask to be deleted.
  285. *
  286. * Formal Parameters:
  287. * None.
  288. *
  289. * Return Value:
  290. * TRUE if channel still valid.
  291. * FALSE if channel needs to be deleted.
  292. *
  293. * Side Effects:
  294. * None.
  295. *
  296. * Caveats:
  297. * None.
  298. */
  299. /*
  300. * CAttachment *GetAttachment ()
  301. *
  302. * Functional Description:
  303. * This function returns a pointer to the attachment that leads to the
  304. * owner of the channel. Since STATIC and ASSIGNED channels do not have
  305. * owners, this function will always return NULL.
  306. *
  307. * Formal Parameters:
  308. * None.
  309. *
  310. * Return Value:
  311. * NULL.
  312. *
  313. * Side Effects:
  314. * None.
  315. *
  316. * Caveats:
  317. * None.
  318. */
  319. /*
  320. * Void IssueMergeRequest ()
  321. *
  322. * Functional Description:
  323. * This member function causes the Channel object to issue a merge request
  324. * to the top provider. It will pack the appropriate local information
  325. * into the command.
  326. *
  327. * Formal Parameters:
  328. * None.
  329. *
  330. * Return Value:
  331. * None.
  332. *
  333. * Side Effects:
  334. * None.
  335. *
  336. * Caveats:
  337. * None.
  338. */
  339. /*
  340. * Void ChannelJoinRequest (
  341. * PCommandTarget originator,
  342. * UserID uidInitiator,
  343. * ChannelID channel_id)
  344. *
  345. * Functional Description:
  346. * This function is invoked when a user tries to join the channel
  347. * associated with a Channel object. The originator will be added to
  348. * the attachment list if it is not already there.
  349. *
  350. * If the user ID passed in is valid (not 0), then a channel join confirm
  351. * will be issued to the user. Setting the user ID to 0 (zero), inhibits
  352. * this.
  353. *
  354. * Derived classes can override this member function to provide more
  355. * stringent rules about who can join a channel. This class lets anyone
  356. * join, as specified in MCS for static and assigned channels.
  357. *
  358. * Formal Parameters:
  359. * originator
  360. * This is the attachment of the user wishing to join the channel.
  361. * uidInitiator
  362. * This is the user ID of the user joining the channel. This can
  363. * be used for security checking in derived classes if desired.
  364. * channel_id
  365. * This is the channel being acted upon.
  366. *
  367. * Return Value:
  368. * None.
  369. *
  370. * Side Effects:
  371. * None.
  372. *
  373. * Caveats:
  374. * None.
  375. */
  376. /*
  377. * Void ChannelJoinConfirm (
  378. * PCommandTarget originator,
  379. * Result result,
  380. * UserID uidInitiator,
  381. * UserID requested_id,
  382. * ChannelID channel_id)
  383. *
  384. * Functional Description:
  385. * This function performs essentially the same operation as JoinRequest
  386. * above. The only difference is that the user ID cannot be set to 0
  387. * to inhibit the re-transmission of the join confirm to the user who
  388. * is joining the channel.
  389. *
  390. * Formal Parameters:
  391. * originator (i)
  392. * This is the attachment of the user wishing to join the channel.
  393. * result (i)
  394. * This is the result of the previous join request.
  395. * uidInitiator (i)
  396. * This is the user ID of the user joining the channel. This can
  397. * be used for security checking in derived classes if desired.
  398. * requested_id (i)
  399. * This is the ID of the channel that the user originally asked to
  400. * join. The only time this will be different from the channel ID
  401. * below is if the user asked for channel 0, which is interpreted as
  402. * a request for an assigned channel.
  403. * channel_id (i)
  404. * This is the channel being acted upon.
  405. *
  406. * Return Value:
  407. * None.
  408. *
  409. * Side Effects:
  410. * None.
  411. *
  412. * Caveats:
  413. * None.
  414. */
  415. /*
  416. * Void ChannelLeaveRequest (
  417. * PCommandTarget originator,
  418. * CChannelIDList *channel_id_list)
  419. *
  420. * Functional Description:
  421. * This member function is used when an attachment needs to be removed
  422. * from a channel. A leave request will only be received from a lower
  423. * provider when all attachments at that level have left (this means that
  424. * the data for the channel no longer needs to be sent downward).
  425. *
  426. * If this request results in an empty attachment list a
  427. * ChannelLeaveRequest will be sent upward to the next higher provider in
  428. * the domain (unless this is the Top Provider).
  429. *
  430. * Formal Parameters:
  431. * originator (i)
  432. * This is the attachment to be removed from the channel.
  433. * channel_id_list (i)
  434. * This is the list of channels being acted upon.
  435. *
  436. * Return Value:
  437. * None.
  438. *
  439. * Side Effects:
  440. * None.
  441. *
  442. * Caveats:
  443. * None.
  444. */
  445. /*
  446. * Void SendDataRequest (
  447. * PCommandTarget originator,
  448. * UINT type,
  449. * PDataPacket data_packet)
  450. *
  451. * Functional Description:
  452. * This function is called when it is necessary to send data through the
  453. * channel that this Channel object represents. All rules for
  454. * non-uniform data apply. The data will be forwarded upward toward
  455. * the Top Provider (unless this is the Top Provider). Data will also
  456. * be sent immediately downward to all attachments who are joined to
  457. * the channel, except for the attachment from which the data came.
  458. *
  459. * Formal Parameters:
  460. * originator (i)
  461. * This is the attachment from which the data came.
  462. * type (i)
  463. * Simple or uniform send data request.
  464. * data_packet (i)
  465. * This is a pointer to a DataPacket object containing the channel
  466. * ID, the User ID of the data sender, segmentation flags, priority of
  467. * the data packet and a pointer to the packet to be sent.
  468. *
  469. * Return Value:
  470. * None.
  471. *
  472. * Side Effects:
  473. * None.
  474. *
  475. * Caveats:
  476. * None.
  477. */
  478. /*
  479. * Void SendDataIndication (
  480. * PCommandTarget originator,
  481. * UINT type,
  482. * PDataPacket data_packet)
  483. *
  484. * Functional Description:
  485. * This function is called when it is necessary to send data through the
  486. * channel that this Channel object represents. The data will be sent
  487. * downward to all attachments joined to the channel.
  488. *
  489. * Formal Parameters:
  490. * originator (i)
  491. * This is the attachment from which the data came.
  492. * type (i)
  493. * normal or uniform indication.
  494. * data_packet (i)
  495. * This is a pointer to a DataPacket object containing the channel
  496. * ID, the User ID of the data sender, segmentation flags, priority of
  497. * the data packet and a pointer to the packet to be sent.
  498. *
  499. * Return Value:
  500. * None.
  501. *
  502. * Side Effects:
  503. * None.
  504. *
  505. * Caveats:
  506. * None.
  507. */
  508. #endif