WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJNATH Reference

#include <stun_sock.h>

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

◆ on_data_sent

pj_bool_t(* pj_stun_sock_cb::on_data_sent) (pj_stun_sock *stun_sock, pj_ioqueue_op_key_t *send_key, pj_ssize_t sent)

Notifification when asynchronous send operation has completed.

Parameters
stun_sockThe STUN transport.
send_keyThe send operation key that was given in pj_stun_sock_sendto().
sentIf 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.

◆ on_rx_data

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_sockThe STUN transport.
dataThe packet.
data_lenLength of the packet.
src_addrThe source address of the packet.
addr_lenThe 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.

◆ on_status

pj_bool_t(* pj_stun_sock_cb::on_status) (pj_stun_sock *stun_sock, pj_stun_sock_op op, pj_status_t status)

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_sockThe STUN transport.
opThe operation that triggers the callback.
statusThe 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.