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

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

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

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

Instances details
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

Methods

compare :: Family -> Family -> Ordering

(<) :: Family -> Family -> Bool

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

(>) :: Family -> Family -> Bool

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

max :: Family -> Family -> Family

min :: Family -> Family -> Family

Read Family 
Instance details

Defined in Network.Socket.Types

Methods

readsPrec :: Int -> ReadS Family

readList :: ReadS [Family]

readPrec :: ReadPrec Family

readListPrec :: ReadPrec [Family]

Show Family 
Instance details

Defined in Network.Socket.Types

Methods

showsPrec :: Int -> Family -> ShowS

show :: Family -> String

showList :: [Family] -> ShowS

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

Instances details
Read HostEntry Source # 
Instance details

Defined in Network.BSD

Methods

readsPrec :: Int -> ReadS HostEntry

readList :: ReadS [HostEntry]

readPrec :: ReadPrec HostEntry

readListPrec :: ReadPrec [HostEntry]

Show HostEntry Source # 
Instance details

Defined in Network.BSD

Methods

showsPrec :: Int -> HostEntry -> ShowS

show :: HostEntry -> String

showList :: [HostEntry] -> ShowS

Storable HostEntry Source # 
Instance details

Defined in Network.BSD

Methods

sizeOf :: HostEntry -> Int

alignment :: HostEntry -> Int

peekElemOff :: Ptr HostEntry -> Int -> IO HostEntry

pokeElemOff :: Ptr HostEntry -> Int -> HostEntry -> IO ()

peekByteOff :: Ptr b -> Int -> IO HostEntry

pokeByteOff :: Ptr b -> Int -> HostEntry -> IO ()

peek :: Ptr HostEntry -> IO HostEntry

poke :: Ptr HostEntry -> HostEntry -> IO ()

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

Instances

Instances details
Show ServiceEntry Source # 
Instance details

Defined in Network.BSD

Methods

showsPrec :: Int -> ServiceEntry -> ShowS

show :: ServiceEntry -> String

showList :: [ServiceEntry] -> ShowS

Storable ServiceEntry Source # 
Instance details

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

Since: 2.8.1.0

Instance details

Defined in Network.BSD

Methods

rnf :: ServiceEntry -> ()

type ServiceName = String Source #

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

data PortNumber Source #

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

Defined in Network.Socket.Types

Eq PortNumber 
Instance details

Defined in Network.Socket.Types

Methods

(==) :: PortNumber -> PortNumber -> Bool

(/=) :: PortNumber -> PortNumber -> Bool

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

Methods

readsPrec :: Int -> ReadS PortNumber

readList :: ReadS [PortNumber]

readPrec :: ReadPrec PortNumber

readListPrec :: ReadPrec [PortNumber]

Real PortNumber 
Instance details

Defined in Network.Socket.Types

Methods

toRational :: PortNumber -> Rational

Show PortNumber 
Instance details

Defined in Network.Socket.Types

Methods

showsPrec :: Int -> PortNumber -> ShowS

show :: PortNumber -> String

showList :: [PortNumber] -> ShowS

Storable PortNumber 
Instance details

Defined in Network.Socket.Types

Methods

sizeOf :: PortNumber -> Int

alignment :: PortNumber -> Int

peekElemOff :: Ptr PortNumber -> Int -> IO PortNumber

pokeElemOff :: Ptr PortNumber -> Int -> PortNumber -> IO ()

peekByteOff :: Ptr b -> Int -> IO PortNumber

pokeByteOff :: Ptr b -> Int -> PortNumber -> IO ()

peek :: Ptr PortNumber -> IO PortNumber

poke :: Ptr PortNumber -> PortNumber -> IO ()

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

Protocol number.

data ProtocolEntry Source #

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

Constructors

ProtocolEntry 

Fields

Instances

Instances details
Read ProtocolEntry Source # 
Instance details

Defined in Network.BSD

Methods

readsPrec :: Int -> ReadS ProtocolEntry

readList :: ReadS [ProtocolEntry]

readPrec :: ReadPrec ProtocolEntry

readListPrec :: ReadPrec [ProtocolEntry]

Show ProtocolEntry Source # 
Instance details

Defined in Network.BSD

Methods

showsPrec :: Int -> ProtocolEntry -> ShowS

show :: ProtocolEntry -> String

showList :: [ProtocolEntry] -> ShowS

Storable ProtocolEntry Source # 
Instance details

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

Since: 2.8.1.0

Instance details

Defined in Network.BSD

Methods

rnf :: ProtocolEntry -> ()

defaultProtocol :: ProtocolNumber Source #

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

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

Instances details
Read NetworkEntry Source # 
Instance details

Defined in Network.BSD

Methods

readsPrec :: Int -> ReadS NetworkEntry

readList :: ReadS [NetworkEntry]

readPrec :: ReadPrec NetworkEntry

readListPrec :: ReadPrec [NetworkEntry]

Show NetworkEntry Source # 
Instance details

Defined in Network.BSD

Methods

showsPrec :: Int -> NetworkEntry -> ShowS

show :: NetworkEntry -> String

showList :: [NetworkEntry] -> ShowS

Storable NetworkEntry Source # 
Instance details

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

Since: 2.8.1.0

Instance details

Defined in Network.BSD

Methods

rnf :: NetworkEntry -> ()

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

Returns the index corresponding to the interface name.

Since 2.7.0.0.