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)
| 822 | |
| 823 | |
| 824 | def 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 | |
| 840 | def in4_isincluded(addr, prefix, mask): |
no test coverage detected