]> git.decadent.org.uk Git - odhcp6c.git/blobdiff - src/script.c
softwire: fix DMR parsing
[odhcp6c.git] / src / script.c
index 6caaffd7f19e67ed149e0cb9551690c475e2c130..9325085c362c3c34a3c03e5b9ababbe866e2220d 100644 (file)
@@ -238,6 +238,9 @@ static void s46_to_env(enum odhcp6c_state state, const uint8_t *data, size_t len
        fputc('=', fp);
 
 #ifdef EXT_S46
+       const char *type = (state == STATE_S46_MAPE) ? "map-e" :
+                       (state == STATE_S46_MAPT) ? "map-t" : "lw4o6";
+
        uint8_t *odata;
        uint16_t otype, olen;
        dhcpv6_for_each_option(data, &data[len], otype, olen, odata) {
@@ -265,8 +268,8 @@ static void s46_to_env(enum odhcp6c_state state, const uint8_t *data, size_t len
                        if (rule->flags & 1)
                                fputs("fmr,", fp);
 
-                       fprintf(fp, "ealen=%d,prefix4len=%d,prefix6len=%d,ipv4prefix=%s,ipv6prefix=%s,",
-                                       rule->ea_len, rule->prefix4_len, rule->prefix6_len, buf4, buf6);
+                       fprintf(fp, "type=%s,ealen=%d,prefix4len=%d,prefix6len=%d,ipv4prefix=%s,ipv6prefix=%s,",
+                                       type, rule->ea_len, rule->prefix4_len, rule->prefix6_len, buf4, buf6);
 
                        s46_to_env_portparams(&rule->ipv6_prefix[prefix6len],
                                        olen - sizeof(*rule) - prefix6len, fp);
@@ -278,6 +281,7 @@ static void s46_to_env(enum odhcp6c_state state, const uint8_t *data, size_t len
                                        fprintf(fp, "br=%s,", buf6);
                                } else if (state == STATE_S46_MAPT && otype == DHCPV6_OPT_S46_DMR &&
                                                olen >= sizeof(struct dhcpv6_s46_dmr)) {
+                                       dmr = (struct dhcpv6_s46_dmr*)odata;
                                        memset(&in6, 0, sizeof(in6));
                                        size_t prefix6len = dmr->dmr_prefix6_len;
                                        prefix6len = (prefix6len % 8 == 0) ? prefix6len / 8 : prefix6len / 8 + 1;
@@ -307,8 +311,8 @@ static void s46_to_env(enum odhcp6c_state state, const uint8_t *data, size_t len
                        inet_ntop(AF_INET, &bind->ipv4_address, buf4, sizeof(buf4));
                        inet_ntop(AF_INET6, &in6, buf6, sizeof(buf6));
 
-                       fprintf(fp, "ipv4address=%s,prefix6len=%d,ipv6prefix=%s,",
-                                       buf4, bind->bindprefix6_len, buf6);
+                       fprintf(fp, "type=%s,ipv4address=%s,prefix6len=%d,ipv6prefix=%s,",
+                                       type, buf4, bind->bindprefix6_len, buf6);
 
                        s46_to_env_portparams(&bind->bind_ipv6_prefix[prefix6len],
                                        olen - sizeof(*bind) - prefix6len, fp);