MCPcopy Index your code
hub / github.com/secdev/scapy / __init__

Method __init__

scapy/base_classes.py:213–239  ·  view source on GitHub ↗
(self, net, stop=None, scope=None)

Source from the content-addressed store, hash-verified

211 return socket.inet_ntoa(struct.pack('!I', val))
212
213 def __init__(self, net, stop=None, scope=None):
214 # type: (str, Optional[str], Optional[str]) -> None
215 if "*" in net:
216 raise Scapy_Exception("Wildcards are no longer accepted in %s()" %
217 self.__class__.__name__)
218 self.scope = None
219 if "%" in net:
220 net = ScopedIP(net)
221 if isinstance(net, _ScopedIP):
222 self.scope = net.scope
223 if stop is None:
224 try:
225 net, mask = net.split("/", 1)
226 except ValueError:
227 self.mask = self.max_mask # type: Union[None, int]
228 else:
229 self.mask = int(mask)
230 self.net = net # type: Union[None, str]
231 inv_mask = self.max_mask - self.mask
232 self.start = self.ip2int(net) >> inv_mask << inv_mask
233 self.count = 1 << inv_mask
234 self.stop = self.start + self.count - 1
235 else:
236 self.start = self.ip2int(net)
237 self.stop = self.ip2int(stop)
238 self.count = self.stop - self.start + 1
239 self.net = self.mask = None
240
241 def __str__(self):
242 # type: () -> str

Callers 1

__call__Method · 0.45

Calls 3

ip2intMethod · 0.95
Scapy_ExceptionClass · 0.90
ScopedIPFunction · 0.85

Tested by

no test coverage detected