summaryrefslogtreecommitdiffstats
path: root/dhcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'dhcp.c')
-rw-r--r--dhcp.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/dhcp.c b/dhcp.c
index 203dc939..c5feccad 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -759,6 +759,31 @@ encode_rfc1035(const char *src, uint8_t *dst)
memcpy(p, &_val.s_addr, 4); \
p += 4; \
}
+
+int
+dhcp_message_add_addr(struct dhcp_message *dhcp,
+ uint8_t type, struct in_addr addr)
+{
+ uint8_t *p;
+ size_t len;
+
+ p = dhcp->options;
+ while (*p != DHO_END) {
+ p++;
+ p += *p + 1;
+ }
+
+ len = p - (uint8_t *)dhcp;
+ if (len + 6 > sizeof(*dhcp)) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ PUTADDR(type, addr);
+ *p = DHO_END;
+ return 0;
+}
+
ssize_t
make_message(struct dhcp_message **message,
const struct interface *iface,