The MAC half of PostgreSQL's network-address family: macaddr
(EUI-48, 6 bytes) and macaddr8 (EUI-64, 8 bytes), from mac.c and
mac8.c.
Neither could be spelled at all. Their pg_type rows were generated
from pg_type.dat, but nothing mapped the NAMES to them, so
'08:00:2b:01:02:03'::macaddr was type "macaddr" does not exist
and so was a column of one -- taking the rest of the file with it.
A value is held as its canonical text, as the geometric family is.
Here that costs nothing at all: the canonical form is fixed-width
lower-case hex, so lexicographic text order IS macaddr_cmp's
unsigned byte order, and text equality is byte equality. No separate
comparator is needed.
The two input grammars are NOT the same, which is the thing to get
right. macaddr_in is seven fixed sscanf patterns -- the groups
may be 2, 3 or 6 digits wide depending on the pattern. macaddr8_in
is a scanner: hex pairs with ONE separator character used
consistently, 6 or 8 of them, and 6 means an EUI-48 that becomes
EUI-64 by inserting ff:fe after the third byte.
The MAC half of PostgreSQL's network-address family: `macaddr` (EUI-48, 6 bytes) and `macaddr8` (EUI-64, 8 bytes), from `mac.c` and `mac8.c`. Neither could be spelled at all. Their `pg_type` rows were generated from pg_type.dat, but nothing mapped the NAMES to them, so `'08:00:2b:01:02:03'::macaddr` was `type "macaddr" does not exist` and so was a column of one -- taking the rest of the file with it. A value is held as its canonical text, as the geometric family is. Here that costs nothing at all: the canonical form is fixed-width lower-case hex, so lexicographic text order IS `macaddr_cmp`'s unsigned byte order, and text equality is byte equality. No separate comparator is needed. The two input grammars are NOT the same, which is the thing to get right. `macaddr_in` is seven fixed `sscanf` patterns -- the groups may be 2, 3 or 6 digits wide depending on the pattern. `macaddr8_in` is a scanner: hex pairs with ONE separator character used consistently, 6 or 8 of them, and 6 means an EUI-48 that becomes EUI-64 by inserting ff:fe after the third byte.
(mac->mac8 v)macaddr::macaddr8, the EUI-48 to EUI-64 widening.
`macaddr::macaddr8`, the EUI-48 to EUI-64 widening.
(mac-in type-name v)Input for whichever of the two type-name is.
Input for whichever of the two `type-name` is.
(mac-not v)~macaddr, the ones' complement of every byte.
`~macaddr`, the ones' complement of every byte.
(mac-trunc v)trunc(macaddr) zeroes the last THREE bytes and trunc(macaddr8)
the last FIVE -- in both cases everything after the 24-bit OUI.
`trunc(macaddr)` zeroes the last THREE bytes and `trunc(macaddr8)` the last FIVE -- in both cases everything after the 24-bit OUI.
(mac8->mac v)macaddr8::macaddr, which is only defined when the 4th and 5th bytes
are ff and fe -- i.e. when the EUI-64 was made from an EUI-48. Any
other address would lose information, so PostgreSQL refuses it with
a hint saying exactly that.
`macaddr8::macaddr`, which is only defined when the 4th and 5th bytes are ff and fe -- i.e. when the EUI-64 was made from an EUI-48. Any other address would lose information, so PostgreSQL refuses it with a hint saying exactly that.
(mac8-set7bit v)macaddr8_set7bit: set the 7th bit of the first byte, which turns a
locally-administered EUI-64 into the modified form IPv6 wants.
`macaddr8_set7bit`: set the 7th bit of the first byte, which turns a locally-administered EUI-64 into the modified form IPv6 wants.
(macaddr-bytes input)The six bytes of a macaddr, or nil when the text is not one.
The six bytes of a `macaddr`, or nil when the text is not one.
(macaddr-in input)macaddr_in: canonical text, or an invalid input syntax error.
`macaddr_in`: canonical text, or an `invalid input syntax` error.
(macaddr8-bytes input)The eight bytes of a macaddr8, or nil when the text is not one.
macaddr8_in is a scanner, not a set of patterns: it reads hex PAIRS
and allows ONE separator character -- :, - or . -- after any
pair, used consistently. So the groups may be any even width, which
is how 08002b:0102030405 and 0800.2b01.0203.0405 are the same
address, and why mixing : with - is refused.
Six bytes is an EUI-48, which becomes EUI-64 by inserting ff:fe
after the third -- the conversion that makes
'08:00:2b:01:02:03'::macaddr8 into 08:00:2b:ff:fe:01:02:03
rather than a left-padded eight.
The eight bytes of a `macaddr8`, or nil when the text is not one. `macaddr8_in` is a scanner, not a set of patterns: it reads hex PAIRS and allows ONE separator character -- `:`, `-` or `.` -- after any pair, used consistently. So the groups may be any even width, which is how `08002b:0102030405` and `0800.2b01.0203.0405` are the same address, and why mixing `:` with `-` is refused. Six bytes is an EUI-48, which becomes EUI-64 by inserting `ff:fe` after the third -- the conversion that makes `'08:00:2b:01:02:03'::macaddr8` into `08:00:2b:ff:fe:01:02:03` rather than a left-padded eight.
(macaddr8-in input)macaddr8_in: canonical text, or an invalid input syntax error.
`macaddr8_in`: canonical text, or an `invalid input syntax` error.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |