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

Function in4_cidr2mask

scapy/utils.py:824–837  ·  view source on GitHub ↗

Return the mask (bitstring) associated with provided length value. For instance if function is called on 20, return value is b'\xff\xff\xf0\x00'.

(m)

Source from the content-addressed store, hash-verified

822
823
824def in4_cidr2mask(m):
825 # type: (int) -> bytes
826 """
827 Return the mask (bitstring) associated with provided length
828 value. For instance if function is called on 20, return value is
829 b'\xff\xff\xf0\x00'.
830 """
831 if m > 32 or m < 0:
832 raise Scapy_Exception("value provided to in4_cidr2mask outside [0, 32] domain (%d)" % m) # noqa: E501
833
834 return strxor(
835 b"\xff" * 4,
836 struct.pack(">I", 2**(32 - m) - 1)
837 )
838
839
840def in4_isincluded(addr, prefix, mask):

Callers 1

in4_isincludedFunction · 0.85

Calls 2

Scapy_ExceptionClass · 0.90
strxorFunction · 0.85

Tested by

no test coverage detected