summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/dhcp6-option.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2014-10-08 11:00:07 +0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2014-10-09 14:57:53 +0300
commitee3a5027f7c56df2ef47a774970433d7045c9e9f (patch)
tree8c4d53fb9be2f55479705da8920cb5c14c653e30 /src/libsystemd-network/dhcp6-option.c
parentd46fbfb48deff83943355992e55f9ef4431ff5ef (diff)
sd-dhcp6-lease: Name the structure containing IAADDR data
With this change the DHCP6_OPTION_IAADDR_LEN define can be removed in favor of using sizeof(). Using the name of the struct and sizeof() makes it clearer how much and what data is being copied from the DHCPv6 message.
Diffstat (limited to 'src/libsystemd-network/dhcp6-option.c')
-rw-r--r--src/libsystemd-network/dhcp6-option.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/libsystemd-network/dhcp6-option.c b/src/libsystemd-network/dhcp6-option.c
index e9b382c170..e6a31778f4 100644
--- a/src/libsystemd-network/dhcp6-option.c
+++ b/src/libsystemd-network/dhcp6-option.c
@@ -32,7 +32,6 @@
#define DHCP6_OPTION_HDR_LEN 4
#define DHCP6_OPTION_IA_NA_LEN 12
#define DHCP6_OPTION_IA_TA_LEN 4
-#define DHCP6_OPTION_IAADDR_LEN 24
static int option_append_hdr(uint8_t **buf, size_t *buflen, uint16_t optcode,
size_t optlen) {
@@ -111,16 +110,16 @@ int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, DHCP6IA *ia) {
LIST_FOREACH(addresses, addr, ia->addresses) {
r = option_append_hdr(buf, buflen, DHCP6_OPTION_IAADDR,
- DHCP6_OPTION_IAADDR_LEN);
+ sizeof(addr->iaaddr));
if (r < 0)
return r;
- memcpy(*buf, &addr->address, DHCP6_OPTION_IAADDR_LEN);
+ memcpy(*buf, &addr->iaaddr, sizeof(addr->iaaddr));
- *buf += DHCP6_OPTION_IAADDR_LEN;
- *buflen -= DHCP6_OPTION_IAADDR_LEN;
+ *buf += sizeof(addr->iaaddr);
+ *buflen -= sizeof(addr->iaaddr);
- ia_addrlen += DHCP6_OPTION_HDR_LEN + DHCP6_OPTION_IAADDR_LEN;
+ ia_addrlen += DHCP6_OPTION_HDR_LEN + sizeof(addr->iaaddr);
}
r = option_append_hdr(&ia_hdr, &ia_buflen, ia->type, len + ia_addrlen);
@@ -192,7 +191,7 @@ int dhcp6_option_parse_ia(uint8_t **buf, size_t *buflen, uint16_t iatype,
case DHCP6_OPTION_IA_NA:
if (*buflen < DHCP6_OPTION_IA_NA_LEN + DHCP6_OPTION_HDR_LEN +
- DHCP6_OPTION_IAADDR_LEN) {
+ sizeof(addr->iaaddr)) {
r = -ENOBUFS;
goto error;
}
@@ -214,7 +213,7 @@ int dhcp6_option_parse_ia(uint8_t **buf, size_t *buflen, uint16_t iatype,
case DHCP6_OPTION_IA_TA:
if (*buflen < DHCP6_OPTION_IA_TA_LEN + DHCP6_OPTION_HDR_LEN +
- DHCP6_OPTION_IAADDR_LEN) {
+ sizeof(addr->iaaddr)) {
r = -ENOBUFS;
goto error;
}
@@ -250,10 +249,10 @@ int dhcp6_option_parse_ia(uint8_t **buf, size_t *buflen, uint16_t iatype,
LIST_INIT(addresses, addr);
- memcpy(&addr->address, *buf, DHCP6_OPTION_IAADDR_LEN);
+ memcpy(&addr->iaaddr, *buf, sizeof(addr->iaaddr));
- lt_valid = be32toh(addr->lifetime_valid);
- lt_pref = be32toh(addr->lifetime_valid);
+ lt_valid = be32toh(addr->iaaddr.lifetime_valid);
+ lt_pref = be32toh(addr->iaaddr.lifetime_valid);
if (!lt_valid || lt_pref > lt_valid) {
log_dhcp6_client(client, "IA preferred %ds > valid %ds",