1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-29 21:55:25 +03:00

sd-dhcp-lease: expose load/save functions

Based on patch by Dan Williams.
This commit is contained in:
Tom Gundersen 2014-11-18 19:10:37 +01:00
parent d8d74ef06f
commit 1dc24d5f48
4 changed files with 6 additions and 6 deletions

View File

@ -76,9 +76,6 @@ int dhcp_lease_new(sd_dhcp_lease **ret);
int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option, int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
void *user_data); void *user_data);
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
int dhcp_lease_load(const char *lease_file, sd_dhcp_lease **ret);
int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease); int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref); DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);

View File

@ -580,7 +580,7 @@ int dhcp_lease_new(sd_dhcp_lease **ret) {
return 0; return 0;
} }
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) { int sd_dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
_cleanup_free_ char *temp_path = NULL; _cleanup_free_ char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
struct in_addr address; struct in_addr address;
@ -675,7 +675,7 @@ finish:
return r; return r;
} }
int dhcp_lease_load(const char *lease_file, sd_dhcp_lease **ret) { int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
_cleanup_dhcp_lease_unref_ sd_dhcp_lease *lease = NULL; _cleanup_dhcp_lease_unref_ sd_dhcp_lease *lease = NULL;
_cleanup_free_ char *address = NULL, *router = NULL, *netmask = NULL, _cleanup_free_ char *address = NULL, *router = NULL, *netmask = NULL,
*server_address = NULL, *next_server = NULL, *server_address = NULL, *next_server = NULL,

View File

@ -1857,7 +1857,7 @@ int link_save(Link *link) {
if (link->dhcp_lease) { if (link->dhcp_lease) {
assert(link->network); assert(link->network);
r = dhcp_lease_save(link->dhcp_lease, link->lease_file); r = sd_dhcp_lease_save(link->dhcp_lease, link->lease_file);
if (r < 0) if (r < 0)
goto fail; goto fail;

View File

@ -46,4 +46,7 @@ int sd_dhcp_lease_get_hostname(sd_dhcp_lease *lease, const char **hostname);
int sd_dhcp_lease_get_root_path(sd_dhcp_lease *lease, const char **root_path); int sd_dhcp_lease_get_root_path(sd_dhcp_lease *lease, const char **root_path);
int sd_dhcp_lease_get_routes(sd_dhcp_lease *lease, struct sd_dhcp_route **routesgn); int sd_dhcp_lease_get_routes(sd_dhcp_lease *lease, struct sd_dhcp_route **routesgn);
int sd_dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);
#endif #endif