27 #include "utils/fmgrprotos.h"
33 #define hibits(addr) \
34 ((unsigned long)(((addr)->a<<24) | ((addr)->b<<16) | ((addr)->c<<8) | ((addr)->d)))
36 #define lobits(addr) \
37 ((unsigned long)(((addr)->e<<24) | ((addr)->f<<16) | ((addr)->g<<8) | ((addr)->h)))
39 static unsigned char hex2_to_uchar(
const unsigned char *ptr,
bool *badhex);
42 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
43 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
44 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
45 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
46 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
47 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
48 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
49 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
58 static inline unsigned char
100 Node *escontext = fcinfo->context;
101 const unsigned char *ptr =
str;
113 unsigned char spacer =
'\0';
116 while (*ptr && isspace(*ptr))
120 while (*ptr && *(ptr + 1))
169 if (*ptr ==
':' || *ptr ==
'-' || *ptr ==
'.')
176 else if (spacer != *ptr)
184 if (count == 6 || count == 8)
188 while (*++ptr && isspace(*ptr));
225 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
226 errmsg(
"invalid input syntax for type %s: \"%s\"",
"macaddr8",
239 result = (
char *)
palloc(32);
241 snprintf(result, 32,
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
242 addr->
a, addr->
b, addr->
c, addr->
d,
243 addr->
e, addr->
f, addr->
g, addr->
h);
421 result->
a = ~addr->
a;
422 result->
b = ~addr->
b;
423 result->
c = ~addr->
c;
424 result->
d = ~addr->
d;
425 result->
e = ~addr->
e;
426 result->
f = ~addr->
f;
427 result->
g = ~addr->
g;
428 result->
h = ~addr->
h;
441 result->
a = addr1->
a & addr2->
a;
442 result->
b = addr1->
b & addr2->
b;
443 result->
c = addr1->
c & addr2->
c;
444 result->
d = addr1->
d & addr2->
d;
445 result->
e = addr1->
e & addr2->
e;
446 result->
f = addr1->
f & addr2->
f;
447 result->
g = addr1->
g & addr2->
g;
448 result->
h = addr1->
h & addr2->
h;
461 result->
a = addr1->
a | addr2->
a;
462 result->
b = addr1->
b | addr2->
b;
463 result->
c = addr1->
c | addr2->
c;
464 result->
d = addr1->
d | addr2->
d;
465 result->
e = addr1->
e | addr2->
e;
466 result->
f = addr1->
f | addr2->
f;
467 result->
g = addr1->
g | addr2->
g;
468 result->
h = addr1->
h | addr2->
h;
507 result->
a = addr->
a | 0x02;
531 result->
a = addr6->
a;
532 result->
b = addr6->
b;
533 result->
c = addr6->
c;
536 result->
f = addr6->
d;
537 result->
g = addr6->
e;
538 result->
h = addr6->
f;
552 if ((addr->
d != 0xFF) || (addr->
e != 0xFE))
554 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
555 errmsg(
"macaddr8 data out of range to convert to macaddr"),
556 errhint(
"Only addresses that have FF and FE as values in the "
557 "4th and 5th bytes from the left, for example "
558 "xx:xx:xx:ff:fe:xx:xx:xx, are eligible to be converted "
559 "from macaddr8 to macaddr.")));
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define ereport(elevel,...)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_INT64(n)
#define PG_RETURN_INT32(x)
#define PG_RETURN_BOOL(x)
static Datum hash_any_extended(const unsigned char *k, int keylen, uint64 seed)
static Datum hash_any(const unsigned char *k, int keylen)
static const FormData_pg_attribute a1
static const FormData_pg_attribute a2
static unsigned char hex2_to_uchar(const unsigned char *ptr, bool *badhex)
Datum macaddr8_or(PG_FUNCTION_ARGS)
Datum macaddrtomacaddr8(PG_FUNCTION_ARGS)
Datum macaddr8_out(PG_FUNCTION_ARGS)
static const signed char hexlookup[128]
Datum macaddr8_set7bit(PG_FUNCTION_ARGS)
Datum macaddr8_cmp(PG_FUNCTION_ARGS)
Datum macaddr8tomacaddr(PG_FUNCTION_ARGS)
Datum macaddr8_eq(PG_FUNCTION_ARGS)
static int32 macaddr8_cmp_internal(macaddr8 *a1, macaddr8 *a2)
Datum macaddr8_and(PG_FUNCTION_ARGS)
Datum macaddr8_gt(PG_FUNCTION_ARGS)
Datum macaddr8_recv(PG_FUNCTION_ARGS)
Datum macaddr8_in(PG_FUNCTION_ARGS)
Datum macaddr8_trunc(PG_FUNCTION_ARGS)
Datum macaddr8_ge(PG_FUNCTION_ARGS)
Datum hashmacaddr8(PG_FUNCTION_ARGS)
Datum macaddr8_send(PG_FUNCTION_ARGS)
Datum macaddr8_not(PG_FUNCTION_ARGS)
Datum macaddr8_ne(PG_FUNCTION_ARGS)
Datum macaddr8_lt(PG_FUNCTION_ARGS)
Datum hashmacaddr8extended(PG_FUNCTION_ARGS)
Datum macaddr8_le(PG_FUNCTION_ARGS)
void * palloc0(Size size)
StringInfoData * StringInfo
#define PG_GETARG_MACADDR_P(n)
#define PG_GETARG_MACADDR8_P(n)
#define PG_RETURN_MACADDR8_P(x)
#define PG_RETURN_MACADDR_P(x)