@@ -572,7 +572,7 @@ def i2m(self, pkt, x):
572572 return self ._pack_subnet (x , pkt )
573573 except (OSError , socket .error ):
574574 pkt .family = 2
575- return ClientSubnetv6 ("" , "" )._pack_subnet (x , pkt )
575+ return ClientSubnetv6 ("" , "" , lambda p : p . source_plen or 32 )._pack_subnet (x , pkt )
576576
577577 def i2len (self , pkt , x ):
578578 # type: (Packet, Any) -> int
@@ -582,7 +582,7 @@ def i2len(self, pkt, x):
582582 return len (self ._pack_subnet (x , pkt ))
583583 except (OSError , socket .error ):
584584 pkt .family = 2
585- return len (ClientSubnetv6 ("" , "" )._pack_subnet (x , pkt ))
585+ return len (ClientSubnetv6 ("" , "" , lambda p : p . source_plen or 32 )._pack_subnet (x , pkt ))
586586
587587
588588class ClientSubnetv6 (ClientSubnetv4 ):
@@ -604,13 +604,13 @@ class EDNS0ClientSubnet(_EDNS0Dummy):
604604 ByteField ("scope_plen" , 0 ),
605605 MultipleTypeField (
606606 [(ClientSubnetv4 ("address" , "192.168.0.0" ,
607- length_from = lambda p : p .source_plen ),
607+ length_from = lambda p : p .source_plen or 16 ),
608608 lambda pkt : pkt .family == 1 ),
609609 (ClientSubnetv6 ("address" , "2001:db8::" ,
610- length_from = lambda p : p .source_plen ),
610+ length_from = lambda p : p .source_plen or 32 ),
611611 lambda pkt : pkt .family == 2 )],
612612 ClientSubnetv4 ("address" , "192.168.0.0" ,
613- length_from = lambda p : p .source_plen ))]
613+ length_from = lambda p : p .source_plen or 32 ))]
614614
615615
616616class EDNS0COOKIE (_EDNS0Dummy ):
0 commit comments