]> git.decadent.org.uk Git - odhcp6c.git/blobdiff - src/script.c
Fix LW4over6 parameter handling
[odhcp6c.git] / src / script.c
index 30441b9e4739e86b928d237d4dd9a9715faee62e..219d034d82f75f75cbcd3da4d1e1ddd238d13d2f 100644 (file)
@@ -247,7 +247,6 @@ static void s46_to_env(enum odhcp6c_state state, const uint8_t *data, size_t len
        uint16_t otype, olen;
        dhcpv6_for_each_option(data, &data[len], otype, olen, odata) {
                struct dhcpv6_s46_rule *rule = (struct dhcpv6_s46_rule*)odata;
-               struct dhcpv6_s46_dmr *dmr = (struct dhcpv6_s46_dmr*)odata;
                struct dhcpv6_s46_v4v6bind *bind = (struct dhcpv6_s46_v4v6bind*)odata;
 
                if (state != STATE_S46_LW && otype == DHCPV6_OPT_S46_RULE &&
@@ -283,7 +282,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;
+                                       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;
@@ -296,6 +295,8 @@ static void s46_to_env(enum odhcp6c_state state, const uint8_t *data, size_t len
                                        fprintf(fp, "dmr=%s/%d,", buf6, dmr->dmr_prefix6_len);
                                }
                        }
+
+                       fputc(' ', fp);
                } else if (state == STATE_S46_LW && otype == DHCPV6_OPT_S46_V4V6BIND &&
                                olen >= sizeof(struct dhcpv6_s46_v4v6bind)) {
                        char buf4[INET_ADDRSTRLEN];
@@ -313,8 +314,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, "type=%s,ipv4address=%s,prefix6len=%d,ipv6prefix=%s,",
-                                       type, buf4, bind->bindprefix6_len, buf6);
+                       fprintf(fp, "type=%s,prefix4len=32,prefix6len=%d,ipv4prefix=%s,ipv6prefix=%s,",
+                                       type, bind->bindprefix6_len, buf4, buf6);
 
                        s46_to_env_portparams(&bind->bind_ipv6_prefix[prefix6len],
                                        olen - sizeof(*bind) - prefix6len, fp);
@@ -325,9 +326,9 @@ static void s46_to_env(enum odhcp6c_state state, const uint8_t *data, size_t len
                                        fprintf(fp, "br=%s,", buf6);
                                }
                        }
-               }
 
-               fputc(' ', fp);
+                       fputc(' ', fp);
+               }
        }
 
        fclose(fp);