aboutsummaryrefslogtreecommitdiffstats
path: root/test/patches/scapy-2.4.3/vrrp.patch
blob: 39e99d4045e9de336f14eeb010a67eacaffbf056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
diff --git a/scapy/layers/vrrp.py b/scapy/layers/vrrp.py
index 1b583653..3d6a5923 100644
--- a/scapy/layers/vrrp.py
+++ b/scapy/layers/vrrp.py
@@ -10,7 +10,7 @@ VRRP (Virtual Router Redundancy Protocol).
 
 from scapy.packet import Packet, bind_layers
 from scapy.fields import BitField, ByteField, FieldLenField, FieldListField, \
-    IPField, IntField, XShortField
+    IPField, IP6Field, IntField, MultipleTypeField, StrField, XShortField
 from scapy.compat import chb, orb
 from scapy.layers.inet import IP, in4_chksum, checksum
 from scapy.layers.inet6 import IPv6, in6_chksum
@@ -62,9 +62,18 @@ class VRRPv3(Packet):
         BitField("res", 0, 4),
         BitField("adv", 100, 12),
         XShortField("chksum", None),
-        # FIXME: addrlist should also allow IPv6 addresses :/
-        FieldListField("addrlist", [], IPField("", "0.0.0.0"),
-                       count_from=lambda pkt: pkt.ipcount)]
+        MultipleTypeField(
+            [
+                (FieldListField("addrlist", [], IPField("", "0.0.0.0"),
+                                count_from=lambda pkt: pkt.ipcount),
+                 lambda p: isinstance(p.underlayer, IP)),
+                (FieldListField("addrlist", [], IP6Field("", "::"),
+                                count_from=lambda pkt: pkt.ipcount),
+                 lambda p: isinstance(p.underlayer, IPv6)),
+            ],
+            StrField("addrlist", "")
+        )
+    ]
 
     def post_build(self, p, pay):
         if self.chksum is None: