dhcp.h 847 B

1234567891011121314151617181920
  1. /* Minimal DHCP client (RFC 2131): DISCOVER -> OFFER -> REQUEST -> ACK over
  2. * UDP broadcast, so a board with a NIC gets an address at boot.
  3. *
  4. * Runs before the WM loop (bounded to a few seconds) and on demand with the
  5. * `dhcp` command. On failure the previously configured address is kept (the
  6. * static default), so nothing depends on a DHCP server being present. */
  7. #ifndef DHCP_H
  8. #define DHCP_H
  9. /* Run the client with an overall time budget. Returns:
  10. * 0 = an address was obtained and applied (net_configure),
  11. * -1 = no server answered (configuration unchanged),
  12. * -2 = protocol error / no NIC. */
  13. int dhcp_run(unsigned int timeout_ms);
  14. /* Info from the last successful run (server id + lease seconds). Returns 1
  15. * if a lease has been obtained. */
  16. int dhcp_last_info(unsigned char server[4], unsigned int *lease_s);
  17. #endif