Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1450 lines
49 KiB

  1. #include "precomp.h"
  2. /**********************************************************************
  3. * File: mcslog.c
  4. * Abstract: global function definitions for protocol logging functions
  5. * added into MCSNC.DLL to read the contents of MCS PDU
  6. * contents sent and received from the T.123 layer.
  7. * Created: 2/18/96, Venkatesh Gopalakrishnan
  8. * Copyright (c) 1996 Microsoft Corpration
  9. ******************************************************************** */
  10. /* NOTE: The contents of this file are only included IFF PDULOG is a
  11. * defined constant. This constant will be defined in the Win32 Diagnostic
  12. * build configuration of MCSNC.DLL
  13. */
  14. #ifdef PDULOG
  15. #include "mcslog.h"
  16. /* just threw these in to keep a total count of the number of bytes
  17. * of ASN.1 coded data sent and received.
  18. */
  19. long int recv_pdu_log = 0;
  20. long int sent_pdu_log = 0;
  21. /***********************************************************************/
  22. int InitializeMCSLog()
  23. {
  24. FILE *logfile;
  25. /* this should just reset the file pointer */
  26. logfile = fopen(LOG_FILE_NAME,"w");
  27. // this "fake" starting PDU is put in so that the Intel Protocol Browser
  28. // dosen't go nuts if it is reading dynamically.
  29. pduLog(logfile,"START_PDU: ============================== START PDU ===========================\n");
  30. pduLog(logfile,"TIMESTAMP: %s\n",pszTimeStamp());
  31. pduLog(logfile,"LAYER: MCS\n");
  32. pduLog(logfile,"DIRECTION: None\n");
  33. pduLog(logfile,"RAW_PDU: - - - - - - - - RAW PDU - - - - - - - -\n");
  34. pduLog(logfile,"DECODED_PDU: - - - - - - - DECODED PDU - - - - - - -\n");
  35. pduLog(logfile,"PDU_TYPE: Bogus_PDU_to_start_the_logging.\n");
  36. pduLog(logfile,"END_PDU: ================================ END PDU =============================\n");
  37. fclose(logfile);
  38. return(0);
  39. }
  40. /**************************************************************************/
  41. char *pszTimeStamp()
  42. {
  43. char *timestring;
  44. timestring = (char *) malloc (13*sizeof(char));
  45. _strtime(timestring);
  46. return(timestring);
  47. }
  48. /**************************************************************************/
  49. void pduFragmentation(FILE *logfile,unsigned int i)
  50. {
  51. pduLog(logfile," PDU Fragmentation: ");
  52. if(i==1)
  53. {
  54. pduLog(logfile,"Complete PDU\n");
  55. }
  56. else
  57. {
  58. pduLog(logfile,"!!!! Icomplete PDU !!!!\n");
  59. }
  60. }
  61. /**************************************************************************/
  62. void pduRawOutput (FILE *logfile,unsigned char *data, unsigned long length)
  63. {
  64. unsigned int i=0,j=0;
  65. pduLog(logfile," ");
  66. for (i=0; i<length; i++)
  67. {
  68. pduLog(logfile,"%02x ",*(data+i));
  69. j++;
  70. if (j >= 16)
  71. {
  72. pduLog(logfile,"\n ");
  73. j=0;
  74. }
  75. }
  76. pduLog(logfile,"\n");
  77. }
  78. /**************************************************************************/
  79. void PrintCharData(FILE *logfile, unsigned char *data, unsigned int length)
  80. {
  81. char print_buffer[255];
  82. //strncpy(print_buffer,(const char *) data, length);
  83. //CopyTextToChar(print_buffer, (unsigned short *) data, length);
  84. //pduLog(logfile,"\tlength = [%d] ; ",length);
  85. //pduLog(logfile,"\ttext = %s\n",print_buffer);
  86. pduRawOutput(logfile,data,length);
  87. }
  88. /**************************************************************************/
  89. void pduDirection(FILE *logfile,unsigned int direction)
  90. {
  91. switch(direction)
  92. {
  93. case SENT:
  94. pduLog(logfile,"DIRECTION: Sent\n");
  95. break;
  96. case RECEIVED:
  97. pduLog(logfile,"DIRECTION: Received\n");
  98. break;
  99. default:
  100. pduLog(logfile,"DIRECTION: Unknown\n");
  101. break;
  102. }
  103. }
  104. /**************************************************************************/
  105. void pduLog (FILE *pFile, char * format,...)
  106. {
  107. char *argument_ptr;
  108. argument_ptr = (char *) &format + sizeof (format);
  109. vfprintf (pFile, format, argument_ptr);
  110. }
  111. /**************************************************************************/
  112. void mcsLog(PPacket packet, PDomainMCSPDU domain_pdu, unsigned int direction)
  113. {
  114. FILE *logfile;
  115. logfile = fopen(LOG_FILE_NAME,"a+");
  116. pduLog(logfile,"START_PDU: ============================== START PDU ===========================\n");
  117. pduLog(logfile,"TIMESTAMP: %s\n",pszTimeStamp());
  118. pduLog(logfile,"LAYER: MCS\n");
  119. pduDirection(logfile,direction);
  120. pduLog(logfile,"RAW_PDU: - - - - - - - - RAW PDU - - - - - - - -\n");
  121. pduLog(logfile," %d octets (hex output):\n",packet->GetEncodedDataLength());
  122. if(direction==RECEIVED)
  123. recv_pdu_log = recv_pdu_log + packet->GetEncodedDataLength();
  124. else
  125. sent_pdu_log = sent_pdu_log + packet->GetEncodedDataLength();
  126. pduLog(logfile," Total Data: sent = %ld recv = %ld\n",sent_pdu_log,recv_pdu_log);
  127. pduRawOutput(logfile,packet->GetEncodedData(1),packet->GetEncodedDataLength());
  128. pduLog(logfile,"DECODED_PDU: - - - - - - - DECODED PDU - - - - - - -\n");
  129. pduFragmentation(logfile,packet->IsValid());
  130. pduLogMCSDomainInfo(logfile,domain_pdu);
  131. pduLog(logfile,"END_PDU: ================================ END PDU =============================\n");
  132. fclose(logfile);
  133. }
  134. /**************************************************************************/
  135. void mcsConnectLog(PPacket packet, PConnectMCSPDU connect_pdu, unsigned int direction)
  136. {
  137. FILE *logfile;
  138. logfile = fopen(LOG_FILE_NAME,"a+");
  139. pduLog(logfile,"START_PDU: ============================== START PDU ===========================\n");
  140. pduLog(logfile,"TIMESTAMP: %s\n",pszTimeStamp());
  141. pduLog(logfile,"LAYER: MCS\n");
  142. pduDirection(logfile,direction);
  143. pduLog(logfile,"RAW_PDU: - - - - - - - - RAW PDU - - - - - - - -\n");
  144. pduLog(logfile," %d octets (hex output):\n",packet->GetEncodedDataLength());
  145. if(direction==RECEIVED)
  146. recv_pdu_log = recv_pdu_log + packet->GetEncodedDataLength();
  147. else
  148. sent_pdu_log = sent_pdu_log + packet->GetEncodedDataLength();
  149. pduLog(logfile," Total Data: sent = %ld recv = %ld\n",sent_pdu_log,recv_pdu_log);
  150. pduRawOutput(logfile,packet->GetEncodedData(1),packet->GetEncodedDataLength());
  151. pduLog(logfile,"DECODED_PDU: - - - - - - - DECODED PDU - - - - - - -\n");
  152. pduFragmentation(logfile,packet->IsValid());
  153. pduLogMCSConnectInfo(logfile,connect_pdu);
  154. pduLog(logfile,"END_PDU: ================================ END PDU =============================\n");
  155. fclose(logfile);
  156. }
  157. ////////////////////////////////////////////////////////////////////////////
  158. // Switch cases for MCS Connect PDUs
  159. ////////////////////////////////////////////////////////////////////////////
  160. /**************************************************************************/
  161. void pduLogMCSConnectInfo(FILE *logfile, PConnectMCSPDU connect_pdu)
  162. {
  163. switch(connect_pdu->choice)
  164. {
  165. case CONNECT_INITIAL_CHOSEN:
  166. {
  167. pduLog(logfile,"PDU_TYPE: MCS_ConnectInitialPDU\n");
  168. pduLogConnectInitial(logfile,connect_pdu);
  169. }
  170. break;
  171. case CONNECT_RESPONSE_CHOSEN:
  172. {
  173. pduLog(logfile, "PDU_TYPE: MCS_ConnectResponsePDU\n");
  174. pduLogConnectResponse(logfile, connect_pdu);
  175. }
  176. break;
  177. case CONNECT_ADDITIONAL_CHOSEN:
  178. {
  179. pduLog(logfile,"PDU_TYPE: MCS_ConnectAdditionalPDU\n");
  180. pduLogConnectAdditional(logfile, connect_pdu);
  181. }
  182. break;
  183. case CONNECT_RESULT_CHOSEN:
  184. {
  185. pduLog(logfile,"PDU_TYPE: MCS_ConnectResultPDU\n");
  186. pduLogConnectResult(logfile, connect_pdu);
  187. }
  188. break;
  189. default:
  190. {
  191. pduLog(logfile,"ERROR: Unknown MCS Connect PDU !! << \n");
  192. }
  193. break;
  194. }
  195. }
  196. /**************************************************************************/
  197. void pduLogMCSDomainInfo(FILE *logfile, PDomainMCSPDU domain_pdu)
  198. {
  199. switch(domain_pdu->choice)
  200. {
  201. case PLUMB_DOMAIN_INDICATION_CHOSEN:
  202. {
  203. pduLog(logfile,"PDU_TYPE: MCS_PlumbDomainIndication\n");
  204. pduLogPlumbDomainIndication(logfile, domain_pdu);
  205. }
  206. break;
  207. case ERECT_DOMAIN_REQUEST_CHOSEN:
  208. {
  209. pduLog(logfile,"PDU_TYPE: MCS_ErectDomainIndication\n");
  210. pduLogErectDomainRequest(logfile, domain_pdu);
  211. }
  212. break;
  213. case MERGE_CHANNELS_REQUEST_CHOSEN:
  214. {
  215. pduLog(logfile,"PDU_TYPE: MCS_MergeChannelsRequest\n");
  216. pduLogMergeChannelsRequest(logfile, domain_pdu);
  217. }
  218. break;
  219. case MERGE_CHANNELS_CONFIRM_CHOSEN:
  220. {
  221. pduLog(logfile,"PDU_TYPE: MCS_MergeChannelsConfirm\n");
  222. pduLogMergeChannelsConfirm(logfile,domain_pdu);
  223. }
  224. break;
  225. case PURGE_CHANNEL_INDICATION_CHOSEN:
  226. {
  227. pduLog(logfile,"PDU_TYPE: MCS_PurgeChannelIndication\n");
  228. pduLogPurgeChannelIndication(logfile,domain_pdu);
  229. }
  230. break;
  231. case MERGE_TOKENS_REQUEST_CHOSEN:
  232. {
  233. pduLog(logfile,"PDU_TYPE: MCS_MergeTokensRequest\n");
  234. pduLogMergeTokensRequest(logfile,domain_pdu);
  235. }
  236. break;
  237. case MERGE_TOKENS_CONFIRM_CHOSEN:
  238. {
  239. pduLog(logfile,"PDU_TYPE: MCS_MergeTokensConfirm\n");
  240. pduLogMergeTokensConfirm(logfile,domain_pdu);
  241. }
  242. break;
  243. case PURGE_TOKEN_INDICATION_CHOSEN:
  244. {
  245. pduLog(logfile,"PDU_TYPE: MCS_PurgeTokenIndication\n");
  246. pduLogPurgeTokenIndication(logfile,domain_pdu);
  247. }
  248. break;
  249. case DISCONNECT_PROVIDER_ULTIMATUM_CHOSEN:
  250. {
  251. pduLog(logfile,"PDU_TYPE: MCS_DisconnectProviderUltimatum\n");
  252. pduLogDisconnectProviderUltimatum(logfile,domain_pdu);
  253. }
  254. break;
  255. case REJECT_ULTIMATUM_CHOSEN:
  256. {
  257. pduLog(logfile,"PDU_TYPE: MCS_RejectUltimatum\n");
  258. pduLogRejectUltimatum(logfile,domain_pdu);
  259. }
  260. break;
  261. case ATTACH_USER_REQUEST_CHOSEN:
  262. {
  263. pduLog(logfile,"PDU_TYPE: MCS_AttachUserRequest\n");
  264. pduLogAttachUserRequest(logfile,domain_pdu);
  265. }
  266. break;
  267. case ATTACH_USER_CONFIRM_CHOSEN:
  268. {
  269. pduLog(logfile,"PDU_TYPE: MCS_AttachUserConfirm\n");
  270. pduLogAttachUserConfirm(logfile,domain_pdu);
  271. }
  272. break;
  273. case DETACH_USER_REQUEST_CHOSEN:
  274. {
  275. pduLog(logfile,"PDU_TYPE: MCS_DetachUserRequest\n");
  276. pduLogDetachUserRequest(logfile,domain_pdu);
  277. }
  278. break;
  279. case DETACH_USER_INDICATION_CHOSEN:
  280. {
  281. pduLog(logfile,"PDU_TYPE: MCS_DetachUserIndication\n");
  282. pduLogDetachUserIndication(logfile,domain_pdu);
  283. }
  284. break;
  285. case CHANNEL_JOIN_REQUEST_CHOSEN:
  286. {
  287. pduLog(logfile,"PDU_TYPE: MCS_ChannelJoinRequest\n");
  288. pduLogChannelJoinRequest(logfile,domain_pdu);
  289. }
  290. break;
  291. case CHANNEL_JOIN_CONFIRM_CHOSEN:
  292. {
  293. pduLog(logfile,"PDU_TYPE: MCS_ChannelJoinConfirm\n");
  294. pduLogChannelJoinConfirm(logfile,domain_pdu);
  295. }
  296. break;
  297. case CHANNEL_LEAVE_REQUEST_CHOSEN:
  298. {
  299. pduLog(logfile,"PDU_TYPE: MCS_ChannelLeaveRequest\n");
  300. pduLogChannelLeaveRequest(logfile,domain_pdu);
  301. }
  302. break;
  303. case CHANNEL_CONVENE_REQUEST_CHOSEN:
  304. {
  305. pduLog(logfile,"PDU_TYPE: MCS_ChannelConveneRequest\n");
  306. pduLogChannelConveneRequest(logfile,domain_pdu);
  307. }
  308. break;
  309. case CHANNEL_CONVENE_CONFIRM_CHOSEN:
  310. {
  311. pduLog(logfile,"PDU_TYPE: MCS_ChannelConveneConfirm\n");
  312. pduLogChannelConveneConfirm(logfile,domain_pdu);
  313. }
  314. break;
  315. case CHANNEL_DISBAND_REQUEST_CHOSEN:
  316. {
  317. pduLog(logfile,"PDU_TYPE: MCS_ChannelDisbandRequest\n");
  318. pduLogChannelDisbandRequest(logfile,domain_pdu);
  319. }
  320. break;
  321. case CHANNEL_DISBAND_INDICATION_CHOSEN:
  322. {
  323. pduLog(logfile,"PDU_TYPE: MCS_ChannelDisbandIndication\n");
  324. pduLogChannelDisbandIndication(logfile,domain_pdu);
  325. }
  326. break;
  327. case CHANNEL_ADMIT_REQUEST_CHOSEN:
  328. {
  329. pduLog(logfile,"PDU_TYPE: MCS_ChannelAdmitRequest\n");
  330. pduLogChannelAdmitRequest(logfile,domain_pdu);
  331. }
  332. break;
  333. case CHANNEL_ADMIT_INDICATION_CHOSEN:
  334. {
  335. pduLog(logfile,"PDU_TYPE: MCS_ChannelAdmitIndication\n");
  336. pduLogChannelAdmitIndication(logfile,domain_pdu);
  337. }
  338. break;
  339. case CHANNEL_EXPEL_REQUEST_CHOSEN:
  340. {
  341. pduLog(logfile,"PDU_TYPE: MCS_ChannelExpelRequest\n");
  342. pduLogChannelExpelRequest(logfile,domain_pdu);
  343. }
  344. break;
  345. case CHANNEL_EXPEL_INDICATION_CHOSEN:
  346. {
  347. pduLog(logfile,"PDU_TYPE: MCS_ChannelExpelIndication\n");
  348. pduLogChannelExpelIndication(logfile,domain_pdu);
  349. }
  350. break;
  351. case SEND_DATA_REQUEST_CHOSEN:
  352. {
  353. pduLog(logfile,"PDU_TYPE: MCS_SendDataRequest\n");
  354. pduLogSendDataRequest(logfile,domain_pdu);
  355. }
  356. break;
  357. case SEND_DATA_INDICATION_CHOSEN:
  358. {
  359. pduLog(logfile,"PDU_TYPE: MCS_SendDataIndication\n");
  360. pduLogSendDataIndication(logfile,domain_pdu);
  361. }
  362. break;
  363. case UNIFORM_SEND_DATA_REQUEST_CHOSEN:
  364. {
  365. pduLog(logfile,"PDU_TYPE: MCS_UniformSendDataRequest\n");
  366. pduLogUniformSendDataRequest(logfile,domain_pdu);
  367. }
  368. break;
  369. case UNIFORM_SEND_DATA_INDICATION_CHOSEN:
  370. {
  371. pduLog(logfile,"PDU_TYPE: MCS_UniformSendDataIndication\n");
  372. pduLogUniformSendDataIndication(logfile,domain_pdu);
  373. }
  374. break;
  375. case TOKEN_GRAB_REQUEST_CHOSEN:
  376. {
  377. pduLog(logfile,"PDU_TYPE: MCS_TokenGrabRequest\n");
  378. pduLogTokenGrabRequest(logfile,domain_pdu);
  379. }
  380. break;
  381. case TOKEN_GRAB_CONFIRM_CHOSEN:
  382. {
  383. pduLog(logfile,"PDU_TYPE: MCS_TokenGrabConfirm\n");
  384. pduLogTokenGrabConfirm(logfile,domain_pdu);
  385. }
  386. break;
  387. case TOKEN_INHIBIT_REQUEST_CHOSEN:
  388. {
  389. pduLog(logfile,"PDU_TYPE: MCS_TokenInhibitRequest\n");
  390. pduLogTokenInhibitRequest(logfile,domain_pdu);
  391. }
  392. break;
  393. case TOKEN_INHIBIT_CONFIRM_CHOSEN:
  394. {
  395. pduLog(logfile,"PDU_TYPE: MCS_TokenInhibitConfirm\n");
  396. pduLogTokenInhibitConfirm(logfile,domain_pdu);
  397. }
  398. break;
  399. case TOKEN_GIVE_REQUEST_CHOSEN:
  400. {
  401. pduLog(logfile,"PDU_TYPE: MCS_TokenGiveRequest\n");
  402. pduLogTokenGiveRequest(logfile,domain_pdu);
  403. }
  404. break;
  405. case TOKEN_GIVE_INDICATION_CHOSEN:
  406. {
  407. pduLog(logfile,"PDU_TYPE: MCS_TokenGiveIndication\n");
  408. pduLogTokenGiveIndication(logfile,domain_pdu);
  409. }
  410. break;
  411. case TOKEN_GIVE_RESPONSE_CHOSEN:
  412. {
  413. pduLog(logfile,"PDU_TYPE: MCS_TokenGiveResponse\n");
  414. pduLogTokenGiveResponse(logfile,domain_pdu);
  415. }
  416. break;
  417. case TOKEN_GIVE_CONFIRM_CHOSEN:
  418. {
  419. pduLog(logfile,"PDU_TYPE: MCS_TokenGiveConfirm\n");
  420. pduLogTokenGiveConfirm(logfile,domain_pdu);
  421. }
  422. break;
  423. case TOKEN_PLEASE_REQUEST_CHOSEN:
  424. {
  425. pduLog(logfile,"PDU_TYPE: MCS_TokenPleaseRequest\n");
  426. pduLogTokenPleaseRequest(logfile,domain_pdu);
  427. }
  428. break;
  429. case TOKEN_PLEASE_INDICATION_CHOSEN:
  430. {
  431. pduLog(logfile,"PDU_TYPE: MCS_TokenPleaseIndication\n");
  432. pduLogTokenPleaseIndication(logfile,domain_pdu);
  433. }
  434. break;
  435. case TOKEN_RELEASE_REQUEST_CHOSEN:
  436. {
  437. pduLog(logfile,"PDU_TYPE: MCS_TokenReleaseRequest\n");
  438. pduLogTokenReleaseRequest(logfile,domain_pdu);
  439. }
  440. break;
  441. case TOKEN_RELEASE_CONFIRM_CHOSEN:
  442. {
  443. pduLog(logfile,"PDU_TYPE: MCS_TokenReleseConfirm\n");
  444. pduLogTokenReleaseConfirm(logfile,domain_pdu);
  445. }
  446. break;
  447. case TOKEN_TEST_REQUEST_CHOSEN:
  448. {
  449. pduLog(logfile,"PDU_TYPE: MCS_TokenTestRequest\n");
  450. pduLogTokenTestRequest(logfile,domain_pdu);
  451. }
  452. break;
  453. case TOKEN_TEST_CONFIRM_CHOSEN:
  454. {
  455. pduLog(logfile,"PDU_TYPE: MCS_TokenTestConfirm\n");
  456. pduLogTokenTestConfirm(logfile,domain_pdu);
  457. }
  458. break;
  459. default:
  460. {
  461. // write something, just so we know we got a PDU.
  462. pduLog(logfile,"ERROR: we got a MCS PDU, just don't know what it is");
  463. }
  464. break;
  465. }
  466. }
  467. ///////////////////////////////////////////////////////////////////////
  468. // constant string returns
  469. //////////////////////////////////////////////////////////////////////
  470. /**************************************************************************/
  471. void PrintPDUResult(FILE *logfile, unsigned int result)
  472. {
  473. switch(result)
  474. {
  475. case RT_SUCCESSFUL:
  476. pduLog(logfile,"RT_SUCCESSFUL\n");
  477. break;
  478. case RT_DOMAIN_MERGING:
  479. pduLog(logfile,"RT_DOMAIN_MERGING\n");
  480. break;
  481. case RT_DOMAIN_NOT_HIERARCHICAL:
  482. pduLog(logfile,"RT_DOMAIN_NOT_HIERARCHICAL\n");
  483. break;
  484. case RT_NO_SUCH_CHANNEL:
  485. pduLog(logfile,"RT_NO_SUCH_CHANNEL\n");
  486. break;
  487. case RT_NO_SUCH_DOMAIN:
  488. pduLog(logfile,"RT_NO_SUCH_DOMAIN\n");
  489. break;
  490. case RT_NO_SUCH_USER:
  491. pduLog(logfile,"RT_NO_SUCH_USER\n");
  492. break;
  493. case RT_NOT_ADMITTED:
  494. pduLog(logfile,"RT_NOT_ADMITTED\n");
  495. break;
  496. case RT_OTHER_USER:
  497. pduLog(logfile,"RT_OTHER_USER\n");
  498. break;
  499. case RT_PARAMETERS_UNACCEPTABLE:
  500. pduLog(logfile,"RT_PARAMETERS_UNACCEPTABLE\n");
  501. break;
  502. case RT_TOKEN_NOT_AVAILABLE:
  503. pduLog(logfile,"RT_TOKEN_NOT_AVAILABLE\n");
  504. break;
  505. case RT_TOKEN_NOT_POSESSED:
  506. pduLog(logfile,"RT_TOKEN_NOT_POSESSED\n");
  507. break;
  508. case RT_TOO_MANY_CHANNELS:
  509. pduLog(logfile,"RT_TOO_MANY_CHANNELS\n");
  510. break;
  511. case RT_TOO_MANY_TOKENS:
  512. pduLog(logfile,"RT_TOO_MANY_TOKENS\n");
  513. break;
  514. case RT_TOO_MANY_USERS:
  515. pduLog(logfile,"RT_TOO_MANY_USERS\n");
  516. break;
  517. case RT_UNSPECIFIED_FAILURE:
  518. pduLog(logfile,"RT_UNSPECIFIED_FAILURE\n");
  519. break;
  520. case RT_USER_REJECTED:
  521. pduLog(logfile,"RT_USER_REJECTED\n");
  522. break;
  523. default:
  524. pduLog(logfile,"ERROR: UNKOWN RETURN TYPE <<<\n");
  525. break;
  526. }
  527. }
  528. /**************************************************************************/
  529. void PrintPDUPriority(FILE *logfile, unsigned int priority)
  530. {
  531. switch(priority)
  532. {
  533. case TOP_PRI:
  534. pduLog(logfile,TOP_STR);
  535. break;
  536. case HIGH_PRI:
  537. pduLog(logfile,HIGH_STR);
  538. break;
  539. case MEDIUM_PRI:
  540. pduLog(logfile,MEDIUM_STR);
  541. break;
  542. case LOW_PRI:
  543. pduLog(logfile,LOW_STR);
  544. break;
  545. default:
  546. pduLog(logfile," >>>> UNKNOWN PRIORITY <<<\n");
  547. break;
  548. }
  549. }
  550. /**************************************************************************/
  551. void PrintPDUSegmentation(FILE *logfile, unsigned char segmentation)
  552. {
  553. if(segmentation==0x80)
  554. pduLog(logfile,"\tSegmentation: Begin\n");
  555. else if (segmentation==0x40)
  556. pduLog(logfile,"\tSegmentation: End\n");
  557. else
  558. pduLog(logfile,"\tSegmentation: Unknown\n");
  559. }
  560. /**************************************************************************/
  561. void PrintTokenStatus(FILE *logfile, unsigned int status)
  562. {
  563. switch(status)
  564. {
  565. case 0:
  566. pduLog(logfile,"\ttoken_status = NOT_IN_USE\n");
  567. break;
  568. case 1:
  569. pduLog(logfile,"\ttoken_status = SELF_GRABBED\n");
  570. break;
  571. case 2:
  572. pduLog(logfile,"\ttoken_status = OTHER_GRABBED\n");
  573. break;
  574. case 3:
  575. pduLog(logfile,"\ttoken_status = SELF_INHIBITED\n");
  576. break;
  577. case 4:
  578. pduLog(logfile,"\ttoken_status = OTHER_INHIBITED\n");
  579. break;
  580. case 5:
  581. pduLog(logfile,"\ttoken_status = SELF_RECIPIENT\n");
  582. break;
  583. case 6:
  584. pduLog(logfile,"\ttoken_status = SELF_GIVING\n");
  585. break;
  586. case 7:
  587. pduLog(logfile,"\ttoken_status = OTHER_GIVING\n");
  588. break;
  589. default:
  590. pduLog(logfile,"\tERROR: unknown token status\n");
  591. break;
  592. }
  593. }
  594. /**************************************************************************/
  595. void PrintPDUReason(FILE *logfile, unsigned int reason)
  596. {
  597. pduLog(logfile,"\t\tReason: ");
  598. switch(reason)
  599. {
  600. case 0:
  601. pduLog(logfile,"RN_DOMAIN_DISCONNECTED\n");
  602. break;
  603. case 1:
  604. pduLog(logfile,"RN_PROVIDER_INITIATED\n");
  605. break;
  606. case 2:
  607. pduLog(logfile,"RN_TOKEN_PURGED\n");
  608. break;
  609. case 3:
  610. pduLog(logfile,"RN_USER_REQUESTED\n");
  611. break;
  612. case 4:
  613. pduLog(logfile,"RN_CHANNEL_PURGED\n");
  614. break;
  615. }
  616. }
  617. /**************************************************************************/
  618. void PrintDiagnostic(FILE *logfile, unsigned int diagnostic)
  619. {
  620. pduLog(logfile,"\t\tDiagnostic: ");
  621. switch(diagnostic)
  622. {
  623. case 0:
  624. pduLog(logfile,"dc_inconsistent_merge\n");
  625. break;
  626. case 1:
  627. pduLog(logfile,"dc_forbidden_pdu_downward\n");
  628. break;
  629. case 2:
  630. pduLog(logfile,"dc_forbidden_pdu_upward\n");
  631. break;
  632. case 3:
  633. pduLog(logfile,"dc_invalid_ber_encoding\n");
  634. break;
  635. case 4:
  636. pduLog(logfile,"dc_invalid_per_encoding\n");
  637. break;
  638. case 5:
  639. pduLog(logfile,"dc_misrouted_user\n");
  640. break;
  641. case 6:
  642. pduLog(logfile,"dc_unrequested_confirm\n");
  643. break;
  644. case 7:
  645. pduLog(logfile,"dc_wrong_transport_priority\n");
  646. break;
  647. case 8:
  648. pduLog(logfile,"dc_channel_id_conflict\n");
  649. break;
  650. case 9:
  651. pduLog(logfile,"dc_token_id_conflict\n");
  652. break;
  653. case 10:
  654. pduLog(logfile,"dc_not_user_id_channel\n");
  655. break;
  656. case 11:
  657. pduLog(logfile,"dc_too_many_channels\n");
  658. break;
  659. case 12:
  660. pduLog(logfile,"dc_too_many_tokens\n");
  661. break;
  662. case 13:
  663. pduLog(logfile,"dc_too_many_users\n");
  664. break;
  665. default:
  666. pduLog(logfile,"ERROR: unknown diagnostic\n");
  667. break;
  668. }
  669. }
  670. /*****
  671. ***** Logging functions for individual MCS PDU contents
  672. *****/
  673. /**************************************************************************/
  674. void pduLogConnectInitial(FILE *logfile, PConnectMCSPDU connect_pdu)
  675. {
  676. pduLog(logfile,"\tCalling Domain Selector:");
  677. PrintCharData(logfile,connect_pdu->u.connect_initial.calling_domain_selector.value,
  678. connect_pdu->u.connect_initial.calling_domain_selector.length);
  679. pduLog(logfile,"\tCalled Domain Selector:");
  680. PrintCharData(logfile,connect_pdu->u.connect_initial.called_domain_selector.value,
  681. connect_pdu->u.connect_initial.called_domain_selector.length);
  682. PrintT120Boolean(logfile,"\tupward_flag = ",
  683. (BOOL) connect_pdu->u.connect_initial.upward_flag);
  684. pduLog(logfile,"\tTarget Parameters: \n");
  685. PrintPDUDomainParameters(logfile, connect_pdu->u.connect_initial.target_parameters);
  686. pduLog(logfile,"\tMinimum Parameters: \n");
  687. PrintPDUDomainParameters(logfile, connect_pdu->u.connect_initial.minimum_parameters);
  688. pduLog(logfile,"\tMaximum Parameters: \n");
  689. PrintPDUDomainParameters(logfile, connect_pdu->u.connect_initial.maximum_parameters);
  690. pduLog(logfile,"\tUser Data: \n");
  691. pduRawOutput(logfile,connect_pdu->u.connect_initial.user_data.value,
  692. connect_pdu->u.connect_initial.user_data.length);
  693. }
  694. /**************************************************************************/
  695. void pduLogConnectResponse(FILE *logfile, PConnectMCSPDU connect_pdu)
  696. {
  697. pduLog(logfile, "\tResult: ");
  698. PrintPDUResult(logfile, connect_pdu->u.connect_response.result);
  699. pduLog(logfile, "\tcalled_connect_id = %u \n",
  700. connect_pdu->u.connect_response.called_connect_id);
  701. pduLog(logfile, "\tDomain Parameters: \n");
  702. PrintPDUDomainParameters(logfile, connect_pdu->u.connect_response.domain_parameters);
  703. pduLog(logfile, "\tUser Data: \n");
  704. pduRawOutput(logfile,connect_pdu->u.connect_response.user_data.value,
  705. connect_pdu->u.connect_response.user_data.length);
  706. }
  707. /**************************************************************************/
  708. void pduLogConnectAdditional(FILE *logfile, PConnectMCSPDU connect_pdu)
  709. {
  710. pduLog(logfile, "\tcalled_connect_id = %u\n",
  711. connect_pdu->u.connect_additional.called_connect_id);
  712. pduLog(logfile, "Priority: \n");
  713. PrintPDUPriority(logfile, connect_pdu->u.connect_additional.data_priority);
  714. }
  715. /**************************************************************************/
  716. void pduLogConnectResult(FILE *logfile, PConnectMCSPDU connect_pdu)
  717. {
  718. pduLog(logfile, "\tResult: ");
  719. PrintPDUResult(logfile, connect_pdu->u.connect_result.result);
  720. }
  721. /**************************************************************************/
  722. void pduLogPlumbDomainIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  723. {
  724. pduLog(logfile, "\theight_limit = %u\n",
  725. domain_pdu->u.plumb_domain_indication.height_limit);
  726. }
  727. /**************************************************************************/
  728. void pduLogErectDomainRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  729. {
  730. pduLog(logfile, "\tsub_height = %u\n",
  731. domain_pdu->u.erect_domain_request.sub_height);
  732. pduLog(logfile, "\tsub_interval = %u\n",
  733. domain_pdu->u.erect_domain_request.sub_interval);
  734. }
  735. /**************************************************************************/
  736. void pduLogMergeChannelsRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  737. {
  738. int i = 0;
  739. PSetOfPDUChannelAttributes channel_attributes;
  740. PSetOfChannelIDs channel_ids;
  741. channel_attributes = domain_pdu->u.merge_channels_request.merge_channels;
  742. channel_ids = domain_pdu->u.merge_channels_request.purge_channel_ids;
  743. pduLog(logfile, " Merge Channels:\n");
  744. for(i=0; channel_attributes!=NULL; i++)
  745. {
  746. pduLog(logfile,"\t*** record [%u] ***\n",i);
  747. PrintChannelAttributes(logfile, channel_attributes->value);
  748. channel_attributes = channel_attributes->next;
  749. }
  750. pduLog(logfile, " Purge Channel IDs:\n");
  751. for(i=0; channel_ids!=NULL; i++)
  752. {
  753. pduLog(logfile,"\t\trecord[%u] = %u\n",channel_ids->value);
  754. channel_ids = channel_ids->next;
  755. }
  756. }
  757. /**************************************************************************/
  758. void pduLogMergeChannelsConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  759. {
  760. unsigned int i = 0;
  761. PSetOfPDUChannelAttributes channel_attributes;
  762. PSetOfChannelIDs channel_ids;
  763. channel_attributes = domain_pdu->u.merge_channels_confirm.merge_channels;
  764. channel_ids = domain_pdu->u.merge_channels_confirm.purge_channel_ids;
  765. pduLog(logfile, " Merge Channels:\n");
  766. for(i=0; channel_attributes!=NULL; i++)
  767. {
  768. pduLog(logfile,"\t*** record [%u] ***\n",i);
  769. PrintChannelAttributes(logfile, channel_attributes->value);
  770. channel_attributes = channel_attributes->next;
  771. }
  772. pduLog(logfile, " Purge Channel IDs:\n");
  773. PrintSetOfChannelIDs(logfile,channel_ids);
  774. }
  775. /**************************************************************************/
  776. void pduLogPurgeChannelIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  777. {
  778. PSetOfUserIDs detach_user_ids;
  779. PSetOfChannelIDs purge_channel_ids;
  780. detach_user_ids = domain_pdu->u.purge_channel_indication.detach_user_ids;
  781. purge_channel_ids = domain_pdu->u.purge_channel_indication.purge_channel_ids;
  782. pduLog(logfile, " Detach User IDs: \n");
  783. PrintSetOfUserIDs(logfile, detach_user_ids);
  784. pduLog(logfile, " Purge Channel IDs: \n");
  785. PrintSetOfChannelIDs(logfile, purge_channel_ids);
  786. }
  787. /**************************************************************************/
  788. void pduLogMergeTokensRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  789. {
  790. PSetOfPDUTokenAttributes merge_tokens;
  791. PSetOfTokenIDs purge_token_ids;
  792. merge_tokens = domain_pdu->u.merge_tokens_request.merge_tokens;
  793. purge_token_ids = domain_pdu->u.merge_tokens_request.purge_token_ids;
  794. pduLog(logfile," Merge Tokens: \n");
  795. PrintSetOfTokenAttributes(logfile, merge_tokens);
  796. pduLog(logfile," Purge Token IDs: \n");
  797. PrintSetOfTokenIDs(logfile, purge_token_ids);
  798. }
  799. /**************************************************************************/
  800. void pduLogMergeTokensConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  801. {
  802. PSetOfPDUTokenAttributes merge_tokens;
  803. PSetOfTokenIDs purge_token_ids;
  804. merge_tokens = domain_pdu->u.merge_tokens_request.merge_tokens;
  805. purge_token_ids = domain_pdu->u.merge_tokens_request.purge_token_ids;
  806. pduLog(logfile," Merge Tokens: \n");
  807. PrintSetOfTokenAttributes(logfile, merge_tokens);
  808. pduLog(logfile," Purge Token IDs: \n");
  809. PrintSetOfTokenIDs(logfile, purge_token_ids);
  810. }
  811. /**************************************************************************/
  812. void pduLogPurgeTokenIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  813. {
  814. PSetOfTokenIDs purge_token_ids;
  815. purge_token_ids = domain_pdu->u.purge_token_indication.purge_token_ids;
  816. pduLog(logfile," Purge Token IDs: \n");
  817. PrintSetOfTokenIDs(logfile, purge_token_ids);
  818. }
  819. /**************************************************************************/
  820. void pduLogDisconnectProviderUltimatum(FILE *logfile, PDomainMCSPDU domain_pdu)
  821. {
  822. PrintPDUReason(logfile, domain_pdu->u.disconnect_provider_ultimatum.reason);
  823. }
  824. /**************************************************************************/
  825. void pduLogRejectUltimatum(FILE *logfile, PDomainMCSPDU domain_pdu)
  826. {
  827. PrintDiagnostic(logfile,
  828. domain_pdu->u.reject_user_ultimatum.diagnostic);
  829. pduLog(logfile,"\tInitial Octets: \n");
  830. pduRawOutput(logfile,
  831. domain_pdu->u.reject_user_ultimatum.initial_octets.value,
  832. domain_pdu->u.reject_user_ultimatum.initial_octets.length);
  833. }
  834. /**************************************************************************/
  835. void pduLogAttachUserRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  836. {
  837. pduLog(logfile, "placeholder = %c\n",
  838. domain_pdu->u.attach_user_request.placeholder);
  839. }
  840. /**************************************************************************/
  841. void pduLogAttachUserConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  842. {
  843. pduLog(logfile,"\tResult: ");
  844. PrintPDUResult(logfile,domain_pdu->u.attach_user_confirm.result);
  845. pduLog(logfile,"\tinitiator = %u\n",
  846. domain_pdu->u.attach_user_confirm.initiator);
  847. }
  848. /**************************************************************************/
  849. void pduLogDetachUserRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  850. {
  851. PrintPDUReason(logfile,domain_pdu->u.detach_user_request.reason);
  852. PrintSetOfUserIDs(logfile,
  853. domain_pdu->u.detach_user_request.user_ids);
  854. }
  855. /**************************************************************************/
  856. void pduLogDetachUserIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  857. {
  858. PrintPDUReason(logfile,domain_pdu->u.detach_user_indication.reason);
  859. PrintSetOfUserIDs(logfile,
  860. domain_pdu->u.detach_user_indication.user_ids);
  861. }
  862. /**************************************************************************/
  863. void pduLogChannelJoinRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  864. {
  865. pduLog(logfile,"\t\tuser_id = %u\n",
  866. domain_pdu->u.channel_join_request.initiator);
  867. pduLog(logfile,"\t\tchannel_id = %u\n",
  868. domain_pdu->u.channel_join_request.channel_id);
  869. }
  870. /**************************************************************************/
  871. void pduLogChannelJoinConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  872. {
  873. pduLog(logfile,"\tResult: ");
  874. PrintPDUResult(logfile,domain_pdu->u.channel_join_confirm.result);
  875. pduLog(logfile,"\tinitiator userID = %u\n",
  876. domain_pdu->u.channel_join_confirm.initiator);
  877. pduLog(logfile,"\trequested channel ID = %u\n",
  878. domain_pdu->u.channel_join_confirm.requested);
  879. pduLog(logfile,"\tjoin channel ID = %u\n",
  880. domain_pdu->u.channel_join_confirm.join_channel_id);
  881. }
  882. /**************************************************************************/
  883. void pduLogChannelLeaveRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  884. {
  885. pduLog(logfile,"\tChannel IDs: \n");
  886. PrintSetOfChannelIDs(logfile,
  887. domain_pdu->u.channel_leave_request.channel_ids);
  888. }
  889. /**************************************************************************/
  890. void pduLogChannelConveneRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  891. {
  892. pduLog(logfile,"\tInitiator user ID = %u\n",
  893. domain_pdu->u.channel_convene_request.initiator);
  894. }
  895. /**************************************************************************/
  896. void pduLogChannelConveneConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  897. {
  898. pduLog(logfile,"\tResult: ");
  899. PrintPDUResult(logfile,domain_pdu->u.channel_convene_confirm.result);
  900. pduLog(logfile,"\tInitiator user ID = %u\n",
  901. domain_pdu->u.channel_convene_confirm.initiator);
  902. pduLog(logfile,"\tPrivate channel ID = %u\n",
  903. domain_pdu->u.channel_convene_confirm.convene_channel_id);
  904. }
  905. /**************************************************************************/
  906. void pduLogChannelDisbandRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  907. {
  908. pduLog(logfile,"\tInitiator User ID = %u\n",
  909. domain_pdu->u.channel_disband_request.initiator);
  910. pduLog(logfile,"\tPrivate channel ID = %u\n",
  911. domain_pdu->u.channel_disband_request.channel_id);
  912. }
  913. /**************************************************************************/
  914. void pduLogChannelDisbandIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  915. {
  916. pduLog(logfile,"\tPrivate Channel ID = %u\n",
  917. domain_pdu->u.channel_disband_indication.channel_id);
  918. }
  919. /**************************************************************************/
  920. void pduLogChannelAdmitRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  921. {
  922. pduLog(logfile,"\tInitiator User ID = %u\n",
  923. domain_pdu->u.channel_admit_request.initiator);
  924. pduLog(logfile,"\tPrivate Channel ID = %u\n",
  925. domain_pdu->u.channel_admit_request.channel_id);
  926. pduLog(logfile,"\tUser IDs Admitted: \n");
  927. PrintSetOfUserIDs(logfile,domain_pdu->u.channel_admit_request.user_ids);
  928. }
  929. /**************************************************************************/
  930. void pduLogChannelAdmitIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  931. {
  932. pduLog(logfile,"\tInitiator User ID = %u\n",
  933. domain_pdu->u.channel_admit_indication.initiator);
  934. pduLog(logfile,"\tPrivate Channel ID = %u\n",
  935. domain_pdu->u.channel_admit_indication.channel_id);
  936. pduLog(logfile,"\tUser IDs Admitted: \n");
  937. PrintSetOfUserIDs(logfile,domain_pdu->u.channel_admit_indication.user_ids);
  938. }
  939. /**************************************************************************/
  940. void pduLogChannelExpelRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  941. {
  942. pduLog(logfile,"\tInitiator User ID = %u\n",
  943. domain_pdu->u.channel_expel_request.initiator);
  944. pduLog(logfile,"\tPrivate Channel ID = %u\n",
  945. domain_pdu->u.channel_expel_request.channel_id);
  946. pduLog(logfile,"\tUser IDs Admitted: \n");
  947. PrintSetOfUserIDs(logfile,domain_pdu->u.channel_expel_request.user_ids);
  948. }
  949. /**************************************************************************/
  950. void pduLogChannelExpelIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  951. {
  952. pduLog(logfile,"\tPrivate Channel ID = %u\n",
  953. domain_pdu->u.channel_expel_indication.channel_id);
  954. pduLog(logfile,"\tUser IDs Admitted: \n");
  955. PrintSetOfUserIDs(logfile,domain_pdu->u.channel_expel_indication.user_ids);
  956. }
  957. /**************************************************************************/
  958. void pduLogSendDataRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  959. {
  960. pduLog(logfile,"\tInitiator User ID = %u\n",
  961. domain_pdu->u.send_data_request.initiator);
  962. pduLog(logfile,"\tChannel ID = %u\n",
  963. domain_pdu->u.send_data_request.channel_id);
  964. pduLog(logfile,"\tPriority: ");
  965. PrintPDUPriority(logfile,domain_pdu->u.send_data_request.data_priority);
  966. pduLog(logfile,"\tSegmentation: ");
  967. PrintPDUSegmentation(logfile,domain_pdu->u.send_data_request.segmentation);
  968. pduLog(logfile,"\tUser Data (%u octets):\n",
  969. domain_pdu->u.send_data_request.user_data.length);
  970. pduRawOutput(logfile,
  971. domain_pdu->u.send_data_request.user_data.value,
  972. domain_pdu->u.send_data_request.user_data.length);
  973. }
  974. /**************************************************************************/
  975. void pduLogSendDataIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  976. {
  977. pduLog(logfile,"\tInitiator User ID = %u\n",
  978. domain_pdu->u.send_data_indication.initiator);
  979. pduLog(logfile,"\tChannel ID = %u\n",
  980. domain_pdu->u.send_data_indication.channel_id);
  981. pduLog(logfile,"\tPriority: ");
  982. PrintPDUPriority(logfile,domain_pdu->u.send_data_indication.data_priority);
  983. pduLog(logfile,"\tSegmentation: ");
  984. PrintPDUSegmentation(logfile,domain_pdu->u.send_data_indication.segmentation);
  985. pduLog(logfile,"\tUser Data (%u octets):\n",
  986. domain_pdu->u.send_data_indication.user_data.length);
  987. pduRawOutput(logfile,
  988. domain_pdu->u.send_data_indication.user_data.value,
  989. domain_pdu->u.send_data_indication.user_data.length);
  990. }
  991. /**************************************************************************/
  992. void pduLogUniformSendDataRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  993. {
  994. pduLog(logfile,"\tInitiator User ID = %u\n",
  995. domain_pdu->u.uniform_send_data_request.initiator);
  996. pduLog(logfile,"\tChannel ID = %u\n",
  997. domain_pdu->u.uniform_send_data_request.channel_id);
  998. pduLog(logfile,"\tPriority: ");
  999. PrintPDUPriority(logfile,domain_pdu->u.uniform_send_data_request.data_priority);
  1000. pduLog(logfile,"\tSegmentation: ");
  1001. PrintPDUSegmentation(logfile,domain_pdu->u.uniform_send_data_request.segmentation);
  1002. pduLog(logfile,"\tUser Data (%u octets):\n",
  1003. domain_pdu->u.uniform_send_data_request.user_data.length);
  1004. pduRawOutput(logfile,
  1005. domain_pdu->u.uniform_send_data_request.user_data.value,
  1006. domain_pdu->u.uniform_send_data_request.user_data.length);
  1007. }
  1008. /**************************************************************************/
  1009. void pduLogUniformSendDataIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  1010. {
  1011. pduLog(logfile,"\tInitiator User ID = %u\n",
  1012. domain_pdu->u.uniform_send_data_indication.initiator);
  1013. pduLog(logfile,"\tChannel ID = %u\n",
  1014. domain_pdu->u.uniform_send_data_indication.channel_id);
  1015. pduLog(logfile,"\tPriority: ");
  1016. PrintPDUPriority(logfile,domain_pdu->u.uniform_send_data_indication.data_priority);
  1017. pduLog(logfile,"\tSegmentation: ");
  1018. PrintPDUSegmentation(logfile,domain_pdu->u.uniform_send_data_indication.segmentation);
  1019. pduLog(logfile,"\tUser Data (%u octets):\n",
  1020. domain_pdu->u.uniform_send_data_indication.user_data.length);
  1021. pduRawOutput(logfile,
  1022. domain_pdu->u.uniform_send_data_indication.user_data.value,
  1023. domain_pdu->u.uniform_send_data_indication.user_data.length);
  1024. }
  1025. /**************************************************************************/
  1026. void pduLogTokenGrabRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  1027. {
  1028. pduLog(logfile,"\tInitiator User ID = %u\n",
  1029. domain_pdu->u.token_grab_request.initiator);
  1030. pduLog(logfile,"\tToken ID = %u\n",
  1031. domain_pdu->u.token_grab_request.token_id);
  1032. }
  1033. /**************************************************************************/
  1034. void pduLogTokenGrabConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  1035. {
  1036. pduLog(logfile,"\tResult: ");
  1037. PrintPDUResult(logfile,domain_pdu->u.token_grab_confirm.result);
  1038. pduLog(logfile,"\tInitiator User ID = %u\n",
  1039. domain_pdu->u.token_grab_confirm.initiator);
  1040. pduLog(logfile,"\tToken ID = %u\n",
  1041. domain_pdu->u.token_grab_confirm.token_id);
  1042. PrintTokenStatus(logfile,domain_pdu->u.token_grab_confirm.token_status);
  1043. }
  1044. /**************************************************************************/
  1045. void pduLogTokenInhibitRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  1046. {
  1047. pduLog(logfile,"\tInitiator User ID = %u\n",
  1048. domain_pdu->u.token_inhibit_request.initiator);
  1049. pduLog(logfile,"\tToken ID = %u\n",
  1050. domain_pdu->u.token_inhibit_request.token_id);
  1051. }
  1052. /**************************************************************************/
  1053. void pduLogTokenInhibitConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  1054. {
  1055. pduLog(logfile,"\tResult: ");
  1056. PrintPDUResult(logfile,domain_pdu->u.token_inhibit_confirm.result);
  1057. pduLog(logfile,"\tInitiator User ID = %u\n",
  1058. domain_pdu->u.token_inhibit_confirm.initiator);
  1059. pduLog(logfile,"\tToken ID = %u\n",
  1060. domain_pdu->u.token_inhibit_confirm.token_id);
  1061. PrintTokenStatus(logfile,domain_pdu->u.token_inhibit_confirm.token_status);
  1062. }
  1063. /**************************************************************************/
  1064. void pduLogTokenGiveRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  1065. {
  1066. pduLog(logfile,"\tInitiator User ID = %u\n",
  1067. domain_pdu->u.token_give_request.initiator);
  1068. pduLog(logfile,"\tToken ID = %u\n",
  1069. domain_pdu->u.token_give_request.token_id);
  1070. pduLog(logfile,"\tRecipient User ID = %u\n",
  1071. domain_pdu->u.token_give_request.recipient);
  1072. }
  1073. /**************************************************************************/
  1074. void pduLogTokenGiveIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  1075. {
  1076. pduLog(logfile,"\tInitiator User ID = %u\n",
  1077. domain_pdu->u.token_give_indication.initiator);
  1078. pduLog(logfile,"\tToken ID = %u\n",
  1079. domain_pdu->u.token_give_indication.token_id);
  1080. pduLog(logfile,"\tRecipient User ID = %u\n",
  1081. domain_pdu->u.token_give_indication.recipient);
  1082. }
  1083. /**************************************************************************/
  1084. void pduLogTokenGiveResponse(FILE *logfile, PDomainMCSPDU domain_pdu)
  1085. {
  1086. pduLog(logfile,"\tResult: ");
  1087. PrintPDUResult(logfile,domain_pdu->u.token_give_response.result);
  1088. pduLog(logfile,"\tRecipient User ID = %u\n",
  1089. domain_pdu->u.token_give_response.recipient);
  1090. pduLog(logfile,"\tToken ID = %u\n",
  1091. domain_pdu->u.token_give_response.token_id);
  1092. }
  1093. /**************************************************************************/
  1094. void pduLogTokenGiveConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  1095. {
  1096. pduLog(logfile,"\tResult: ");
  1097. PrintPDUResult(logfile,domain_pdu->u.token_give_confirm.result);
  1098. pduLog(logfile,"\tInitiator User ID = %u\n",
  1099. domain_pdu->u.token_give_confirm.initiator);
  1100. pduLog(logfile,"\tToken ID = %u\n",
  1101. domain_pdu->u.token_give_confirm.token_id);
  1102. PrintTokenStatus(logfile,domain_pdu->u.token_give_confirm.token_status);
  1103. }
  1104. /**************************************************************************/
  1105. void pduLogTokenPleaseRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  1106. {
  1107. pduLog(logfile,"\tInitiator User ID = %u\n",
  1108. domain_pdu->u.token_please_request.initiator);
  1109. pduLog(logfile,"\tToken ID = %u\n",
  1110. domain_pdu->u.token_please_request.token_id);
  1111. }
  1112. /**************************************************************************/
  1113. void pduLogTokenPleaseIndication(FILE *logfile, PDomainMCSPDU domain_pdu)
  1114. {
  1115. pduLog(logfile,"\tInitiator User ID = %u\n",
  1116. domain_pdu->u.token_please_indication.initiator);
  1117. pduLog(logfile,"\tToken ID = %u\n",
  1118. domain_pdu->u.token_please_indication.token_id);
  1119. }
  1120. /**************************************************************************/
  1121. void pduLogTokenReleaseRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  1122. {
  1123. pduLog(logfile,"\tInitiator User ID = %u\n",
  1124. domain_pdu->u.token_release_request.initiator);
  1125. pduLog(logfile,"\tToken ID = %u\n",
  1126. domain_pdu->u.token_release_request.token_id);
  1127. }
  1128. /**************************************************************************/
  1129. void pduLogTokenReleaseConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  1130. {
  1131. pduLog(logfile,"\tResult: ");
  1132. PrintPDUResult(logfile,domain_pdu->u.token_release_confirm.result);
  1133. pduLog(logfile,"\tInitiator User ID = %u\n",
  1134. domain_pdu->u.token_release_confirm.initiator);
  1135. pduLog(logfile,"\tToken ID = %u\n",
  1136. domain_pdu->u.token_release_confirm.token_id);
  1137. PrintTokenStatus(logfile,domain_pdu->u.token_release_confirm.token_status);
  1138. }
  1139. /**************************************************************************/
  1140. void pduLogTokenTestRequest(FILE *logfile, PDomainMCSPDU domain_pdu)
  1141. {
  1142. pduLog(logfile,"\tInitiator User ID = %u\n",
  1143. domain_pdu->u.token_test_request.initiator);
  1144. pduLog(logfile,"\tToken ID = %u\n",
  1145. domain_pdu->u.token_test_request.token_id);
  1146. }
  1147. /**************************************************************************/
  1148. void pduLogTokenTestConfirm(FILE *logfile, PDomainMCSPDU domain_pdu)
  1149. {
  1150. pduLog(logfile,"\tInitiator User ID = %u\n",
  1151. domain_pdu->u.token_test_confirm.initiator);
  1152. pduLog(logfile,"\tToken ID = %u\n",
  1153. domain_pdu->u.token_test_confirm.token_id);
  1154. PrintTokenStatus(logfile,domain_pdu->u.token_test_confirm.token_status);
  1155. }
  1156. //****************************************************************/
  1157. /****
  1158. **** Service Functions for logging PDU structures.
  1159. ****/
  1160. /**************************************************************************/
  1161. void PrintSetOfUserIDs(FILE *logfile, PSetOfUserIDs user_ids)
  1162. {
  1163. unsigned int i = 0;
  1164. for(i=0; user_ids!=NULL; i++)
  1165. {
  1166. pduLog(logfile, "\t\trecord[%u] = %u\n",i,user_ids->value);
  1167. user_ids = user_ids->next;
  1168. }
  1169. }
  1170. /**************************************************************************/
  1171. void PrintSetOfTokenAttributes(FILE *logfile,
  1172. PSetOfPDUTokenAttributes token_attribute_obj)
  1173. {
  1174. unsigned int i = 0;
  1175. for(i=0; token_attribute_obj!=NULL;i++)
  1176. {
  1177. pduLog(logfile,"\t**** record [%u] ****\n",i);
  1178. PrintTokenAttributes(logfile, token_attribute_obj->value);
  1179. token_attribute_obj = token_attribute_obj->next;
  1180. }
  1181. }
  1182. /**************************************************************************/
  1183. void PrintSetOfChannelIDs(FILE *logfile, PSetOfChannelIDs channel_ids)
  1184. {
  1185. unsigned int i = 0;
  1186. for(i=0; channel_ids!=NULL; i++)
  1187. {
  1188. pduLog(logfile, "\t\trecord[%u] = %u\n",i,channel_ids->value);
  1189. channel_ids = channel_ids->next;
  1190. }
  1191. }
  1192. /**************************************************************************/
  1193. void PrintSetOfTokenIDs(FILE *logfile, PSetOfTokenIDs token_ids)
  1194. {
  1195. unsigned int i = 0;
  1196. for(i=0; token_ids!=NULL; i++)
  1197. {
  1198. pduLog(logfile, "\t\trecord[%u] = %u\n",i,token_ids->value);
  1199. token_ids = token_ids->next;
  1200. }
  1201. }
  1202. /**************************************************************************/
  1203. void PrintChannelAttributes(FILE *logfile, PDUChannelAttributes channel_attributes)
  1204. {
  1205. switch(channel_attributes.choice)
  1206. {
  1207. case CHANNEL_ATTRIBUTES_STATIC_CHOSEN:
  1208. pduLog(logfile, "\tStatic Channel Attributes:\n");
  1209. pduLog(logfile, "\t\tchannel_id = %u\n",
  1210. channel_attributes.u.channel_attributes_static.channel_id);
  1211. break;
  1212. case CHANNEL_ATTRIBUTES_USER_ID_CHOSEN:
  1213. pduLog(logfile, "\tUser ID Channel Attributes:\n");
  1214. PrintT120Boolean(logfile, "\t\tjoined",
  1215. (BOOL) channel_attributes.u.channel_attributes_user_id.joined);
  1216. pduLog(logfile, "\t\tuser_id = %u\n",
  1217. channel_attributes.u.channel_attributes_user_id.user_id);
  1218. break;
  1219. case CHANNEL_ATTRIBUTES_PRIVATE_CHOSEN:
  1220. pduLog(logfile,"\tPrivate Channel Attributes:\n");
  1221. PrintT120Boolean(logfile, "\t\tjoined",
  1222. (BOOL) channel_attributes.u.channel_attributes_private.joined);
  1223. pduLog(logfile,"\t\tchannel_id = %u\n",
  1224. channel_attributes.u.channel_attributes_private.channel_id);
  1225. pduLog(logfile,"\t\tmanager = %u\n",
  1226. channel_attributes.u.channel_attributes_private.manager);
  1227. PrintSetOfUserIDs(logfile, channel_attributes.u.channel_attributes_private.admitted);
  1228. break;
  1229. case CHANNEL_ATTRIBUTES_ASSIGNED_CHOSEN:
  1230. pduLog(logfile,"\tAssigned Channel Attributes\n");
  1231. pduLog(logfile,"\t\tchannel_id = %u\n",
  1232. channel_attributes.u.channel_attributes_assigned.channel_id);
  1233. break;
  1234. default:
  1235. pduLog(logfile,"\tERROR -- canot figure out channel attributes\n");
  1236. break;
  1237. }
  1238. }
  1239. /**************************************************************************/
  1240. void PrintTokenAttributes(FILE *logfile, PDUTokenAttributes token_attributes)
  1241. {
  1242. switch(token_attributes.choice)
  1243. {
  1244. case GRABBED_CHOSEN:
  1245. pduLog(logfile,"\tGrabbed Token Attributes:\n");
  1246. pduLog(logfile,"\t\ttoken_id = %u\n",
  1247. token_attributes.u.grabbed.token_id);
  1248. pduLog(logfile,"\t\tgrabber = %u\n",
  1249. token_attributes.u.grabbed.grabber);
  1250. break;
  1251. case INHIBITED_CHOSEN:
  1252. pduLog(logfile,"\tInhibited Token Attributes:\n");
  1253. pduLog(logfile,"\t\ttoken_id = %u\n",
  1254. token_attributes.u.inhibited.token_id);
  1255. pduLog(logfile,"\t\tInhibitors:\n");
  1256. PrintSetOfUserIDs(logfile,token_attributes.u.inhibited.inhibitors);
  1257. break;
  1258. case GIVING_CHOSEN:
  1259. pduLog(logfile,"\tGiving Token Attributes:\n");
  1260. pduLog(logfile,"\t\ttoken_id = %u\n",
  1261. token_attributes.u.giving.token_id);
  1262. pduLog(logfile,"\t\tgrabber = %u\n",
  1263. token_attributes.u.giving.grabber);
  1264. pduLog(logfile,"\t\trecipient = %u\n",
  1265. token_attributes.u.giving.recipient);
  1266. break;
  1267. case UNGIVABLE_CHOSEN:
  1268. pduLog(logfile,"\tUngivable Token Attributes:\n");
  1269. pduLog(logfile,"\t\ttoken_id = %u\n",
  1270. token_attributes.u.ungivable.token_id);
  1271. pduLog(logfile,"\t\tgrabber = %u\n",
  1272. token_attributes.u.ungivable.grabber);
  1273. break;
  1274. case GIVEN_CHOSEN:
  1275. pduLog(logfile,"\tGiven Token Attributes:\n");
  1276. pduLog(logfile,"\t\ttoken_id = %u\n",
  1277. token_attributes.u.given.token_id);
  1278. pduLog(logfile,"\t\trecipient = %u\n",
  1279. token_attributes.u.given.recipient);
  1280. break;
  1281. default:
  1282. pduLog(logfile,"ERROR: cannot determine token attributes\n");
  1283. break;
  1284. }
  1285. }
  1286. /**************************************************************************/
  1287. void PrintPDUDomainParameters(FILE *logfile, PDUDomainParameters domain_params)
  1288. {
  1289. pduLog(logfile,"\t\tmax_channel_ids = %u \n",domain_params.max_channel_ids);
  1290. pduLog(logfile,"\t\tmax_user_ids = %u\n",domain_params.max_user_ids);
  1291. pduLog(logfile,"\t\tmax_token_ids = %u\n",domain_params.max_token_ids);
  1292. pduLog(logfile,"\t\tnumber_priorities = %u\n",domain_params.number_priorities);
  1293. pduLog(logfile,"\t\tmin_throughput = %u\n",domain_params.min_throughput);
  1294. pduLog(logfile,"\t\tmax_height = %u\n",domain_params.max_height);
  1295. pduLog(logfile,"\t\tmax_mcspdu_size = %u\n",domain_params.max_mcspdu_size);
  1296. pduLog(logfile,"\t\tprotocol_version = %u\n",domain_params.protocol_version);
  1297. }
  1298. /**************************************************************************/
  1299. void PrintT120Boolean( FILE * logfile,
  1300. Char * print_text,
  1301. BOOL T120Boolean)
  1302. {
  1303. if( T120Boolean == FALSE )
  1304. pduLog( logfile, "%s = FALSE\n", print_text );
  1305. else
  1306. pduLog( logfile, "%s = TRUE\n", print_text );
  1307. }
  1308. /************************************************************************/
  1309. BOOL CopyTextToChar(char * print_string,
  1310. unsigned short * text_string_value,
  1311. unsigned int text_string_length)
  1312. {
  1313. UShort i;
  1314. if(print_string==NULL)
  1315. return(FALSE);
  1316. if((text_string_length <= 0)||(text_string_value == NULL))
  1317. return( FALSE );
  1318. if (*text_string_value == 0x0000)
  1319. return (FALSE);
  1320. for(i=0;i < text_string_length;i++)
  1321. {
  1322. //if((&text_string_value[i]==NULL) || (text_string_value[i]==0x0000))
  1323. // break;
  1324. print_string[i] = (char) text_string_value[i];
  1325. }
  1326. print_string[text_string_length] = '\0';
  1327. return(TRUE);
  1328. }
  1329. /********************************************************************/
  1330. #endif //// PDULOG