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.

2180 lines
67 KiB

  1. #include "precomp.h"
  2. DEBUG_FILEZONE(ZONE_T120_GCCNC);
  3. /*
  4. * netaddr.cpp
  5. *
  6. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  7. *
  8. * Abstract:
  9. * This is the implementation file for the CNetAddrListContainer Class. This
  10. * class manages the data associated with a network address. Network
  11. * addresses can be one of three types: aggregated channel, transport
  12. * connection, or non-standard. A variety of structures, objects, and
  13. * Rogue Wave containers are used to buffer the network address data
  14. * internally.
  15. *
  16. * Protected Instance Variables:
  17. * m_NetAddrItemList
  18. * List of structures used to hold the network address data internally.
  19. * m_pSetOfNetAddrPDU
  20. * Storage for the "PDU" form of the network address list.
  21. * m_cbDataSize
  22. * Variable holding the size of the memory which will be required to
  23. * hold any data referenced by the "API" network address structures.
  24. * m_fValidNetAddrPDU
  25. * Flag indicating that memory has been allocated to hold the internal
  26. * "PDU" network address list.
  27. *
  28. * Private Member Functions:
  29. * StoreNetworkAddressList
  30. * This routine is used to store the network address data passed in as
  31. * "API" data in the internal structures.
  32. * ConvertPDUDataToInternal
  33. * This routine is used to store the network address data passed in as
  34. * "PDU" data in the internal structures.
  35. * ConvertNetworkAddressInfoToPDU
  36. * This routine is used to convert the network address info structures
  37. * maintained internally into the "PDU" form which is a
  38. * SetOfNetworkAddresses.
  39. * ConvertTransferModesToInternal
  40. * This routine is used to convert the PDU network address transfer
  41. * modes structure into the internal form where the structure is saved
  42. * as a GCCTranferModes structure.
  43. * ConvertHighLayerCompatibilityToInternal
  44. * This routine is used to convert the PDU network address high layer
  45. * compatibility structure into the internal form where the structure
  46. * is saved as a GCCHighLayerCompatibility structure.
  47. * ConvertTransferModesToPDU
  48. * This routine is used to convert the API network address transfer
  49. * modes structure into the PDU form which is a TranferModes structure.
  50. * ConvertHighLayerCompatibilityToPDU
  51. * This routine is used to convert the API network address high layer
  52. * compatibility structure into the PDU form which is a
  53. * HighLayerCompatibility structure.
  54. * IsDialingStringValid
  55. * This routine is used to ensure that the values held within a
  56. * dialing string do not violate the imposed ASN.1 constraints.
  57. * IsCharacterStringValid
  58. * This routine is used to ensure that the values held within a
  59. * character string do not violate the imposed ASN.1 constraints.
  60. * IsExtraDialingStringValid
  61. * This routine is used to ensure that the values held within an
  62. * extra dialing string do not violate the imposed ASN.1 constraints.
  63. *
  64. * Caveats:
  65. * This container stores much of the network address information internally
  66. * using an "API" GCCNetworkAddress structure. Any data referenced by
  67. * pointers in this structure is stored in some other container.
  68. * Therefore, the pointers held within the internal "API" structure are
  69. * not valid and must not be accessed.
  70. *
  71. * Author:
  72. * blp/jbo
  73. */
  74. #include <stdio.h>
  75. #include "ms_util.h"
  76. #include "netaddr.h"
  77. /*
  78. * These macros are used to define the size constraints of an "nsap" address.
  79. */
  80. #define MINIMUM_NSAP_ADDRESS_SIZE 1
  81. #define MAXIMUM_NSAP_ADDRESS_SIZE 20
  82. /*
  83. * These macros are used to verify that a network address has a valid number
  84. * of network address entities.
  85. */
  86. #define MINIMUM_NUMBER_OF_ADDRESSES 1
  87. #define MAXIMUM_NUMBER_OF_ADDRESSES 64
  88. /*
  89. * These macros are used to define the size constraints of an extra dialing
  90. * string.
  91. */
  92. #define MINIMUM_EXTRA_DIALING_STRING_SIZE 1
  93. #define MAXIMUM_EXTRA_DIALING_STRING_SIZE 255
  94. NET_ADDR::NET_ADDR(void)
  95. :
  96. pszSubAddress(NULL),
  97. pwszExtraDialing(NULL),
  98. high_layer_compatibility(NULL),
  99. poszTransportSelector(NULL),
  100. poszNonStandardParam(NULL),
  101. object_key(NULL)
  102. {
  103. }
  104. NET_ADDR::~NET_ADDR(void)
  105. {
  106. switch (network_address.network_address_type)
  107. {
  108. case GCC_AGGREGATED_CHANNEL_ADDRESS:
  109. delete pszSubAddress;
  110. delete pwszExtraDialing;
  111. delete high_layer_compatibility;
  112. break;
  113. case GCC_TRANSPORT_CONNECTION_ADDRESS:
  114. delete poszTransportSelector;
  115. break;
  116. case GCC_NONSTANDARD_NETWORK_ADDRESS:
  117. delete poszNonStandardParam;
  118. if (NULL != object_key)
  119. {
  120. object_key->Release();
  121. }
  122. break;
  123. default:
  124. ERROR_OUT(("NET_ADDR::~NET_ADDR: unknown addr type=%u", (UINT) network_address.network_address_type));
  125. break;
  126. }
  127. }
  128. /*
  129. * CNetAddrListContainer()
  130. *
  131. * Public Function Description:
  132. * This constructor is used when creating a CNetAddrListContainer object with
  133. * the "API" form of network address, GCCNetworkAddress.
  134. */
  135. CNetAddrListContainer::
  136. CNetAddrListContainer(UINT number_of_network_addresses,
  137. PGCCNetworkAddress *network_address_list,
  138. PGCCError return_value )
  139. :
  140. CRefCount(MAKE_STAMP_ID('N','t','A','L')),
  141. m_pSetOfNetAddrPDU(NULL),
  142. m_fValidNetAddrPDU(FALSE),
  143. m_cbDataSize(0)
  144. {
  145. /*
  146. * Initialize the instance variables. The m_NetAddrItemList which
  147. * will hold the network address data internally will be filled in by the
  148. * call to StoreNetworkAddressList.
  149. */
  150. /*
  151. * Check to make sure a valid number of network addresses exist.
  152. */
  153. if ((number_of_network_addresses < MINIMUM_NUMBER_OF_ADDRESSES)
  154. || (number_of_network_addresses > MAXIMUM_NUMBER_OF_ADDRESSES))
  155. {
  156. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: ERROR Invalid number of network addresses, %u", (UINT) number_of_network_addresses));
  157. *return_value = GCC_BAD_NETWORK_ADDRESS;
  158. }
  159. /*
  160. * Check to make sure that the list pointer is valid.
  161. */
  162. else if (network_address_list == NULL)
  163. {
  164. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: ERROR NULL address list"));
  165. *return_value = GCC_BAD_NETWORK_ADDRESS;
  166. }
  167. /*
  168. * Save the network address(es) in the internal structures.
  169. */
  170. else
  171. {
  172. *return_value = StoreNetworkAddressList(number_of_network_addresses,
  173. network_address_list);
  174. }
  175. }
  176. /*
  177. * CNetAddrListContainer()
  178. *
  179. * Public Function Description:
  180. * This constructor is used when creating a CNetAddrListContainer object with
  181. * the "PDU" form of network address, SetOfNetworkAddresses.
  182. */
  183. CNetAddrListContainer::
  184. CNetAddrListContainer(PSetOfNetworkAddresses network_address_list,
  185. PGCCError return_value )
  186. :
  187. CRefCount(MAKE_STAMP_ID('N','t','A','L')),
  188. m_pSetOfNetAddrPDU(NULL),
  189. m_fValidNetAddrPDU(FALSE),
  190. m_cbDataSize(0)
  191. {
  192. PSetOfNetworkAddresses network_address_ptr;
  193. /*
  194. * Initialize the instance variables. The m_NetAddrItemList which
  195. * will hold the network address data internally will be filled in by the
  196. * calls to ConvertPDUDataToInternal.
  197. */
  198. *return_value = GCC_NO_ERROR;
  199. network_address_ptr = network_address_list;
  200. /*
  201. * Loop through the set of network addresses, saving each in an internal
  202. * NET_ADDR structure and saving those structures in the internal
  203. * list.
  204. */
  205. if (network_address_list != NULL)
  206. {
  207. while (1)
  208. {
  209. /*
  210. * Convert each "PDU" network address into the internal form. Note
  211. * that object ID validation is not performed on data received as
  212. * a PDU. If a bad object ID comes in on the wire, this will be
  213. * flagged as an allocation failure.
  214. */
  215. if (ConvertPDUDataToInternal (network_address_ptr) != GCC_NO_ERROR)
  216. {
  217. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: Error converting PDU data to internal"));
  218. *return_value = GCC_ALLOCATION_FAILURE;
  219. break;
  220. }
  221. else
  222. {
  223. network_address_ptr = network_address_ptr->next;
  224. }
  225. if (network_address_ptr == NULL)
  226. break;
  227. }
  228. }
  229. }
  230. /*
  231. * CNetAddrListContainer()
  232. *
  233. * Public Function Description:
  234. * This is the copy constructor used to create a new CNetAddrListContainer
  235. * object from an existing CNetAddrListContainer object.
  236. */
  237. CNetAddrListContainer::
  238. CNetAddrListContainer(CNetAddrListContainer *address_list,
  239. PGCCError pRetCode)
  240. :
  241. CRefCount(MAKE_STAMP_ID('N','t','A','L')),
  242. m_pSetOfNetAddrPDU(NULL),
  243. m_fValidNetAddrPDU(FALSE),
  244. m_cbDataSize(0)
  245. {
  246. NET_ADDR *network_address_info;
  247. NET_ADDR *lpNetAddrInfo;
  248. GCCNetworkAddressType network_address_type;
  249. GCCError rc;
  250. /*
  251. * Set up an iterator for the internal list of network addresses.
  252. */
  253. address_list->m_NetAddrItemList.Reset();
  254. /*
  255. * Copy each NET_ADDR structure contained in the
  256. * CNetAddrListContainer object to be copied.
  257. */
  258. while (NULL != (lpNetAddrInfo = address_list->m_NetAddrItemList.Iterate()))
  259. {
  260. /*
  261. * Create a new NET_ADDR structure to hold each element of the
  262. * new CNetAddrListContainer object. Report an error if creation of this
  263. * structure fails.
  264. */
  265. DBG_SAVE_FILE_LINE
  266. if (NULL == (network_address_info = new NET_ADDR))
  267. {
  268. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: can't create NET_ADDR"));
  269. rc = GCC_ALLOCATION_FAILURE;
  270. goto MyExit;
  271. }
  272. /*
  273. * First copy the GCCNetworkAddress structure contained in the
  274. * internal NET_ADDR structure. This copies all data
  275. * except that referenced by pointers in the structure.
  276. */
  277. network_address_info->network_address = lpNetAddrInfo->network_address;
  278. /*
  279. * Next copy any data embedded in the network address that would
  280. * not have been copied in the above operation (typically pointers
  281. * to strings).
  282. */
  283. /*
  284. * This variable is used for abbreviation.
  285. */
  286. network_address_type = lpNetAddrInfo->network_address.network_address_type;
  287. /*
  288. * The network address is the "Aggregated" type.
  289. */
  290. switch (network_address_type)
  291. {
  292. case GCC_AGGREGATED_CHANNEL_ADDRESS:
  293. /*
  294. * If a sub-address string exists, store it in a Rogue Wave
  295. * container. Set the structure pointer to NULL if one does
  296. * not exist.
  297. */
  298. if (lpNetAddrInfo->pszSubAddress != NULL)
  299. {
  300. if (NULL == (network_address_info->pszSubAddress =
  301. ::My_strdupA(lpNetAddrInfo->pszSubAddress)))
  302. {
  303. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: can't create sub address"));
  304. rc = GCC_ALLOCATION_FAILURE;
  305. goto MyExit;
  306. }
  307. }
  308. else
  309. {
  310. network_address_info->pszSubAddress = NULL;
  311. }
  312. /*
  313. * If an extra dialing string exists, store it in a Unicode
  314. * String object. Set the structure pointer to NULL if one
  315. * does not exist.
  316. */
  317. if (lpNetAddrInfo->pwszExtraDialing != NULL)
  318. {
  319. if (NULL == (network_address_info->pwszExtraDialing =
  320. ::My_strdupW(lpNetAddrInfo->pwszExtraDialing)))
  321. {
  322. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: can't creating extra dialing string"));
  323. rc = GCC_ALLOCATION_FAILURE;
  324. goto MyExit;
  325. }
  326. }
  327. else
  328. {
  329. network_address_info->pwszExtraDialing = NULL;
  330. }
  331. /*
  332. * If a higher layer compatibility structure exists, store it
  333. * in a GCCHighLayerCompatibility structure. Set the structure
  334. * pointer to NULL if one does not exist.
  335. */
  336. if (lpNetAddrInfo->high_layer_compatibility != NULL)
  337. {
  338. DBG_SAVE_FILE_LINE
  339. network_address_info->high_layer_compatibility = new GCCHighLayerCompatibility;
  340. if (network_address_info->high_layer_compatibility != NULL)
  341. {
  342. /*
  343. * Copy the high layer compatibility data to the
  344. * new structure.
  345. */
  346. *network_address_info->high_layer_compatibility =
  347. *(lpNetAddrInfo->high_layer_compatibility);
  348. }
  349. else
  350. {
  351. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: Error creating new GCCHighLayerCompat"));
  352. rc = GCC_ALLOCATION_FAILURE;
  353. goto MyExit;
  354. }
  355. }
  356. else
  357. {
  358. network_address_info->high_layer_compatibility = NULL;
  359. }
  360. break;
  361. /*
  362. * The network address is the "Transport Connection" type.
  363. */
  364. case GCC_TRANSPORT_CONNECTION_ADDRESS:
  365. /*
  366. * If a transport selector exists, store it in a Rogue Wave
  367. * container. Otherwise, set the structure pointer to NULL.
  368. */
  369. if (lpNetAddrInfo->poszTransportSelector != NULL)
  370. {
  371. if (NULL == (network_address_info->poszTransportSelector =
  372. ::My_strdupO(lpNetAddrInfo->poszTransportSelector)))
  373. {
  374. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: can't create transport selector"));
  375. rc = GCC_ALLOCATION_FAILURE;
  376. goto MyExit;
  377. }
  378. }
  379. else
  380. {
  381. network_address_info->poszTransportSelector = NULL;
  382. }
  383. break;
  384. /*
  385. * The network address is the "Non-Standard" type.
  386. */
  387. case GCC_NONSTANDARD_NETWORK_ADDRESS:
  388. /*
  389. * First store the non-standard parameter data in a Rogue Wave
  390. * container.
  391. */
  392. if (NULL == (network_address_info->poszNonStandardParam =
  393. ::My_strdupO(lpNetAddrInfo->poszNonStandardParam)))
  394. {
  395. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: can't create non-standard param"));
  396. rc = GCC_ALLOCATION_FAILURE;
  397. goto MyExit;
  398. }
  399. /*
  400. * Next store the object key internally in an CObjectKeyContainer
  401. * object. Note that there is no need to report the error
  402. * "BAD_NETWORK_ADDRESS" here since the object key data
  403. * would have been validated when the original network address
  404. * was created.
  405. */
  406. DBG_SAVE_FILE_LINE
  407. network_address_info->object_key = new CObjectKeyContainer(lpNetAddrInfo->object_key, &rc);
  408. if ((network_address_info->object_key == NULL) || (rc != GCC_NO_ERROR))
  409. {
  410. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: Error creating new CObjectKeyContainer"));
  411. rc = GCC_ALLOCATION_FAILURE;
  412. goto MyExit;
  413. }
  414. break;
  415. /*
  416. * The network address is of unknown type. This should never be
  417. * encountered so flag it as an allocation failure.
  418. */
  419. default:
  420. ERROR_OUT(("CNetAddrListContainer::CNetAddrListContainer: Invalid type received as PDU"));
  421. rc = GCC_ALLOCATION_FAILURE;
  422. goto MyExit;
  423. }
  424. /*
  425. * Go ahead and insert the pointer to the NET_ADDR
  426. * structure into the internal Rogue Wave list.
  427. */
  428. m_NetAddrItemList.Append(network_address_info);
  429. }
  430. rc = GCC_NO_ERROR;
  431. MyExit:
  432. if (GCC_NO_ERROR != rc)
  433. {
  434. delete network_address_info;
  435. }
  436. *pRetCode = rc;
  437. }
  438. /*
  439. * ~CNetAddrListContainer()
  440. *
  441. * Public Function Description:
  442. * The destructor is used to free up any memory allocated during the life
  443. * of the object.
  444. */
  445. CNetAddrListContainer::
  446. ~CNetAddrListContainer(void)
  447. {
  448. /*
  449. * Free any data allocated to hold "PDU" information.
  450. */
  451. if (m_fValidNetAddrPDU)
  452. {
  453. FreeNetworkAddressListPDU();
  454. }
  455. /*
  456. * Free any data allocated for the internal list of "info" structures.
  457. */
  458. NET_ADDR *pNetAddrInfo;
  459. m_NetAddrItemList.Reset();
  460. while (NULL != (pNetAddrInfo = m_NetAddrItemList.Iterate()))
  461. {
  462. delete pNetAddrInfo;
  463. }
  464. }
  465. /*
  466. * LockNetworkAddressList ()
  467. *
  468. * Public Function Description:
  469. * This routine is called to "Lock" the network address data in "API" form.
  470. * The amount of memory required to hold the "API" data which is referenced
  471. * by, but not included in the GCCNetworkAddress structure, will be
  472. * returned.
  473. *
  474. */
  475. UINT CNetAddrListContainer::
  476. LockNetworkAddressList(void)
  477. {
  478. /*
  479. * If this is the first time this routine is called, determine the size of
  480. * the memory required to hold the data. Otherwise, just increment the
  481. * lock count.
  482. */
  483. if (Lock() == 1)
  484. {
  485. PGCCNetworkAddress network_address;
  486. NET_ADDR *lpNetAddrInfo;
  487. /*
  488. * Set aside memory to hold the pointers to the GCCNetworkAddress
  489. * structures as well as the structures themselves. The "sizeof" the
  490. * structure must be rounded to an even four-byte boundary.
  491. */
  492. m_cbDataSize = m_NetAddrItemList.GetCount() *
  493. ( sizeof(PGCCNetworkAddress) + ROUNDTOBOUNDARY(sizeof(GCCNetworkAddress)) );
  494. /*
  495. * Loop through the list of network addresses, adding up the space
  496. * requirements of each address.
  497. */
  498. m_NetAddrItemList.Reset();
  499. while (NULL != (lpNetAddrInfo = m_NetAddrItemList.Iterate()))
  500. {
  501. /*
  502. * Use a local variable to keep from having to access the Rogue Wave
  503. * iterator repeatedly.
  504. */
  505. network_address = &lpNetAddrInfo->network_address;
  506. /*
  507. * Check to see what type of network address exists.
  508. */
  509. switch (network_address->network_address_type)
  510. {
  511. case GCC_AGGREGATED_CHANNEL_ADDRESS:
  512. /*
  513. * Add the length of the sub address string if it exists.
  514. */
  515. if (lpNetAddrInfo->pszSubAddress != NULL)
  516. {
  517. m_cbDataSize += ROUNDTOBOUNDARY(::lstrlenA(lpNetAddrInfo->pszSubAddress) + 1);
  518. }
  519. /*
  520. * Add the size of the GCCExtraDialingString structure as well
  521. * as the length of the extra dialing string if it exists.
  522. */
  523. if (lpNetAddrInfo->pwszExtraDialing != NULL)
  524. {
  525. m_cbDataSize += ROUNDTOBOUNDARY(sizeof(GCCExtraDialingString)) +
  526. ROUNDTOBOUNDARY((::lstrlenW(lpNetAddrInfo->pwszExtraDialing) + 1) * sizeof(WCHAR));
  527. }
  528. /*
  529. * Add the size of the high layer compatibility structure if
  530. * it exists.
  531. */
  532. if (lpNetAddrInfo->high_layer_compatibility != NULL)
  533. {
  534. m_cbDataSize += ROUNDTOBOUNDARY(sizeof(GCCHighLayerCompatibility));
  535. }
  536. break;
  537. case GCC_TRANSPORT_CONNECTION_ADDRESS:
  538. /*
  539. * Add the size of the OSTR structure as well as the
  540. * length of the octet string if it exists.
  541. */
  542. if (lpNetAddrInfo->poszTransportSelector != NULL)
  543. {
  544. m_cbDataSize += ROUNDTOBOUNDARY(sizeof(OSTR)) +
  545. ROUNDTOBOUNDARY(lpNetAddrInfo->poszTransportSelector->length);
  546. }
  547. break;
  548. case GCC_NONSTANDARD_NETWORK_ADDRESS:
  549. /*
  550. * Lock the object key in the non-standard parameter in order to
  551. * determine the amount of memory needed to hold its data.
  552. */
  553. m_cbDataSize += lpNetAddrInfo->object_key->LockObjectKeyData ();
  554. /*
  555. * Add the space needed to hold the octet string data for the
  556. * non-standard parameter.
  557. */
  558. m_cbDataSize += ROUNDTOBOUNDARY(lpNetAddrInfo->poszNonStandardParam->length);
  559. break;
  560. }
  561. }
  562. }
  563. return m_cbDataSize;
  564. }
  565. /*
  566. * GetNetworkAddressListAPI ()
  567. *
  568. * Public Function Description:
  569. * This routine is used to retrieve the list of network addresses in "API"
  570. * form.
  571. */
  572. UINT CNetAddrListContainer::
  573. GetNetworkAddressListAPI(UINT * number_of_network_addresses,
  574. PGCCNetworkAddress ** network_address_list,
  575. LPBYTE memory)
  576. {
  577. UINT cbDataSizeToRet = 0;
  578. UINT data_length = 0;
  579. UINT network_address_counter = 0;
  580. PGCCNetworkAddress network_address_ptr;
  581. NET_ADDR *address_info;
  582. PGCCNetworkAddress *address_array;
  583. /*
  584. * If the user data has been locked, fill in the output parameters and
  585. * the data referenced by the pointers. Otherwise, report that the object
  586. * has yet to be locked into the "API" form.
  587. */
  588. if (GetLockCount() > 0)
  589. {
  590. // NET_ADDR *lpNetAddrInfo;
  591. /*
  592. * Fill in the output length parameter which indicates how much data
  593. * referenced outside the structure will be written.
  594. */
  595. cbDataSizeToRet = m_cbDataSize;
  596. /*
  597. * Fill in the number of network address entities and save a pointer to
  598. * the memory location passed in. This is where the pointers to the
  599. * GCCNetworkAddress structures will be written. The actual structures
  600. * will be written into memory immediately following the list of
  601. * pointers.
  602. */
  603. *number_of_network_addresses = (UINT) m_NetAddrItemList.GetCount();
  604. *network_address_list = (PGCCNetworkAddress *)memory;
  605. address_array = *network_address_list;
  606. /*
  607. * Save the amount of memory needed to hold the list of pointers as
  608. * well as the actual network address structures.
  609. */
  610. data_length = m_NetAddrItemList.GetCount() * sizeof(PGCCNetworkAddress);
  611. /*
  612. * Move the memory pointer past the list of network address pointers.
  613. * This is where the first network address structure will be written.
  614. */
  615. memory += data_length;
  616. /*
  617. * Iterate through the internal list of NET_ADDR structures,
  618. * building "API" GCCNetworkAddress structures in memory.
  619. */
  620. m_NetAddrItemList.Reset();
  621. while (NULL != (address_info = m_NetAddrItemList.Iterate()))
  622. {
  623. /*
  624. * Save the pointer to the network address structure in the list
  625. * of pointers.
  626. */
  627. network_address_ptr = (PGCCNetworkAddress)memory;
  628. address_array[network_address_counter++] = network_address_ptr;
  629. /*
  630. * Move the memory pointer past the network address structure.
  631. * This is where the network address data will be written.
  632. */
  633. memory += ROUNDTOBOUNDARY(sizeof(GCCNetworkAddress));
  634. /*
  635. * Check to see what type of network address this is and fill in
  636. * the user data structure. Here the address is the aggregated
  637. * channel type.
  638. */
  639. switch (address_info->network_address.network_address_type)
  640. {
  641. case GCC_AGGREGATED_CHANNEL_ADDRESS:
  642. network_address_ptr->network_address_type = GCC_AGGREGATED_CHANNEL_ADDRESS;
  643. /*
  644. * Copy the transfer modes.
  645. */
  646. network_address_ptr->u.aggregated_channel_address.transfer_modes =
  647. address_info->network_address.u.aggregated_channel_address.transfer_modes;
  648. /*
  649. * Copy the international number.
  650. */
  651. ::lstrcpyA(network_address_ptr->u.aggregated_channel_address.international_number,
  652. address_info->network_address.u.aggregated_channel_address.international_number);
  653. /*
  654. * If the sub address string exists, set the sub address string
  655. * pointer and write the data into memory. Otherwise, set the
  656. * "API" pointer to NULL.
  657. */
  658. if (address_info->pszSubAddress != NULL)
  659. {
  660. network_address_ptr->u.aggregated_channel_address.sub_address_string =
  661. (GCCCharacterString)memory;
  662. /*
  663. * Now copy the sub-address string data from the internal
  664. * Rogue Wave string into memory.
  665. */
  666. ::lstrcpyA((LPSTR) memory, address_info->pszSubAddress);
  667. /*
  668. * Move the memory pointer past the sub-address string data.
  669. * This is where the GCCExtraDialingString structure will be
  670. * written.
  671. */
  672. memory += ROUNDTOBOUNDARY(::lstrlenA(address_info->pszSubAddress) + 1);
  673. }
  674. else
  675. {
  676. /*
  677. * No sub-address was present so set the pointer to NULL.
  678. */
  679. network_address_ptr->u.aggregated_channel_address.sub_address_string = NULL;
  680. }
  681. /*
  682. * If the extra dialing string exists, set the extra dialing
  683. * string pointer and write the data into memory. Otherwise,
  684. * set the "API" pointer to NULL.
  685. */
  686. if (address_info->pwszExtraDialing != NULL)
  687. {
  688. network_address_ptr->u.aggregated_channel_address.extra_dialing_string =
  689. (PGCCExtraDialingString)memory;
  690. /*
  691. * Move the memory pointer past the GCCExtraDialingString
  692. * structure. This is where the extra dialing string data
  693. * will be written.
  694. */
  695. memory += ROUNDTOBOUNDARY(sizeof(GCCExtraDialingString));
  696. UINT cchExtraDialing = ::lstrlenW(address_info->pwszExtraDialing);
  697. network_address_ptr->u.aggregated_channel_address.extra_dialing_string->length =
  698. (USHORT) cchExtraDialing;
  699. network_address_ptr->u.aggregated_channel_address.extra_dialing_string->value =
  700. (LPWSTR)memory;
  701. /*
  702. * Now copy the hex string data from the internal Unicode
  703. * String into the allocated memory.
  704. */
  705. //
  706. // LONCHANC: The size does not include null terminator in the original code.
  707. // could this be a bug???
  708. //
  709. ::CopyMemory(memory, address_info->pwszExtraDialing, cchExtraDialing * sizeof(WCHAR));
  710. /*
  711. * Move the memory pointer past the extra dialing string
  712. * data. This is where the high layer compatibility
  713. * structure will be written.
  714. */
  715. memory += ROUNDTOBOUNDARY(cchExtraDialing * sizeof(WCHAR));
  716. }
  717. else
  718. {
  719. /*
  720. * No extra dialing string was present so set the pointer
  721. * to NULL.
  722. */
  723. network_address_ptr->u.aggregated_channel_address.extra_dialing_string = NULL;
  724. }
  725. /*
  726. * If the high layer compatibility structure exists, set the
  727. * pointer and write the data into memory. Otherwise, set
  728. * the "API" pointer to NULL.
  729. */
  730. if (address_info->high_layer_compatibility != NULL)
  731. {
  732. network_address_ptr->u.aggregated_channel_address.high_layer_compatibility =
  733. (PGCCHighLayerCompatibility)memory;
  734. *network_address_ptr->u.aggregated_channel_address.high_layer_compatibility =
  735. *(address_info->high_layer_compatibility);
  736. /*
  737. * Move the memory pointer past the high layer
  738. * compatibility structure.
  739. */
  740. memory += ROUNDTOBOUNDARY(sizeof(GCCHighLayerCompatibility));
  741. }
  742. else
  743. {
  744. /*
  745. * No high layer compatibility structure was present so
  746. * set the pointer to NULL.
  747. */
  748. network_address_ptr->u.aggregated_channel_address.
  749. high_layer_compatibility = NULL;
  750. }
  751. break;
  752. /*
  753. * The network address is a transport connection type.
  754. */
  755. case GCC_TRANSPORT_CONNECTION_ADDRESS:
  756. network_address_ptr->network_address_type = GCC_TRANSPORT_CONNECTION_ADDRESS;
  757. /*
  758. * Now copy the nsap address.
  759. */
  760. ::CopyMemory(network_address_ptr->u.transport_connection_address.nsap_address.value,
  761. address_info->network_address.u.transport_connection_address.nsap_address.value,
  762. address_info->network_address.u.transport_connection_address.nsap_address.length);
  763. network_address_ptr->u.transport_connection_address.nsap_address.length =
  764. address_info->network_address.u.transport_connection_address.nsap_address.length;
  765. /*
  766. * If a transport selector exists, set the transport selector
  767. * pointer and write the data into memory. Otherwise, set the
  768. * "API" pointer to NULL.
  769. */
  770. if (address_info->poszTransportSelector != NULL)
  771. {
  772. network_address_ptr->u.transport_connection_address.transport_selector = (LPOSTR) memory;
  773. /*
  774. * Move the memory pointer past the OSTR
  775. * structure. This is where the actual string data will
  776. * be written.
  777. */
  778. memory += ROUNDTOBOUNDARY(sizeof(OSTR));
  779. network_address_ptr->u.transport_connection_address.
  780. transport_selector->value = (LPBYTE)memory;
  781. network_address_ptr->u.transport_connection_address.
  782. transport_selector->length =
  783. address_info->poszTransportSelector->length;
  784. /*
  785. * Now copy the transport selector string data from the
  786. * internal Rogue Wave string into memory.
  787. */
  788. ::CopyMemory(memory, address_info->poszTransportSelector->value,
  789. address_info->poszTransportSelector->length);
  790. /*
  791. * Move the memory pointer past the transport selector
  792. * string data.
  793. */
  794. memory += ROUNDTOBOUNDARY(address_info->poszTransportSelector->length);
  795. }
  796. else
  797. {
  798. network_address_ptr->u.transport_connection_address.transport_selector = NULL;
  799. }
  800. break;
  801. /*
  802. * The network address is a non-standard type.
  803. */
  804. case GCC_NONSTANDARD_NETWORK_ADDRESS:
  805. network_address_ptr->network_address_type = GCC_NONSTANDARD_NETWORK_ADDRESS;
  806. /*
  807. * Check to make sure both elements of the non-standard address
  808. * exist in the internal structure.
  809. */
  810. if ((address_info->poszNonStandardParam == NULL) ||
  811. (address_info->object_key == NULL))
  812. {
  813. ERROR_OUT(("CNetAddrListContainer::GetNetworkAddressListAPI: Bad internal pointer"));
  814. cbDataSizeToRet = 0;
  815. }
  816. else
  817. {
  818. data_length = address_info->object_key->
  819. GetGCCObjectKeyData( &network_address_ptr->u.
  820. non_standard_network_address.object_key,
  821. memory);
  822. /*
  823. * Move the memory pointer past the object key data. This
  824. * is where the octet string data will be written.
  825. */
  826. memory += data_length;
  827. network_address_ptr->u.non_standard_network_address.parameter_data.value =
  828. memory;
  829. /*
  830. * Write the octet string data into memory and set the octet
  831. * string structure pointer and length.
  832. */
  833. network_address_ptr->u.non_standard_network_address.parameter_data.length =
  834. (USHORT) address_info->poszNonStandardParam->length;
  835. /*
  836. * Now copy the octet string data from the internal Rogue
  837. * Wave string into the object key structure held in memory.
  838. */
  839. ::CopyMemory(memory, address_info->poszNonStandardParam->value,
  840. address_info->poszNonStandardParam->length);
  841. /*
  842. * Move the memory pointer past the octet string data.
  843. */
  844. memory += ROUNDTOBOUNDARY(address_info->poszNonStandardParam->length);
  845. }
  846. break;
  847. default:
  848. ERROR_OUT(("CNetAddrListContainer::GetNetworkAddressListAPI: Error Bad type."));
  849. break;
  850. } // switch
  851. } // while
  852. }
  853. else
  854. {
  855. *network_address_list = NULL;
  856. *number_of_network_addresses = 0;
  857. ERROR_OUT(("CNetAddrListContainer::GetNetworkAddressListAPI: Error Data Not Locked"));
  858. }
  859. return cbDataSizeToRet;
  860. }
  861. /*
  862. * UnLockNetworkAddressList ()
  863. *
  864. * Public Function Description:
  865. * This routine unlocks any memory which has been locked for the "API"
  866. * form of the network address list. If the "Free" flag has been set then
  867. * the CNetAddrListContainer object will be destroyed.
  868. *
  869. */
  870. void CNetAddrListContainer::
  871. UnLockNetworkAddressList(void)
  872. {
  873. /*
  874. * If the lock count has reached zero, this object is "unlocked" so do
  875. * some cleanup.
  876. */
  877. if (Unlock(FALSE) == 0)
  878. {
  879. /*
  880. * Unlock any memory locked for the CObjectKeyContainer objects in the
  881. * internal NET_ADDR structures.
  882. */
  883. NET_ADDR *pNetAddrInfo;
  884. m_NetAddrItemList.Reset();
  885. while (NULL != (pNetAddrInfo = m_NetAddrItemList.Iterate()))
  886. {
  887. if (pNetAddrInfo->object_key != NULL)
  888. {
  889. pNetAddrInfo->object_key->UnLockObjectKeyData();
  890. }
  891. }
  892. }
  893. // we have to call Release() because we used Unlock(FALSE)
  894. Release();
  895. }
  896. /*
  897. * GetNetworkAddressListPDU ()
  898. *
  899. * Public Function Description:
  900. * This routine is used to retrieve the network address list in "PDU" form.
  901. */
  902. GCCError CNetAddrListContainer::
  903. GetNetworkAddressListPDU(PSetOfNetworkAddresses *set_of_network_addresses)
  904. {
  905. GCCError rc = GCC_NO_ERROR;
  906. PSetOfNetworkAddresses new_pdu_network_address_ptr;
  907. PSetOfNetworkAddresses old_pdu_network_address_ptr = NULL;
  908. /*
  909. * If this is the first time that PDU data has been requested then we must
  910. * fill in the internal PDU structure and copy it into the structure pointed
  911. * to by the output parameter. On subsequent calls to "GetPDU" we can just
  912. * copy the internal PDU structure into the structure pointed to by the
  913. * output parameter.
  914. */
  915. if (m_fValidNetAddrPDU == FALSE)
  916. {
  917. m_fValidNetAddrPDU = TRUE;
  918. /*
  919. * Initialize the output parameter to NULL so that the first time
  920. * through it will be set equal to the first new set of network address
  921. * data created in the iterator loop.
  922. */
  923. m_pSetOfNetAddrPDU = NULL;
  924. /*
  925. * Iterate through the list of NET_ADDR structures,
  926. * converting each into "PDU" form and saving the pointers in the
  927. * linked list of "SetsOfNetworkAddresses".
  928. */
  929. NET_ADDR *pNetAddrInfo;
  930. m_NetAddrItemList.Reset();
  931. while (NULL != (pNetAddrInfo = m_NetAddrItemList.Iterate()))
  932. {
  933. /*
  934. * If an allocation failure occurs, call the routine which will
  935. * iterate through the list freeing any data which had been
  936. * allocated.
  937. */
  938. DBG_SAVE_FILE_LINE
  939. new_pdu_network_address_ptr = new SetOfNetworkAddresses;
  940. if (new_pdu_network_address_ptr == NULL)
  941. {
  942. ERROR_OUT(("CNetAddrListContainer::GetNetworkAddressListPDU: Allocation error, cleaning up"));
  943. rc = GCC_ALLOCATION_FAILURE;
  944. FreeNetworkAddressListPDU ();
  945. break;
  946. }
  947. /*
  948. * The first time through, set the PDU structure pointer equal
  949. * to the first SetOfNetworkAddresses created. On subsequent loops,
  950. * set the structure's "next" pointer equal to the new structure.
  951. */
  952. if (m_pSetOfNetAddrPDU == NULL)
  953. {
  954. m_pSetOfNetAddrPDU = new_pdu_network_address_ptr;
  955. }
  956. else
  957. {
  958. old_pdu_network_address_ptr->next = new_pdu_network_address_ptr;
  959. }
  960. old_pdu_network_address_ptr = new_pdu_network_address_ptr;
  961. /*
  962. * Initialize the new "next" pointer to NULL.
  963. */
  964. new_pdu_network_address_ptr->next = NULL;
  965. /*
  966. * Call the routine to actually convert the network address.
  967. */
  968. if (ConvertNetworkAddressInfoToPDU(pNetAddrInfo, new_pdu_network_address_ptr) != GCC_NO_ERROR)
  969. {
  970. ERROR_OUT(("CNetAddrListContainer::GetNetworkAddressListPDU: can't create NET_ADDR to PDU"));
  971. rc = GCC_ALLOCATION_FAILURE;
  972. break;
  973. }
  974. }
  975. }
  976. /*
  977. * Copy the internal PDU structure into the structure pointed to by the
  978. * output parameter.
  979. */
  980. *set_of_network_addresses = m_pSetOfNetAddrPDU;
  981. return rc;
  982. }
  983. /*
  984. * FreeNetworkAddressListPDU ()
  985. *
  986. * Public Function Description:
  987. * This routine is used to free the memory allocated for the "PDU" form
  988. * of the network address list.
  989. */
  990. GCCError CNetAddrListContainer::
  991. FreeNetworkAddressListPDU(void)
  992. {
  993. GCCError rc = GCC_NO_ERROR;
  994. PSetOfNetworkAddresses pdu_network_address_set;
  995. PSetOfNetworkAddresses next_pdu_network_address_set;
  996. if (m_fValidNetAddrPDU)
  997. {
  998. m_fValidNetAddrPDU = FALSE;
  999. pdu_network_address_set = m_pSetOfNetAddrPDU;
  1000. /*
  1001. * Loop through the list, freeing the network address data associated
  1002. * with each structure contained in the list. The only data allocated
  1003. * for the PDU which is not held in the internal info structure list
  1004. * is done by the CObjectKeyContainer object. Those objects are told to free
  1005. * that data in the iterator loop below.
  1006. */
  1007. while (pdu_network_address_set != NULL)
  1008. {
  1009. next_pdu_network_address_set = pdu_network_address_set->next;
  1010. delete pdu_network_address_set;
  1011. pdu_network_address_set = next_pdu_network_address_set;
  1012. }
  1013. /*
  1014. * Free any PDU memory allocated by the internal CObjectKeyContainer object.
  1015. */
  1016. NET_ADDR *pNetAddrInfo;
  1017. m_NetAddrItemList.Reset();
  1018. while (NULL != (pNetAddrInfo = m_NetAddrItemList.Iterate()))
  1019. {
  1020. if (pNetAddrInfo->object_key != NULL)
  1021. {
  1022. pNetAddrInfo->object_key->FreeObjectKeyDataPDU();
  1023. }
  1024. }
  1025. }
  1026. else
  1027. {
  1028. ERROR_OUT(("NetAddressList::FreeUserDataListPDU: PDU Data not allocated"));
  1029. rc = GCC_BAD_NETWORK_ADDRESS;
  1030. }
  1031. return (rc);
  1032. }
  1033. /*
  1034. * GCCError StoreNetworkAddressList (
  1035. * UINT number_of_network_addresses,
  1036. * PGCCNetworkAddress * local_network_address_list);
  1037. *
  1038. * Private member function of CNetAddrListContainer.
  1039. *
  1040. * Function Description:
  1041. * This routine is used to store the network address data passed in as
  1042. * "API" data in the internal structures.
  1043. *
  1044. * Formal Parameters:
  1045. * number_of_network_addresses (i) Number of addresses in "API" list.
  1046. * local_network_address_list (i) List of "API" addresses.
  1047. *
  1048. * Return Value:
  1049. * GCC_NO_ERROR - No error.
  1050. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  1051. * "new" operator.
  1052. * GCC_BAD_NETWORK_ADDRESS - Invalid network address passed in.
  1053. * GCC_BAD_NETWORK_ADDRESS_TYPE - Bad "choice" field for address
  1054. *
  1055. * Side Effects:
  1056. * None.
  1057. *
  1058. * Caveats:
  1059. * None.
  1060. */
  1061. GCCError CNetAddrListContainer::
  1062. StoreNetworkAddressList(UINT number_of_network_addresses,
  1063. PGCCNetworkAddress * local_network_address_list)
  1064. {
  1065. GCCError rc;
  1066. NET_ADDR *network_address_info;
  1067. PGCCNetworkAddress network_address;
  1068. UINT i;
  1069. /*
  1070. * For each network address in the list, create a new "info" structure to
  1071. * buffer the data internally. Fill in the structure and save it in the
  1072. * Rogue Wave list.
  1073. */
  1074. for (i = 0; i < number_of_network_addresses; i++)
  1075. {
  1076. DBG_SAVE_FILE_LINE
  1077. if (NULL == (network_address_info = new NET_ADDR))
  1078. {
  1079. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: can't create NET_ADDR"));
  1080. rc = GCC_ALLOCATION_FAILURE;
  1081. goto MyExit;
  1082. }
  1083. /*
  1084. * This variable is used for abbreviation.
  1085. */
  1086. network_address = &network_address_info->network_address;
  1087. /*
  1088. * Copy all the network address data into the network address
  1089. * structure that is part of the network address info structure.
  1090. */
  1091. *network_address = *local_network_address_list[i];
  1092. /*
  1093. * This section of the code deals with any data embedded in the
  1094. * network address that would not have been copied in the above
  1095. * operation (typically pointers to strings).
  1096. */
  1097. switch (network_address->network_address_type)
  1098. {
  1099. case GCC_AGGREGATED_CHANNEL_ADDRESS:
  1100. /*
  1101. * Check to make sure the international number dialing string
  1102. * does not violate the imposed ASN.1 constraints.
  1103. */
  1104. if (! IsDialingStringValid(local_network_address_list[i]->u.aggregated_channel_address.international_number))
  1105. {
  1106. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: Invalid international number"));
  1107. rc = GCC_BAD_NETWORK_ADDRESS;
  1108. goto MyExit;
  1109. }
  1110. /*
  1111. * If a sub-address string exists, store it in a Rogue Wave
  1112. * container. Set the structure pointer to NULL if one does
  1113. * not exist.
  1114. */
  1115. if (local_network_address_list[i]->u.aggregated_channel_address.sub_address_string != NULL)
  1116. {
  1117. /*
  1118. * Check to make sure the sub address string does not
  1119. * violate the imposed ASN.1 constraints.
  1120. */
  1121. if (! IsCharacterStringValid(local_network_address_list[i]->u.aggregated_channel_address.sub_address_string))
  1122. {
  1123. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: Invalid sub address string"));
  1124. rc = GCC_BAD_NETWORK_ADDRESS;
  1125. goto MyExit;
  1126. }
  1127. /*
  1128. * Create a string to hold the sub address.
  1129. */
  1130. if (NULL == (network_address_info->pszSubAddress = ::My_strdupA(
  1131. (LPSTR) local_network_address_list[i]->u.aggregated_channel_address.sub_address_string)))
  1132. {
  1133. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: can't creating new sub address string"));
  1134. rc = GCC_ALLOCATION_FAILURE;
  1135. goto MyExit;
  1136. }
  1137. }
  1138. else
  1139. {
  1140. network_address_info->pszSubAddress = NULL;
  1141. }
  1142. /*
  1143. * If an extra dialing string exists, store it in a Unicode
  1144. * String object. Set the structure pointer to NULL if one
  1145. * does not exist.
  1146. */
  1147. if (local_network_address_list[i]->u.aggregated_channel_address.extra_dialing_string != NULL)
  1148. {
  1149. /*
  1150. * Check to make sure the extra dialing string does not
  1151. * violate the imposed ASN.1 constraints.
  1152. */
  1153. if (! IsExtraDialingStringValid(local_network_address_list[i]->u.aggregated_channel_address.extra_dialing_string))
  1154. {
  1155. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: Invalid extra dialing string"));
  1156. rc = GCC_BAD_NETWORK_ADDRESS;
  1157. goto MyExit;
  1158. }
  1159. if (NULL == (network_address_info->pwszExtraDialing = ::My_strdupW2(
  1160. local_network_address_list[i]->u.aggregated_channel_address.extra_dialing_string->length,
  1161. local_network_address_list[i]->u.aggregated_channel_address.extra_dialing_string->value)))
  1162. {
  1163. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: Error creating extra dialing string"));
  1164. rc = GCC_ALLOCATION_FAILURE;
  1165. goto MyExit;
  1166. }
  1167. }
  1168. else
  1169. {
  1170. network_address_info->pwszExtraDialing = NULL;
  1171. }
  1172. /*
  1173. * If a higher layer compatibility structure exists, store it
  1174. * in a GCCHighLayerCompatibility structure. Set the structure
  1175. * pointer to NULL if one does not exist.
  1176. */
  1177. if (local_network_address_list[i]->u.aggregated_channel_address.high_layer_compatibility != NULL)
  1178. {
  1179. DBG_SAVE_FILE_LINE
  1180. network_address_info->high_layer_compatibility = new GCCHighLayerCompatibility;
  1181. if (network_address_info->high_layer_compatibility != NULL)
  1182. {
  1183. /*
  1184. * Copy the high layer compatibility data to the
  1185. * new structure.
  1186. */
  1187. *network_address_info->high_layer_compatibility =
  1188. *(local_network_address_list[i]->u.aggregated_channel_address.high_layer_compatibility);
  1189. }
  1190. else
  1191. {
  1192. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: Error creating new GCCHighLayerCompatibility"));
  1193. rc = GCC_ALLOCATION_FAILURE;
  1194. goto MyExit;
  1195. }
  1196. }
  1197. else
  1198. {
  1199. network_address_info->high_layer_compatibility = NULL;
  1200. }
  1201. break;
  1202. case GCC_TRANSPORT_CONNECTION_ADDRESS:
  1203. /*
  1204. * Check to make sure the length of the nsap address is within
  1205. * the allowable range.
  1206. */
  1207. if ((local_network_address_list[i]->u.transport_connection_address.nsap_address.length < MINIMUM_NSAP_ADDRESS_SIZE)
  1208. ||
  1209. (local_network_address_list[i]->u.transport_connection_address.nsap_address.length > MAXIMUM_NSAP_ADDRESS_SIZE))
  1210. {
  1211. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: Invalid nsap address"));
  1212. rc = GCC_BAD_NETWORK_ADDRESS;
  1213. goto MyExit;
  1214. }
  1215. /*
  1216. * If a transport selector exists, store it in a Rogue Wave
  1217. * string. Otherwise, set the structure pointer to NULL.
  1218. */
  1219. if (local_network_address_list[i]->u.transport_connection_address.transport_selector != NULL)
  1220. {
  1221. /*
  1222. * Create a Rogue Wave string to hold the transport
  1223. * selector string.
  1224. */
  1225. if (NULL == (network_address_info->poszTransportSelector = ::My_strdupO2(
  1226. local_network_address_list[i]->u.transport_connection_address.transport_selector->value,
  1227. local_network_address_list[i]->u.transport_connection_address.transport_selector->length)))
  1228. {
  1229. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: can't create transport selector"));
  1230. rc = GCC_ALLOCATION_FAILURE;
  1231. goto MyExit;
  1232. }
  1233. }
  1234. else
  1235. {
  1236. network_address_info->poszTransportSelector = NULL;
  1237. }
  1238. break;
  1239. case GCC_NONSTANDARD_NETWORK_ADDRESS:
  1240. /*
  1241. * Create a Rogue Wave string to hold the non-standard
  1242. * parameter octet string.
  1243. */
  1244. if (NULL == (network_address_info->poszNonStandardParam = ::My_strdupO2(
  1245. local_network_address_list[i]->u.non_standard_network_address.parameter_data.value,
  1246. local_network_address_list[i]->u.non_standard_network_address.parameter_data.length)))
  1247. {
  1248. ERROR_OUT(("CNetAddrListContainer::StoreNetworkAddressList: can't create non-standard param"));
  1249. rc = GCC_ALLOCATION_FAILURE;
  1250. goto MyExit;
  1251. }
  1252. /*
  1253. * Next store the object key internally in an CObjectKeyContainer
  1254. * object.
  1255. */
  1256. DBG_SAVE_FILE_LINE
  1257. network_address_info->object_key = new CObjectKeyContainer(
  1258. &local_network_address_list[i]->u.non_standard_network_address.object_key,
  1259. &rc);
  1260. if (network_address_info->object_key == NULL || rc != GCC_NO_ERROR)
  1261. {
  1262. ERROR_OUT(("CNetAddrListContainer::StoreNetAddrList: Error creating new CObjectKeyContainer"));
  1263. rc = GCC_ALLOCATION_FAILURE;
  1264. goto MyExit;
  1265. }
  1266. break;
  1267. default:
  1268. ERROR_OUT(("CNetAddrListContainer::StoreNetAddrList: bad network address type=%u", (UINT) network_address->network_address_type));
  1269. rc = GCC_BAD_NETWORK_ADDRESS_TYPE;
  1270. goto MyExit;
  1271. }
  1272. /*
  1273. * If all data was properly saved, insert the "info" structure
  1274. * pointer into the Rogue Wave list.
  1275. */
  1276. m_NetAddrItemList.Append(network_address_info);
  1277. } // for
  1278. rc = GCC_NO_ERROR;
  1279. MyExit:
  1280. if (GCC_NO_ERROR != rc)
  1281. {
  1282. delete network_address_info;
  1283. }
  1284. return rc;
  1285. }
  1286. /*
  1287. * GCCError ConvertPDUDataToInternal (
  1288. * PSetOfNetworkAddresses network_address_ptr)
  1289. *
  1290. * Private member function of CNetAddrListContainer.
  1291. *
  1292. * Function Description:
  1293. * This routine is used to store the network address data passed in as
  1294. * "PDU" data in the internal structures.
  1295. *
  1296. * Formal Parameters:
  1297. * network_address_ptr (i) "PDU" address list structure.
  1298. *
  1299. * Return Value:
  1300. * GCC_NO_ERROR - No error.
  1301. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  1302. * "new" operator.
  1303. *
  1304. * Side Effects:
  1305. * None.
  1306. *
  1307. * Caveats:
  1308. * None.
  1309. */
  1310. GCCError CNetAddrListContainer::
  1311. ConvertPDUDataToInternal(PSetOfNetworkAddresses network_address_ptr)
  1312. {
  1313. GCCError rc;
  1314. GCCError error_value;
  1315. NET_ADDR *network_address_info_ptr;
  1316. PGCCNetworkAddress copy_network_address;
  1317. PNetworkAddress pdu_network_address;
  1318. /*
  1319. * Create a new info structure to hold the data internally.
  1320. */
  1321. DBG_SAVE_FILE_LINE
  1322. if (NULL == (network_address_info_ptr = new NET_ADDR))
  1323. {
  1324. ERROR_OUT(("CNetAddrListContainer::ConvertPDUDataToInternal: can't create NET_ADDR"));
  1325. rc = GCC_ALLOCATION_FAILURE;
  1326. goto MyExit;
  1327. }
  1328. /*
  1329. * Use these variables for clarity and brevity.
  1330. */
  1331. copy_network_address = &network_address_info_ptr->network_address;
  1332. pdu_network_address = &network_address_ptr->value;
  1333. /*
  1334. * Check to see what type of network address exists and save the data
  1335. * in the internal structures.
  1336. */
  1337. switch (pdu_network_address->choice)
  1338. {
  1339. case AGGREGATED_CHANNEL_CHOSEN:
  1340. copy_network_address->network_address_type = GCC_AGGREGATED_CHANNEL_ADDRESS;
  1341. /*
  1342. * Save the tranfer modes structure.
  1343. */
  1344. ConvertTransferModesToInternal(
  1345. &pdu_network_address->u.aggregated_channel.transfer_modes,
  1346. &copy_network_address->u.aggregated_channel_address.transfer_modes);
  1347. /*
  1348. * Save the international number.
  1349. */
  1350. ::lstrcpyA(copy_network_address->u.aggregated_channel_address.international_number,
  1351. pdu_network_address->u.aggregated_channel.international_number);
  1352. /*
  1353. * Save the sub address string (if it exists) in the Rogue Wave
  1354. * buffer contained in the network info structure. Otherwise, set
  1355. * the structure pointer to NULL.
  1356. */
  1357. if (pdu_network_address->u.aggregated_channel.bit_mask & SUB_ADDRESS_PRESENT)
  1358. {
  1359. /*
  1360. * Create a Rogue Wave string to hold the sub address string.
  1361. */
  1362. if (NULL == (network_address_info_ptr->pszSubAddress = ::My_strdupA(
  1363. pdu_network_address->u.aggregated_channel.sub_address)))
  1364. {
  1365. ERROR_OUT(("CNetAddrListContainer::ConvertPDUDataToInternal: can't create sub address string"));
  1366. rc = GCC_ALLOCATION_FAILURE;
  1367. goto MyExit;
  1368. }
  1369. }
  1370. else
  1371. {
  1372. /*
  1373. * The sub address string is not present so set the internal
  1374. * info structure pointer to NULL.
  1375. */
  1376. network_address_info_ptr->pszSubAddress = NULL;
  1377. }
  1378. /*
  1379. * Next save the extra dialing string if one exists.
  1380. */
  1381. if (pdu_network_address->u.aggregated_channel.bit_mask & EXTRA_DIALING_STRING_PRESENT)
  1382. {
  1383. if (NULL == (network_address_info_ptr->pwszExtraDialing = ::My_strdupW2(
  1384. pdu_network_address->u.aggregated_channel.extra_dialing_string.length,
  1385. pdu_network_address->u.aggregated_channel.extra_dialing_string.value)))
  1386. {
  1387. ERROR_OUT(("CNetAddrListContainer::ConvertPDUDataToInternal: Error creating extra dialing string"));
  1388. rc = GCC_ALLOCATION_FAILURE;
  1389. goto MyExit;
  1390. }
  1391. }
  1392. else
  1393. {
  1394. /*
  1395. * The extra dialing string is not present so set the internal
  1396. * info structure pointer to NULL.
  1397. */
  1398. network_address_info_ptr->pwszExtraDialing = NULL;
  1399. }
  1400. /*
  1401. * Save the high layer compatibility structure if it is present.
  1402. */
  1403. if (pdu_network_address->u.aggregated_channel.bit_mask & HIGH_LAYER_COMPATIBILITY_PRESENT)
  1404. {
  1405. DBG_SAVE_FILE_LINE
  1406. network_address_info_ptr->high_layer_compatibility = new GCCHighLayerCompatibility;
  1407. if (network_address_info_ptr->high_layer_compatibility != NULL)
  1408. {
  1409. /*
  1410. * Copy the high layer compatibility data to the
  1411. * new structure.
  1412. */
  1413. ConvertHighLayerCompatibilityToInternal(
  1414. &pdu_network_address->u.aggregated_channel.high_layer_compatibility,
  1415. network_address_info_ptr->high_layer_compatibility);
  1416. }
  1417. else
  1418. {
  1419. ERROR_OUT(("CNetAddrListContainer::ConvertPDUDataToInternal: Error creating new GCCHighLayerCompatibility"));
  1420. rc = GCC_ALLOCATION_FAILURE;
  1421. goto MyExit;
  1422. }
  1423. }
  1424. else
  1425. {
  1426. /*
  1427. * The high layer compatibility structure is not present so set
  1428. * the internal info structure pointer to NULL.
  1429. */
  1430. network_address_info_ptr->high_layer_compatibility = NULL;
  1431. }
  1432. break;
  1433. /*
  1434. * Save the transport connection address.
  1435. */
  1436. case TRANSPORT_CONNECTION_CHOSEN:
  1437. copy_network_address->network_address_type = GCC_TRANSPORT_CONNECTION_ADDRESS;
  1438. /*
  1439. * Save the nsap address by copying the length and then the string.
  1440. */
  1441. copy_network_address->u.transport_connection_address.nsap_address.length =
  1442. pdu_network_address->u.transport_connection.nsap_address.length;
  1443. ::lstrcpyA((LPSTR)copy_network_address->u.transport_connection_address.nsap_address.value,
  1444. (LPSTR)pdu_network_address->u.transport_connection.nsap_address.value);
  1445. /*
  1446. * Save the transport selector if one exists.
  1447. */
  1448. if (pdu_network_address->u.transport_connection.bit_mask & TRANSPORT_SELECTOR_PRESENT)
  1449. {
  1450. /*
  1451. * Create a Rogue Wave string to hold the transport
  1452. * selector string.
  1453. */
  1454. if (NULL == (network_address_info_ptr->poszTransportSelector = ::My_strdupO2(
  1455. pdu_network_address->u.transport_connection.transport_selector.value,
  1456. pdu_network_address->u.transport_connection.transport_selector.length)))
  1457. {
  1458. ERROR_OUT(("CNetAddrListContainer::ConvertPDUDataToInternal: can't create transport selector"));
  1459. rc = GCC_ALLOCATION_FAILURE;
  1460. goto MyExit;
  1461. }
  1462. }
  1463. else
  1464. {
  1465. /*
  1466. * The transport selector is not present so set the internal
  1467. * info structure pointer to NULL.
  1468. */
  1469. network_address_info_ptr->poszTransportSelector = NULL;
  1470. }
  1471. break;
  1472. /*
  1473. * Save the non standard address.
  1474. */
  1475. case ADDRESS_NON_STANDARD_CHOSEN:
  1476. copy_network_address->network_address_type = GCC_NONSTANDARD_NETWORK_ADDRESS;
  1477. /*
  1478. * Create a Rogue Wave string to hold the non-standard
  1479. * parameter octet string.
  1480. */
  1481. if (NULL == (network_address_info_ptr->poszNonStandardParam = ::My_strdupO2(
  1482. pdu_network_address->u.address_non_standard.data.value,
  1483. pdu_network_address->u.address_non_standard.data.length)))
  1484. {
  1485. ERROR_OUT(("CNetAddrListContainer::ConvertPDUDataToInternal: can't create non-standard param"));
  1486. rc = GCC_ALLOCATION_FAILURE;
  1487. goto MyExit;
  1488. }
  1489. /*
  1490. * Next store the object key internally in an CObjectKeyContainer
  1491. * object.
  1492. */
  1493. DBG_SAVE_FILE_LINE
  1494. network_address_info_ptr->object_key = new CObjectKeyContainer(
  1495. &pdu_network_address->u.address_non_standard.key,
  1496. &error_value);
  1497. if ((network_address_info_ptr->object_key == NULL) ||
  1498. (error_value != GCC_NO_ERROR))
  1499. {
  1500. ERROR_OUT(("CNetAddrListContainer::ConvertPDUDataToInternal: Error creating new CObjectKeyContainer"));
  1501. rc = GCC_ALLOCATION_FAILURE;
  1502. goto MyExit;
  1503. }
  1504. break;
  1505. default:
  1506. ERROR_OUT(("CNetAddrListContainer::ConvertPDUDataToInternal: Error bad network address type"));
  1507. rc = GCC_ALLOCATION_FAILURE;
  1508. goto MyExit;
  1509. } // switch
  1510. /*
  1511. * Go ahead and save the pointer to the info structure in the
  1512. * internal Rogue Wave list.
  1513. */
  1514. m_NetAddrItemList.Append(network_address_info_ptr);
  1515. rc = GCC_NO_ERROR;
  1516. MyExit:
  1517. if (GCC_NO_ERROR != rc)
  1518. {
  1519. delete network_address_info_ptr;
  1520. }
  1521. return rc;
  1522. }
  1523. /*
  1524. * GCCError ConvertNetworkAddressInfoToPDU (
  1525. * NET_ADDR *network_address_info_ptr,
  1526. * PSetOfNetworkAddresses network_address_pdu_ptr)
  1527. *
  1528. * Private member function of CNetAddrListContainer.
  1529. *
  1530. * Function Description:
  1531. * This routine is used to convert the network address info structures
  1532. * maintained internally into the "PDU" form which is a
  1533. * SetOfNetworkAddresses.
  1534. *
  1535. * Formal Parameters:
  1536. * network_address_info_ptr (i) Internal network address structure.
  1537. * network_address_pdu_ptr (o) PDU network address structure to fill in
  1538. *
  1539. * Return Value:
  1540. * GCC_NO_ERROR - No error.
  1541. * GCC_ALLOCATION_FAILURE - Error converting the network address
  1542. *
  1543. * Side Effects:
  1544. * None.
  1545. *
  1546. * Caveats:
  1547. * None.
  1548. */
  1549. GCCError CNetAddrListContainer::
  1550. ConvertNetworkAddressInfoToPDU(NET_ADDR *network_address_info_ptr,
  1551. PSetOfNetworkAddresses network_address_pdu_ptr)
  1552. {
  1553. GCCError rc = GCC_NO_ERROR;
  1554. PGCCNetworkAddress api_ptr;
  1555. PNetworkAddress pdu_ptr;
  1556. /*
  1557. * This variable will point to the "API" network address structure held in
  1558. * the internal info structure. It is used for brevity.
  1559. */
  1560. api_ptr = &network_address_info_ptr->network_address;
  1561. /*
  1562. * This variable will point to the "PDU" network address structure held in
  1563. * the "SetOfNetworkAddresses" structure. It is used for brevity.
  1564. */
  1565. pdu_ptr = &network_address_pdu_ptr->value;
  1566. /*
  1567. * Check to see what type of network address exists. Fill in the
  1568. * appropriate form of the network address PDU structure.
  1569. */
  1570. switch (api_ptr->network_address_type)
  1571. {
  1572. case GCC_AGGREGATED_CHANNEL_ADDRESS:
  1573. /*
  1574. * Fill in the aggregated channel address PDU structure.
  1575. */
  1576. pdu_ptr->choice = AGGREGATED_CHANNEL_CHOSEN;
  1577. pdu_ptr->u.aggregated_channel.bit_mask = 0;
  1578. /*
  1579. * Convert the structure holding the transfer modes into PDU form.
  1580. */
  1581. ConvertTransferModesToPDU(&api_ptr->u.aggregated_channel_address.transfer_modes,
  1582. &pdu_ptr->u.aggregated_channel.transfer_modes);
  1583. /*
  1584. * Copy the international number string.
  1585. */
  1586. ::lstrcpyA(pdu_ptr->u.aggregated_channel.international_number,
  1587. api_ptr->u.aggregated_channel_address.international_number);
  1588. /*
  1589. * Copy the sub-address string if it is present. Set the bit mask in
  1590. * the PDU structure indicating that a sub-address string is present.
  1591. */
  1592. if (network_address_info_ptr->pszSubAddress != NULL)
  1593. {
  1594. pdu_ptr->u.aggregated_channel.bit_mask |= SUB_ADDRESS_PRESENT;
  1595. ::lstrcpyA((LPSTR) pdu_ptr->u.aggregated_channel.sub_address,
  1596. network_address_info_ptr->pszSubAddress);
  1597. }
  1598. /*
  1599. * Copy the extra dialing string if it is present. Set the bit mask in
  1600. * the PDU structure indicating that an extra dialing string is present.
  1601. */
  1602. if (network_address_info_ptr->pwszExtraDialing != NULL)
  1603. {
  1604. pdu_ptr->u.aggregated_channel.bit_mask |= EXTRA_DIALING_STRING_PRESENT;
  1605. pdu_ptr->u.aggregated_channel.extra_dialing_string.value =
  1606. network_address_info_ptr->pwszExtraDialing;
  1607. pdu_ptr->u.aggregated_channel.extra_dialing_string.length =
  1608. ::lstrlenW(network_address_info_ptr->pwszExtraDialing);
  1609. }
  1610. /*
  1611. * Convert the structure holding the high layer compatibilities into
  1612. * PDU form, if it is present. Set the bit mask in the PDU structure
  1613. * indicating that a high layer compatibility structure is present.
  1614. */
  1615. if (network_address_info_ptr->high_layer_compatibility != NULL)
  1616. {
  1617. pdu_ptr->u.aggregated_channel.bit_mask |= HIGH_LAYER_COMPATIBILITY_PRESENT;
  1618. ConvertHighLayerCompatibilityToPDU(
  1619. network_address_info_ptr->high_layer_compatibility,
  1620. &pdu_ptr->u.aggregated_channel.high_layer_compatibility);
  1621. }
  1622. break;
  1623. case GCC_TRANSPORT_CONNECTION_ADDRESS:
  1624. /*
  1625. * Fill in the transport connection address PDU structure.
  1626. */
  1627. pdu_ptr->choice = TRANSPORT_CONNECTION_CHOSEN;
  1628. /*
  1629. * Copy the nsap_address.
  1630. */
  1631. pdu_ptr->u.transport_connection.nsap_address.length =
  1632. api_ptr->u.transport_connection_address.nsap_address.length;
  1633. ::lstrcpyA((LPSTR)pdu_ptr->u.transport_connection.nsap_address.value,
  1634. (LPSTR)api_ptr->u.transport_connection_address.nsap_address.value);
  1635. /*
  1636. * Copy the transport selector if it is present. Set the bit mask in
  1637. * the PDU structure indicating that a transport selector is present.
  1638. */
  1639. if (network_address_info_ptr->poszTransportSelector != NULL)
  1640. {
  1641. pdu_ptr->u.transport_connection.bit_mask |= TRANSPORT_SELECTOR_PRESENT;
  1642. pdu_ptr->u.transport_connection.transport_selector.length =
  1643. network_address_info_ptr->poszTransportSelector->length;
  1644. pdu_ptr->u.transport_connection.transport_selector.value =
  1645. (LPBYTE) network_address_info_ptr->poszTransportSelector->value;
  1646. }
  1647. break;
  1648. case GCC_NONSTANDARD_NETWORK_ADDRESS:
  1649. /*
  1650. * Fill in the non-standard network address PDU structure.
  1651. */
  1652. pdu_ptr->choice = ADDRESS_NON_STANDARD_CHOSEN;
  1653. /*
  1654. * Fill in the data portion of the non-standard parameter.
  1655. */
  1656. pdu_ptr->u.address_non_standard.data.length =
  1657. network_address_info_ptr->poszNonStandardParam->length;
  1658. pdu_ptr->u.address_non_standard.data.value =
  1659. network_address_info_ptr->poszNonStandardParam->value;
  1660. /*
  1661. * Now fill in the object key portion of the non-standard parameter
  1662. * using the CObjectKeyContainer object stored internally in the network
  1663. * address info structure.
  1664. */
  1665. rc = network_address_info_ptr->object_key->GetObjectKeyDataPDU(&pdu_ptr->u.address_non_standard.key);
  1666. if (rc != GCC_NO_ERROR)
  1667. {
  1668. ERROR_OUT(("CNetAddrListContainer::ConvertNetworkAddressInfoToPDU: Error getting object key data PDU"));
  1669. }
  1670. break;
  1671. default:
  1672. /*
  1673. * The constructors will check to make sure a valid network address
  1674. * type exists so this should never be encountered.
  1675. */
  1676. ERROR_OUT(("CNetAddrListContainer::ConvertNetworkAddressInfoToPDU: Error bad network address type"));
  1677. rc = GCC_ALLOCATION_FAILURE;
  1678. }
  1679. return rc;
  1680. }
  1681. /*
  1682. * void ConvertTransferModesToInternal (
  1683. * PTransferModes source_transfer_modes,
  1684. * PGCCTransferModes copy_transfer_modes)
  1685. *
  1686. * Private member function of CNetAddrListContainer.
  1687. *
  1688. * Function Description:
  1689. * This routine is used to convert the PDU network address transfer modes
  1690. * structure into the internal form where the structure is saved as a
  1691. * GCCTranferModes structure.
  1692. *
  1693. * Formal Parameters:
  1694. * source_transfer_modes (i) Structure holding "PDU" transfer modes.
  1695. * copy_transfer_modes (o) Structure to hold "API" transfer modes.
  1696. *
  1697. * Return Value:
  1698. * None.
  1699. *
  1700. * Side Effects:
  1701. * None.
  1702. *
  1703. * Caveats:
  1704. * None.
  1705. */
  1706. void CNetAddrListContainer::
  1707. ConvertTransferModesToInternal(PTransferModes source_transfer_modes,
  1708. PGCCTransferModes copy_transfer_modes)
  1709. {
  1710. copy_transfer_modes->speech = (BOOL) source_transfer_modes->speech;
  1711. copy_transfer_modes->voice_band = (BOOL) source_transfer_modes->voice_band;
  1712. copy_transfer_modes->digital_56k = (BOOL) source_transfer_modes->digital_56k;
  1713. copy_transfer_modes->digital_64k = (BOOL) source_transfer_modes->digital_64k;
  1714. copy_transfer_modes->digital_128k = (BOOL) source_transfer_modes->digital_128k;
  1715. copy_transfer_modes->digital_192k = (BOOL) source_transfer_modes->digital_192k;
  1716. copy_transfer_modes->digital_256k = (BOOL) source_transfer_modes->digital_256k;
  1717. copy_transfer_modes->digital_320k = (BOOL) source_transfer_modes->digital_320k;
  1718. copy_transfer_modes->digital_384k = (BOOL) source_transfer_modes->digital_384k;
  1719. copy_transfer_modes->digital_512k = (BOOL) source_transfer_modes->digital_512k;
  1720. copy_transfer_modes->digital_768k = (BOOL) source_transfer_modes->digital_768k;
  1721. copy_transfer_modes->digital_1152k = (BOOL) source_transfer_modes->digital_1152k;
  1722. copy_transfer_modes->digital_1472k = (BOOL) source_transfer_modes->digital_1472k;
  1723. copy_transfer_modes->digital_1536k = (BOOL) source_transfer_modes->digital_1536k;
  1724. copy_transfer_modes->digital_1920k = (BOOL) source_transfer_modes->digital_1920k;
  1725. copy_transfer_modes->packet_mode = (BOOL) source_transfer_modes->packet_mode;
  1726. copy_transfer_modes->frame_mode = (BOOL) source_transfer_modes->frame_mode;
  1727. copy_transfer_modes->atm = (BOOL) source_transfer_modes->atm;
  1728. }
  1729. /*
  1730. * void ConvertHighLayerCompatibilityToInternal (
  1731. * PHighLayerCompatibility source_structure,
  1732. * PGCCHighLayerCompatibility copy_structure)
  1733. *
  1734. * Private member function of CNetAddrListContainer.
  1735. *
  1736. * Function Description:
  1737. * This routine is used to convert the PDU network address high layer
  1738. * compatibility structure into the internal form where the structure is
  1739. * saved as a GCCHighLayerCompatibility structure.
  1740. *
  1741. * Formal Parameters:
  1742. * source_structure (i) Structure holding "PDU" high layer
  1743. * compatibilities.
  1744. * copy_structure (o) Structure to hold "API" high layer
  1745. * compatibilities.
  1746. *
  1747. * Return Value:
  1748. * None.
  1749. *
  1750. * Side Effects:
  1751. * None.
  1752. *
  1753. * Caveats:
  1754. * None.
  1755. */
  1756. void CNetAddrListContainer::
  1757. ConvertHighLayerCompatibilityToInternal(PHighLayerCompatibility source_structure,
  1758. PGCCHighLayerCompatibility copy_structure)
  1759. {
  1760. copy_structure->telephony3kHz = (BOOL) source_structure->telephony3kHz;
  1761. copy_structure->telephony7kHz = (BOOL) source_structure->telephony7kHz;
  1762. copy_structure->videotelephony = (BOOL) source_structure->videotelephony;
  1763. copy_structure->videoconference = (BOOL) source_structure->videoconference;
  1764. copy_structure->audiographic = (BOOL) source_structure->audiographic;
  1765. copy_structure->audiovisual = (BOOL) source_structure->audiovisual;
  1766. copy_structure->multimedia = (BOOL) source_structure->multimedia;
  1767. }
  1768. /*
  1769. * void ConvertTransferModesToPDU (
  1770. * PGCCTransferModes source_transfer_modes,
  1771. * PTransferModes copy_transfer_modes)
  1772. *
  1773. * Private member function of CNetAddrListContainer.
  1774. *
  1775. * Function Description:
  1776. * This routine is used to convert the API network address transfer modes
  1777. * structure into the PDU form which is a TranferModes structure.
  1778. *
  1779. * Formal Parameters:
  1780. * source_transfer_modes (i) Structure holding "API" transfer modes.
  1781. * copy_transfer_modes (i) Structure holding "PDU" transfer modes.
  1782. *
  1783. * Return Value:
  1784. * None.
  1785. *
  1786. * Side Effects:
  1787. * None.
  1788. *
  1789. * Caveats:
  1790. * None.
  1791. */
  1792. void CNetAddrListContainer::
  1793. ConvertTransferModesToPDU(PGCCTransferModes source_transfer_modes,
  1794. PTransferModes copy_transfer_modes)
  1795. {
  1796. copy_transfer_modes->speech = (ASN1bool_t) source_transfer_modes->speech;
  1797. copy_transfer_modes->voice_band = (ASN1bool_t) source_transfer_modes->voice_band;
  1798. copy_transfer_modes->digital_56k = (ASN1bool_t) source_transfer_modes->digital_56k;
  1799. copy_transfer_modes->digital_64k = (ASN1bool_t) source_transfer_modes->digital_64k;
  1800. copy_transfer_modes->digital_128k = (ASN1bool_t) source_transfer_modes->digital_128k;
  1801. copy_transfer_modes->digital_192k = (ASN1bool_t) source_transfer_modes->digital_192k;
  1802. copy_transfer_modes->digital_256k = (ASN1bool_t) source_transfer_modes->digital_256k;
  1803. copy_transfer_modes->digital_320k = (ASN1bool_t) source_transfer_modes->digital_320k;
  1804. copy_transfer_modes->digital_384k = (ASN1bool_t) source_transfer_modes->digital_384k;
  1805. copy_transfer_modes->digital_512k = (ASN1bool_t) source_transfer_modes->digital_512k;
  1806. copy_transfer_modes->digital_768k = (ASN1bool_t) source_transfer_modes->digital_768k;
  1807. copy_transfer_modes->digital_1152k = (ASN1bool_t) source_transfer_modes->digital_1152k;
  1808. copy_transfer_modes->digital_1472k = (ASN1bool_t) source_transfer_modes->digital_1472k;
  1809. copy_transfer_modes->digital_1536k = (ASN1bool_t) source_transfer_modes->digital_1536k;
  1810. copy_transfer_modes->digital_1920k = (ASN1bool_t) source_transfer_modes->digital_1920k;
  1811. copy_transfer_modes->packet_mode = (ASN1bool_t) source_transfer_modes->packet_mode;
  1812. copy_transfer_modes->frame_mode = (ASN1bool_t) source_transfer_modes->frame_mode;
  1813. copy_transfer_modes->atm = (ASN1bool_t) source_transfer_modes->atm;
  1814. }
  1815. /*
  1816. * void ConvertHighLayerCompatibilityToPDU (
  1817. * PGCCHighLayerCompatibility source_structure,
  1818. * PHighLayerCompatibility copy_structure)
  1819. *
  1820. * Private member function of CNetAddrListContainer.
  1821. *
  1822. * Function Description:
  1823. * This routine is used to convert the API network address high layer
  1824. * compatibility structure into the PDU form which is a
  1825. * HighLayerCompatibility structure.
  1826. *
  1827. * Formal Parameters:
  1828. * source_structure (i) Structure holding "API" high layer
  1829. * compatibilities.
  1830. * copy_structure (o) Structure to hold "PDU" high layer
  1831. * compatibilities.
  1832. *
  1833. * Return Value:
  1834. * None.
  1835. *
  1836. * Side Effects:
  1837. * None.
  1838. *
  1839. * Caveats:
  1840. * None.
  1841. */
  1842. void CNetAddrListContainer::
  1843. ConvertHighLayerCompatibilityToPDU(PGCCHighLayerCompatibility source_structure,
  1844. PHighLayerCompatibility copy_structure)
  1845. {
  1846. copy_structure->telephony3kHz = (ASN1bool_t) source_structure->telephony3kHz;
  1847. copy_structure->telephony7kHz = (ASN1bool_t) source_structure->telephony7kHz;
  1848. copy_structure->videotelephony = (ASN1bool_t) source_structure->videotelephony;
  1849. copy_structure->videoconference = (ASN1bool_t) source_structure->videoconference;
  1850. copy_structure->audiographic = (ASN1bool_t) source_structure->audiographic;
  1851. copy_structure->audiovisual = (ASN1bool_t) source_structure->audiovisual;
  1852. copy_structure->multimedia = (ASN1bool_t) source_structure->multimedia;
  1853. }
  1854. /*
  1855. * BOOL IsDialingStringValid ( GCCDialingString dialing_string)
  1856. *
  1857. * Private member function of CNetAddrListContainer.
  1858. *
  1859. * Function Description:
  1860. * This routine is used to ensure that the values held within a
  1861. * dialing string do not violate the imposed ASN.1 constraints. The
  1862. * dialing string is constrained to be digits between 0 and 9, inclusive.
  1863. *
  1864. * Formal Parameters:
  1865. * dialing_string (i) Dialing string to validate.
  1866. *
  1867. * Return Value:
  1868. * TRUE - The string is valid.
  1869. * FALSE - The string violates the ASN.1 constraints.
  1870. *
  1871. * Side Effects:
  1872. * None.
  1873. *
  1874. * Caveats:
  1875. * None.
  1876. */
  1877. BOOL CNetAddrListContainer::
  1878. IsDialingStringValid(GCCDialingString dialing_string)
  1879. {
  1880. BOOL fRet = TRUE;
  1881. while (*dialing_string != 0)
  1882. {
  1883. if ((*dialing_string < '0') || (*dialing_string > '9'))
  1884. {
  1885. fRet = FALSE;
  1886. break;
  1887. }
  1888. dialing_string++;
  1889. }
  1890. return fRet;
  1891. }
  1892. /*
  1893. * BOOL IsCharacterStringValid (
  1894. * GCCCharacterString character_string)
  1895. *
  1896. * Private member function of CNetAddrListContainer.
  1897. *
  1898. * Function Description:
  1899. * This routine is used to ensure that the values held within a
  1900. * character string do not violate the imposed ASN.1 constraints. The
  1901. * character string is constrained to be digits between 0 and 9, inclusive.
  1902. *
  1903. * Formal Parameters:
  1904. * character_string (i) Character string to validate.
  1905. *
  1906. * Return Value:
  1907. * TRUE - The string is valid.
  1908. * FALSE - The string violates the ASN.1 constraints.
  1909. *
  1910. * Side Effects:
  1911. * None.
  1912. *
  1913. * Caveats:
  1914. * None.
  1915. */
  1916. BOOL CNetAddrListContainer::
  1917. IsCharacterStringValid(GCCCharacterString character_string)
  1918. {
  1919. BOOL fRet = TRUE;
  1920. while (*character_string != 0)
  1921. {
  1922. if ((*character_string < '0') || (*character_string > '9'))
  1923. {
  1924. fRet = FALSE;
  1925. break;
  1926. }
  1927. character_string++;
  1928. }
  1929. return fRet;
  1930. }
  1931. /*
  1932. * BOOL IsExtraDialingStringValid (
  1933. * PGCCExtraDialingString extra_dialing_string)
  1934. *
  1935. * Private member function of CNetAddrListContainer.
  1936. *
  1937. * Function Description:
  1938. * This routine is used to ensure that the values held within an
  1939. * extra dialing string do not violate the imposed ASN.1 constraints.
  1940. *
  1941. * Formal Parameters:
  1942. * extra_dialing_string (i) Dialing string to validate.
  1943. *
  1944. * Return Value:
  1945. * TRUE - The string is valid.
  1946. * FALSE - The string violates the ASN.1 constraints.
  1947. *
  1948. * Side Effects:
  1949. * None.
  1950. *
  1951. * Caveats:
  1952. * None.
  1953. */
  1954. BOOL CNetAddrListContainer::
  1955. IsExtraDialingStringValid(PGCCExtraDialingString extra_dialing_string)
  1956. {
  1957. BOOL fRet = TRUE;
  1958. /*
  1959. * Check to make sure the length of the string is within the
  1960. * allowable range.
  1961. */
  1962. if ((extra_dialing_string->length < MINIMUM_EXTRA_DIALING_STRING_SIZE) ||
  1963. (extra_dialing_string->length > MAXIMUM_EXTRA_DIALING_STRING_SIZE))
  1964. {
  1965. fRet = FALSE;
  1966. }
  1967. else
  1968. {
  1969. /*
  1970. * If the length is valid, check the string values.
  1971. */
  1972. LPWSTR pwsz = extra_dialing_string->value;
  1973. for (USHORT i = 0; i < extra_dialing_string->length; i++)
  1974. {
  1975. if ((*pwsz != '#') && (*pwsz != '*') && (*pwsz != ','))
  1976. {
  1977. if ((*pwsz < '0') || (*pwsz > '9'))
  1978. {
  1979. fRet = FALSE;
  1980. break;
  1981. }
  1982. }
  1983. pwsz++;
  1984. }
  1985. }
  1986. return fRet;
  1987. }