Ignore:
Timestamp:
Jun 23, 2006 3:04:54 PM (18 years ago)
Author:
bennylp
Message:

Renamed pjsip_transport_unregister() to pjsip_transport_destroy(), also initial implementation of TCP transport

File:
1 edited

Legend:

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

    r515 r550  
    493493    pj_atomic_t            *ref_cnt;        /**< Reference counter.         */ 
    494494    pj_lock_t              *lock;           /**< Lock object.               */ 
    495     int                     tracing;        /**< Tracing enabled?           */ 
     495    pj_bool_t               tracing;        /**< Tracing enabled?           */ 
     496    pj_bool_t               is_shutdown;    /**< Being shutdown?            */ 
    496497 
    497498    /** Key for indexing this transport in hash table. */ 
     
    550551 
    551552    /** 
    552      * Destroy this transport. 
     553     * Instruct the transport to initiate graceful shutdown procedure. 
     554     * After all objects release their reference to this transport, 
     555     * the transport will be deleted. 
     556     * 
     557     * Note that application MUST use #pjsip_transport_shutdown() instead. 
     558     * 
     559     * @param transport     The transport. 
     560     * 
     561     * @return              PJ_SUCCESS on success. 
     562     */ 
     563    pj_status_t (*do_shutdown)(pjsip_transport *transport); 
     564 
     565    /** 
     566     * Forcefully destroy this transport regardless whether there are 
     567     * objects that currently use this transport. This function should only 
     568     * be called by transport manager or other internal objects (such as the 
     569     * transport itself) who know what they're doing. Application should use 
     570     * #pjsip_transport_shutdown() instead. 
     571     * 
     572     * @param transport     The transport. 
     573     * 
     574     * @return              PJ_SUCCESS on success. 
    553575     */ 
    554576    pj_status_t (*destroy)(pjsip_transport *transport); 
     
    561583 
    562584/** 
    563  * Register a transport. 
     585 * Register a transport instance to the transport manager. This function 
     586 * is normally called by the transport instance when it is created 
     587 * by application. 
     588 * 
     589 * @param mgr           The transport manager. 
     590 * @param tp            The new transport to be registered. 
     591 * 
     592 * @return              PJ_SUCCESS on success. 
    564593 */ 
    565594PJ_DECL(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr, 
     
    568597 
    569598/** 
    570  * Unregister transport. This will eventually call the transport to 
    571  * destroy itself. 
    572  */ 
    573 PJ_DECL(pj_status_t) pjsip_transport_unregister( pjsip_tpmgr *mgr, 
    574                                                  pjsip_transport *tp); 
    575  
    576 /** 
    577  * Add ref. 
     599 * Start graceful shutdown procedure for this transport. After graceful 
     600 * shutdown has been initiated, no new reference can be obtained for 
     601 * the transport. However, existing objects that currently uses the 
     602 * transport may still use this transport to send and receive packets. 
     603 * 
     604 * After all objects release their reference to this transport, 
     605 * the transport will be destroyed immediately. 
     606 * 
     607 * @param tp                The transport. 
     608 * 
     609 * @return                  PJ_SUCCESS on success. 
     610 */ 
     611PJ_DECL(pj_status_t) pjsip_transport_shutdown(pjsip_transport *tp); 
     612 
     613/** 
     614 * Destroy a transport when there is no object currently uses the transport. 
     615 * This function is normally called internally by transport manager or the 
     616 * transport itself. Application should use #pjsip_transport_shutdown() 
     617 * instead. 
     618 * 
     619 * @param tp            The transport instance. 
     620 * 
     621 * @return              PJ_SUCCESS on success or the appropriate error code. 
     622 *                      Some of possible errors are PJSIP_EBUSY if the  
     623 *                      transport's reference counter is not zero. 
     624 */ 
     625PJ_DECL(pj_status_t) pjsip_transport_destroy( pjsip_transport *tp); 
     626 
     627/** 
     628 * Add reference counter to the specified transport. Any objects that wishes 
     629 * to keep the reference of the transport MUST increment the transport's 
     630 * reference counter to prevent it from being destroyed. 
     631 * 
     632 * @param tp            The transport instance. 
     633 * 
     634 * @return              PJ_SUCCESS on success or the appropriate error code. 
    578635 */ 
    579636PJ_DECL(pj_status_t) pjsip_transport_add_ref( pjsip_transport *tp ); 
    580637 
    581638/** 
    582  * Dec ref. 
     639 * Decrement reference counter of the specified transport. When an object no 
     640 * longer want to keep the reference to the transport, it must decrement the 
     641 * reference counter. When the reference counter of the transport reaches  
     642 * zero, the transport manager will start the idle timer to destroy the 
     643 * transport if no objects acquire the reference counter during the idle 
     644 * interval. 
     645 * 
     646 * @param tp            The transport instance. 
     647 * 
     648 * @return              PJ_SUCCESS on success. 
    583649 */ 
    584650PJ_DECL(pj_status_t) pjsip_transport_dec_ref( pjsip_transport *tp ); 
     
    586652 
    587653/** 
    588  * Call for incoming message. 
     654 * This function is called by transport instances to report an incoming  
     655 * packet to the transport manager. The transport manager then would try to 
     656 * parse all SIP messages in the packet, and for each parsed SIP message, it 
     657 * would report the message to the SIP endpoint (#pjsip_endpoint). 
     658 * 
     659 * @param mgr           The transport manager instance. 
     660 * @param rdata         The receive data buffer containing the packet. The 
     661 *                      transport MUST fully initialize tp_info and pkt_info 
     662 *                      member of the rdata. 
     663 * 
     664 * @return              The number of bytes successfully processed from the 
     665 *                      packet. If the transport is datagram oriented, the 
     666 *                      value will be equal to the size of the packet. For 
     667 *                      stream oriented transport (e.g. TCP, TLS), the value 
     668 *                      returned may be less than the packet size, if  
     669 *                      partial message is received. The transport then MUST 
     670 *                      keep the remainder part and report it again to 
     671 *                      this function once more data/packet is received. 
    589672 */ 
    590673PJ_DECL(pj_ssize_t) pjsip_tpmgr_receive_packet(pjsip_tpmgr *mgr, 
     
    598681 *****************************************************************************/ 
    599682 
    600  
    601 /** 
    602  * Transport factory. 
     683/* 
     684 * Forward declaration for transport factory (since it is referenced by 
     685 * the transport factory itself). 
    603686 */ 
    604687typedef struct pjsip_tpfactory pjsip_tpfactory; 
    605688 
    606 /** 
    607  * Transport factory. 
     689 
     690/** 
     691 * A transport factory is normally used for connection oriented transports 
     692 * (such as TCP or TLS) to create instances of transports. It registers 
     693 * a new transport type to the transport manager, and the transport manager 
     694 * would ask the factory to create a transport instance when it received 
     695 * command from application to send a SIP message using the specified 
     696 * transport type. 
    608697 */ 
    609698struct pjsip_tpfactory 
Note: See TracChangeset for help on using the changeset viewer.