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".
Modulenetwork-bsd-2.8.1.0Haskell2010
Network.BSD
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:
Contents
Synopsis
- type HostName
- type HostAddress
- newtype Family
- pattern AF_UNSPEC
- pattern AF_UNIX
- pattern AF_INET
- pattern AF_INET6
- pattern AF_IMPLINK
- pattern AF_PUP
- pattern AF_CHAOS
- pattern AF_NS
- pattern AF_NBS
- pattern AF_ECMA
- pattern AF_DATAKIT
- pattern AF_CCITT
- pattern AF_SNA
- pattern AF_DECnet
- pattern AF_DLI
- pattern AF_LAT
- pattern AF_HYLINK
- pattern AF_APPLETALK
- pattern AF_ROUTE
- pattern AF_NETBIOS
- pattern AF_NIT
- pattern AF_802
- pattern AF_ISO
- pattern AF_OSI
- pattern AF_NETMAN
- pattern AF_X25
- pattern AF_AX25
- pattern AF_OSINET
- pattern AF_GOSSIP
- pattern AF_IPX
- pattern Pseudo_AF_XTP
- pattern AF_CTF
- pattern AF_WAN
- pattern AF_SDL
- pattern AF_NETWARE
- pattern AF_NDD
- pattern AF_INTF
- pattern AF_COIP
- pattern AF_CNT
- pattern Pseudo_AF_RTIP
- pattern Pseudo_AF_PIP
- pattern AF_SIP
- pattern AF_ISDN
- pattern Pseudo_AF_KEY
- pattern AF_NATM
- pattern AF_ARP
- pattern Pseudo_AF_HDRCMPLT
- pattern AF_ENCAP
- pattern AF_LINK
- pattern AF_RAW
- pattern AF_RIF
- pattern AF_NETROM
- pattern AF_BRIDGE
- pattern AF_ATMPVC
- pattern AF_ROSE
- pattern AF_NETBEUI
- pattern AF_SECURITY
- pattern AF_PACKET
- pattern AF_ASH
- pattern AF_ECONET
- pattern AF_ATMSVC
- pattern AF_IRDA
- pattern AF_PPPOX
- pattern AF_WANPIPE
- pattern AF_BLUETOOTH
- pattern AF_CAN
- value getHostName
- data HostEntry
- value getHostByName
- value getHostByAddr
- value hostAddress
- value getHostEntries
- value setHostEntry
- value getHostEntry
- value endHostEntry
- data ServiceEntry
- type ServiceName
- newtype PortNumber
- value getServiceByName
- value getServiceByPort
- value getServicePortNumber
- value getServiceEntries
- value getServiceEntry
- value setServiceEntry
- value endServiceEntry
- type ProtocolName
- type ProtocolNumber
- data ProtocolEntry
- value getProtocolByName
- value getProtocolByNumber
- value getProtocolNumber
- value defaultProtocol
- value getProtocolEntries
- value setProtocolEntry
- value getProtocolEntry
- value endProtocolEntry
- type NetworkName
- type NetworkAddr
- data NetworkEntry
- value getNetworkByName
- value getNetworkByAddr
- value getNetworkEntries
- value setNetworkEntry
- value getNetworkEntry
- value endNetworkEntry
- value ifNameToIndex
- Packagenetwork-bsd-2.8.1.0
- Exports109
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceBSD.hsc
Host names and network addresses
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.
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.
unspecified
UNIX-domain
Internet Protocol version 4
Internet Protocol version 6
Arpanet imp addresses
pup protocols: e.g. BSP
mit CHAOS protocols
XEROX NS protocols
nbs protocols
european computer manufacturers
datakit protocols
CCITT protocols, X.25 etc
IBM SNA
DECnet
Direct data link interface
LAT
NSC Hyperchannel
Apple Talk
Internal Routing Protocol (aka AF_NETLINK)
NetBios-style addresses
Network Interface Tap
IEEE 802.2, also ISO 8802
ISO protocols
umbrella of all families used by OSI
DNA Network Management
CCITT X.25
AX25
AFI
US Government OSI
Novell Internet Protocol
eXpress Transfer Protocol (no AF)
Common Trace Facility
Wide Area Network protocols
SGI Data Link for DLPI
Netware
NDD
Debugging use only
connection-oriented IP, aka ST II
Computer Network Technology
Help Identify RTIP packets
Help Identify PIP packets
Simple Internet Protocol
Integrated Services Digital Network
Internal key-management function
native ATM access
ARP (RFC 826)
Used by BPF to not rewrite hdrs in iface output
ENCAP
Link layer interface
Link layer interface
raw interface
Amateur radio NetROM
multiprotocol bridge
ATM PVCs
Amateur Radio X.25 PLP
Netbeui 802.2LLC
Security callback pseudo AF
Packet family
Ash
Acorn Econet
ATM SVCs
IRDA sockets
PPPoX sockets
Wanpipe API sockets
bluetooth sockets
Controller Area Network
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
HostEntryhostName :: HostNameOfficial name of the host
hostAliases :: [HostName]Alternative names of the host
hostFamily :: FamilyAddress type (currently
AF_INET)hostAddresses :: [HostAddress]Set of network addresses for the host
Resolve a HostName to IPv4 address.
Get a HostEntry corresponding to the given address and family. Note that only IPv4 is currently supported.
Retrieve list of all HostEntry via gethostent(3).
Low level functionality
sethostent(3).
gethostent(3).
endhostent(3).
Service names
Representation of the POSIX servent structure defined in netdb.h.
Constructors
ServiceEntryserviceName :: ServiceNameOfficial service name
serviceAliases :: [ServiceName]aliases
servicePort :: PortNumberPort Number
serviceProtocol :: ProtocolNameProtocol to use
Instances3Show, Storable, NFData
Show ServiceEntryDefined in network-bsd-2.8.1.0 · Network.BSDStorable ServiceEntryDefined in network-bsd-2.8.1.0 · Network.BSDNFData ServiceEntryDefined in network-bsd-2.8.1.0 · Network.BSD
Either a service name e.g., "http" or a numeric port number.
Port number.
Use the Num instance (i.e. use a literal) to create a
PortNumber value.
1 :: PortNumber1read "1" :: PortNumber1show (12345 :: PortNumber)"12345"50000 < (51000 :: PortNumber)True50000 < (52000 :: PortNumber)True50000 + (10000 :: PortNumber)60000
Instances10Bounded, Enum, Eq, Integral, Num, Ord, …
Bounded PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesEnum PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesEq PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesIntegral PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesNum PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesOrd PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesRead PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesReal PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesShow PortNumberDefined in network-3.2.9.0 · Network.Socket.TypesStorable PortNumberDefined in network-3.2.9.0 · Network.Socket.Types
Get service by name.
Get the service given a PortNumber and ProtocolName.
Get the PortNumber corresponding to the ServiceName.
Retrieve list of all ServiceEntry via getservent(3).
Low level functionality
getservent(3).
setservent(3).
endservent(3).
Protocol names
Protocol number.
Representation of the POSIX protoent structure defined in netdb.h.
Constructors
ProtocolEntryprotoName :: ProtocolNameOfficial name
protoAliases :: [ProtocolName]aliases
protoNumber :: ProtocolNumberProtocol number
Instances4Read, Show, Storable, NFData
Read ProtocolEntryDefined in network-bsd-2.8.1.0 · Network.BSDShow ProtocolEntryDefined in network-bsd-2.8.1.0 · Network.BSDStorable ProtocolEntryDefined in network-bsd-2.8.1.0 · Network.BSDNFData ProtocolEntryDefined in network-bsd-2.8.1.0 · Network.BSD
getprotobyname(3).
getprotobynumber(3).
getprotobyname(3).
This is the default protocol for a given service.
defaultProtocol0
Retrieve list of all ProtocolEntry via getprotoent(3).
Low level functionality
setprotoent(3).
getprotoent(3).
endprotoent(3).
Network names
Representation of the POSIX netent structure defined in netdb.h.
Constructors
NetworkEntrynetworkName :: NetworkNameOfficial network name
networkAliases :: [NetworkName]aliases
networkFamily :: FamilyNetwork address type
networkAddress :: NetworkAddrNetwork number
Instances4Read, Show, Storable, NFData
Read NetworkEntryDefined in network-bsd-2.8.1.0 · Network.BSDShow NetworkEntryDefined in network-bsd-2.8.1.0 · Network.BSDStorable NetworkEntryDefined in network-bsd-2.8.1.0 · Network.BSDNFData NetworkEntryDefined in network-bsd-2.8.1.0 · Network.BSD
getnetbyname(3).
getnetbyaddr(3).
Get the list of network entries via getnetent(3).
Low level functionality
Open the network name database. The parameter specifies whether a connection is maintained open between various networkEntry calls
setnetent(3).
getnetent(3).
Close the connection to the network name database.
endnetent(3).
Interface names
Returns the index corresponding to the interface name.
Since 2.7.0.0.