diff --git a/RouteHelper/README.md b/RouteHelper/README.md new file mode 100644 index 00000000..01dce924 --- /dev/null +++ b/RouteHelper/README.md @@ -0,0 +1,29 @@ +# RouteHelper +```cpp +ULONG ConvertLuidToIndex(ULONG64 id); +BOOL CreateIPv4(const char* address, const char* netmask, ULONG index); +BOOL CreateUnicastIP(USHORT inet, const char* address, UINT8 cidr, ULONG index); +BOOL RefreshIPTable(USHORT inet, ULONG index); +BOOL CreateRoute(USHORT inet, const char* address, UINT8 cidr, const char* gateway, ULONG index, ULONG metric); +BOOL DeleteRoute(USHORT inet, const char* address, UINT8 cidr, const char* gateway, ULONG index, ULONG metric); +``` + +```csharp +[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl)] +public static extern ulong ConvertLuidToIndex(ulong id); + +[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl)] +public static extern bool CreateIPv4(string address, string netmask, ulong index); + +[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl)] +public static extern bool CreateUnicastIP(AddressFamily inet, string address, byte cidr, ulong index); + +[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl)] +public static extern bool RefreshIPTable(AddressFamily inet, ulong index); + +[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl)] +public static extern bool CreateRoute(AddressFamily inet, string address, byte cidr, string gateway, ulong index, ulong metric); + +[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl)] +public static extern bool CreateRoute(AddressFamily inet, string address, byte cidr, string gateway, ulong index, ulong metric); +``` diff --git a/RouteHelper/RouteHelper.cpp b/RouteHelper/RouteHelper.cpp index 6c2584e3..23620c01 100644 --- a/RouteHelper/RouteHelper.cpp +++ b/RouteHelper/RouteHelper.cpp @@ -16,7 +16,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv return TRUE; } -BOOL make(PMIB_IPFORWARD_ROW2 rule, USHORT inet, const char* address, UINT8 cidr, const char* gateway, ULONG index, int metric) +BOOL make(PMIB_IPFORWARD_ROW2 rule, USHORT inet, const char* address, UINT8 cidr, const char* gateway, ULONG index, ULONG metric) { rule->InterfaceIndex = index; rule->DestinationPrefix.PrefixLength = cidr; @@ -130,7 +130,7 @@ extern "C" { return (NO_ERROR == FlushIpNetTable2(inet, index)) ? TRUE : FALSE; } - __declspec(dllexport) BOOL __cdecl CreateRoute(USHORT inet, const char* address, UINT8 cidr, const char* gateway, ULONG index, int metric = 1) + __declspec(dllexport) BOOL __cdecl CreateRoute(USHORT inet, const char* address, UINT8 cidr, const char* gateway, ULONG index, ULONG metric = 1) { MIB_IPFORWARD_ROW2 rule; InitializeIpForwardEntry(&rule); @@ -143,7 +143,7 @@ extern "C" { return (NO_ERROR == CreateIpForwardEntry2(&rule)) ? TRUE : FALSE; } - __declspec(dllexport) BOOL __cdecl DeleteRoute(USHORT inet, const char* address, UINT8 cidr, const char* gateway, ULONG index, int metric = 1) + __declspec(dllexport) BOOL __cdecl DeleteRoute(USHORT inet, const char* address, UINT8 cidr, const char* gateway, ULONG index, ULONG metric = 1) { MIB_IPFORWARD_ROW2 rule; InitializeIpForwardEntry(&rule);