32 #define hibits(addr) \
33 ((unsigned long)(((addr)->a<<24) | ((addr)->b<<16) | ((addr)->c<<8) | ((addr)->d)))
35 #define lobits(addr) \
36 ((unsigned long)(((addr)->e<<24) | ((addr)->f<<16) | ((addr)->g<<8) | ((addr)->h)))
38 static unsigned char hex2_to_uchar(
const unsigned char *ptr,
bool *badhex);
41 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
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 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
45 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
46 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
47 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
48 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
57 static inline unsigned char
99 Node *escontext = fcinfo->context;
100 const unsigned char *ptr =
str;
112 unsigned char spacer =
'\0';
115 while (*ptr && isspace(*ptr))
119 while (*ptr && *(ptr + 1))
168 if (*ptr ==
':' || *ptr ==
'-' || *ptr ==
'.')
175 else if (spacer != *ptr)
183 if (count == 6 || count == 8)
187 while (*++ptr && isspace(*ptr));
224 (
errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
225 errmsg(
"invalid input syntax for type %s: \"%s\"",
"macaddr8",
238 result = (
char *)
palloc(32);
240 snprintf(result, 32,
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
241 addr->
a, addr->
b, addr->
c, addr->
d,
242 addr->
e, addr->
f, addr->
g, addr->
h);
420 result->
a = ~addr->
a;
421 result->
b = ~addr->
b;
422 result->
c = ~addr->
c;
423 result->
d = ~addr->
d;
424 result->
e = ~addr->
e;
425 result->
f = ~addr->
f;
426 result->
g = ~addr->
g;
427 result->
h = ~addr->
h;
440 result->
a = addr1->
a & addr2->
a;
441 result->
b = addr1->
b & addr2->
b;
442 result->
c = addr1->
c & addr2->
c;
443 result->
d = addr1->
d & addr2->
d;
444 result->
e = addr1->
e & addr2->
e;
445 result->
f = addr1->
f & addr2->
f;
446 result->
g = addr1->
g & addr2->
g;
447 result->
h = addr1->
h & addr2->
h;
460 result->
a = addr1->
a | addr2->
a;
461 result->
b = addr1->
b | addr2->
b;
462 result->
c = addr1->
c | addr2->
c;
463 result->
d = addr1->
d | addr2->
d;
464 result->
e = addr1->
e | addr2->
e;
465 result->
f = addr1->
f | addr2->
f;
466 result->
g = addr1->
g | addr2->
g;
467 result->
h = addr1->
h | addr2->
h;
506 result->
a = addr->
a | 0x02;
530 result->
a = addr6->
a;
531 result->
b = addr6->
b;
532 result->
c = addr6->
c;
535 result->
f = addr6->
d;
536 result->
g = addr6->
e;
537 result->
h = addr6->
f;
551 if ((addr->
d != 0xFF) || (addr->
e != 0xFE))
553 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
554 errmsg(
"macaddr8 data out of range to convert to macaddr"),
555 errhint(
"Only addresses that have FF and FE as values in the "
556 "4th and 5th bytes from the left, for example "
557 "xx:xx:xx:ff:fe:xx:xx:xx, are eligible to be converted "
558 "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)