-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | POSIX network database (<netdb.h>) API
--   
--   This package provides Haskell bindings to the the <a>POSIX network
--   database (<a>netdb.h</a>) API</a>.
--   
--   <h3>Relationship to the <tt>network</tt> package</h3>
--   
--   The <tt>network</tt> package version 2.* series provides
--   <a>Network.BSD</a> but it is removed starting with <tt>network</tt>
--   version 3.0.
--   
--   This package provides the <a>Network.BSD</a> module split off from the
--   <a>network package</a>.
--   
--   If in addition to the <tt>network</tt>'s modules also
--   <a>Network.BSD</a> is necessary, add <tt>network-bsd</tt> to your
--   dependencies like so:
--   
--   <pre>
--   library
--       build-depends: network     &gt;= 2.7 &amp;&amp; &lt; 3.1
--                    , network-bsd &gt;= 2.7 &amp;&amp; &lt; 2.9
--   </pre>
--   
--   I.e. you can control the version of the <tt>network</tt> package
--   independently.
--   
--   <b>NOTE</b>: Starting with <tt>network-bsd-2.8.1.0</tt> the APIs of
--   <tt>network</tt> and <tt>network-bsd</tt> evolve differently, and
--   consequently the versioning doesn't match up anymore! Moreover, also
--   starting with version <tt>network-bsd-2.8.1.0</tt> this package
--   requires <tt>network &gt;= 3</tt> in order to avoid module name
--   clashes with <tt>network &lt; 3</tt>'s <a>Network.BSD</a> module.
--   
--   However, <tt>network-bsd-2.7.0.0</tt> and <tt>network-bsd-2.8.0.0</tt>
--   passes thru the <a>Network.BSD</a> module from <tt>network-2.7.*</tt>
--   and <tt>network-2.8.*</tt> respectively in a non-clashing way via
--   Cabal's <a>reexported-modules</a> feature while ensuring a
--   well-defined <a>API versioning</a> of the observable API of
--   <tt>network-bsd</tt>. This is why the example above supporting a wide
--   range of <tt>network</tt> versions works by including version 2.7.0.0
--   in the required version range of <tt>network-bsd</tt>.
@package network-bsd
@version 2.8.1.0


-- | The <a>Network.BSD</a> module defines Haskell bindings to network
--   programming functionality (mostly <a>network database operations</a>)
--   provided by BSD Unix derivatives.
--   
--   <b>NOTE</b>: Some of the types are reexported from
--   <a>Network.Socket</a> in order to make the <tt>network-bsd</tt> API
--   self-contained.
--   
--   <h2>Windows compatibility</h2>
--   
--   The following functions are not exported by <a>Network.BSD</a> on the
--   Windows platform:
--   
--   <ul>
--   <li><a>getHostEntries</a>, <a>setHostEntry</a>, <a>getHostEntry</a>,
--   <a>endHostEntry</a></li>
--   <li><a>getServiceEntries</a>, <a>getServiceEntry</a>,
--   <a>setServiceEntry</a>, <a>endServiceEntry</a></li>
--   <li><a>getProtocolEntries</a>, <a>setProtocolEntry</a>,
--   <a>getProtocolEntry</a>, <a>endProtocolEntry</a></li>
--   <li><a>getNetworkByName</a>, <a>getNetworkByAddr</a>,
--   <a>getNetworkEntries</a>, <a>setNetworkEntry</a>,
--   <a>getNetworkEntry</a>, <a>endNetworkEntry</a></li>
--   </ul>
module Network.BSD

-- | Either a host name e.g., <tt>"haskell.org"</tt> or a numeric host
--   address string consisting of a dotted decimal IPv4 address or an IPv6
--   address e.g., <tt>"192.168.0.1"</tt>.
type HostName = String

-- | The raw network byte order number is read using host byte order.
--   Therefore on little-endian architectures the byte order is swapped.
--   For example <tt>127.0.0.1</tt> is represented as <tt>0x0100007f</tt>
--   on little-endian hosts and as <tt>0x7f000001</tt> on big-endian hosts.
--   
--   For direct manipulation prefer <a>hostAddressToTuple</a> and
--   <a>tupleToHostAddress</a>.
type HostAddress = Word32

-- | Address families.
--   
--   A constructor being present here does not mean it is supported by the
--   operating system: see <a>isSupportedFamily</a>.
data Family

-- | unspecified
AF_UNSPEC :: Family

-- | UNIX-domain
AF_UNIX :: Family

-- | Internet Protocol version 4
AF_INET :: Family

-- | Internet Protocol version 6
AF_INET6 :: Family

-- | Arpanet imp addresses
AF_IMPLINK :: Family

-- | pup protocols: e.g. BSP
AF_PUP :: Family

-- | mit CHAOS protocols
AF_CHAOS :: Family

-- | XEROX NS protocols
AF_NS :: Family

-- | nbs protocols
AF_NBS :: Family

-- | european computer manufacturers
AF_ECMA :: Family

-- | datakit protocols
AF_DATAKIT :: Family

-- | CCITT protocols, X.25 etc
AF_CCITT :: Family

-- | IBM SNA
AF_SNA :: Family

-- | DECnet
AF_DECnet :: Family

-- | Direct data link interface
AF_DLI :: Family

-- | LAT
AF_LAT :: Family

-- | NSC Hyperchannel
AF_HYLINK :: Family

-- | Apple Talk
AF_APPLETALK :: Family

-- | Internal Routing Protocol (aka AF_NETLINK)
AF_ROUTE :: Family

-- | NetBios-style addresses
AF_NETBIOS :: Family

-- | Network Interface Tap
AF_NIT :: Family

-- | IEEE 802.2, also ISO 8802
AF_802 :: Family

-- | ISO protocols
AF_ISO :: Family

-- | umbrella of all families used by OSI
AF_OSI :: Family

-- | DNA Network Management
AF_NETMAN :: Family

-- | CCITT X.25
AF_X25 :: Family

-- | AX25
AF_AX25 :: Family

-- | AFI
AF_OSINET :: Family

-- | US Government OSI
AF_GOSSIP :: Family

-- | Novell Internet Protocol
AF_IPX :: Family

-- | eXpress Transfer Protocol (no AF)
Pseudo_AF_XTP :: Family

-- | Common Trace Facility
AF_CTF :: Family

-- | Wide Area Network protocols
AF_WAN :: Family

-- | SGI Data Link for DLPI
AF_SDL :: Family

-- | Netware
AF_NETWARE :: Family

-- | NDD
AF_NDD :: Family

-- | Debugging use only
AF_INTF :: Family

-- | connection-oriented IP, aka ST II
AF_COIP :: Family

-- | Computer Network Technology
AF_CNT :: Family

-- | Help Identify RTIP packets
Pseudo_AF_RTIP :: Family

-- | Help Identify PIP packets
Pseudo_AF_PIP :: Family

-- | Simple Internet Protocol
AF_SIP :: Family

-- | Integrated Services Digital Network
AF_ISDN :: Family

-- | Internal key-management function
Pseudo_AF_KEY :: Family

-- | native ATM access
AF_NATM :: Family

-- | ARP (RFC 826)
AF_ARP :: Family

-- | Used by BPF to not rewrite hdrs in iface output
Pseudo_AF_HDRCMPLT :: Family

-- | ENCAP
AF_ENCAP :: Family

-- | Link layer interface
AF_LINK :: Family

-- | Link layer interface
AF_RAW :: Family

-- | raw interface
AF_RIF :: Family

-- | Amateur radio NetROM
AF_NETROM :: Family

-- | multiprotocol bridge
AF_BRIDGE :: Family

-- | ATM PVCs
AF_ATMPVC :: Family

-- | Amateur Radio X.25 PLP
AF_ROSE :: Family

-- | Netbeui 802.2LLC
AF_NETBEUI :: Family

-- | Security callback pseudo AF
AF_SECURITY :: Family

-- | Packet family
AF_PACKET :: Family

-- | Ash
AF_ASH :: Family

-- | Acorn Econet
AF_ECONET :: Family

-- | ATM SVCs
AF_ATMSVC :: Family

-- | IRDA sockets
AF_IRDA :: Family

-- | PPPoX sockets
AF_PPPOX :: Family

-- | Wanpipe API sockets
AF_WANPIPE :: Family

-- | bluetooth sockets
AF_BLUETOOTH :: Family

-- | Controller Area Network
AF_CAN :: Family

-- | Calling <a>getHostName</a> returns the standard host name for the
--   current processor, as set at boot time.
--   
--   <tt>gethostname(2)</tt>.
getHostName :: IO HostName

-- | Representation of the POSIX <tt>hostent</tt> structure defined in
--   <a><a>netdb.h</a></a>.
data HostEntry
HostEntry :: HostName -> [HostName] -> Family -> [HostAddress] -> HostEntry

-- | Official name of the host
[hostName] :: HostEntry -> HostName

-- | Alternative names of the host
[hostAliases] :: HostEntry -> [HostName]

-- | Address type (currently <tt>AF_INET</tt>)
[hostFamily] :: HostEntry -> Family

-- | Set of network addresses for the host
[hostAddresses] :: HostEntry -> [HostAddress]

-- | Resolve a <a>HostName</a> to IPv4 address.
getHostByName :: HostName -> IO HostEntry

-- | Get a <a>HostEntry</a> corresponding to the given address and family.
--   Note that only IPv4 is currently supported.
getHostByAddr :: Family -> HostAddress -> IO HostEntry

-- | Convenience function extracting one address in a <a>HostEntry</a>.
--   Returns <a>error</a> if <a>HostEntry</a> contains no addresses.
hostAddress :: HostEntry -> HostAddress

-- | Retrieve list of all <a>HostEntry</a> via <tt>gethostent(3)</tt>.
getHostEntries :: Bool -> IO [HostEntry]

-- | <tt>sethostent(3)</tt>.
setHostEntry :: Bool -> IO ()

-- | <tt>gethostent(3)</tt>.
getHostEntry :: IO HostEntry

-- | <tt>endhostent(3)</tt>.
endHostEntry :: IO ()

-- | Representation of the POSIX <tt>servent</tt> structure defined in
--   <a><a>netdb.h</a></a>.
data ServiceEntry
ServiceEntry :: ServiceName -> [ServiceName] -> PortNumber -> ProtocolName -> ServiceEntry

-- | Official service name
[serviceName] :: ServiceEntry -> ServiceName

-- | aliases
[serviceAliases] :: ServiceEntry -> [ServiceName]

-- | Port Number
[servicePort] :: ServiceEntry -> PortNumber

-- | Protocol to use
[serviceProtocol] :: ServiceEntry -> ProtocolName

-- | Either a service name e.g., <tt>"http"</tt> or a numeric port number.
type ServiceName = String

-- | Port number. Use the <tt>Num</tt> instance (i.e. use a literal) to
--   create a <tt>PortNumber</tt> value.
--   
--   <pre>
--   &gt;&gt;&gt; 1 :: PortNumber
--   1
--   
--   &gt;&gt;&gt; read "1" :: PortNumber
--   1
--   
--   &gt;&gt;&gt; show (12345 :: PortNumber)
--   "12345"
--   
--   &gt;&gt;&gt; 50000 &lt; (51000 :: PortNumber)
--   True
--   
--   &gt;&gt;&gt; 50000 &lt; (52000 :: PortNumber)
--   True
--   
--   &gt;&gt;&gt; 50000 + (10000 :: PortNumber)
--   60000
--   </pre>
data PortNumber

-- | Get service by name.
getServiceByName :: ServiceName -> ProtocolName -> IO ServiceEntry

-- | Get the service given a <a>PortNumber</a> and <a>ProtocolName</a>.
getServiceByPort :: PortNumber -> ProtocolName -> IO ServiceEntry

-- | Get the <a>PortNumber</a> corresponding to the <a>ServiceName</a>.
getServicePortNumber :: ServiceName -> IO PortNumber

-- | Retrieve list of all <a>ServiceEntry</a> via <tt>getservent(3)</tt>.
getServiceEntries :: Bool -> IO [ServiceEntry]

-- | <tt>getservent(3)</tt>.
getServiceEntry :: IO ServiceEntry

-- | <tt>setservent(3)</tt>.
setServiceEntry :: Bool -> IO ()

-- | <tt>endservent(3)</tt>.
endServiceEntry :: IO ()
type ProtocolName = String

-- | Protocol number.
type ProtocolNumber = CInt

-- | Representation of the POSIX <tt>protoent</tt> structure defined in
--   <a><a>netdb.h</a></a>.
data ProtocolEntry
ProtocolEntry :: ProtocolName -> [ProtocolName] -> ProtocolNumber -> ProtocolEntry

-- | Official name
[protoName] :: ProtocolEntry -> ProtocolName

-- | aliases
[protoAliases] :: ProtocolEntry -> [ProtocolName]

-- | Protocol number
[protoNumber] :: ProtocolEntry -> ProtocolNumber

-- | <tt>getprotobyname(3)</tt>.
getProtocolByName :: ProtocolName -> IO ProtocolEntry

-- | <tt>getprotobynumber(3)</tt>.
getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry

-- | <tt>getprotobyname(3)</tt>.
getProtocolNumber :: ProtocolName -> IO ProtocolNumber

-- | This is the default protocol for a given service.
--   
--   <pre>
--   &gt;&gt;&gt; defaultProtocol
--   0
--   </pre>
defaultProtocol :: ProtocolNumber

-- | Retrieve list of all <a>ProtocolEntry</a> via <tt>getprotoent(3)</tt>.
getProtocolEntries :: Bool -> IO [ProtocolEntry]

-- | <tt>setprotoent(3)</tt>.
setProtocolEntry :: Bool -> IO ()

-- | <tt>getprotoent(3)</tt>.
getProtocolEntry :: IO ProtocolEntry

-- | <tt>endprotoent(3)</tt>.
endProtocolEntry :: IO ()
type NetworkName = String
type NetworkAddr = CULong

-- | Representation of the POSIX <tt>netent</tt> structure defined in
--   <a><a>netdb.h</a></a>.
data NetworkEntry
NetworkEntry :: NetworkName -> [NetworkName] -> Family -> NetworkAddr -> NetworkEntry

-- | Official network name
[networkName] :: NetworkEntry -> NetworkName

-- | aliases
[networkAliases] :: NetworkEntry -> [NetworkName]

-- | Network address type
[networkFamily] :: NetworkEntry -> Family

-- | Network number
[networkAddress] :: NetworkEntry -> NetworkAddr

-- | <tt>getnetbyname(3)</tt>.
getNetworkByName :: NetworkName -> IO NetworkEntry

-- | <tt>getnetbyaddr(3)</tt>.
getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry

-- | Get the list of network entries via <tt>getnetent(3)</tt>.
getNetworkEntries :: Bool -> IO [NetworkEntry]

-- | Open the network name database. The parameter specifies whether a
--   connection is maintained open between various networkEntry calls
--   
--   <tt>setnetent(3)</tt>.
setNetworkEntry :: Bool -> IO ()

-- | <tt>getnetent(3)</tt>.
getNetworkEntry :: IO NetworkEntry

-- | Close the connection to the network name database.
--   
--   <tt>endnetent(3)</tt>.
endNetworkEntry :: IO ()

-- | Returns the index corresponding to the interface name.
--   
--   Since 2.7.0.0.
ifNameToIndex :: String -> IO (Maybe Int)
instance GHC.Show.Show Network.BSD.NetworkEntry
instance GHC.Read.Read Network.BSD.NetworkEntry
instance GHC.Show.Show Network.BSD.HostEntry
instance GHC.Read.Read Network.BSD.HostEntry
instance GHC.Show.Show Network.BSD.ProtocolEntry
instance GHC.Read.Read Network.BSD.ProtocolEntry
instance GHC.Show.Show Network.BSD.ServiceEntry
instance Control.DeepSeq.NFData Network.BSD.NetworkEntry
instance Foreign.Storable.Storable Network.BSD.NetworkEntry
instance Control.DeepSeq.NFData Network.BSD.HostEntry
instance Foreign.Storable.Storable Network.BSD.HostEntry
instance Control.DeepSeq.NFData Network.BSD.ProtocolEntry
instance Foreign.Storable.Storable Network.BSD.ProtocolEntry
instance Control.DeepSeq.NFData Network.BSD.ServiceEntry
instance Foreign.Storable.Storable Network.BSD.ServiceEntry
