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
- = AF_UNSPEC
- | AF_UNIX
- | AF_INET
- | AF_INET6
- | AF_IMPLINK
- | AF_PUP
- | AF_CHAOS
- | AF_NS
- | AF_NBS
- | AF_ECMA
- | AF_DATAKIT
- | AF_CCITT
- | AF_SNA
- | AF_DECnet
- | AF_DLI
- | AF_LAT
- | AF_HYLINK
- | AF_APPLETALK
- | AF_ROUTE
- | AF_NETBIOS
- | AF_NIT
- | AF_802
- | AF_ISO
- | AF_OSI
- | AF_NETMAN
- | AF_X25
- | AF_AX25
- | AF_OSINET
- | AF_GOSSIP
- | AF_IPX
- | Pseudo_AF_XTP
- | AF_CTF
- | AF_WAN
- | AF_SDL
- | AF_NETWARE
- | AF_NDD
- | AF_INTF
- | AF_COIP
- | AF_CNT
- | Pseudo_AF_RTIP
- | Pseudo_AF_PIP
- | AF_SIP
- | AF_ISDN
- | Pseudo_AF_KEY
- | AF_NATM
- | AF_ARP
- | Pseudo_AF_HDRCMPLT
- | AF_ENCAP
- | AF_LINK
- | AF_RAW
- | AF_RIF
- | AF_NETROM
- | AF_BRIDGE
- | AF_ATMPVC
- | AF_ROSE
- | AF_NETBEUI
- | AF_SECURITY
- | AF_PACKET
- | AF_ASH
- | AF_ECONET
- | AF_ATMSVC
- | AF_IRDA
- | AF_PPPOX
- | AF_WANPIPE
- | AF_BLUETOOTH
- | AF_CAN
- 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 #
Constructors
Instances
Eq Family | |
Ord Family | |
Read Family | |
Defined in Network.Socket.Types | |
Show Family | |
getHostName :: IO HostName #
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
Read HostEntry # | |
Defined in Network.BSD | |
Show HostEntry # | |
Storable HostEntry # | |
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 () | |
NFData HostEntry # | Since: 2.8.1.0 |
Defined in Network.BSD |
getHostByName :: HostName -> IO HostEntry #
Resolve a HostName
to IPv4 address.
getHostByAddr :: Family -> HostAddress -> IO HostEntry #
Get a HostEntry
corresponding to the given address and family.
Note that only IPv4 is currently supported.
hostAddress :: HostEntry -> HostAddress #
getHostEntries :: Bool -> IO [HostEntry] #
Retrieve list of all HostEntry
via gethostent(3)
.
Low level functionality
setHostEntry :: Bool -> IO () #
sethostent(3)
.
getHostEntry :: IO HostEntry #
gethostent(3)
.
endHostEntry :: IO () #
endhostent(3)
.
Service names
data ServiceEntry #
Representation of the POSIX servent
structure defined in netdb.h.
Constructors
ServiceEntry | |
Fields
|
Instances
Show ServiceEntry # | |
Defined in Network.BSD Methods showsPrec :: Int -> ServiceEntry -> ShowS show :: ServiceEntry -> String showList :: [ServiceEntry] -> ShowS | |
Storable ServiceEntry # | |
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 () | |
NFData ServiceEntry # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: ServiceEntry -> () |
type ServiceName = String #
data PortNumber #
Instances
getServiceByName :: ServiceName -> ProtocolName -> IO ServiceEntry #
Get service by name.
getServiceByPort :: PortNumber -> ProtocolName -> IO ServiceEntry #
Get the service given a PortNumber
and ProtocolName
.
getServicePortNumber :: ServiceName -> IO PortNumber #
Get the PortNumber
corresponding to the ServiceName
.
getServiceEntries :: Bool -> IO [ServiceEntry] #
Retrieve list of all ServiceEntry
via getservent(3)
.
Low level functionality
getServiceEntry :: IO ServiceEntry #
getservent(3)
.
setServiceEntry :: Bool -> IO () #
setservent(3)
.
endServiceEntry :: IO () #
endservent(3)
.
Protocol names
type ProtocolName = String #
type ProtocolNumber = CInt #
data ProtocolEntry #
Representation of the POSIX protoent
structure defined in netdb.h.
Constructors
ProtocolEntry | |
Fields
|
Instances
Read ProtocolEntry # | |
Defined in Network.BSD Methods readsPrec :: Int -> ReadS ProtocolEntry readList :: ReadS [ProtocolEntry] readPrec :: ReadPrec ProtocolEntry readListPrec :: ReadPrec [ProtocolEntry] | |
Show ProtocolEntry # | |
Defined in Network.BSD Methods showsPrec :: Int -> ProtocolEntry -> ShowS show :: ProtocolEntry -> String showList :: [ProtocolEntry] -> ShowS | |
Storable ProtocolEntry # | |
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 () | |
NFData ProtocolEntry # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: ProtocolEntry -> () |
getProtocolByName :: ProtocolName -> IO ProtocolEntry #
getprotobyname(3)
.
getProtocolByNumber :: ProtocolNumber -> IO ProtocolEntry #
getprotobynumber(3)
.
getProtocolNumber :: ProtocolName -> IO ProtocolNumber #
getprotobyname(3)
.
getProtocolEntries :: Bool -> IO [ProtocolEntry] #
Retrieve list of all ProtocolEntry
via getprotoent(3)
.
Low level functionality
setProtocolEntry :: Bool -> IO () #
setprotoent(3)
.
getProtocolEntry :: IO ProtocolEntry #
getprotoent(3)
.
endProtocolEntry :: IO () #
endprotoent(3)
.
Network names
type NetworkName = String #
type NetworkAddr = CULong #
data NetworkEntry #
Representation of the POSIX netent
structure defined in netdb.h.
Constructors
NetworkEntry | |
Fields
|
Instances
Read NetworkEntry # | |
Defined in Network.BSD Methods readsPrec :: Int -> ReadS NetworkEntry readList :: ReadS [NetworkEntry] readPrec :: ReadPrec NetworkEntry readListPrec :: ReadPrec [NetworkEntry] | |
Show NetworkEntry # | |
Defined in Network.BSD Methods showsPrec :: Int -> NetworkEntry -> ShowS show :: NetworkEntry -> String showList :: [NetworkEntry] -> ShowS | |
Storable NetworkEntry # | |
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 () | |
NFData NetworkEntry # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: NetworkEntry -> () |
getNetworkByName :: NetworkName -> IO NetworkEntry #
getnetbyname(3)
.
getNetworkByAddr :: NetworkAddr -> Family -> IO NetworkEntry #
getnetbyaddr(3)
.
getNetworkEntries :: Bool -> IO [NetworkEntry] #
Get the list of network entries via getnetent(3)
.
Low level functionality
setNetworkEntry :: Bool -> IO () #
Open the network name database. The parameter specifies whether a connection is maintained open between various networkEntry calls
setnetent(3)
.
getNetworkEntry :: IO NetworkEntry #
getnetent(3)
.
endNetworkEntry :: IO () #
Close the connection to the network name database.
endnetent(3)
.
Interface names
ifNameToIndex :: String -> IO (Maybe Int) #