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.

381 lines
11 KiB

  1. /*
  2. * netaddr.h
  3. *
  4. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the Network Address List class. This
  8. * class manages the data associated with a network address. Network
  9. * addresses can be one of three types: aggregated channel, transport
  10. * connection, or non-standard. A variety of structures, objects, and
  11. * Rogue Wave containers are used to buffer the network address data
  12. * internally.
  13. *
  14. * Caveats:
  15. * A network address may contain an Object Key if it is a non-standard
  16. * type. When created locally with "API" data, checks are made to ensure
  17. * that the constraints imposed upon Object Keys are not violated. Checks
  18. * are also performed to validate certain types of strings which may exist
  19. * in a network address. If however, a network address is created from
  20. * "PDU" data received from a remote site no such validation is performed.
  21. * We are taking no responsibility for validation of data originated by
  22. * other GCC providers.
  23. *
  24. * Author:
  25. * blp/jbo
  26. */
  27. #ifndef _NETWORK_ADDRESS_
  28. #define _NETWORK_ADDRESS_
  29. #include "objkey.h"
  30. /*
  31. * This structure holds network address information and data.
  32. */
  33. typedef struct NET_ADDR
  34. {
  35. NET_ADDR(void);
  36. ~NET_ADDR(void);
  37. GCCNetworkAddress network_address;
  38. // Variables associated with aggregated channels.
  39. LPSTR pszSubAddress;
  40. LPWSTR pwszExtraDialing;
  41. PGCCHighLayerCompatibility high_layer_compatibility;
  42. // Variables associated with transport connection addresses.
  43. LPOSTR poszTransportSelector;
  44. // Variables associated with non-standard network addresses.
  45. LPOSTR poszNonStandardParam;
  46. CObjectKeyContainer *object_key;
  47. }
  48. NET_ADDR;
  49. /*
  50. * This list is holds the network address information structures.
  51. */
  52. class CNetAddrList : public CList
  53. {
  54. DEFINE_CLIST(CNetAddrList, NET_ADDR*)
  55. };
  56. /*
  57. * Class definition:
  58. */
  59. class CNetAddrListContainer : public CRefCount
  60. {
  61. public:
  62. CNetAddrListContainer(UINT cAddrs, PGCCNetworkAddress *, PGCCError);
  63. CNetAddrListContainer(PSetOfNetworkAddresses, PGCCError);
  64. CNetAddrListContainer(CNetAddrListContainer *, PGCCError);
  65. ~CNetAddrListContainer(void);
  66. UINT LockNetworkAddressList(void);
  67. void UnLockNetworkAddressList(void);
  68. UINT GetNetworkAddressListAPI(UINT *pcAddrs, PGCCNetworkAddress **, LPBYTE pMemory);
  69. GCCError GetNetworkAddressListPDU(PSetOfNetworkAddresses *);
  70. GCCError FreeNetworkAddressListPDU(void);
  71. protected:
  72. CNetAddrList m_NetAddrItemList;
  73. UINT m_cbDataSize;
  74. PSetOfNetworkAddresses m_pSetOfNetAddrPDU;
  75. BOOL m_fValidNetAddrPDU;
  76. private:
  77. GCCError StoreNetworkAddressList(UINT cAddrs, PGCCNetworkAddress *);
  78. GCCError ConvertPDUDataToInternal(PSetOfNetworkAddresses);
  79. GCCError ConvertNetworkAddressInfoToPDU(NET_ADDR *, PSetOfNetworkAddresses);
  80. void ConvertTransferModesToInternal(PTransferModes pSrc, PGCCTransferModes pDst);
  81. void ConvertHighLayerCompatibilityToInternal(PHighLayerCompatibility pSrc, PGCCHighLayerCompatibility pDst);
  82. void ConvertTransferModesToPDU(PGCCTransferModes pSrc, PTransferModes pDst);
  83. void ConvertHighLayerCompatibilityToPDU(PGCCHighLayerCompatibility pSrc, PHighLayerCompatibility pDst);
  84. BOOL IsDialingStringValid(GCCDialingString);
  85. BOOL IsCharacterStringValid(GCCCharacterString);
  86. BOOL IsExtraDialingStringValid(PGCCExtraDialingString);
  87. };
  88. /*
  89. * Comments explaining the public and protected class member functions
  90. */
  91. /*
  92. * CNetAddrListContainer (
  93. * UINT number_of_network_addresses,
  94. * PGCCNetworkAddress * network_address_list,
  95. * PGCCError return_value);
  96. *
  97. * Public member function of CNetAddrListContainer.
  98. *
  99. * Function Description:
  100. * This is the constructor for the CNetAddrListContainer class which takes as
  101. * input the "API" version of network address data, GCCNetworkAddress.
  102. *
  103. * Formal Parameters:
  104. * number_of_network_addresses (i) The number of addresses in the list.
  105. * network_address_list (i) The network address data to store.
  106. * return_value (o) The output parameter used to indicate errors.
  107. *
  108. * Return Value:
  109. * GCC_NO_ERROR - No error.
  110. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  111. * "new" operator.
  112. * GCC_BAD_NETWORK_ADDRESS - Invalid network address passed in.
  113. * GCC_BAD_NETWORK_ADDRESS_TYPE - Bad "choice" field for address
  114. *
  115. * Side Effects:
  116. * None.
  117. *
  118. * Caveats:
  119. * None.
  120. */
  121. /*
  122. * CNetAddrListContainer (
  123. * PSetOfNetworkAddresses network_address_list,
  124. * PGCCError return_value);
  125. *
  126. * Public member function of CNetAddrListContainer.
  127. *
  128. * Function Description:
  129. * This is the constructor for the CNetAddrListContainer class which takes as
  130. * input the "PDU" version of network address data, SetOfNetworkAddresses.
  131. *
  132. * Formal Parameters:
  133. * network_address_list (i) The network address data to store.
  134. * return_value (o) The output parameter used to indicate errors.
  135. *
  136. * Return Value:
  137. * GCC_NO_ERROR - No error.
  138. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  139. * "new" operator.
  140. *
  141. * Side Effects:
  142. * None.
  143. *
  144. * Caveats:
  145. * None.
  146. */
  147. /*
  148. * CNetAddrListContainer (
  149. * CNetAddrListContainer *network_address_list,
  150. * PGCCError return_value);
  151. *
  152. * Public member function of CNetAddrListContainer.
  153. *
  154. * Function Description:
  155. * This is the copy constructor for the CNetAddrListContainer class which
  156. * takes as input another CNetAddrListContainer object.
  157. *
  158. * Formal Parameters:
  159. * network_address_list (i) The CNetAddrListContainer object to copy.
  160. * return_value (o) The output parameter used to indicate errors.
  161. *
  162. * Return Value:
  163. * GCC_NO_ERROR - No error.
  164. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  165. * "new" operator.
  166. *
  167. * Side Effects:
  168. * None.
  169. *
  170. * Caveats:
  171. * None.
  172. */
  173. /*
  174. * ~CNetAddrListContainer ();
  175. *
  176. * Public member function of CNetAddrListContainer.
  177. *
  178. * Function Description:
  179. * This is the destructor for the CNetAddrListContainer class. It is used to
  180. * clean up any memory allocated during the life of this object.
  181. *
  182. * Formal Parameters:
  183. * None.
  184. *
  185. * Return Value:
  186. * None.
  187. *
  188. * Side Effects:
  189. * None.
  190. *
  191. * Caveats:
  192. * None.
  193. */
  194. /*
  195. * UINT LockNetworkAddressList ();
  196. *
  197. * Public member function of CNetAddrListContainer.
  198. *
  199. * Function Description:
  200. * This routine is used to "lock" the "API" data for this object. This
  201. * results in the lock count for this object being incremented. When the
  202. * lock count transitions from 0 to 1, a calculation is made to determine
  203. * how much memory will be needed to hold any "API" data which will
  204. * be referenced by, but not held in, the list of GCCNetworkAddress
  205. * structures which is filled in on a call to GetNetworkAddressListAPI.
  206. * This is the value returned by this routine in order to allow the calling
  207. * object to allocate that amount of memory in preparation for the call to
  208. * GetNetworkAddressListAPI.
  209. *
  210. * Formal Parameters:
  211. * None.
  212. *
  213. * Return Value:
  214. * The amount of memory, if any, which will be needed to hold "API" data
  215. * which is referenced by, but not held in, the list of GCCNetworkAddress
  216. * structures provided as an output parameter to the
  217. * GetNetworkAddressListAPI call.
  218. *
  219. * Side Effects:
  220. * The internal lock count is incremented.
  221. *
  222. * Caveats:
  223. * The internal lock count is used in conjuction with an internal "free"
  224. * flag as a mechanism for ensuring that this object remains in existance
  225. * until all interested parties are through with it. The object remains
  226. * valid (unless explicity deleted) until the lock count is zero and the
  227. * "free" flag is set through a call to FreeNetworkAddressList. This allows
  228. * other objects to lock this object and be sure that it remains valid
  229. * until they call UnLock which will decrement the internal lock count. A
  230. * typical usage scenerio for this object would be: A CNetAddrListContainer
  231. * object is constructed and then passed off to any interested parties
  232. * through a function call. On return from the function call, the
  233. * FreeNetworkAddressList call is made which will set the internal "free"
  234. * flag. If no other parties have locked the object with a Lock call,
  235. * then the CNetAddrListContainer object will automatically delete itself when
  236. * the FreeNetworkAddressList call is made. If, however, any number of
  237. * other parties has locked the object, it will remain in existence until
  238. * each of them has unlocked the object through a call to UnLock.
  239. */
  240. /*
  241. * UINT GetNetworkAddressListAPI (
  242. * UINT * number_of_network_addresses,
  243. * PGCCNetworkAddress ** network_address_list,
  244. * LPSTR memory);
  245. *
  246. * Public member function of CNetAddrListContainer.
  247. *
  248. * Function Description:
  249. * This routine is used to retrieve the network address data from the
  250. * CNetAddrListContainer object in the "API" form of a list of
  251. * GCCNetworkAddress structures.
  252. *
  253. * Formal Parameters:
  254. * number_of_network_addresses (o) Number of addresses in returned list.
  255. * network_address_list (o) The pointer to the list of
  256. * GCCNetworkAddress structures
  257. * to fill in.
  258. * memory (o) The memory used to hold any data
  259. * referenced by, but not held in, the
  260. * list of output structures.
  261. *
  262. * Return Value:
  263. * The amount of data, if any, written into the bulk memory block provided.
  264. *
  265. * Side Effects:
  266. * None.
  267. *
  268. * Caveats:
  269. * None.
  270. */
  271. /*
  272. * void UnLockNetworkAddressList ();
  273. *
  274. * Public member function of CNetAddrListContainer.
  275. *
  276. * Function Description:
  277. * This routine is used to "unlock" the "API" data for this object. This
  278. * results in the lock count for this object being decremented. When the
  279. * lock count transitions from 1 to 0, a check is made to determine
  280. * whether the object has been freed through a call to
  281. * FreeNetworkAddressList. If so, the object will automatically delete
  282. * itself.
  283. *
  284. * Formal Parameters:
  285. * None.
  286. *
  287. * Return Value:
  288. * None.
  289. *
  290. * Side Effects:
  291. * The internal lock count is decremented.
  292. *
  293. * Caveats:
  294. * It is the responsibility of any party which locks a CNetAddrListContainer
  295. * object by calling Lock to also unlock the object with a call to UnLock.
  296. * If the party calling UnLock did not construct the CNetAddrListContainer
  297. * object, it should assume the object to be invalid thereafter.
  298. */
  299. /*
  300. * GCCError GetNetworkAddressListPDU (
  301. * PSetOfNetworkAddresses * set_of_network_addresses);
  302. *
  303. * Public member function of CNetAddrListContainer.
  304. *
  305. * Function Description:
  306. * This routine is used to retrieve the network address data from the
  307. * CNetAddrListContainer object in the "PDU" form of a SetOfNetworkAddresses.
  308. *
  309. * Formal Parameters:
  310. * set_of_network_addresses (o) The address structure to fill in.
  311. *
  312. * Return Value:
  313. * GCC_NO_ERROR - No error.
  314. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  315. * "new" operator.
  316. *
  317. * Side Effects:
  318. * None.
  319. *
  320. * Caveats:
  321. * None.
  322. */
  323. /*
  324. * GCCError FreeNetworkAddressListPDU ();
  325. *
  326. * Public member function of CNetAddrListContainer.
  327. *
  328. * Function Description:
  329. * This routine is used to "free" the "PDU" data allocated for this object
  330. * which is held internally in a SetOfNetworkAddresses structure.
  331. *
  332. * Formal Parameters:
  333. * None.
  334. *
  335. * Return Value:
  336. * GCC_NO_ERROR - No error.
  337. *
  338. * Side Effects:
  339. * The internal "free" flag is set.
  340. *
  341. * Caveats:
  342. * This object should be assumed invalid after a call to
  343. * FreeNetworkAddressListPDU has been made.
  344. */
  345. #endif