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

Contents

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 #

Address families.

A constructor being present here does not mean it is supported by the operating system: see isSupportedFamily.

Constructors

AF_UNSPEC

unspecified

AF_UNIX

UNIX-domain

AF_INET

Internet Protocol version 4

AF_INET6

Internet Protocol version 6

AF_IMPLINK

Arpanet imp addresses

AF_PUP

pup protocols: e.g. BSP

AF_CHAOS

mit CHAOS protocols

AF_NS

XEROX NS protocols

AF_NBS

nbs protocols

AF_ECMA

european computer manufacturers

AF_DATAKIT

datakit protocols

AF_CCITT

CCITT protocols, X.25 etc

AF_SNA

IBM SNA

AF_DECnet

DECnet

AF_DLI

Direct data link interface

AF_LAT

LAT

AF_HYLINK

NSC Hyperchannel

AF_APPLETALK

Apple Talk

AF_ROUTE

Internal Routing Protocol (aka AF_NETLINK)

AF_NETBIOS

NetBios-style addresses

AF_NIT

Network Interface Tap

AF_802

IEEE 802.2, also ISO 8802

AF_ISO

ISO protocols

AF_OSI

umbrella of all families used by OSI

AF_NETMAN

DNA Network Management

AF_X25

CCITT X.25

AF_AX25

AX25

AF_OSINET

AFI

AF_GOSSIP

US Government OSI

AF_IPX

Novell Internet Protocol

Pseudo_AF_XTP

eXpress Transfer Protocol (no AF)

AF_CTF

Common Trace Facility

AF_WAN

Wide Area Network protocols

AF_SDL

SGI Data Link for DLPI

AF_NETWARE

Netware

AF_NDD

NDD

AF_INTF

Debugging use only

AF_COIP

connection-oriented IP, aka ST II

AF_CNT

Computer Network Technology

Pseudo_AF_RTIP

Help Identify RTIP packets

Pseudo_AF_PIP

Help Identify PIP packets

AF_SIP

Simple Internet Protocol

AF_ISDN

Integrated Services Digital Network

Pseudo_AF_KEY

Internal key-management function

AF_NATM

native ATM access

AF_ARP

ARP (RFC 826)

Pseudo_AF_HDRCMPLT

Used by BPF to not rewrite hdrs in iface output

AF_ENCAP

ENCAP

AF_LINK

Link layer interface

AF_RAW

Link layer interface

AF_RIF

raw interface

AF_NETROM

Amateur radio NetROM

AF_BRIDGE

multiprotocol bridge

AF_ATMPVC

ATM PVCs

AF_ROSE

Amateur Radio X.25 PLP

AF_NETBEUI

Netbeui 802.2LLC

AF_SECURITY

Security callback pseudo AF

AF_PACKET

Packet family

AF_ASH

Ash

AF_ECONET

Acorn Econet

AF_ATMSVC

ATM SVCs

AF_IRDA

IRDA sockets

AF_PPPOX

PPPoX sockets

AF_WANPIPE

Wanpipe API sockets

AF_BLUETOOTH

bluetooth sockets

AF_CAN

Controller Area Network

Instances
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

Read Family 
Instance details

Defined in Network.Socket.Types

Show Family 
Instance details

Defined in Network.Socket.Types

getHostName :: IO HostName Source #

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

gethostname(2).

data HostEntry Source #

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

Constructors

HostEntry 

Fields

Instances
Read HostEntry Source # 
Instance details

Defined in Network.BSD

Show HostEntry Source # 
Instance details

Defined in Network.BSD

Storable HostEntry Source # 
Instance details

Defined in Network.BSD

NFData HostEntry Source #

Since: 2.8.1.0

Instance details

Defined in Network.BSD

Methods

rnf :: HostEntry -> () #

getHostByName :: HostName -> IO HostEntry Source #

Resolve a HostName to IPv4 address.

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 #

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

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

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
Enum PortNumber 
Instance details

Defined in Network.Socket.Types

Eq PortNumber 
Instance details

Defined in Network.Socket.Types

Integral PortNumber 
Instance details

Defined in Network.Socket.Types

Num PortNumber 
Instance details

Defined in Network.Socket.Types

Ord PortNumber 
Instance details

Defined in Network.Socket.Types

Read 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

Storable PortNumber 
Instance details

Defined in Network.Socket.Types

getServiceEntries :: Bool -> IO [ServiceEntry] Source #

Retrieve list of all ServiceEntry via getservent(3).

Low level functionality

setServiceEntry :: Bool -> IO () Source #

setservent(3).

endServiceEntry :: IO () Source #

endservent(3).

Protocol names

type ProtocolNumber = CInt #

Protocl number.

data ProtocolEntry Source #

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] Source #

Retrieve list of all ProtocolEntry via getprotoent(3).

Low level functionality

setProtocolEntry :: Bool -> IO () Source #

setprotoent(3).

endProtocolEntry :: IO () Source #

endprotoent(3).

Network names

data NetworkEntry Source #

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

Constructors

NetworkEntry 

Fields

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

endNetworkEntry :: IO () Source #

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.