sockets-0.3.1.0: High-level network sockets

Safe HaskellNone
LanguageHaskell2010

Socket.Datagram.IPv4.Spoof

Contents

Description

Internet datagram sockets without a fixed destination. The user may spoof the source address and may specify the packet ID. An application must have CAP_NET_RAW or be running as root to use the functions in this module.

Synopsis

Types

newtype Socket Source #

A socket that send datagrams with spoofed source IP addresses. It cannot receive datagrams.

Constructors

Socket Fd 
Instances
Eq Socket Source # 
Instance details

Defined in Socket.Datagram.IPv4.Spoof

Methods

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

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

Ord Socket Source # 
Instance details

Defined in Socket.Datagram.IPv4.Spoof

Show Socket Source # 
Instance details

Defined in Socket.Datagram.IPv4.Spoof

data Endpoint Source #

An endpoint for an IPv4 socket, connection, or listener. Everything is in host byte order, and the user is not responisble for performing any conversions.

Constructors

Endpoint 

Fields

Instances
Eq Endpoint Source # 
Instance details

Defined in Socket.IPv4

Show Endpoint Source # 
Instance details

Defined in Socket.IPv4

data Message Source #

Constructors

Message 

Fields

Instances
Eq Message Source # 
Instance details

Defined in Socket.Datagram.IPv4.Undestined.Internal

Methods

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

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

Show Message Source # 
Instance details

Defined in Socket.Datagram.IPv4.Undestined.Internal

Establish

withSocket Source #

Arguments

:: (Socket -> IO a)

Callback providing the socket

-> IO (Either SocketException a) 

Open a socket and run the supplied callback on it. This closes the socket when the callback finishes or when an exception is thrown. Do not return the socket from the callback. This leads to undefined behavior. The user cannot specify an endpoint since the socket cannot receive traffic.

Communicate

sendMutableByteArray Source #

Arguments

:: Socket

Socket

-> Endpoint

Spoofed source address and port

-> Endpoint

Remote IPv4 address and port

-> MutableByteArray RealWorld

Buffer (will be sliced)

-> Int

Offset into payload

-> Int

Lenth of slice into buffer

-> IO (Either (SendException Uninterruptible) ()) 

Send a slice of a bytearray to the specified endpoint.

Exceptions

data SocketException :: Type where Source #

Constructors

SocketPermissionDenied :: SocketException

Permission to create a raw socket was denied. The process needs the capability CAP_NET_RAW, or it must be run as root.

SocketFileDescriptorLimit :: SocketException

A limit on the number of open file descriptors has been reached. This could be the per-process limit or the system limit. (EMFILE and ENFILE)

data SendException :: Interruptibility -> Type where Source #

Constructors

SendTruncated :: !Int -> SendException i

The datagram did not fit in the buffer. The field is the number of bytes that were successfully copied into the send buffer. The datagram does still get sent when this happens.

SendBroadcasted :: SendException i

Attempted to send to a broadcast address.

SendInterrupted :: SendException Interruptible

STM-style interrupt (much safer than C-style interrupt)