summaryrefslogtreecommitdiff
path: root/gdhcp/common.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-01-05 13:38:09 +0200
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2012-01-05 13:17:26 +0100
commit195007a210055b96f42f29348cbce02915dea242 (patch)
treede2dc353c33f9f8999d0df16a87fe15da379ad1b /gdhcp/common.c
parent60bc9d2cdd88171bf10a545b46f49b5e7c6415ab (diff)
downloadconnman-195007a210055b96f42f29348cbce02915dea242.tar.gz
connman-195007a210055b96f42f29348cbce02915dea242.tar.bz2
connman-195007a210055b96f42f29348cbce02915dea242.zip
dhcpv6: Initial stateful DHCPv6 support.
This patch contains solicitation message support.
Diffstat (limited to 'gdhcp/common.c')
-rw-r--r--gdhcp/common.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gdhcp/common.c b/gdhcp/common.c
index 46cf5f6d..c511e26d 100644
--- a/gdhcp/common.c
+++ b/gdhcp/common.c
@@ -188,6 +188,31 @@ uint8_t *dhcpv6_get_option(struct dhcpv6_packet *packet, uint16_t pkt_len,
return found;
}
+uint8_t *dhcpv6_get_sub_option(unsigned char *option, uint16_t max_len,
+ uint16_t *option_code, uint16_t *option_len)
+{
+ int rem;
+ uint16_t code, len;
+
+ rem = max_len - 2 - 2;
+
+ if (rem <= 0)
+ /* Bad option */
+ return NULL;
+
+ code = option[0] << 8 | option[1];
+ len = option[2] << 8 | option[3];
+
+ rem -= len;
+ if (rem < 0)
+ return NULL;
+
+ *option_code = code;
+ *option_len = len;
+
+ return &option[4];
+}
+
/*
* Add an option (supplied in binary form) to the options.
* Option format: [code][len][data1][data2]..[dataLEN]