-- 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 (netdb.h) 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.2
--                    , 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. The <tt>AF_xxxxx</tt> constants are widely used as
--   synonyms for the corresponding <tt>PF_xxxxx</tt> protocol family
--   values, to which they are numerically equal in mainstream socket API
--   implementations.
--   
--   Strictly correct usage would be to pass the <tt>PF_xxxxx</tt>
--   constants as the first argument when creating a <a>Socket</a>, while
--   the <tt>AF_xxxxx</tt> constants should be used as <tt>addrFamily</tt>
--   values with <tt>getAddrInfo</tt>. For now only the <tt>AF_xxxxx</tt>
--   constants are provided.
--   
--   Some of the defined patterns may be unsupported on some systems: see
--   <a>isSupportedFamily</a>.
data Family

-- | unspecified
pattern AF_UNSPEC :: Family

-- | UNIX-domain
pattern AF_UNIX :: Family

-- | Internet Protocol version 4
pattern AF_INET :: Family

-- | Internet Protocol version 6
pattern AF_INET6 :: Family

-- | Arpanet imp addresses
pattern AF_IMPLINK :: Family

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

-- | mit CHAOS protocols
pattern AF_CHAOS :: Family

-- | XEROX NS protocols
pattern AF_NS :: Family

-- | nbs protocols
pattern AF_NBS :: Family

-- | european computer manufacturers
pattern AF_ECMA :: Family

-- | datakit protocols
pattern AF_DATAKIT :: Family

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

-- | IBM SNA
pattern AF_SNA :: Family

-- | DECnet
pattern AF_DECnet :: Family

-- | Direct data link interface
pattern AF_DLI :: Family

-- | LAT
pattern AF_LAT :: Family

-- | NSC Hyperchannel
pattern AF_HYLINK :: Family

-- | Apple Talk
pattern AF_APPLETALK :: Family

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

-- | NetBios-style addresses
pattern AF_NETBIOS :: Family

-- | Network Interface Tap
pattern AF_NIT :: Family

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

-- | ISO protocols
pattern AF_ISO :: Family

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

-- | DNA Network Management
pattern AF_NETMAN :: Family

-- | CCITT X.25
pattern AF_X25 :: Family

-- | AX25
pattern AF_AX25 :: Family

-- | AFI
pattern AF_OSINET :: Family

-- | US Government OSI
pattern AF_GOSSIP :: Family

-- | Novell Internet Protocol
pattern AF_IPX :: Family

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

-- | Common Trace Facility
pattern AF_CTF :: Family

-- | Wide Area Network protocols
pattern AF_WAN :: Family

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

-- | Netware
pattern AF_NETWARE :: Family

-- | NDD
pattern AF_NDD :: Family

-- | Debugging use only
pattern AF_INTF :: Family

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

-- | Computer Network Technology
pattern AF_CNT :: Family

-- | Help Identify RTIP packets
pattern Pseudo_AF_RTIP :: Family

-- | Help Identify PIP packets
pattern Pseudo_AF_PIP :: Family

-- | Simple Internet Protocol
pattern AF_SIP :: Family

-- | Integrated Services Digital Network
pattern AF_ISDN :: Family

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

-- | native ATM access
pattern AF_NATM :: Family

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

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

-- | ENCAP
pattern AF_ENCAP :: Family

-- | Link layer interface
pattern AF_LINK :: Family

-- | Link layer interface
pattern AF_RAW :: Family

-- | raw interface
pattern AF_RIF :: Family

-- | Amateur radio NetROM
pattern AF_NETROM :: Family

-- | multiprotocol bridge
pattern AF_BRIDGE :: Family

-- | ATM PVCs
pattern AF_ATMPVC :: Family

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

-- | Netbeui 802.2LLC
pattern AF_NETBEUI :: Family

-- | Security callback pseudo AF
pattern AF_SECURITY :: Family

-- | Packet family
pattern AF_PACKET :: Family

-- | Ash
pattern AF_ASH :: Family

-- | Acorn Econet
pattern AF_ECONET :: Family

-- | ATM SVCs
pattern AF_ATMSVC :: Family

-- | IRDA sockets
pattern AF_IRDA :: Family

-- | PPPoX sockets
pattern AF_PPPOX :: Family

-- | Wanpipe API sockets
pattern AF_WANPIPE :: Family

-- | bluetooth sockets
pattern AF_BLUETOOTH :: Family

-- | Controller Area Network
pattern 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 Control.DeepSeq.NFData Network.BSD.HostEntry
instance Control.DeepSeq.NFData Network.BSD.NetworkEntry
instance Control.DeepSeq.NFData Network.BSD.ProtocolEntry
instance Control.DeepSeq.NFData Network.BSD.ServiceEntry
instance GHC.Internal.Read.Read Network.BSD.HostEntry
instance GHC.Internal.Read.Read Network.BSD.NetworkEntry
instance GHC.Internal.Read.Read Network.BSD.ProtocolEntry
instance GHC.Internal.Show.Show Network.BSD.HostEntry
instance GHC.Internal.Show.Show Network.BSD.NetworkEntry
instance GHC.Internal.Show.Show Network.BSD.ProtocolEntry
instance GHC.Internal.Show.Show Network.BSD.ServiceEntry
instance GHC.Internal.Foreign.Storable.Storable Network.BSD.HostEntry
instance GHC.Internal.Foreign.Storable.Storable Network.BSD.NetworkEntry
instance GHC.Internal.Foreign.Storable.Storable Network.BSD.ProtocolEntry
instance GHC.Internal.Foreign.Storable.Storable Network.BSD.ServiceEntry
