Home
TURN module (rfc5766)

UDPAllocation

Server-side UDP TURN allocation that relays datagrams to permitted peers.

UDPAllocation

#include <icy/turn/server/udpallocation.h>
class UDPAllocation

Defined in src/turn/include/icy/turn/server/udpallocation.h:31

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.

List of all members

NameKindOwner
UDPAllocationfunctionDeclared here
~UDPAllocationfunctionDeclared here
onPeerDataReceivedfunctionDeclared here
handleRequestfunctionDeclared here
handleSendIndicationfunctionDeclared here
sendfunctionDeclared here
relayedAddressfunctionDeclared here
_relaySocketvariableDeclared here
ServerfriendInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
~ServerAllocationfunctionInherited from ServerAllocation
handleRequestfunctionInherited from ServerAllocation
handleRefreshRequestfunctionInherited from ServerAllocation
handleCreatePermissionfunctionInherited from ServerAllocation
onTimerfunctionInherited from ServerAllocation
timeRemainingfunctionInherited from ServerAllocation
maxTimeRemainingfunctionInherited from ServerAllocation
hasPermissionfunctionInherited from ServerAllocation
hasPermissionfunctionInherited from ServerAllocation
serverfunctionInherited from ServerAllocation
printfunctionInherited from ServerAllocation
refreshDeleteRequestedfunctionInherited from ServerAllocation
_maxLifetimevariableInherited from ServerAllocation
_servervariableInherited from ServerAllocation
_permissionPolicyvariableInherited from ServerAllocation
_refreshDeleteRequestedvariableInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
operator=functionInherited from ServerAllocation
ServerAllocationfunctionInherited from ServerAllocation
operator=functionInherited from ServerAllocation
operator<<friendInherited from IAllocation
IAllocationfunctionInherited from IAllocation
~IAllocationfunctionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
operator=functionInherited from IAllocation
IAllocationfunctionInherited from IAllocation
operator=functionInherited from IAllocation
updateUsagefunctionInherited from IAllocation
setLifetimefunctionInherited from IAllocation
setBandwidthLimitfunctionInherited from IAllocation
expiredfunctionInherited from IAllocation
deletedfunctionInherited from IAllocation
bandwidthLimitfunctionInherited from IAllocation
bandwidthUsedfunctionInherited from IAllocation
bandwidthRemainingfunctionInherited from IAllocation
timeRemainingfunctionInherited from IAllocation
tuplefunctionInherited from IAllocation
usernamefunctionInherited from IAllocation
lifetimefunctionInherited from IAllocation
permissionsfunctionInherited from IAllocation
relayedAddressfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionfunctionInherited from IAllocation
addPermissionsfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removePermissionfunctionInherited from IAllocation
removeAllPermissionsfunctionInherited from IAllocation
removeExpiredPermissionsfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
hasPermissionfunctionInherited from IAllocation
printfunctionInherited from IAllocation
_tuplevariableInherited from IAllocation
_usernamevariableInherited from IAllocation
_permissionsvariableInherited from IAllocation
_lifetimevariableInherited from IAllocation
_bandwidthLimitvariableInherited from IAllocation
_bandwidthUsedvariableInherited from IAllocation
_createdAtvariableInherited from IAllocation
_updatedAtvariableInherited from IAllocation
_deletedvariableInherited from IAllocation

Inherited from ServerAllocation

KindNameDescription
friendServer
functionServerAllocation
function~ServerAllocation virtual
functionhandleRequest virtualDispatches incoming STUN requests to handleCreatePermission() or handleRefreshRequest(). Subclasses override to add transport-specific methods.
functionhandleRefreshRequest virtualProcesses a Refresh request; updates the lifetime or sets the delete flag if the requested lifetime is 0, then sends a success response.
functionhandleCreatePermission virtualProcesses a CreatePermission request; installs or refreshes permissions for each XOR-PEER-ADDRESS attribute, then sends a success response.
functiononTimerPeriodic maintenance callback called by Server::onTimer(). Removes expired permissions. Returns false to signal that this allocation should be destroyed.
functiontimeRemaining virtual const override
functionmaxTimeRemaining const
functionhasPermission virtual overrideChecks permission, auto-granting local IPs if enabled in server options.
functionhasPermission virtual overrideChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionserver virtual
functionprint virtual const overrideWrites a detailed diagnostic dump of this allocation to os.
functionrefreshDeleteRequested const inlineReturns true if the refresh request set lifetime to 0, signaling the parent Server to delete this allocation.
variable_maxLifetime
variable_server
variable_permissionPolicy
variable_refreshDeleteRequested
functionServerAllocationNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionServerAllocationDeleted constructor.
functionoperator=Deleted assignment operator.

Inherited from IAllocation

KindNameDescription
friendoperator<< inline
functionIAllocation
function~IAllocation virtual
functionIAllocationDeleted constructor.
functionoperator=Deleted assignment operator.
functionIAllocationDeleted constructor.
functionoperator=Deleted assignment operator.
functionupdateUsage virtualUpdates the last-activity timestamp and accumulates bandwidth usage. Call this whenever data is relayed through the allocation.
functionsetLifetime virtualSets the allocation lifetime in seconds and resets the activity timestamp, effectively extending the expiry from the current moment.
functionsetBandwidthLimit virtualSets the maximum number of bytes this allocation may relay in its lifetime. Pass 0 to disable bandwidth limiting.
functionexpired virtual const
functiondeleted virtual constReturns true if the allocation's deleted flag is set and or if the allocation has expired.
functionbandwidthLimit virtual const
functionbandwidthUsed virtual const
functionbandwidthRemaining virtual const
functiontimeRemaining virtual const
functiontuple virtual
functionusername virtual const
functionlifetime virtual const
functionpermissions virtual const
functionrelayedAddress virtual const
functionaddPermission virtualAdds a permission for ip, or refreshes the existing one.
functionaddPermission virtualAdds a permission for address, or refreshes the existing one. The port is ignored; TURN permissions are IP-only.
functionaddPermissions virtualAdds (or refreshes) permissions for multiple IPs.
functionremovePermission virtualRemoves the permission for ip if present.
functionremovePermission virtualRemoves the permission for address if present. The port is ignored; TURN permissions are IP-only.
functionremoveAllPermissions virtualRemoves all permissions from the list.
functionremoveExpiredPermissions virtualRemoves any permissions whose 5-minute lifetime has elapsed.
functionhasPermission virtualChecks whether a permission exists for peerIP. Local addresses (192.168.x.x and 127.x.x.x) are always permitted.
functionhasPermission virtualChecks whether a permission exists for peerAddress. The port is ignored; TURN permissions are IP-only.
functionprint virtual const inline
variable_tuple
variable_username
variable_permissions
variable_lifetime
variable_bandwidthLimit
variable_bandwidthUsed
variable_createdAt
variable_updatedAt
variable_deleted

Public Methods

ReturnNameDescription
UDPAllocationBinds the relay UDP socket and registers the peer receive callback.
boolonPeerDataReceivedReceive callback for the relay UDP socket; validates permissions, updates bandwidth usage, and forwards data to the client as a Data Indication.
boolhandleRequest virtualExtends the base handler with Send Indication support.
voidhandleSendIndicationHandles 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_tsendSends raw data to peerAddress via the relay UDP socket. Updates bandwidth usage and returns -1 if the allocation is expired.
net::AddressrelayedAddress virtual const

UDPAllocation

UDPAllocation(Server & server, const FiveTuple & tuple, const std::string & username, const uint32_t & lifetime)

Defined in src/turn/include/icy/turn/server/udpallocation.h:39

Binds the relay UDP socket and registers the peer receive callback.

Parameters

  • server Owning TURN server.

  • tuple 5-tuple identifying this allocation.

  • username Authenticated username from the Allocate request.

  • lifetime Initial lifetime in seconds.


onPeerDataReceived

bool onPeerDataReceived(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/server/udpallocation.h:48

Receive callback for the relay UDP socket; validates permissions, updates bandwidth usage, and forwards data to the client as a Data Indication.

Parameters

  • socket The relay socket.

  • buffer Received datagram.

  • peerAddress Source address of the peer datagram.


handleRequest

virtual

virtual bool handleRequest(Request & request)

Defined in src/turn/include/icy/turn/server/udpallocation.h:54

Extends the base handler with Send Indication support.

Parameters

  • request Incoming STUN request or indication.

Returns

true if handled.

Reimplements

handleSendIndication

void handleSendIndication(Request & request)

Defined in src/turn/include/icy/turn/server/udpallocation.h:60

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

  • request Incoming Send Indication.

send

ssize_t send(const char * data, size_t size, const net::Address & peerAddress)

Defined in src/turn/include/icy/turn/server/udpallocation.h:68

Sends raw data to peerAddress via the relay UDP socket. Updates bandwidth usage and returns -1 if the allocation is expired.

Parameters

  • data Payload bytes to relay.

  • size Number of bytes.

  • peerAddress Destination peer address.

Returns

Number of bytes sent, or -1 if the quota is exhausted.


relayedAddress

virtual const

virtual net::Address relayedAddress() const

Defined in src/turn/include/icy/turn/server/udpallocation.h:72

Returns

The bound address of the relay UDP socket.

Reimplements

Private Attributes

ReturnNameDescription
net::SocketEmitter_relaySocket

_relaySocket

net::SocketEmitter _relaySocket

Defined in src/turn/include/icy/turn/server/udpallocation.h:75