diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-01-07 18:44:25 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-01-07 18:44:25 +0000 |
commit | 57b75697969b3cfd0cc5fe6ca3c98b38acc16608 (patch) | |
tree | bca6c76392e15dcc6447919313eadf835138269d /pjsip/include | |
parent | 9b1fe4bbb2a30ea94d3ff33989341c656936d930 (diff) |
Added test functions for UAC transaction
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@109 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include')
-rw-r--r-- | pjsip/include/pjsip/sip_errno.h | 10 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_module.h | 29 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_msg.h | 7 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transaction.h | 12 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transport.h | 63 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transport_loop.h | 43 |
6 files changed, 147 insertions, 17 deletions
diff --git a/pjsip/include/pjsip/sip_errno.h b/pjsip/include/pjsip/sip_errno.h index 253e6c00..7c3dbbd2 100644 --- a/pjsip/include/pjsip/sip_errno.h +++ b/pjsip/include/pjsip/sip_errno.h @@ -23,6 +23,11 @@ PJ_BEGIN_DECL +/** + * Guidelines on error message length. + */ +#define PJSIP_ERR_MSG_SIZE 64 + /* * PJSIP error codes occupies 170000 - 219000, and mapped as follows: * - 170100 - 170799: mapped to SIP status code in response msg. @@ -86,6 +91,11 @@ PJ_DECL(pj_str_t) pjsip_strerror( pj_status_t status, char *buffer, * SIP object with the same type already exists. */ #define PJSIP_ETYPEEXISTS (PJSIP_ERRNO_START_PJSIP + 2) /* 171002 */ +/** + * @hideinitializer + * SIP stack is shutting down. + */ +#define PJSIP_ESHUTDOWN (PJSIP_ERRNO_START_PJSIP + 3) /* 171003 */ /************************************************************ diff --git a/pjsip/include/pjsip/sip_module.h b/pjsip/include/pjsip/sip_module.h index 0f188194..161e43d2 100644 --- a/pjsip/include/pjsip/sip_module.h +++ b/pjsip/include/pjsip/sip_module.h @@ -133,6 +133,28 @@ struct pjsip_module pj_bool_t (*on_rx_response)(pjsip_rx_data *rdata); /** + * Called to process outgoing request. + * + * @param tdata The outgoing request message. + * + * @return Module should return PJ_SUCCESS in all cases. + * If non-zero (or PJ_FALSE) is returned, the message + * will not be sent. + */ + pj_status_t (*on_tx_request)(pjsip_tx_data *tdata); + + /** + * Called to process outgoing response message. + * + * @param tdata The outgoing response message. + * + * @return Module should return PJ_SUCCESS in all cases. + * If non-zero (or PJ_FALSE) is returned, the message + * will not be sent. + */ + pj_status_t (*on_tx_response)(pjsip_tx_data *tdata); + + /** * Called when this module is acting as transaction user for the specified * transaction, when the transaction's state has changed. * @@ -150,9 +172,10 @@ struct pjsip_module */ enum pjsip_module_priority { - PJSIP_MOD_PRIORITY_TSX_LAYER = 4, - PJSIP_MOD_PRIORITY_UA_PROXY_LAYER = 16, - PJSIP_MOD_PRIORITY_APPLICATION = 32, + PJSIP_MOD_PRIORITY_TRANSPORT_LAYER = 8, + PJSIP_MOD_PRIORITY_TSX_LAYER = 16, + PJSIP_MOD_PRIORITY_UA_PROXY_LAYER = 32, + PJSIP_MOD_PRIORITY_APPLICATION = 64, }; diff --git a/pjsip/include/pjsip/sip_msg.h b/pjsip/include/pjsip/sip_msg.h index 29bd9766..229f2c77 100644 --- a/pjsip/include/pjsip/sip_msg.h +++ b/pjsip/include/pjsip/sip_msg.h @@ -376,6 +376,7 @@ typedef enum pjsip_status_code PJSIP_SC_PROGRESS = 183, PJSIP_SC_OK = 200, + PJSIP_SC_ACCEPTED = 202, PJSIP_SC_MULTIPLE_CHOICES = 300, PJSIP_SC_MOVED_PERMANENTLY = 301, @@ -399,6 +400,7 @@ typedef enum pjsip_status_code PJSIP_SC_UNSUPPORTED_URI_SCHEME = 416, PJSIP_SC_BAD_EXTENSION = 420, PJSIP_SC_EXTENSION_REQUIRED = 421, + PJSIP_SC_SESSION_TIMER_TOO_SMALL = 422, PJSIP_SC_INTERVAL_TOO_BRIEF = 423, PJSIP_SC_TEMPORARILY_UNAVAILABLE = 480, PJSIP_SC_CALL_TSX_DOES_NOT_EXIST = 481, @@ -409,6 +411,8 @@ typedef enum pjsip_status_code PJSIP_SC_BUSY_HERE = 486, PJSIP_SC_REQUEST_TERMINATED = 487, PJSIP_SC_NOT_ACCEPTABLE_HERE = 488, + PJSIP_SC_UNKNOWN_EVENT = 489, + PJSIP_SC_REQUEST_UPDATED = 490, PJSIP_SC_REQUEST_PENDING = 491, PJSIP_SC_UNDECIPHERABLE = 493, @@ -419,6 +423,7 @@ typedef enum pjsip_status_code PJSIP_SC_SERVER_TIMEOUT = 504, PJSIP_SC_VERSION_NOT_SUPPORTED = 505, PJSIP_SC_MESSAGE_TOO_LARGE = 513, + PJSIP_SC_PRECONDITION_FAILURE = 580, PJSIP_SC_BUSY_EVERYWHERE = 600, PJSIP_SC_DECLINE = 603, @@ -426,7 +431,7 @@ typedef enum pjsip_status_code PJSIP_SC_NOT_ACCEPTABLE_ANYWHERE = 606, PJSIP_SC_TSX_TIMEOUT = 701, - PJSIP_SC_TSX_RESOLVE_ERROR = 702, + //PJSIP_SC_TSX_RESOLVE_ERROR = 702, PJSIP_SC_TSX_TRANSPORT_ERROR = 703, } pjsip_status_code; diff --git a/pjsip/include/pjsip/sip_transaction.h b/pjsip/include/pjsip/sip_transaction.h index 5d2a5126..4a7305ec 100644 --- a/pjsip/include/pjsip/sip_transaction.h +++ b/pjsip/include/pjsip/sip_transaction.h @@ -92,6 +92,7 @@ struct pjsip_transaction * Transport. */ pjsip_transport *transport; /**< Transport to use. */ + pj_bool_t is_reliable; /**< Transport is reliable. */ pj_sockaddr addr; /**< Destination address. */ int addr_len; /**< Address length. */ pjsip_response_addr res_addr; /**< Response address. */ @@ -189,11 +190,16 @@ PJ_DECL(pj_status_t) pjsip_tsx_create_uas( pjsip_module *tsx_user, /** * Transmit message in tdata with this transaction. It is possible to - * pass NULL in tdata for UAC transaction, which in this case the request - * message which was specified in #pjsip_tsx_create_uac() will be sent. + * pass NULL in tdata for UAC transaction, which in this case the last message + * or the request message which was specified in #pjsip_tsx_create_uac() + * will be sent. + * + * This function decrements the reference counter of the transmit buffer. * * @param tsx The transaction. - * @param tdata The outgoing message. + * @param tdata The outgoing message. If NULL is specified, then the + * last message transmitted (or the message specified + * in UAC initialization) will be sent. * * @return PJ_SUCCESS if successfull. */ diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h index c296054c..f2cce0f6 100644 --- a/pjsip/include/pjsip/sip_transport.h +++ b/pjsip/include/pjsip/sip_transport.h @@ -109,6 +109,15 @@ pjsip_transport_get_flag_from_type( pjsip_transport_type_e type ); PJ_DECL(int) pjsip_transport_get_default_port_for_type(pjsip_transport_type_e type); +/** + * Get transport type name. + * + * @param t Transport type. + * + * @return Transport name. + */ +PJ_DECL(const char*) pjsip_transport_get_type_name(pjsip_transport_type_e t); + /***************************************************************************** * @@ -203,6 +212,11 @@ struct pjsip_rx_data /** The parsed message, if any. */ pjsip_msg *msg; + /** Short description about the message. + * Application should use #pjsip_rx_data_get_info() instead. + */ + char *info; + /** The Call-ID header as found in the message. */ pj_str_t call_id; @@ -259,6 +273,15 @@ struct pjsip_rx_data }; +/** + * Get printable information about the message in the rdata. + * + * @param rdata The receive data buffer. + * + * @return Printable information. + */ +PJ_DECL(char*) pjsip_rx_data_get_info(pjsip_rx_data *rdata); + /***************************************************************************** * @@ -303,6 +326,12 @@ struct pjsip_tx_data /** A name to identify this buffer. */ char obj_name[PJ_MAX_OBJ_NAME]; + /** Short information describing this buffer and the message in it. + * Application should use #pjsip_tx_data_get_info() instead of + * directly accessing this member. + */ + char *info; + /** For response message, this contains the reference to timestamp when * the original request message was received. The value of this field * is set when application creates response message to a request by @@ -339,6 +368,18 @@ struct pjsip_tx_data /** Transport manager internal. */ void *token; void (*cb)(void*, pjsip_tx_data*, pj_ssize_t); + + /** Transport information, only valid during on_tx_request() and + * on_tx_response() callback. + */ + struct + { + pjsip_transport *transport; /**< Transport being used. */ + pj_sockaddr dst_addr; /**< Destination address. */ + int dst_addr_len; /**< Length of address. */ + char dst_name[16]; /**< Destination address. */ + int dst_port; /**< Destination port. */ + } tp_info; }; @@ -397,6 +438,16 @@ PJ_DECL(pj_bool_t) pjsip_tx_data_is_valid( pjsip_tx_data *tdata ); */ PJ_DECL(void) pjsip_tx_data_invalidate_msg( pjsip_tx_data *tdata ); +/** + * Get short printable info about the transmit data. This will normally return + * short information about the message. + * + * @param tdata The transmit buffer. + * + * @return Null terminated info string. + */ +PJ_DECL(char*) pjsip_tx_data_get_info( pjsip_tx_data *tdata ); + /***************************************************************************** * @@ -593,16 +644,20 @@ PJ_DECL(pj_status_t) pjsip_tpmgr_unregister_tpfactory(pjsip_tpmgr *mgr, * * @param pool Pool. * @param endpt Endpoint instance. - * @param cb Callback to receive incoming message. + * @param rx_cb Callback to receive incoming message. + * @param tx_cb Callback to be called before transport manager is sending + * outgoing message. * @param p_mgr Pointer to receive the new transport manager. * * @return PJ_SUCCESS or the appropriate error code on error. */ PJ_DECL(pj_status_t) pjsip_tpmgr_create( pj_pool_t *pool, pjsip_endpoint * endpt, - void (*cb)(pjsip_endpoint*, - pj_status_t, - pjsip_rx_data *), + void (*rx_cb)(pjsip_endpoint*, + pj_status_t, + pjsip_rx_data *), + pj_status_t (*tx_cb)(pjsip_endpoint*, + pjsip_tx_data*), pjsip_tpmgr **p_mgr); diff --git a/pjsip/include/pjsip/sip_transport_loop.h b/pjsip/include/pjsip/sip_transport_loop.h index bfcb93f4..3cc2af86 100644 --- a/pjsip/include/pjsip/sip_transport_loop.h +++ b/pjsip/include/pjsip/sip_transport_loop.h @@ -58,9 +58,10 @@ PJ_DECL(pj_status_t) pjsip_loop_set_discard( pjsip_transport *tp, * will occur after some delay, which is controlled by #pjsip_loop_set_delay(). * * @param tp The loop transport. - * @param fail_flag If set to 1, the transport will return immediate error. - * If set to 2, the transport will return error via - * callback. If zero, the transport will deliver + * @param fail_flag If set to 1, the transport will return fail to deliver + * the message. If delay is zero, failure will occur + * immediately; otherwise it will be reported in callback. + * If set to zero, the transport will successfully deliver * the packet. * @param prev_value Optional argument to receive previous value of * the failure flag. @@ -73,7 +74,8 @@ PJ_DECL(pj_status_t) pjsip_loop_set_failure( pjsip_transport *tp, /** - * Set delay (in miliseconds) before packet is delivered. This will also + * Set delay (in miliseconds) before packet is received by the other end + * of the loop transport. This will also * control the delay for error notification callback. * * @param tp The loop transport. @@ -83,9 +85,38 @@ PJ_DECL(pj_status_t) pjsip_loop_set_failure( pjsip_transport *tp, * * @return PJ_SUCCESS on success. */ +PJ_DECL(pj_status_t) pjsip_loop_set_recv_delay( pjsip_transport *tp, + unsigned delay, + unsigned *prev_value); + + +/** + * Set delay (in miliseconds) before send notification is delivered to sender. + * This will also control the delay for error notification callback. + * + * @param tp The loop transport. + * @param delay Delay, in miliseconds. + * @param prev_value Optional argument to receive previous value of the + * delay. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_loop_set_send_callback_delay( pjsip_transport *tp, + unsigned delay, + unsigned *prev_value); + + +/** + * Set both receive and send notification delay. + * + * @param tp The loop transport. + * @param delay Delay, in miliseconds. + * + * @return PJ_SUCCESS on success. + */ PJ_DECL(pj_status_t) pjsip_loop_set_delay( pjsip_transport *tp, - unsigned delay, - unsigned *prev_value); + unsigned delay ); + PJ_END_DECL |