Skip to content
Snippets Groups Projects
Commit 7835bcec authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

fix buf wrongly get subnet

parent 69559e3a
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,8 @@ stop_sniffing = False
def ip_to_subnet_hex(ip):
"""Convert an IP address to its subnet base (last octet set to 0) in hex format."""
ip_obj = ipaddress.IPv4Address(ip)
subnet_ip = ip_obj & ipaddress.IPv4Address("255.255.255.0") # Force last octet to 0
network = ipaddress.IPv4Network(f"{ip_obj}/24", strict=False)
subnet_ip = network.network_address
return f"0x{int(subnet_ip):08X}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment