using System.Runtime.InteropServices;
namespace Netch
{
public static class NativeMethods
{
///
/// 分配 IP 地址
///
/// AF_INET / AF_INET6
/// 目标地址
/// CIDR
/// 适配器索引
/// 是否成功
[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CreateUnicastIP")]
public static extern bool CreateUnicastIP(int inet, string address, int cidr, int index);
///
/// 创建路由规则
///
/// AF_INET / AF_INET6
/// 目标地址
/// CIDR
/// 网关地址
/// 适配器索引
/// 跃点数
/// 是否成功
[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl, EntryPoint = "CreateRoute")]
public static extern bool CreateRoute(int inet, string address, int cidr, string gateway, int index, int metric = 0);
///
/// 删除路由规则
///
/// AF_INET / AF_INET6
/// 目标地址
/// 掩码地址
/// 网关地址
/// 适配器索引
/// 跃点数
/// 是否成功
[DllImport("RouteHelper.bin", CallingConvention = CallingConvention.Cdecl, EntryPoint = "DeleteRoute")]
public static extern bool DeleteRoute(int inet, string address, int cidr, string gateway, int index, int metric = 0);
[DllImport("dnsapi", EntryPoint = "DnsFlushResolverCache")]
public static extern uint FlushDNSResolverCache();
[DllImport("kernel32.dll")]
public static extern bool AllocConsole();
[DllImport("kernel32.dll")]
public static extern bool AttachConsole(int dwProcessId);
}
}