BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJNATH Reference

Data Fields

void(* on_rx_data )(pj_turn_sock *turn_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
 
void(* on_state )(pj_turn_sock *turn_sock, pj_turn_state_t old_state, pj_turn_state_t new_state)
 
pj_status_t(* on_connection_attempt )(pj_turn_sock *turn_sock, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
 
void(* on_connection_status )(pj_turn_sock *turn_sock, pj_status_t status, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
 

Detailed Description

This structure contains callbacks that will be called by the TURN transport.

Field Documentation

◆ on_connection_attempt

pj_status_t(* pj_turn_sock_cb::on_connection_attempt) (pj_turn_sock *turn_sock, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)

Notification when TURN client received a ConnectionAttempt Indication from the TURN server, which indicates that peer initiates a TCP connection to allocated slot in the TURN server. Application should implement this callback if it uses RFC 6062 (TURN TCP allocations), otherwise TURN client will automatically accept it.

If application accepts the peer connection attempt (i.e: by returning PJ_SUCCESS or not implementing this callback), the TURN socket will initiate a new connection to the TURN server and send ConnectionBind request, and eventually will notify application via on_connection_status callback, if implemented.

Parameters
turn_sockThe TURN client transport.
conn_idThe connection ID assigned by TURN server.
peer_addrPeer address that tried to connect to the TURN server.
addr_lenLength of the peer address.
Returns
The callback must return PJ_SUCCESS to accept the connection attempt.

◆ on_connection_status

void(* pj_turn_sock_cb::on_connection_status) (pj_turn_sock *turn_sock, pj_status_t status, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)

Notification for initiated TCP data connection to peer (RFC 6062), for example after peer connection attempt is accepted.

Parameters
turn_sockThe TURN client transport.
statusThe status code.
conn_idThe connection ID.
peer_addrPeer address.
addr_lenLength of the peer address.

◆ on_rx_data

void(* pj_turn_sock_cb::on_rx_data) (pj_turn_sock *turn_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)

Notification when incoming data has been received from the remote peer via the TURN server. The data reported in this callback will be the exact data as sent by the peer (e.g. the TURN encapsulation such as Data Indication or ChannelData will be removed before this function is called).

Parameters
turn_sockThe TURN client transport.
dataThe data as received from the peer.
data_lenLength of the data.
peer_addrThe peer address.
addr_lenThe length of the peer address.

◆ on_state

void(* pj_turn_sock_cb::on_state) (pj_turn_sock *turn_sock, pj_turn_state_t old_state, pj_turn_state_t new_state)

Notification when TURN session state has changed. Application should implement this callback to monitor the progress of the TURN session.

Parameters
turn_sockThe TURN client transport.
old_statePrevious state.
new_stateCurrent state.

The documentation for this struct was generated from the following file:

 


PJNATH - Open Source NAT traversal helper library supporting STUN, TURN, and ICE
Copyright (C) 2006-2009 Teluu Inc.