diff options
Diffstat (limited to 'pjsip/include')
-rw-r--r-- | pjsip/include/pjsip/sip_config.h | 14 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_endpoint.h | 2 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_errno.h | 5 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_msg.h | 35 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transaction.h | 221 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transport.h | 6 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transport_loop.h | 94 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_types.h | 6 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_util.h | 82 | ||||
-rw-r--r-- | pjsip/include/pjsip_core.h | 1 |
10 files changed, 343 insertions, 123 deletions
diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h index 592aea41..158d4a75 100644 --- a/pjsip/include/pjsip/sip_config.h +++ b/pjsip/include/pjsip/sip_config.h @@ -45,6 +45,14 @@ #define PJSIP_RFC3261_BRANCH_ID "z9hG4bK" #define PJSIP_RFC3261_BRANCH_LEN 7 +/* Transaction related constants. */ +#define PJSIP_POOL_TSX_LAYER_LEN 4000 +#define PJSIP_POOL_TSX_LAYER_INC 4000 +#define PJSIP_MAX_TSX_COUNT (16*1024) +#define PJSIP_POOL_TSX_LEN 1536 //768 +#define PJSIP_POOL_TSX_INC 256 +#define PJSIP_MAX_TSX_KEY_LEN (PJSIP_MAX_URL_SIZE*2) + /* Message/URL related constants. */ #define PJSIP_MAX_CALL_ID_LEN PJ_GUID_STRING_LENGTH #define PJSIP_MAX_TAG_LEN PJ_GUID_STRING_LENGTH @@ -52,12 +60,6 @@ #define PJSIP_MAX_URL_SIZE 256 #define PJSIP_MAX_HNAME_LEN 64 -/* Transction related constants. */ -#define PJSIP_MAX_TSX_COUNT (16*1024) -#define PJSIP_POOL_LEN_TSX 1536 //768 -#define PJSIP_POOL_INC_TSX 256 -#define PJSIP_MAX_TSX_KEY_LEN (PJSIP_MAX_URL_SIZE*2) - /* Dialog related constants. */ #define PJSIP_MAX_DIALOG_COUNT (16*1024) #define PJSIP_POOL_LEN_DIALOG 1200 diff --git a/pjsip/include/pjsip/sip_endpoint.h b/pjsip/include/pjsip/sip_endpoint.h index d9d03a97..527cd886 100644 --- a/pjsip/include/pjsip/sip_endpoint.h +++ b/pjsip/include/pjsip/sip_endpoint.h @@ -209,7 +209,7 @@ PJ_DECL(pj_pool_t*) pjsip_endpt_create_pool( pjsip_endpoint *endpt, * @param endpt The endpoint. * @param pool The pool to be destroyed. */ -PJ_DECL(void) pjsip_endpt_destroy_pool( pjsip_endpoint *endpt, +PJ_DECL(void) pjsip_endpt_release_pool( pjsip_endpoint *endpt, pj_pool_t *pool ); /** diff --git a/pjsip/include/pjsip/sip_errno.h b/pjsip/include/pjsip/sip_errno.h index 4d50c75d..253e6c00 100644 --- a/pjsip/include/pjsip/sip_errno.h +++ b/pjsip/include/pjsip/sip_errno.h @@ -151,6 +151,11 @@ PJ_DECL(pj_str_t) pjsip_strerror( pj_status_t status, char *buffer, * Expecting response message. */ #define PJSIP_ENOTRESPONSEMSG (PJSIP_ERRNO_START_PJSIP + 31) /* 171031 */ +/** + * @hideinitializer + * Invalid header field. + */ +#define PJSIP_EINVALIDHDR (PJSIP_ERRNO_START_PJSIP + 32) /* 171032 */ /************************************************************ diff --git a/pjsip/include/pjsip/sip_msg.h b/pjsip/include/pjsip/sip_msg.h index e1866048..29bd9766 100644 --- a/pjsip/include/pjsip/sip_msg.h +++ b/pjsip/include/pjsip/sip_msg.h @@ -499,9 +499,13 @@ typedef struct pjsip_msg_body * For incoming messages, the parser will fill in this member with the * content type found in Content-Type header. * - * For outgoing messages, application must fill in this member with + * For outgoing messages, application may fill in this member with * appropriate value, because the stack will generate Content-Type header * based on the value specified here. + * + * If the content_type is empty, no Content-Type AND Content-Length header + * will be added to the message. The stack assumes that application adds + * these headers themselves. */ pjsip_media_type content_type; @@ -543,6 +547,19 @@ typedef struct pjsip_msg_body int (*print_body)(struct pjsip_msg_body *msg_body, char *buf, pj_size_t size); + /** Clone the data part only of this message body. Note that this only + * duplicates the data part of the body instead of the whole message + * body. If application wants to duplicate the entire message body + * structure, it must call #pjsip_msg_body_clone(). + * + * @param pool Pool used to clone the data. + * @param data The data inside message body, to be cloned. + * @param len The length of the data. + * + * @return New data duplicated from the original data. + */ + void* (*clone_data)(pj_pool_t *pool, const void *data, unsigned len); + } pjsip_msg_body; /** @@ -562,6 +579,22 @@ PJ_DECL(int) pjsip_print_text_body( pjsip_msg_body *msg_body, char *buf, pj_size_t size); /** + * Clone the message body in src_body to the dst_body. This will duplicate + * the contents of the message body using the \a clone_data member of the + * source message body. + * + * @param pool Pool to use to duplicate the message body. + * @param dst_body Destination message body. + * @param src_body Source message body to duplicate. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_msg_body_clone(pj_pool_t *pool, + pjsip_msg_body *dst_body, + const pjsip_msg_body *src_body ); + + +/** * @} */ diff --git a/pjsip/include/pjsip/sip_transaction.h b/pjsip/include/pjsip/sip_transaction.h index c0627aab..5d2a5126 100644 --- a/pjsip/include/pjsip/sip_transaction.h +++ b/pjsip/include/pjsip/sip_transaction.h @@ -25,7 +25,7 @@ */ #include <pjsip/sip_msg.h> -#include <pjsip/sip_resolve.h> +#include <pjsip/sip_util.h> #include <pj/timer.h> PJ_BEGIN_DECL @@ -36,42 +36,26 @@ PJ_BEGIN_DECL * @{ */ -/* Forward decl. */ -struct pjsip_transaction; - - /** - * Transaction state. + * This enumeration represents transaction state. */ typedef enum pjsip_tsx_state_e { - PJSIP_TSX_STATE_NULL, - PJSIP_TSX_STATE_CALLING, - PJSIP_TSX_STATE_TRYING, - PJSIP_TSX_STATE_PROCEEDING, - PJSIP_TSX_STATE_COMPLETED, - PJSIP_TSX_STATE_CONFIRMED, - PJSIP_TSX_STATE_TERMINATED, - PJSIP_TSX_STATE_DESTROYED, - PJSIP_TSX_STATE_MAX, + PJSIP_TSX_STATE_NULL, /**< For UAC, before any message is sent. */ + PJSIP_TSX_STATE_CALLING, /**< For UAC, just after request is sent. */ + PJSIP_TSX_STATE_TRYING, /**< For UAS, just after request is received.*/ + PJSIP_TSX_STATE_PROCEEDING, /**< For UAS/UAC, after provisional response.*/ + PJSIP_TSX_STATE_COMPLETED, /**< For UAS/UAC, after final response. */ + PJSIP_TSX_STATE_CONFIRMED, /**< For UAS, after ACK is received. */ + PJSIP_TSX_STATE_TERMINATED, /**< For UAS/UAC, before it's destroyed. */ + PJSIP_TSX_STATE_DESTROYED, /**< For UAS/UAC, will be destroyed now. */ + PJSIP_TSX_STATE_MAX, /**< Number of states. */ } pjsip_tsx_state_e; /** - * State of the transport in the transaction. - * The transport is progressing independently of the transaction. - */ -typedef enum pjsip_tsx_transport_state_e -{ - PJSIP_TSX_TRANSPORT_STATE_NULL, - PJSIP_TSX_TRANSPORT_STATE_RESOLVING, - PJSIP_TSX_TRANSPORT_STATE_CONNECTING, - PJSIP_TSX_TRANSPORT_STATE_FINAL, -} pjsip_tsx_transport_state_e; - - -/** - * Transaction state. + * This structure describes SIP transaction object. The transaction object + * is used to handle both UAS and UAC transaction. */ struct pjsip_transaction { @@ -79,18 +63,18 @@ struct pjsip_transaction * Administrivia */ pj_pool_t *pool; /**< Pool owned by the tsx. */ + pjsip_module *tsx_user; /**< Transaction user. */ pjsip_endpoint *endpt; /**< Endpoint instance. */ pj_mutex_t *mutex; /**< Mutex for this tsx. */ - char obj_name[PJ_MAX_OBJ_NAME]; /**< Tsx name. */ - int tracing; /**< Tracing enabled? */ /* * Transaction identification. */ + char obj_name[PJ_MAX_OBJ_NAME]; /**< Log info. */ pjsip_role_e role; /**< Role (UAS or UAC) */ pjsip_method method; /**< The method. */ int cseq; /**< The CSeq */ - pj_str_t transaction_key;/**< hash table key. */ + pj_str_t transaction_key;/**< Hash table key. */ pj_str_t branch; /**< The branch Id. */ /* @@ -98,7 +82,8 @@ struct pjsip_transaction */ int status_code; /**< Last status code seen. */ pjsip_tsx_state_e state; /**< State. */ - int handle_ack; /**< Should we handle ACK? */ + int handle_200resp; /**< UAS 200/INVITE retrsm.*/ + int tracing; /**< Tracing enabled? */ /** Handler according to current state. */ pj_status_t (*state_handler)(struct pjsip_transaction *, pjsip_event *); @@ -106,123 +91,115 @@ struct pjsip_transaction /* * Transport. */ - pjsip_tsx_transport_state_e transport_state;/**< Transport's state. */ - pjsip_host_info dest_name; /**< Destination address. */ - pjsip_server_addresses remote_addr; /**< Addresses resolved. */ - int current_addr; /**< Address currently used. */ - pjsip_transport *transport; /**< Transport to use. */ + pj_sockaddr addr; /**< Destination address. */ + int addr_len; /**< Address length. */ + pjsip_response_addr res_addr; /**< Response address. */ + unsigned transport_flag; /**< Miscelaneous flag. */ /* * Messages and timer. */ pjsip_tx_data *last_tx; /**< Msg kept for retrans. */ - int has_unsent_msg; /**< Non-zero if tsx need to - transmit msg once resolver - completes. */ int retransmit_count;/**< Retransmission count. */ pj_timer_entry retransmit_timer;/**< Retransmit timer. */ pj_timer_entry timeout_timer; /**< Timeout timer. */ /** Module specific data. */ - void *module_data[PJSIP_MAX_MODULE]; + void *mod_data[PJSIP_MAX_MODULE]; }; /** - * Create new transaction. Application would normally use - * #pjsip_endpt_create_tsx rather than this function. - * - * @param pool Pool to use by the transaction. - * @param endpt Endpoint. - * @param p_tsx Pointer to return the transaction. - * - * @return PJ_SUCCESS or the appropriate error code. + * Create and register transaction layer module to the specified endpoint. * - * @see pjsip_endpt_create_tsx + * @param endpt The endpoint instance. * + * @return PJ_SUCCESS on success. */ -PJ_DEF(pj_status_t) pjsip_tsx_create( pj_pool_t *pool, - pjsip_endpoint *endpt, - pjsip_transaction **p_tsx); - -/** - * Init transaction as UAC from the specified transmit data (\c tdata). - * The transmit data must have a valid \c Request-Line and \c CSeq header. - * If \c Route headers are present, it will be used to calculate remote - * destination. - * - * If \c Via header does not exist, it will be created along with a unique - * \c branch parameter. If it exists and contains branch parameter, then - * the \c branch parameter will be used as is as the transaction key. - * - * The \c Route headers in the transmit data, if present, are used to - * calculate remote destination. - * - * At the end of the function, the transaction will start resolving the - * addresses of remote server to contact. Transport will be acquired as soon - * as the resolving job completes. - * - * @param tsx The transaction. - * @param tdata The transmit data. +PJ_DECL(pj_status_t) pjsip_tsx_layer_init(pjsip_endpoint *endpt); + +/** + * Get the instance of the transaction layer module. * - * @return PJ_SUCCESS if successfull. + * @return The transaction layer module. */ -PJ_DECL(pj_status_t) pjsip_tsx_init_uac( pjsip_transaction *tsx, - pjsip_tx_data *tdata); +PJ_DECL(pjsip_module*) pjsip_tsx_layer_instance(void); /** - * Init transaction as UAS. + * Unregister and destroy transaction layer module. * - * @param tsx The transaction to be initialized. - * @param rdata The received incoming request. - * - * @return PJ_SUCCESS if successfull. + * @return PJ_SUCCESS on success. */ -PJ_DECL(pj_status_t) pjsip_tsx_init_uas( pjsip_transaction *tsx, - pjsip_rx_data *rdata); +PJ_DECL(pj_status_t) pjsip_tsx_layer_destroy(void); /** - * Process incoming message for this transaction. + * Find a transaction with the specified key. The transaction key normally + * is created by calling #pjsip_tsx_create_key() from an incoming message. * - * @param tsx The transaction. - * @param rdata The incoming message. + * @param key The key string to find the transaction. + * @param lock If non-zero, transaction will be locked before the + * function returns, to make sure that it's not deleted + * by other threads. + * + * @return The matching transaction instance, or NULL if transaction + * can not be found. */ -PJ_DECL(void) pjsip_tsx_on_rx_msg( pjsip_transaction *tsx, - pjsip_rx_data *rdata); +PJ_DECL(pjsip_transaction*) pjsip_tsx_layer_find_tsx( const pj_str_t *key, + pj_bool_t lock ); /** - * Transmit message with this transaction. + * Create, initialize, and register a new transaction as UAC from the + * specified transmit data (\c tdata). The transmit data must have a valid + * \c Request-Line and \c CSeq header. * - * @param tsx The transaction. - * @param tdata The outgoing message. + * If \c Via header does not exist, it will be created along with a unique + * \c branch parameter. If it exists and contains branch parameter, then + * the \c branch parameter will be used as is as the transaction key. If + * it exists but branch parameter doesn't exist, a unique branch parameter + * will be created. + * + * @param tsx_user Module to be registered as transaction user of the new + * transaction, which will receive notification from the + * transaction via on_tsx_state() callback. + * @param tdata The outgoing request message. + * @param p_tsx On return will contain the new transaction instance. + * + * @return PJ_SUCCESS if successfull. */ -PJ_DECL(void) pjsip_tsx_on_tx_msg( pjsip_transaction *tsx, - pjsip_tx_data *tdata); - +PJ_DECL(pj_status_t) pjsip_tsx_create_uac( pjsip_module *tsx_user, + pjsip_tx_data *tdata, + pjsip_transaction **p_tsx); /** - * Transmit ACK message for 2xx/INVITE with this transaction. The ACK for - * non-2xx/INVITE is automatically sent by the transaction. - * This operation is only valid if the transaction is configured to handle ACK - * (tsx->handle_ack is non-zero). If this attribute is not set, then the - * transaction will comply with RFC-3261, i.e. it will set itself to - * TERMINATED state when it receives 2xx/INVITE. + * Create, initialize, and register a new transaction as UAS from the + * specified incoming request in \c rdata. * - * @param tsx The transaction. - * @param tdata The ACK request. + * @param tsx_user Module to be registered as transaction user of the new + * transaction, which will receive notification from the + * transaction via on_tsx_state() callback. + * @param rdata The received incoming request. + * @param p_tsx On return will contain the new transaction instance. + * + * @return PJ_SUCCESS if successfull. */ -PJ_DECL(void) pjsip_tsx_on_tx_ack( pjsip_transaction *tsx, - pjsip_tx_data *tdata); +PJ_DECL(pj_status_t) pjsip_tsx_create_uas( pjsip_module *tsx_user, + pjsip_rx_data *rdata, + pjsip_transaction **p_tsx ); /** - * Force terminate transaction. + * 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. * * @param tsx The transaction. - * @param code The status code to report. + * @param tdata The outgoing message. + * + * @return PJ_SUCCESS if successfull. */ -PJ_DECL(void) pjsip_tsx_terminate( pjsip_transaction *tsx, - int code ); +PJ_DECL(pj_status_t) pjsip_tsx_send_msg( pjsip_transaction *tsx, + pjsip_tx_data *tdata); + /** * Create transaction key, which is used to match incoming requests @@ -244,6 +221,29 @@ PJ_DECL(pj_status_t) pjsip_tsx_create_key( pj_pool_t *pool, /** + * Force terminate transaction. + * + * @param tsx The transaction. + * @param code The status code to report. + */ +PJ_DECL(pj_status_t) pjsip_tsx_terminate( pjsip_transaction *tsx, + int st_code ); + + +/** + * Get the transaction instance in the incoming message. If the message + * has a corresponding transaction, this function will return non NULL + * value. + * + * @param rdata The incoming message buffer. + * + * @return The transaction instance associated with this message, + * or NULL if the message doesn't match any transactions. + */ +PJ_DECL(pjsip_transaction*) pjsip_rdata_get_tsx( pjsip_rx_data *rdata ); + + +/** * @} */ @@ -262,9 +262,6 @@ PJ_DECL(const char *) pjsip_tsx_state_str(pjsip_tsx_state_e state); PJ_DECL(const char *) pjsip_role_name(pjsip_role_e role); -/* Thread Local Storage ID for transaction lock (initialized by endpoint) */ -extern long pjsip_tsx_lock_tls_id; - PJ_END_DECL #endif /* __PJSIP_TRANSACT_H__ */ diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h index 6e6ba428..c296054c 100644 --- a/pjsip/include/pjsip/sip_transport.h +++ b/pjsip/include/pjsip/sip_transport.h @@ -171,7 +171,7 @@ struct pjsip_rx_data pj_uint32_t zero; /** The length of the packet received. */ - int len; + pj_ssize_t len; /** The source address from which the packet was received. */ pj_sockaddr src_addr; @@ -251,9 +251,9 @@ struct pjsip_rx_data struct { /** - * This the transaction key generated for the message. + * Data attached by modules to this message. */ - pj_str_t key; + void *mod_data[PJSIP_MAX_MODULE]; } endpt_info; diff --git a/pjsip/include/pjsip/sip_transport_loop.h b/pjsip/include/pjsip/sip_transport_loop.h new file mode 100644 index 00000000..bfcb93f4 --- /dev/null +++ b/pjsip/include/pjsip/sip_transport_loop.h @@ -0,0 +1,94 @@ +/* $Id$ */ +/* + * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJSIP_TRANSPORT_LOOP_H__ +#define __PJSIP_TRANSPORT_LOOP_H__ + +#include <pjsip/sip_transport.h> + +PJ_BEGIN_DECL + +/** + * Create and start datagram loop transport. + * + * @param endpt The endpoint instance. + * @param transport Pointer to receive the transport instance. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_loop_start( pjsip_endpoint *endpt, + pjsip_transport **transport); + + +/** + * Enable/disable flag to discard any packets sent using the specified + * loop transport. + * + * @param tp The loop transport. + * @param discard If non-zero, any outgoing packets will be discarded. + * @param prev_value Optional argument to receive previous value of + * the discard flag. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_loop_set_discard( pjsip_transport *tp, + pj_bool_t discard, + pj_bool_t *prev_value ); + + +/** + * Enable/disable flag to simulate network error. When this flag is set, + * outgoing transmission will return either immediate error or error via + * callback. If error is to be notified via callback, then the notification + * 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 + * the packet. + * @param prev_value Optional argument to receive previous value of + * the failure flag. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_loop_set_failure( pjsip_transport *tp, + int fail_flag, + int *prev_value ); + + +/** + * Set delay (in miliseconds) before packet is delivered. 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_delay( pjsip_transport *tp, + unsigned delay, + unsigned *prev_value); + +PJ_END_DECL + + +#endif /* __PJSIP_TRANSPORT_LOOP_H__ */ + diff --git a/pjsip/include/pjsip/sip_types.h b/pjsip/include/pjsip/sip_types.h index 516d50d5..72fe3af5 100644 --- a/pjsip/include/pjsip/sip_types.h +++ b/pjsip/include/pjsip/sip_types.h @@ -52,6 +52,12 @@ typedef enum pjsip_transport_type_e /** SCTP. */ PJSIP_TRANSPORT_SCTP, + /** Loopback (stream, reliable) */ + PJSIP_TRANSPORT_LOOP, + + /** Loopback (datagram, unreliable) */ + PJSIP_TRANSPORT_LOOP_DGRAM, + } pjsip_transport_type_e; diff --git a/pjsip/include/pjsip/sip_util.h b/pjsip/include/pjsip/sip_util.h index ea0fcf3f..f0d55bdf 100644 --- a/pjsip/include/pjsip/sip_util.h +++ b/pjsip/include/pjsip/sip_util.h @@ -328,6 +328,29 @@ PJ_DECL(pj_status_t) pjsip_endpt_send_response( pjsip_endpoint *endpt, pj_bool_t *cont)); /** + * This composite function sends response message statelessly to an incoming + * request message. Internally it calls #pjsip_endpt_create_response() and + * #pjsip_endpt_send_response(). + * + * @param endpt The endpoint instance. + * @param rdata The incoming request message. + * @param st_code Status code of the response. + * @param st_text Optional status text of the response. + * @param hdr_list Optional header list to be added to the response. + * @param body Optional message body to be added to the response. + * + * @return PJ_SUCCESS if response message has successfully been + * created. + */ +PJ_DECL(pj_status_t) pjsip_endpt_respond_stateless(pjsip_endpoint *endpt, + pjsip_rx_data *rdata, + int st_code, + const pj_str_t *st_text, + const pjsip_hdr *hdr_list, + const pjsip_msg_body *body); + + +/** * Send outgoing request and initiate UAC transaction for the request. * This is an auxiliary function to be used by application to send arbitrary * requests outside a dialog. To send a request within a dialog, application @@ -352,6 +375,65 @@ PJ_DECL(pj_status_t) pjsip_endpt_send_request( pjsip_endpoint *endpt, void *token, void (*cb)(void*,pjsip_event*)); +/** + * Create new request message to be forwarded upstream to new destination URI + * in uri. The new request is a full/deep clone of the request received in + * rdata, unless if other copy mechanism is specified in the options. + * The branch parameter, if not NULL, will be used as the branch-param in + * the Via header. If it is NULL, then a unique branch parameter will be used. + * + * @param endpt The endpoint instance. + * @param rdata The incoming request message. + * @param uri The URI where the request will be forwarded to. + * @param branch Optional branch parameter. + * @param options Optional option flags when duplicating the message. + * @param tdata The result. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_endpt_create_request_fwd( pjsip_endpoint *endpt, + pjsip_rx_data *rdata, + const pjsip_uri *uri, + const pj_str_t *branch, + unsigned options, + pjsip_tx_data **tdata); + +/** + * Create new response message to be forwarded downstream by the proxy from + * the response message found in rdata. Note that this function practically + * will clone the response as is, i.e. without checking the validity of the + * response or removing top most Via header. This function will perform + * full/deep clone of the response, unless other copy mechanism is used in + * the options. + * + * @param endpt The endpoint instance. + * @param rdata The incoming response message. + * @param options Optional option flags when duplicate the message. + * @param tdata The result + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_endpt_create_response_fwd( pjsip_endpoint *endpt, + pjsip_rx_data *rdata, + unsigned options, + pjsip_tx_data **tdata); + + +/** + * Create a globally unique branch parameter based on the information in + * the incoming request message. This function guarantees that subsequent + * retransmissions of the same request will generate the same branch id. + * This function can also be used in the loop detection process. + * If the same request arrives back in the proxy with the same URL, it will + * calculate into the same branch id. + * Note that the returned string was allocated from rdata's pool. + * + * @param rdata The incoming request message. + * + * @return Unique branch-ID string. + */ +PJ_DECL(pj_str_t) pjsip_calculate_branch_id( pjsip_rx_data *rdata ); + /** * @} diff --git a/pjsip/include/pjsip_core.h b/pjsip/include/pjsip_core.h index 9f3c7e9b..5947d4b1 100644 --- a/pjsip/include/pjsip_core.h +++ b/pjsip/include/pjsip_core.h @@ -32,6 +32,7 @@ #include <pjsip/sip_transaction.h> #include <pjsip/sip_transport.h> #include <pjsip/sip_transport_udp.h> +#include <pjsip/sip_transport_loop.h> #include <pjsip/sip_uri.h> #include <pjsip/sip_util.h> |