|
reSIProcate/rutil
9694
|
00001 #if !defined(resip_WinCompat_hxx) 00002 #define resip_WinCompat_hxx 00003 00004 #if defined(WIN32) 00005 #include <Iphlpapi.h> 00006 #include <list> 00007 00008 #include "rutil/BaseException.hxx" 00009 #include "rutil/Mutex.hxx" 00010 #include "rutil/GenericIPAddress.hxx" 00011 00012 namespace resip 00013 { 00014 00019 class WinCompat 00020 { 00021 public: 00022 //typedef enum Version 00023 // above is not valid C++ syntax 00024 enum Version 00025 { 00026 NotWindows, 00027 Windows95, 00028 Windows98, 00029 Windows98SE, 00030 WindowsME, 00031 WindowsNT, 00032 Windows2000, 00033 WindowsXP, 00034 Windows2003Server, 00035 WindowsUnknown 00036 }; 00037 00038 static Version getVersion(); 00039 00040 class Exception : public BaseException 00041 { 00042 public: 00043 Exception(const Data& msg, const Data& file, const int line); 00044 const char* name() const { return "TransportException"; } 00045 }; 00046 00047 static GenericIPAddress determineSourceInterface(const GenericIPAddress& destination); 00048 static std::list<std::pair<Data,Data> > getInterfaces(const Data& matching); 00049 static void destroyInstance(); 00050 00051 private: 00052 static WinCompat* instance(); 00053 static WinCompat* mInstance; 00054 00055 static GenericIPAddress WinCompat::determineSourceInterfaceWithIPv6(const GenericIPAddress& destination); 00056 static GenericIPAddress WinCompat::determineSourceInterfaceWithoutIPv6(const GenericIPAddress& destination); 00057 typedef DWORD (WINAPI * GetBestInterfaceExProc)(const sockaddr *, DWORD *); 00058 typedef DWORD (WINAPI * GetAdaptersAddressesProc)(ULONG, DWORD, VOID *, IP_ADAPTER_ADDRESSES *, ULONG *); 00059 typedef DWORD (WINAPI * GetAdaptersInfoProc)(PIP_ADAPTER_INFO, PULONG); 00060 00061 WinCompat(); 00062 ~WinCompat(); 00063 00064 GetBestInterfaceExProc getBestInterfaceEx; 00065 GetAdaptersAddressesProc getAdaptersAddresses; 00066 GetAdaptersInfoProc getAdaptersInfo; 00067 bool loadLibraryWithIPv4Failed; 00068 bool loadLibraryWithIPv6Failed; 00069 HMODULE hLib; 00070 }; 00071 00072 } 00073 00074 #endif // WIN32 00075 #endif
1.7.5.1