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.

390 lines
9.9 KiB

  1. /*
  2. - DEBUG.CPP
  3. -
  4. * Microsoft NetMeeting
  5. * Quality of Service DLL
  6. * Debug code
  7. *
  8. * Revision History:
  9. *
  10. * When Who What
  11. * -------- ------------------ ---------------------------------------
  12. * 10.23.96 Yoram Yaacovi Created
  13. * 01.04.97 Robert Donner Added NetMeeting utility routines
  14. * 01.09.97 Yoram Yaacovi Added DisplayRequestList
  15. *
  16. * Functions:
  17. * DisplayQoSObject
  18. * DisplayRequestList
  19. * DisplayRequestListInt
  20. *
  21. */
  22. #include "precomp.h"
  23. #ifdef DEBUG
  24. int QoSDbgPrintf(LPCSTR lpszFormat, ...)
  25. {
  26. va_list v1;
  27. va_start(v1, lpszFormat);
  28. DbgPrintf("QoS:", lpszFormat, v1);
  29. va_end(v1);
  30. return 0;
  31. }
  32. /***************************************************************************
  33. Name : DisplayParameters
  34. Purpose : Displays parameters of a given function
  35. Parameters: nFunctionID - ID of the function for which to display parameters
  36. p1 - p5: up to 5 32-bit function parameters
  37. Returns :
  38. Comment :
  39. ***************************************************************************/
  40. void CQoS::DisplayParameters(ULONG nFunctionID, ULONG_PTR p1, ULONG_PTR p2, ULONG_PTR p3, ULONG_PTR p4, ULONG_PTR p5)
  41. {
  42. BOOL fDisplay=FALSE;
  43. TCHAR szGuid[40 /* CCHSZGUID */];
  44. fDisplay = (m_bInNotify ?
  45. (ZONE_THREAD && ZONE_PARAMETERS) :
  46. ZONE_PARAMETERS);
  47. if (!fDisplay)
  48. return;
  49. switch (nFunctionID)
  50. {
  51. case REQUEST_RESOURCES_ID:
  52. GuidToSz((LPGUID) p1 /* lpClientGUID */, szGuid);
  53. DEBUGMSG(fDisplay, ("Client: %s\n", szGuid));
  54. DisplayRequestList((LPRESOURCEREQUESTLIST) p2 /* lpResourceRequestList */);
  55. break;
  56. case RELEASE_RESOURCES_ID:
  57. GuidToSz((LPGUID) p1 /* lpClientGUID */, szGuid);
  58. DEBUGMSG(fDisplay, ("Client: %s\n", szGuid));
  59. DisplayRequestList((LPRESOURCEREQUESTLIST) p2 /* lpResourceRequestList */);
  60. break;
  61. case SET_RESOURCES_ID:
  62. DisplayResourceList((LPRESOURCELIST) p1 /* lpResourceList */);
  63. break;
  64. case SET_CLIENTS_ID:
  65. DisplayClientList((LPCLIENTLIST) p1 /* lpClientList */);
  66. break;
  67. default:
  68. break;
  69. }
  70. }
  71. /***************************************************************************
  72. Name : DisplayClientList
  73. Purpose : Displays a client list given a pointer to the list
  74. Parameters: pCl - pointer to the list
  75. Returns :
  76. Comment :
  77. ***************************************************************************/
  78. void CQoS::DisplayClientList(LPCLIENTLIST pcl)
  79. {
  80. BOOL fDisplay=FALSE;
  81. ULONG i=0;
  82. LPCLIENT pc=NULL;
  83. TCHAR szGuid[40 /* CCHSZGUID */];
  84. char szNoName[]="No Name";
  85. PSTR pszClientName=szNoName;
  86. fDisplay = (m_bInNotify ? (ZONE_THREAD && ZONE_PARAMETERS) : ZONE_PARAMETERS);
  87. DEBUGMSG(fDisplay, ("Number of clients: %d\n", pcl->cClients));
  88. DEBUGMSG(fDisplay, ("Client priority GUID\n"));
  89. for (i=0; i < pcl->cClients; i++)
  90. {
  91. pc = &(pcl->aClients[i]);
  92. GuidToSz(&(pc->guidClientGUID), szGuid);
  93. // assuming DEBUGMSG always prints non-Unicode
  94. if (*(pc->wszName) && (pszClientName = UnicodeToAnsi(pc->wszName)))
  95. {
  96. // display the client
  97. DEBUGMSG(fDisplay, (" %-20s%-9d %s",
  98. pszClientName,
  99. pc->priority,
  100. szGuid));
  101. delete pszClientName;
  102. }
  103. else
  104. {
  105. pszClientName = szNoName;
  106. // display the client
  107. DEBUGMSG(fDisplay, (" %-20s%-9d %s",
  108. pszClientName,
  109. pc->priority,
  110. szGuid));
  111. }
  112. }
  113. }
  114. /***************************************************************************
  115. Name : DisplayResourceList
  116. Purpose : Displays a resource list given a pointer to the list
  117. Parameters: prl - pointer to the list
  118. Returns :
  119. Comment :
  120. ***************************************************************************/
  121. void CQoS::DisplayResourceList(LPRESOURCELIST prl)
  122. {
  123. BOOL fDisplay=FALSE;
  124. ULONG i=0;
  125. LPRESOURCE pr=NULL;
  126. fDisplay = (m_bInNotify ? (ZONE_THREAD && ZONE_PARAMETERS) : ZONE_PARAMETERS);
  127. DEBUGMSG(fDisplay, ("Number of resources: %d\n", prl->cResources));
  128. DEBUGMSG(fDisplay, ("Resource Flags MinUnits MaxUnits Level hResult\n"));
  129. for (i=0; i < prl->cResources; i++)
  130. {
  131. pr = &(prl->aResources[i]);
  132. // display the resource
  133. DEBUGMSG(fDisplay, (" %-10d%-8x%-9d",
  134. pr->resourceID,
  135. pr->ulResourceFlags,
  136. pr->nUnits));
  137. }
  138. }
  139. /***************************************************************************
  140. Name : DisplayRequestList
  141. Purpose : Displays a request list given a pointer to the list
  142. Parameters: prrl - pointer to the list
  143. Returns :
  144. Comment :
  145. ***************************************************************************/
  146. void CQoS::DisplayRequestList(LPRESOURCEREQUESTLIST prrl)
  147. {
  148. BOOL fDisplay=FALSE;
  149. ULONG i=0;
  150. LPRESOURCEREQUEST prr=NULL;
  151. fDisplay = (m_bInNotify ? (ZONE_THREAD && ZONE_PARAMETERS) : ZONE_PARAMETERS);
  152. DEBUGMSG(fDisplay, ("Number of requests: %d\n", prrl->cRequests));
  153. DEBUGMSG(fDisplay, ("Resource Flags MinUnits MaxUnits Level hResult\n"));
  154. for (i=0; i < prrl->cRequests; i++)
  155. {
  156. prr = &(prrl->aRequests[i]);
  157. // display the resource
  158. DEBUGMSG(fDisplay, (" %-10d%-8x%-9d%-9d%-6d%-8x",
  159. prr->resourceID,
  160. prr->ulRequestFlags,
  161. prr->nUnitsMin,
  162. prr->nUnitsMax,
  163. prr->levelOfGuarantee,
  164. prr->hResult));
  165. }
  166. }
  167. /***************************************************************************
  168. Name : DisplayRequestListInt
  169. Purpose : Displays an internal request list given a pointer to the list
  170. Parameters: prr - pointer to the first request in the list
  171. fDisplay - a flag to tell DisplayRequestListInt whether to display
  172. or no. This might seem dumb, since why call DisplayRequestListInt
  173. if it's not going to display, but this parameter really conveys
  174. the zone information that thcaller wants.
  175. Returns :
  176. Comment :
  177. ***************************************************************************/
  178. void CQoS::DisplayRequestListInt(LPRESOURCEREQUESTINT prr, BOOL fDisplay)
  179. {
  180. TCHAR szGuid[40 /* CCHSZGUID */];
  181. while (prr)
  182. {
  183. GuidToSz(&(prr->guidClientGUID), szGuid);
  184. // display the resource
  185. DEBUGMSG(fDisplay, (" %-10x%-10x%-10d%-8x%-6d%-7d%-11x %s",
  186. prr,
  187. prr->fLink,
  188. prr->sResourceRequest.resourceID,
  189. prr->sResourceRequest.ulRequestFlags,
  190. prr->sResourceRequest.levelOfGuarantee,
  191. prr->sResourceRequest.nUnitsMin,
  192. prr->pfnQoSNotify,
  193. szGuid));
  194. // next request
  195. prr = prr->fLink;
  196. }
  197. }
  198. /***************************************************************************
  199. Name : DisplayQoSObject
  200. Purpose : Displays the containing QoS object
  201. Parameters: none
  202. Returns : none
  203. Comment :
  204. ***************************************************************************/
  205. void CQoS::DisplayQoSObject(void)
  206. {
  207. LPRESOURCEINT pr=NULL;
  208. LPRESOURCEREQUESTINT prr=NULL;
  209. LPCLIENTINT pc=NULL;
  210. BOOL fDisplay=FALSE;
  211. // don't waste time if we are not going to print
  212. fDisplay = (m_bInNotify ? (ZONE_THREAD && ZONE_STRUCTURES) : ZONE_STRUCTURES);
  213. if (!fDisplay)
  214. return;
  215. DEBUGMSG(fDisplay, ("Start object display\n"));
  216. DEBUGMSG(fDisplay, ("=========================================\n"));
  217. /*
  218. * Print resources and requests
  219. */
  220. DEBUGMSG(fDisplay, ("Resources\n"));
  221. DEBUGMSG(fDisplay, ("*********\n"));
  222. pr = m_pResourceList;
  223. if (!pr)
  224. {
  225. DEBUGMSG(fDisplay, ("No Resources\n"));
  226. }
  227. else
  228. {
  229. DEBUGMSG(fDisplay, ("Address fLink Resource Flags Units Avail\n"));
  230. DEBUGMSG(fDisplay, (" Address fLink Resource Flags Level Units NotifyProc Client GUID\n"));
  231. }
  232. while (pr)
  233. {
  234. // display the resource
  235. DEBUGMSG(fDisplay, ("Resource: %d\n", pr->resource.resourceID));
  236. DEBUGMSG(fDisplay, ("%-10x%-10x%-10d%-8x%-7d%-7d\n",
  237. pr,
  238. pr->fLink,
  239. pr->resource.resourceID,
  240. pr->resource.ulResourceFlags,
  241. pr->resource.nUnits,
  242. pr->nNowAvailUnits));
  243. // display the request list for this reasource
  244. prr = pr->pRequestList;
  245. DisplayRequestListInt(prr, fDisplay);
  246. //next resource
  247. pr = pr->fLink;
  248. }
  249. /*
  250. * Print clients
  251. */
  252. DEBUGMSG(fDisplay, ("\n"));
  253. DEBUGMSG(fDisplay, ("Clients\n"));
  254. DEBUGMSG(fDisplay, ("*******\n"));
  255. pc = m_pClientList;
  256. if (!pc)
  257. {
  258. DEBUGMSG(fDisplay, ("No Clients\n"));
  259. }
  260. else
  261. {
  262. DEBUGMSG(fDisplay, ("Address fLink Priority\n"));
  263. DEBUGMSG(fDisplay, (" Address fLink Resource Flags Level Units NotifyProc Client GUID\n"));
  264. }
  265. while (pc)
  266. {
  267. TCHAR szGuid[40 /* CCHSZGUID */];
  268. PSTR pszClientName=NULL;
  269. GuidToSz(&(pc->client.guidClientGUID), szGuid);
  270. // update the list of requests for this client
  271. // doing this if in the notify thread is bad !!
  272. if (!m_bInNotify)
  273. UpdateRequestsForClient (&(pc->client.guidClientGUID));
  274. // display the client
  275. // assuming DEBUGMSG always prints non-Unicode
  276. if (*(pc->client.wszName) &&
  277. (pszClientName = UnicodeToAnsi(pc->client.wszName)))
  278. {
  279. DEBUGMSG(fDisplay, ("Client: %s %s", pszClientName, szGuid));
  280. delete pszClientName;
  281. }
  282. else
  283. {
  284. DEBUGMSG(fDisplay, ("Client: %s", szGuid));
  285. }
  286. DEBUGMSG(fDisplay, ("%-10x%-10x%-10d",
  287. pc, pc->fLink, pc->client.priority));
  288. // display the request list for this reasource
  289. prr = pc->pRequestList;
  290. DisplayRequestListInt(prr, fDisplay);
  291. //next resource
  292. pc = pc->fLink;
  293. }
  294. DEBUGMSG(fDisplay, ("=========================================\n"));
  295. DEBUGMSG(fDisplay, ("End object display\n"));
  296. }
  297. #else // DEBUG
  298. void CQoS::DisplayQoSObject(void)
  299. {}
  300. void CQoS::DisplayRequestList(LPRESOURCEREQUESTLIST)
  301. {}
  302. void CQoS::DisplayRequestListInt(LPRESOURCEREQUESTINT, BOOL)
  303. {}
  304. void CQoS::DisplayResourceList(LPRESOURCELIST prl)
  305. {}
  306. void CQoS::DisplayParameters(ULONG nFunctionID, ULONG_PTR P1, ULONG_PTR P2, ULONG_PTR P3, ULONG_PTR P4, ULONG_PTR P5)
  307. {}
  308. #endif // DEBUG