ip_classifier.py for ipv32
Written simple program to find the class for an ip address of 32bit version #!/usr/bin/python import sys, getopt def __help(): sys.stderr.write('\n Usage: \n ip_classifier.py -h \n ip_classifier.py --help \n ip_classifier.py -i 128.12.14.23 \n ip_classifier.py --ipv4=128.12.14.23 \n ') sys.exit() def __input_validator(check): if len(check) 0: check = list(check) c = 0; n = 0 for v in check: if v in ['.','1','2','3','4','5','6','7','8','9','0']: n += 1 test = True if v is '.': c += 1 else: test = False break if test and c 6: return check else: sys.stderr.write('**** Enter correct ip address **** \n') __help() def __validator(ip): if ip in range(0,256): return True else: sys.stderr.write('**** Enter correct ip address **** \n') __help() def __class_finder(ip, class_ip, bin_ip): i='' dict ...