BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJNATH Reference

Data Fields

pj_status_t(* on_send_msg )(pj_stun_session *sess, void *token, const void *pkt, pj_size_t pkt_size, const pj_sockaddr_t *dst_addr, unsigned addr_len)
 
pj_status_t(* on_rx_request )(pj_stun_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_stun_rx_data *rdata, void *token, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
 
void(* on_request_complete )(pj_stun_session *sess, pj_status_t status, void *token, pj_stun_tx_data *tdata, const pj_stun_msg *response, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
 
pj_status_t(* on_rx_indication )(pj_stun_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_stun_msg *msg, void *token, const pj_sockaddr_t *src_addr, unsigned src_addr_len)
 

Detailed Description

This is the callback to be registered to pj_stun_session, to send outgoing message and to receive various notifications from the STUN session.

Field Documentation

void(* pj_stun_session_cb::on_request_complete)(pj_stun_session *sess, pj_status_t status, void *token, pj_stun_tx_data *tdata, const pj_stun_msg *response, const pj_sockaddr_t *src_addr, unsigned src_addr_len)

Callback to be called when response is received or the transaction has timed out. This callback is called either when application calls pj_stun_session_on_rx_pkt() with the packet containing a STUN response for the client transaction, or when the internal timer of the STUN client transaction has timed-out before a STUN response is received.

Parameters
sessThe STUN session.
statusStatus of the request. If the value if not PJ_SUCCESS, the transaction has timed-out or other error has occurred, and the response argument may be NULL. Note that when the status is not success, the response may contain non-NULL value if the response contains STUN ERROR-CODE attribute.
tokenThe token that was set by the application when calling pj_stun_session_send_msg() function. Please not that this token IS NOT the token that was given in pj_stun_session_on_rx_pkt().
tdataThe original STUN request.
responseThe response message, on successful transaction, or otherwise MAY BE NULL if status is not success. Note that when the status is not success, this argument may contain non-NULL value if the response contains STUN ERROR-CODE attribute.
src_addrThe source address where the response was received, or NULL if the response is NULL.
src_addr_lenThe length of the source address.
pj_status_t(* pj_stun_session_cb::on_rx_indication)(pj_stun_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_stun_msg *msg, void *token, const pj_sockaddr_t *src_addr, unsigned src_addr_len)

Callback to be called on incoming STUN request message. This function is called when application calls pj_stun_session_on_rx_pkt() and when the STUN session has detected that the incoming STUN message is a STUN indication message.

Parameters
sessThe STUN session.
pktPointer to the original STUN packet.
pkt_lenLength of the STUN packet.
msgThe parsed STUN indication.
tokenThe token that was set by the application when calling pj_stun_session_on_rx_pkt() function.
src_addrSource address of the packet.
src_addr_lenLength of the source address.
Returns
The return value of this callback will be returned back to pj_stun_session_on_rx_pkt() function.
pj_status_t(* pj_stun_session_cb::on_rx_request)(pj_stun_session *sess, const pj_uint8_t *pkt, unsigned pkt_len, const pj_stun_rx_data *rdata, void *token, const pj_sockaddr_t *src_addr, unsigned src_addr_len)

Callback to be called on incoming STUN request message. This function is called when application calls pj_stun_session_on_rx_pkt() and when the STUN session has detected that the incoming STUN message is a STUN request message. In the callback processing, application MUST create a response by calling pj_stun_session_create_response() function and send the response with pj_stun_session_send_msg() function, before returning from the callback.

Parameters
sessThe STUN session.
pktPointer to the original STUN packet.
pkt_lenLength of the STUN packet.
rdataData containing incoming request message.
tokenThe token that was set by the application when calling pj_stun_session_on_rx_pkt() function.
src_addrSource address of the packet.
src_addr_lenLength of the source address.
Returns
The return value of this callback will be returned back to pj_stun_session_on_rx_pkt() function.
pj_status_t(* pj_stun_session_cb::on_send_msg)(pj_stun_session *sess, void *token, const void *pkt, pj_size_t pkt_size, const pj_sockaddr_t *dst_addr, unsigned addr_len)

Callback to be called by the STUN session to send outgoing message.

Parameters
sessThe STUN session.
tokenThe token associated with this outgoing message and was set by the application. This token was set by application in pj_stun_session_send_msg() for outgoing messages that are initiated by the application, or in pj_stun_session_on_rx_pkt() if this message is a response that was internally generated by the STUN session (for example, an 401/Unauthorized response). Application may use this facility for any purposes.
pktPacket to be sent.
pkt_sizeSize of the packet to be sent.
dst_addrThe destination address.
addr_lenLength of destination address.
Returns
The callback should return the status of the packet sending.

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.