Copyright | (c) The University of Glasgow 2001 |
---|---|
License | BSD-3-Clause |
Maintainer | libraries@haskell.org |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Network.BSD
Description
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
Synopsis
- type HostName = String
- type HostAddress = Word32
- data Family where
- pattern AF_UNSPEC :: Family
- pattern AF_UNIX :: Family
- pattern AF_INET :: Family
- pattern AF_INET6 :: Family
- pattern AF_IMPLINK :: Family
- pattern AF_PUP :: Family
- pattern AF_CHAOS :: Family
- pattern AF_NS :: Family
- pattern AF_NBS :: Family
- pattern AF_ECMA :: Family
- pattern AF_DATAKIT :: Family
- pattern AF_CCITT :: Family
- pattern AF_SNA :: Family
- pattern AF_DECnet :: Family
- pattern AF_DLI :: Family
- pattern AF_LAT :: Family
- pattern AF_HYLINK :: Family
- pattern AF_APPLETALK :: Family
- pattern AF_ROUTE :: Family
- pattern AF_NETBIOS :: Family
- pattern AF_NIT :: Family
- pattern AF_802 :: Family
- pattern AF_ISO :: Family
- pattern AF_OSI :: Family
- pattern AF_NETMAN :: Family
- pattern AF_X25 :: Family
- pattern AF_AX25 :: Family
- pattern AF_OSINET :: Family
- pattern AF_GOSSIP :: Family
- pattern AF_IPX :: Family
- pattern Pseudo_AF_XTP :: Family
- pattern AF_CTF :: Family
- pattern AF_WAN :: Family
- pattern AF_SDL :: Family
- pattern AF_NETWARE :: Family
- pattern AF_NDD :: Family
- pattern AF_INTF :: Family
- pattern AF_COIP :: Family
- pattern AF_CNT :: Family
- pattern Pseudo_AF_RTIP :: Family
- pattern Pseudo_AF_PIP :: Family
- pattern AF_SIP :: Family
- pattern AF_ISDN :: Family
- pattern Pseudo_AF_KEY :: Family
- pattern AF_NATM :: Family
- pattern AF_ARP :: Family
- pattern Pseudo_AF_HDRCMPLT :: Family
- pattern AF_ENCAP :: Family
- pattern AF_LINK :: Family
- pattern AF_RAW :: Family
- pattern AF_RIF :: Family
- pattern AF_NETROM :: Family
- pattern AF_BRIDGE :: Family
- pattern AF_ATMPVC :: Family
- pattern AF_ROSE :: Family
- pattern AF_NETBEUI :: Family
- pattern AF_SECURITY :: Family
- pattern AF_PACKET :: Family
- pattern AF_ASH :: Family
- pattern AF_ECONET :: Family
- pattern AF_ATMSVC :: Family
- pattern AF_IRDA :: Family
- pattern AF_PPPOX :: Family
- pattern AF_WANPIPE :: Family
- pattern AF_BLUETOOTH :: Family
- pattern AF_CAN :: Family
- getHostName :: IO HostName
- data HostEntry = HostEntry {
- hostName :: HostName
- hostAliases :: [HostName]
- hostFamily :: Family
- hostAddresses :: [HostAddress]
- getHostByName :: HostName -> IO HostEntry
- getHostByAddr :: Family -> HostAddress -> IO HostEntry
- hostAddress :: HostEntry -> HostAddress
- getHostEntries :: Bool -> IO [HostEntry]
- setHostEntry :: Bool -> IO ()
- getHostEntry :: IO HostEntry
- endHostEntry :: IO ()
- data ServiceEntry = ServiceEntry {}
- type ServiceName = String
- data PortNumber
- getServiceByName :: ServiceName -> ProtocolName -> IO ServiceEntry
- getServiceByPort :: PortNumber -> ProtocolName -> IO ServiceEntry
- getServicePortNumber :: ServiceName -> IO PortNumber
- getServiceEntries :: Bool -> IO [ServiceEntry]
- getServiceEntry :: IO ServiceEntry
- setServiceEntry :: Bool -> IO ()
- endServiceEntry :: IO ()
- type ProtocolName = String
- type ProtocolNumber = CInt
- data ProtocolEntry = ProtocolEntry {}
- getProtocolByName :: ProtocolName -> IO ProtocolEntry
- getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry
- getProtocolNumber :: ProtocolName -> IO ProtocolNumber
- defaultProtocol :: ProtocolNumber
- getProtocolEntries :: Bool -> IO [ProtocolEntry]
- setProtocolEntry :: Bool -> IO ()
- getProtocolEntry :: IO ProtocolEntry
- endProtocolEntry :: IO ()
- type NetworkName = String
- type NetworkAddr = CULong
- data NetworkEntry = NetworkEntry {}
- getNetworkByName :: NetworkName -> IO NetworkEntry
- getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry
- getNetworkEntries :: Bool -> IO [NetworkEntry]
- setNetworkEntry :: Bool -> IO ()
- getNetworkEntry :: IO NetworkEntry
- endNetworkEntry :: IO ()
- ifNameToIndex :: String -> IO (Maybe Int)
Host names and network addresses
type HostAddress = Word32 #
Bundled Patterns
Instances
Read Family | |
Defined in Network.Socket.Types | |
Show Family | |
Eq Family | |
Ord Family | |
getHostName :: IO HostName Source #
Calling getHostName
returns the standard host name for the current
processor, as set at boot time.
gethostname(2)
.
Representation of the POSIX hostent
structure defined in netdb.h.
Constructors
HostEntry | |
Fields
|
Instances
NFData HostEntry Source # | Since: 2.8.1.0 |
Defined in Network.BSD | |
Storable HostEntry Source # | |
Defined in Network.BSD Methods peekElemOff :: Ptr HostEntry -> Int -> IO HostEntry pokeElemOff :: Ptr HostEntry -> Int -> HostEntry -> IO () peekByteOff :: Ptr b -> Int -> IO HostEntry pokeByteOff :: Ptr b -> Int -> HostEntry -> IO () | |
Read HostEntry Source # | |
Defined in Network.BSD | |
Show HostEntry Source # | |
getHostByAddr :: Family -> HostAddress -> IO HostEntry Source #
Get a HostEntry
corresponding to the given address and family.
Note that only IPv4 is currently supported.
hostAddress :: HostEntry -> HostAddress Source #
getHostEntries :: Bool -> IO [HostEntry] Source #
Retrieve list of all HostEntry
via gethostent(3)
.
Low level functionality
setHostEntry :: Bool -> IO () Source #
sethostent(3)
.
getHostEntry :: IO HostEntry Source #
gethostent(3)
.
endHostEntry :: IO () Source #
endhostent(3)
.
Service names
data ServiceEntry Source #
Representation of the POSIX servent
structure defined in netdb.h.
Constructors
ServiceEntry | |
Fields
|
Instances
NFData ServiceEntry Source # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: ServiceEntry -> () | |
Storable ServiceEntry Source # | |
Defined in Network.BSD Methods sizeOf :: ServiceEntry -> Int alignment :: ServiceEntry -> Int peekElemOff :: Ptr ServiceEntry -> Int -> IO ServiceEntry pokeElemOff :: Ptr ServiceEntry -> Int -> ServiceEntry -> IO () peekByteOff :: Ptr b -> Int -> IO ServiceEntry pokeByteOff :: Ptr b -> Int -> ServiceEntry -> IO () peek :: Ptr ServiceEntry -> IO ServiceEntry poke :: Ptr ServiceEntry -> ServiceEntry -> IO () | |
Show ServiceEntry Source # | |
Defined in Network.BSD Methods showsPrec :: Int -> ServiceEntry -> ShowS show :: ServiceEntry -> String showList :: [ServiceEntry] -> ShowS |
type ServiceName = String #
data PortNumber #
Instances
getServiceByName :: ServiceName -> ProtocolName -> IO ServiceEntry Source #
Get service by name.
getServiceByPort :: PortNumber -> ProtocolName -> IO ServiceEntry Source #
Get the service given a PortNumber
and ProtocolName
.
getServicePortNumber :: ServiceName -> IO PortNumber Source #
Get the PortNumber
corresponding to the ServiceName
.
getServiceEntries :: Bool -> IO [ServiceEntry] Source #
Retrieve list of all ServiceEntry
via getservent(3)
.
Low level functionality
getServiceEntry :: IO ServiceEntry Source #
getservent(3)
.
setServiceEntry :: Bool -> IO () Source #
setservent(3)
.
endServiceEntry :: IO () Source #
endservent(3)
.
Protocol names
type ProtocolName = String Source #
type ProtocolNumber = CInt #
data ProtocolEntry Source #
Representation of the POSIX protoent
structure defined in netdb.h.
Constructors
ProtocolEntry | |
Fields
|
Instances
NFData ProtocolEntry Source # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: ProtocolEntry -> () | |
Storable ProtocolEntry Source # | |
Defined in Network.BSD Methods sizeOf :: ProtocolEntry -> Int alignment :: ProtocolEntry -> Int peekElemOff :: Ptr ProtocolEntry -> Int -> IO ProtocolEntry pokeElemOff :: Ptr ProtocolEntry -> Int -> ProtocolEntry -> IO () peekByteOff :: Ptr b -> Int -> IO ProtocolEntry pokeByteOff :: Ptr b -> Int -> ProtocolEntry -> IO () peek :: Ptr ProtocolEntry -> IO ProtocolEntry poke :: Ptr ProtocolEntry -> ProtocolEntry -> IO () | |
Read ProtocolEntry Source # | |
Defined in Network.BSD Methods readsPrec :: Int -> ReadS ProtocolEntry readList :: ReadS [ProtocolEntry] readPrec :: ReadPrec ProtocolEntry readListPrec :: ReadPrec [ProtocolEntry] | |
Show ProtocolEntry Source # | |
Defined in Network.BSD Methods showsPrec :: Int -> ProtocolEntry -> ShowS show :: ProtocolEntry -> String showList :: [ProtocolEntry] -> ShowS |
getProtocolByName :: ProtocolName -> IO ProtocolEntry Source #
getprotobyname(3)
.
getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry Source #
getprotobynumber(3)
.
getProtocolNumber :: ProtocolName -> IO ProtocolNumber Source #
getprotobyname(3)
.
getProtocolEntries :: Bool -> IO [ProtocolEntry] Source #
Retrieve list of all ProtocolEntry
via getprotoent(3)
.
Low level functionality
setProtocolEntry :: Bool -> IO () Source #
setprotoent(3)
.
getProtocolEntry :: IO ProtocolEntry Source #
getprotoent(3)
.
endProtocolEntry :: IO () Source #
endprotoent(3)
.
Network names
type NetworkName = String Source #
type NetworkAddr = CULong Source #
data NetworkEntry Source #
Representation of the POSIX netent
structure defined in netdb.h.
Constructors
NetworkEntry | |
Fields
|
Instances
NFData NetworkEntry Source # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: NetworkEntry -> () | |
Storable NetworkEntry Source # | |
Defined in Network.BSD Methods sizeOf :: NetworkEntry -> Int alignment :: NetworkEntry -> Int peekElemOff :: Ptr NetworkEntry -> Int -> IO NetworkEntry pokeElemOff :: Ptr NetworkEntry -> Int -> NetworkEntry -> IO () peekByteOff :: Ptr b -> Int -> IO NetworkEntry pokeByteOff :: Ptr b -> Int -> NetworkEntry -> IO () peek :: Ptr NetworkEntry -> IO NetworkEntry poke :: Ptr NetworkEntry -> NetworkEntry -> IO () | |
Read NetworkEntry Source # | |
Defined in Network.BSD Methods readsPrec :: Int -> ReadS NetworkEntry readList :: ReadS [NetworkEntry] readPrec :: ReadPrec NetworkEntry readListPrec :: ReadPrec [NetworkEntry] | |
Show NetworkEntry Source # | |
Defined in Network.BSD Methods showsPrec :: Int -> NetworkEntry -> ShowS show :: NetworkEntry -> String showList :: [NetworkEntry] -> ShowS |
getNetworkByName :: NetworkName -> IO NetworkEntry Source #
getnetbyname(3)
.
getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry Source #
getnetbyaddr(3)
.
getNetworkEntries :: Bool -> IO [NetworkEntry] Source #
Get the list of network entries via getnetent(3)
.
Low level functionality
setNetworkEntry :: Bool -> IO () Source #
Open the network name database. The parameter specifies whether a connection is maintained open between various networkEntry calls
setnetent(3)
.
getNetworkEntry :: IO NetworkEntry Source #
getnetent(3)
.
endNetworkEntry :: IO () Source #
Close the connection to the network name database.
endnetent(3)
.
Interface names
ifNameToIndex :: String -> IO (Maybe Int) #