Add support for colored address in IA_NA
authorMaico Le Pape <mlepape@cisco.com>
Tue, 30 Jul 2013 21:10:54 +0000 (23:10 +0200)
committerMarkus Stenberg <markus.stenberg@iki.fi>
Wed, 31 Jul 2013 06:46:14 +0000 (08:46 +0200)
Signed-off-by: Maico Le Pape <mlepape@cisco.com>
src/dhcpv6.c
src/script.c

index 7f2aa1a70ab91c22c2b18d0700c9e0c07ee2a639..01d14942f73567337dabe9fdb0da8e07c7ce87c3 100644 (file)
@@ -885,6 +885,15 @@ static uint32_t dhcpv6_parse_ia(void *opt, void *end)
                        entry.length = 128;
                        entry.target = addr->addr;
 
+                       uint16_t stype, slen;
+                       uint8_t *sdata;
+                       
+                       // Find prefix class, if any
+                       dhcpv6_for_each_option(&addr[1], odata + olen,
+                                              stype, slen, sdata)
+                         if (stype == DHCPV6_OPT_PREFIX_CLASS && slen == 2) 
+                            entry.prefix_class = ntohs(*((uint16_t*)sdata));
+                       
                        odhcp6c_update_entry(STATE_IA_NA, &entry);
                }
 
index 3cc7e2b47c663afacb4575acf3baa8147af69c32..74aea6411dbad82a14f0e05f52d2cbd1f4cc483e 100644 (file)
@@ -187,7 +187,7 @@ static void entry_to_env(const char *name, const void *data, size_t len, enum en
                        } else {
                                buf_len += snprintf(&buf[buf_len], 24, ",%u,%u", e[i].preferred, e[i].valid);
                        }
-                        if (type == ENTRY_PREFIX && e[i].prefix_class) {
+                       if ((type == ENTRY_PREFIX || type == ENTRY_ADDRESS) && e[i].prefix_class) {
                           buf_len += snprintf(&buf[buf_len], 12, ",class=%u", e[i].prefix_class);
                         }