private static DhcpServerClient GetClientVQ(DhcpServer Server, IntPtr SearchInfo) { try { IntPtr clientPtr; DhcpErrors result = Api.DhcpGetClientInfoVQ(Server.ipAddress.ToString(), SearchInfo, out clientPtr); if (result == DhcpErrors.JET_ERROR) { return(null); } if (result != DhcpErrors.SUCCESS) { throw new DhcpServerException("DhcpGetClientInfoVQ", result); } try { var client = (DHCP_CLIENT_INFO_VQ)Marshal.PtrToStructure(clientPtr, typeof(DHCP_CLIENT_INFO_VQ)); return(DhcpServerClient.FromNative(Server, client)); } finally { Api.DhcpRpcFreeMemory(clientPtr); } } finally { Marshal.FreeHGlobal(SearchInfo); } }
private static IEnumerable <DhcpServerClient> GetClientsVQ(DhcpServer Server, DHCP_IP_ADDRESS SubnetAddress) { IntPtr clientsPtr; IntPtr resultHandle = IntPtr.Zero; int clientsRead, clientsTotal; DhcpErrors result = Api.DhcpEnumSubnetClientsVQ(Server.ipAddress.ToString(), SubnetAddress, ref resultHandle, 65536, out clientsPtr, out clientsRead, out clientsTotal); if (result != DhcpErrors.SUCCESS && result != DhcpErrors.ERROR_MORE_DATA) { throw new DhcpServerException("DhcpEnumSubnetClientsVQ", result); } while (result == DhcpErrors.SUCCESS || result == DhcpErrors.ERROR_MORE_DATA) { try { using (var clients = DHCP_CLIENT_INFO_ARRAY_VQ.Read(clientsPtr)) { foreach (var client in clients.Clients) { yield return(DhcpServerClient.FromNative(Server, client.Item2)); } } } finally { Api.DhcpRpcFreeMemory(clientsPtr); clientsPtr = IntPtr.Zero; } if (result == DhcpErrors.SUCCESS) { yield break; // Last results } clientsRead = 0; clientsTotal = 0; result = Api.DhcpEnumSubnetClientsVQ(Server.ipAddress.ToString(), SubnetAddress, ref resultHandle, 65536, out clientsPtr, out clientsRead, out clientsTotal); if (result != DhcpErrors.SUCCESS && result != DhcpErrors.ERROR_MORE_DATA) { throw new DhcpServerException("DhcpEnumSubnetClientsVQ", result); } } }
private static IEnumerable <DhcpServerClient> GetClientsV5(DhcpServer Server, DHCP_IP_ADDRESS SubnetAddress) { IntPtr clientsPtr; IntPtr resultHandle = IntPtr.Zero; int clientsRead, clientsTotal; DhcpErrors result = Api.DhcpEnumSubnetClientsV5(Server.ipAddress.ToString(), SubnetAddress, ref resultHandle, 65536, out clientsPtr, out clientsRead, out clientsTotal); if (result != DhcpErrors.SUCCESS && result != DhcpErrors.ERROR_MORE_DATA && result != DhcpErrors.ERROR_NO_MORE_ITEMS) { throw new DhcpServerException("DhcpEnumSubnetClientsV5", result); } while (result == DhcpErrors.SUCCESS || result == DhcpErrors.ERROR_MORE_DATA) { try { var clients = (DHCP_CLIENT_INFO_ARRAY_V5)Marshal.PtrToStructure(clientsPtr, typeof(DHCP_CLIENT_INFO_ARRAY_V5)); foreach (var client in clients.Clients) { yield return(DhcpServerClient.FromNative(Server, client)); } } finally { Api.DhcpRpcFreeMemory(clientsPtr); } if (result == DhcpErrors.SUCCESS) { yield break; // Last results } result = Api.DhcpEnumSubnetClientsV5(Server.ipAddress.ToString(), SubnetAddress, ref resultHandle, 65536, out clientsPtr, out clientsRead, out clientsTotal); if (result != DhcpErrors.SUCCESS && result != DhcpErrors.ERROR_MORE_DATA && result != DhcpErrors.ERROR_NO_MORE_ITEMS) { throw new DhcpServerException("DhcpEnumSubnetClientsV5", result); } } }
public IDhcpServerClient AddClient(DhcpServerIpAddress address, DhcpServerHardwareAddress hardwareAddress, string name, string comment, DateTime leaseExpires, IDhcpServerHost ownerHost) => DhcpServerClient.CreateClient(Scope, address, hardwareAddress, name, comment, leaseExpires, (DhcpServerHost)ownerHost);
public IDhcpServerClient AddClient(DhcpServerIpAddress address, DhcpServerHardwareAddress hardwareAddress, string name, string comment, DateTime leaseExpires, IDhcpServerHost ownerHost, DhcpServerClientTypes clientType, DhcpServerClientAddressStates addressState, DhcpServerClientQuarantineStatuses quarantineStatus, DateTime probationEnds, bool quarantineCapable) => DhcpServerClient.CreateClient(Scope, address, hardwareAddress, name, comment, leaseExpires, (DhcpServerHost)ownerHost, clientType, addressState, quarantineStatus, probationEnds, quarantineCapable);
public IDhcpServerClient AddClient(DhcpServerIpAddress address, DhcpServerHardwareAddress hardwareAddress, string name, string comment) => DhcpServerClient.CreateClient(Scope, address, hardwareAddress, name, comment);
public IDhcpServerClient AddClient(DhcpServerIpAddress address, DhcpServerHardwareAddress hardwareAddress) => DhcpServerClient.CreateClient(Scope, address, hardwareAddress);
public IEnumerator <IDhcpServerClient> GetEnumerator() => DhcpServerClient.GetScopeClients(Scope).GetEnumerator();
private DhcpServerClient GetClient() { return(DhcpServerClient.GetClient(Server, ipAddress)); }
public IEnumerator <IDhcpServerClient> GetEnumerator() => DhcpServerClient.GetClients(Server).GetEnumerator();