def ip_string_to_int(ipstr):
    """ Convert a string IPv4 address to integer"""
    if ipstr == '':
        return 0
    if len(ipstr) > 15: # max len of ipv4 in string (could be less)
        #print "Damn:", ipstr
        return 0 
    parts = ipstr.split('.')
    return (int(parts[0]) << 24) + (int(parts[1]) << 16) + \
                                            (int(parts[2]) << 8) + int(parts[3])