* is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate.
*
- * $Id: network.c,v 1.9 1999/05/25 16:12:11 momjian Exp $
+ * $Id: network.c,v 1.15 1999/07/17 20:17:58 momjian Exp $
* Jon Postel RIP 16 Oct 1998
*/
#include <sys/types.h>
#include <sys/socket.h>
-#include <stdio.h>
-#include <string.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <postgres.h>
-#include <utils/palloc.h>
-#include <utils/builtins.h>
-#include <utils/inet.h>
+#include "postgres.h"
+#include "utils/builtins.h"
static int v4bitncmp(unsigned int a1, unsigned int a2, int bits);
{
if (ntohl(ip_v4addr(a1)) < ntohl(ip_v4addr(a2)))
return (-1);
- else if (ntohl(ip_v4addr(a1)) > ntohl(ip_v4addr(a2)))
+
+ if (ntohl(ip_v4addr(a1)) > ntohl(ip_v4addr(a2)))
+ return (1);
+
+ if (ip_bits(a1) < ip_bits(a2))
+ return (-1);
+
+ if (ip_bits(a1) > ip_bits(a2))
return (1);
+
return 0;
}