Home
TURN module (rfc5766)

UDPClient

UDP transport TURN client for datagram-based relay allocations.

UDPClient

#include <icy/turn/client/udpclient.h>
class UDPClient

Defined in src/turn/include/icy/turn/client/udpclient.h:31

Inherits: Client

UDP transport TURN client for datagram-based relay allocations. Uses a single UDP socket for both STUN signalling and Send/Data Indications. All Client methods apply; data is relayed via sendData() using Send Indications.

List of all members

NameKindOwner
UDPClientfunctionDeclared here
~UDPClientfunctionDeclared here
ClientfunctionInherited from Client
~ClientfunctionInherited from Client
startfunctionInherited from Client
stopfunctionInherited from Client
sendAllocatefunctionInherited from Client
addPermissionfunctionInherited from Client
addPermissionfunctionInherited from Client
sendCreatePermissionfunctionInherited from Client
sendChannelBindfunctionInherited from Client
sendRefreshfunctionInherited from Client
sendDatafunctionInherited from Client
handleResponsefunctionInherited from Client
handleAllocateResponsefunctionInherited from Client
handleAllocateErrorResponsefunctionInherited from Client
handleCreatePermissionResponsefunctionInherited from Client
handleCreatePermissionErrorResponsefunctionInherited from Client
handleRefreshResponsefunctionInherited from Client
handleDataIndicationfunctionInherited from Client
transportProtocolfunctionInherited from Client
createTransactionfunctionInherited from Client
authenticateRequestfunctionInherited from Client
sendAuthenticatedTransactionfunctionInherited from Client
removeTransactionfunctionInherited from Client
mappedAddressfunctionInherited from Client
relayedAddressfunctionInherited from Client
closedfunctionInherited from Client
observerfunctionInherited from Client
optionsfunctionInherited from Client
addPermissionfunctionInherited from Client
addPermissionfunctionInherited from Client
hasPermissionfunctionInherited from Client
hasPermissionfunctionInherited from Client
removePermissionfunctionInherited from Client
removePermissionfunctionInherited from Client
_observervariableInherited from Client
_optionsvariableInherited from Client
_socketvariableInherited from Client
_timervariableInherited from Client
_errorvariableInherited from Client
_mappedAddressvariableInherited from Client
_relayedAddressvariableInherited from Client
_realmvariableInherited from Client
_noncevariableInherited from Client
_pendingIndicationsvariableInherited from Client
_transactionsvariableInherited from Client
setErrorfunctionInherited from Client
onSocketConnectfunctionInherited from Client
onSocketRecvfunctionInherited from Client
onSocketClosefunctionInherited from Client
onTransactionProgressfunctionInherited from Client
onStateChangefunctionInherited from Client
onTimerfunctionInherited from Client
StateChangevariableInherited from Stateful
StatefulfunctionInherited from Stateful
~StatefulfunctionInherited from Stateful
stateEqualsfunctionInherited from Stateful
stateBetweenfunctionInherited from Stateful
statefunctionInherited from Stateful
statefunctionInherited from Stateful
_statevariableInherited from Stateful
beforeStateChangefunctionInherited from Stateful
onStateChangefunctionInherited from Stateful
setStatefunctionInherited from Stateful
setStatefunctionInherited from Stateful
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 Client

KindNameDescription
functionClient
function~Client virtual
functionstart virtualConnects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this.
functionstop virtualStops the timer, cancels pending transactions, and closes the socket.
functionsendAllocate virtualSends an Allocate request to the server with the configured transport and lifetime. On first call the server will typically respond with a 401 challenge; the client re-sends with credentials automatically.
functionaddPermission virtualAdds multiple peer IP addresses to the permission list.
functionaddPermission virtual overrideAdds a single peer IP to the permission list, or refreshes it if already present. Permissions should be added before start(); they may also be added later, in which case a new CreatePermission request is required.
functionsendCreatePermission virtualSends a CreatePermission request for all IPs currently in the permission list. Called automatically after allocation succeeds and periodically by the timer to refresh expiring permissions.
functionsendChannelBind virtualChannel bindings (RFC 5766 Section 11) are intentionally not implemented. They are a bandwidth optimization that replaces STUN-framed Send/Data indications with a compact 4-byte ChannelData header. This only benefits high-throughput media relay scenarios; in practice, media flows directly via ICE/DTLS rather than through this TURN client's data path, so the optimization is not worth the complexity (channel number allocation, 10-minute binding refresh timers, ChannelData wire framing). Data relay uses sendData() with Send Indications instead.
functionsendRefresh virtualSends a Refresh request to extend the allocation lifetime. Called automatically by the timer when roughly one-third of the lifetime remains.
functionsendData virtualSends a Send Indication to relay data to peerAddress through the TURN server. If permissions are still being negotiated the indication is queued and flushed once CreatePermission succeeds.
functionhandleResponse virtualDispatches an incoming STUN/TURN response to the appropriate handler.
functionhandleAllocateResponse virtualProcesses a successful Allocate response; extracts mapped/relayed addresses and advances the state to Authorizing, then sends CreatePermission.
functionhandleAllocateErrorResponse virtualHandles an Allocate error response; manages the 401 challenge/re-send flow and sets the client to Failed for unrecoverable errors.
functionhandleCreatePermissionResponse virtualHandles a successful CreatePermission response; flushes queued Send Indications and advances state to Success.
functionhandleCreatePermissionErrorResponse virtualHandles a failed CreatePermission response; clears all permissions and sets the client to Failed.
functionhandleRefreshResponse virtualHandles a Refresh response; updates the stored lifetime.
functionhandleDataIndication virtualHandles an incoming Data Indication; extracts peer address and data and forwards to ClientObserver::onRelayDataReceived().
functiontransportProtocol virtual
functioncreateTransaction virtualCreates a new STUN transaction, registers the progress callback, and adds it to the active transaction list.
functionauthenticateRequest virtualAdds STUN long-term credential attributes (Username, Realm, Nonce, MessageIntegrity) to request if the realm has been received from the server.
functionsendAuthenticatedTransaction virtualCalls authenticateRequest() then sends the transaction.
functionremoveTransaction virtualRemoves a transaction from the active list. The IntrusivePtr keeps the object alive until the caller's copy is released.
functionmappedAddress const
functionrelayedAddress virtual const override
functionclosed const
functionobserver
functionoptions 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.
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.
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.
variable_observer
variable_options
variable_socket
variable_timer
variable_error
variable_mappedAddress
variable_relayedAddress
variable_realm
variable_nonce
variable_pendingIndicationsA list of queued Send indication packets awaiting server permissions.
variable_transactionsA list containing currently active transactions.
functionsetError virtualSets the error field and transitions the client to the Failed state.
functiononSocketConnect virtualSocket connect callback; starts the timer and sends the first Allocate request.
functiononSocketRecv virtualSocket receive callback; parses STUN messages from the buffer and dispatches them.
functiononSocketClose virtualSocket close callback; shuts down the client and records the socket error.
functiononTransactionProgress virtualSTUN transaction state-change callback; handles Success and Failed outcomes.
functiononStateChange overrideForwards state-change events to the observer.
functiononTimer virtualPeriodic timer callback; re-allocates on expiry or refreshes when lifetime is below one-third remaining. Also calls ClientObserver::onTimer().

Inherited from Stateful

KindNameDescription
variableStateChangeSignals when the state changes.
functionStateful inline
function~Stateful virtual inline
functionstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
functionstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
functionstate virtual inlineReturns a mutable reference to the current state.
functionstate virtual const inlineReturns a copy of the current state.
variable_state
functionbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
functiononStateChange virtual inlineOverride to handle post state change logic.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.

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
UDPClient

UDPClient

UDPClient(ClientObserver & observer, const Options & options = Options())

Defined in src/turn/include/icy/turn/client/udpclient.h:36

Parameters

  • observer Observer for allocation lifecycle and data relay events.

  • options Client configuration; defaults to loopback server, 5-min lifetime.