getAdapterAddress method

Pointer<IP_ADAPTER_ADDRESSES_LH>? getAdapterAddress(
  1. Pointer<GUID> pGuid,
  2. Pointer<IP_ADAPTER_ADDRESSES_LH> pIpAdapterAddresses
)

Implementation

Pointer<IP_ADAPTER_ADDRESSES_LH>? getAdapterAddress(Pointer<GUID> pGuid,
    Pointer<IP_ADAPTER_ADDRESSES_LH> pIpAdapterAddresses) {
  final ifLuid = calloc<NET_LUID_LH>();
  try {
    if (ConvertInterfaceGuidToLuid(pGuid, ifLuid) != NO_ERROR) {
      return null;
    }

    var pCurrent = pIpAdapterAddresses;
    while (pCurrent.address != 0) {
      if (pCurrent.ref.Luid.Value == ifLuid.ref.Value) {
        return pCurrent;
      }
      pCurrent = pCurrent.ref.Next;
    }
    return null;
  } finally {
    free(ifLuid);
  }
}