def ip2hex(ip):
parts = ip.split("<STR_LIT:.>")<EOL>if len(parts) != <NUM_LIT:4>: return None<EOL>ipv = <NUM_LIT:0><EOL>for part in parts:<EOL><INDENT>try:<EOL><INDENT>p = int(part)<EOL>if p < <NUM_LIT:0> or p > <NUM_LIT:255>: return None<EOL>ipv = (ipv << <NUM_LIT:8>) + p<EOL><DEDENT>except:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>return ipv<EOL>
Converts an ip to a hex value that can be used with a hex bit mask