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

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

-- | Either a host name e.g., "haskell.org" or a numeric host
--   address string consisting of a dotted decimal IPv4 address or an IPv6
--   address e.g., "192.168.0.1".
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 127.0.0.1 is represented as 0x0100007f
--   on little-endian hosts and as 0x7f000001 on big-endian hosts.
--   
--   For direct manipulation prefer hostAddressToTuple and
--   tupleToHostAddress.
type HostAddress = Word32

-- | Address families. The AF_xxxxx constants are widely used as
--   synonyms for the corresponding PF_xxxxx protocol family
--   values, to which they are numerically equal in mainstream socket API
--   implementations.
--   
--   Strictly correct usage would be to pass the PF_xxxxx
--   constants as the first argument when creating a Socket, while
--   the AF_xxxxx constants should be used as addrFamily
--   values with getAddrInfo. For now only the AF_xxxxx
--   constants are provided.
--   
--   Some of the defined patterns may be unsupported on some systems: see
--   isSupportedFamily.
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 getHostName returns the standard host name for the
--   current processor, as set at boot time.
--   
--   gethostname(2).
getHostName :: IO HostName

-- | Representation of the POSIX hostent structure defined in
--   netdb.h.
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 AF_INET)
[hostFamily] :: HostEntry -> Family

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

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

-- | Get a HostEntry 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 HostEntry.
--   Returns error if HostEntry contains no addresses.
hostAddress :: HostEntry -> HostAddress

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

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

-- | gethostent(3).
getHostEntry :: IO HostEntry

-- | endhostent(3).
endHostEntry :: IO ()

-- | Representation of the POSIX servent structure defined in
--   netdb.h.
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., "http" or a numeric port number.
type ServiceName = String

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

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

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

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

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

-- | getservent(3).
getServiceEntry :: IO ServiceEntry

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

-- | endservent(3).
endServiceEntry :: IO ()
type ProtocolName = String

-- | Protocol number.
type ProtocolNumber = CInt

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

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

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

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

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

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

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

-- | This is the default protocol for a given service.
--   
--   
--   >>> defaultProtocol
--   0
--   
defaultProtocol :: ProtocolNumber

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

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

-- | getprotoent(3).
getProtocolEntry :: IO ProtocolEntry

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

-- | Representation of the POSIX netent structure defined in
--   netdb.h.
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

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

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

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

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

-- | getnetent(3).
getNetworkEntry :: IO NetworkEntry

-- | Close the connection to the network name database.
--   
--   endnetent(3).
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
