diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-11-20 23:06:13 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-12-14 14:30:16 +0100 |
commit | 528298b702a0ad238dd01b3497f7c0bb671bf7c9 (patch) | |
tree | de45aac980aca35e3761921449728afadd033f77 /include | |
parent | 6b4a38d00255149c63277100ed1a3f5f95ab2e75 (diff) | |
download | barebox-528298b702a0ad238dd01b3497f7c0bb671bf7c9.tar.gz barebox-528298b702a0ad238dd01b3497f7c0bb671bf7c9.tar.xz |
net: dhcp: rework
The DHCP code is a mess. It is not clear which options are sent to the
server and which options are returned from the server. Also environment
variables are read from and written to all over the place.
This patch cleans this up. There now is struct dhcp_req_param which is
used for options sent to the server and struct dhcp_result which contains
the values sent from the server. The values from the server are written
to the barebox variables in a single place. Also it's now possible to
call the dhcp code without modifying barebox variables at all, storing
the result only in the dhcp result struct.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/dhcp.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/include/dhcp.h b/include/dhcp.h index 20a523250f..0977ff42da 100644 --- a/include/dhcp.h +++ b/include/dhcp.h @@ -18,10 +18,30 @@ struct dhcp_req_param { char *client_id; char *user_class; char *client_uuid; + int retries; +}; + +struct dhcp_result { + IPaddr_t ip; + IPaddr_t netmask; + IPaddr_t gateway; + IPaddr_t nameserver; + IPaddr_t serverip; + char *hostname; + char *domainname; + char *rootpath; + char *devicetree; + char *bootfile; + char *tftp_server_name; + uint32_t leasetime; }; struct eth_device; -int dhcp(struct eth_device *edev, int retries, struct dhcp_req_param *param); +int dhcp_request(struct eth_device *edev, const struct dhcp_req_param *param, + struct dhcp_result **res); +int dhcp_set_result(struct eth_device *edev, struct dhcp_result *res); +void dhcp_result_free(struct dhcp_result *res); +int dhcp(struct eth_device *edev, const struct dhcp_req_param *param); #endif |