BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJNATH Reference

Data Fields

pj_status_t(* on_send_pkt )(pj_turn_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_sockaddr_t *dst_addr, unsigned addr_len)
 
pj_status_t(* on_stun_send_pkt )(pj_turn_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_sockaddr_t *dst_addr, unsigned addr_len)
 
void(* on_channel_bound )(pj_turn_session *sess, const pj_sockaddr_t *peer_addr, unsigned addr_len, unsigned ch_num)
 
void(* on_rx_data )(pj_turn_session *sess, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)
 
void(* on_state )(pj_turn_session *sess, pj_turn_state_t old_state, pj_turn_state_t new_state)
 
void(* on_connection_attempt )(pj_turn_session *sess, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
 
void(* on_connection_bind_status )(pj_turn_session *sess, pj_status_t status, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)
 

Detailed Description

Callback to receive events from TURN session.

Field Documentation

◆ on_channel_bound

void(* pj_turn_session_cb::on_channel_bound) (pj_turn_session *sess, const pj_sockaddr_t *peer_addr, unsigned addr_len, unsigned ch_num)

Notification when peer address has been bound successfully to a channel number.

This callback is optional since the nature of this callback is for information only.

Parameters
sessThe TURN session.
peer_addrThe peer address.
addr_lenLength of the peer address.
ch_numThe channel number associated with this peer address.

◆ on_connection_attempt

void(* pj_turn_session_cb::on_connection_attempt) (pj_turn_session *sess, 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 must implement this callback if it uses RFC 6062 (TURN TCP allocations).

After receiving this callback, application should establish a new TCP connection to the TURN server and send ConnectionBind request (using pj_turn_session_connection_bind()). After the connection binding succeeds, this new connection will become a data only connection.

Parameters
sessThe TURN session.
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.

◆ on_connection_bind_status

void(* pj_turn_session_cb::on_connection_bind_status) (pj_turn_session *sess, pj_status_t status, pj_uint32_t conn_id, const pj_sockaddr_t *peer_addr, unsigned addr_len)

Notification for ConnectionBind request sent using pj_turn_session_connection_bind().

Parameters
sessThe TURN session.
statusThe status code.
conn_idThe connection ID.
peer_addrPeer address.
addr_lenLength of the peer address.

◆ on_rx_data

void(* pj_turn_session_cb::on_rx_data) (pj_turn_session *sess, void *pkt, unsigned pkt_len, const pj_sockaddr_t *peer_addr, unsigned addr_len)

Notification when incoming data has been received, either through Data indication or ChannelData message from the TURN server.

Parameters
sessThe TURN session.
pktThe data/payload of the Data Indication or ChannelData packet.
pkt_lenLength of the data/payload.
peer_addrPeer address where this payload was received by the TURN server.
addr_lenLength of the peer address.

◆ on_send_pkt

pj_status_t(* pj_turn_session_cb::on_send_pkt) (pj_turn_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_sockaddr_t *dst_addr, unsigned addr_len)

This callback will be called by the TURN session whenever it needs to send data or outgoing messages. Since the TURN session doesn't have a socket on its own, this callback must be implemented.

If the callback on_stun_send_pkt() is implemented, outgoing messages will use that callback instead.

Parameters
sessThe TURN session.
pktThe packet/data to be sent.
pkt_lenLength of the packet/data.
dst_addrDestination address of the packet.
addr_lenLength of the destination address.
Returns
The callback should return the status of the send operation.

◆ on_state

void(* pj_turn_session_cb::on_state) (pj_turn_session *sess, pj_turn_state_t old_state, pj_turn_state_t new_state)

Notification when TURN session state has changed. Application should implement this callback at least to know that the TURN session is going to be destroyed.

Parameters
sessThe TURN session.
old_stateThe previous state of the session.
new_stateThe current state of the session.

◆ on_stun_send_pkt

pj_status_t(* pj_turn_session_cb::on_stun_send_pkt) (pj_turn_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_sockaddr_t *dst_addr, unsigned addr_len)

This callback will be called by the TURN session whenever it needs to send outgoing STUN requests/messages for TURN signalling purposes (data sending will not invoke this callback). If this callback is not implemented, the callback on_send_pkt() will be called instead.

Parameters
sessThe TURN session.
pktThe packet/data to be sent.
pkt_lenLength of the packet/data.
dst_addrDestination address of the packet.
addr_lenLength of the destination address.
Returns
The callback should return the status of the send operation.

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.