| 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,endHostEntrygetServiceEntries,getServiceEntry,setServiceEntry,endServiceEntrygetProtocolEntries,setProtocolEntry,getProtocolEntry,endProtocolEntrygetNetworkByName,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 | |
| Show 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
| Read HostEntry Source # | |
| Show HostEntry Source # | |
| Storable HostEntry Source # | |
Defined in Network.BSD Methods sizeOf :: HostEntry -> Int Source # alignment :: HostEntry -> Int Source # peekElemOff :: Ptr HostEntry -> Int -> IO HostEntry Source # pokeElemOff :: Ptr HostEntry -> Int -> HostEntry -> IO () Source # peekByteOff :: Ptr b -> Int -> IO HostEntry Source # pokeByteOff :: Ptr b -> Int -> HostEntry -> IO () Source # | |
| NFData HostEntry Source # | Since: 2.8.1.0 |
Defined in Network.BSD | |
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 #
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
| Show ServiceEntry Source # | |
Defined in Network.BSD | |
| Storable ServiceEntry Source # | |
Defined in Network.BSD Methods sizeOf :: ServiceEntry -> Int Source # alignment :: ServiceEntry -> Int Source # peekElemOff :: Ptr ServiceEntry -> Int -> IO ServiceEntry Source # pokeElemOff :: Ptr ServiceEntry -> Int -> ServiceEntry -> IO () Source # peekByteOff :: Ptr b -> Int -> IO ServiceEntry Source # pokeByteOff :: Ptr b -> Int -> ServiceEntry -> IO () Source # peek :: Ptr ServiceEntry -> IO ServiceEntry Source # poke :: Ptr ServiceEntry -> ServiceEntry -> IO () Source # | |
| NFData ServiceEntry Source # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: ServiceEntry -> () Source # | |
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
| Read ProtocolEntry Source # | |
Defined in Network.BSD | |
| Show ProtocolEntry Source # | |
Defined in Network.BSD | |
| Storable ProtocolEntry Source # | |
Defined in Network.BSD Methods sizeOf :: ProtocolEntry -> Int Source # alignment :: ProtocolEntry -> Int Source # peekElemOff :: Ptr ProtocolEntry -> Int -> IO ProtocolEntry Source # pokeElemOff :: Ptr ProtocolEntry -> Int -> ProtocolEntry -> IO () Source # peekByteOff :: Ptr b -> Int -> IO ProtocolEntry Source # pokeByteOff :: Ptr b -> Int -> ProtocolEntry -> IO () Source # peek :: Ptr ProtocolEntry -> IO ProtocolEntry Source # poke :: Ptr ProtocolEntry -> ProtocolEntry -> IO () Source # | |
| NFData ProtocolEntry Source # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: ProtocolEntry -> () Source # | |
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
| Read NetworkEntry Source # | |
Defined in Network.BSD | |
| Show NetworkEntry Source # | |
Defined in Network.BSD | |
| Storable NetworkEntry Source # | |
Defined in Network.BSD Methods sizeOf :: NetworkEntry -> Int Source # alignment :: NetworkEntry -> Int Source # peekElemOff :: Ptr NetworkEntry -> Int -> IO NetworkEntry Source # pokeElemOff :: Ptr NetworkEntry -> Int -> NetworkEntry -> IO () Source # peekByteOff :: Ptr b -> Int -> IO NetworkEntry Source # pokeByteOff :: Ptr b -> Int -> NetworkEntry -> IO () Source # peek :: Ptr NetworkEntry -> IO NetworkEntry Source # poke :: Ptr NetworkEntry -> NetworkEntry -> IO () Source # | |
| NFData NetworkEntry Source # | Since: 2.8.1.0 |
Defined in Network.BSD Methods rnf :: NetworkEntry -> () Source # | |
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).