BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJNATH Reference

pj_stun_sock_cb Struct Reference
[STUN-aware socket transport]

Data Fields

pj_bool_t(* on_rx_data )(pj_stun_sock *stun_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *src_addr, unsigned addr_len)
pj_bool_t(* on_data_sent )(pj_stun_sock *stun_sock, pj_ioqueue_op_key_t *send_key, pj_ssize_t sent)
pj_bool_t(* on_status )(pj_stun_sock *stun_sock, pj_stun_sock_op op, pj_status_t status)

Detailed Description

This structure contains callbacks that will be called by the STUN transport to notify application about various events.


Field Documentation

Notifification when asynchronous send operation has completed.

Parameters:
stun_sock The STUN transport.
send_key The send operation key that was given in pj_stun_sock_sendto().
sent If value is positive non-zero it indicates the number of data sent. When the value is negative, it contains the error code which can be retrieved by negating the value (i.e. status=-sent).
Returns:
Application should normally return PJ_TRUE to let the STUN transport continue its operation. However it must return PJ_FALSE if it has destroyed the STUN transport in this callback.
pj_bool_t(* pj_stun_sock_cb::on_rx_data)(pj_stun_sock *stun_sock, void *pkt, unsigned pkt_len, const pj_sockaddr_t *src_addr, unsigned addr_len)

Notification when incoming packet has been received.

Parameters:
stun_sock The STUN transport.
data The packet.
data_len Length of the packet.
src_addr The source address of the packet.
addr_len The length of the source address.
Returns:
Application should normally return PJ_TRUE to let the STUN transport continue its operation. However it must return PJ_FALSE if it has destroyed the STUN transport in this callback.

Notification when the status of the STUN transport has changed. This callback may be called for the following conditions:

  • the first time the publicly mapped address has been resolved from the STUN server, this callback will be called with op argument set to PJ_STUN_SOCK_BINDING_OP status argument set to PJ_SUCCESS.
  • anytime when the transport has detected that the publicly mapped address has changed, this callback will be called with op argument set to PJ_STUN_SOCK_KEEP_ALIVE_OP and status argument set to PJ_SUCCESS. On this case and the case above, application will get the resolved public address in the pj_stun_sock_info structure.
  • for any terminal error (such as STUN time-out, DNS resolution failure, or keep-alive failure), this callback will be called with the status argument set to non-PJ_SUCCESS.
Parameters:
stun_sock The STUN transport.
op The operation that triggers the callback.
status The status.
Returns:
Must return PJ_FALSE if it has destroyed the STUN transport in this callback. Application should normally destroy the socket and return PJ_FALSE upon encountering terminal error, otherwise it should return PJ_TRUE to let the STUN socket operation continues.

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.