@@ -572,7 +572,8 @@ 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 ). \
576+ _pack_subnet (x , pkt )
576577
577578 def i2len (self , pkt , x ):
578579 # type: (Packet, Any) -> int
@@ -582,7 +583,8 @@ def i2len(self, pkt, x):
582583 return len (self ._pack_subnet (x , pkt ))
583584 except (OSError , socket .error ):
584585 pkt .family = 2
585- return len (ClientSubnetv6 ("" , "" )._pack_subnet (x , pkt ))
586+ return len (ClientSubnetv6 ("" , "" , lambda p : p .source_plen or 32 ). \
587+ _pack_subnet (x , pkt ))
586588
587589
588590class ClientSubnetv6 (ClientSubnetv4 ):
@@ -604,13 +606,13 @@ class EDNS0ClientSubnet(_EDNS0Dummy):
604606 ByteField ("scope_plen" , 0 ),
605607 MultipleTypeField (
606608 [(ClientSubnetv4 ("address" , "192.168.0.0" ,
607- length_from = lambda p : p .source_plen ),
609+ length_from = lambda p : p .source_plen or 16 ),
608610 lambda pkt : pkt .family == 1 ),
609611 (ClientSubnetv6 ("address" , "2001:db8::" ,
610- length_from = lambda p : p .source_plen ),
612+ length_from = lambda p : p .source_plen or 32 ),
611613 lambda pkt : pkt .family == 2 )],
612614 ClientSubnetv4 ("address" , "192.168.0.0" ,
613- length_from = lambda p : p .source_plen ))]
615+ length_from = lambda p : p .source_plen or 32 ))]
614616
615617
616618class EDNS0COOKIE (_EDNS0Dummy ):
0 commit comments