pfsense/pfsense — pull request #952 by stilez (2014-02-20 02:15:41+00:00)
Title: Tighten ip_compare, gt, lt, functions

ip_less_than(), ip_greater_than(), ipcmp() and ip_compare():

1) ip_less_than() and ip_greater_than() both fail for IPv6 as they rely on 32 bit ip2ulong

2) ip_less_than() and ip_greater_than() both also fail for data validation as they do not trap bad data, or detect the malformed case where one arg is IPv4 and the other IPv6 due to improper user input. (One will always be "greater" or "less" than the other so one of these functions will attempt to return True if they don't error out first)

3) It's easier and cleaner if ip_less_than() and ip_greater_than() call ip_compare() than ipcompare() calls the two separate sub-functions. Effectively they are aliases for it, it saves a function call.

4) Previously there was no way to distinguish "equal" from "bad data" (except "bad data" wasn't trapped anyway); now it returns '' for bad data and 0 for equal.

5) Switches to a more obvious and 'canonical' name ip_compare() for the main function, ipcmp() remains an alias to ensure nothing breaks