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.

140 lines
3.6 KiB

  1. #ifndef _ATLKADAPTER_H
  2. #define _ATLKADAPTER_H
  3. #include <windows.h>
  4. #include <atlbase.h>
  5. #include <winsock.h>
  6. #include <stdio.h>
  7. #include <tchar.h>
  8. #include <shlwapi.h>
  9. #include <vector>
  10. #include <string>
  11. using namespace std;
  12. typedef std::vector<wstring> TZoneListVector;
  13. #include "atalkwsh.h"
  14. #define ZONEBUFFER_LEN 32*255
  15. #define NDIS 0x01
  16. //registry constants
  17. // Registry Paths
  18. static const WCHAR c_szAtlk[] = L"AppleTalk";
  19. static const WCHAR c_szATLKParameters[] = L"System\\CurrentControlSet\\Services\\AppleTalk\\Parameters";
  20. static const WCHAR c_szATLKAdapters[] = L"System\\CurrentControlSet\\Services\\AppleTalk\\Parameters\\Adapters";
  21. static const WCHAR c_szATLKLinkage[] = L"System\\CurrentControlSet\\Services\\AppleTalk\\Linkage";
  22. // Values under AppleTalk\Parameters
  23. static const WCHAR c_szDefaultPort[] = L"DefaultPort"; // REG_SZ
  24. static const WCHAR c_szDesiredZone[] = L"DesiredZone"; // REG_SZ
  25. // Values under AppleTalk\Parameters\Adapters\<AdapterId>
  26. static const WCHAR c_szDefaultZone[] = L"DefaultZone"; // REG_SZ
  27. static const WCHAR c_szPortName[] = L"PortName"; // REG_SZ
  28. static const WCHAR c_szZoneList[] = L"ZoneList"; // REG_MULTI_SZ
  29. // Values under AppleTalk\Linkage
  30. static const WCHAR c_szRoute[] = L"Route"; // REG_MULTI_SZ
  31. typedef struct _ZONE_LIST
  32. {
  33. WCHAR szZone[200];
  34. }ZONE_LIST;
  35. typedef enum
  36. {
  37. AT_PNP_SWITCH_ROUTING = 0,
  38. AT_PNP_SWITCH_DEFAULT_ADAPTER,
  39. AT_PNP_RECONFIGURE_PARMS
  40. } ATALK_PNP_MSGTYPE;
  41. typedef struct _ATALK_PNP_EVENT
  42. {
  43. ATALK_PNP_MSGTYPE PnpMessage;
  44. } ATALK_PNP_EVENT, *PATALK_PNP_EVENT;
  45. class CAtlkAdapter
  46. {
  47. public:
  48. CAtlkAdapter(BSTR bstrAdapGuid)
  49. {
  50. m_bstrAdapGuid = bstrAdapGuid;
  51. // For each known adapter, create a device name by merging the "\\device\\"
  52. // prefix and the adapter's bind name.
  53. m_bstrPortName.Append(L"\\Device\\");
  54. m_bstrPortName.Append(m_bstrAdapGuid.m_str);
  55. m_bDefaultPort = FALSE;
  56. m_bNewDefPort = FALSE;
  57. m_bDefPortDirty = FALSE;
  58. m_bDesZoneDirty = FALSE;
  59. }
  60. HRESULT Initialize();
  61. VOID GetZoneList(TZoneListVector *pZonesList);
  62. BOOL GetDesiredZone(BSTR *bstrZoneName)
  63. {
  64. if(m_bstrDesiredZone && m_bstrDesiredZone.m_str[0] != _TEXT('\0'))
  65. {
  66. *bstrZoneName = SysAllocString(m_bstrDesiredZone.m_str);
  67. }
  68. else
  69. *bstrZoneName = SysAllocString(_TEXT(""));
  70. return TRUE;
  71. }
  72. BOOL IsDefaultPort()
  73. {
  74. return m_bDefaultPort;
  75. }
  76. HRESULT SetAsDefaultPort();
  77. HRESULT SetDesiredZone(BSTR bstrZoneName);
  78. private:
  79. CComBSTR m_bstrAdapGuid;
  80. CComBSTR m_bstrPortName;
  81. CComBSTR m_bstrDesiredZone;
  82. CComBSTR m_bstrNewDesiredZone;
  83. CComBSTR m_bstrDefZone;
  84. TZoneListVector m_ZonesList;
  85. BOOL m_bDefaultPort;
  86. BOOL m_bNewDefPort;
  87. BOOL m_bDefPortDirty;
  88. BOOL m_bDesZoneDirty;
  89. HRESULT UpdateZoneList();
  90. HRESULT UpdateZonesListFromSocket();
  91. HRESULT UpdateDefZonesFromSocket ( SOCKET socket );
  92. HRESULT UpdateDefZonesToZoneList(CHAR * szZoneList, ULONG NumZones);
  93. VOID UpdateDesiredZone();
  94. BOOL GetDesiredZoneFromReg();
  95. HRESULT AtlkReconfig();
  96. HRESULT SetDefaultPortInReg();
  97. HRESULT SetDesiredZoneInReg();
  98. HRESULT ValidateAdapGuid();
  99. };
  100. #endif