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.

129 lines
2.2 KiB

  1. //
  2. // MyAdapterNotify.cpp : Implementation of CMyALG
  3. //
  4. // Call back class for notification of adapter added, removed or modified
  5. //
  6. #include "PreComp.h"
  7. #include "MyAdapterNotify.h"
  8. /////////////////////////////////////////////////////////////////////////////
  9. //
  10. // CMyAdapterNotify
  11. //
  12. //
  13. // This function will be call when a new adapter is made active
  14. //
  15. STDMETHODIMP
  16. CMyAdapterNotify::AdapterAdded(
  17. IAdapterInfo* pAdapter
  18. )
  19. {
  20. MYTRACE_ENTER("CMyAdapterNotify::AdapterAdded");
  21. ULONG ulIndex;
  22. HRESULT hr = pAdapter->GetAdapterIndex(&ulIndex);
  23. if ( SUCCEEDED(hr) )
  24. {
  25. MYTRACE("Adapter Index %d", ulIndex);
  26. }
  27. else
  28. {
  29. MYTRACE_ERROR("On GetAdapterIndex", hr);
  30. }
  31. ALG_ADAPTER_TYPE eType;
  32. hr = pAdapter->GetAdapterType(&eType);
  33. if ( SUCCEEDED(hr) )
  34. {
  35. MYTRACE("Adapter Type %d", eType);
  36. }
  37. else
  38. {
  39. MYTRACE_ERROR("On GetAdapterType", hr);
  40. }
  41. return S_OK;
  42. }
  43. //
  44. // This function will be call when a adapter is remove and/or disable
  45. //
  46. STDMETHODIMP
  47. CMyAdapterNotify::AdapterRemoved(
  48. IAdapterInfo* pAdapter
  49. )
  50. {
  51. MYTRACE_ENTER("CMyAdapterNotify::AdapterRemoved");
  52. ULONG ulIndex;
  53. HRESULT hr = pAdapter->GetAdapterIndex(&ulIndex);
  54. if ( SUCCEEDED(hr) )
  55. {
  56. MYTRACE("Adapter Index %d", ulIndex);
  57. }
  58. else
  59. {
  60. MYTRACE_ERROR("On GetAdapterIndex", hr);
  61. }
  62. return S_OK;
  63. }
  64. //
  65. // This function will be call when a adapter is modified
  66. //
  67. STDMETHODIMP
  68. CMyAdapterNotify::AdapterModified(
  69. IAdapterInfo* pAdapter
  70. )
  71. {
  72. MYTRACE_ENTER("CMyAdapterNotify::AdapterModified");
  73. ULONG nIndex;
  74. HRESULT hr = pAdapter->GetAdapterIndex(
  75. &nIndex
  76. );
  77. MYTRACE("For Adapter INDEX %d", nIndex);
  78. ULONG nAddressCount;
  79. ULONG* pnAddresses;
  80. hr = pAdapter->GetAdapterAddresses(
  81. &nAddressCount,
  82. &pnAddresses
  83. );
  84. if ( SUCCEEDED(hr) )
  85. {
  86. for ( ULONG nI=0; nI < nAddressCount; nI++ )
  87. {
  88. MYTRACE("Address %s", MYTRACE_IP(pnAddresses[nI]));
  89. }
  90. }
  91. else
  92. {
  93. MYTRACE_ERROR("Could not get the addresss", hr);
  94. }
  95. CoTaskMemFree(pnAddresses);
  96. return S_OK;
  97. }