network-bsd-2.8.1.0: POSIX network database (<netdb.h>) API
Copyright(c) The University of Glasgow 2001
LicenseBSD-3-Clause
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

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:

Synopsis

Host names and network addresses

type HostName = String #

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 HostAddress = Word32 #

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.

data Family where #

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.

Bundled Patterns

pattern AF_UNSPEC :: Family

unspecified

pattern AF_UNIX :: Family

UNIX-domain

pattern AF_INET :: Family

Internet Protocol version 4

pattern AF_INET6 :: Family

Internet Protocol version 6

pattern AF_IMPLINK :: Family

Arpanet imp addresses

pattern AF_PUP :: Family

pup protocols: e.g. BSP

pattern AF_CHAOS :: Family

mit CHAOS protocols

pattern AF_NS :: Family

XEROX NS protocols

pattern AF_NBS :: Family

nbs protocols

pattern AF_ECMA :: Family

european computer manufacturers

pattern AF_DATAKIT :: Family

datakit protocols

pattern AF_CCITT :: Family

CCITT protocols, X.25 etc

pattern AF_SNA :: Family

IBM SNA

pattern AF_DECnet :: Family

DECnet

pattern AF_DLI :: Family

Direct data link interface

pattern AF_LAT :: Family

LAT

pattern AF_HYLINK :: Family

NSC Hyperchannel

pattern AF_APPLETALK :: Family

Apple Talk

pattern AF_ROUTE :: Family

Internal Routing Protocol (aka AF_NETLINK)

pattern AF_NETBIOS :: Family

NetBios-style addresses

pattern AF_NIT :: Family

Network Interface Tap

pattern AF_802 :: Family

IEEE 802.2, also ISO 8802

pattern AF_ISO :: Family

ISO protocols

pattern AF_OSI :: Family

umbrella of all families used by OSI

pattern AF_NETMAN :: Family

DNA Network Management

pattern AF_X25 :: Family

CCITT X.25

pattern AF_AX25 :: Family

AX25

pattern AF_OSINET :: Family

AFI

pattern AF_GOSSIP :: Family

US Government OSI

pattern AF_IPX :: Family

Novell Internet Protocol

pattern Pseudo_AF_XTP :: Family

eXpress Transfer Protocol (no AF)

pattern AF_CTF :: Family

Common Trace Facility

pattern AF_WAN :: Family

Wide Area Network protocols

pattern AF_SDL :: Family

SGI Data Link for DLPI

pattern AF_NETWARE :: Family

Netware

pattern AF_NDD :: Family

NDD

pattern AF_INTF :: Family

Debugging use only

pattern AF_COIP :: Family

connection-oriented IP, aka ST II

pattern AF_CNT :: Family

Computer Network Technology

pattern Pseudo_AF_RTIP :: Family

Help Identify RTIP packets

pattern Pseudo_AF_PIP :: Family

Help Identify PIP packets

pattern AF_SIP :: Family

Simple Internet Protocol

pattern AF_ISDN :: Family

Integrated Services Digital Network

pattern Pseudo_AF_KEY :: Family

Internal key-management function

pattern AF_NATM :: Family

native ATM access

pattern AF_ARP :: Family

ARP (RFC 826)

pattern Pseudo_AF_HDRCMPLT :: Family

Used by BPF to not rewrite hdrs in iface output

pattern AF_ENCAP :: Family

ENCAP

pattern AF_LINK :: Family

Link layer interface

pattern AF_RAW :: Family

Link layer interface

pattern AF_RIF :: Family

raw interface

pattern AF_NETROM :: Family

Amateur radio NetROM

pattern AF_BRIDGE :: Family

multiprotocol bridge

pattern AF_ATMPVC :: Family

ATM PVCs

pattern AF_ROSE :: Family

Amateur Radio X.25 PLP

pattern AF_NETBEUI :: Family

Netbeui 802.2LLC

pattern AF_SECURITY :: Family

Security callback pseudo AF

pattern AF_PACKET :: Family

Packet family

pattern AF_ASH :: Family

Ash

pattern AF_ECONET :: Family

Acorn Econet

pattern AF_ATMSVC :: Family

ATM SVCs

pattern AF_IRDA :: Family

IRDA sockets

pattern AF_PPPOX :: Family

PPPoX sockets

pattern AF_WANPIPE :: Family

Wanpipe API sockets

pattern AF_BLUETOOTH :: Family

bluetooth sockets

pattern AF_CAN :: Family

Controller Area Network

Instances

Instances details
Read Family 
Instance details

Defined in Network.Socket.Types

Show Family 
Instance details

Defined in Network.Socket.Types

Eq Family 
Instance details

Defined in Network.Socket.Types

Methods

(==) :: Family -> Family -> Bool #

(/=) :: Family -> Family -> Bool #

Ord Family 
Instance details

Defined in Network.Socket.Types

getHostName :: IO HostName #

Calling getHostName returns the standard host name for the current processor, as set at boot time.

gethostname(2).

data HostEntry #

Representation of the POSIX hostent structure defined in netdb.h.

Constructors

HostEntry 

Fields

Instances

Instances details
NFData HostEntry #

Since: 2.8.1.0

Instance details

Defined in Network.BSD

Methods

rnf :: HostEntry -> () #

Storable HostEntry # 
Instance details

Defined in Network.BSD

Read HostEntry # 
Instance details

Defined in Network.BSD

Show HostEntry # 
Instance details

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 #

Convenience function extracting one address in a HostEntry. Returns error if HostEntry contains no addresses.

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

Instances details
NFData ServiceEntry #

Since: 2.8.1.0

Instance details

Defined in Network.BSD

Methods

rnf :: ServiceEntry -> () #

Storable ServiceEntry # 
Instance details

Defined in Network.BSD

Show ServiceEntry # 
Instance details

Defined in Network.BSD

type ServiceName = String #

Either a service name e.g., "http" or a numeric port number.

data PortNumber #

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

Instances

Instances details
Bounded PortNumber 
Instance details

Defined in Network.Socket.Types

Enum PortNumber 
Instance details

Defined in Network.Socket.Types

Storable PortNumber 
Instance details

Defined in Network.Socket.Types

Num PortNumber 
Instance details

Defined in Network.Socket.Types

Read PortNumber 
Instance details

Defined in Network.Socket.Types

Integral PortNumber 
Instance details

Defined in Network.Socket.Types

Real PortNumber 
Instance details

Defined in Network.Socket.Types

Show PortNumber 
Instance details

Defined in Network.Socket.Types

Eq PortNumber 
Instance details

Defined in Network.Socket.Types

Ord PortNumber 
Instance details

Defined in Network.Socket.Types

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 ProtocolNumber = CInt #

Protocol number.

data ProtocolEntry #

Representation of the POSIX protoent structure defined in netdb.h.

Constructors

ProtocolEntry 

Fields

defaultProtocol :: ProtocolNumber #

This is the default protocol for a given service.

>>> defaultProtocol
0

getProtocolEntries :: Bool -> IO [ProtocolEntry] #

Retrieve list of all ProtocolEntry via getprotoent(3).

Low level functionality

setProtocolEntry :: Bool -> IO () #

setprotoent(3).

endProtocolEntry :: IO () #

endprotoent(3).

Network names

data NetworkEntry #

Representation of the POSIX netent structure defined in netdb.h.

Constructors

NetworkEntry 

Fields

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).

endNetworkEntry :: IO () #

Close the connection to the network name database.

endnetent(3).

Interface names

ifNameToIndex :: String -> IO (Maybe Int) #

Returns the index corresponding to the interface name.

Since 2.7.0.0.