@@ -1077,9 +1077,6 @@ class _BaseV4:
1077
1077
# Equivalent to 255.255.255.255 or 32 bits of 1's.
1078
1078
_ALL_ONES = (2 ** IPV4LENGTH ) - 1
1079
1079
1080
- # the valid octets for host and netmasks. only useful for IPv4.
1081
- _valid_mask_octets = frozenset ({255 , 254 , 252 , 248 , 240 , 224 , 192 , 128 , 0 })
1082
-
1083
1080
_max_prefixlen = IPV4LENGTH
1084
1081
# There are only a handful of valid v4 netmasks, so we cache them all
1085
1082
# when constructed (see _make_netmask()).
@@ -1182,58 +1179,6 @@ def _string_from_ip_int(cls, ip_int):
1182
1179
"""
1183
1180
return '.' .join (map (str , ip_int .to_bytes (4 , 'big' )))
1184
1181
1185
- def _is_valid_netmask (self , netmask ):
1186
- """Verify that the netmask is valid.
1187
-
1188
- Args:
1189
- netmask: A string, either a prefix or dotted decimal
1190
- netmask.
1191
-
1192
- Returns:
1193
- A boolean, True if the prefix represents a valid IPv4
1194
- netmask.
1195
-
1196
- """
1197
- mask = netmask .split ('.' )
1198
- if len (mask ) == 4 :
1199
- try :
1200
- for x in mask :
1201
- if int (x ) not in self ._valid_mask_octets :
1202
- return False
1203
- except ValueError :
1204
- # Found something that isn't an integer or isn't valid
1205
- return False
1206
- for idx , y in enumerate (mask ):
1207
- if idx > 0 and y > mask [idx - 1 ]:
1208
- return False
1209
- return True
1210
- try :
1211
- netmask = int (netmask )
1212
- except ValueError :
1213
- return False
1214
- return 0 <= netmask <= self ._max_prefixlen
1215
-
1216
- def _is_hostmask (self , ip_str ):
1217
- """Test if the IP string is a hostmask (rather than a netmask).
1218
-
1219
- Args:
1220
- ip_str: A string, the potential hostmask.
1221
-
1222
- Returns:
1223
- A boolean, True if the IP string is a hostmask.
1224
-
1225
- """
1226
- bits = ip_str .split ('.' )
1227
- try :
1228
- parts = [x for x in map (int , bits ) if x in self ._valid_mask_octets ]
1229
- except ValueError :
1230
- return False
1231
- if len (parts ) != len (bits ):
1232
- return False
1233
- if parts [0 ] < parts [- 1 ]:
1234
- return True
1235
- return False
1236
-
1237
1182
def _reverse_pointer (self ):
1238
1183
"""Return the reverse DNS pointer name for the IPv4 address.
1239
1184
0 commit comments