Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbaa3a09

Browse files
committed
Convert macaddr documentation to DocBook, update outdated information.
1 parent2d5ff2f commitbaa3a09

File tree

4 files changed

+135
-153
lines changed

4 files changed

+135
-153
lines changed

‎doc/README.inet

Lines changed: 0 additions & 74 deletions
This file was deleted.

‎doc/src/sgml/datatype.sgml

Lines changed: 85 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.37 2000/09/29 20:21:33 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.38 2000/10/04 15:47:45 petere Exp $
33
-->
44

55
<chapter id="datatype">
@@ -1732,67 +1732,78 @@ January 8 04:05:06 1999 PST
17321732
</sect1>
17331733

17341734
<sect1 id="net-types">
1735-
<title>IP Version 4 Networks and Host Addresses</title>
1735+
<title>Network Address Data Types</title>
17361736

17371737
<para>
1738-
The <type>cidr</type> type stores networks specified
1739-
in <acronym>CIDR</acronym> (Classless Inter-Domain Routing) notation.
1740-
The <type>inet</type> type stores hosts and networks in CIDR notation using a simple
1741-
variation in representation to represent simple host TCP/IP addresses.
1742-
</para>
1738+
<productname>Postgres</> offers data types to store IP and MAC
1739+
addresses. It is preferrable to use these types over plain text
1740+
types, because these types offer input error checking and several
1741+
specialized operators and functions.
17431742

1744-
<para>
1745-
<table tocentry="1">
1746-
<title><productname>Postgres</productname>IP Version 4 Types</title>
1747-
<titleabbrev>IPV4</titleabbrev>
1743+
<table tocentry="1" id="net-types-table">
1744+
<title>Network Address Data Types</title>
17481745
<tgroup cols="4">
17491746
<thead>
17501747
<row>
1751-
<entry>IPV4 Type</entry>
1748+
<entry>Name</entry>
17521749
<entry>Storage</entry>
17531750
<entry>Description</entry>
17541751
<entry>Range</entry>
17551752
</row>
17561753
</thead>
17571754
<tbody>
1755+
17581756
<row>
17591757
<entry>cidr</entry>
1760-
<entry>variable</entry>
1761-
<entry>CIDR networks</entry>
1762-
<entry>Valid IPV4 CIDR blocks</entry>
1758+
<entry>11 bytes</entry>
1759+
<entry>IP networks</entry>
1760+
<entry>valid IPv4 networks</entry>
17631761
</row>
1762+
17641763
<row>
17651764
<entry>inet</entry>
1766-
<entry>variable</entry>
1767-
<entry>netsandhosts</entry>
1768-
<entry>Valid IPV4 CIDR blocks</entry>
1765+
<entry>11 bytes</entry>
1766+
<entry>IP hostsandnetworks</entry>
1767+
<entry>valid IPv4 hosts</entry>
17691768
</row>
1769+
1770+
<row>
1771+
<entry>macaddr</entry>
1772+
<entry>6 bytes</entry>
1773+
<entry>MAC addresses</entry>
1774+
<entry>customary formats</entry>
1775+
</row>
1776+
17701777
</tbody>
17711778
</tgroup>
17721779
</table>
17731780
</para>
17741781

1775-
<sect2>
1776-
<title>CIDR</title>
1782+
<para>
1783+
IP v6 is not supported, yet.
1784+
</para>
1785+
1786+
1787+
<sect2 id="cidr-type">
1788+
<title><type>cidr</></title>
17771789

17781790
<para>
1779-
The <type>cidr</type> type holds a CIDR network.
1780-
The format for specifying classless networks is
1781-
<replaceable class="parameter">x.x.x.x/y</replaceable>
1782-
where <replaceable class="parameter">x.x.x.x</replaceable> is the
1783-
network and <replaceable class="parameter">/y</replaceable> is
1784-
the number of bits in the netmask.
1785-
If <replaceable class="parameter">/y</replaceable> omitted, it is
1786-
calculated using assumptions from
1787-
the older classfull naming system except that it is extended to include at least
1788-
all of the octets in the input.
1791+
The <type>cidr</type> type holds an IP network. The format for
1792+
specifying classless networks is <replaceable
1793+
class="parameter">x.x.x.x/y</> where <replaceable
1794+
class="parameter">x.x.x.x</> is the network and <replaceable
1795+
class="parameter">y</> is the number of bits in the netmask. If
1796+
<replaceable class="parameter">y</> omitted, it is calculated
1797+
using assumptions from the older classfull naming system except
1798+
that it is extended to include at least all of the octets in the
1799+
input.
17891800
</para>
17901801

17911802
<para>
17921803
Here are some examples:
17931804

17941805
<table tocentry="1">
1795-
<title><productname>Postgres</productname>IP Types Examples</title>
1806+
<title><type>cidr</> Type Input Examples</title>
17961807
<tgroup cols="2">
17971808
<thead>
17981809
<row>
@@ -1801,6 +1812,14 @@ January 8 04:05:06 1999 PST
18011812
</row>
18021813
</thead>
18031814
<tbody>
1815+
<row>
1816+
<entry>192.168.100.128/25</entry>
1817+
<entry>192.168.100.128/25</entry>
1818+
</row>
1819+
<row>
1820+
<entry>192.168/25</entry>
1821+
<entry>192.168.0.0/25</entry>
1822+
</row>
18041823
<row>
18051824
<entry>192.168.1</entry>
18061825
<entry>192.168.1/24</entry>
@@ -1839,34 +1858,48 @@ January 8 04:05:06 1999 PST
18391858
</para>
18401859
</sect2>
18411860

1842-
<sect2>
1843-
<title id="inet-type"><type>inet</type></title>
1861+
<sect2 id="inet-type">
1862+
<title><type>inet</type></title>
18441863

18451864
<para>
1846-
The <type>inet</type> type is designed to hold, in one field, all of the information
1847-
about a host including the CIDR-style subnet that it is in.
1848-
Note that if you want to store proper CIDR networks,
1849-
you should use the <type>cidr</type> type.
1850-
The <type>inet</type> type is similar to the <type>cidr</type>
1851-
type except that the bits in the
1852-
host part can be non-zero.
1853-
Functions exist to extract the various elements of the field.
1865+
The <type>inet</type> type holds an IP host address, and
1866+
optionally the identity of the subnet it is in, all in one field.
1867+
Note that if you want to store networks only, you should use the
1868+
<type>cidr</type> type. The <type>inet</type> type is similar to
1869+
the <type>cidr</type> type except that the bits in the host part
1870+
can be non-zero. Functions exist to extract the various elements
1871+
of the field.
18541872
</para>
18551873

18561874
<para>
1857-
The input format for this function is
1858-
<replaceable class="parameter">x.x.x.x/y</replaceable>
1859-
where <replaceable class="parameter">x.x.x.x</replaceable> is
1860-
an internet host and <replaceable class="parameter">y</replaceable>
1861-
is the number of bits in the netmask.
1862-
If the <replaceable class="parameter">/y</replaceable> part is left off,
1863-
it is treated as <literal>/32</literal>.
1864-
On output, the <replaceable class="parameter">/y</replaceable> part is not printed
1865-
if it is <literal>/32</literal>.
1866-
This allows the type to be used as a straight host type by just leaving off
1867-
the bits part.
1875+
The input format for this type is <replaceable
1876+
class="parameter">x.x.x.x/y</replaceable> where <replaceable
1877+
class="parameter">x.x.x.x</replaceable> is an internet host and
1878+
<replaceable class="parameter">y</replaceable> is the number of
1879+
bits in the netmask. If the <replaceable
1880+
class="parameter">y</replaceable> part is left off, then the
1881+
netmask is 32 and you are effectively only storing the address of
1882+
a single host.
18681883
</para>
18691884
</sect2>
1885+
1886+
<sect2 id="macaddr-type">
1887+
<title><type>macaddr</></>
1888+
1889+
<para>
1890+
The <type>macaddr</> type stores MAC addresses, i.e., Ethernet
1891+
card hardware addresses (although MAC addresses are used for
1892+
other purposes as well). Input is accepted in various customary
1893+
formats, including <literal>'08002b:010203'</>,
1894+
<literal>'08002b-010203'</>, <literal>'0800.2b01.0203'</>,
1895+
<literal>'08-00-2b-01-02-03'</>, and
1896+
<literal>'08:00:2b:01:02:03'</>, which would all specify the same
1897+
address. Upper and lower case is accepted for the digits
1898+
<literal>a</> through <literal>f</>. Output is always in the
1899+
latter of the given forms.
1900+
</para>
1901+
</sect2>
1902+
18701903
</sect1>
18711904

18721905
</chapter>

‎doc/src/sgml/func.sgml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -945,17 +945,18 @@
945945

946946
<listitem>
947947
<para>
948-
A double quote ('"') between quotation marks is skipped and is not parsed.
949-
If you want to write a double quote to output you must preceed
950-
it with a double backslash (<literal>'\\"</literal>), for
951-
example <literal>'\\"YYYY Month\\"'</literal>.
948+
A double quote (<quote><literal>"</literal></quote>) between
949+
quotation marks is skipped and is not parsed. If you want to
950+
write a double quote to output you must preceed it with a
951+
double backslash (<literal>'\\"</literal>), for example
952+
<literal>'\\"YYYY Month\\"'</literal>.
952953
</para>
953954
</listitem>
954955

955956
<listitem>
956957
<para>
957958
<function>to_char</function> supports text without a leading
958-
double quote('"'),but any string
959+
double quote but any string
959960
between a quotation marks is rapidly handled and you are
960961
guaranteed that it will not be interpreted as a template
961962
keyword (example: <literal>'"Hello Year: "YYYY'</literal>).
@@ -1473,12 +1474,12 @@ Not defined by this name. Implements the intersection operator '#'
14731474
</para>
14741475
</sect1>
14751476

1476-
<sect1 id="cidr-functions">
1477-
<title>IP V4 Functions</title>
1477+
<sect1 id="net-functions">
1478+
<title>Network Address Type Functions</title>
14781479

14791480
<para>
1480-
<table tocentry="1">
1481-
<title><productname>Postgres</productname>IP V4 Functions</title>
1481+
<table tocentry="1" id="cidr-inet-functions">
1482+
<title><type>cidr</> and <type>inet</> Functions</title>
14821483
<tgroup cols="4">
14831484
<thead>
14841485
<row>
@@ -1509,13 +1510,13 @@ Not defined by this name. Implements the intersection operator '#'
15091510
</row>
15101511
<row>
15111512
<entry>masklen(cidr)</entry>
1512-
<entry>int4</entry>
1513+
<entry>integer</entry>
15131514
<entry>calculate netmask length</entry>
15141515
<entry>masklen('192.168.1.5/24')</entry>
15151516
</row>
15161517
<row>
15171518
<entry>masklen(inet)</entry>
1518-
<entry>int4</entry>
1519+
<entry>integer</entry>
15191520
<entry>calculate netmask length</entry>
15201521
<entry>masklen('192.168.1.5/24')</entry>
15211522
</row>
@@ -1525,9 +1526,21 @@ Not defined by this name. Implements the intersection operator '#'
15251526
<entry>construct netmask as text</entry>
15261527
<entry>netmask('192.168.1.5/24')</entry>
15271528
</row>
1529+
<row>
1530+
<entry>trunc(macaddr)</entry>
1531+
<entry>macaddr</entry>
1532+
<entry>set last 3 bytes to zero</entry>
1533+
<entry>trunc(macaddr '12:34:56:78:90:ab')</entry>
1534+
</row>
15281535
</tbody>
15291536
</tgroup>
15301537
</table>
1538+
1539+
The function <function>trunc</>(<type>macaddr</>) returns a MAC
1540+
address with the last 3 bytes set to 0. This can be used to
1541+
associate the remaining prefix with a manufacturer. The directory
1542+
<filename>contrib/mac</> in the source distribution contains some
1543+
utilities to create and maintain such an association table.
15311544
</para>
15321545

15331546
</sect1>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp