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>nets andhosts </entry>
1768- <entry>Valid IPV4 CIDR blocks </entry>
1765+ <entry>11 bytes </entry>
1766+ <entry>IP hosts andnetworks </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>