From e63ecd7bc40595ca1c70b377b3323cc215f3d256 Mon Sep 17 00:00:00 2001
From: ngkokkee <ngkokkee@hotmail.com>
Date: Tue, 24 Jan 2017 18:34:33 +0800
Subject: [PATCH] Fix IA_PD length error (#428)

* Fix IA_PD length error

I tested this and noticed wireshark wasn't parsing the message correctly. Turns out the length is wrong.

* Update regression.uts

Fix test for DHCP6OptIA_PD

* Update length of DHCP6OptIA_PD in test.
---
 scapy/layers/dhcp6.py | 4 ++--
 test/regression.uts   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/scapy/layers/dhcp6.py b/scapy/layers/dhcp6.py
index 4cb92910..7980a51c 100644
--- a/scapy/layers/dhcp6.py
+++ b/scapy/layers/dhcp6.py
@@ -694,13 +694,13 @@ class DHCP6OptIAPrefix(_DHCP6OptGuessPayload):                    #RFC3633
     name = "DHCP6 Option - IA_PD Prefix option"
     fields_desc = [ ShortEnumField("optcode", 26, dhcp6opts),
                     FieldLenField("optlen", None, length_of="iaprefopts",
-                                  adjust = lambda pkt,x: x+26),
+                                  adjust = lambda pkt,x: x+25),
                     IntField("preflft", 0),
                     IntField("validlft", 0),
                     ByteField("plen", 48),  # TODO: Challenge that default value
                     IP6Field("prefix", "2001:db8::"), # At least, global and won't hurt
                     StrLenField("iaprefopts", "",
-                                length_from = lambda pkt: pkt.optlen-26) ]
+                                length_from = lambda pkt: pkt.optlen-25) ]
 
 class DHCP6OptIA_PD(_DHCP6OptGuessPayload):                       #RFC3633
     name = "DHCP6 Option - Identity Association for Prefix Delegation"
diff --git a/test/regression.uts b/test/regression.uts
index 6e0ba09c..b6fd6f08 100644
--- a/test/regression.uts
+++ b/test/regression.uts
@@ -3548,7 +3548,7 @@ a.optcode == 24 and a.optlen == 36 and len(a.dnsdomains) == 2 and a.dnsdomains[0
 + Test DHCP6 Option - IA_PD Prefix Option
 
 = DHCP6OptIAPrefix - Basic Instantiation
-str(DHCP6OptIAPrefix()) == '\x00\x1a\x00\x1a\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+str(DHCP6OptIAPrefix()) == '\x00\x1a\x00\x19\x00\x00\x00\x00\x00\x00\x00\x000 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 
 #TODO : finish me
 
-- 
GitLab