Ignore:
Timestamp:
Jun 22, 2007 11:32:49 AM (16 years ago)
Author:
bennylp
Message:

Committed ticket #337: Ability to restart PJSIP UDP transport

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_transport_udp.h

    r974 r1382  
    3737 * the transport to the framework. 
    3838 */ 
     39 
     40/** 
     41 * Flag that can be specified when calling #pjsip_udp_transport_pause() or 
     42 * #pjsip_udp_transport_restart(). 
     43 */ 
     44enum 
     45{ 
     46    /** 
     47     * This flag tells the transport to keep the existing/internal socket 
     48     * handle. 
     49     */ 
     50    PJSIP_UDP_TRANSPORT_KEEP_SOCKET     = 1, 
     51 
     52    /** 
     53     * This flag tells the transport to destroy the existing/internal socket 
     54     * handle. Naturally this flag and PJSIP_UDP_TRANSPORT_KEEP_SOCKET are  
     55     * mutually exclusive. 
     56     */ 
     57    PJSIP_UDP_TRANSPORT_DESTROY_SOCKET  = 2 
     58}; 
     59 
    3960 
    4061/** 
     
    82103 
    83104 
     105/** 
     106 * Retrieve the internal socket handle used by the UDP transport. Note 
     107 * that this socket normally is registered to ioqueue, so if application 
     108 * wants to make use of this socket, it should temporarily pause the 
     109 * transport. 
     110 * 
     111 * @param transport     The UDP transport. 
     112 * 
     113 * @return              The socket handle, or PJ_INVALID_SOCKET if no socket 
     114 *                      is currently being used (for example, when transport 
     115 *                      is being paused). 
     116 */ 
     117PJ_DECL(pj_sock_t) pjsip_udp_transport_get_socket(pjsip_transport *transport); 
     118 
     119 
     120/** 
     121 * Temporarily pause or shutdown the transport. When transport is being 
     122 * paused, it cannot be used by the SIP stack to send or receive SIP 
     123 * messages. 
     124 * 
     125 * Two types of operations are supported by this function: 
     126 *  - to temporarily make this transport unavailable for SIP uses, but 
     127 *    otherwise keep the socket handle intact. Application then can 
     128 *    retrieve the socket handle with #pjsip_udp_transport_get_socket() 
     129 *    and use it to send/receive application data (for example, STUN 
     130 *    messages). In this case, application should specify 
     131 *    PJSIP_UDP_TRANSPORT_KEEP_SOCKET when calling this function, and 
     132 *    also to specify this flag when calling #pjsip_udp_transport_restart() 
     133 *    later. 
     134 *  - to temporarily shutdown the transport, including closing down 
     135 *    the internal socket handle. This is useful for example to 
     136 *    temporarily suspend the application for an indefinite period. In 
     137 *    this case, application should specify PJSIP_UDP_TRANSPORT_DESTROY_SOCKET 
     138 *    flag when calling this function, and specify a new socket when 
     139 *    calling #pjsip_udp_transport_restart(). 
     140 * 
     141 * @param transport     The UDP transport. 
     142 * @param option        Pause option. 
     143 * 
     144 * @return              PJ_SUCCESS if transport is paused successfully, 
     145 *                      or the appropriate error code. 
     146 */ 
     147PJ_DECL(pj_status_t) pjsip_udp_transport_pause(pjsip_transport *transport, 
     148                                               unsigned option); 
     149 
     150/** 
     151 * Restart the transport. Several operations are supported by this function: 
     152 *  - if transport was made temporarily unavailable to SIP stack with 
     153 *    pjsip_udp_transport_pause() and PJSIP_UDP_TRANSPORT_KEEP_SOCKET, 
     154 *    application can make the transport available to the SIP stack 
     155 *    again, by specifying PJSIP_UDP_TRANSPORT_KEEP_SOCKET flag here. 
     156 *  - if application wants to replace the internal socket with a new 
     157 *    socket, it must specify PJSIP_UDP_TRANSPORT_DESTROY_SOCKET when 
     158 *    calling this function, so that the internal socket will be destroyed 
     159 *    if it hasn't been closed. In this case, application has two choices 
     160 *    on how to create the new socket: 1) to let the transport create 
     161 *    the new socket, in this case the \a sock option should be set 
     162 *    to \a PJ_INVALID_SOCKET and optionally the \a local parameter can be 
     163 *    filled with the desired address and port where the new socket  
     164 *    should be bound to, or 2) to specify its own socket to be used 
     165 *    by this transport, by specifying a valid socket in \a sock argument 
     166 *    and set the \a local argument to NULL. In both cases, application 
     167 *    may specify the published address of the socket in \a a_name 
     168 *    argument. 
     169 * 
     170 * @param transport     The UDP transport. 
     171 * @param option        Restart option. 
     172 * @param sock          Optional socket to be used by the transport. 
     173 * @param local         The address where the socket should be bound to. 
     174 *                      If this argument is NULL, socket will be bound 
     175 *                      to any available port. 
     176 * @param a_name        Optionally specify the published address for 
     177 *                      this transport. If the socket is not replaced 
     178 *                      (PJSIP_UDP_TRANSPORT_KEEP_SOCKET flag is 
     179 *                      specified), then if this argument is NULL, the 
     180 *                      previous value will be used. If the socket is 
     181 *                      replaced and this argument is NULL, the bound 
     182 *                      address will be used as the published address  
     183 *                      of the transport. 
     184 * 
     185 * @return              PJ_SUCCESS if transport can be restarted, or 
     186 *                      the appropriate error code. 
     187 */ 
     188PJ_DECL(pj_status_t) pjsip_udp_transport_restart(pjsip_transport *transport, 
     189                                                 unsigned option, 
     190                                                 pj_sock_t sock, 
     191                                                 const pj_sockaddr_in *local, 
     192                                                 const pjsip_host_port *a_name); 
     193 
     194 
    84195PJ_END_DECL 
    85196 
Note: See TracChangeset for help on using the changeset viewer.