9.12. 網路位址函式及運算子

    Table 9.36. cidrandinetOperators

    Table 9.37shows the functions available for use with thecidrandinettypes. Theabbrev,host, andtextfunctions are primarily intended to offer alternative display formats.

    Anycidrvalue can be cast toinetimplicitly or explicitly; therefore, the functions shown above as operating oninetalso work oncidrvalues. (Where there are separate functions forinetandcidr, it is because the behavior should be different for the two cases.) Also, it is permitted to cast aninetvalue tocidr. When this is done, any bits to the right of the netmask are silently zeroed to create a validcidrvalue. In addition, you can cast a text value toinetorcidrusing normal casting syntax: for example,inet(expression)orcolname::cidr.

    shows the functions available for use with themacaddrtype. The functiontrunc(macaddr)returns a MAC address with the last 3 bytes set to zero. This can be used to associate the remaining prefix with a manufacturer.

    Themacaddrtype also supports the standard relational operators (>,<=, etc.) for lexicographical ordering, and the bitwise arithmetic operators (~,&and|) for NOT, AND and OR.

    Table 9.39shows the functions available for use with themacaddr8type. The functiontrunc(macaddr8)returns a MAC address with the last 5 bytes set to zero. This can be used to associate the remaining prefix with a manufacturer.

    Themacaddr8type also supports the standard relational operators (>,<=, etc.) for ordering, and the bitwise arithmetic operators (~,and|) for NOT, AND and OR.