Exemplo n.º 1
0
 public static RoutingTableEntry ParseIpForwardTableEntry(NativeNetworkMethods.IPFORWARDROW row)
 {
     return(new RoutingTableEntry
     {
         destination = new IPAddress((long)row.dwForwardDest),
         subnetMask = new IPAddress((long)row.dwForwardMask),
         nextHop = new IPAddress((long)row.dwForwardNextHop),
         interfaceIndex = row.dwForwardIfIndex,
         type = row.dwForwardType,
         proto = row.dwForwardProto,
         age = row.dwForwardAge,
         metric = row.dwForwardMetric1
     });
 }
Exemplo n.º 2
0
        public static NativeNetworkMethods.IPForwardTable ReadIPForwardTable(IntPtr tablePtr)
        {
            var result = (NativeNetworkMethods.IPForwardTable)Marshal.PtrToStructure(tablePtr, typeof(NativeNetworkMethods.IPForwardTable));

            NativeNetworkMethods.IPFORWARDROW[] table = new NativeNetworkMethods.IPFORWARDROW[result.Size];
            IntPtr p = new IntPtr(tablePtr.ToInt64() + Marshal.SizeOf(result.Size));

            for (int i = 0; i < result.Size; ++i)
            {
                table[i] = (NativeNetworkMethods.IPFORWARDROW)Marshal.PtrToStructure(p, typeof(NativeNetworkMethods.IPFORWARDROW));
                p        = new IntPtr(p.ToInt64() + Marshal.SizeOf(typeof(NativeNetworkMethods.IPFORWARDROW)));
            }
            result.Table = table;

            return(result);
        }