示例#1
0
        public static MIB_IPINTERFACE_ROW GetIpInterfaceEntry(Guid InterfaceGuid, ADDRESS_FAMILY Family)
        {
            MIB_IPINTERFACE_ROW pIpRow = new MIB_IPINTERFACE_ROW();

            ConvertInterfaceGuidToLuid(ref InterfaceGuid, out NET_LUID NetLUID);
            pIpRow.InterfaceLuid = NetLUID;
            pIpRow.Family        = Family; // ADDRESS_FAMILY.AF_INET || ADDRESS_FAMILY.AF_INET6
            uint result = GetIpInterfaceEntry(ref pIpRow);

            if (result != 0)
            {
                Trace.WriteLine("GetIpInterfaceEntry");
            }
            PrintErrorResult(result);
            return(pIpRow);
        }
示例#2
0
        public MIB_IPINTERFACE_TABLE(IntPtr pTable)
        {
            NumEntries = (uint)Marshal.ReadInt32(pTable, 0);
            Table      = new MIB_IPINTERFACE_ROW[NumEntries];
            for (int i = 0; i < NumEntries; i++)
            {
                // The offset of the array of structures is 8 bytes past the beginning. Then, take the index and multiply it by the number of bytes in the structure.
                // the length of the MIB_IPINTERFACE_ROW structure is 168 bytes - this was determined by doing a sizeof(MIB_IPINTERFACE_ROW) in an unmanaged C++ app.
                IntPtr pItemList = new IntPtr(pTable.ToInt64() + (i * 168) + 8);

                // Construct the MIB_IPINTERFACE_ROW structure, marshal the unmanaged structure into it, then copy it to the array of structures.
                MIB_IPINTERFACE_ROW Row = new MIB_IPINTERFACE_ROW();
                Row      = (MIB_IPINTERFACE_ROW)Marshal.PtrToStructure(pItemList, typeof(MIB_IPINTERFACE_ROW));
                Table[i] = Row;
            }
        }
示例#3
0
 private static extern uint GetIpInterfaceEntry([In, Out] ref MIB_IPINTERFACE_ROW Row);