diff options
Diffstat (limited to 'pjsip/include/pjsip')
-rw-r--r-- | pjsip/include/pjsip/sip_auth.h | 79 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_config.h | 50 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_endpoint.h | 73 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transport.h | 110 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_transport_tls.h | 42 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_types.h | 7 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_uri.h | 10 | ||||
-rw-r--r-- | pjsip/include/pjsip/sip_util.h | 9 |
8 files changed, 362 insertions, 18 deletions
diff --git a/pjsip/include/pjsip/sip_auth.h b/pjsip/include/pjsip/sip_auth.h index 613e0d5..cd59372 100644 --- a/pjsip/include/pjsip/sip_auth.h +++ b/pjsip/include/pjsip/sip_auth.h @@ -1,4 +1,4 @@ -/* $Id: sip_auth.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: sip_auth.h 4214 2012-07-25 14:29:28Z nanang $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> @@ -275,6 +275,37 @@ typedef pj_status_t pjsip_auth_lookup_cred( pj_pool_t *pool, const pj_str_t *acc_name, pjsip_cred_info *cred_info ); + +/** + * This structure describes input param for credential lookup. + */ +typedef struct pjsip_auth_lookup_cred_param +{ + pj_str_t realm; /**< Realm to find the account. */ + pj_str_t acc_name; /**< Account name to look for. */ + pjsip_rx_data *rdata; /**< Incoming request to be authenticated. */ + +} pjsip_auth_lookup_cred_param; + + +/** + * Type of function to lookup credential for the specified name. + * + * @param pool Pool to initialize the credential info. + * @param param The input param for credential lookup. + * @param cred_info The structure to put the credential when it's found. + * + * @return The function MUST return PJ_SUCCESS when it found + * a correct credential for the specified account and + * realm. Otherwise it may return PJSIP_EAUTHACCNOTFOUND + * or PJSIP_EAUTHACCDISABLED. + */ +typedef pj_status_t pjsip_auth_lookup_cred2( + pj_pool_t *pool, + const pjsip_auth_lookup_cred_param *param, + pjsip_cred_info *cred_info ); + + /** Flag to specify that server is a proxy. */ #define PJSIP_AUTH_SRV_IS_PROXY 1 @@ -286,7 +317,8 @@ typedef struct pjsip_auth_srv pj_str_t realm; /**< Realm to serve. */ pj_bool_t is_proxy; /**< Will issue 407 instead of 401 */ pjsip_auth_lookup_cred *lookup; /**< Lookup function. */ - + pjsip_auth_lookup_cred2 *lookup2; /**< Lookup function with additional + info in its input param. */ } pjsip_auth_srv; @@ -434,6 +466,49 @@ PJ_DECL(pj_status_t) pjsip_auth_srv_init( pj_pool_t *pool, /** + * This structure describes initialization settings of server authorization + * session. + */ +typedef struct pjsip_auth_srv_init_param +{ + /** + * Realm to be served by the server. + */ + const pj_str_t *realm; + + /** + * Account lookup function. + */ + pjsip_auth_lookup_cred2 *lookup2; + + /** + * Options, bitmask of: + * - PJSIP_AUTH_SRV_IS_PROXY: to specify that the server will authorize + * clients as a proxy server (instead of as UAS), which means that + * Proxy-Authenticate will be used instead of WWW-Authenticate. + */ + unsigned options; + +} pjsip_auth_srv_init_param; + + +/** + * Initialize server authorization session data structure to serve the + * specified realm and to use lookup_func function to look for the credential + * info. + * + * @param pool Pool used to initialize the authentication server. + * @param auth_srv The authentication server structure. + * @param param The initialization param. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_auth_srv_init2( + pj_pool_t *pool, + pjsip_auth_srv *auth_srv, + const pjsip_auth_srv_init_param *param); + +/** * Request the authorization server framework to verify the authorization * information in the specified request in rdata. * diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h index 9035b1e..bde0777 100644 --- a/pjsip/include/pjsip/sip_config.h +++ b/pjsip/include/pjsip/sip_config.h @@ -1,4 +1,4 @@ -/* $Id: sip_config.h 4172 2012-06-19 14:35:18Z nanang $ */ +/* $Id: sip_config.h 4285 2012-10-19 04:23:57Z nanang $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> @@ -73,18 +73,41 @@ typedef struct pjsip_cfg_t /** * Specify port number should be allowed to appear in To and From * header. Note that RFC 3261 disallow this, see Table 1 in section - * 19.1.1 of the RFC. Default is PJSIP_ALLOW_PORT_IN_FROMTO_HDR. + * 19.1.1 of the RFC. + * + * Default is PJSIP_ALLOW_PORT_IN_FROMTO_HDR. */ pj_bool_t allow_port_in_fromto_hdr; /** + * Accept call replace in early state when invite is not initiated + * by the user agent. RFC 3891 Section 3 disallows this, however, + * for better interoperability reason, this might be ignored. + * + * Default is PJSIP_ACCEPT_REPLACE_IN_EARLY_STATE. + */ + pj_bool_t accept_replace_in_early_state; + + /** + * Allow hash character ('#') to appear in outgoing URIs. See + * https://trac.pjsip.org/repos/ticket/1569. + * + * Default is PJ_FALSE. + */ + pj_bool_t allow_tx_hash_in_uri; + + /** * Disable rport in request. + * + * Default is PJ_FALSE. */ pj_bool_t disable_rport; /** * Disable automatic switching from UDP to TCP if outgoing request - * is greater than 1300 bytes. See PJSIP_DONT_SWITCH_TO_TCP. + * is greater than 1300 bytes. + * + * Default is PJSIP_DONT_SWITCH_TO_TCP. */ pj_bool_t disable_tcp_switch; @@ -269,6 +292,21 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void) /** + * Accept call replace in early state when invite is not initiated + * by the user agent. RFC 3891 Section 3 disallows this, however, + * for better interoperability reason, this might be ignored. + * + * This option can also be controlled at run-time by the + * \a accept_replace_in_early_state setting in pjsip_cfg_t. + * + * Default is 0 (no). + */ +#ifndef PJSIP_ACCEPT_REPLACE_IN_EARLY_STATE +# define PJSIP_ACCEPT_REPLACE_IN_EARLY_STATE 0 +#endif + + +/** * This setting controls the threshold of the UDP packet, which if it's * larger than this value the request will be sent with TCP. This setting * is useful only when PJSIP_DONT_SWITCH_TO_TCP is set to 0. @@ -362,9 +400,13 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void) * response is received, the response will be discarded since its Via * sent-by now contains address that is different than the transport * address. + * + * Update: + * As of version 2.1, the default value is 0. This change was part of + * https://trac.pjsip.org/repos/ticket/1412 */ #ifndef PJSIP_CHECK_VIA_SENT_BY -# define PJSIP_CHECK_VIA_SENT_BY 1 +# define PJSIP_CHECK_VIA_SENT_BY 0 #endif diff --git a/pjsip/include/pjsip/sip_endpoint.h b/pjsip/include/pjsip/sip_endpoint.h index ac3f525..63c65d7 100644 --- a/pjsip/include/pjsip/sip_endpoint.h +++ b/pjsip/include/pjsip/sip_endpoint.h @@ -1,4 +1,4 @@ -/* $Id: sip_endpoint.h 4154 2012-06-05 10:41:17Z bennylp $ */ +/* $Id: sip_endpoint.h 4275 2012-10-04 06:11:58Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> @@ -213,6 +213,77 @@ PJ_DECL(pj_status_t) pjsip_endpt_register_module( pjsip_endpoint *endpt, PJ_DECL(pj_status_t) pjsip_endpt_unregister_module( pjsip_endpoint *endpt, pjsip_module *module ); +/** + * This describes additional parameters to pjsip_endpt_process_rx_data() + * function. Application MUST call pjsip_process_rdata_param_default() to + * initialize this structure. + */ +typedef struct pjsip_process_rdata_param +{ + /** + * Specify the minimum priority number of the modules that are allowed + * to process the message. Default is zero to allow all modules to + * process the message. + */ + unsigned start_prio; + + /** + * Specify the pointer of the module where processing will start. + * The default is NULL, meaning processing will start from the start + * of the module list. + */ + void *start_mod; + + /** + * Set to N, then processing will start at Nth module after start + * module (where start module can be an explicit module as specified + * by \a start_mod or the start of module list when \a start_mod is + * NULL). For example, if set to 1, then processing will start from + * the next module after start module. Default is zero. + */ + unsigned idx_after_start; + + /** + * Print nothing to log. Default is PJ_FALSE. + */ + pj_bool_t silent; + +} pjsip_process_rdata_param; + +/** + * Initialize with default. + * + * @param p The param. + */ +PJ_DECL(void) pjsip_process_rdata_param_default(pjsip_process_rdata_param *p); + +/** + * Manually distribute the specified pjsip_rx_data to registered modules. + * Normally application does not need to call this function because received + * messages will be given to endpoint automatically by transports. + * + * Application can use this function when it has postponed the processing of + * an incoming message, for example to perform long operations such as + * database operation or to consult other servers to decide what to do with + * the message. In this case, application clones the original rdata, return + * from the callback, and perform the long operation. Upon completing the + * long operation, it resumes pjsip's module processing by calling this + * function, and then free the cloned rdata. + * + * @param endpt The endpoint instance. + * @param rdata The rdata to be distributed. + * @param p Optional pointer to param to specify from which module + * the processing should start. + * @param p_handled Optional pointer to receive last return value of + * module's \a on_rx_request() or \a on_rx_response() + * callback. + * + * @return PJ_SUCCESS on success. + */ +PJ_DECL(pj_status_t) pjsip_endpt_process_rx_data(pjsip_endpoint *endpt, + pjsip_rx_data *rdata, + pjsip_process_rdata_param *p, + pj_bool_t *p_handled); /** * Create pool from the endpoint. All SIP components should allocate their diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h index c8ea6fd..21b2238 100644 --- a/pjsip/include/pjsip/sip_transport.h +++ b/pjsip/include/pjsip/sip_transport.h @@ -1,4 +1,4 @@ -/* $Id: sip_transport.h 4173 2012-06-20 10:39:05Z ming $ */ +/* $Id: sip_transport.h 4275 2012-10-04 06:11:58Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> @@ -427,6 +427,42 @@ struct pjsip_rx_data */ PJ_DECL(char*) pjsip_rx_data_get_info(pjsip_rx_data *rdata); +/** + * Clone pjsip_rx_data. This will duplicate the contents of + * pjsip_rx_data and add reference count to the transport. + * Once application has finished using the cloned pjsip_rx_data, + * it must release it by calling #pjsip_rx_data_free_cloned(). + * + * By default (if flags is set to zero), this function copies the + * transport pointer in \a tp_info, duplicates the \a pkt_info, + * perform deep clone of the \a msg_info parts of the rdata, and + * fills the \a endpt_info (i.e. the \a mod_data) with zeros. + * + * @param src The source to be cloned. + * @param flags Optional flags. Must be zero for now. + * @param p_rdata Pointer to receive the cloned rdata. + * + * @return PJ_SUCCESS on success or the appropriate error. + */ +PJ_DECL(pj_status_t) pjsip_rx_data_clone(const pjsip_rx_data *src, + unsigned flags, + pjsip_rx_data **p_rdata); + +/** + * Free cloned pjsip_rx_data. This function must be and must only + * be called for a cloned pjsip_rx_data. Specifically, it must NOT + * be called for the original pjsip_rx_data that is returned by + * transports. + * + * This function will free the memory used by the pjsip_rx_data and + * decrement the transport reference counter. + * + * @param rdata The receive data buffer. + * + * @return PJ_SUCCESS on success or the appropriate error. + */ +PJ_DECL(pj_status_t) pjsip_rx_data_free_cloned(pjsip_rx_data *rdata); + /***************************************************************************** * @@ -1076,6 +1112,8 @@ PJ_DECL(pj_status_t) pjsip_tpmgr_create( pj_pool_t *pool, * In this implementation, it will only select the transport based on * the transport type in the request. * + * @see pjsip_tpmgr_find_local_addr2() + * * @param tpmgr The transport manager. * @param pool Pool to allocate memory for the IP address. * @param type Destination address to contact. @@ -1093,6 +1131,76 @@ PJ_DECL(pj_status_t) pjsip_tpmgr_find_local_addr( pjsip_tpmgr *tpmgr, int *port); /** + * Parameter for pjsip_tpmgr_find_local_addr2() function. + */ +typedef struct pjsip_tpmgr_fla2_param +{ + /** + * Specify transport type to use. This must be set. + */ + pjsip_transport_type_e tp_type; + + /** + * Optional pointer to preferred transport, if any. + */ + const pjsip_tpselector *tp_sel; + + /** + * Destination host, if known. The destination host is needed + * if \a local_if field below is set. + */ + pj_str_t dst_host; + + /** + * Specify if the function should return which local interface + * to use for the specified destination in \a dst_host. By definition, + * the returned address will always be local interface address. + */ + pj_bool_t local_if; + + /** + * The returned address. + */ + pj_str_t ret_addr; + + /** + * The returned port. + */ + pj_uint16_t ret_port; + + /** + * Returned pointer to the transport. Only set if local_if is set. + */ + const void *ret_tp; + +} pjsip_tpmgr_fla2_param; + +/** + * Initialize with default values. + * + * @param prm The parameter to be initialized. + */ +PJ_DECL(void) pjsip_tpmgr_fla2_param_default(pjsip_tpmgr_fla2_param *prm); + +/** + * Find out the appropriate local address info (IP address and port) to + * advertise in Contact or Via header header based on the remote address + * to be contacted. The local address info would be the address name of the + * transport or listener which will be used to send the request. + * + * @see pjsip_tpmgr_find_local_addr() + * + * @param tpmgr The transport manager. + * @param pool Pool to allocate memory for the IP address. + * @param param Function input and output parameters. + * + * @return PJ_SUCCESS, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsip_tpmgr_find_local_addr2(pjsip_tpmgr *tpmgr, + pj_pool_t *pool, + pjsip_tpmgr_fla2_param *prm); + +/** * Return number of transports currently registered to the transport * manager. * diff --git a/pjsip/include/pjsip/sip_transport_tls.h b/pjsip/include/pjsip/sip_transport_tls.h index cbc1d75..8164c63 100644 --- a/pjsip/include/pjsip/sip_transport_tls.h +++ b/pjsip/include/pjsip/sip_transport_tls.h @@ -1,4 +1,4 @@ -/* $Id: sip_transport_tls.h 3999 2012-03-30 07:10:13Z bennylp $ */ +/* $Id: sip_transport_tls.h 4262 2012-09-20 06:00:23Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> @@ -262,6 +262,8 @@ PJ_INLINE(void) pjsip_tls_setting_copy(pj_pool_t *pool, * instance of SIP TLS transport factory and register it to the * transport manager. * + * See also #pjsip_tls_transport_start2() which supports IPv6. + * * @param endpt The SIP endpoint. * @param opt Optional TLS settings. * @param local Optional local address to bind, or specify the @@ -294,7 +296,43 @@ PJ_DECL(pj_status_t) pjsip_tls_transport_start(pjsip_endpoint *endpt, unsigned async_cnt, pjsip_tpfactory **p_factory); - +/** + * Variant of #pjsip_tls_transport_start() that supports IPv6. To instantiate + * IPv6 listener, set the address family of the "local" argument to IPv6 + * (the host and port part may be left unspecified if not desired, i.e. by + * filling them with zeroes). + * + * @param endpt The SIP endpoint. + * @param opt Optional TLS settings. + * @param local Optional local address to bind, or specify the + * address to bind the server socket to. Both IP + * interface address and port fields are optional. + * If IP interface address is not specified, socket + * will be bound to any address. If port is not + * specified, socket will be bound to any port + * selected by the operating system. + * @param a_name Optional published address, which is the address to be + * advertised as the address of this SIP transport. + * If this argument is NULL, then the bound address + * will be used as the published address. + * @param async_cnt Number of simultaneous asynchronous accept() + * operations to be supported. It is recommended that + * the number here corresponds to the number of + * processors in the system (or the number of SIP + * worker threads). + * @param p_factory Optional pointer to receive the instance of the + * SIP TLS transport factory just created. + * + * @return PJ_SUCCESS when the transport has been successfully + * started and registered to transport manager, or + * the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsip_tls_transport_start2(pjsip_endpoint *endpt, + const pjsip_tls_setting *opt, + const pj_sockaddr *local, + const pjsip_host_port *a_name, + unsigned async_cnt, + pjsip_tpfactory **p_factory); PJ_END_DECL diff --git a/pjsip/include/pjsip/sip_types.h b/pjsip/include/pjsip/sip_types.h index 8cd98ae..9809983 100644 --- a/pjsip/include/pjsip/sip_types.h +++ b/pjsip/include/pjsip/sip_types.h @@ -1,4 +1,4 @@ -/* $Id: sip_types.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: sip_types.h 4262 2012-09-20 06:00:23Z bennylp $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> @@ -92,7 +92,10 @@ typedef enum pjsip_transport_type_e PJSIP_TRANSPORT_UDP6 = PJSIP_TRANSPORT_UDP + PJSIP_TRANSPORT_IPV6, /** TCP over IPv6 */ - PJSIP_TRANSPORT_TCP6 = PJSIP_TRANSPORT_TCP + PJSIP_TRANSPORT_IPV6 + PJSIP_TRANSPORT_TCP6 = PJSIP_TRANSPORT_TCP + PJSIP_TRANSPORT_IPV6, + + /** TLS over IPv6 */ + PJSIP_TRANSPORT_TLS6 = PJSIP_TRANSPORT_TLS + PJSIP_TRANSPORT_IPV6 } pjsip_transport_type_e; diff --git a/pjsip/include/pjsip/sip_uri.h b/pjsip/include/pjsip/sip_uri.h index 849392f..47b63bd 100644 --- a/pjsip/include/pjsip/sip_uri.h +++ b/pjsip/include/pjsip/sip_uri.h @@ -1,4 +1,4 @@ -/* $Id: sip_uri.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: sip_uri.h 4370 2013-02-26 05:30:00Z nanang $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> @@ -226,12 +226,12 @@ struct pjsip_uri }; /** - * This macro checks that the URL is a "sip:" or "sips:" URL. + * This macro checks that the URL is a "sip:" URL. * @param url The URL (pointer to) * @return non-zero if TRUE. */ #define PJSIP_URI_SCHEME_IS_SIP(url) \ - (pj_strnicmp2(pjsip_uri_get_scheme(url), "sip", 3)==0) + (pj_stricmp2(pjsip_uri_get_scheme(url), "sip")==0) /** * This macro checks that the URL is a "sips:" URL (not SIP). @@ -239,7 +239,7 @@ struct pjsip_uri * @return non-zero if TRUE. */ #define PJSIP_URI_SCHEME_IS_SIPS(url) \ - (pj_strnicmp2(pjsip_uri_get_scheme(url), "sips", 4)==0) + (pj_stricmp2(pjsip_uri_get_scheme(url), "sips")==0) /** * This macro checks that the URL is a "tel:" URL. @@ -247,7 +247,7 @@ struct pjsip_uri * @return non-zero if TRUE. */ #define PJSIP_URI_SCHEME_IS_TEL(url) \ - (pj_strnicmp2(pjsip_uri_get_scheme(url), "tel", 3)==0) + (pj_stricmp2(pjsip_uri_get_scheme(url), "tel")==0) /** diff --git a/pjsip/include/pjsip/sip_util.h b/pjsip/include/pjsip/sip_util.h index 6efa45f..018ad87 100644 --- a/pjsip/include/pjsip/sip_util.h +++ b/pjsip/include/pjsip/sip_util.h @@ -1,4 +1,4 @@ -/* $Id: sip_util.h 3553 2011-05-05 06:14:19Z nanang $ */ +/* $Id: sip_util.h 4347 2013-02-13 10:19:25Z nanang $ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> @@ -92,6 +92,13 @@ typedef enum pjsip_redirect_op PJSIP_REDIRECT_ACCEPT, /** + * Accept the redirection to the current target and replace the To + * header in the INVITE request with the current target. The INVITE + * request will be resent to the current target. + */ + PJSIP_REDIRECT_ACCEPT_REPLACE, + + /** * Defer the redirection decision, for example to request permission * from the end user. */ |