Changeset 107 for pjproject/trunk/pjsip/include/pjsip/sip_transaction.h
- Timestamp:
- Jan 5, 2006 11:35:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_transaction.h
r105 r107 26 26 27 27 #include <pjsip/sip_msg.h> 28 #include <pjsip/sip_ resolve.h>28 #include <pjsip/sip_util.h> 29 29 #include <pj/timer.h> 30 30 … … 37 37 */ 38 38 39 /* Forward decl. */ 40 struct pjsip_transaction; 41 42 43 /** 44 * Transaction state. 39 /** 40 * This enumeration represents transaction state. 45 41 */ 46 42 typedef enum pjsip_tsx_state_e 47 43 { 48 PJSIP_TSX_STATE_NULL, 49 PJSIP_TSX_STATE_CALLING, 50 PJSIP_TSX_STATE_TRYING, 51 PJSIP_TSX_STATE_PROCEEDING, 52 PJSIP_TSX_STATE_COMPLETED, 53 PJSIP_TSX_STATE_CONFIRMED, 54 PJSIP_TSX_STATE_TERMINATED, 55 PJSIP_TSX_STATE_DESTROYED, 56 PJSIP_TSX_STATE_MAX, 44 PJSIP_TSX_STATE_NULL, /**< For UAC, before any message is sent. */ 45 PJSIP_TSX_STATE_CALLING, /**< For UAC, just after request is sent. */ 46 PJSIP_TSX_STATE_TRYING, /**< For UAS, just after request is received.*/ 47 PJSIP_TSX_STATE_PROCEEDING, /**< For UAS/UAC, after provisional response.*/ 48 PJSIP_TSX_STATE_COMPLETED, /**< For UAS/UAC, after final response. */ 49 PJSIP_TSX_STATE_CONFIRMED, /**< For UAS, after ACK is received. */ 50 PJSIP_TSX_STATE_TERMINATED, /**< For UAS/UAC, before it's destroyed. */ 51 PJSIP_TSX_STATE_DESTROYED, /**< For UAS/UAC, will be destroyed now. */ 52 PJSIP_TSX_STATE_MAX, /**< Number of states. */ 57 53 } pjsip_tsx_state_e; 58 54 59 55 60 56 /** 61 * State of the transport in the transaction. 62 * The transport is progressing independently of the transaction. 63 */ 64 typedef enum pjsip_tsx_transport_state_e 65 { 66 PJSIP_TSX_TRANSPORT_STATE_NULL, 67 PJSIP_TSX_TRANSPORT_STATE_RESOLVING, 68 PJSIP_TSX_TRANSPORT_STATE_CONNECTING, 69 PJSIP_TSX_TRANSPORT_STATE_FINAL, 70 } pjsip_tsx_transport_state_e; 71 72 73 /** 74 * Transaction state. 57 * This structure describes SIP transaction object. The transaction object 58 * is used to handle both UAS and UAC transaction. 75 59 */ 76 60 struct pjsip_transaction … … 80 64 */ 81 65 pj_pool_t *pool; /**< Pool owned by the tsx. */ 66 pjsip_module *tsx_user; /**< Transaction user. */ 82 67 pjsip_endpoint *endpt; /**< Endpoint instance. */ 83 68 pj_mutex_t *mutex; /**< Mutex for this tsx. */ 84 char obj_name[PJ_MAX_OBJ_NAME]; /**< Tsx name. */85 int tracing; /**< Tracing enabled? */86 69 87 70 /* 88 71 * Transaction identification. 89 72 */ 73 char obj_name[PJ_MAX_OBJ_NAME]; /**< Log info. */ 90 74 pjsip_role_e role; /**< Role (UAS or UAC) */ 91 75 pjsip_method method; /**< The method. */ 92 76 int cseq; /**< The CSeq */ 93 pj_str_t transaction_key;/**< hash table key. */77 pj_str_t transaction_key;/**< Hash table key. */ 94 78 pj_str_t branch; /**< The branch Id. */ 95 79 … … 99 83 int status_code; /**< Last status code seen. */ 100 84 pjsip_tsx_state_e state; /**< State. */ 101 int handle_ack; /**< Should we handle ACK? */ 85 int handle_200resp; /**< UAS 200/INVITE retrsm.*/ 86 int tracing; /**< Tracing enabled? */ 102 87 103 88 /** Handler according to current state. */ … … 107 92 * Transport. 108 93 */ 109 pjsip_tsx_transport_state_e transport_state;/**< Transport's state. */110 pjsip_host_info dest_name; /**< Destination address. */111 pjsip_server_addresses remote_addr; /**< Addresses resolved. */112 int current_addr; /**< Address currently used. */113 114 94 pjsip_transport *transport; /**< Transport to use. */ 95 pj_sockaddr addr; /**< Destination address. */ 96 int addr_len; /**< Address length. */ 97 pjsip_response_addr res_addr; /**< Response address. */ 98 unsigned transport_flag; /**< Miscelaneous flag. */ 115 99 116 100 /* … … 118 102 */ 119 103 pjsip_tx_data *last_tx; /**< Msg kept for retrans. */ 120 int has_unsent_msg; /**< Non-zero if tsx need to121 transmit msg once resolver122 completes. */123 104 int retransmit_count;/**< Retransmission count. */ 124 105 pj_timer_entry retransmit_timer;/**< Retransmit timer. */ … … 126 107 127 108 /** Module specific data. */ 128 void *mod ule_data[PJSIP_MAX_MODULE];109 void *mod_data[PJSIP_MAX_MODULE]; 129 110 }; 130 111 131 112 132 113 /** 133 * Create new transaction. Application would normally use 134 * #pjsip_endpt_create_tsx rather than this function. 135 * 136 * @param pool Pool to use by the transaction. 137 * @param endpt Endpoint. 138 * @param p_tsx Pointer to return the transaction. 139 * 140 * @return PJ_SUCCESS or the appropriate error code. 141 * 142 * @see pjsip_endpt_create_tsx 143 * 144 */ 145 PJ_DEF(pj_status_t) pjsip_tsx_create( pj_pool_t *pool, 146 pjsip_endpoint *endpt, 147 pjsip_transaction **p_tsx); 148 149 /** 150 * Init transaction as UAC from the specified transmit data (\c tdata). 151 * The transmit data must have a valid \c Request-Line and \c CSeq header. 152 * If \c Route headers are present, it will be used to calculate remote 153 * destination. 114 * Create and register transaction layer module to the specified endpoint. 115 * 116 * @param endpt The endpoint instance. 117 * 118 * @return PJ_SUCCESS on success. 119 */ 120 PJ_DECL(pj_status_t) pjsip_tsx_layer_init(pjsip_endpoint *endpt); 121 122 /** 123 * Get the instance of the transaction layer module. 124 * 125 * @return The transaction layer module. 126 */ 127 PJ_DECL(pjsip_module*) pjsip_tsx_layer_instance(void); 128 129 /** 130 * Unregister and destroy transaction layer module. 131 * 132 * @return PJ_SUCCESS on success. 133 */ 134 PJ_DECL(pj_status_t) pjsip_tsx_layer_destroy(void); 135 136 /** 137 * Find a transaction with the specified key. The transaction key normally 138 * is created by calling #pjsip_tsx_create_key() from an incoming message. 139 * 140 * @param key The key string to find the transaction. 141 * @param lock If non-zero, transaction will be locked before the 142 * function returns, to make sure that it's not deleted 143 * by other threads. 144 * 145 * @return The matching transaction instance, or NULL if transaction 146 * can not be found. 147 */ 148 PJ_DECL(pjsip_transaction*) pjsip_tsx_layer_find_tsx( const pj_str_t *key, 149 pj_bool_t lock ); 150 151 /** 152 * Create, initialize, and register a new transaction as UAC from the 153 * specified transmit data (\c tdata). The transmit data must have a valid 154 * \c Request-Line and \c CSeq header. 154 155 * 155 156 * If \c Via header does not exist, it will be created along with a unique 156 157 * \c branch parameter. If it exists and contains branch parameter, then 157 * the \c branch parameter will be used as is as the transaction key. 158 * 159 * The \c Route headers in the transmit data, if present, are used to 160 * calculate remote destination. 161 * 162 * At the end of the function, the transaction will start resolving the 163 * addresses of remote server to contact. Transport will be acquired as soon 164 * as the resolving job completes. 165 * 166 * @param tsx The transaction. 167 * @param tdata The transmit data. 158 * the \c branch parameter will be used as is as the transaction key. If 159 * it exists but branch parameter doesn't exist, a unique branch parameter 160 * will be created. 161 * 162 * @param tsx_user Module to be registered as transaction user of the new 163 * transaction, which will receive notification from the 164 * transaction via on_tsx_state() callback. 165 * @param tdata The outgoing request message. 166 * @param p_tsx On return will contain the new transaction instance. 168 167 * 169 168 * @return PJ_SUCCESS if successfull. 170 169 */ 171 PJ_DECL(pj_status_t) pjsip_tsx_init_uac( pjsip_transaction *tsx, 172 pjsip_tx_data *tdata); 173 174 /** 175 * Init transaction as UAS. 176 * 177 * @param tsx The transaction to be initialized. 170 PJ_DECL(pj_status_t) pjsip_tsx_create_uac( pjsip_module *tsx_user, 171 pjsip_tx_data *tdata, 172 pjsip_transaction **p_tsx); 173 174 /** 175 * Create, initialize, and register a new transaction as UAS from the 176 * specified incoming request in \c rdata. 177 * 178 * @param tsx_user Module to be registered as transaction user of the new 179 * transaction, which will receive notification from the 180 * transaction via on_tsx_state() callback. 178 181 * @param rdata The received incoming request. 179 * 180 * @return PJ_SUCCESS if successfull. 181 */ 182 PJ_DECL(pj_status_t) pjsip_tsx_init_uas( pjsip_transaction *tsx, 183 pjsip_rx_data *rdata); 184 185 /** 186 * Process incoming message for this transaction. 187 * 188 * @param tsx The transaction. 189 * @param rdata The incoming message. 190 */ 191 PJ_DECL(void) pjsip_tsx_on_rx_msg( pjsip_transaction *tsx, 192 pjsip_rx_data *rdata); 193 194 /** 195 * Transmit message with this transaction. 182 * @param p_tsx On return will contain the new transaction instance. 183 * 184 * @return PJ_SUCCESS if successfull. 185 */ 186 PJ_DECL(pj_status_t) pjsip_tsx_create_uas( pjsip_module *tsx_user, 187 pjsip_rx_data *rdata, 188 pjsip_transaction **p_tsx ); 189 190 /** 191 * Transmit message in tdata with this transaction. It is possible to 192 * pass NULL in tdata for UAC transaction, which in this case the request 193 * message which was specified in #pjsip_tsx_create_uac() will be sent. 196 194 * 197 195 * @param tsx The transaction. 198 196 * @param tdata The outgoing message. 199 */ 200 PJ_DECL(void) pjsip_tsx_on_tx_msg( pjsip_transaction *tsx, 201 pjsip_tx_data *tdata); 202 203 204 /** 205 * Transmit ACK message for 2xx/INVITE with this transaction. The ACK for 206 * non-2xx/INVITE is automatically sent by the transaction. 207 * This operation is only valid if the transaction is configured to handle ACK 208 * (tsx->handle_ack is non-zero). If this attribute is not set, then the 209 * transaction will comply with RFC-3261, i.e. it will set itself to 210 * TERMINATED state when it receives 2xx/INVITE. 211 * 212 * @param tsx The transaction. 213 * @param tdata The ACK request. 214 */ 215 PJ_DECL(void) pjsip_tsx_on_tx_ack( pjsip_transaction *tsx, 216 pjsip_tx_data *tdata); 217 218 /** 219 * Force terminate transaction. 220 * 221 * @param tsx The transaction. 222 * @param code The status code to report. 223 */ 224 PJ_DECL(void) pjsip_tsx_terminate( pjsip_transaction *tsx, 225 int code ); 197 * 198 * @return PJ_SUCCESS if successfull. 199 */ 200 PJ_DECL(pj_status_t) pjsip_tsx_send_msg( pjsip_transaction *tsx, 201 pjsip_tx_data *tdata); 202 226 203 227 204 /** … … 245 222 246 223 /** 224 * Force terminate transaction. 225 * 226 * @param tsx The transaction. 227 * @param code The status code to report. 228 */ 229 PJ_DECL(pj_status_t) pjsip_tsx_terminate( pjsip_transaction *tsx, 230 int st_code ); 231 232 233 /** 234 * Get the transaction instance in the incoming message. If the message 235 * has a corresponding transaction, this function will return non NULL 236 * value. 237 * 238 * @param rdata The incoming message buffer. 239 * 240 * @return The transaction instance associated with this message, 241 * or NULL if the message doesn't match any transactions. 242 */ 243 PJ_DECL(pjsip_transaction*) pjsip_rdata_get_tsx( pjsip_rx_data *rdata ); 244 245 246 /** 247 247 * @} 248 248 */ … … 263 263 264 264 265 /* Thread Local Storage ID for transaction lock (initialized by endpoint) */266 extern long pjsip_tsx_lock_tls_id;267 268 265 PJ_END_DECL 269 266
Note: See TracChangeset
for help on using the changeset viewer.