CodeCowboy.NetworkRoute 1.0.0

dotnet add package CodeCowboy.NetworkRoute --version 1.0.0
NuGet\Install-Package CodeCowboy.NetworkRoute -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeCowboy.NetworkRoute" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodeCowboy.NetworkRoute --version 1.0.0
#r "nuget: CodeCowboy.NetworkRoute, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CodeCowboy.NetworkRoute as a Cake Addin
#addin nuget:?package=CodeCowboy.NetworkRoute&version=1.0.0

// Install CodeCowboy.NetworkRoute as a Cake Tool
#tool nuget:?package=CodeCowboy.NetworkRoute&version=1.0.0

Ip4RouteTable

Windows IP4 Routing Table using WinAPI Calls Mimicking the functionality of "route add" and "route delete" in C#

Sample Usage

        static void Main(string[] args)
        {
            try
            {
                //Print all the Network adaptors
                NicInterface.PrintAllNetworkInterface();
                //Print the Routing Table
                Ip4RouteTable.RoutePrint();

                //Demostrate Deleting routes and Adding routes
                int interfaceIndex = 42; // Int32.Parse(args[0]);
                NetworkAdaptor na = NicInterface.GetNetworkAdaptor(interfaceIndex);
                if (na != null && na.PrimaryGateway.Address.ToString().Length > 0)
                {
                    Ip4RouteTable.DeleteRoute(interfaceIndex);
                    Ip4RouteTable.DeleteRoute("10.100.0.0");
                    Ip4RouteTable.CreateRoute("202.0.0.0", "255.0.0.0", interfaceIndex, 100);
                }
            }
            catch
            {

            }
        }

Uses the WinAPI DLLs

        internal struct PMIB_IPFORWARDROW
        {
            internal uint /*DWORD*/ dwForwardDest;
            internal uint /*DWORD*/ dwForwardMask;
            internal uint /*DWORD*/ dwForwardPolicy;
            internal uint /*DWORD*/ dwForwardNextHop;
            internal uint /*DWORD*/ dwForwardIfIndex;
            internal uint /*DWORD*/ dwForwardType;
            internal uint /*DWORD*/ dwForwardProto;
            internal uint /*DWORD*/ dwForwardAge;
            internal uint /*DWORD*/ dwForwardNextHopAS;
            internal uint /*DWORD*/ dwForwardMetric1;
            internal uint /*DWORD*/ dwForwardMetric2;
            internal uint /*DWORD*/ dwForwardMetric3;
            internal uint /*DWORD*/ dwForwardMetric4;
            internal uint /*DWORD*/ dwForwardMetric5;
        };
        
    internal static class NativeMethods
    {
        [DllImport("iphlpapi", CharSet = CharSet.Auto)]
        public extern static int GetIpForwardTable(IntPtr /*PMIB_IPFORWARDTABLE*/ pIpForwardTable, ref int /*PULONG*/ pdwSize, bool bOrder);

        [DllImport("iphlpapi", CharSet = CharSet.Auto)]
        //public extern static int CreateIpForwardEntry(ref /*PMIB_IPFORWARDROW*/ Ip4RouteTable.PMIB_IPFORWARDROW pRoute);  Can do by reference or by Pointer
        public extern static int CreateIpForwardEntry(IntPtr /*PMIB_IPFORWARDROW*/ pRoute);

        [DllImport("iphlpapi", CharSet = CharSet.Auto)]
        public extern static int DeleteIpForwardEntry(IntPtr /*PMIB_IPFORWARDROW*/ pRoute);
    }        
''''
Product Compatible and additional computed target framework versions.
.NET Framework net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 1,222 9/15/2019

Initial Release