From a073309fb779e9c9e48eaef664daeb6b8f6080da Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Fri, 31 Jul 2015 20:18:51 -0700 Subject: networkd: serialize the private options Save the private options along side the rest of the options in the lease files. --- src/libsystemd-network/network-internal.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/libsystemd-network/network-internal.c') diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index d579755cc8..3d78bf8b35 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -509,3 +509,30 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t return 0; } + +int serialize_dhcp_option(FILE *f, const char *key, const uint8_t *data, size_t size) { + _cleanup_free_ char *hex_buf = NULL; + + assert(f); + assert(key); + assert(data); + + hex_buf = hexmem(data, size); + if (hex_buf == NULL) + return -ENOMEM; + + fprintf(f, "%s=%s\n", key, hex_buf); + + return 0; +} + +int deserialize_dhcp_option(uint8_t **data, size_t *data_len, const char *string) { + assert(data); + assert(data_len); + assert(string); + + if (strlen(string) % 2) + return -EINVAL; + + return unhexmem(string, strlen(string), (void **)data, data_len); +} -- cgit v1.2.3-54-g00ecf