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.

2104 lines
68 KiB

  1. /***************************************************************************
  2. *
  3. * INTEL Corporation Proprietary Information
  4. * Copyright (c) 1994, 1995, 1996 Intel Corporation.
  5. *
  6. * This listing is supplied under the terms of a license agreement
  7. * with INTEL Corporation and may not be used, copied, nor disclosed
  8. * except in accordance with the terms of that agreement.
  9. *
  10. ***************************************************************************
  11. *
  12. * $Workfile: pdu.c $
  13. * $Revision: 1.13 $
  14. * $Modtime: 27 Jan 1997 12:33:26 $
  15. * $Log: S:/STURGEON/SRC/H245/SRC/VCS/pdu.c_v $
  16. *
  17. * Rev 1.13 27 Jan 1997 12:40:28 MANDREWS
  18. *
  19. * Fixed warnings.
  20. *
  21. * Rev 1.12 28 Aug 1996 11:37:26 EHOWARDX
  22. * const changes.
  23. *
  24. * Rev 1.11 19 Aug 1996 15:38:36 EHOWARDX
  25. * Initialized lResult to H245_ERROR_OK in SetupCommModeEntry().
  26. *
  27. * Rev 1.10 15 Aug 1996 15:20:34 EHOWARDX
  28. * First pass at new H245_COMM_MODE_ENTRY_T requested by Mike Andrews.
  29. * Use at your own risk!
  30. *
  31. * Rev 1.9 08 Aug 1996 16:01:56 EHOWARDX
  32. *
  33. * Change pdu_rsp_mstslv_ack to take either master_chosen or slave_chosen
  34. * as second parameter.
  35. *
  36. * Rev 1.8 19 Jul 1996 12:14:30 EHOWARDX
  37. * Eliminated pdu_cmd_misc.
  38. *
  39. * Rev 1.7 09 Jul 1996 17:10:26 EHOWARDX
  40. * Fixed pointer offset bug in processing DataType from received
  41. * OpenLogicalChannel.
  42. *
  43. * Rev 1.6 14 Jun 1996 18:58:32 EHOWARDX
  44. * Geneva Update.
  45. *
  46. * Rev 1.5 10 Jun 1996 16:52:24 EHOWARDX
  47. * Eliminated #include "h245init.x"
  48. *
  49. * Rev 1.4 30 May 1996 23:39:22 EHOWARDX
  50. * Cleanup.
  51. *
  52. * Rev 1.3 29 May 1996 15:20:22 EHOWARDX
  53. * Change to use HRESULT.
  54. *
  55. * Rev 1.2 28 May 1996 14:25:20 EHOWARDX
  56. * Tel Aviv update.
  57. *
  58. * Rev 1.1 13 May 1996 23:16:40 EHOWARDX
  59. * Fixed remote terminal capability handling.
  60. *
  61. * Rev 1.0 09 May 1996 21:06:38 EHOWARDX
  62. * Initial revision.
  63. *
  64. * Rev 1.27 09 May 1996 19:32:46 EHOWARDX
  65. * Added support for new H.245 fields (e.g. SeparateStack).
  66. *
  67. * Rev 1.26 01 May 1996 19:28:24 EHOWARDX
  68. * Changed H2250_xxx defines from H2250 address type to H245_xxx defines.
  69. *
  70. * Rev 1.25 27 Apr 1996 21:10:42 EHOWARDX
  71. * Cleaned up multiplex ack parameter handling.
  72. *
  73. * Rev 1.23.1.5 25 Apr 1996 17:54:34 EHOWARDX
  74. * Changed wTxPort to dwTxPort in pdu_req_open_logical_channel().
  75. *
  76. * Rev 1.23.1.4 24 Apr 1996 20:51:24 EHOWARDX
  77. * Added new OpenLogicalChannelAck support.
  78. *
  79. * Rev 1.23.1.3 16 Apr 1996 20:10:58 EHOWARDX
  80. * Added support for H2250LogicalParameters to OpenLogicalChannel.
  81. *
  82. * Rev 1.23.1.2 15 Apr 1996 15:14:20 EHOWARDX
  83. * Updated Open Logical Channel to match current ASN.1 syntax structure.
  84. *
  85. * Rev 1.23.1.1 02 Apr 1996 22:35:04 EHOWARDX
  86. * Needed to initialize setupType.choice in H245OpenChannel.
  87. * (This field is probably soon to be obsolete, but right now
  88. * the PDU encode rejects it if it is not initialized.
  89. *
  90. * Rev 1.23.1.0 28 Mar 1996 20:17:18 EHOWARDX
  91. *
  92. * Changes for new ASN syntax additions.
  93. *
  94. * Rev 1.22 13 Mar 1996 10:12:00 cjutzi
  95. *
  96. * - was not puting sequence number in mux_acc or mux_rej
  97. *
  98. * Rev 1.21 12 Mar 1996 15:50:22 cjutzi
  99. *
  100. * added EndSession
  101. *
  102. * Rev 1.20 11 Mar 1996 14:04:32 cjutzi
  103. * - added ind_multiplex_entry_send_release.. back in.. and to the header..
  104. *
  105. * Rev 1.19 08 Mar 1996 14:01:04 cjutzi
  106. *
  107. * - added Multiplex Entry stuff
  108. *
  109. * Rev 1.18 06 Mar 1996 08:43:32 cjutzi
  110. * - fixed constraints on sub element lists, and nesting depth for
  111. * mux table pdu build..
  112. *
  113. * Rev 1.17 05 Mar 1996 19:40:04 EHOWARDX
  114. * Put pdu_ind_multiplex_entry_send_release() and
  115. * pdu_ind_request_multiplex_entry_release() functions back in after
  116. * Curt was so kind as to delete them for us.
  117. *
  118. * Rev 1.16 05 Mar 1996 17:33:12 cjutzi
  119. *
  120. * - fixed, and imlemented down muxt table entries,
  121. * - removed bzero/bcopy and fixed free api call
  122. *
  123. * Rev 1.15 02 Mar 1996 22:14:18 DABROWN1
  124. *
  125. * Rev 1.14 28 Feb 1996 19:06:34 unknown
  126. * Oops! Gotta watch those global replaces... (Changed H245ASSERT
  127. * back to ASSERT)
  128. *
  129. * Rev 1.13 28 Feb 1996 18:29:34 EHOWARDX
  130. * Changed ASSERT() to ASSERT().
  131. *
  132. * Rev 1.12 28 Feb 1996 16:08:36 EHOWARDX
  133. *
  134. * Changed pTable to WORD pointer.
  135. *
  136. * Rev 1.11 28 Feb 1996 14:01:42 EHOWARDX
  137. *
  138. * Added MultiplexEntry functions:
  139. * pdu_req_multiplex_entry_send
  140. * pdu_rsp_multiplex_entry_send_ack
  141. * pdu_rsp_multiplex_entry_send_reject
  142. * pdu_ind_multiplex_entry_send_release
  143. * pdu_ind_request_multiplex_entry_release
  144. *
  145. * Rev 1.10 26 Feb 1996 17:25:14 cjutzi
  146. *
  147. * - implemented MISCCMD command for PDU's
  148. *
  149. * Rev 1.9 26 Feb 1996 09:24:30 cjutzi
  150. * - removed req_termcqap_set (bit_mask) setup.. moved to main line
  151. * code.. rather than the pdu build..
  152. *
  153. * Rev 1.8 22 Feb 1996 12:43:16 unknown
  154. * Fixed bitmask Open Ack problem
  155. *
  156. * Rev 1.7 21 Feb 1996 14:17:36 unknown
  157. * No change.
  158. *
  159. * Rev 1.6 15 Feb 1996 10:55:16 cjutzi
  160. *
  161. * - fixed open pdu problem bit-mask
  162. * - changed interface for MUX_T
  163. *
  164. * Rev 1.5 13 Feb 1996 14:39:48 DABROWN1
  165. * Removed SPOX dependent include files from mainline
  166. *
  167. * Rev 1.4 13 Feb 1996 13:27:04 cjutzi
  168. * - fixed a problem w/ open channel
  169. *
  170. * Rev 1.3 09 Feb 1996 15:49:48 cjutzi
  171. *
  172. * - added dollar log to header.
  173. * - changed bitmask on open.. hadn't set forward open parameters to present..
  174. *
  175. ***************************************************************************/
  176. #ifndef STRICT
  177. #define STRICT
  178. #endif
  179. #include "precomp.h"
  180. /***********************/
  181. /* H245 INCLUDES */
  182. /***********************/
  183. #include "h245asn1.h" /* must be included before H245api.h */
  184. #include "h245api.h"
  185. #include "h245com.h"
  186. #include "h245sys.x"
  187. #include "api_util.x" /* for free_mux_desc_list */
  188. #include "pdu.x"
  189. HRESULT
  190. SetupUnicastAddress (UnicastAddress *pOut,
  191. const H245_TRANSPORT_ADDRESS_T *pIn)
  192. {
  193. switch (pIn->type)
  194. {
  195. case H245_IP_UNICAST:
  196. pOut->choice = UnicastAddress_iPAddress_chosen;
  197. pOut->u.UnicastAddress_iPAddress.network.length = 4;
  198. memcpy(pOut->u.UnicastAddress_iPAddress.network.value, pIn->u.ip.network, 4);
  199. pOut->u.UnicastAddress_iPAddress.tsapIdentifier = pIn->u.ip.tsapIdentifier;
  200. break;
  201. case H245_IP6_UNICAST:
  202. pOut->choice = UncstAddrss_iP6Address_chosen;
  203. pOut->u.UncstAddrss_iP6Address.network.length = 16;
  204. memcpy(pOut->u.UncstAddrss_iP6Address.network.value, pIn->u.ip6.network, 16);
  205. pOut->u.UncstAddrss_iP6Address.tsapIdentifier = pIn->u.ip6.tsapIdentifier;
  206. break;
  207. case H245_IPSSR_UNICAST:
  208. pOut->choice = iPSourceRouteAddress_chosen;
  209. pOut->u.iPSourceRouteAddress.routing.choice = strict_chosen;
  210. pOut->u.iPSourceRouteAddress.network.length = 4;
  211. memcpy(pOut->u.iPSourceRouteAddress.network.value, pIn->u.ipSourceRoute.network, 4);
  212. pOut->u.iPSourceRouteAddress.tsapIdentifier = pIn->u.ipSourceRoute.tsapIdentifier;
  213. // TBD - handle route
  214. return H245_ERROR_NOTIMP;
  215. break;
  216. case H245_IPLSR_UNICAST:
  217. pOut->choice = iPSourceRouteAddress_chosen;
  218. pOut->u.iPSourceRouteAddress.routing.choice = loose_chosen;
  219. pOut->u.iPSourceRouteAddress.network.length = 4;
  220. memcpy(pOut->u.iPSourceRouteAddress.network.value, pIn->u.ipSourceRoute.network, 4);
  221. pOut->u.iPSourceRouteAddress.tsapIdentifier = pIn->u.ipSourceRoute.tsapIdentifier;
  222. // TBD - handle route
  223. return H245_ERROR_NOTIMP;
  224. break;
  225. case H245_IPX_UNICAST:
  226. pOut->choice = iPXAddress_chosen;
  227. pOut->u.iPXAddress.node.length = 6;
  228. memcpy(pOut->u.iPXAddress.node.value, pIn->u.ipx.node, 6);
  229. pOut->u.iPXAddress.netnum.length = 4;
  230. memcpy(pOut->u.iPXAddress.netnum.value, pIn->u.ipx.netnum, 4);
  231. pOut->u.iPXAddress.tsapIdentifier.length = 2;
  232. memcpy(pOut->u.iPXAddress.tsapIdentifier.value, pIn->u.ipx.tsapIdentifier, 2);
  233. break;
  234. case H245_NETBIOS_UNICAST:
  235. pOut->choice = netBios_chosen;
  236. pOut->u.netBios.length = 16;
  237. memcpy(pOut->u.netBios.value, pIn->u.netBios, 16);
  238. break;
  239. default:
  240. H245TRACE(0,1,"API:SetupUnicastAddress: invalid address type %d", pIn->type);
  241. return H245_ERROR_PARAM;
  242. } // switch
  243. return H245_ERROR_OK;
  244. } // SetupUnicastAddress()
  245. HRESULT
  246. SetupMulticastAddress (MulticastAddress *pOut,
  247. const H245_TRANSPORT_ADDRESS_T *pIn)
  248. {
  249. switch (pIn->type)
  250. {
  251. case H245_IP_MULTICAST:
  252. pOut->choice = MltcstAddrss_iPAddress_chosen;
  253. pOut->u.MltcstAddrss_iPAddress.network.length = 4;
  254. memcpy(pOut->u.MltcstAddrss_iPAddress.network.value, pIn->u.ip.network, 4);
  255. pOut->u.MltcstAddrss_iPAddress.tsapIdentifier = pIn->u.ip.tsapIdentifier;
  256. break;
  257. case H245_IP6_MULTICAST:
  258. pOut->choice = MltcstAddrss_iP6Address_chosen;
  259. pOut->u.MltcstAddrss_iP6Address.network.length = 16;
  260. memcpy(pOut->u.MltcstAddrss_iP6Address.network.value, pIn->u.ip6.network, 16);
  261. pOut->u.MltcstAddrss_iP6Address.tsapIdentifier = pIn->u.ip6.tsapIdentifier;
  262. break;
  263. default:
  264. H245TRACE(0,1,"API:SetupMulticastAddress: invalid address type %d", pIn->type);
  265. return H245_ERROR_PARAM;
  266. } // switch
  267. return H245_ERROR_OK;
  268. } // SetupMulticastAddress()
  269. HRESULT
  270. SetupTransportAddress ( H245TransportAddress *pOut,
  271. const H245_TRANSPORT_ADDRESS_T *pIn)
  272. {
  273. if (pIn->type & 1)
  274. {
  275. pOut->choice = unicastAddress_chosen;
  276. return SetupUnicastAddress(&pOut->u.unicastAddress, pIn);
  277. }
  278. else
  279. {
  280. pOut->choice = multicastAddress_chosen;
  281. return SetupMulticastAddress(&pOut->u.multicastAddress, pIn);
  282. }
  283. } // SetupTransportAddress()
  284. HRESULT
  285. SetupCommModeEntry ( CommunicationModeTableEntry *pOut,
  286. const H245_COMM_MODE_ENTRY_T *pIn)
  287. {
  288. HRESULT lResult = H245_ERROR_OK;
  289. memset(pOut, 0, sizeof(*pOut));
  290. if (pIn->pNonStandard != NULL)
  291. {
  292. pOut->CMTEy_nnStndrd = pIn->pNonStandard;
  293. pOut->bit_mask |= CMTEy_nnStndrd_present;
  294. }
  295. pOut->sessionID = pIn->sessionID;
  296. if (pIn->associatedSessionIDPresent)
  297. {
  298. pOut->CMTEy_assctdSssnID = pIn->associatedSessionID;
  299. pOut->bit_mask |= CMTEy_assctdSssnID_present;
  300. }
  301. if (pIn->terminalLabelPresent)
  302. {
  303. pOut->terminalLabel = pIn->terminalLabel;
  304. pOut->bit_mask |= CommunicationModeTableEntry_terminalLabel_present;
  305. }
  306. pOut->sessionDescription.value = pIn->pSessionDescription;
  307. pOut->sessionDescription.length = pIn->wSessionDescriptionLength;
  308. switch (pIn->dataType.ClientType)
  309. {
  310. case H245_CLIENT_VID_NONSTD:
  311. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_VID_NONSTD");
  312. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_videoData.u.VdCpblty_nonStandard,
  313. &pIn->dataType.Cap.H245Vid_NONSTD);
  314. pOut->dataType.u.dataType_videoData.choice = VdCpblty_nonStandard_chosen;
  315. pOut->dataType.choice = dataType_videoData_chosen;
  316. break;
  317. case H245_CLIENT_VID_H261:
  318. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_VID_H261");
  319. pOut->dataType.u.dataType_videoData.u.h261VideoCapability = pIn->dataType.Cap.H245Vid_H261;
  320. pOut->dataType.u.dataType_videoData.choice = h261VideoCapability_chosen;
  321. pOut->dataType.choice = dataType_videoData_chosen;
  322. break;
  323. case H245_CLIENT_VID_H262:
  324. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_VID_H262");
  325. pOut->dataType.u.dataType_videoData.u.h262VideoCapability = pIn->dataType.Cap.H245Vid_H262;
  326. pOut->dataType.u.dataType_videoData.choice = h262VideoCapability_chosen;
  327. pOut->dataType.choice = dataType_videoData_chosen;
  328. break;
  329. case H245_CLIENT_VID_H263:
  330. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_VID_H263");
  331. pOut->dataType.u.dataType_videoData.u.h263VideoCapability = pIn->dataType.Cap.H245Vid_H263;
  332. pOut->dataType.u.dataType_videoData.choice = h263VideoCapability_chosen;
  333. pOut->dataType.choice = dataType_videoData_chosen;
  334. break;
  335. case H245_CLIENT_VID_IS11172:
  336. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_VID_IS11172");
  337. pOut->dataType.u.dataType_videoData.u.is11172VideoCapability = pIn->dataType.Cap.H245Vid_IS11172;
  338. pOut->dataType.u.dataType_videoData.choice = is11172VideoCapability_chosen;
  339. pOut->dataType.choice = dataType_videoData_chosen;
  340. break;
  341. case H245_CLIENT_AUD_NONSTD:
  342. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_NONSTD");
  343. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_audioData.u.AdCpblty_nonStandard,
  344. &pIn->dataType.Cap.H245Aud_NONSTD);
  345. pOut->dataType.u.dataType_audioData.choice = AdCpblty_nonStandard_chosen;
  346. pOut->dataType.choice = dataType_audioData_chosen;
  347. break;
  348. case H245_CLIENT_AUD_G711_ALAW64:
  349. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G711_ALAW64");
  350. pOut->dataType.u.dataType_audioData.u.AdCpblty_g711Alaw64k = pIn->dataType.Cap.H245Aud_G711_ALAW64;
  351. pOut->dataType.u.dataType_audioData.choice = AdCpblty_g711Alaw64k_chosen;
  352. pOut->dataType.choice = dataType_audioData_chosen;
  353. break;
  354. case H245_CLIENT_AUD_G711_ALAW56:
  355. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G711_ALAW56");
  356. pOut->dataType.u.dataType_audioData.u.AdCpblty_g711Alaw56k = pIn->dataType.Cap.H245Aud_G711_ALAW56;
  357. pOut->dataType.u.dataType_audioData.choice = AdCpblty_g711Alaw56k_chosen;
  358. pOut->dataType.choice = dataType_audioData_chosen;
  359. break;
  360. case H245_CLIENT_AUD_G711_ULAW64:
  361. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G711_ULAW64");
  362. pOut->dataType.u.dataType_audioData.u.AdCpblty_g711Ulaw64k = pIn->dataType.Cap.H245Aud_G711_ULAW64;
  363. pOut->dataType.u.dataType_audioData.choice = AdCpblty_g711Ulaw64k_chosen;
  364. pOut->dataType.choice = dataType_audioData_chosen;
  365. break;
  366. case H245_CLIENT_AUD_G711_ULAW56:
  367. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G711_ULAW56");
  368. pOut->dataType.u.dataType_audioData.u.AdCpblty_g711Ulaw56k = pIn->dataType.Cap.H245Aud_G711_ULAW56;
  369. pOut->dataType.u.dataType_audioData.choice = AdCpblty_g711Ulaw56k_chosen;
  370. pOut->dataType.choice = dataType_audioData_chosen;
  371. break;
  372. case H245_CLIENT_AUD_G722_64:
  373. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G722_64");
  374. pOut->dataType.u.dataType_audioData.u.AudioCapability_g722_64k = pIn->dataType.Cap.H245Aud_G722_64;
  375. pOut->dataType.u.dataType_audioData.choice = AudioCapability_g722_64k_chosen;
  376. pOut->dataType.choice = dataType_audioData_chosen;
  377. break;
  378. case H245_CLIENT_AUD_G722_56:
  379. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G722_56");
  380. pOut->dataType.u.dataType_audioData.u.AudioCapability_g722_56k = pIn->dataType.Cap.H245Aud_G722_56;
  381. pOut->dataType.u.dataType_audioData.choice = AudioCapability_g722_56k_chosen;
  382. pOut->dataType.choice = dataType_audioData_chosen;
  383. break;
  384. case H245_CLIENT_AUD_G722_48:
  385. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G722_48");
  386. pOut->dataType.u.dataType_audioData.u.AudioCapability_g722_48k = pIn->dataType.Cap.H245Aud_G722_48;
  387. pOut->dataType.u.dataType_audioData.choice = AudioCapability_g722_48k_chosen;
  388. pOut->dataType.choice = dataType_audioData_chosen;
  389. break;
  390. case H245_CLIENT_AUD_G723:
  391. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G723");
  392. pOut->dataType.u.dataType_audioData.u.AudioCapability_g7231 = pIn->dataType.Cap.H245Aud_G723;
  393. pOut->dataType.u.dataType_audioData.choice = AudioCapability_g7231_chosen;
  394. pOut->dataType.choice = dataType_audioData_chosen;
  395. break;
  396. case H245_CLIENT_AUD_G728:
  397. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G728");
  398. pOut->dataType.u.dataType_audioData.u.AudioCapability_g728 = pIn->dataType.Cap.H245Aud_G728;
  399. pOut->dataType.u.dataType_audioData.choice = AudioCapability_g728_chosen;
  400. pOut->dataType.choice = dataType_audioData_chosen;
  401. break;
  402. case H245_CLIENT_AUD_G729:
  403. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_G729");
  404. pOut->dataType.u.dataType_audioData.u.AudioCapability_g729 = pIn->dataType.Cap.H245Aud_G729;
  405. pOut->dataType.u.dataType_audioData.choice = AudioCapability_g729_chosen;
  406. pOut->dataType.choice = dataType_audioData_chosen;
  407. break;
  408. case H245_CLIENT_AUD_GDSVD:
  409. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_GDSVD");
  410. pOut->dataType.u.dataType_audioData.u.AdCpblty_g729AnnexA = pIn->dataType.Cap.H245Aud_GDSVD;
  411. pOut->dataType.u.dataType_audioData.choice = AdCpblty_g729AnnexA_chosen;
  412. pOut->dataType.choice = dataType_audioData_chosen;
  413. break;
  414. case H245_CLIENT_AUD_IS11172:
  415. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_IS11172");
  416. pOut->dataType.u.dataType_audioData.u.is11172AudioCapability = pIn->dataType.Cap.H245Aud_IS11172;
  417. pOut->dataType.u.dataType_audioData.choice = is11172AudioCapability_chosen;
  418. pOut->dataType.choice = dataType_audioData_chosen;
  419. break;
  420. case H245_CLIENT_AUD_IS13818:
  421. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_AUD_IS13818");
  422. pOut->dataType.u.dataType_audioData.u.is13818AudioCapability = pIn->dataType.Cap.H245Aud_IS13818;
  423. pOut->dataType.u.dataType_audioData.choice = is13818AudioCapability_chosen;
  424. pOut->dataType.choice = dataType_audioData_chosen;
  425. break;
  426. case H245_CLIENT_DAT_NONSTD:
  427. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_NONSTD");
  428. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_NONSTD;
  429. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_applctn_nnStndrd,
  430. &pIn->dataType.Cap.H245Dat_NONSTD.application.u.DACy_applctn_nnStndrd);
  431. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_nnStndrd_chosen;
  432. pOut->dataType.choice = dataType_data_chosen;
  433. break;
  434. case H245_CLIENT_DAT_T120:
  435. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_T120");
  436. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_T120;
  437. if (pIn->dataType.Cap.H245Dat_T120.application.u.DACy_applctn_t120.choice == DtPrtclCpblty_nnStndrd_chosen)
  438. {
  439. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_applctn_t120.u.DtPrtclCpblty_nnStndrd,
  440. &pIn->dataType.Cap.H245Dat_T120.application.u.DACy_applctn_t120.u.DtPrtclCpblty_nnStndrd);
  441. }
  442. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_t120_chosen;
  443. pOut->dataType.choice = dataType_data_chosen;
  444. break;
  445. case H245_CLIENT_DAT_DSMCC:
  446. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_DSMCC");
  447. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_DSMCC;
  448. if (pIn->dataType.Cap.H245Dat_DSMCC.application.u.DACy_applctn_dsm_cc.choice == DtPrtclCpblty_nnStndrd_chosen)
  449. {
  450. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_applctn_dsm_cc.u.DtPrtclCpblty_nnStndrd,
  451. &pIn->dataType.Cap.H245Dat_DSMCC.application.u.DACy_applctn_dsm_cc.u.DtPrtclCpblty_nnStndrd);
  452. }
  453. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_dsm_cc_chosen;
  454. pOut->dataType.choice = dataType_data_chosen;
  455. break;
  456. case H245_CLIENT_DAT_USERDATA:
  457. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_USERDATA");
  458. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_USERDATA;
  459. if (pIn->dataType.Cap.H245Dat_USERDATA.application.u.DACy_applctn_usrDt.choice == DtPrtclCpblty_nnStndrd_chosen)
  460. {
  461. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_applctn_usrDt.u.DtPrtclCpblty_nnStndrd,
  462. &pIn->dataType.Cap.H245Dat_USERDATA.application.u.DACy_applctn_usrDt.u.DtPrtclCpblty_nnStndrd);
  463. }
  464. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_usrDt_chosen;
  465. pOut->dataType.choice = dataType_data_chosen;
  466. break;
  467. case H245_CLIENT_DAT_T84:
  468. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_T84");
  469. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_T84;
  470. if (pIn->dataType.Cap.H245Dat_T84.application.u.DACy_applctn_t84.t84Protocol.choice == DtPrtclCpblty_nnStndrd_chosen)
  471. {
  472. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_applctn_t84.t84Protocol.u.DtPrtclCpblty_nnStndrd,
  473. &pIn->dataType.Cap.H245Dat_T84.application.u.DACy_applctn_t84.t84Protocol.u.DtPrtclCpblty_nnStndrd);
  474. }
  475. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_t84_chosen;
  476. pOut->dataType.choice = dataType_data_chosen;
  477. break;
  478. case H245_CLIENT_DAT_T434:
  479. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_T434");
  480. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_T434;
  481. if (pIn->dataType.Cap.H245Dat_T434.application.u.DACy_applctn_t434.choice == DtPrtclCpblty_nnStndrd_chosen)
  482. {
  483. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_applctn_t434.u.DtPrtclCpblty_nnStndrd,
  484. &pIn->dataType.Cap.H245Dat_T434.application.u.DACy_applctn_t434.u.DtPrtclCpblty_nnStndrd);
  485. }
  486. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_t434_chosen;
  487. pOut->dataType.choice = dataType_data_chosen;
  488. break;
  489. case H245_CLIENT_DAT_H224:
  490. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_H224");
  491. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_H224;
  492. if (pIn->dataType.Cap.H245Dat_H224.application.u.DACy_applctn_h224.choice == DtPrtclCpblty_nnStndrd_chosen)
  493. {
  494. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_applctn_h224.u.DtPrtclCpblty_nnStndrd,
  495. &pIn->dataType.Cap.H245Dat_H224.application.u.DACy_applctn_h224.u.DtPrtclCpblty_nnStndrd);
  496. }
  497. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_h224_chosen;
  498. pOut->dataType.choice = dataType_data_chosen;
  499. break;
  500. case H245_CLIENT_DAT_NLPID:
  501. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_NLPID");
  502. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_NLPID;
  503. if (pIn->dataType.Cap.H245Dat_NLPID.application.u.DACy_applctn_nlpd.nlpidProtocol.choice == DtPrtclCpblty_nnStndrd_chosen)
  504. {
  505. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_applctn_nlpd.nlpidProtocol.u.DtPrtclCpblty_nnStndrd,
  506. &pIn->dataType.Cap.H245Dat_NLPID.application.u.DACy_applctn_nlpd.nlpidProtocol.u.DtPrtclCpblty_nnStndrd);
  507. }
  508. if (lResult == H245_ERROR_OK && pIn->dataType.Cap.H245Dat_NLPID.application.u.DACy_applctn_nlpd.nlpidData.length != 0)
  509. {
  510. pOut->dataType.u.dataType_data.application.u.DACy_applctn_nlpd.nlpidData.value =
  511. MemAlloc(pIn->dataType.Cap.H245Dat_NLPID.application.u.DACy_applctn_nlpd.nlpidData.length);
  512. if (pOut->dataType.u.dataType_data.application.u.DACy_applctn_nlpd.nlpidData.value)
  513. {
  514. memcpy(pOut->dataType.u.dataType_data.application.u.DACy_applctn_nlpd.nlpidData.value,
  515. pIn->dataType.Cap.H245Dat_NLPID.application.u.DACy_applctn_nlpd.nlpidData.value,
  516. pIn->dataType.Cap.H245Dat_NLPID.application.u.DACy_applctn_nlpd.nlpidData.length);
  517. }
  518. else
  519. lResult = H245_ERROR_NOMEM;
  520. }
  521. else
  522. pOut->dataType.u.dataType_data.application.u.DACy_applctn_nlpd.nlpidData.value = NULL;
  523. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_nlpd_chosen;
  524. pOut->dataType.choice = dataType_data_chosen;
  525. break;
  526. case H245_CLIENT_DAT_DSVD:
  527. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_DSVD");
  528. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_DSMCC;
  529. pOut->dataType.u.dataType_data.application.choice = DACy_applctn_dsvdCntrl_chosen;
  530. pOut->dataType.choice = dataType_data_chosen;
  531. break;
  532. case H245_CLIENT_DAT_H222:
  533. H245TRACE(0,20,"SetupCommModeEntry: H245_CLIENT_DAT_H222");
  534. pOut->dataType.u.dataType_data = pIn->dataType.Cap.H245Dat_H222;
  535. if (pIn->dataType.Cap.H245Dat_H222.application.u.DACy_an_h222DtPrttnng.choice == DtPrtclCpblty_nnStndrd_chosen)
  536. {
  537. lResult = CopyNonStandardParameter(&pOut->dataType.u.dataType_data.application.u.DACy_an_h222DtPrttnng.u.DtPrtclCpblty_nnStndrd,
  538. &pIn->dataType.Cap.H245Dat_H222.application.u.DACy_an_h222DtPrttnng.u.DtPrtclCpblty_nnStndrd);
  539. }
  540. pOut->dataType.u.dataType_data.application.choice = DACy_an_h222DtPrttnng_chosen ;
  541. pOut->dataType.choice = dataType_data_chosen;
  542. break;
  543. default:
  544. H245TRACE(0,20,"SetupCommModeEntry: default");
  545. lResult = H245_ERROR_NOSUP;
  546. } /* switch */
  547. if (lResult)
  548. return lResult;
  549. if (pIn->mediaChannelPresent)
  550. {
  551. lResult = SetupTransportAddress(&pOut->CMTEy_mdChnnl, &pIn->mediaChannel);
  552. if (lResult)
  553. return lResult;
  554. pOut->bit_mask |= CMTEy_mdChnnl_present;
  555. }
  556. if (pIn->mediaGuaranteedPresent)
  557. {
  558. pOut->CMTEy_mdGrntdDlvry = pIn->mediaGuaranteed;
  559. pOut->bit_mask |= CMTEy_mdGrntdDlvry_present;
  560. }
  561. if (pIn->mediaControlChannelPresent)
  562. {
  563. lResult = SetupTransportAddress(&pOut->CMTEy_mdCntrlChnnl, &pIn->mediaControlChannel);
  564. if (lResult)
  565. return lResult;
  566. pOut->bit_mask |= CMTEy_mdCntrlChnnl_present;
  567. }
  568. if (pIn->mediaControlGuaranteedPresent)
  569. {
  570. pOut->CMTEy_mdCntrlGrntdDlvry = pIn->mediaControlGuaranteed;
  571. pOut->bit_mask |= CMTEy_mdCntrlGrntdDlvry_present;
  572. }
  573. return H245_ERROR_OK;
  574. } // SetupCommModeEntry()
  575. /*****************************************************************************
  576. *
  577. * TYPE: Local
  578. *
  579. * PROCEDURE: setup_H223_mux
  580. *
  581. * DESCRIPTION
  582. *
  583. * RETURN:
  584. *
  585. *****************************************************************************/
  586. static HRESULT
  587. setup_H222_mux (H222LogicalChannelParameters *pOut,
  588. const H245_H222_LOGICAL_PARAM_T *pIn)
  589. {
  590. /* See load_H222_param() for inverse function */
  591. pOut->bit_mask = 0;
  592. pOut->resourceID = pIn->resourceID;
  593. pOut->subChannelID = pIn->subChannelID;
  594. if (pIn->pcr_pidPresent)
  595. {
  596. pOut->bit_mask |= pcr_pid_present;
  597. pOut->pcr_pid = pIn->pcr_pid;
  598. }
  599. if (pIn->programDescriptors.length && pIn->programDescriptors.value)
  600. {
  601. pOut->bit_mask |= programDescriptors_present;
  602. pOut->programDescriptors.length = (WORD)pIn->programDescriptors.length;
  603. pOut->programDescriptors.value = pIn->programDescriptors.value;
  604. }
  605. if (pIn->streamDescriptors.length && pIn->streamDescriptors.value)
  606. {
  607. pOut->bit_mask |= streamDescriptors_present;
  608. pOut->streamDescriptors.length = (WORD)pIn->streamDescriptors.length;
  609. pOut->streamDescriptors.value = pIn->streamDescriptors.value;
  610. }
  611. return H245_ERROR_OK;
  612. } // setup_H222_mux
  613. static HRESULT
  614. setup_H223_mux (H223LogicalChannelParameters *pOut,
  615. const H245_H223_LOGICAL_PARAM_T *pIn)
  616. {
  617. /* See load_H223_param() for inverse function */
  618. switch (pIn->AlType)
  619. {
  620. case H245_H223_AL_NONSTD:
  621. pOut->adaptationLayerType.u.H223LCPs_aLTp_nnStndrd = pIn->H223_NONSTD;
  622. pOut->adaptationLayerType.choice = H223LCPs_aLTp_nnStndrd_chosen;
  623. break;
  624. case H245_H223_AL_AL1FRAMED:
  625. pOut->adaptationLayerType.choice = H223LCPs_aLTp_al1Frmd_chosen;
  626. break;
  627. case H245_H223_AL_AL1NOTFRAMED:
  628. pOut->adaptationLayerType.choice = H223LCPs_aLTp_al1NtFrmd_chosen;
  629. break;
  630. case H245_H223_AL_AL2NOSEQ:
  631. pOut->adaptationLayerType.choice = H223LCPs_aLTp_a2WSNs_1_chosen;
  632. break;
  633. case H245_H223_AL_AL2SEQ:
  634. pOut->adaptationLayerType.choice = H223LCPs_aLTp_a2WSNs_2_chosen;
  635. break;
  636. case H245_H223_AL_AL3:
  637. pOut->adaptationLayerType.choice = H223LCPs_aLTp_al3_chosen;
  638. pOut->adaptationLayerType.u.H223LCPs_aLTp_al3.controlFieldOctets = pIn->CtlFldOctet;
  639. pOut->adaptationLayerType.u.H223LCPs_aLTp_al3.sendBufferSize = pIn->SndBufSize;
  640. break;
  641. default:
  642. H245TRACE(0,1,"API:setup_H223_mux: invalid AlType %d", pIn->AlType);
  643. return H245_ERROR_PARAM;
  644. } /* switch */
  645. /* segmentation flag */
  646. pOut->segmentableFlag = pIn->SegmentFlag;
  647. return H245_ERROR_OK;
  648. } // setup_H223_mux
  649. static HRESULT
  650. setup_VGMUX_mux(V76LogicalChannelParameters *pOut,
  651. const H245_VGMUX_LOGICAL_PARAM_T *pIn)
  652. {
  653. /* See load_VGMUX_param() for inverse function */
  654. pOut->hdlcParameters.crcLength.choice = (unsigned short)pIn->crcLength;
  655. pOut->hdlcParameters.n401 = pIn->n401;
  656. pOut->hdlcParameters.loopbackTestProcedure = pIn->loopbackTestProcedure;
  657. pOut->suspendResume.choice = (unsigned short)pIn->suspendResume;
  658. pOut->uIH = pIn->uIH;
  659. pOut->mode.choice = (unsigned short)pIn->mode;
  660. switch (pIn->mode)
  661. {
  662. case H245_V76_ERM:
  663. pOut->mode.u.eRM.windowSize = pIn->windowSize;
  664. pOut->mode.u.eRM.recovery.choice = (unsigned short)pIn->recovery;
  665. break;
  666. } // switch
  667. pOut->v75Parameters.audioHeaderPresent = pIn->audioHeaderPresent;
  668. return H245_ERROR_OK;
  669. } // setup_VGMUX_mux
  670. static HRESULT
  671. setup_H2250_mux(H2250LogicalChannelParameters *pOut,
  672. const H245_H2250_LOGICAL_PARAM_T *pIn)
  673. {
  674. /* See load_H2250_param() for inverse function */
  675. HRESULT lError = H245_ERROR_OK;
  676. pOut->bit_mask = 0;
  677. if (pIn->nonStandardList)
  678. {
  679. pOut->H2250LCPs_nnStndrd = pIn->nonStandardList;
  680. pOut->bit_mask |= H2250LCPs_nnStndrd_present;
  681. }
  682. pOut->sessionID = pIn->sessionID;
  683. if (pIn->associatedSessionIDPresent)
  684. {
  685. pOut->H2250LCPs_assctdSssnID = pIn->associatedSessionID;
  686. pOut->bit_mask |= H2250LCPs_assctdSssnID_present;
  687. }
  688. if (pIn->mediaChannelPresent)
  689. {
  690. if (lError == H245_ERROR_OK)
  691. {
  692. lError = SetupTransportAddress(&pOut->H2250LCPs_mdChnnl,
  693. &pIn->mediaChannel);
  694. if (lError == H245_ERROR_OK)
  695. {
  696. pOut->bit_mask |= H2250LCPs_mdChnnl_present;
  697. }
  698. }
  699. }
  700. if (pIn->mediaGuaranteedPresent)
  701. {
  702. pOut->H2250LCPs_mdGrntdDlvry = pIn->mediaGuaranteed;
  703. pOut->bit_mask |= H2250LCPs_mdGrntdDlvry_present;
  704. }
  705. if (pIn->mediaControlChannelPresent)
  706. {
  707. if (lError == H245_ERROR_OK)
  708. {
  709. lError = SetupTransportAddress(&pOut->H2250LCPs_mdCntrlChnnl,
  710. &pIn->mediaControlChannel);
  711. if (lError == H245_ERROR_OK)
  712. {
  713. pOut->bit_mask |= H2250LCPs_mdCntrlChnnl_present;
  714. }
  715. }
  716. }
  717. if (pIn->mediaControlGuaranteedPresent)
  718. {
  719. pOut->H2250LCPs_mCGDy = pIn->mediaControlGuaranteed;
  720. pOut->bit_mask |= H2250LCPs_mCGDy_present;
  721. }
  722. if (pIn->silenceSuppressionPresent)
  723. {
  724. pOut->silenceSuppression = pIn->silenceSuppression;
  725. pOut->bit_mask |= silenceSuppression_present;
  726. }
  727. if (pIn->destinationPresent)
  728. {
  729. pOut->destination = pIn->destination;
  730. pOut->bit_mask |= H2250LogicalChannelParameters_destination_present;
  731. }
  732. if (pIn->mediaControlChannelPresent)
  733. {
  734. pOut->bit_mask |= H2250LCPs_mdCntrlChnnl_present;
  735. lError = SetupTransportAddress(&pOut->H2250LCPs_mdCntrlChnnl,
  736. &pIn->mediaControlChannel);
  737. }
  738. if (pIn->dynamicRTPPayloadTypePresent)
  739. {
  740. pOut->H2250LCPs_dRTPPTp = pIn->dynamicRTPPayloadType;
  741. pOut->bit_mask |= H2250LCPs_dRTPPTp_present;
  742. }
  743. if (pIn->h261aVideoPacketization)
  744. {
  745. pOut->mediaPacketization.choice = h261aVideoPacketization_chosen;
  746. pOut->bit_mask |= mediaPacketization_present;
  747. }
  748. return lError;
  749. } // setup_H2250_mux
  750. static HRESULT
  751. setup_H2250ACK_mux(H2250LgclChnnlAckPrmtrs *pOut,
  752. const H245_H2250ACK_LOGICAL_PARAM_T *pIn)
  753. {
  754. /* See load_H2250ACK_param() for inverse function */
  755. HRESULT lError = H245_ERROR_OK;
  756. pOut->bit_mask = 0;
  757. if (pIn->nonStandardList)
  758. {
  759. pOut->H2250LCAPs_nnStndrd = pIn->nonStandardList;
  760. pOut->bit_mask |= H2250LCAPs_nnStndrd_present;
  761. }
  762. if (pIn->sessionIDPresent)
  763. {
  764. pOut->sessionID = pIn->sessionID;
  765. pOut->bit_mask |= sessionID_present;
  766. }
  767. if (pIn->mediaChannelPresent)
  768. {
  769. if (lError == H245_ERROR_OK)
  770. {
  771. lError = SetupTransportAddress(&pOut->H2250LCAPs_mdChnnl,
  772. &pIn->mediaChannel);
  773. if (lError == H245_ERROR_OK)
  774. {
  775. pOut->bit_mask |= H2250LCAPs_mdChnnl_present;
  776. }
  777. }
  778. }
  779. if (pIn->mediaControlChannelPresent)
  780. {
  781. if (lError == H245_ERROR_OK)
  782. {
  783. lError = SetupTransportAddress(&pOut->H2250LCAPs_mdCntrlChnnl,
  784. &pIn->mediaControlChannel);
  785. if (lError == H245_ERROR_OK)
  786. {
  787. pOut->bit_mask |= H2250LCAPs_mdCntrlChnnl_present;
  788. }
  789. }
  790. }
  791. if (pIn->dynamicRTPPayloadTypePresent)
  792. {
  793. pOut->H2250LCAPs_dRTPPTp = pIn->dynamicRTPPayloadType;
  794. pOut->bit_mask |= H2250LCAPs_dRTPPTp_present;
  795. }
  796. return lError;
  797. } // setup_H2250ACK_mux
  798. /*****************************************************************************
  799. *
  800. * TYPE:
  801. *
  802. * PROCEDURE:
  803. *
  804. * DESCRIPTION:
  805. *
  806. * RETURN:
  807. *
  808. *****************************************************************************/
  809. HRESULT
  810. pdu_req_open_channel ( PDU_T * pPdu,
  811. WORD wTxChannel,
  812. DWORD dwTxPort,
  813. const H245_TOTCAP_T * pTxMode,
  814. const H245_MUX_T * pTxMux,
  815. const H245_TOTCAP_T * pRxMode,
  816. const H245_MUX_T * pRxMux,
  817. const H245_ACCESS_T * pSeparateStack)
  818. {
  819. RequestMessage *p_req = &pPdu->u.MltmdSystmCntrlMssg_rqst;
  820. struct OpenLogicalChannel *pPdu_olc = &p_req->u.openLogicalChannel;
  821. HRESULT lError;
  822. pPdu->choice = MltmdSystmCntrlMssg_rqst_chosen;
  823. p_req->choice = openLogicalChannel_chosen;
  824. ASSERT(pTxMode);
  825. ASSERT(pTxMux);
  826. /* Initialize bit masks to 0 */
  827. /* --> bit_mask no reverse parameters, no reverse mux table parameters */
  828. pPdu_olc->bit_mask = 0;
  829. /* no port number present */
  830. pPdu_olc->forwardLogicalChannelParameters.bit_mask = 0;
  831. /* no reverse mulitiplex parameters present */
  832. pPdu_olc->OLCl_rLCPs.bit_mask = 0;
  833. /************************************************************/
  834. /* SETUP THE CHANNEL INFORMATION (NOT MUX STUFF : SEE BELOW */
  835. /************************************************************/
  836. /*************************/
  837. /* FORWARD CHANNEL STUFF */
  838. /*************************/
  839. /* --> forwardLogicalChannelNumber */
  840. pPdu_olc->forwardLogicalChannelNumber = wTxChannel;
  841. /* --> forwardLogicalChannelParameters */
  842. /* -->forwardLogicalChannelParameters.bit_mask */
  843. /* -->forwardLogicalChannelParameters.fLCPs_prtNmbr*/
  844. /* -->forwardLogicalChannelParameters.dataType */
  845. /* if port present .. make it so.. (beam me up scotty) */
  846. if (dwTxPort != H245_INVALID_PORT_NUMBER)
  847. {
  848. pPdu_olc->forwardLogicalChannelParameters.bit_mask |= fLCPs_prtNmbr_present;
  849. pPdu_olc->forwardLogicalChannelParameters.fLCPs_prtNmbr = (WORD)dwTxPort;
  850. }
  851. /* select the data type */
  852. switch (pTxMode->DataType)
  853. {
  854. case H245_DATA_NONSTD:
  855. pPdu_olc->forwardLogicalChannelParameters.dataType.choice = DataType_nonStandard_chosen;
  856. break;
  857. case H245_DATA_NULL:
  858. pPdu_olc->forwardLogicalChannelParameters.dataType.choice = nullData_chosen;
  859. break;
  860. case H245_DATA_VIDEO:
  861. pPdu_olc->forwardLogicalChannelParameters.dataType.choice = DataType_videoData_chosen;
  862. break;
  863. case H245_DATA_AUDIO:
  864. pPdu_olc->forwardLogicalChannelParameters.dataType.choice = DataType_audioData_chosen;
  865. break;
  866. case H245_DATA_DATA:
  867. pPdu_olc->forwardLogicalChannelParameters.dataType.choice = DataType_data_chosen;
  868. break;
  869. case H245_DATA_ENCRYPT_D:
  870. pPdu_olc->forwardLogicalChannelParameters.dataType.choice = encryptionData_chosen;
  871. return H245_ERROR_NOTIMP; // TBD
  872. break;
  873. default:
  874. H245TRACE(0,1,"API:pdu_req_open_channel: invalid TX DataType %d", pTxMode->DataType);
  875. return H245_ERROR_PARAM;
  876. } /* switch */
  877. /* in the DataType.. load the capability */
  878. lError = load_cap((struct Capability *)&pPdu_olc->forwardLogicalChannelParameters.dataType, pTxMode);
  879. if (lError != H245_ERROR_OK)
  880. {
  881. return lError;
  882. }
  883. /********************************/
  884. /* FORWARD MUX H223 PARAM STUFF */
  885. /********************************/
  886. /* set forward parameters choices */
  887. /* -->forwardLogicalChannelParameters.multiplexParameters.choice */
  888. /* -->forwardLogicalChannelParameters.multiplexParameters.u.fLCPs_mPs_h222LCPs */
  889. switch (pTxMux->Kind)
  890. {
  891. case H245_H222:
  892. pPdu_olc->forwardLogicalChannelParameters.multiplexParameters.choice =
  893. fLCPs_mPs_h222LCPs_chosen;
  894. lError = setup_H222_mux(&pPdu_olc->forwardLogicalChannelParameters.multiplexParameters.u.fLCPs_mPs_h222LCPs,
  895. &pTxMux->u.H222);
  896. break;
  897. case H245_H223:
  898. pPdu_olc->forwardLogicalChannelParameters.multiplexParameters.choice =
  899. fLCPs_mPs_h223LCPs_chosen;
  900. lError = setup_H223_mux(&pPdu_olc->forwardLogicalChannelParameters.multiplexParameters.u.fLCPs_mPs_h223LCPs,
  901. &pTxMux->u.H223);
  902. break;
  903. case H245_VGMUX:
  904. pPdu_olc->forwardLogicalChannelParameters.multiplexParameters.choice =
  905. fLCPs_mPs_v76LCPs_chosen;
  906. lError = setup_VGMUX_mux(&pPdu_olc->forwardLogicalChannelParameters.multiplexParameters.u.fLCPs_mPs_v76LCPs,
  907. &pTxMux->u.VGMUX);
  908. break;
  909. case H245_H2250:
  910. pPdu_olc->forwardLogicalChannelParameters.multiplexParameters.choice =
  911. fLCPs_mPs_h2250LCPs_chosen;
  912. lError = setup_H2250_mux(&pPdu_olc->forwardLogicalChannelParameters.multiplexParameters.u.fLCPs_mPs_h2250LCPs,
  913. &pTxMux->u.H2250);
  914. // TBD - Add Network Access Parameters support
  915. break;
  916. default:
  917. H245TRACE(0,1,"API:pdu_req_open_channel: invalid TX Mux Kind %d", pTxMux->Kind);
  918. lError = H245_ERROR_PARAM;
  919. } /* switch */
  920. if (lError != H245_ERROR_OK)
  921. return lError;
  922. /*************************/
  923. /* REVERSE CHANNEL STUFF */
  924. /*************************/
  925. if (pRxMode)
  926. {
  927. /* --> bit_mask reverse parameters exist !!!! party..down garth.. */
  928. pPdu_olc->bit_mask |= OLCl_rLCPs_present;
  929. /* -->OLCl_rLCPs.dataType */
  930. /* select the data type */
  931. switch (pRxMode->DataType)
  932. {
  933. case H245_DATA_NONSTD:
  934. pPdu_olc->OLCl_rLCPs.dataType.choice = DataType_nonStandard_chosen;
  935. break;
  936. case H245_DATA_NULL:
  937. pPdu_olc->OLCl_rLCPs.dataType.choice = nullData_chosen;
  938. break;
  939. case H245_DATA_VIDEO:
  940. pPdu_olc->OLCl_rLCPs.dataType.choice = DataType_videoData_chosen;
  941. break;
  942. case H245_DATA_AUDIO:
  943. pPdu_olc->OLCl_rLCPs.dataType.choice = DataType_audioData_chosen;
  944. break;
  945. case H245_DATA_DATA:
  946. pPdu_olc->OLCl_rLCPs.dataType.choice = DataType_data_chosen;
  947. break;
  948. case H245_DATA_ENCRYPT_D:
  949. pPdu_olc->OLCl_rLCPs.dataType.choice = encryptionData_chosen;
  950. return H245_ERROR_NOTIMP; // TBD
  951. break;
  952. default:
  953. H245TRACE(0,1,"API:pdu_req_open_channel: invalid RX DataType %d", pRxMode->DataType);
  954. return H245_ERROR_PARAM;
  955. } /* switch */
  956. /* in the DataType.. load the capability */
  957. lError = load_cap((struct Capability *)&pPdu_olc->OLCl_rLCPs.dataType, pRxMode);
  958. if (lError != H245_ERROR_OK)
  959. {
  960. return lError;
  961. }
  962. /********************************/
  963. /* REVERSE MUX H223 PARAM STUFF */
  964. /********************************/
  965. if (pRxMux)
  966. {
  967. /* set reverse parameters choices */
  968. /* -->OLCl_rLCPs.dataType */
  969. /* -->OLCl_rLCPs.bit_mask */
  970. /* set them to be present.. and it was so */
  971. switch (pRxMux->Kind)
  972. {
  973. case H245_H223:
  974. pPdu_olc->OLCl_rLCPs.OLCl_rLCPs_mltplxPrmtrs.choice = rLCPs_mPs_h223LCPs_chosen;
  975. lError = setup_H223_mux (&pPdu_olc->OLCl_rLCPs.OLCl_rLCPs_mltplxPrmtrs.u.rLCPs_mPs_h223LCPs,
  976. &pRxMux->u.H223);
  977. break;
  978. case H245_VGMUX:
  979. pPdu_olc->OLCl_rLCPs.OLCl_rLCPs_mltplxPrmtrs.choice = rLCPs_mPs_v76LCPs_chosen;
  980. lError = setup_VGMUX_mux (&pPdu_olc->OLCl_rLCPs.OLCl_rLCPs_mltplxPrmtrs.u.rLCPs_mPs_v76LCPs,
  981. &pRxMux->u.VGMUX);
  982. break;
  983. case H245_H2250:
  984. pPdu_olc->OLCl_rLCPs.OLCl_rLCPs_mltplxPrmtrs.choice = rLCPs_mPs_h2250LCPs_chosen;
  985. lError = setup_H2250_mux (&pPdu_olc->OLCl_rLCPs.OLCl_rLCPs_mltplxPrmtrs.u.rLCPs_mPs_h2250LCPs,
  986. &pRxMux->u.H2250);
  987. break;
  988. default:
  989. H245TRACE(0,1,"API:pdu_req_open_channel: invalid RX Mux Kind %d", pRxMux->Kind);
  990. lError = H245_ERROR_PARAM;
  991. } /* switch */
  992. if (lError != H245_ERROR_OK)
  993. return lError;
  994. pPdu_olc->OLCl_rLCPs.bit_mask |= OLCl_rLCPs_mltplxPrmtrs_present; /* reverse multiplex parameters present */
  995. } /* if pRxMux */
  996. } /* if pRxMode */
  997. if (pSeparateStack)
  998. {
  999. pPdu_olc->bit_mask |= OpnLgclChnnl_sprtStck_present;
  1000. pPdu_olc->OpnLgclChnnl_sprtStck = *pSeparateStack;
  1001. }
  1002. return H245_ERROR_OK;
  1003. }
  1004. //
  1005. // Frees PDU and contents used for pdu_req_open_channel()
  1006. //
  1007. void free_pdu_req_open_channel
  1008. (
  1009. PDU_T * pPdu,
  1010. const H245_TOTCAP_T * pTxMode,
  1011. const H245_TOTCAP_T * pRxMode
  1012. )
  1013. {
  1014. RequestMessage * p_req = &pPdu->u.MltmdSystmCntrlMssg_rqst;
  1015. struct OpenLogicalChannel * pPdu_olc = &p_req->u.openLogicalChannel;
  1016. if (pRxMode)
  1017. {
  1018. free_cap((struct Capability *)&pPdu_olc->OLCl_rLCPs.dataType, pRxMode);
  1019. }
  1020. free_cap((struct Capability *)&pPdu_olc->forwardLogicalChannelParameters.dataType, pTxMode);
  1021. // Free PDU pointer
  1022. MemFree(pPdu);
  1023. }
  1024. /*****************************************************************************
  1025. *
  1026. * TYPE:
  1027. *
  1028. * PROCEDURE:
  1029. *
  1030. * DESCRIPTION
  1031. *
  1032. * RETURN:
  1033. *
  1034. *****************************************************************************/
  1035. HRESULT
  1036. pdu_rsp_open_logical_channel_ack ( PDU_T * pPdu,
  1037. WORD wRxChannel,
  1038. const H245_MUX_T * pRxMux,
  1039. WORD wTxChannel,
  1040. const H245_MUX_T * pTxMux, // for H.222/H.225.0 only
  1041. DWORD dwTxPort,
  1042. const H245_ACCESS_T * pSeparateStack)
  1043. {
  1044. OpenLogicalChannelAck *pAck = &pPdu->u.MSCMg_rspns.u.openLogicalChannelAck;
  1045. HRESULT lError;
  1046. pPdu->choice = MSCMg_rspns_chosen;
  1047. pPdu->u.MSCMg_rspns.choice = openLogicalChannelAck_chosen;
  1048. pAck->bit_mask = 0; // Initialize bit mask
  1049. pAck->forwardLogicalChannelNumber = wRxChannel;
  1050. if (wTxChannel != 0)
  1051. {
  1052. pAck->bit_mask |= OLCAk_rLCPs_present;
  1053. pAck->OLCAk_rLCPs.bit_mask = 0; // Initialize bit mask
  1054. pAck->OLCAk_rLCPs.reverseLogicalChannelNumber = wTxChannel;
  1055. if (dwTxPort != H245_INVALID_PORT_NUMBER)
  1056. {
  1057. pAck->OLCAk_rLCPs.bit_mask |= rLCPs_prtNmbr_present;
  1058. pAck->OLCAk_rLCPs.rLCPs_prtNmbr = (WORD)dwTxPort;
  1059. }
  1060. if (pTxMux)
  1061. {
  1062. pAck->OLCAk_rLCPs.bit_mask |= OLCAk_rLCPs_mPs_present;
  1063. lError = H245_ERROR_PARAM;
  1064. switch (pTxMux->Kind)
  1065. {
  1066. case H245_H222:
  1067. pAck->OLCAk_rLCPs.OLCAk_rLCPs_mPs.choice = rLCPs_mPs_h222LCPs_chosen;
  1068. lError = setup_H222_mux(&pAck->OLCAk_rLCPs.OLCAk_rLCPs_mPs.u.rLCPs_mPs_h222LCPs,
  1069. &pTxMux->u.H222);
  1070. break;
  1071. case H245_H2250:
  1072. pAck->OLCAk_rLCPs.OLCAk_rLCPs_mPs.choice = mPs_h2250LgclChnnlPrmtrs_chosen;
  1073. lError = setup_H2250_mux(&pAck->OLCAk_rLCPs.OLCAk_rLCPs_mPs.u.mPs_h2250LgclChnnlPrmtrs,
  1074. &pTxMux->u.H2250);
  1075. break;
  1076. } // switch
  1077. if (lError != H245_ERROR_OK)
  1078. return lError;
  1079. } // if
  1080. } // if
  1081. if (pSeparateStack)
  1082. {
  1083. pAck->bit_mask |= OLCAk_sprtStck_present;
  1084. pAck->OLCAk_sprtStck = *pSeparateStack;
  1085. }
  1086. if (pRxMux)
  1087. {
  1088. pAck->bit_mask |= frwrdMltplxAckPrmtrs_present;
  1089. lError = H245_ERROR_PARAM;
  1090. switch (pRxMux->Kind)
  1091. {
  1092. case H245_H2250ACK:
  1093. pAck->frwrdMltplxAckPrmtrs.choice = h2250LgclChnnlAckPrmtrs_chosen;
  1094. lError = setup_H2250ACK_mux(&pAck->frwrdMltplxAckPrmtrs.u.h2250LgclChnnlAckPrmtrs,
  1095. &pRxMux->u.H2250ACK);
  1096. break;
  1097. } // switch
  1098. if (lError != H245_ERROR_PARAM)
  1099. return lError;
  1100. }
  1101. return H245_ERROR_OK;
  1102. }
  1103. /*****************************************************************************
  1104. *
  1105. * TYPE:
  1106. *
  1107. * PROCEDURE:
  1108. *
  1109. * DESCRIPTION
  1110. *
  1111. * RETURN:
  1112. *
  1113. *****************************************************************************/
  1114. HRESULT
  1115. pdu_rsp_open_logical_channel_rej ( PDU_T * pPdu,
  1116. WORD wRxChannel,
  1117. WORD wCause)
  1118. {
  1119. pPdu->choice = MSCMg_rspns_chosen;
  1120. pPdu->u.MSCMg_rspns.choice = openLogicalChannelReject_chosen;
  1121. pPdu->u.MSCMg_rspns.u.openLogicalChannelReject.forwardLogicalChannelNumber = wRxChannel;
  1122. pPdu->u.MSCMg_rspns.u.openLogicalChannelReject.cause.choice = wCause;
  1123. return H245_ERROR_OK;
  1124. }
  1125. /*****************************************************************************
  1126. *
  1127. * TYPE:
  1128. *
  1129. * PROCEDURE:
  1130. *
  1131. * DESCRIPTION
  1132. *
  1133. * RETURN:
  1134. *
  1135. *****************************************************************************/
  1136. HRESULT
  1137. pdu_ind_open_logical_channel_conf ( PDU_T *pPdu,
  1138. WORD wChannel)
  1139. {
  1140. IndicationMessage *p_ind = &pPdu->u.indication;
  1141. OpenLogicalChannelConfirm *pPdu_olcc = &(p_ind->u.opnLgclChnnlCnfrm);
  1142. p_ind->choice = opnLgclChnnlCnfrm_chosen;
  1143. pPdu->choice = indication_chosen;
  1144. pPdu_olcc->forwardLogicalChannelNumber = wChannel;
  1145. return H245_ERROR_OK;
  1146. }
  1147. /*****************************************************************************
  1148. *
  1149. * TYPE:
  1150. *
  1151. * PROCEDURE:
  1152. *
  1153. * DESCRIPTION
  1154. *
  1155. * RETURN:
  1156. *
  1157. *****************************************************************************/
  1158. HRESULT
  1159. pdu_req_request_close_channel(PDU_T *pPdu,
  1160. WORD wChannel)
  1161. {
  1162. RequestMessage *p_req = &pPdu->u.MltmdSystmCntrlMssg_rqst;
  1163. RequestChannelClose *pPdu_rcc = &(p_req->u.requestChannelClose);
  1164. pPdu->choice = MltmdSystmCntrlMssg_rqst_chosen;
  1165. p_req->choice = requestChannelClose_chosen;
  1166. pPdu_rcc->forwardLogicalChannelNumber = wChannel;
  1167. return H245_ERROR_OK;
  1168. }
  1169. /*****************************************************************************
  1170. *
  1171. * TYPE:
  1172. *
  1173. * PROCEDURE:
  1174. *
  1175. * DESCRIPTION
  1176. *
  1177. * RETURN:
  1178. *
  1179. *****************************************************************************/
  1180. HRESULT
  1181. pdu_req_close_logical_channel (PDU_T *pPdu,
  1182. WORD wChannel,
  1183. DWORD user_lcse) /* 0=user */
  1184. /* 1=lcse */
  1185. {
  1186. RequestMessage *p_req = &pPdu->u.MltmdSystmCntrlMssg_rqst;
  1187. CloseLogicalChannel *pPdu_cc = &(p_req->u.closeLogicalChannel);
  1188. p_req->choice = closeLogicalChannel_chosen;
  1189. pPdu_cc->bit_mask = CloseLogicalChannel_reason_present;
  1190. pPdu_cc->reason.choice = CloseLogicalChannel_reason_reopen_chosen;
  1191. pPdu->choice = MltmdSystmCntrlMssg_rqst_chosen;
  1192. pPdu_cc->forwardLogicalChannelNumber = wChannel;
  1193. if (user_lcse)
  1194. pPdu_cc->source.choice = lcse_chosen;
  1195. else
  1196. pPdu_cc->source.choice = user_chosen;
  1197. return H245_ERROR_OK;
  1198. }
  1199. /*****************************************************************************
  1200. *
  1201. * TYPE:
  1202. *
  1203. * PROCEDURE:
  1204. *
  1205. * DESCRIPTION
  1206. *
  1207. * RETURN:
  1208. *
  1209. *****************************************************************************/
  1210. HRESULT
  1211. pdu_rsp_close_logical_channel_ack ( PDU_T *pPdu,
  1212. WORD wChannel)
  1213. {
  1214. ResponseMessage *p_rsp = &pPdu->u.MSCMg_rspns;
  1215. CloseLogicalChannelAck *pPdu_clca = &(p_rsp->u.closeLogicalChannelAck);
  1216. p_rsp->choice = closeLogicalChannelAck_chosen;
  1217. pPdu->choice = MSCMg_rspns_chosen;
  1218. pPdu_clca->forwardLogicalChannelNumber = wChannel;
  1219. return H245_ERROR_OK;
  1220. }
  1221. /*****************************************************************************
  1222. *
  1223. * TYPE:
  1224. *
  1225. * PROCEDURE:
  1226. *
  1227. * DESCRIPTION
  1228. *
  1229. * RETURN:
  1230. *
  1231. *****************************************************************************/
  1232. HRESULT
  1233. pdu_rsp_request_channel_close_ack ( PDU_T *pPdu,
  1234. WORD wChannel)
  1235. {
  1236. ResponseMessage *p_rsp = &pPdu->u.MSCMg_rspns;
  1237. RequestChannelCloseAck *pPdu_rcca = &(p_rsp->u.requestChannelCloseAck);
  1238. p_rsp->choice = requestChannelCloseAck_chosen;
  1239. pPdu->choice = MSCMg_rspns_chosen;
  1240. pPdu_rcca->forwardLogicalChannelNumber = wChannel;
  1241. return H245_ERROR_OK;
  1242. }
  1243. /*****************************************************************************
  1244. *
  1245. * TYPE:
  1246. *
  1247. * PROCEDURE:
  1248. *
  1249. * DESCRIPTION
  1250. *
  1251. * RETURN:
  1252. *
  1253. *****************************************************************************/
  1254. HRESULT
  1255. pdu_rsp_request_channel_close_rej ( PDU_T *pPdu,
  1256. WORD wChannel,
  1257. H245_ACC_REJ_T acc_rej)
  1258. {
  1259. ResponseMessage *p_rsp = &pPdu->u.MSCMg_rspns;
  1260. RequestChannelCloseReject *pPdu_rccr = &(p_rsp->u.rqstChnnlClsRjct);
  1261. p_rsp->choice = rqstChnnlClsRjct_chosen;
  1262. pPdu->choice = MSCMg_rspns_chosen;
  1263. pPdu_rccr->forwardLogicalChannelNumber = wChannel;
  1264. pPdu_rccr->cause.choice = (WORD)acc_rej;
  1265. return H245_ERROR_OK;
  1266. }
  1267. /*****************************************************************************
  1268. *
  1269. * TYPE:
  1270. *
  1271. * PROCEDURE:
  1272. *
  1273. * DESCRIPTION
  1274. *
  1275. * RETURN:
  1276. *
  1277. *****************************************************************************/
  1278. HRESULT
  1279. pdu_req_mstslv ( PDU_T * pPdu,
  1280. BYTE byTerminalType,
  1281. unsigned int number)
  1282. {
  1283. RequestMessage *p_req = &pPdu->u.MltmdSystmCntrlMssg_rqst;
  1284. MasterSlaveDetermination *pPdu_msd = &(p_req->u.masterSlaveDetermination);
  1285. p_req->choice = masterSlaveDetermination_chosen;
  1286. pPdu->choice = MltmdSystmCntrlMssg_rqst_chosen;
  1287. pPdu_msd->terminalType = byTerminalType;
  1288. pPdu_msd->statusDeterminationNumber = number;
  1289. return H245_ERROR_OK;
  1290. }
  1291. /*****************************************************************************
  1292. *
  1293. * TYPE:
  1294. *
  1295. * PROCEDURE:
  1296. *
  1297. * DESCRIPTION
  1298. *
  1299. * RETURN:
  1300. *
  1301. *****************************************************************************/
  1302. HRESULT
  1303. pdu_rsp_mstslv_rej (PDU_T *pPdu)
  1304. {
  1305. ResponseMessage *p_rsp = &pPdu->u.MSCMg_rspns;
  1306. MasterSlaveDeterminationReject *pPdu_msdr = &(p_rsp->u.mstrSlvDtrmntnRjct);
  1307. p_rsp->choice = mstrSlvDtrmntnRjct_chosen;
  1308. pPdu->choice = MSCMg_rspns_chosen;
  1309. pPdu_msdr->cause.choice = identicalNumbers_chosen;
  1310. return H245_ERROR_OK;
  1311. }
  1312. /*****************************************************************************
  1313. *
  1314. * TYPE:
  1315. *
  1316. * PROCEDURE:
  1317. *
  1318. * DESCRIPTION
  1319. *
  1320. * RETURN:
  1321. *
  1322. *****************************************************************************/
  1323. HRESULT
  1324. pdu_rsp_mstslv_ack ( PDU_T * pPdu,
  1325. unsigned short mst_slv)
  1326. {
  1327. pPdu->choice = MSCMg_rspns_chosen;
  1328. pPdu->u.MSCMg_rspns.choice = mstrSlvDtrmntnAck_chosen;
  1329. pPdu->u.MSCMg_rspns.u.mstrSlvDtrmntnAck.decision.choice = mst_slv;
  1330. return H245_ERROR_OK;
  1331. }
  1332. /*****************************************************************************
  1333. *
  1334. * TYPE:
  1335. *
  1336. * PROCEDURE:
  1337. *
  1338. * DESCRIPTION
  1339. *
  1340. * RETURN:
  1341. *
  1342. *****************************************************************************/
  1343. HRESULT
  1344. pdu_req_termcap_set (PDU_T *pPdu,
  1345. WORD wSequenceNumber)
  1346. {
  1347. RequestMessage *p_req = &pPdu->u.MltmdSystmCntrlMssg_rqst;
  1348. TerminalCapabilitySet *pPdu_tcs = &(p_req->u.terminalCapabilitySet);
  1349. p_req->choice = terminalCapabilitySet_chosen;
  1350. pPdu->choice = MltmdSystmCntrlMssg_rqst_chosen;
  1351. pPdu_tcs->sequenceNumber = (SequenceNumber)wSequenceNumber;
  1352. return H245_ERROR_OK;
  1353. }
  1354. /*****************************************************************************
  1355. *
  1356. * TYPE:
  1357. *
  1358. * PROCEDURE:
  1359. *
  1360. * DESCRIPTION
  1361. *
  1362. * RETURN:
  1363. *
  1364. *****************************************************************************/
  1365. HRESULT
  1366. pdu_rsp_termcap_set_ack(PDU_T *pPdu,
  1367. WORD wSequenceNumber)
  1368. {
  1369. ResponseMessage *p_rsp = &pPdu->u.MSCMg_rspns;
  1370. TerminalCapabilitySetAck *pPdu_tcsa = &(p_rsp->u.terminalCapabilitySetAck);
  1371. p_rsp->choice = terminalCapabilitySetAck_chosen;
  1372. pPdu->choice = MSCMg_rspns_chosen;
  1373. pPdu_tcsa->sequenceNumber = (SequenceNumber)wSequenceNumber;
  1374. return H245_ERROR_OK;
  1375. }
  1376. /*****************************************************************************
  1377. *
  1378. * TYPE:
  1379. *
  1380. * PROCEDURE:
  1381. *
  1382. * DESCRIPTION
  1383. *
  1384. * RETURN:
  1385. *
  1386. *****************************************************************************/
  1387. HRESULT
  1388. pdu_rsp_termcap_set_rej(PDU_T *pPdu,
  1389. WORD wSequenceNumber,
  1390. H245_ACC_REJ_T reason,
  1391. WORD highest_processed)
  1392. {
  1393. ResponseMessage *p_rsp = &pPdu->u.MSCMg_rspns;
  1394. TerminalCapabilitySetReject *pPdu_tcsr = &(p_rsp->u.trmnlCpbltyStRjct);
  1395. p_rsp->choice = trmnlCpbltyStRjct_chosen;
  1396. pPdu->choice = MSCMg_rspns_chosen;
  1397. pPdu_tcsr->sequenceNumber = (SequenceNumber)wSequenceNumber;
  1398. switch (reason)
  1399. {
  1400. case H245_REJ_UNDEF_TBL_ENTRY:
  1401. pPdu_tcsr->cause.choice = undefinedTableEntryUsed_chosen;
  1402. break;
  1403. case H245_REJ_DIS_CAP_EXCEED:
  1404. pPdu_tcsr->cause.choice = dscrptrCpctyExcdd_chosen;
  1405. break;
  1406. case H245_REJ_TBLENTRY_CAP_EXCEED:
  1407. pPdu_tcsr->cause.choice = tblEntryCpctyExcdd_chosen;
  1408. if (!highest_processed)
  1409. pPdu_tcsr->cause.u.tblEntryCpctyExcdd.choice = noneProcessed_chosen;
  1410. else
  1411. {
  1412. pPdu_tcsr->cause.u.tblEntryCpctyExcdd.choice = hghstEntryNmbrPrcssd_chosen;
  1413. pPdu_tcsr->cause.u.tblEntryCpctyExcdd.u.hghstEntryNmbrPrcssd = highest_processed;
  1414. }
  1415. break;
  1416. case H245_REJ:
  1417. default:
  1418. pPdu_tcsr->cause.choice = TCSRt_cs_unspcfd_chosen;
  1419. break;
  1420. }
  1421. return H245_ERROR_OK;
  1422. }
  1423. /*****************************************************************************
  1424. *
  1425. * TYPE:
  1426. *
  1427. * PROCEDURE:
  1428. *
  1429. * DESCRIPTION
  1430. *
  1431. * RETURN:
  1432. *
  1433. *****************************************************************************/
  1434. HRESULT
  1435. pdu_ind_misc (PDU_T *pPdu)
  1436. {
  1437. IndicationMessage *p_ind = &pPdu->u.indication;
  1438. MiscellaneousIndication *p_pdu_misc = &(p_ind->u.miscellaneousIndication);
  1439. p_ind->choice = miscellaneousIndication_chosen;
  1440. pPdu->choice = indication_chosen;
  1441. /* (TBC) */
  1442. return H245_ERROR_NOTIMP;
  1443. }
  1444. /*****************************************************************************
  1445. *
  1446. * TYPE: LOCAL
  1447. *
  1448. * PROCEDURE: build_mux_entry_element - recursivly build mux element list
  1449. *
  1450. * DESCRIPTION
  1451. *
  1452. * RETURN:
  1453. *
  1454. *****************************************************************************/
  1455. HRESULT
  1456. build_mux_entry_element(struct InstanceStruct *pInstance,
  1457. H245_MUX_ENTRY_ELEMENT_T *p_mux_el,
  1458. MultiplexElement *p_ASN_mux_el,
  1459. DWORD element_depth)
  1460. {
  1461. HRESULT lError;
  1462. DWORD max_element_depth = 0;
  1463. DWORD max_element_width = 0;
  1464. /* check for h223 MAX depth of recursion */
  1465. if (pInstance->Configuration == H245_CONF_H324)
  1466. {
  1467. /* if h223 in basic mode */
  1468. if (pInstance->API.PDU_LocalTermCap.
  1469. u.MltmdSystmCntrlMssg_rqst.
  1470. u.terminalCapabilitySet.multiplexCapability.
  1471. u.h223Capability.
  1472. h223MultiplexTableCapability.choice == h223MltplxTblCpblty_bsc_chosen)
  1473. {
  1474. max_element_depth = 1;
  1475. max_element_width = 2;
  1476. }
  1477. else
  1478. if (pInstance->API.PDU_LocalTermCap.
  1479. u.MltmdSystmCntrlMssg_rqst.
  1480. u.terminalCapabilitySet.multiplexCapability.
  1481. u.h223Capability.
  1482. h223MultiplexTableCapability.choice == h223MTCy_enhncd_chosen)
  1483. {
  1484. max_element_depth =
  1485. pInstance->API.PDU_LocalTermCap.
  1486. u.MltmdSystmCntrlMssg_rqst.
  1487. u.terminalCapabilitySet.multiplexCapability.
  1488. u.h223Capability.
  1489. h223MultiplexTableCapability.u.h223MTCy_enhncd.maximumNestingDepth;
  1490. max_element_width =
  1491. pInstance->API.PDU_LocalTermCap.
  1492. u.MltmdSystmCntrlMssg_rqst.
  1493. u.terminalCapabilitySet.multiplexCapability.
  1494. u.h223Capability.
  1495. h223MultiplexTableCapability.u.h223MTCy_enhncd.maximumElementListSize;
  1496. }
  1497. }
  1498. /* nested too deap */
  1499. if (max_element_depth)
  1500. if (element_depth > max_element_depth)
  1501. {
  1502. H245TRACE(pInstance->dwInst,1,"API:build_mux_entry_element: << ERROR >> Maximum Depth %d",element_depth );
  1503. return (H245_ERROR_MUXELEMENT_DEPTH);
  1504. }
  1505. ASSERT (p_mux_el);
  1506. /* if logical channel number (termination of tree branch) */
  1507. if (p_mux_el->Kind == H245_MUX_LOGICAL_CHANNEL)
  1508. {
  1509. p_ASN_mux_el->type.choice = typ_logicalChannelNumber_chosen;
  1510. /* invalid channel number .. 0 is command channel */
  1511. // 3/7/96 - cjutzi removed.. looks like they use it in the examples
  1512. //
  1513. //if (p_mux_el->u.wChannel == 0)
  1514. // {
  1515. // H245TRACE(Inst,1,"API:build_mux_entry_element: << ERROR >> Channel 0 not allowed if format");
  1516. // return H245_ERROR_INVALID_DATA_FORMAT;
  1517. // }
  1518. p_ASN_mux_el->type.u.typ_logicalChannelNumber = (WORD)p_mux_el->u.Channel;
  1519. }
  1520. /* else it is a sub element list again.. */
  1521. else
  1522. {
  1523. MultiplexElementLink p_ASN_mux_link;
  1524. H245_MUX_ENTRY_ELEMENT_T *p_mux_el_look;
  1525. /* allocate a new sub element list structure */
  1526. p_ASN_mux_link = (MultiplexElementLink)MemAlloc(sizeof(*p_ASN_mux_link));
  1527. if (p_ASN_mux_link == NULL)
  1528. {
  1529. return H245_ERROR_NOMEM;
  1530. }
  1531. /* zero memory out */
  1532. memset (p_ASN_mux_link, 0, sizeof (*p_ASN_mux_link));
  1533. /* for every entry entry present.. */
  1534. for (p_ASN_mux_link->count = 0, p_mux_el_look = p_mux_el->u.pMuxTblEntryElem;
  1535. p_mux_el_look;
  1536. p_mux_el_look = p_mux_el_look->pNext, p_ASN_mux_link->count++)
  1537. {
  1538. /* check.. for api mistakes.. ie.. pointer is really a channel # */
  1539. if ((DWORD_PTR)p_mux_el_look < (DWORD)128)
  1540. {
  1541. H245TRACE(pInstance->dwInst,1,"API:build_mux_entry_element: << WARNING >> Possible H245_MUX_LOGICAL_CHANNEL labeled as pointer.. <<CRASH>>");
  1542. }
  1543. if ((lError = build_mux_entry_element (pInstance,
  1544. p_mux_el_look,
  1545. &(p_ASN_mux_link->value[p_ASN_mux_link->count]),
  1546. element_depth+1)) != H245_ERROR_OK)
  1547. {
  1548. MemFree (p_ASN_mux_link);
  1549. return lError;
  1550. }
  1551. } /* for */
  1552. /* must have at least 2 subelements in the list.. if not */
  1553. /* there is an error in the construct. */
  1554. if (p_ASN_mux_link->count < 2)
  1555. {
  1556. H245TRACE(pInstance->dwInst,1,"API:build_mux_entry_element: << ERROR >> Element List < 2");
  1557. MemFree (p_ASN_mux_link);
  1558. return H245_ERROR_INVALID_DATA_FORMAT;
  1559. }
  1560. /* width too wide for MuxLayer*/
  1561. if (max_element_width)
  1562. if (p_ASN_mux_link->count > max_element_width)
  1563. {
  1564. H245TRACE(pInstance->dwInst,1,"API:build_mux_entry_element: << ERROR >> Maximum Width %d",(p_ASN_mux_link->count));
  1565. MemFree (p_ASN_mux_link);
  1566. return H245_ERROR_MUXELEMENT_WIDTH;
  1567. }
  1568. /* assign to the ASN1 struct for this element */
  1569. p_ASN_mux_el->type.u.subElementList = p_ASN_mux_link;
  1570. p_ASN_mux_el->type.choice = subElementList_chosen;
  1571. }
  1572. /* ok.. deal w/ ASN1 repeat count */
  1573. if (!p_mux_el->RepeatCount)
  1574. p_ASN_mux_el->repeatCount.choice = untilClosingFlag_chosen;
  1575. else
  1576. {
  1577. p_ASN_mux_el->repeatCount.choice = repeatCount_finite_chosen;
  1578. p_ASN_mux_el->repeatCount.u.repeatCount_finite = (WORD)p_mux_el->RepeatCount;
  1579. }
  1580. return H245_ERROR_OK;
  1581. }
  1582. /*****************************************************************************
  1583. *
  1584. * TYPE:
  1585. *
  1586. * PROCEDURE:
  1587. *
  1588. * DESCRIPTION
  1589. *
  1590. * RETURN:
  1591. *
  1592. *****************************************************************************/
  1593. HRESULT
  1594. pdu_req_send_mux_table ( struct InstanceStruct * pInstance,
  1595. PDU_T * pPdu,
  1596. H245_MUX_TABLE_T * p_mux_table,
  1597. WORD wSequenceNumber,
  1598. DWORD * p_mux_count)
  1599. {
  1600. RequestMessage *p_req = &pPdu->u.MltmdSystmCntrlMssg_rqst;
  1601. MultiplexEntrySend *pPdu_mes = &(p_req->u.multiplexEntrySend);
  1602. MultiplexEntryDescriptorLink p_ASN_med_link = NULL;
  1603. MultiplexEntryDescriptorLink p_ASN_med_link_lst = NULL;
  1604. //H245_MUX_ENTRY_DESC_T *p_mux_desc;
  1605. /* setup pdu choices */
  1606. pPdu->choice = MltmdSystmCntrlMssg_rqst_chosen;
  1607. p_req->choice = multiplexEntrySend_chosen;
  1608. pPdu_mes->sequenceNumber = (SequenceNumber)wSequenceNumber;
  1609. pPdu_mes->multiplexEntryDescriptors = NULL;
  1610. /* must have mux table structure */
  1611. if (!p_mux_table)
  1612. return H245_ERROR_PARAM;
  1613. /* for each descriptor in the table.. */
  1614. /* make sure there are only max of 15 */
  1615. /* and that the numbers range 1-15 */
  1616. for (*p_mux_count = 0;
  1617. p_mux_table && (*p_mux_count < 16);
  1618. p_mux_table = p_mux_table->pNext,*p_mux_count = (*p_mux_count)+1)
  1619. {
  1620. /* allocate a new multiplex Entry Descriptor */
  1621. p_ASN_med_link = (MultiplexEntryDescriptorLink)MemAlloc(sizeof(*p_ASN_med_link));
  1622. if (p_ASN_med_link == NULL)
  1623. {
  1624. free_mux_desc_list(pPdu_mes->multiplexEntryDescriptors);
  1625. return H245_ERROR_NOMEM;
  1626. }
  1627. /* zero out the structure */
  1628. memset (p_ASN_med_link, 0, sizeof(*p_ASN_med_link));
  1629. /* first multiplex entry descriptor ie. time through */
  1630. /* assign to "->multiplexEntryDescriptors" */
  1631. if (!pPdu_mes->multiplexEntryDescriptors)
  1632. pPdu_mes->multiplexEntryDescriptors = p_ASN_med_link;
  1633. /* every other time.. link it in.. */
  1634. else
  1635. {
  1636. ASSERT (p_ASN_med_link_lst);
  1637. p_ASN_med_link_lst->next = p_ASN_med_link;
  1638. }
  1639. /* setup for next time thorugh */
  1640. p_ASN_med_link_lst = p_ASN_med_link;
  1641. /* set the entry number */
  1642. if ((p_mux_table->MuxEntryId > 15) ||
  1643. (p_mux_table->MuxEntryId < 1))
  1644. {
  1645. free_mux_desc_list(pPdu_mes->multiplexEntryDescriptors);
  1646. /* MemFree (p_ASN_med_link); -- will be freed in call abouve since it is already linked in */
  1647. return H245_ERROR_PARAM;
  1648. }
  1649. p_ASN_med_link->value.multiplexTableEntryNumber = (MultiplexTableEntryNumber)p_mux_table->MuxEntryId;
  1650. /* if entry is present */
  1651. if (p_mux_table->pMuxTblEntryElem)
  1652. {
  1653. H245_MUX_ENTRY_ELEMENT_T *p_mux_el;
  1654. DWORD error;
  1655. /* setup so ASN knows entry is present */
  1656. p_ASN_med_link->value.bit_mask = elementList_present;
  1657. /* for every entry entry present.. */
  1658. for (p_ASN_med_link->value.elementList.count = 0, p_mux_el = p_mux_table->pMuxTblEntryElem;
  1659. p_mux_el;
  1660. p_mux_el = p_mux_el->pNext, p_ASN_med_link->value.elementList.count++)
  1661. {
  1662. if ((error =
  1663. build_mux_entry_element (pInstance, p_mux_el,
  1664. &(p_ASN_med_link->value.elementList.value[p_ASN_med_link->value.elementList.count]),0)) != H245_ERROR_OK)
  1665. {
  1666. free_mux_desc_list(pPdu_mes->multiplexEntryDescriptors);
  1667. return error;
  1668. }
  1669. } /* for */
  1670. } /* if */
  1671. /* else.. not present */
  1672. else
  1673. p_ASN_med_link->value.bit_mask = 0;
  1674. } /* for */
  1675. /* you've got too many mux entries.. no more than 16 .. remember.. */
  1676. if (*p_mux_count >= 16)
  1677. {
  1678. free_mux_desc_list(pPdu_mes->multiplexEntryDescriptors);
  1679. return H245_ERROR_INVALID_MUXTBLENTRY;
  1680. }
  1681. return H245_ERROR_OK;
  1682. }
  1683. /*****************************************************************************
  1684. *
  1685. * TYPE:
  1686. *
  1687. * PROCEDURE: pdu_rsp_mux_table_ack -
  1688. *
  1689. * DESCRIPTION
  1690. *
  1691. * ASSUMES:
  1692. *
  1693. * - Assume all mux id's are valid.
  1694. *
  1695. * RETURN:
  1696. * - H245_ERROR_OK if there are acks to send
  1697. * - H245_CANCELED if you shouldn't send the pdu.. (nothing to do)
  1698. *
  1699. *****************************************************************************/
  1700. HRESULT
  1701. pdu_rsp_mux_table_ack ( PDU_T *pPdu,
  1702. WORD wSequenceNumber,
  1703. H245_ACC_REJ_MUX_T acc_rej_mux,
  1704. DWORD count)
  1705. {
  1706. DWORD ii;
  1707. WORD num_ack = 0;
  1708. ResponseMessage *p_rsp = &(pPdu->u.MSCMg_rspns);
  1709. MultiplexEntrySendAck *p_mux_ack = &(p_rsp->u.multiplexEntrySendAck);
  1710. pPdu->choice = MSCMg_rspns_chosen;
  1711. p_rsp->choice = multiplexEntrySendAck_chosen;
  1712. p_mux_ack->sequenceNumber = (SequenceNumber)wSequenceNumber;
  1713. for (ii = 0; ii < count; ii++)
  1714. {
  1715. if (acc_rej_mux[ii].AccRej == H245_ACC)
  1716. {
  1717. p_mux_ack->multiplexTableEntryNumber.value[num_ack] =
  1718. (MultiplexTableEntryNumber)acc_rej_mux[ii].MuxEntryId;
  1719. num_ack++;
  1720. }
  1721. }
  1722. p_mux_ack->multiplexTableEntryNumber.count = num_ack;
  1723. if (num_ack)
  1724. return H245_ERROR_OK;
  1725. else
  1726. return H245_ERROR_CANCELED;
  1727. }
  1728. /*****************************************************************************
  1729. *
  1730. * TYPE:
  1731. *
  1732. * PROCEDURE: pdu_rsp_mux_table_rej -
  1733. *
  1734. * DESCRIPTION
  1735. *
  1736. * ASSUMES:
  1737. *
  1738. * - Assume all mux id's are valid.
  1739. *
  1740. * RETURN:
  1741. * - H245_ERROR_OK if there are rej to send
  1742. * - H245_CANCELED if you shouldn't send the pdu.. (nothing to do)
  1743. *
  1744. *****************************************************************************/
  1745. HRESULT
  1746. pdu_rsp_mux_table_rej ( PDU_T *pPdu,
  1747. WORD wSequenceNumber,
  1748. H245_ACC_REJ_MUX_T acc_rej_mux,
  1749. DWORD count)
  1750. {
  1751. DWORD ii;
  1752. WORD num_rej = 0;
  1753. ResponseMessage *p_rsp = &(pPdu->u.MSCMg_rspns);
  1754. MultiplexEntrySendReject *p_mux_rej = &(p_rsp->u.multiplexEntrySendReject);
  1755. pPdu->choice = MSCMg_rspns_chosen;
  1756. p_rsp->choice = multiplexEntrySendReject_chosen;
  1757. p_mux_rej->sequenceNumber = (SequenceNumber)wSequenceNumber;
  1758. for (ii = 0; ii < count; ii++)
  1759. {
  1760. if (acc_rej_mux[ii].AccRej != H245_ACC)
  1761. {
  1762. p_mux_rej->rejectionDescriptions.value[num_rej].multiplexTableEntryNumber =
  1763. (MultiplexTableEntryNumber)acc_rej_mux[ii].MuxEntryId;
  1764. switch (acc_rej_mux[ii].AccRej)
  1765. {
  1766. case H245_REJ_MUX_COMPLICATED:
  1767. p_mux_rej->rejectionDescriptions.value[num_rej].cause.choice =
  1768. descriptorTooComplex_chosen;
  1769. break;
  1770. case H245_REJ:
  1771. default:
  1772. p_mux_rej->rejectionDescriptions.value[num_rej].cause.choice =
  1773. MERDs_cs_unspcfdCs_chosen;
  1774. break;
  1775. }
  1776. num_rej++;
  1777. }
  1778. }
  1779. p_mux_rej->rejectionDescriptions.count = num_rej;
  1780. if (num_rej)
  1781. return H245_ERROR_OK;
  1782. else
  1783. return H245_ERROR_CANCELED;
  1784. }
  1785. /*****************************************************************************
  1786. *
  1787. * TYPE:
  1788. *
  1789. * PROCEDURE: pdu_cmd_end_session
  1790. *
  1791. * DESCRIPTION
  1792. *
  1793. * ASSUMES:
  1794. *
  1795. * RETURN:
  1796. *
  1797. *****************************************************************************/
  1798. HRESULT
  1799. pdu_cmd_end_session(PDU_T * pPdu,
  1800. H245_ENDSESSION_T mode,
  1801. const H245_NONSTANDARD_PARAMETER_T *p_nonstd)
  1802. {
  1803. CommandMessage *p_cmd = &pPdu->u.MSCMg_cmmnd;
  1804. EndSessionCommand *p_pdu_endsess = &(p_cmd->u.endSessionCommand);
  1805. p_cmd->choice = endSessionCommand_chosen;
  1806. pPdu->choice = MSCMg_cmmnd_chosen;
  1807. switch (mode)
  1808. {
  1809. case H245_ENDSESSION_DISCONNECT:
  1810. p_pdu_endsess->choice = disconnect_chosen;
  1811. break;
  1812. case H245_ENDSESSION_NONSTD:
  1813. p_pdu_endsess->choice = EndSssnCmmnd_nonStandard_chosen;
  1814. ASSERT(p_nonstd);
  1815. p_pdu_endsess->u.EndSssnCmmnd_nonStandard = *p_nonstd;
  1816. break;
  1817. case H245_ENDSESSION_TELEPHONY:
  1818. p_pdu_endsess->choice = gstnOptions_chosen;
  1819. p_pdu_endsess->u.gstnOptions.choice =
  1820. EndSessionCommand_gstnOptions_telephonyMode_chosen;
  1821. break;
  1822. case H245_ENDSESSION_V8BIS:
  1823. p_pdu_endsess->choice = gstnOptions_chosen;
  1824. p_pdu_endsess->u.gstnOptions.choice = v8bis_chosen;
  1825. break;
  1826. case H245_ENDSESSION_V34DSVD:
  1827. p_pdu_endsess->choice = gstnOptions_chosen;
  1828. p_pdu_endsess->u.gstnOptions.choice = v34DSVD_chosen;
  1829. break;
  1830. case H245_ENDSESSION_V34DUPFAX:
  1831. p_pdu_endsess->choice = gstnOptions_chosen;
  1832. p_pdu_endsess->u.gstnOptions.choice = v34DuplexFAX_chosen;
  1833. break;
  1834. case H245_ENDSESSION_V34H324:
  1835. p_pdu_endsess->choice = gstnOptions_chosen;
  1836. p_pdu_endsess->u.gstnOptions.choice = v34H324_chosen;
  1837. break;
  1838. default:
  1839. return H245_ERROR_NOSUP;
  1840. }
  1841. return H245_ERROR_OK;
  1842. }
  1843. /*****************************************************************************
  1844. *
  1845. * TYPE:
  1846. *
  1847. * PROCEDURE:
  1848. *
  1849. * DESCRIPTION
  1850. *
  1851. * RETURN:
  1852. *
  1853. *****************************************************************************/
  1854. HRESULT
  1855. pdu_ind_usrinpt ( PDU_T *pPdu,
  1856. const H245_NONSTANDARD_PARAMETER_T *pNonStd,
  1857. const char *string)
  1858. {
  1859. IndicationMessage *p_ind = &pPdu->u.indication;
  1860. UserInputIndication *p_pdu_usr = &p_ind->u.userInput;
  1861. pPdu->choice = indication_chosen;
  1862. p_ind->choice = userInput_chosen;
  1863. /* Must be either one or the other */
  1864. if (pNonStd && string)
  1865. return H245_ERROR_PARAM;
  1866. if (pNonStd)
  1867. {
  1868. p_pdu_usr->choice = UsrInptIndctn_nnStndrd_chosen;
  1869. p_pdu_usr->u.UsrInptIndctn_nnStndrd = *pNonStd;
  1870. }
  1871. else if (string)
  1872. {
  1873. p_pdu_usr->choice = alphanumeric_chosen;
  1874. p_pdu_usr->u.alphanumeric = (char *)string;
  1875. }
  1876. else
  1877. return H245_ERROR_PARAM;
  1878. return H245_ERROR_OK;
  1879. }
  1880.