diff options
author | Alex Crawford <alex.crawford@coreos.com> | 2015-07-31 20:18:51 -0700 |
---|---|---|
committer | Alex Crawford <alex.crawford@coreos.com> | 2015-08-05 09:00:57 -0700 |
commit | a073309fb779e9c9e48eaef664daeb6b8f6080da (patch) | |
tree | 5bd0288183077852a2874b9fe3505528e39991ca /src/libsystemd-network/network-internal.c | |
parent | 7e753d9d28ca93fe0e48fd3605ed7c3371736422 (diff) |
networkd: serialize the private options
Save the private options along side the rest of the options in the lease
files.
Diffstat (limited to 'src/libsystemd-network/network-internal.c')
-rw-r--r-- | src/libsystemd-network/network-internal.c | 27 |
1 files changed, 27 insertions, 0 deletions
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); +} |