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.

106 lines
2.4 KiB

  1. // File: util.cpp
  2. //
  3. // General Utilities
  4. #include "precomp.h"
  5. #include "avcommon.h"
  6. #include "util.h"
  7. static BOOL VersionCheck(PCC_VENDORINFO pVendorInfo, LPCSTR pszVersion)
  8. {
  9. return (0 == _StrCmpN((char*)(pVendorInfo->pVersionNumber->pOctetString),
  10. pszVersion,
  11. pVendorInfo->pVersionNumber->wOctetStringLength));
  12. }
  13. static BOOL ProductCheck(PCC_VENDORINFO pVendorInfo, LPCSTR pszName)
  14. {
  15. BOOL fFound = FALSE;
  16. // Octet string may not be terminated allow for terminator
  17. int len = pVendorInfo->pProductNumber->wOctetStringLength + 1;
  18. char* pszPN = new char[len];
  19. if (NULL != pszPN)
  20. {
  21. lstrcpyn(pszPN, (char*)pVendorInfo->pProductNumber->pOctetString, len);
  22. fFound = (NULL != _StrStr(pszPN, pszName));
  23. delete[] pszPN;
  24. }
  25. return fFound;
  26. }
  27. H323VERSION GetH323Version(PCC_VENDORINFO pRemoteVendorInfo)
  28. {
  29. if (NULL == pRemoteVendorInfo)
  30. {
  31. return H323_Unknown;
  32. }
  33. // make sure we are dealing with a Microsoft product
  34. if ((pRemoteVendorInfo->bCountryCode != USA_H221_COUNTRY_CODE) ||
  35. (pRemoteVendorInfo->wManufacturerCode != MICROSOFT_H_221_MFG_CODE) ||
  36. (pRemoteVendorInfo->pProductNumber == NULL) ||
  37. (pRemoteVendorInfo->pVersionNumber == NULL)
  38. )
  39. {
  40. return H323_Unknown;
  41. }
  42. // redundant check to make sure we are a Microsoft H.323 product
  43. if (!ProductCheck(pRemoteVendorInfo, H323_COMPANYNAME_STR))
  44. {
  45. return H323_Unknown;
  46. }
  47. // check for NetMeeting in the string
  48. if (ProductCheck(pRemoteVendorInfo, H323_PRODUCTNAME_SHORT_STR))
  49. {
  50. if (VersionCheck(pRemoteVendorInfo, H323_20_PRODUCTRELEASE_STR))
  51. {
  52. return H323_NetMeeting20;
  53. }
  54. if (VersionCheck(pRemoteVendorInfo, H323_21_PRODUCTRELEASE_STR))
  55. {
  56. return H323_NetMeeting21;
  57. }
  58. if (VersionCheck(pRemoteVendorInfo, H323_21_SP1_PRODUCTRELEASE_STR))
  59. {
  60. return H323_NetMeeting21;
  61. }
  62. if (VersionCheck(pRemoteVendorInfo, H323_211_PRODUCTRELEASE_STR))
  63. {
  64. return H323_NetMeeting211;
  65. }
  66. if (VersionCheck(pRemoteVendorInfo, H323_30_PRODUCTRELEASE_STR))
  67. {
  68. return H323_NetMeeting30;
  69. }
  70. // must be future version of NetMeeting 3.1
  71. return H323_NetMeetingFuture;
  72. }
  73. // filter out TAPI v3.0
  74. // their version string is "Version 3.0"
  75. if (VersionCheck(pRemoteVendorInfo, H323_TAPI30_PRODUCTRELEASE_STR))
  76. {
  77. return H323_TAPI30;
  78. }
  79. // must be TAPI 3.1, or some other Microsoft product
  80. return H323_MicrosoftFuture;
  81. }