| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Socket.Datagram.IPv4.Spoof
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
- newtype Socket = Socket Fd
- data Endpoint = Endpoint {}
- data Message = Message {}
- withSocket :: (Socket -> IO a) -> IO (Either SocketException a)
- sendMutableByteArray :: Socket -> Endpoint -> Endpoint -> MutableByteArray RealWorld -> Int -> Int -> IO (Either (SendException Uninterruptible) ())
- data SocketException :: Type where
- data SendException :: Interruptibility -> Type where
Types
A socket that send datagrams with spoofed source IP addresses. It cannot receive datagrams.
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.
Establish
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
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 |
| 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.
( |
Instances
| Show SocketException Source # | |
Defined in Socket.Datagram.IPv4.Spoof Methods showsPrec :: Int -> SocketException -> ShowS # show :: SocketException -> String # showList :: [SocketException] -> ShowS # | |
| Exception SocketException Source # | |
Defined in Socket.Datagram.IPv4.Spoof Methods toException :: SocketException -> SomeException # | |
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) |
Instances
| Show (SendException i) Source # | |
Defined in Socket.Datagram Methods showsPrec :: Int -> SendException i -> ShowS # show :: SendException i -> String # showList :: [SendException i] -> ShowS # | |
| Typeable i => Exception (SendException i) Source # | |
Defined in Socket.Datagram Methods toException :: SendException i -> SomeException # fromException :: SomeException -> Maybe (SendException i) # displayException :: SendException i -> String # | |