1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Integrate new IP type from Tom Ivar Helbekkmo.

This commit is contained in:
Bruce Momjian
1998-10-03 05:41:01 +00:00
parent 607cd930d5
commit 2d69fd90b9
33 changed files with 3774 additions and 5868 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
# Makefile for utils/adt
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.17 1998/08/24 01:38:04 momjian Exp $
# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.18 1998/10/03 05:40:47 momjian Exp $
#
#-------------------------------------------------------------------------
@ -23,7 +23,8 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o chunk.o \
misc.o nabstime.o name.o not_in.o numutils.o \
oid.o oracle_compat.o \
regexp.o regproc.o ruleutils.o selfuncs.o sets.o \
tid.o timestamp.o varchar.o varlena.o version.o
tid.o timestamp.o varchar.o varlena.o version.o \
ip.o mac.o inet_net_ntop.o inet_net_pton.o
all: SUBSYS.o

View File

@ -0,0 +1,137 @@
/*
* Copyright (c) 1996 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.1 1998/10/03 05:40:48 momjian Exp $";
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef SPRINTF_CHAR
#define SPRINTF(x) strlen(sprintf/**/x)
#else
#define SPRINTF(x) ((size_t)sprintf x)
#endif
static char *inet_net_ntop_ipv4(const u_char *src, int bits,
char *dst, size_t size);
/*
* char *
* inet_net_ntop(af, src, bits, dst, size)
* convert network number from network to presentation format.
* generates CIDR style result always.
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* author:
* Paul Vixie (ISC), July 1996
*/
char *
inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size)
{
switch (af)
{
case AF_INET:
return (inet_net_ntop_ipv4(src, bits, dst, size));
default:
errno = EAFNOSUPPORT;
return (NULL);
}
}
/*
* static char *
* inet_net_ntop_ipv4(src, bits, dst, size)
* convert IPv4 network number from network to presentation format.
* generates CIDR style result always.
* return:
* pointer to dst, or NULL if an error occurred (check errno).
* note:
* network byte order assumed. this means 192.5.5.240/28 has
* 0x11110000 in its fourth octet.
* author:
* Paul Vixie (ISC), July 1996
*/
static char *
inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size)
{
char *odst = dst;
char *t;
u_int m;
int b;
if (bits < 0 || bits > 32)
{
errno = EINVAL;
return (NULL);
}
if (bits == 0)
{
if (size < sizeof "0")
goto emsgsize;
*dst++ = '0';
*dst = '\0';
}
/* Format whole octets. */
for (b = bits / 8; b > 0; b--)
{
if (size < sizeof "255.")
goto emsgsize;
t = dst;
dst += SPRINTF((dst, "%u", *src++));
if (b > 1)
{
*dst++ = '.';
*dst = '\0';
}
size -= (size_t) (dst - t);
}
/* Format partial octet. */
b = bits % 8;
if (b > 0)
{
if (size < sizeof ".255")
goto emsgsize;
t = dst;
if (dst != odst)
*dst++ = '.';
m = ((1 << b) - 1) << (8 - b);
dst += SPRINTF((dst, "%u", *src & m));
size -= (size_t) (dst - t);
}
/* Format CIDR /width. */
if (size < sizeof "/32")
goto emsgsize;
dst += SPRINTF((dst, "/%u", bits));
return (odst);
emsgsize:
errno = EMSGSIZE;
return (NULL);
}

View File

@ -0,0 +1,217 @@
/*
* Copyright (c) 1996 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.1 1998/10/03 05:40:49 momjian Exp $";
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef SPRINTF_CHAR
#define SPRINTF(x) strlen(sprintf/**/x)
#else
#define SPRINTF(x) ((size_t)sprintf x)
#endif
static int inet_net_pton_ipv4(const char *src, u_char *dst, size_t size);
/*
* static int
* inet_net_pton(af, src, dst, size)
* convert network number from presentation to network format.
* accepts hex octets, hex strings, decimal octets, and /CIDR.
* "size" is in bytes and describes "dst".
* return:
* number of bits, either imputed classfully or specified with /CIDR,
* or -1 if some failure occurred (check errno). ENOENT means it was
* not a valid network specification.
* author:
* Paul Vixie (ISC), June 1996
*/
int
inet_net_pton(int af, const char *src, void *dst, size_t size)
{
switch (af)
{
case AF_INET:
return (inet_net_pton_ipv4(src, dst, size));
default:
errno = EAFNOSUPPORT;
return (-1);
}
}
/*
* static int
* inet_net_pton_ipv4(src, dst, size)
* convert IPv4 network number from presentation to network format.
* accepts hex octets, hex strings, decimal octets, and /CIDR.
* "size" is in bytes and describes "dst".
* return:
* number of bits, either imputed classfully or specified with /CIDR,
* or -1 if some failure occurred (check errno). ENOENT means it was
* not an IPv4 network specification.
* note:
* network byte order assumed. this means 192.5.5.240/28 has
* 0x11110000 in its fourth octet.
* author:
* Paul Vixie (ISC), June 1996
*/
static int
inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
{
static const char
xdigits[] = "0123456789abcdef",
digits[] = "0123456789";
int n,
ch,
tmp,
dirty,
bits;
const u_char *odst = dst;
ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
&& isascii(src[1]) && isxdigit(src[1]))
{
/* Hexadecimal: Eat nybble string. */
if (size <= 0)
goto emsgsize;
*dst = 0, dirty = 0;
src++; /* skip x or X. */
while ((ch = *src++) != '\0' &&
isascii(ch) && isxdigit(ch))
{
if (isupper(ch))
ch = tolower(ch);
n = strchr(xdigits, ch) - xdigits;
assert(n >= 0 && n <= 15);
*dst |= n;
if (!dirty++)
*dst <<= 4;
else if (size-- > 0)
*++dst = 0, dirty = 0;
else
goto emsgsize;
}
if (dirty)
size--;
}
else if (isascii(ch) && isdigit(ch))
{
/* Decimal: eat dotted digit string. */
for (;;)
{
tmp = 0;
do
{
n = strchr(digits, ch) - digits;
assert(n >= 0 && n <= 9);
tmp *= 10;
tmp += n;
if (tmp > 255)
goto enoent;
} while ((ch = *src++) != '\0' &&
isascii(ch) && isdigit(ch));
if (size-- <= 0)
goto emsgsize;
*dst++ = (u_char) tmp;
if (ch == '\0' || ch == '/')
break;
if (ch != '.')
goto enoent;
ch = *src++;
if (!isascii(ch) || !isdigit(ch))
goto enoent;
}
}
else
goto enoent;
bits = -1;
if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst)
{
/* CIDR width specifier. Nothing can follow it. */
ch = *src++; /* Skip over the /. */
bits = 0;
do
{
n = strchr(digits, ch) - digits;
assert(n >= 0 && n <= 9);
bits *= 10;
bits += n;
} while ((ch = *src++) != '\0' &&
isascii(ch) && isdigit(ch));
if (ch != '\0')
goto enoent;
if (bits > 32)
goto emsgsize;
}
/* Firey death and destruction unless we prefetched EOS. */
if (ch != '\0')
goto enoent;
/* If nothing was written to the destination, we found no address. */
if (dst == odst)
goto enoent;
/* If no CIDR spec was given, infer width from net class. */
if (bits == -1)
{
if (*odst >= 240) /* Class E */
bits = 32;
else if (*odst >= 224) /* Class D */
bits = 4;
else if (*odst >= 192) /* Class C */
bits = 24;
else if (*odst >= 128) /* Class B */
bits = 16;
else
/* Class A */
bits = 8;
/* If imputed mask is narrower than specified octets, widen. */
if (bits >= 8 && bits < ((dst - odst) * 8))
bits = (dst - odst) * 8;
}
/* Extend network to cover the actual mask. */
while (bits > ((dst - odst) * 8))
{
if (size-- <= 0)
goto emsgsize;
*dst++ = '\0';
}
return (bits);
enoent:
errno = ENOENT;
return (-1);
emsgsize:
errno = EMSGSIZE;
return (-1);
}

283
src/backend/utils/adt/ip.c Normal file
View File

@ -0,0 +1,283 @@
/*
* PostgreSQL type definitions for IP addresses. This
* is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate.
*
* $Id: ip.c,v 1.1 1998/10/03 05:40:49 momjian Exp $
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <postgres.h>
#include <utils/palloc.h>
#include <utils/mac.h>
/*
* Access macros. Add IPV6 support.
*/
#define ip_addrsize(ipaddrptr) \
(((ipaddr_struct *)VARDATA(ipaddrptr))->family == AF_INET ? 4 : -1)
#define ip_family(ipaddrptr) \
(((ipaddr_struct *)VARDATA(ipaddrptr))->family)
#define ip_bits(ipaddrptr) \
(((ipaddr_struct *)VARDATA(ipaddrptr))->bits)
#define ip_v4addr(ipaddrptr) \
(((ipaddr_struct *)VARDATA(ipaddrptr))->addr.ipv4_addr)
/*
* IP address reader.
*/
ipaddr *
ipaddr_in(char *src)
{
int bits;
ipaddr *dst;
dst = palloc(VARHDRSZ + sizeof(ipaddr_struct));
if (dst == NULL)
{
elog(ERROR, "unable to allocate memory in ipaddr_in()");
return (NULL);
}
/* First, try for an IP V4 address: */
ip_family(dst) = AF_INET;
bits = inet_net_pton(ip_family(dst), src, &ip_v4addr(dst), ip_addrsize(dst));
if ((bits < 0) || (bits > 32))
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "could not parse \"%s\"", src);
pfree(dst);
return (NULL);
}
VARSIZE(dst) = VARHDRSZ
+ ((char *) &ip_v4addr(dst) - (char *) VARDATA(dst))
+ ip_addrsize(dst);
ip_bits(dst) = bits;
return (dst);
}
/*
* IP address output function.
*/
char *
ipaddr_out(ipaddr *src)
{
char *dst,
tmp[sizeof("255.255.255.255/32")];
if (ip_family(src) == AF_INET)
{
/* It's an IP V4 address: */
if (inet_net_ntop(AF_INET, &ip_v4addr(src), ip_bits(src),
tmp, sizeof(tmp)) < 0)
{
elog(ERROR, "unable to print address (%s)", strerror(errno));
return (NULL);
}
}
else
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "unknown address family (%d)", ip_family(src));
return (NULL);
}
dst = palloc(strlen(tmp) + 1);
if (dst == NULL)
{
elog(ERROR, "unable to allocate memory in ipaddr_out()");
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
/*
* Boolean tests for magnitude. Add V4/V6 testing!
*/
bool
ipaddr_lt(ipaddr *a1, ipaddr *a2)
{
if ((ip_family(a1) == AF_INET) && (ip_family(a2) == AF_INET))
{
int order = v4bitncmp(ip_v4addr(a1), ip_v4addr(a2), ip_bits(a2));
return ((order < 0) || ((order == 0) && (ip_bits(a1) < ip_bits(a2))));
}
else
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "cannot compare address families %d and %d",
ip_family(a1), ip_family(a2));
return (FALSE);
}
}
bool
ipaddr_le(ipaddr *a1, ipaddr *a2)
{
return (ipaddr_lt(a1, a2) || ipaddr_eq(a1, a2));
}
bool
ipaddr_eq(ipaddr *a1, ipaddr *a2)
{
if ((ip_family(a1) == AF_INET) && (ip_family(a2) == AF_INET))
{
return ((ip_bits(a1) == ip_bits(a2))
&& (v4bitncmp(ip_v4addr(a1), ip_v4addr(a2), ip_bits(a1)) == 0));
}
else
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "cannot compare address families %d and %d",
ip_family(a1), ip_family(a2));
return (FALSE);
}
}
bool
ipaddr_ge(ipaddr *a1, ipaddr *a2)
{
return (ipaddr_gt(a1, a2) || ipaddr_eq(a1, a2));
}
bool
ipaddr_gt(ipaddr *a1, ipaddr *a2)
{
if ((ip_family(a1) == AF_INET) && (ip_family(a2) == AF_INET))
{
int order = v4bitncmp(ip_v4addr(a1), ip_v4addr(a2), ip_bits(a2));
return ((order > 0) || ((order == 0) && (ip_bits(a1) > ip_bits(a2))));
}
else
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "cannot compare address families %d and %d",
ip_family(a1), ip_family(a2));
return (FALSE);
}
}
bool
ipaddr_ne(ipaddr *a1, ipaddr *a2)
{
return (!ipaddr_eq(a1, a2));
}
bool
ipaddr_sub(ipaddr *a1, ipaddr *a2)
{
if ((ip_family(a1) == AF_INET) && (ip_family(a2) == AF_INET))
{
return ((ip_bits(a1) > ip_bits(a2))
&& (v4bitncmp(ip_v4addr(a1), ip_v4addr(a2), ip_bits(a2)) == 0));
}
else
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "cannot compare address families %d and %d",
ip_family(a1), ip_family(a2));
return (FALSE);
}
}
bool
ipaddr_subeq(ipaddr *a1, ipaddr *a2)
{
if ((ip_family(a1) == AF_INET) && (ip_family(a2) == AF_INET))
{
return ((ip_bits(a1) >= ip_bits(a2))
&& (v4bitncmp(ip_v4addr(a1), ip_v4addr(a2), ip_bits(a2)) == 0));
}
else
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "cannot compare address families %d and %d",
ip_family(a1), ip_family(a2));
return (FALSE);
}
}
bool
ipaddr_sup(ipaddr *a1, ipaddr *a2)
{
if ((ip_family(a1) == AF_INET) && (ip_family(a2) == AF_INET))
{
return ((ip_bits(a1) < ip_bits(a2))
&& (v4bitncmp(ip_v4addr(a1), ip_v4addr(a2), ip_bits(a1)) == 0));
}
else
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "cannot compare address families %d and %d",
ip_family(a1), ip_family(a2));
return (FALSE);
}
}
bool
ipaddr_supeq(ipaddr *a1, ipaddr *a2)
{
if ((ip_family(a1) == AF_INET) && (ip_family(a2) == AF_INET))
{
return ((ip_bits(a1) <= ip_bits(a2))
&& (v4bitncmp(ip_v4addr(a1), ip_v4addr(a2), ip_bits(a1)) == 0));
}
else
{
/* Go for an IPV6 address here, before faulting out: */
elog(ERROR, "cannot compare address families %d and %d",
ip_family(a1), ip_family(a2));
return (FALSE);
}
}
/*
* Comparison function for sorting. Add V4/V6 testing!
*/
int4
ipaddr_cmp(ipaddr *a1, ipaddr *a2)
{
if (ntohl(ip_v4addr(a1)) < ntohl(ip_v4addr(a2)))
return (-1);
else if (ntohl(ip_v4addr(a1)) > ntohl(ip_v4addr(a2)))
return (1);
return 0;
}
/*
* Bitwise comparison for V4 addresses. Add V6 implementation!
*/
int
v4bitncmp(u_int32_t a1, u_int32_t a2, int bits)
{
unsigned long mask = 0;
int i;
for (i = 0; i < bits; i++)
mask = (mask >> 1) | 0x80000000;
a1 = ntohl(a1);
a2 = ntohl(a2);
if ((a1 & mask) < (a2 & mask))
return (-1);
else if ((a1 & mask) > (a2 & mask))
return (1);
return (0);
}

323
src/backend/utils/adt/mac.c Normal file
View File

@ -0,0 +1,323 @@
/*
* PostgreSQL type definitions for MAC addresses.
*
* $Id: mac.c,v 1.1 1998/10/03 05:40:50 momjian Exp $
*/
#include <stdio.h>
#include <postgres.h>
#include <utils/palloc.h>
#include <utils/mac.h>
manufacturer manufacturers[] = {
{0x00, 0x00, 0x0C, "Cisco"},
{0x00, 0x00, 0x0E, "Fujitsu"},
{0x00, 0x00, 0x0F, "NeXT"},
{0x00, 0x00, 0x10, "Sytek"},
{0x00, 0x00, 0x1D, "Cabletron"},
{0x00, 0x00, 0x20, "DIAB"},
{0x00, 0x00, 0x22, "Visual Technology"},
{0x00, 0x00, 0x2A, "TRW"},
{0x00, 0x00, 0x32, "GPT Limited"},
{0x00, 0x00, 0x5A, "S & Koch"},
{0x00, 0x00, 0x5E, "IANA"},
{0x00, 0x00, 0x65, "Network General"},
{0x00, 0x00, 0x6B, "MIPS"},
{0x00, 0x00, 0x77, "MIPS"},
{0x00, 0x00, 0x7A, "Ardent"},
{0x00, 0x00, 0x89, "Cayman Systems"},
{0x00, 0x00, 0x93, "Proteon"},
{0x00, 0x00, 0x9F, "Ameristar Technology"},
{0x00, 0x00, 0xA2, "Wellfleet"},
{0x00, 0x00, 0xA3, "Network Application Technology"},
{0x00, 0x00, 0xA6, "Network General"},
{0x00, 0x00, 0xA7, "NCD"},
{0x00, 0x00, 0xA9, "Network Systems"},
{0x00, 0x00, 0xAA, "Xerox"},
{0x00, 0x00, 0xB3, "CIMLinc"},
{0x00, 0x00, 0xB7, "Dove Fastnet"},
{0x00, 0x00, 0xBC, "Allen-Bradley"},
{0x00, 0x00, 0xC0, "Western Digital"},
{0x00, 0x00, 0xC5, "Farallon"},
{0x00, 0x00, 0xC6, "Hewlett-Packard"},
{0x00, 0x00, 0xC8, "Altos"},
{0x00, 0x00, 0xC9, "Emulex"},
{0x00, 0x00, 0xD7, "Dartmouth College"},
{0x00, 0x00, 0xD8, "3Com (?)"},
{0x00, 0x00, 0xDD, "Gould"},
{0x00, 0x00, 0xDE, "Unigraph"},
{0x00, 0x00, 0xE2, "Acer Counterpoint"},
{0x00, 0x00, 0xEF, "Alantec"},
{0x00, 0x00, 0xFD, "High Level Hardware"},
{0x00, 0x01, 0x02, "BBN internal usage"},
{0x00, 0x20, 0xAF, "3Com"},
{0x00, 0x17, 0x00, "Kabel"},
{0x00, 0x80, 0x64, "Wyse Technology"},
{0x00, 0x80, 0x2B, "IMAC (?)"},
{0x00, 0x80, 0x2D, "Xylogics, Inc."},
{0x00, 0x80, 0x8C, "Frontier Software Development"},
{0x00, 0x80, 0xC2, "IEEE 802.1 Committee"},
{0x00, 0x80, 0xD3, "Shiva"},
{0x00, 0xAA, 0x00, "Intel"},
{0x00, 0xDD, 0x00, "Ungermann-Bass"},
{0x00, 0xDD, 0x01, "Ungermann-Bass"},
{0x02, 0x07, 0x01, "Racal InterLan"},
{0x02, 0x04, 0x06, "BBN internal usage"},
{0x02, 0x60, 0x86, "Satelcom MegaPac"},
{0x02, 0x60, 0x8C, "3Com"},
{0x02, 0xCF, 0x1F, "CMC"},
{0x08, 0x00, 0x02, "3Com"},
{0x08, 0x00, 0x03, "ACC"},
{0x08, 0x00, 0x05, "Symbolics"},
{0x08, 0x00, 0x08, "BBN"},
{0x08, 0x00, 0x09, "Hewlett-Packard"},
{0x08, 0x00, 0x0A, "Nestar Systems"},
{0x08, 0x00, 0x0B, "Unisys"},
{0x08, 0x00, 0x11, "Tektronix"},
{0x08, 0x00, 0x14, "Excelan"},
{0x08, 0x00, 0x17, "NSC"},
{0x08, 0x00, 0x1A, "Data General"},
{0x08, 0x00, 0x1B, "Data General"},
{0x08, 0x00, 0x1E, "Apollo"},
{0x08, 0x00, 0x20, "Sun"},
{0x08, 0x00, 0x22, "NBI"},
{0x08, 0x00, 0x25, "CDC"},
{0x08, 0x00, 0x26, "Norsk Data"},
{0x08, 0x00, 0x27, "PCS Computer Systems GmbH"},
{0x08, 0x00, 0x28, "Texas Instruments"},
{0x08, 0x00, 0x2B, "DEC"},
{0x08, 0x00, 0x2E, "Metaphor"},
{0x08, 0x00, 0x2F, "Prime Computer"},
{0x08, 0x00, 0x36, "Intergraph"},
{0x08, 0x00, 0x37, "Fujitsu-Xerox"},
{0x08, 0x00, 0x38, "Bull"},
{0x08, 0x00, 0x39, "Spider Systems"},
{0x08, 0x00, 0x41, "DCA Digital Comm. Assoc."},
{0x08, 0x00, 0x45, "Xylogics (?)"},
{0x08, 0x00, 0x46, "Sony"},
{0x08, 0x00, 0x47, "Sequent"},
{0x08, 0x00, 0x49, "Univation"},
{0x08, 0x00, 0x4C, "Encore"},
{0x08, 0x00, 0x4E, "BICC"},
{0x08, 0x00, 0x56, "Stanford University"},
{0x08, 0x00, 0x58, "DECsystem 20 (?)"},
{0x08, 0x00, 0x5A, "IBM"},
{0x08, 0x00, 0x67, "Comdesign"},
{0x08, 0x00, 0x68, "Ridge"},
{0x08, 0x00, 0x69, "Silicon Graphics"},
{0x08, 0x00, 0x6E, "Concurrent"},
{0x08, 0x00, 0x75, "DDE"},
{0x08, 0x00, 0x7C, "Vitalink"},
{0x08, 0x00, 0x80, "XIOS"},
{0x08, 0x00, 0x86, "Imagen/QMS"},
{0x08, 0x00, 0x87, "Xyplex"},
{0x08, 0x00, 0x89, "Kinetics"},
{0x08, 0x00, 0x8B, "Pyramid"},
{0x08, 0x00, 0x8D, "XyVision"},
{0x08, 0x00, 0x90, "Retix Inc"},
{0x48, 0x44, 0x53, "HDS (?)"},
{0x80, 0x00, 0x10, "AT&T"},
{0xAA, 0x00, 0x00, "DEC"},
{0xAA, 0x00, 0x01, "DEC"},
{0xAA, 0x00, 0x02, "DEC"},
{0xAA, 0x00, 0x03, "DEC"},
{0xAA, 0x00, 0x04, "DEC"},
{0x00, 0x00, 0x00, NULL}
};
/*
* Utility macros used for sorting and comparing:
*/
#define hibits(addr) \
((unsigned long)((addr->a<<16)|(addr->b<<8)|(addr->c)))
#define lobits(addr) \
((unsigned long)((addr->c<<16)|(addr->e<<8)|(addr->f)))
/*
* MAC address reader. Accepts several common notations.
*/
macaddr *
macaddr_in(char *str)
{
int a,
b,
c,
d,
e,
f;
macaddr *result;
int count;
if (strlen(str) > 0)
{
count = sscanf(str, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f);
if (count != 6)
count = sscanf(str, "%x-%x-%x-%x-%x-%x", &a, &b, &c, &d, &e, &f);
if (count != 6)
count = sscanf(str, "%2x%2x%2x:%2x%2x%2x", &a, &b, &c, &d, &e, &f);
if (count != 6)
count = sscanf(str, "%2x%2x%2x-%2x%2x%2x", &a, &b, &c, &d, &e, &f);
if (count != 6)
count = sscanf(str, "%2x%2x.%2x%2x.%2x%2x", &a, &b, &c, &d, &e, &f);
if (count != 6)
{
elog(ERROR, "macaddr_in: error in parsing \"%s\"", str);
return (NULL);
}
if ((a < 0) || (a > 255) || (b < 0) || (b > 255) ||
(c < 0) || (c > 255) || (d < 0) || (d > 255) ||
(e < 0) || (e > 255) || (f < 0) || (f > 255))
{
elog(ERROR, "macaddr_in: illegal address \"%s\"", str);
return (NULL);
}
}
else
{
a = b = c = d = e = f = 0; /* special case for missing
* address */
}
result = (macaddr *) palloc(sizeof(macaddr));
result->a = a;
result->b = b;
result->c = c;
result->d = d;
result->e = e;
result->f = f;
return (result);
}
/*
* MAC address output function. Fixed format.
*/
char *
macaddr_out(macaddr *addr)
{
char *result;
if (addr == NULL)
return (NULL);
result = (char *) palloc(32);
if ((hibits(addr) > 0) || (lobits(addr) > 0))
{
sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
addr->a, addr->b, addr->c, addr->d, addr->e, addr->f);
}
else
{
result[0] = 0; /* special case for missing address */
}
return (result);
}
/*
* Boolean tests.
*/
bool
macaddr_lt(macaddr *a1, macaddr *a2)
{
return ((hibits(a1) < hibits(a2)) ||
((hibits(a1) == hibits(a2)) && lobits(a1) < lobits(a2)));
};
bool
macaddr_le(macaddr *a1, macaddr *a2)
{
return ((hibits(a1) < hibits(a2)) ||
((hibits(a1) == hibits(a2)) && lobits(a1) <= lobits(a2)));
};
bool
macaddr_eq(macaddr *a1, macaddr *a2)
{
return ((hibits(a1) == hibits(a2)) && (lobits(a1) == lobits(a2)));
};
bool
macaddr_ge(macaddr *a1, macaddr *a2)
{
return ((hibits(a1) > hibits(a2)) ||
((hibits(a1) == hibits(a2)) && lobits(a1) >= lobits(a2)));
};
bool
macaddr_gt(macaddr *a1, macaddr *a2)
{
return ((hibits(a1) > hibits(a2)) ||
((hibits(a1) == hibits(a2)) && lobits(a1) > lobits(a2)));
};
bool
macaddr_ne(macaddr *a1, macaddr *a2)
{
return ((hibits(a1) != hibits(a2)) || (lobits(a1) != lobits(a2)));
};
/*
* Comparison function for sorting:
*/
int4
macaddr_cmp(macaddr *a1, macaddr *a2)
{
if (hibits(a1) < hibits(a2))
return -1;
else if (hibits(a1) > hibits(a2))
return 1;
else if (lobits(a1) < lobits(a2))
return -1;
else if (lobits(a1) > lobits(a2))
return 1;
else
return 0;
}
/*
* The special manufacturer fetching function. See "mac.h".
*/
text *
macaddr_manuf(macaddr *addr)
{
manufacturer *manuf;
int length;
text *result;
for (manuf = manufacturers; manuf->name != NULL; manuf++)
{
if ((manuf->a == addr->a) &&
(manuf->b == addr->b) &&
(manuf->c == addr->c))
break;
}
if (manuf->name == NULL)
{
result = palloc(VARHDRSZ + 1);
memset(result, 0, VARHDRSZ + 1);
VARSIZE(result) = VARHDRSZ + 1;
}
else
{
length = strlen(manuf->name) + 1;
result = palloc(length + VARHDRSZ);
memset(result, 0, length + VARHDRSZ);
VARSIZE(result) = length + VARHDRSZ;
memcpy(VARDATA(result), manuf->name, length);
}
return result;
}

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_amop.h,v 1.15 1998/09/01 04:34:48 momjian Exp $
* $Id: pg_amop.h,v 1.16 1998/10/03 05:40:51 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -298,6 +298,26 @@ DATA(insert OID = 0 ( 403 1313 1330 3 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 1313 1335 4 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 1313 1334 5 btreesel btreenpage ));
/*
* nbtree macaddr
*/
DATA(insert OID = 0 ( 403 810 1222 1 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 810 1223 2 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 810 1220 3 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 810 1225 4 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 810 1224 5 btreesel btreenpage ));
/*
* nbtree ip
*/
DATA(insert OID = 0 ( 403 935 1203 1 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 935 1204 2 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 935 1201 3 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 935 1206 4 btreesel btreenpage ));
DATA(insert OID = 0 ( 403 935 1205 5 btreesel btreenpage ));
/*
* hash table _ops
*/

View File

@ -9,7 +9,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_amproc.h,v 1.10 1998/09/01 04:34:49 momjian Exp $
* $Id: pg_amproc.h,v 1.11 1998/10/03 05:40:52 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -99,6 +99,8 @@ DATA(insert OID = 0 (403 1115 1107 1));
DATA(insert OID = 0 (403 1181 359 1));
DATA(insert OID = 0 (403 1312 1314 1));
DATA(insert OID = 0 (403 1313 1315 1));
DATA(insert OID = 0 (403 810 836 1));
DATA(insert OID = 0 (403 935 926 1));
/* hash */

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_opclass.h,v 1.11 1998/09/01 04:35:06 momjian Exp $
* $Id: pg_opclass.h,v 1.12 1998/10/03 05:40:54 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -107,5 +107,9 @@ DATA(insert OID = 1312 ( datetime_ops 1184 ));
DESCR("");
DATA(insert OID = 1313 ( timespan_ops 1186 ));
DESCR("");
DATA(insert OID = 810 ( macaddr_ops 829 ));
DESCR("");
DATA(insert OID = 935 ( ipaddr_ops 869 ));
DESCR("");
#endif /* PG_OPCLASS_H */

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_operator.h,v 1.38 1998/09/14 01:14:48 momjian Exp $
* $Id: pg_operator.h,v 1.39 1998/10/03 05:40:55 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -466,7 +466,7 @@ DATA(insert OID = 1094 ( "<>" PGUID 0 b t f 1082 1082 16 1094 1093 0 0 da
DATA(insert OID = 1095 ( "<" PGUID 0 b t f 1082 1082 16 1097 1098 0 0 date_lt intltsel intltjoinsel ));
DATA(insert OID = 1096 ( "<=" PGUID 0 b t f 1082 1082 16 1098 1097 0 0 date_le intltsel intltjoinsel ));
DATA(insert OID = 1097 ( ">" PGUID 0 b t f 1082 1082 16 1095 1096 0 0 date_gt intltsel intltjoinsel ));
DATA(insert OID = 1098 ( ">=" PGUID 0 b t f 1082 1082 16 1096 1065 0 0 date_ge intltsel intltjoinsel ));
DATA(insert OID = 1098 ( ">=" PGUID 0 b t f 1082 1082 16 1096 1095 0 0 date_ge intltsel intltjoinsel ));
DATA(insert OID = 1099 ( "-" PGUID 0 b t f 1082 1082 23 0 0 0 0 date_mi - - ));
DATA(insert OID = 1100 ( "+" PGUID 0 b t f 1082 23 1082 0 0 0 0 date_pli - - ));
DATA(insert OID = 1101 ( "-" PGUID 0 b t f 1082 23 1082 0 0 0 0 date_mii - - ));
@ -477,7 +477,7 @@ DATA(insert OID = 1109 ( "<>" PGUID 0 b t f 1083 1083 16 1109 1108 0 0 time
DATA(insert OID = 1110 ( "<" PGUID 0 b t f 1083 1083 16 1112 1113 0 0 time_lt intltsel intltjoinsel ));
DATA(insert OID = 1111 ( "<=" PGUID 0 b t f 1083 1083 16 1113 1112 0 0 time_le intltsel intltjoinsel ));
DATA(insert OID = 1112 ( ">" PGUID 0 b t f 1083 1083 16 1110 1111 0 0 time_gt intltsel intltjoinsel ));
DATA(insert OID = 1113 ( ">=" PGUID 0 b t f 1083 1083 16 1111 1065 0 0 time_ge intltsel intltjoinsel ));
DATA(insert OID = 1113 ( ">=" PGUID 0 b t f 1083 1083 16 1111 1110 0 0 time_ge intltsel intltjoinsel ));
/* float48 operators */
DATA(insert OID = 1116 ( "+" PGUID 0 b t f 700 701 701 1116 0 0 0 float48pl - - ));
@ -538,10 +538,10 @@ DATA(insert OID = 1305 ( ">=" PGUID 0 b t f 1296 1296 16 1304 1302 0 0 timest
/* name, owner, prec, kind, isleft, canhash, left, right, result, com, negate, lsortop, rsortop, oprcode, operrest, oprjoin */
DATA(insert OID = 1320 ( "=" PGUID 0 b t t 1184 1184 16 1320 1321 1322 1322 datetime_eq eqsel eqjoinsel ));
DATA(insert OID = 1321 ( "<>" PGUID 0 b t f 1184 1184 16 1321 1320 0 0 datetime_ne neqsel neqjoinsel ));
DATA(insert OID = 1322 ( "<" PGUID 0 b t f 1184 1184 16 1325 1325 0 0 datetime_lt intltsel intltjoinsel ));
DATA(insert OID = 1323 ( "<=" PGUID 0 b t f 1184 1184 16 1324 1324 0 0 datetime_le intltsel intltjoinsel ));
DATA(insert OID = 1324 ( ">" PGUID 0 b t f 1184 1184 16 1323 1323 0 0 datetime_gt intltsel intltjoinsel ));
DATA(insert OID = 1325 ( ">=" PGUID 0 b t f 1184 1184 16 1322 1322 0 0 datetime_ge intltsel intltjoinsel ));
DATA(insert OID = 1322 ( "<" PGUID 0 b t f 1184 1184 16 1324 1325 0 0 datetime_lt intltsel intltjoinsel ));
DATA(insert OID = 1323 ( "<=" PGUID 0 b t f 1184 1184 16 1325 1324 0 0 datetime_le intltsel intltjoinsel ));
DATA(insert OID = 1324 ( ">" PGUID 0 b t f 1184 1184 16 1322 1323 0 0 datetime_gt intltsel intltjoinsel ));
DATA(insert OID = 1325 ( ">=" PGUID 0 b t f 1184 1184 16 1323 1322 0 0 datetime_ge intltsel intltjoinsel ));
DATA(insert OID = 1327 ( "+" PGUID 0 b t f 1184 1186 1184 1327 0 0 0 datetime_pl_span - - ));
DATA(insert OID = 1328 ( "-" PGUID 0 b t f 1184 1184 1186 0 0 0 0 datetime_mi - - ));
@ -550,10 +550,10 @@ DATA(insert OID = 1329 ( "-" PGUID 0 b t f 1184 1186 1184 0 0 0 0 datetim
/* timespan operators */
DATA(insert OID = 1330 ( "=" PGUID 0 b t t 1186 1186 16 1330 1331 1332 1332 timespan_eq eqsel eqjoinsel ));
DATA(insert OID = 1331 ( "<>" PGUID 0 b t f 1186 1186 16 1331 1330 0 0 timespan_ne neqsel neqjoinsel ));
DATA(insert OID = 1332 ( "<" PGUID 0 b t f 1186 1186 16 1335 1335 0 0 timespan_lt intltsel intltjoinsel ));
DATA(insert OID = 1333 ( "<=" PGUID 0 b t f 1186 1186 16 1334 1334 0 0 timespan_le intltsel intltjoinsel ));
DATA(insert OID = 1334 ( ">" PGUID 0 b t f 1186 1186 16 1333 1333 0 0 timespan_gt intltsel intltjoinsel ));
DATA(insert OID = 1335 ( ">=" PGUID 0 b t f 1186 1186 16 1332 1332 0 0 timespan_ge intltsel intltjoinsel ));
DATA(insert OID = 1332 ( "<" PGUID 0 b t f 1186 1186 16 1334 1335 0 0 timespan_lt intltsel intltjoinsel ));
DATA(insert OID = 1333 ( "<=" PGUID 0 b t f 1186 1186 16 1335 1334 0 0 timespan_le intltsel intltjoinsel ));
DATA(insert OID = 1334 ( ">" PGUID 0 b t f 1186 1186 16 1332 1333 0 0 timespan_gt intltsel intltjoinsel ));
DATA(insert OID = 1335 ( ">=" PGUID 0 b t f 1186 1186 16 1333 1332 0 0 timespan_ge intltsel intltjoinsel ));
DATA(insert OID = 1336 ( "-" PGUID 0 l t f 0 1186 1186 0 0 0 0 timespan_um 0 0 ));
DATA(insert OID = 1337 ( "+" PGUID 0 b t f 1186 1186 1186 1337 0 0 0 timespan_pl - - ));
@ -563,10 +563,10 @@ DATA(insert OID = 1338 ( "-" PGUID 0 b t f 1186 1186 1186 0 0 0 0 timespa
DATA(insert OID = 1420 ( "@@" PGUID 0 l t f 0 718 600 0 0 0 0 circle_center - - ));
DATA(insert OID = 1500 ( "=" PGUID 0 b t t 718 718 16 1500 1501 1502 1502 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1501 ( "<>" PGUID 0 b t f 718 718 16 1501 1500 0 0 circle_ne neqsel neqjoinsel ));
DATA(insert OID = 1502 ( "<" PGUID 0 b t f 718 718 16 0 0 0 0 circle_lt areasel areajoinsel ));
DATA(insert OID = 1503 ( ">" PGUID 0 b t f 718 718 16 0 0 0 0 circle_gt areasel areajoinsel ));
DATA(insert OID = 1504 ( "<=" PGUID 0 b t f 718 718 16 0 0 0 0 circle_le areasel areajoinsel ));
DATA(insert OID = 1505 ( ">=" PGUID 0 b t f 718 718 16 0 0 0 0 circle_ge areasel areajoinsel ));
DATA(insert OID = 1502 ( "<" PGUID 0 b t f 718 718 16 1503 1505 0 0 circle_lt areasel areajoinsel ));
DATA(insert OID = 1503 ( ">" PGUID 0 b t f 718 718 16 1502 1504 0 0 circle_gt areasel areajoinsel ));
DATA(insert OID = 1504 ( "<=" PGUID 0 b t f 718 718 16 1505 1503 0 0 circle_le areasel areajoinsel ));
DATA(insert OID = 1505 ( ">=" PGUID 0 b t f 718 718 16 1504 1502 0 0 circle_ge areasel areajoinsel ));
DATA(insert OID = 1506 ( "<<" PGUID 0 b t f 718 718 16 0 0 0 0 circle_left intltsel intltjoinsel ));
DATA(insert OID = 1507 ( "&<" PGUID 0 b t f 718 718 16 0 0 0 0 circle_overleft intltsel intltjoinsel ));
@ -635,6 +635,27 @@ DATA(insert OID = 1615 ( "?|" PGUID 0 l t f 0 628 16 1615 0 0 0 line_ver
DATA(insert OID = 1616 ( "=" PGUID 0 b t f 628 628 16 1616 0 0 0 line_eq intltsel - ));
DATA(insert OID = 1617 ( "#" PGUID 0 b t f 628 628 600 1617 0 0 0 line_interpt - - ));
/* MAC type */
DATA(insert OID = 1220 ( "=" PGUID 0 b t t 829 829 16 1220 1221 0 0 macaddr_eq eqsel eqjoinsel ));
DATA(insert OID = 1221 ( "<>" PGUID 0 b t f 829 829 16 1221 1220 0 0 macaddr_ne neqsel neqjoinsel ));
DATA(insert OID = 1222 ( "<" PGUID 0 b t f 829 829 16 1224 1225 0 0 macaddr_lt intltsel intltjoinsel ));
DATA(insert OID = 1223 ( "<=" PGUID 0 b t f 829 829 16 1225 1224 0 0 macaddr_le intltsel intltjoinsel ));
DATA(insert OID = 1224 ( ">" PGUID 0 b t f 829 829 16 1222 1223 0 0 macaddr_gt intltsel intltjoinsel ));
DATA(insert OID = 1225 ( ">=" PGUID 0 b t f 829 829 16 1223 1222 0 0 macaddr_ge intltsel intltjoinsel ));
/* IP type */
DATA(insert OID = 1201 ( "=" PGUID 0 b t t 869 869 16 1201 1202 0 0 ipaddr_eq eqsel eqjoinsel ));
DATA(insert OID = 1202 ( "<>" PGUID 0 b t f 869 869 16 1202 1201 0 0 ipaddr_ne neqsel neqjoinsel ));
DATA(insert OID = 1203 ( "<" PGUID 0 b t f 869 869 16 1205 1206 0 0 ipaddr_lt intltsel intltjoinsel ));
DATA(insert OID = 1204 ( "<=" PGUID 0 b t f 869 869 16 1206 1205 0 0 ipaddr_le intltsel intltjoinsel ));
DATA(insert OID = 1205 ( ">" PGUID 0 b t f 869 869 16 1203 1204 0 0 ipaddr_gt intltsel intltjoinsel ));
DATA(insert OID = 1206 ( ">=" PGUID 0 b t f 869 869 16 1204 1203 0 0 ipaddr_ge intltsel intltjoinsel ));
DATA(insert OID = 931 ( "<<" PGUID 0 b t f 869 869 16 933 934 0 0 ipaddr_sub intltsel intltjoinsel ));
DATA(insert OID = 932 ( "<<=" PGUID 0 b t f 869 869 16 934 933 0 0 ipaddr_subeq intltsel intltjoinsel ));
DATA(insert OID = 933 ( ">>" PGUID 0 b t f 869 869 16 931 932 0 0 ipaddr_sup intltsel intltjoinsel ));
DATA(insert OID = 934 ( ">>=" PGUID 0 b t f 869 869 16 932 931 0 0 ipaddr_supeq intltsel intltjoinsel ));
/*
* function prototypes
*/

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_proc.h,v 1.70 1998/10/02 16:27:55 momjian Exp $
* $Id: pg_proc.h,v 1.71 1998/10/03 05:40:56 momjian Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@ -2045,6 +2045,59 @@ DESCR("user name by UID (with fallback)");
DATA(insert OID = 1643 ( pg_get_indexdef PGUID 11 f t f 1 f 25 "26" 100 0 0 100 foo bar ));
DESCR("index description");
/* for mac type support */
DATA(insert OID = 436 ( macaddr_in PGUID 11 f t f 1 f 829 "0" 100 0 0 100 foo bar ));
DESCR("(internal)");
DATA(insert OID = 437 ( macaddr_out PGUID 11 f t f 1 f 23 "0" 100 0 0 100 foo bar ));
DESCR("(internal)");
DATA(insert OID = 830 ( macaddr_eq PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 foo bar ));
DESCR("equal");
DATA(insert OID = 831 ( macaddr_lt PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 foo bar ));
DESCR("less-than");
DATA(insert OID = 832 ( macaddr_le PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 foo bar ));
DESCR("less-than-or-equal");
DATA(insert OID = 833 ( macaddr_gt PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 foo bar ));
DESCR("greater-than");
DATA(insert OID = 834 ( macaddr_ge PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 foo bar ));
DESCR("greater-than-or-equal");
DATA(insert OID = 835 ( macaddr_ne PGUID 11 f t f 2 f 16 "829 829" 100 0 0 100 foo bar ));
DESCR("not equal");
DATA(insert OID = 836 ( macaddr_cmp PGUID 11 f t f 2 f 23 "829 829" 100 0 0 100 foo bar ));
DESCR("less-equal-greater");
DATA(insert OID = 837 ( macaddr_manuf PGUID 11 f t f 1 f 25 "829" 100 0 0 100 foo bar ));
DESCR("MAC manufacturer");
/* for ip type support */
DATA(insert OID = 910 ( ipaddr_in PGUID 11 f t f 1 f 869 "0" 100 0 0 100 foo bar ));
DESCR("(internal)");
DATA(insert OID = 911 ( ipaddr_out PGUID 11 f t f 1 f 23 "0" 100 0 0 100 foo bar ));
DESCR("(internal)");
DATA(insert OID = 920 ( ipaddr_eq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("equal");
DATA(insert OID = 921 ( ipaddr_lt PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("less-than");
DATA(insert OID = 922 ( ipaddr_le PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("less-than-or-equal");
DATA(insert OID = 923 ( ipaddr_gt PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("greater-than");
DATA(insert OID = 924 ( ipaddr_ge PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("greater-than-or-equal");
DATA(insert OID = 925 ( ipaddr_ne PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("not equal");
DATA(insert OID = 926 ( ipaddr_cmp PGUID 11 f t f 2 f 23 "869 869" 100 0 0 100 foo bar ));
DESCR("less-equal-greater");
DATA(insert OID = 927 ( ipaddr_sub PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("is-subnet");
DATA(insert OID = 928 ( ipaddr_subeq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("is-subnet-or-equal");
DATA(insert OID = 929 ( ipaddr_sup PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("is-supernet");
DATA(insert OID = 930 ( ipaddr_supeq PGUID 11 f t f 2 f 16 "869 869" 100 0 0 100 foo bar ));
DESCR("is-supernet-or-equal");
/*
* prototypes for functions pg_proc.c
*/

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_type.h,v 1.47 1998/09/01 04:35:18 momjian Exp $
* $Id: pg_type.h,v 1.48 1998/10/03 05:40:58 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -298,6 +298,10 @@ DESCR("money '$d,ddd.cc'");
DATA(insert OID = 791 ( _money PGUID -1 -1 f b t \054 0 790 array_in array_out array_in array_out i _null_ ));
/* OIDS 800 - 899 */
DATA(insert OID = 829 ( macaddr PGUID 6 -1 f b t \054 0 0 macaddr_in macaddr_out macaddr_in macaddr_out i _null_ ));
DESCR("MAC address");
DATA(insert OID = 869 ( ipaddr PGUID -1 -1 f b t \054 0 0 ipaddr_in ipaddr_out ipaddr_in ipaddr_out i _null_ ));
DESCR("IP address");
/* OIDS 900 - 999 */
@ -333,8 +337,9 @@ DATA(insert OID = 1027 ( _polygon PGUID -1 -1 f b t \054 0 604 array_in array
/* Note: the size of an aclitem needs to match sizeof(AclItem) in acl.h */
DATA(insert OID = 1033 ( aclitem PGUID 8 -1 f b t \054 0 0 aclitemin aclitemout aclitemin aclitemout i _null_ ));
DESCR("access control list");
DATA(insert OID = 1034 ( _aclitem PGUID -1 -1 f b t \054 0 1033 array_in array_out array_in array_out i _null_ ));
DATA(insert OID = 1034 ( _aclitem PGUID -1 -1 f b t \054 0 1033 array_in array_out array_in array_out i _null_ ));
DATA(insert OID = 1040 ( _macaddr PGUID -1 -1 f b t \054 0 829 array_in array_out array_in array_out i _null_ ));
DATA(insert OID = 1041 ( _ipaddr PGUID -1 -1 f b t \054 0 869 array_in array_out array_in array_out i _null_ ));
DATA(insert OID = 1042 ( bpchar PGUID -1 -1 f b t \054 0 18 bpcharin bpcharout bpcharin bpcharout i _null_ ));
DESCR("blank-padded characters, length specifed when created");
#define BPCHAROID 1042

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: builtins.h,v 1.55 1998/09/22 20:28:13 momjian Exp $
* $Id: builtins.h,v 1.56 1998/10/03 05:40:59 momjian Exp $
*
* NOTES
* This should normally only be included by fmgr.h.
@ -28,6 +28,7 @@
#include <utils/nabstime.h>
#include <utils/int8.h>
#include <utils/cash.h>
#include <utils/mac.h>
#include <utils/rel.h>
/*
@ -511,4 +512,40 @@ extern text *translate(text *string, char from, char to);
/* acl.c */
/* inet_net_ntop.c */
char *inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size);
/* inet_net_pton.c */
int inet_net_pton(int af, const char *src, void *dst, size_t size);
/* ip.c */
ipaddr *ipaddr_in(char *str);
char *ipaddr_out(ipaddr * addr);
bool ipaddr_lt(ipaddr * a1, ipaddr * a2);
bool ipaddr_le(ipaddr * a1, ipaddr * a2);
bool ipaddr_eq(ipaddr * a1, ipaddr * a2);
bool ipaddr_ge(ipaddr * a1, ipaddr * a2);
bool ipaddr_gt(ipaddr * a1, ipaddr * a2);
bool ipaddr_ne(ipaddr * a1, ipaddr * a2);
bool ipaddr_sub(ipaddr * a1, ipaddr * a2);
bool ipaddr_subeq(ipaddr * a1, ipaddr * a2);
bool ipaddr_sup(ipaddr * a1, ipaddr * a2);
bool ipaddr_supeq(ipaddr * a1, ipaddr * a2);
int4 ipaddr_cmp(ipaddr * a1, ipaddr * a2);
int v4bitncmp(u_int32_t a1, u_int32_t a2, int bits);
/* mac.c */
macaddr *macaddr_in(char *str);
char *macaddr_out(macaddr * addr);
bool macaddr_lt(macaddr * a1, macaddr * a2);
bool macaddr_le(macaddr * a1, macaddr * a2);
bool macaddr_eq(macaddr * a1, macaddr * a2);
bool macaddr_ge(macaddr * a1, macaddr * a2);
bool macaddr_gt(macaddr * a1, macaddr * a2);
bool macaddr_ne(macaddr * a1, macaddr * a2);
int4 macaddr_cmp(macaddr * a1, macaddr * a2);
text *macaddr_manuf(macaddr * addr);
#endif /* BUILTINS_H */

58
src/include/utils/mac.h Normal file
View File

@ -0,0 +1,58 @@
/*-------------------------------------------------------------------------
*
* builtins.h--
* Declarations for operations on built-in types.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: mac.h,v 1.1 1998/10/03 05:41:01 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef MAC_H
#define MAC_H
/*
* This is the internal storage format for IP addresses:
*/
typedef struct
{
unsigned char family;
unsigned char bits;
union
{
u_int32_t ipv4_addr; /* network byte order */
/* add IPV6 address type here */
} addr;
} ipaddr_struct;
typedef struct varlena ipaddr;
/*
* This is the internal storage format for MAC addresses:
*/
typedef struct macaddr
{
unsigned char a;
unsigned char b;
unsigned char c;
unsigned char d;
unsigned char e;
unsigned char f;
} macaddr;
typedef struct manufacturer
{
unsigned char a;
unsigned char b;
unsigned char c;
char *name;
} manufacturer;
extern manufacturer manufacturers[];
#endif /* MAC_H */

View File

@ -786,6 +786,8 @@ do
-Tword8 \
-Tyy_size_t \
-Tyy_state_type \
-Tipaddr \
-Tmacaddr \
/tmp/$$a >/tmp/$$ 2>&1
if [ "$?" -ne 0 -o -s /tmp/$$ ]
then echo "$FILE"