parameters: (ip, net)
return_statement: return ret
docstring: Is an address in a network
docstring_summary: Is an address in a network
docstring_tokens: Is an address in a network
function: def addressInNetwork(ip, net):
      "Is an address in a network"
      ret = False
      try:
          ipaddr = struct.unpack('!I', socket.inet_aton(ip))[0]
          netaddr, bits = net.split('/')
          netmask = struct.unpack('!I', socket.inet_aton(netaddr))[
              0] & ((2 << int(bits)-1) - 1)
          ret = ipaddr & netmask == netmask
      except Exception as e:
          ret = False
      return ret
function_tokens: def addressInNetwork ( ip , net ) : ret = False try : ipaddr = struct . unpack ( '!I' , socket . inet_aton ( ip ) ) [ 0 ] netaddr , bits = net . split ( '/' ) netmask = struct . unpack ( '!I' , socket . inet_aton ( netaddr ) ) [ 0 ] & ( ( 2 << int ( bits ) - 1 ) - 1 ) ret = ipaddr & netmask == netmask except Exception as e : ret = False return ret