• AVR Freaks

List DHCP Servers leased clients IP addresses

New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2019/09/05 15:16:55
  • Location: 0
  • Status: offline
2019/09/07 11:35:29 (permalink)

List DHCP Servers leased clients IP addresses

I am using TCP/IP Stack version 7.31 on a PIC32MZ2048EFMH144 chip using Harmony Configurator
I am using the PIC as a DHCP Server to assign IP addresses to other client devices. This works correctly. What I am trying to do now is get a list of IP addresses that have been assigned out. Ideally is to get a list of current connected clients. I plan to iterate through the clients and query their states through either TCP or UDP. The problem I am having is getting the list of IP addresses from the DHCP Server (service) running. 
Running the following I can get the number of clients.
int tmpInt = TCPIP_DHCPS_GetPoolEntries(netH, DHCP_SERVER_POOL_ENTRY_IN_USE); // In Use clients
int tmpInt = TCPIP_DHCPS_GetPoolEntries(netH, DHCP_SERVER_POOL_ENTRY_ALL); // All clients
This returns a 2 for the two clients I have connected. Now I want their IP addresses.
To get their IP addresses, it appears that I need to use the command TCPIP_DHCPS_LeaseEntryGet() in dhcps.c.
This function returns a TCPIP_DHCPS_LEASE_HANDLE and also requires a TCPIP_DHCPS_LEASE_HANDLE as an argument. Since this is the only function that returns a TCPIP_DHCPS_LEASE_HANDLE, what do I pass to the function as an argument and where do I get it?

1 Reply Related Threads

    • Total Posts : 1209
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: List DHCP Servers leased clients IP addresses 2019/09/09 09:55:01 (permalink)
    Looking at the code, looks like the first value for the TCPIP_DHCPS_LEASE_HANDLE parameter could be 0.
    After that, use the returned value, until 0 is returned, meaning end of leases.
    But the description of the function is not clear, I agree.
    We'll fix it and provide an update.
    Thank you for reporting this.
    Jump to:
    © 2019 APG vNext Commercial Version 4.5