UDPAllocation
UDPAllocation
#include <icy/turn/server/udpallocation.h>Inherits:
ServerAllocation
Server-side UDP TURN allocation that relays datagrams to permitted peers. Binds a dedicated UDP relay socket for peer communication and forwards incoming datagrams to the client as Data Indications.
Public Methods
| Return | Name | Description |
|---|---|---|
UDPAllocation | Binds the relay UDP socket and registers the peer receive callback. | |
bool | onPeerDataReceived | Receive callback for the relay UDP socket; validates permissions, updates bandwidth usage, and forwards data to the client as a Data Indication. |
bool | handleRequest virtual | Extends the base handler with Send Indication support. |
void | handleSendIndication | Handles a Send Indication from the client; validates permissions and relays the DATA attribute payload to the peer via the relay socket. Silently discards on permission or attribute errors. |
ssize_t | send | Sends raw data to peerAddress via the relay UDP socket. Updates bandwidth usage and returns -1 if the allocation is expired. |
net::Address | relayedAddress virtual const | #### Returns |
UDPAllocation
UDPAllocation(Server & server, const FiveTuple & tuple, const std::string & username, const uint32_t & lifetime)Binds the relay UDP socket and registers the peer receive callback.
Parameters
serverOwning TURN server.tuple5-tuple identifying this allocation.usernameAuthenticated username from the Allocate request.lifetimeInitial lifetime in seconds.
onPeerDataReceived
bool onPeerDataReceived(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)Receive callback for the relay UDP socket; validates permissions, updates bandwidth usage, and forwards data to the client as a Data Indication.
Parameters
socketThe relay socket.bufferReceived datagram.peerAddressSource address of the peer datagram.
handleRequest
virtual
virtual bool handleRequest(Request & request)Extends the base handler with Send Indication support.
Parameters
requestIncoming STUN request or indication.
Returns
true if handled.
handleSendIndication
void handleSendIndication(Request & request)Handles a Send Indication from the client; validates permissions and relays the DATA attribute payload to the peer via the relay socket. Silently discards on permission or attribute errors.
Parameters
requestIncoming Send Indication.
send
ssize_t send(const char * data, size_t size, const net::Address & peerAddress)Sends raw data to peerAddress via the relay UDP socket. Updates bandwidth usage and returns -1 if the allocation is expired.
Parameters
dataPayload bytes to relay.sizeNumber of bytes.peerAddressDestination peer address.
Returns
Number of bytes sent, or -1 if the quota is exhausted.
relayedAddress
virtual const
virtual net::Address relayedAddress() constReturns
The bound address of the relay UDP socket.
Private Attributes
| Return | Name | Description |
|---|---|---|
net::SocketEmitter | _relaySocket |
_relaySocket
net::SocketEmitter _relaySocket