diff options
author | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2016-12-19 15:56:49 +1100 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2016-12-20 16:40:22 +1100 |
commit | 0d3caaf8e9a75e9b6ebc9427c75ed2914c60439d (patch) | |
tree | 02b8930345eea0a0e0c11673ffac1cfe22495afc /lib/pb-protocol/pb-protocol.c | |
parent | f901ce58f58ad4f7d769140fe98426e5ac9f7759 (diff) | |
download | petitboot-0d3caaf8e9a75e9b6ebc9427c75ed2914c60439d.zip petitboot-0d3caaf8e9a75e9b6ebc9427c75ed2914c60439d.tar.gz |
discover: Record IP address of network interfaces
If an interface has a valid IP address (either via DHCP or static
config) store it in the interface_info struct so it can be referenced
later.
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'lib/pb-protocol/pb-protocol.c')
-rw-r--r-- | lib/pb-protocol/pb-protocol.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index 65a1e93..18edf57 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -249,7 +249,8 @@ int pb_protocol_system_info_len(const struct system_info *sysinfo) struct interface_info *if_info = sysinfo->interfaces[i]; len += 4 + if_info->hwaddr_size + 4 + optional_strlen(if_info->name) + - sizeof(if_info->link); + sizeof(if_info->link) + + 4 + optional_strlen(if_info->address); } for (i = 0; i < sysinfo->n_blockdevs; i++) { @@ -465,6 +466,8 @@ int pb_protocol_serialise_system_info(const struct system_info *sysinfo, *(bool *)pos = if_info->link; pos += sizeof(bool); + + pos += pb_protocol_serialise_string(pos, if_info->address); } *(uint32_t *)pos = __cpu_to_be32(sysinfo->n_blockdevs); @@ -949,6 +952,9 @@ int pb_protocol_deserialise_system_info(struct system_info *sysinfo, if_info->link = *(bool *)pos; pos += sizeof(if_info->link); + if (read_string(if_info, &pos, &len, &if_info->address)) + goto out; + sysinfo->interfaces[i] = if_info; } |