diff options
Diffstat (limited to 'pjsip')
33 files changed, 611 insertions, 443 deletions
diff --git a/pjsip/include/pjsip-simple/errno.h b/pjsip/include/pjsip-simple/errno.h index 911333c8..ab3d4ec3 100644 --- a/pjsip/include/pjsip-simple/errno.h +++ b/pjsip/include/pjsip-simple/errno.h @@ -19,9 +19,10 @@ #ifndef __PJSIP_SIMPLE_ERRNO_H__ #define __PJSIP_SIMPLE_ERRNO_H__ - #include <pjsip/sip_errno.h> +PJ_BEGIN_DECL + /** * Start of error code relative to PJ_ERRNO_START_USER. */ @@ -87,6 +88,25 @@ */ #define PJSIP_SIMPLE_EBADISCOMPOSE (PJSIP_SIMPLE_ERRNO_START+40) /*270040*/ +/** + * Get error message for the specified error code. Note that this + * function is only able to decode PJSIP-SIMPLE specific error code. + * Application should use pj_strerror(), which should be able to + * decode all error codes belonging to all subsystems (e.g. pjlib, + * pjmedia, pjsip, etc). + * + * @param status The error code. + * @param buffer The buffer where to put the error message. + * @param bufsize Size of the buffer. + * + * @return The error message as NULL terminated string, + * wrapped with pj_str_t. + */ +PJ_DECL(pj_str_t) pjsipsimple_strerror(pj_status_t status, + char *buffer, pj_size_t bufsize); + + +PJ_END_DECL #endif /* __PJSIP_SIMPLE_ERRNO_H__ */ diff --git a/pjsip/include/pjsip-simple/evsub.h b/pjsip/include/pjsip-simple/evsub.h index 3f67590b..1c3ee97c 100644 --- a/pjsip/include/pjsip-simple/evsub.h +++ b/pjsip/include/pjsip-simple/evsub.h @@ -202,15 +202,24 @@ typedef struct pjsip_evsub_user pjsip_evsub_user; /** + * SUBSCRIBE method constant. @see pjsip_get_subscribe_method() + */ +PJ_DECL_DATA(const pjsip_method) pjsip_subscribe_method; + +/** + * NOTIFY method constant. @see pjsip_get_notify_method() + */ +PJ_DECL_DATA(const pjsip_method) pjsip_notify_method; + +/** * SUBSCRIBE method constant. */ -extern const pjsip_method pjsip_subscribe_method; +PJ_DECL(const pjsip_method*) pjsip_get_subscribe_method(); /** * NOTIFY method constant. */ -extern const pjsip_method pjsip_notify_method; - +PJ_DECL(const pjsip_method*) pjsip_get_notify_method(); /** diff --git a/pjsip/include/pjsip-simple/evsub_msg.h b/pjsip/include/pjsip-simple/evsub_msg.h index a27e07aa..f1c3f4b7 100644 --- a/pjsip/include/pjsip-simple/evsub_msg.h +++ b/pjsip/include/pjsip-simple/evsub_msg.h @@ -104,7 +104,7 @@ PJ_DECL(pjsip_sub_state_hdr*) pjsip_sub_state_hdr_create(pj_pool_t *pool); /** * Initialize parser for event notify module. */ -PJ_DEF(void) pjsip_evsub_init_parser(void); +PJ_DECL(void) pjsip_evsub_init_parser(void); PJ_END_DECL diff --git a/pjsip/include/pjsip-ua/sip_xfer.h b/pjsip/include/pjsip-ua/sip_xfer.h index cbc3a7de..2ad9324e 100644 --- a/pjsip/include/pjsip-ua/sip_xfer.h +++ b/pjsip/include/pjsip-ua/sip_xfer.h @@ -61,10 +61,11 @@ PJ_BEGIN_DECL -/** - * Declaration for REFER method constant. - */ -extern const pjsip_method pjsip_refer_method; +/** Declaration for REFER method constant. */ +PJ_DECL_DATA(const pjsip_method) pjsip_refer_method; + +/** Get REFER method constant */ +PJ_DECL(const pjsip_method*) pjsip_get_refer_method(); /** diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h index c591e0db..846c2a57 100644 --- a/pjsip/include/pjsip/sip_config.h +++ b/pjsip/include/pjsip/sip_config.h @@ -467,9 +467,9 @@ #define PJSIP_POOL_INC_USER_AGENT 1024 /* Message/URL related constants. */ -#define PJSIP_MAX_CALL_ID_LEN PJ_GUID_STRING_LENGTH -#define PJSIP_MAX_TAG_LEN PJ_GUID_STRING_LENGTH -#define PJSIP_MAX_BRANCH_LEN (PJSIP_RFC3261_BRANCH_LEN + PJ_GUID_STRING_LENGTH + 2) +#define PJSIP_MAX_CALL_ID_LEN pj_GUID_STRING_LENGTH() +#define PJSIP_MAX_TAG_LEN pj_GUID_STRING_LENGTH() +#define PJSIP_MAX_BRANCH_LEN (PJSIP_RFC3261_BRANCH_LEN + pj_GUID_STRING_LENGTH() + 2) #define PJSIP_MAX_HNAME_LEN 64 /* Dialog related constants. */ diff --git a/pjsip/include/pjsip/sip_dialog.h b/pjsip/include/pjsip/sip_dialog.h index 00768ffd..626ec08b 100644 --- a/pjsip/include/pjsip/sip_dialog.h +++ b/pjsip/include/pjsip/sip_dialog.h @@ -86,6 +86,7 @@ typedef enum pjsip_dialog_state PJSIP_DIALOG_STATE_ESTABLISHED } pjsip_dialog_state; + /** * This structure describes the dialog structure. Application MUST NOT * try to SET the values here directly, but instead it MUST use the @@ -126,6 +127,7 @@ struct pjsip_dialog pjsip_role_e role; /**< Initial role. */ pj_bool_t uac_has_2xx;/**< UAC has received 2xx response? */ pj_bool_t secure; /**< Use secure transport? */ + pj_bool_t add_allow; /**< Add Allow header in requests? */ pjsip_cid_hdr *call_id; /**< Call-ID header. */ pjsip_route_hdr route_set; /**< Route set. */ pjsip_auth_clt_sess auth_sess; /**< Client authentication session. */ diff --git a/pjsip/include/pjsip/sip_errno.h b/pjsip/include/pjsip/sip_errno.h index 11823c9a..0e5ae2f1 100644 --- a/pjsip/include/pjsip/sip_errno.h +++ b/pjsip/include/pjsip/sip_errno.h @@ -487,6 +487,22 @@ PJ_BEGIN_DECL #define PJSIP_TLS_ETIMEDOUT (PJSIP_ERRNO_START_PJSIP+172) /* 171172 */ +/** + * Get error message for the specified error code. Note that this + * function is only able to decode PJSIP specific error code. + * Application should use pj_strerror(), which should be able to + * decode all error codes belonging to all subsystems (e.g. pjlib, + * pjmedia, pjsip, etc). + * + * @param status The error code. + * @param buffer The buffer where to put the error message. + * @param bufsize Size of the buffer. + * + * @return The error message as NULL terminated string, + * wrapped with pj_str_t. + */ +PJ_DECL(pj_str_t) pjsip_strerror(pj_status_t status, + char *buffer, pj_size_t bufsize); PJ_END_DECL @@ -497,3 +513,4 @@ PJ_END_DECL */ #endif /* __PJSIP_SIP_ERRNO_H__ */ + diff --git a/pjsip/include/pjsip/sip_event.h b/pjsip/include/pjsip/sip_event.h index 0df0c044..e4b27ca1 100644 --- a/pjsip/include/pjsip/sip_event.h +++ b/pjsip/include/pjsip/sip_event.h @@ -218,7 +218,7 @@ struct pjsip_event * @param e the event ID. * @note defined in sip_util.c */ -PJ_DEF(const char *) pjsip_event_str(pjsip_event_id_e e); +PJ_DECL(const char *) pjsip_event_str(pjsip_event_id_e e); /** * @} diff --git a/pjsip/include/pjsip/sip_msg.h b/pjsip/include/pjsip/sip_msg.h index 7a303521..906c4a5f 100644 --- a/pjsip/include/pjsip/sip_msg.h +++ b/pjsip/include/pjsip/sip_msg.h @@ -84,13 +84,44 @@ struct pjsip_method /* * For convenience, standard method structures are defined in the library. */ -extern const pjsip_method pjsip_invite_method; /**< INVITE structure. */ -extern const pjsip_method pjsip_cancel_method; /**< CANCEL structure. */ -extern const pjsip_method pjsip_ack_method; /**< ACK structure. */ -extern const pjsip_method pjsip_bye_method; /**< BYE structure. */ -extern const pjsip_method pjsip_register_method; /**< REGISTER structure.*/ -extern const pjsip_method pjsip_options_method; /**< OPTIONS structure. */ +/** INVITE method constant. @see pjsip_get_invite_method() */ +PJ_DECL_DATA(const pjsip_method) pjsip_invite_method; +/** CANCEL method constant. @see pjsip_get_cancel_method() */ +PJ_DECL_DATA(const pjsip_method) pjsip_cancel_method; + +/** ACK method constant. @see pjsip_get_ack_method() */ +PJ_DECL_DATA(const pjsip_method) pjsip_ack_method; + +/** BYE method constant. @see pjsip_get_bye_method() */ +PJ_DECL_DATA(const pjsip_method) pjsip_bye_method; + +/** REGISTER method constant. @see pjsip_get_register_method() */ +PJ_DECL_DATA(const pjsip_method) pjsip_register_method; + +/** OPTIONS method constant. @see pjsip_get_options_method() */ +PJ_DECL_DATA(const pjsip_method) pjsip_options_method; + +/* + * Accessor functions for standard SIP methods. + */ +/** Get INVITE method constant. */ +PJ_DECL(const pjsip_method*) pjsip_get_invite_method(void); +/** Get CANCEL method constant. */ +PJ_DECL(const pjsip_method*) pjsip_get_cancel_method(void); +/** Get ACK method constant. */ +PJ_DECL(const pjsip_method*) pjsip_get_ack_method(void); +/** Get BYE method constant. */ +PJ_DECL(const pjsip_method*) pjsip_get_bye_method(void); +/** Get REGISTER method constant.*/ +PJ_DECL(const pjsip_method*) pjsip_get_register_method(void); +/** Get OPTIONS method constant. */ +PJ_DECL(const pjsip_method*) pjsip_get_options_method(void); + + +/* + * Accessor functions + */ /** * Initialize the method structure from a string. diff --git a/pjsip/include/pjsip/sip_parser.h b/pjsip/include/pjsip/sip_parser.h index ef8277fb..804aed1c 100644 --- a/pjsip/include/pjsip/sip_parser.h +++ b/pjsip/include/pjsip/sip_parser.h @@ -315,51 +315,64 @@ PJ_DECL(pj_status_t) pjsip_parse_headers( pj_pool_t *pool, */ -/* - * Various specification used in parsing, exported here as extern for other - * parsers. +/** + * Parser constants. @see pjsip_parser_const() */ -extern pj_cis_t - pjsip_HOST_SPEC, /**< For scanning host part. */ - pjsip_DIGIT_SPEC, /**< Decimal digits */ - pjsip_ALPHA_SPEC, /**< Alpha (A-Z, a-z) */ - pjsip_ALNUM_SPEC, /**< Decimal + Alpha. */ - pjsip_TOKEN_SPEC, /**< Token. */ - pjsip_TOKEN_SPEC_ESC, /**< Token without '%' character */ - pjsip_HEX_SPEC, /**< Hexadecimal digits. */ - pjsip_PARAM_CHAR_SPEC, /**< For scanning pname (or pvalue when it's - not quoted.) in URI */ - pjsip_PARAM_CHAR_SPEC_ESC, /**< Variant without the escape ('%') char */ - pjsip_HDR_CHAR_SPEC, /**< Chars in hname/havalue in URL. */ - pjsip_HDR_CHAR_SPEC_ESC, /**< Variant without the escape ('%') char */ - pjsip_PROBE_USER_HOST_SPEC, /**< Hostname characters. */ - pjsip_PASSWD_SPEC, /**< Password. */ - pjsip_PASSWD_SPEC_ESC, /**< Variant without the escape ('%') char */ - pjsip_USER_SPEC, /**< User */ - pjsip_USER_SPEC_ESC, /**< Variant without the escape ('%') char */ - pjsip_NOT_NEWLINE, /**< For eating up header, basicly any chars - except newlines or zero. */ - pjsip_NOT_COMMA_OR_NEWLINE, /**< Array elements. */ - pjsip_DISPLAY_SPEC; /**< Used when searching for display name. */ +typedef struct pjsip_parser_const_t +{ + const pj_str_t pjsip_USER_STR; /**< "user" string constant. */ + const pj_str_t pjsip_METHOD_STR; /**< "method" string constant */ + const pj_str_t pjsip_TRANSPORT_STR; /**< "transport" string const. */ + const pj_str_t pjsip_MADDR_STR; /**< "maddr" string const. */ + const pj_str_t pjsip_LR_STR; /**< "lr" string const. */ + const pj_str_t pjsip_SIP_STR; /**< "sip" string constant. */ + const pj_str_t pjsip_SIPS_STR; /**< "sips" string constant. */ + const pj_str_t pjsip_TEL_STR; /**< "tel" string constant. */ + const pj_str_t pjsip_BRANCH_STR; /**< "branch" string constant. */ + const pj_str_t pjsip_TTL_STR; /**< "ttl" string constant. */ + const pj_str_t pjsip_RECEIVED_STR; /**< "received" string const. */ + const pj_str_t pjsip_Q_STR; /**< "q" string constant. */ + const pj_str_t pjsip_EXPIRES_STR; /**< "expires" string constant. */ + const pj_str_t pjsip_TAG_STR; /**< "tag" string constant. */ + const pj_str_t pjsip_RPORT_STR; /**< "rport" string const. */ + + pj_cis_t pjsip_HOST_SPEC; /**< For scanning host part. */ + pj_cis_t pjsip_DIGIT_SPEC; /**< Decimal digits */ + pj_cis_t pjsip_ALPHA_SPEC; /**< Alpha (A-Z, a-z) */ + pj_cis_t pjsip_ALNUM_SPEC; /**< Decimal + Alpha. */ + pj_cis_t pjsip_TOKEN_SPEC; /**< Token. */ + pj_cis_t pjsip_TOKEN_SPEC_ESC; /**< Token without '%' character */ + pj_cis_t pjsip_HEX_SPEC; /**< Hexadecimal digits. */ + pj_cis_t pjsip_PARAM_CHAR_SPEC; /**< For scanning pname (or pvalue + when it's not quoted.) in URI */ + pj_cis_t pjsip_PARAM_CHAR_SPEC_ESC; /**< Variant without the escape ('%') + char */ + pj_cis_t pjsip_HDR_CHAR_SPEC; /**< Chars in hname/havalue in URL. */ + pj_cis_t pjsip_HDR_CHAR_SPEC_ESC; /**< Variant without the escape ('%') + char */ + pj_cis_t pjsip_PROBE_USER_HOST_SPEC;/**< Hostname characters. */ + pj_cis_t pjsip_PASSWD_SPEC; /**< Password. */ + pj_cis_t pjsip_PASSWD_SPEC_ESC; /**< Variant without the escape ('%') + char */ + pj_cis_t pjsip_USER_SPEC; /**< User */ + pj_cis_t pjsip_USER_SPEC_ESC; /**< Variant without the escape ('%') + char */ + pj_cis_t pjsip_USER_SPEC_LENIENT; /**< User, with additional '#' char */ + pj_cis_t pjsip_USER_SPEC_LENIENT_ESC;/**< pjsip_USER_SPEC_ESC with '#' */ + pj_cis_t pjsip_NOT_NEWLINE; /**< For eating up header, basically + any chars except newlines or + zero. */ + pj_cis_t pjsip_NOT_COMMA_OR_NEWLINE;/**< Array elements. */ + pj_cis_t pjsip_DISPLAY_SPEC; /**< Used when searching for display + name. */ + +} pjsip_parser_const_t; -/* - * Various string constants. + +/** + * Get parser constants. */ -extern const pj_str_t pjsip_USER_STR, /**< "user" string constant. */ - pjsip_METHOD_STR, /**< "method" string constant */ - pjsip_TRANSPORT_STR, /**< "transport" string const. */ - pjsip_MADDR_STR, /**< "maddr" string const. */ - pjsip_LR_STR, /**< "lr" string const. */ - pjsip_SIP_STR, /**< "sip" string constant. */ - pjsip_SIPS_STR, /**< "sips" string constant. */ - pjsip_TEL_STR, /**< "tel" string constant. */ - pjsip_BRANCH_STR, /**< "branch" string constant. */ - pjsip_TTL_STR, /**< "ttl" string constant. */ - pjsip_RECEIVED_STR, /**< "received" string const. */ - pjsip_Q_STR, /**< "q" string constant. */ - pjsip_EXPIRES_STR, /**< "expires" string constant. */ - pjsip_TAG_STR, /**< "tag" string constant. */ - pjsip_RPORT_STR; /**< "rport" string const. */ +PJ_DECL(const pjsip_parser_const_t*) pjsip_parser_const(void); /* @@ -371,17 +384,18 @@ enum }; /* Parse parameter in header (matching the character as token) */ -void pjsip_parse_param_imp( pj_scanner *scanner, pj_pool_t *pool, - pj_str_t *pname, pj_str_t *pvalue, - unsigned opt); +PJ_DECL(void) pjsip_parse_param_imp(pj_scanner *scanner, pj_pool_t *pool, + pj_str_t *pname, pj_str_t *pvalue, + unsigned opt); /* Parse parameter in URL (matching the character as paramchar) */ -void pjsip_parse_uri_param_imp( pj_scanner *scanner, pj_pool_t *pool, - pj_str_t *pname, pj_str_t *pvalue, - unsigned opt); -void pjsip_concat_param_imp( pj_str_t *param, pj_pool_t *pool, - const pj_str_t *pname, const pj_str_t *pvalue, - int sepchar); -void pjsip_parse_end_hdr_imp ( pj_scanner *scanner ); +PJ_DECL(void) pjsip_parse_uri_param_imp(pj_scanner *scanner, pj_pool_t *pool, + pj_str_t *pname, pj_str_t *pvalue, + unsigned opt); +PJ_DECL(void) pjsip_concat_param_imp(pj_str_t *param, pj_pool_t *pool, + const pj_str_t *pname, + const pj_str_t *pvalue, + int sepchar); +PJ_DECL(void) pjsip_parse_end_hdr_imp ( pj_scanner *scanner ); PJ_END_DECL diff --git a/pjsip/include/pjsip/sip_ua_layer.h b/pjsip/include/pjsip/sip_ua_layer.h index e08d7396..67d3e644 100644 --- a/pjsip/include/pjsip/sip_ua_layer.h +++ b/pjsip/include/pjsip/sip_ua_layer.h @@ -114,7 +114,7 @@ PJ_DECL(pj_status_t) pjsip_ua_destroy(void); * * @param detail If non-zero, list of dialogs will be printed. */ -PJ_DEF(void) pjsip_ua_dump(pj_bool_t detail); +PJ_DECL(void) pjsip_ua_dump(pj_bool_t detail); /** * Get the endpoint instance of a user agent module. diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 78f8b1bd..73793247 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -474,16 +474,8 @@ typedef struct pjsua_logging_config logging_cfg = py_pjsua.logging_config_default() * \endcode */ -PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg) -{ - pj_bzero(cfg, sizeof(*cfg)); +PJ_DECL(void) pjsua_logging_config_default(pjsua_logging_config *cfg); - cfg->msg_logging = PJ_TRUE; - cfg->level = 5; - cfg->console_level = 4; - cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME | - PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE; -} /** * Use this function to duplicate logging config. @@ -496,14 +488,9 @@ PJ_INLINE(void) pjsua_logging_config_default(pjsua_logging_config *cfg) * Not available (for now). Ideally we should be able to just assign * one config to another, but this has not been tested. */ -PJ_INLINE(void) pjsua_logging_config_dup(pj_pool_t *pool, - pjsua_logging_config *dst, - const pjsua_logging_config *src) -{ - pj_memcpy(dst, src, sizeof(*src)); - pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename); -} - +PJ_DECL(void) pjsua_logging_config_dup(pj_pool_t *pool, + pjsua_logging_config *dst, + const pjsua_logging_config *src); /** @@ -1015,13 +1002,7 @@ typedef struct pjsua_config * \endcode */ -PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg) -{ - pj_bzero(cfg, sizeof(*cfg)); - - cfg->max_calls = 4; - cfg->thread_cnt = 1; -} +PJ_DECL(void) pjsua_config_default(pjsua_config *cfg); /** @@ -1035,16 +1016,9 @@ PJ_INLINE(void) pjsua_config_default(pjsua_config *cfg) * Not applicable (for now). Probably we could just assign one credential * variable to another, but this has not been tested. */ -PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool, - pjsip_cred_info *dst, - const pjsip_cred_info *src) -{ - pj_strdup_with_null(pool, &dst->realm, &src->realm); - pj_strdup_with_null(pool, &dst->scheme, &src->scheme); - pj_strdup_with_null(pool, &dst->username, &src->username); - pj_strdup_with_null(pool, &dst->data, &src->data); - -} +PJ_DECL(void) pjsip_cred_dup( pj_pool_t *pool, + pjsip_cred_info *dst, + const pjsip_cred_info *src); /** @@ -1054,29 +1028,9 @@ PJ_INLINE(void) pjsip_cred_dup( pj_pool_t *pool, * @param dst Destination config. * @param src Source config. */ -PJ_INLINE(void) pjsua_config_dup(pj_pool_t *pool, - pjsua_config *dst, - const pjsua_config *src) -{ - unsigned i; - - pj_memcpy(dst, src, sizeof(*src)); - - for (i=0; i<src->outbound_proxy_cnt; ++i) { - pj_strdup_with_null(pool, &dst->outbound_proxy[i], - &src->outbound_proxy[i]); - } - - for (i=0; i<src->cred_count; ++i) { - pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]); - } - - pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent); - pj_strdup_with_null(pool, &dst->stun_domain, &src->stun_domain); - pj_strdup_with_null(pool, &dst->stun_host, &src->stun_host); - pj_strdup_with_null(pool, &dst->stun_relay_host, &src->stun_relay_host); -} - +PJ_DECL(void) pjsua_config_dup(pj_pool_t *pool, + pjsua_config *dst, + const pjsua_config *src); /** @@ -1137,12 +1091,7 @@ typedef struct pjsua_msg_data msg_data = py_pjsua.msg_data_init() * \endcode */ -PJ_INLINE(void) pjsua_msg_data_init(pjsua_msg_data *msg_data) -{ - pj_bzero(msg_data, sizeof(*msg_data)); - pj_list_init(&msg_data->hdr_list); -} - +PJ_DECL(void) pjsua_msg_data_init(pjsua_msg_data *msg_data); /** @@ -1485,11 +1434,7 @@ typedef struct pjsua_transport_config transport_cfg = py_pjsua.transport_config_default() * \endcode */ -PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg) -{ - pj_bzero(cfg, sizeof(*cfg)); - pjsip_tls_setting_default(&cfg->tls_setting); -} +PJ_DECL(void) pjsua_transport_config_default(pjsua_transport_config *cfg); /** @@ -1503,14 +1448,9 @@ PJ_INLINE(void) pjsua_transport_config_default(pjsua_transport_config *cfg) * Not applicable. One should be able to just copy one variable instance * to another in Python. */ -PJ_INLINE(void) pjsua_transport_config_dup(pj_pool_t *pool, - pjsua_transport_config *dst, - const pjsua_transport_config *src) -{ - PJ_UNUSED_ARG(pool); - pj_memcpy(dst, src, sizeof(*src)); -} - +PJ_DECL(void) pjsua_transport_config_dup(pj_pool_t *pool, + pjsua_transport_config *dst, + const pjsua_transport_config *src); /** @@ -1916,14 +1856,7 @@ typedef struct pjsua_acc_config acc_cfg = py_pjsua.acc_config_default() * \endcode */ -PJ_INLINE(void) pjsua_acc_config_default(pjsua_acc_config *cfg) -{ - pj_bzero(cfg, sizeof(*cfg)); - - cfg->reg_timeout = PJSUA_REG_INTERVAL; - cfg->transport_id = PJSUA_INVALID_ID; -} - +PJ_DECL(void) pjsua_acc_config_default(pjsua_acc_config *cfg); /** @@ -3064,10 +2997,7 @@ typedef struct pjsua_buddy_info buddy_cfg = py_pjsua.buddy_config_default() * \endcode */ -PJ_INLINE(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg) -{ - pj_bzero(cfg, sizeof(*cfg)); -} +PJ_DECL(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg); /** @@ -3555,20 +3485,7 @@ struct pjsua_media_config media_cfg = py_pjsua.media_config_default() * \endcode */ -PJ_INLINE(void) pjsua_media_config_default(pjsua_media_config *cfg) -{ - pj_bzero(cfg, sizeof(*cfg)); - - cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE; - cfg->max_media_ports = 32; - cfg->has_ioqueue = PJ_TRUE; - cfg->thread_cnt = 1; - cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY; - cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE; - cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN; - cfg->jb_init = cfg->jb_min_pre = cfg->jb_max_pre = cfg->jb_max = -1; -} - +PJ_DECL(void) pjsua_media_config_default(pjsua_media_config *cfg); /** diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c index 61a268d7..b3ef031f 100644 --- a/pjsip/src/pjsip-simple/evsub.c +++ b/pjsip/src/pjsip-simple/evsub.c @@ -49,18 +49,35 @@ enum PJSIP_NOTIFY_METHOD = PJSIP_OTHER_METHOD }; -const pjsip_method pjsip_subscribe_method = +PJ_DEF_DATA(const pjsip_method) pjsip_subscribe_method = { (pjsip_method_e) PJSIP_SUBSCRIBE_METHOD, { "SUBSCRIBE", 9 } }; -const pjsip_method pjsip_notify_method = +PJ_DEF_DATA(const pjsip_method) pjsip_notify_method = { (pjsip_method_e) PJSIP_NOTIFY_METHOD, { "NOTIFY", 6 } }; +/** + * SUBSCRIBE method constant. + */ +PJ_DEF(const pjsip_method*) pjsip_get_subscribe_method() +{ + return &pjsip_subscribe_method; +} + +/** + * NOTIFY method constant. + */ +PJ_DEF(const pjsip_method*) pjsip_get_notify_method() +{ + return &pjsip_notify_method; +} + + /* * Static prototypes. */ @@ -1112,8 +1129,8 @@ PJ_DEF(pj_status_t) pjsip_evsub_notify( pjsip_evsub *sub, pjsip_dlg_inc_lock(sub->dlg); /* Create NOTIFY request */ - status = pjsip_dlg_create_request( sub->dlg, &pjsip_notify_method, -1, - &tdata); + status = pjsip_dlg_create_request( sub->dlg, pjsip_get_notify_method(), + -1, &tdata); if (status != PJ_SUCCESS) goto on_return; diff --git a/pjsip/src/pjsip-simple/evsub_msg.c b/pjsip/src/pjsip-simple/evsub_msg.c index 467345d9..19058b15 100644 --- a/pjsip/src/pjsip-simple/evsub_msg.c +++ b/pjsip/src/pjsip-simple/evsub_msg.c @@ -61,6 +61,7 @@ static int pjsip_event_hdr_print( pjsip_event_hdr *hdr, char *p = buf; char *endbuf = buf+size; int printed; + const pjsip_parser_const_t *pc = pjsip_parser_const(); copy_advance(p, hdr->name); *p++ = ':'; @@ -70,8 +71,8 @@ static int pjsip_event_hdr_print( pjsip_event_hdr *hdr, copy_advance_pair(p, ";id=", 4, hdr->id_param); printed = pjsip_param_print_on(&hdr->other_param, p, endbuf-p, - &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC, ';'); + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ';'); if (printed < 0) return printed; @@ -159,6 +160,7 @@ static int pjsip_sub_state_hdr_print(pjsip_sub_state_hdr *hdr, char *p = buf; char *endbuf = buf+size; int printed; + const pjsip_parser_const_t *pc = pjsip_parser_const(); copy_advance(p, hdr->name); *p++ = ':'; @@ -180,8 +182,8 @@ static int pjsip_sub_state_hdr_print(pjsip_sub_state_hdr *hdr, } printed = pjsip_param_print_on( &hdr->other_param, p, endbuf-p, - &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ';'); if (printed < 0) return printed; @@ -222,8 +224,9 @@ static pjsip_hdr *parse_hdr_event(pjsip_parse_ctx *ctx) { pjsip_event_hdr *hdr = pjsip_event_hdr_create(ctx->pool); const pj_str_t id_param = { "id", 2 }; + const pjsip_parser_const_t *pc = pjsip_parser_const(); - pj_scan_get(ctx->scanner, &pjsip_TOKEN_SPEC, &hdr->event_type); + pj_scan_get(ctx->scanner, &pc->pjsip_TOKEN_SPEC, &hdr->event_type); while (*ctx->scanner->curptr == ';') { pj_str_t pname, pvalue; @@ -253,7 +256,9 @@ static pjsip_hdr* parse_hdr_sub_state( pjsip_parse_ctx *ctx ) const pj_str_t reason = { "reason", 6 }, expires = { "expires", 7 }, retry_after = { "retry-after", 11 }; - pj_scan_get(ctx->scanner, &pjsip_TOKEN_SPEC, &hdr->sub_state); + const pjsip_parser_const_t *pc = pjsip_parser_const(); + + pj_scan_get(ctx->scanner, &pc->pjsip_TOKEN_SPEC, &hdr->sub_state); while (*ctx->scanner->curptr == ';') { pj_str_t pname, pvalue; diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c index 1ff497b0..9f561763 100644 --- a/pjsip/src/pjsip-ua/sip_inv.c +++ b/pjsip/src/pjsip-ua/sip_inv.c @@ -113,9 +113,6 @@ struct tsx_inv_data pj_bool_t sdp_done; }; -/* Config */ -extern pj_bool_t pjsip_include_allow_hdr_in_dlg; - /* * Module load() */ @@ -223,7 +220,7 @@ static pj_status_t inv_send_ack(pjsip_inv_session *inv, pjsip_rx_data *rdata) PJ_LOG(5,(inv->obj_name, "Received %s, sending ACK", pjsip_rx_data_get_info(rdata))); - status = pjsip_dlg_create_request(inv->dlg, &pjsip_ack_method, + status = pjsip_dlg_create_request(inv->dlg, pjsip_get_ack_method(), rdata->msg_info.cseq->cseq, &tdata); if (status != PJ_SUCCESS) { /* Better luck next time */ @@ -1108,7 +1105,7 @@ PJ_DEF(pj_status_t) pjsip_inv_invite( pjsip_inv_session *inv, pjsip_dlg_inc_lock(inv->dlg); /* Create the INVITE request. */ - status = pjsip_dlg_create_request(inv->dlg, &pjsip_invite_method, -1, + status = pjsip_dlg_create_request(inv->dlg, pjsip_get_invite_method(), -1, &tdata); if (status != PJ_SUCCESS) goto on_return; @@ -1155,7 +1152,7 @@ PJ_DEF(pj_status_t) pjsip_inv_invite( pjsip_inv_session *inv, } /* Add Allow header. */ - if (pjsip_include_allow_hdr_in_dlg) { + if (inv->dlg->add_allow) { hdr = pjsip_endpt_get_capability(inv->dlg->endpt, PJSIP_H_ALLOW, NULL); if (hdr) { pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*) @@ -1597,8 +1594,8 @@ PJ_DEF(pj_status_t) pjsip_inv_end_session( pjsip_inv_session *inv, case PJSIP_INV_STATE_CONNECTING: case PJSIP_INV_STATE_CONFIRMED: /* For established dialog, send BYE */ - status = pjsip_dlg_create_request(inv->dlg, &pjsip_bye_method, -1, - &tdata); + status = pjsip_dlg_create_request(inv->dlg, pjsip_get_bye_method(), + -1, &tdata); break; case PJSIP_INV_STATE_DISCONNECTED: @@ -1792,7 +1789,7 @@ static void inv_respond_incoming_cancel(pjsip_inv_session *inv, /* See if we have matching INVITE server transaction: */ pjsip_tsx_create_key(rdata->tp_info.pool, &key, PJSIP_ROLE_UAS, - &pjsip_invite_method, rdata); + pjsip_get_invite_method(), rdata); invite_tsx = pjsip_tsx_layer_find_tsx(&key, PJ_TRUE); if (invite_tsx == NULL) { diff --git a/pjsip/src/pjsip-ua/sip_reg.c b/pjsip/src/pjsip-ua/sip_reg.c index 6a5c3c2f..c04fe07e 100644 --- a/pjsip/src/pjsip-ua/sip_reg.c +++ b/pjsip/src/pjsip-ua/sip_reg.c @@ -366,7 +366,7 @@ static pj_status_t create_request(pjsip_regc *regc, /* Create the request. */ status = pjsip_endpt_create_request_from_hdr( regc->endpt, - &pjsip_register_method, + pjsip_get_register_method(), regc->srv_url, regc->from_hdr, regc->to_hdr, diff --git a/pjsip/src/pjsip-ua/sip_replaces.c b/pjsip/src/pjsip-ua/sip_replaces.c index 284c2828..9b233942 100644 --- a/pjsip/src/pjsip-ua/sip_replaces.c +++ b/pjsip/src/pjsip-ua/sip_replaces.c @@ -68,6 +68,7 @@ static int replaces_hdr_print( pjsip_replaces_hdr *hdr, char *p = buf; char *endbuf = buf+size; int printed; + const pjsip_parser_const_t *pc = pjsip_parser_const(); copy_advance(p, hdr->name); *p++ = ':'; @@ -83,8 +84,8 @@ static int replaces_hdr_print( pjsip_replaces_hdr *hdr, } printed = pjsip_param_print_on(&hdr->other_param, p, endbuf-p, - &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC, ';'); + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ';'); if (printed < 0) return printed; diff --git a/pjsip/src/pjsip-ua/sip_xfer.c b/pjsip/src/pjsip-ua/sip_xfer.c index a4c46629..b9c41e88 100644 --- a/pjsip/src/pjsip-ua/sip_xfer.c +++ b/pjsip/src/pjsip-ua/sip_xfer.c @@ -57,11 +57,15 @@ enum PJSIP_REFER_METHOD = PJSIP_OTHER_METHOD }; -const pjsip_method pjsip_refer_method = { +PJ_DEF_DATA(const pjsip_method) pjsip_refer_method = { (pjsip_method_e) PJSIP_REFER_METHOD, { "REFER", 5} }; +PJ_DEF(const pjsip_method*) pjsip_get_refer_method() +{ + return &pjsip_refer_method; +} /* * String constants @@ -144,7 +148,8 @@ PJ_DEF(pj_status_t) pjsip_xfer_init_module(pjsip_endpoint *endpt) return status; status = pjsip_endpt_add_capability( endpt, &mod_xfer, PJSIP_H_ALLOW, - NULL, 1, &pjsip_refer_method.name); + NULL, 1, + &pjsip_get_refer_method()->name); if (status != PJ_SUCCESS) return status; @@ -223,7 +228,7 @@ PJ_DEF(pj_status_t) pjsip_xfer_create_uas( pjsip_dialog *dlg, /* Check that request is REFER */ PJ_ASSERT_RETURN(pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, - &pjsip_refer_method)==0, + pjsip_get_refer_method())==0, PJSIP_ENOTREFER); /* Lock dialog */ @@ -298,7 +303,7 @@ PJ_DEF(pj_status_t) pjsip_xfer_initiate( pjsip_evsub *sub, pjsip_dlg_inc_lock(xfer->dlg); /* Create basic REFER request */ - status = pjsip_evsub_initiate(sub, &pjsip_refer_method, -1, + status = pjsip_evsub_initiate(sub, pjsip_get_refer_method(), -1, &tdata); if (status != PJ_SUCCESS) goto on_return; diff --git a/pjsip/src/pjsip/sip_auth_msg.c b/pjsip/src/pjsip/sip_auth_msg.c index 7b6cbc20..5cb78527 100644 --- a/pjsip/src/pjsip/sip_auth_msg.c +++ b/pjsip/src/pjsip/sip_auth_msg.c @@ -67,6 +67,7 @@ static int print_digest_credential(pjsip_digest_credential *cred, char *buf, pj_ int printed; char *startbuf = buf; char *endbuf = buf + size; + const pjsip_parser_const_t *pc = pjsip_parser_const(); copy_advance_pair_quote_cond(buf, "username=", 9, cred->username, '"', '"'); copy_advance_pair_quote_cond(buf, ", realm=", 8, cred->realm, '"', '"'); @@ -83,8 +84,8 @@ static int print_digest_credential(pjsip_digest_credential *cred, char *buf, pj_ copy_advance_pair(buf, ", nc=", 5, cred->nc); printed = pjsip_param_print_on(&cred->other_param, buf, endbuf-buf, - &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC, ','); + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ','); if (printed < 0) return -1; buf += printed; @@ -228,6 +229,7 @@ static int print_digest_challenge( pjsip_digest_challenge *chal, int printed; char *startbuf = buf; char *endbuf = buf + size; + const pjsip_parser_const_t *pc = pjsip_parser_const(); copy_advance_pair_quote_cond(buf, " realm=", 7, chal->realm, '"', '"'); copy_advance_pair_quote_cond(buf, ",domain=", 8, chal->domain, '"', '"'); @@ -241,8 +243,8 @@ static int print_digest_challenge( pjsip_digest_challenge *chal, copy_advance_pair_quote_cond(buf, ",qop=", 5, chal->qop, '"', '"'); printed = pjsip_param_print_on(&chal->other_param, buf, endbuf-buf, - &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC, ','); + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ','); if (printed < 0) return -1; buf += printed; diff --git a/pjsip/src/pjsip/sip_auth_parser.c b/pjsip/src/pjsip/sip_auth_parser.c index fca1a41a..a9ffea6a 100644 --- a/pjsip/src/pjsip/sip_auth_parser.c +++ b/pjsip/src/pjsip/sip_auth_parser.c @@ -195,12 +195,14 @@ static void parse_pgp_challenge( pj_scanner *scanner, pj_pool_t *pool, static void int_parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool, pjsip_authorization_hdr *hdr) { + const pjsip_parser_const_t *pc = pjsip_parser_const(); + if (*scanner->curptr == '"') { pj_scan_get_quote(scanner, '"', '"', &hdr->scheme); hdr->scheme.ptr++; hdr->scheme.slen -= 2; } else { - pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &hdr->scheme); + pj_scan_get(scanner, &pc->pjsip_TOKEN_SPEC, &hdr->scheme); } if (!pj_stricmp(&hdr->scheme, &pjsip_DIGEST_STR)) { @@ -221,12 +223,14 @@ static void int_parse_hdr_authorization( pj_scanner *scanner, pj_pool_t *pool, static void int_parse_hdr_authenticate( pj_scanner *scanner, pj_pool_t *pool, pjsip_www_authenticate_hdr *hdr) { + const pjsip_parser_const_t *pc = pjsip_parser_const(); + if (*scanner->curptr == '"') { pj_scan_get_quote(scanner, '"', '"', &hdr->scheme); hdr->scheme.ptr++; hdr->scheme.slen -= 2; } else { - pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &hdr->scheme); + pj_scan_get(scanner, &pc->pjsip_TOKEN_SPEC, &hdr->scheme); } if (!pj_stricmp(&hdr->scheme, &pjsip_DIGEST_STR)) { diff --git a/pjsip/src/pjsip/sip_dialog.c b/pjsip/src/pjsip/sip_dialog.c index 326696a2..1295508b 100644 --- a/pjsip/src/pjsip/sip_dialog.c +++ b/pjsip/src/pjsip/sip_dialog.c @@ -81,6 +81,7 @@ static pj_status_t create_dialog( pjsip_user_agent *ua, dlg->ua = ua; dlg->endpt = endpt; dlg->state = PJSIP_DIALOG_STATE_NULL; + dlg->add_allow = pjsip_include_allow_hdr_in_dlg; pj_list_init(&dlg->inv_hdr); @@ -1200,7 +1201,7 @@ static void dlg_beautify_response(pjsip_dialog *dlg, } /* Add Allow header in 2xx and 405 response. */ - if (((st_class==2 && pjsip_include_allow_hdr_in_dlg) + if (((st_class==2 && dlg->add_allow) || st_code==405) && pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ALLOW, NULL)==NULL) { diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c index 859c47d1..ef279a89 100644 --- a/pjsip/src/pjsip/sip_endpoint.c +++ b/pjsip/src/pjsip/sip_endpoint.c @@ -34,7 +34,7 @@ #include <pj/errno.h> #include <pj/lock.h> -#define PJSIP_EX_NO_MEMORY PJ_NO_MEMORY_EXCEPTION +#define PJSIP_EX_NO_MEMORY pj_NO_MEMORY_EXCEPTION() #define THIS_FILE "sip_endpoint.c" #define MAX_METHODS 32 @@ -117,24 +117,6 @@ pj_status_t pjsip_tel_uri_subsys_init(void); /* Specifies whether error subsystem has been registered to pjlib. */ static int error_subsys_initialized; -/** - * Defined in sip_errno.c - * - * Get error message for the specified error code. This can only get - * PJSIP specific error message. To get all types of error message, - * use pj_strerror() instead. - * - * @param status The error code. - * @param buffer The buffer where to put the error message. - * @param bufsize Size of the buffer. - * - * @return The error message as NULL terminated string, - * wrapped with pj_str_t. - */ -PJ_DECL(pj_str_t) pjsip_strerror( pj_status_t status, char *buffer, - pj_size_t bufsize); - - /* * This is the global handler for memory allocation failure, for pools that * are created by the endpoint (by default, all pools ARE allocated by diff --git a/pjsip/src/pjsip/sip_msg.c b/pjsip/src/pjsip/sip_msg.c index eb5348f9..869cb59d 100644 --- a/pjsip/src/pjsip/sip_msg.c +++ b/pjsip/src/pjsip/sip_msg.c @@ -24,13 +24,61 @@ #include <pj/pool.h> #include <pj/assert.h> -const pjsip_method - pjsip_invite_method = { PJSIP_INVITE_METHOD, { "INVITE",6 } }, - pjsip_cancel_method = { PJSIP_CANCEL_METHOD, { "CANCEL",6 } }, - pjsip_ack_method = { PJSIP_ACK_METHOD, { "ACK",3} }, - pjsip_bye_method = { PJSIP_BYE_METHOD, { "BYE",3} }, - pjsip_register_method = { PJSIP_REGISTER_METHOD, { "REGISTER",8} }, - pjsip_options_method = { PJSIP_OPTIONS_METHOD, { "OPTIONS",7} }; +PJ_DEF_DATA(const pjsip_method) pjsip_invite_method = + { PJSIP_INVITE_METHOD, { "INVITE",6 }}; + +PJ_DEF_DATA(const pjsip_method) pjsip_cancel_method = + { PJSIP_CANCEL_METHOD, { "CANCEL",6 }}; + +PJ_DEF_DATA(const pjsip_method) pjsip_ack_method = + { PJSIP_ACK_METHOD, { "ACK",3}}; + +PJ_DEF_DATA(const pjsip_method) pjsip_bye_method = + { PJSIP_BYE_METHOD, { "BYE",3}}; + +PJ_DEF_DATA(const pjsip_method) pjsip_register_method = + { PJSIP_REGISTER_METHOD, { "REGISTER", 8}}; + +PJ_DEF_DATA(const pjsip_method) pjsip_options_method = + { PJSIP_OPTIONS_METHOD, { "OPTIONS",7}}; + + +/** INVITE method constant. */ +PJ_DEF(const pjsip_method*) pjsip_get_invite_method(void) +{ + return &pjsip_invite_method; +} + +/** CANCEL method constant. */ +PJ_DEF(const pjsip_method*) pjsip_get_cancel_method(void) +{ + return &pjsip_cancel_method; +} + +/** ACK method constant. */ +PJ_DEF(const pjsip_method*) pjsip_get_ack_method(void) +{ + return &pjsip_ack_method; +} + +/** BYE method constant. */ +PJ_DEF(const pjsip_method*) pjsip_get_bye_method(void) +{ + return &pjsip_bye_method; +} + +/** REGISTER method constant.*/ +PJ_DEF(const pjsip_method*) pjsip_get_register_method(void) +{ + return &pjsip_register_method; +} + +/** OPTIONS method constant. */ +PJ_DEF(const pjsip_method*) pjsip_get_options_method(void) +{ + return &pjsip_options_method; +} + static const pj_str_t *method_names[] = { @@ -565,11 +613,10 @@ PJ_DEF(void) pjsip_generic_string_hdr_init2(pjsip_generic_string_hdr *hdr, } -PJ_DEF(pjsip_generic_string_hdr*) -pjsip_generic_string_hdr_init( pj_pool_t *pool, - void *mem, - const pj_str_t *hnames, - const pj_str_t *hvalue) +PJ_DEF(pjsip_generic_string_hdr*) pjsip_generic_string_hdr_init(pj_pool_t *pool, + void *mem, + const pj_str_t *hnames, + const pj_str_t *hvalue) { pjsip_generic_string_hdr *hdr = (pjsip_generic_string_hdr*) mem; pj_str_t dup_hname, dup_hval; @@ -590,8 +637,7 @@ pjsip_generic_string_hdr_init( pj_pool_t *pool, return hdr; } -PJ_DEF(pjsip_generic_string_hdr*) -pjsip_generic_string_hdr_create( pj_pool_t *pool, +PJ_DEF(pjsip_generic_string_hdr*) pjsip_generic_string_hdr_create(pj_pool_t *pool, const pj_str_t *hnames, const pj_str_t *hvalue) { @@ -1055,6 +1101,7 @@ static int pjsip_contact_hdr_print( pjsip_contact_hdr *hdr, char *buf, pj_size_t size) { const pj_str_t *hname = pjsip_use_compact_form? &hdr->sname : &hdr->name; + const pjsip_parser_const_t *pc = pjsip_parser_const(); if (hdr->star) { char *p = buf; @@ -1109,7 +1156,8 @@ static int pjsip_contact_hdr_print( pjsip_contact_hdr *hdr, char *buf, } printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf, - &pjsip_TOKEN_SPEC, &pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ';'); if (printed < 0) return printed; @@ -1346,6 +1394,7 @@ static int pjsip_fromto_hdr_print( pjsip_fromto_hdr *hdr, char *startbuf = buf; char *endbuf = buf + size; const pj_str_t *hname = pjsip_use_compact_form? &hdr->sname : &hdr->name; + const pjsip_parser_const_t *pc = pjsip_parser_const(); copy_advance(buf, (*hname)); *buf++ = ':'; @@ -1361,8 +1410,8 @@ static int pjsip_fromto_hdr_print( pjsip_fromto_hdr *hdr, copy_advance_pair(buf, ";tag=", 5, hdr->tag); printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf, - &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC, ';'); + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ';'); if (printed < 0) return -1; buf += printed; @@ -1524,6 +1573,7 @@ static int pjsip_routing_hdr_print( pjsip_routing_hdr *hdr, int printed; char *startbuf = buf; char *endbuf = buf + size; + const pjsip_parser_const_t *pc = pjsip_parser_const(); /* Route and Record-Route don't compact forms */ copy_advance(buf, hdr->name); @@ -1537,8 +1587,8 @@ static int pjsip_routing_hdr_print( pjsip_routing_hdr *hdr, buf += printed; printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf, - &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC, ';'); + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ';'); if (printed < 0) return -1; buf += printed; @@ -1704,6 +1754,7 @@ static int pjsip_via_hdr_print( pjsip_via_hdr *hdr, char *endbuf = buf + size; pj_str_t sip_ver = { "SIP/2.0/", 8 }; const pj_str_t *hname = pjsip_use_compact_form? &hdr->sname : &hdr->name; + const pjsip_parser_const_t *pc = pjsip_parser_const(); if ((pj_ssize_t)size < hname->slen + sip_ver.slen + hdr->transport.slen + hdr->sent_by.host.slen + 12) @@ -1757,8 +1808,8 @@ static int pjsip_via_hdr_print( pjsip_via_hdr *hdr, copy_advance_pair(buf, ";branch=", 8, hdr->branch_param); printed = pjsip_param_print_on(&hdr->other_param, buf, endbuf-buf, - &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC, ';'); + &pc->pjsip_TOKEN_SPEC, + &pc->pjsip_TOKEN_SPEC, ';'); if (printed < 0) return -1; buf += printed; @@ -1813,10 +1864,9 @@ PJ_DEF(pjsip_warning_hdr*) pjsip_warning_hdr_create( pj_pool_t *pool, return pjsip_generic_string_hdr_create(pool, &str_warning, &hvalue); } -PJ_DEF(pjsip_warning_hdr*) -pjsip_warning_hdr_create_from_status( pj_pool_t *pool, - const pj_str_t *host, - pj_status_t status) +PJ_DEF(pjsip_warning_hdr*) pjsip_warning_hdr_create_from_status(pj_pool_t *pool, + const pj_str_t *host, + pj_status_t status) { char errbuf[PJ_ERR_MSG_SIZE]; pj_str_t text; diff --git a/pjsip/src/pjsip/sip_parser.c b/pjsip/src/pjsip/sip_parser.c index 6c322428..9a0edcfa 100644 --- a/pjsip/src/pjsip/sip_parser.c +++ b/pjsip/src/pjsip/sip_parser.c @@ -87,50 +87,29 @@ static unsigned uri_handler_count; */ int PJSIP_SYN_ERR_EXCEPTION; -const pj_str_t pjsip_USER_STR = { "user", 4}; -const pj_str_t pjsip_METHOD_STR = { "method", 6}; -const pj_str_t pjsip_TRANSPORT_STR = { "transport", 9}; -const pj_str_t pjsip_MADDR_STR = { "maddr", 5 }; -const pj_str_t pjsip_LR_STR = { "lr", 2 }; -const pj_str_t pjsip_SIP_STR = { "sip", 3 }; -const pj_str_t pjsip_SIPS_STR = { "sips", 4 }; -const pj_str_t pjsip_TEL_STR = { "tel", 3 }; -const pj_str_t pjsip_BRANCH_STR = { "branch", 6 }; -const pj_str_t pjsip_TTL_STR = { "ttl", 3 }; -const pj_str_t pjsip_RECEIVED_STR = { "received", 8 }; -const pj_str_t pjsip_Q_STR = { "q", 1 }; -const pj_str_t pjsip_EXPIRES_STR = { "expires", 7 }; -const pj_str_t pjsip_TAG_STR = { "tag", 3 }; -const pj_str_t pjsip_RPORT_STR = { "rport", 5}; +/* Parser constants */ +static pjsip_parser_const_t pconst = +{ + { "user", 4}, /* pjsip_USER_STR */ + { "method", 6}, /* pjsip_METHOD_STR */ + { "transport", 9}, /* pjsip_TRANSPORT_STR */ + { "maddr", 5 }, /* pjsip_MADDR_STR */ + { "lr", 2 }, /* pjsip_LR_STR */ + { "sip", 3 }, /* pjsip_SIP_STR */ + { "sips", 4 }, /* pjsip_SIPS_STR */ + { "tel", 3 }, /* pjsip_TEL_STR */ + { "branch", 6 }, /* pjsip_BRANCH_STR */ + { "ttl", 3 }, /* pjsip_TTL_STR */ + { "received", 8 }, /* pjsip_RECEIVED_STR */ + { "q", 1 }, /* pjsip_Q_STR */ + { "expires", 7 }, /* pjsip_EXPIRES_STR */ + { "tag", 3 }, /* pjsip_TAG_STR */ + { "rport", 5} /* pjsip_RPORT_STR */ +}; /* Character Input Specification buffer. */ static pj_cis_buf_t cis_buf; -/* Character Input Specifications. */ -pj_cis_t pjsip_HOST_SPEC, /* For scanning host part. */ - pjsip_DIGIT_SPEC, /* Decimal digits */ - pjsip_ALPHA_SPEC, /* Alpha (A-Z, a-z) */ - pjsip_ALNUM_SPEC, /* Decimal + Alpha. */ - pjsip_TOKEN_SPEC, /* Token. */ - pjsip_TOKEN_SPEC_ESC, /* Token without '%' character */ - pjsip_HEX_SPEC, /* Hexadecimal digits. */ - pjsip_PARAM_CHAR_SPEC, /* For scanning pname (or pvalue when - * it's not quoted.) */ - pjsip_PARAM_CHAR_SPEC_ESC, /* The variant without escaped char */ - pjsip_HDR_CHAR_SPEC, /* Chars in hname or hvalue */ - pjsip_HDR_CHAR_SPEC_ESC, /* Variant without escaped char */ - pjsip_PROBE_USER_HOST_SPEC, /* Hostname characters. */ - pjsip_PASSWD_SPEC, /* Password. */ - pjsip_PASSWD_SPEC_ESC, /* Variant without escaped char */ - pjsip_USER_SPEC, /* User */ - pjsip_USER_SPEC_ESC, /* Variant without escaped char */ - pjsip_USER_SPEC_LENIENT, /* User, with additional '#' char */ - pjsip_USER_SPEC_LENIENT_ESC, - pjsip_NOT_COMMA_OR_NEWLINE, /* Array separator. */ - pjsip_NOT_NEWLINE, /* For eating up header.*/ - pjsip_DISPLAY_SPEC; /* Used when searching for display name - * in URL. */ - /* * Forward decl. @@ -243,10 +222,17 @@ static void on_syntax_error(pj_scanner *scanner) PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); } +/* Get parser constants. */ +PJ_DEF(const pjsip_parser_const_t*) pjsip_parser_const(void) +{ + return &pconst; +} + /* Concatenate unrecognized params into single string. */ -void pjsip_concat_param_imp( pj_str_t *param, pj_pool_t *pool, - const pj_str_t *pname, const pj_str_t *pvalue, - int sepchar) +PJ_DEF(void) pjsip_concat_param_imp(pj_str_t *param, pj_pool_t *pool, + const pj_str_t *pname, + const pj_str_t *pvalue, + int sepchar) { char *new_param, *p; int len; @@ -300,94 +286,94 @@ static pj_status_t init_parser() pj_cis_buf_init(&cis_buf); - status = pj_cis_init(&cis_buf, &pjsip_DIGIT_SPEC); + status = pj_cis_init(&cis_buf, &pconst.pjsip_DIGIT_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_num(&pjsip_DIGIT_SPEC); + pj_cis_add_num(&pconst.pjsip_DIGIT_SPEC); - status = pj_cis_init(&cis_buf, &pjsip_ALPHA_SPEC); + status = pj_cis_init(&cis_buf, &pconst.pjsip_ALPHA_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_alpha( &pjsip_ALPHA_SPEC ); + pj_cis_add_alpha( &pconst.pjsip_ALPHA_SPEC ); - status = pj_cis_init(&cis_buf, &pjsip_ALNUM_SPEC); + status = pj_cis_init(&cis_buf, &pconst.pjsip_ALNUM_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_alpha( &pjsip_ALNUM_SPEC ); - pj_cis_add_num( &pjsip_ALNUM_SPEC ); + pj_cis_add_alpha( &pconst.pjsip_ALNUM_SPEC ); + pj_cis_add_num( &pconst.pjsip_ALNUM_SPEC ); - status = pj_cis_init(&cis_buf, &pjsip_NOT_NEWLINE); + status = pj_cis_init(&cis_buf, &pconst.pjsip_NOT_NEWLINE); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str(&pjsip_NOT_NEWLINE, "\r\n"); - pj_cis_invert(&pjsip_NOT_NEWLINE); + pj_cis_add_str(&pconst.pjsip_NOT_NEWLINE, "\r\n"); + pj_cis_invert(&pconst.pjsip_NOT_NEWLINE); - status = pj_cis_init(&cis_buf, &pjsip_NOT_COMMA_OR_NEWLINE); + status = pj_cis_init(&cis_buf, &pconst.pjsip_NOT_COMMA_OR_NEWLINE); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str( &pjsip_NOT_COMMA_OR_NEWLINE, ",\r\n"); - pj_cis_invert(&pjsip_NOT_COMMA_OR_NEWLINE); + pj_cis_add_str( &pconst.pjsip_NOT_COMMA_OR_NEWLINE, ",\r\n"); + pj_cis_invert(&pconst.pjsip_NOT_COMMA_OR_NEWLINE); - status = pj_cis_dup(&pjsip_TOKEN_SPEC, &pjsip_ALNUM_SPEC); + status = pj_cis_dup(&pconst.pjsip_TOKEN_SPEC, &pconst.pjsip_ALNUM_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str( &pjsip_TOKEN_SPEC, TOKEN); + pj_cis_add_str( &pconst.pjsip_TOKEN_SPEC, TOKEN); - status = pj_cis_dup(&pjsip_TOKEN_SPEC_ESC, &pjsip_TOKEN_SPEC); + status = pj_cis_dup(&pconst.pjsip_TOKEN_SPEC_ESC, &pconst.pjsip_TOKEN_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_del_str(&pjsip_TOKEN_SPEC_ESC, "%"); + pj_cis_del_str(&pconst.pjsip_TOKEN_SPEC_ESC, "%"); - status = pj_cis_dup(&pjsip_HOST_SPEC, &pjsip_ALNUM_SPEC); + status = pj_cis_dup(&pconst.pjsip_HOST_SPEC, &pconst.pjsip_ALNUM_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str( &pjsip_HOST_SPEC, HOST); + pj_cis_add_str( &pconst.pjsip_HOST_SPEC, HOST); - status = pj_cis_dup(&pjsip_HEX_SPEC, &pjsip_DIGIT_SPEC); + status = pj_cis_dup(&pconst.pjsip_HEX_SPEC, &pconst.pjsip_DIGIT_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str( &pjsip_HEX_SPEC, HEX_DIGIT); + pj_cis_add_str( &pconst.pjsip_HEX_SPEC, HEX_DIGIT); - status = pj_cis_dup(&pjsip_PARAM_CHAR_SPEC, &pjsip_ALNUM_SPEC); + status = pj_cis_dup(&pconst.pjsip_PARAM_CHAR_SPEC, &pconst.pjsip_ALNUM_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str(&pjsip_PARAM_CHAR_SPEC, PARAM_CHAR); + pj_cis_add_str(&pconst.pjsip_PARAM_CHAR_SPEC, PARAM_CHAR); - status = pj_cis_dup(&pjsip_PARAM_CHAR_SPEC_ESC, &pjsip_PARAM_CHAR_SPEC); + status = pj_cis_dup(&pconst.pjsip_PARAM_CHAR_SPEC_ESC, &pconst.pjsip_PARAM_CHAR_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_del_str(&pjsip_PARAM_CHAR_SPEC_ESC, ESCAPED); + pj_cis_del_str(&pconst.pjsip_PARAM_CHAR_SPEC_ESC, ESCAPED); - status = pj_cis_dup(&pjsip_HDR_CHAR_SPEC, &pjsip_ALNUM_SPEC); + status = pj_cis_dup(&pconst.pjsip_HDR_CHAR_SPEC, &pconst.pjsip_ALNUM_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str(&pjsip_HDR_CHAR_SPEC, HDR_CHAR); + pj_cis_add_str(&pconst.pjsip_HDR_CHAR_SPEC, HDR_CHAR); - status = pj_cis_dup(&pjsip_HDR_CHAR_SPEC_ESC, &pjsip_HDR_CHAR_SPEC); + status = pj_cis_dup(&pconst.pjsip_HDR_CHAR_SPEC_ESC, &pconst.pjsip_HDR_CHAR_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_del_str(&pjsip_HDR_CHAR_SPEC_ESC, ESCAPED); + pj_cis_del_str(&pconst.pjsip_HDR_CHAR_SPEC_ESC, ESCAPED); - status = pj_cis_dup(&pjsip_USER_SPEC, &pjsip_ALNUM_SPEC); + status = pj_cis_dup(&pconst.pjsip_USER_SPEC, &pconst.pjsip_ALNUM_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str( &pjsip_USER_SPEC, UNRESERVED ESCAPED USER_UNRESERVED ); + pj_cis_add_str( &pconst.pjsip_USER_SPEC, UNRESERVED ESCAPED USER_UNRESERVED ); - status = pj_cis_dup(&pjsip_USER_SPEC_ESC, &pjsip_USER_SPEC); + status = pj_cis_dup(&pconst.pjsip_USER_SPEC_ESC, &pconst.pjsip_USER_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_del_str( &pjsip_USER_SPEC_ESC, ESCAPED); + pj_cis_del_str( &pconst.pjsip_USER_SPEC_ESC, ESCAPED); - status = pj_cis_dup(&pjsip_USER_SPEC_LENIENT, &pjsip_USER_SPEC); + status = pj_cis_dup(&pconst.pjsip_USER_SPEC_LENIENT, &pconst.pjsip_USER_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str(&pjsip_USER_SPEC_LENIENT, "#"); + pj_cis_add_str(&pconst.pjsip_USER_SPEC_LENIENT, "#"); - status = pj_cis_dup(&pjsip_USER_SPEC_LENIENT_ESC, &pjsip_USER_SPEC_ESC); + status = pj_cis_dup(&pconst.pjsip_USER_SPEC_LENIENT_ESC, &pconst.pjsip_USER_SPEC_ESC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str(&pjsip_USER_SPEC_LENIENT_ESC, "#"); + pj_cis_add_str(&pconst.pjsip_USER_SPEC_LENIENT_ESC, "#"); - status = pj_cis_dup(&pjsip_PASSWD_SPEC, &pjsip_ALNUM_SPEC); + status = pj_cis_dup(&pconst.pjsip_PASSWD_SPEC, &pconst.pjsip_ALNUM_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str( &pjsip_PASSWD_SPEC, UNRESERVED ESCAPED PASS); + pj_cis_add_str( &pconst.pjsip_PASSWD_SPEC, UNRESERVED ESCAPED PASS); - status = pj_cis_dup(&pjsip_PASSWD_SPEC_ESC, &pjsip_PASSWD_SPEC); + status = pj_cis_dup(&pconst.pjsip_PASSWD_SPEC_ESC, &pconst.pjsip_PASSWD_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_del_str( &pjsip_PASSWD_SPEC_ESC, ESCAPED); + pj_cis_del_str( &pconst.pjsip_PASSWD_SPEC_ESC, ESCAPED); - status = pj_cis_init(&cis_buf, &pjsip_PROBE_USER_HOST_SPEC); + status = pj_cis_init(&cis_buf, &pconst.pjsip_PROBE_USER_HOST_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str( &pjsip_PROBE_USER_HOST_SPEC, "@ \n>"); - pj_cis_invert( &pjsip_PROBE_USER_HOST_SPEC ); + pj_cis_add_str( &pconst.pjsip_PROBE_USER_HOST_SPEC, "@ \n>"); + pj_cis_invert( &pconst.pjsip_PROBE_USER_HOST_SPEC ); - status = pj_cis_init(&cis_buf, &pjsip_DISPLAY_SPEC); + status = pj_cis_init(&cis_buf, &pconst.pjsip_DISPLAY_SPEC); PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); - pj_cis_add_str( &pjsip_DISPLAY_SPEC, ":\r\n<"); - pj_cis_invert(&pjsip_DISPLAY_SPEC); + pj_cis_add_str( &pconst.pjsip_DISPLAY_SPEC, ":\r\n<"); + pj_cis_invert(&pconst.pjsip_DISPLAY_SPEC); /* * Register URI parsers. @@ -817,7 +803,7 @@ PJ_DEF(pj_bool_t) pjsip_find_msg( const char *buf, pj_size_t size, } /* Get number */ - pj_scan_get(&scanner, &pjsip_DIGIT_SPEC, &str_clen); + pj_scan_get(&scanner, &pconst.pjsip_DIGIT_SPEC, &str_clen); /* Get newline. */ pj_scan_get_newline(&scanner); @@ -959,7 +945,7 @@ parse_headers: hname.slen = 0; /* Get hname. */ - pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &hname); + pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &hname); if (pj_scan_get_char( scanner ) != ':') { PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); } @@ -1109,22 +1095,22 @@ static void parse_param_imp( pj_scanner *scanner, pj_pool_t *pool, } /* Parse parameter (pname ["=" pvalue]) using token. */ -void pjsip_parse_param_imp( pj_scanner *scanner, pj_pool_t *pool, - pj_str_t *pname, pj_str_t *pvalue, - unsigned option) +PJ_DEF(void) pjsip_parse_param_imp(pj_scanner *scanner, pj_pool_t *pool, + pj_str_t *pname, pj_str_t *pvalue, + unsigned option) { - parse_param_imp(scanner, pool, pname, pvalue, &pjsip_TOKEN_SPEC, - &pjsip_TOKEN_SPEC_ESC, option); + parse_param_imp(scanner, pool, pname, pvalue, &pconst.pjsip_TOKEN_SPEC, + &pconst.pjsip_TOKEN_SPEC_ESC, option); } /* Parse parameter (pname ["=" pvalue]) using paramchar. */ -void pjsip_parse_uri_param_imp(pj_scanner *scanner, pj_pool_t *pool, - pj_str_t *pname, pj_str_t *pvalue, - unsigned option) +PJ_DEF(void) pjsip_parse_uri_param_imp( pj_scanner *scanner, pj_pool_t *pool, + pj_str_t *pname, pj_str_t *pvalue, + unsigned option) { - parse_param_imp(scanner, pool, pname, pvalue, &pjsip_PARAM_CHAR_SPEC, - &pjsip_PARAM_CHAR_SPEC_ESC, option); + parse_param_imp(scanner,pool, pname, pvalue, &pconst.pjsip_PARAM_CHAR_SPEC, + &pconst.pjsip_PARAM_CHAR_SPEC_ESC, option); } @@ -1162,8 +1148,8 @@ static void int_parse_hparam( pj_scanner *scanner, pj_pool_t *pool, pj_scan_get_char(scanner); /* hname */ - parser_get_and_unescape(scanner, pool, &pjsip_HDR_CHAR_SPEC, - &pjsip_HDR_CHAR_SPEC_ESC, hname); + parser_get_and_unescape(scanner, pool, &pconst.pjsip_HDR_CHAR_SPEC, + &pconst.pjsip_HDR_CHAR_SPEC_ESC, hname); /* Init hvalue */ hvalue->ptr = NULL; @@ -1173,10 +1159,10 @@ static void int_parse_hparam( pj_scanner *scanner, pj_pool_t *pool, if (*scanner->curptr == '=') { pj_scan_get_char(scanner); if (!pj_scan_is_eof(scanner) && - pj_cis_match(&pjsip_HDR_CHAR_SPEC, *scanner->curptr)) + pj_cis_match(&pconst.pjsip_HDR_CHAR_SPEC, *scanner->curptr)) { - parser_get_and_unescape(scanner, pool, &pjsip_HDR_CHAR_SPEC, - &pjsip_HDR_CHAR_SPEC_ESC, hvalue); + parser_get_and_unescape(scanner, pool, &pconst.pjsip_HDR_CHAR_SPEC, + &pconst.pjsip_HDR_CHAR_SPEC_ESC, hvalue); } } } @@ -1185,12 +1171,12 @@ static void int_parse_hparam( pj_scanner *scanner, pj_pool_t *pool, static void int_parse_uri_host_port( pj_scanner *scanner, pj_str_t *host, int *p_port) { - pj_scan_get( scanner, &pjsip_HOST_SPEC, host); + pj_scan_get( scanner, &pconst.pjsip_HOST_SPEC, host); /* RFC3261 section 19.1.2: host don't need to be unescaped */ if (*scanner->curptr == ':') { pj_str_t port; pj_scan_get_char(scanner); - pj_scan_get(scanner, &pjsip_DIGIT_SPEC, &port); + pj_scan_get(scanner, &pconst.pjsip_DIGIT_SPEC, &port); *p_port = pj_strtoul(&port); } else { *p_port = 0; @@ -1206,7 +1192,7 @@ static int int_is_next_user(pj_scanner *scanner) /* Find character '@'. If this character exist, then the token * must be a username. */ - if (pj_scan_peek( scanner, &pjsip_PROBE_USER_HOST_SPEC, &dummy) == '@') + if (pj_scan_peek( scanner, &pconst.pjsip_PROBE_USER_HOST_SPEC, &dummy) == '@') is_user = 1; else is_user = 0; @@ -1218,13 +1204,13 @@ static int int_is_next_user(pj_scanner *scanner) static void int_parse_user_pass( pj_scanner *scanner, pj_pool_t *pool, pj_str_t *user, pj_str_t *pass) { - parser_get_and_unescape(scanner, pool, &pjsip_USER_SPEC_LENIENT, - &pjsip_USER_SPEC_LENIENT_ESC, user); + parser_get_and_unescape(scanner, pool, &pconst.pjsip_USER_SPEC_LENIENT, + &pconst.pjsip_USER_SPEC_LENIENT_ESC, user); if ( *scanner->curptr == ':') { pj_scan_get_char( scanner ); - parser_get_and_unescape(scanner, pool, &pjsip_PASSWD_SPEC, - &pjsip_PASSWD_SPEC_ESC, pass); + parser_get_and_unescape(scanner, pool, &pconst.pjsip_PASSWD_SPEC, + &pconst.pjsip_PASSWD_SPEC_ESC, pass); } else { pass->ptr = NULL; pass->slen = 0; @@ -1251,7 +1237,7 @@ static pjsip_uri *int_parse_uri_or_name_addr( pj_scanner *scanner, pj_pool_t *po pj_str_t scheme; int next_ch; - next_ch = pj_scan_peek( scanner, &pjsip_DISPLAY_SPEC, &scheme); + next_ch = pj_scan_peek( scanner, &pconst.pjsip_DISPLAY_SPEC, &scheme); if (next_ch==':') { pjsip_parse_uri_func *func = find_uri_handler(&scheme); @@ -1304,7 +1290,7 @@ static pjsip_uri *int_parse_uri(pj_scanner *scanner, pj_pool_t *pool, pjsip_parse_uri_func *func; /* Get scheme. */ - colon = pj_scan_peek(scanner, &pjsip_TOKEN_SPEC, &scheme); + colon = pj_scan_peek(scanner, &pconst.pjsip_TOKEN_SPEC, &scheme); if (colon != ':') { PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); } @@ -1337,16 +1323,16 @@ static void* int_parse_sip_url( pj_scanner *scanner, int skip_ws = scanner->skip_ws; scanner->skip_ws = 0; - pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &scheme); + pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &scheme); colon = pj_scan_get_char(scanner); if (colon != ':') { PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); } - if (parser_stricmp(scheme, pjsip_SIP_STR)==0) { + if (parser_stricmp(scheme, pconst.pjsip_SIP_STR)==0) { url = pjsip_sip_uri_create(pool, 0); - } else if (parser_stricmp(scheme, pjsip_SIPS_STR)==0) { + } else if (parser_stricmp(scheme, pconst.pjsip_SIPS_STR)==0) { url = pjsip_sip_uri_create(pool, 1); } else { @@ -1372,22 +1358,22 @@ static void* int_parse_sip_url( pj_scanner *scanner, int_parse_uri_param( scanner, pool, &pname, &pvalue, 0); - if (!parser_stricmp(pname, pjsip_USER_STR) && pvalue.slen) { + if (!parser_stricmp(pname, pconst.pjsip_USER_STR) && pvalue.slen) { url->user_param = pvalue; - } else if (!parser_stricmp(pname, pjsip_METHOD_STR) && pvalue.slen) { + } else if (!parser_stricmp(pname, pconst.pjsip_METHOD_STR) && pvalue.slen) { url->method_param = pvalue; - } else if (!parser_stricmp(pname,pjsip_TRANSPORT_STR) && pvalue.slen) { + } else if (!parser_stricmp(pname, pconst.pjsip_TRANSPORT_STR) && pvalue.slen) { url->transport_param = pvalue; - } else if (!parser_stricmp(pname, pjsip_TTL_STR) && pvalue.slen) { + } else if (!parser_stricmp(pname, pconst.pjsip_TTL_STR) && pvalue.slen) { url->ttl_param = pj_strtoul(&pvalue); - } else if (!parser_stricmp(pname, pjsip_MADDR_STR) && pvalue.slen) { + } else if (!parser_stricmp(pname, pconst.pjsip_MADDR_STR) && pvalue.slen) { url->maddr_param = pvalue; - } else if (!parser_stricmp(pname, pjsip_LR_STR)) { + } else if (!parser_stricmp(pname, pconst.pjsip_LR_STR)) { url->lr_param = 1; } else { @@ -1438,7 +1424,7 @@ static pjsip_name_addr *int_parse_name_addr( pj_scanner *scanner, * We're only interested in display name, because SIP URL * will be parser later. */ - next = pj_scan_peek(scanner, &pjsip_DISPLAY_SPEC, &dummy); + next = pj_scan_peek(scanner, &pconst.pjsip_DISPLAY_SPEC, &dummy); if (next == '<') { /* Ok, this is what we're looking for, a display name. */ pj_scan_get_until_ch( scanner, '<', &name_addr->display); @@ -1469,7 +1455,7 @@ static void int_parse_req_line( pj_scanner *scanner, pj_pool_t *pool, { pj_str_t token; - pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &token); + pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &token); pjsip_method_init_np( &req_line->method, &token); req_line->uri = int_parse_uri(scanner, pool, PJ_TRUE); @@ -1489,9 +1475,9 @@ static void int_parse_status_line( pj_scanner *scanner, PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); pj_scan_advance_n( scanner, 7, 1); - pj_scan_get( scanner, &pjsip_DIGIT_SPEC, &token); + pj_scan_get( scanner, &pconst.pjsip_DIGIT_SPEC, &token); status_line->code = pj_strtoul(&token); - pj_scan_get( scanner, &pjsip_NOT_NEWLINE, &status_line->reason); + pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &status_line->reason); pj_scan_get_newline( scanner ); } @@ -1538,7 +1524,7 @@ static void parse_hdr_end( pj_scanner *scanner ) } /* Parse ending of header. */ -void pjsip_parse_end_hdr_imp( pj_scanner *scanner ) +PJ_DEF(void) pjsip_parse_end_hdr_imp( pj_scanner *scanner ) { parse_hdr_end(scanner); } @@ -1556,12 +1542,12 @@ static void parse_generic_array_hdr( pjsip_generic_array_hdr *hdr, goto end; } - pj_scan_get( scanner, &pjsip_NOT_COMMA_OR_NEWLINE, &hdr->values[0]); + pj_scan_get( scanner, &pconst.pjsip_NOT_COMMA_OR_NEWLINE, &hdr->values[0]); hdr->count++; while (*scanner->curptr == ',') { pj_scan_get_char(scanner); - pj_scan_get( scanner, &pjsip_NOT_COMMA_OR_NEWLINE, + pj_scan_get( scanner, &pconst.pjsip_NOT_COMMA_OR_NEWLINE, &hdr->values[hdr->count]); hdr->count++; @@ -1577,8 +1563,8 @@ end: static void parse_generic_string_hdr( pjsip_generic_string_hdr *hdr, pj_scanner *scanner ) { - if (pj_cis_match(&pjsip_NOT_NEWLINE, *scanner->curptr)) - pj_scan_get( scanner, &pjsip_NOT_NEWLINE, &hdr->hvalue); + if (pj_cis_match(&pconst.pjsip_NOT_NEWLINE, *scanner->curptr)) + pj_scan_get( scanner, &pconst.pjsip_NOT_NEWLINE, &hdr->hvalue); else hdr->hvalue.slen = 0; @@ -1590,7 +1576,7 @@ static void parse_generic_int_hdr( pjsip_generic_int_hdr *hdr, pj_scanner *scanner ) { pj_str_t tmp; - pj_scan_get( scanner, &pjsip_DIGIT_SPEC, &tmp); + pj_scan_get( scanner, &pconst.pjsip_DIGIT_SPEC, &tmp); hdr->ivalue = pj_strtoul(&tmp); parse_hdr_end(scanner); } @@ -1616,7 +1602,7 @@ static pjsip_hdr* parse_hdr_allow(pjsip_parse_ctx *ctx) static pjsip_hdr* parse_hdr_call_id(pjsip_parse_ctx *ctx) { pjsip_cid_hdr *hdr = pjsip_cid_hdr_create(ctx->pool); - pj_scan_get( ctx->scanner, &pjsip_NOT_NEWLINE, &hdr->id); + pj_scan_get( ctx->scanner, &pconst.pjsip_NOT_NEWLINE, &hdr->id); parse_hdr_end(ctx->scanner); if (ctx->rdata) @@ -1634,7 +1620,7 @@ static void int_parse_contact_param( pjsip_contact_hdr *hdr, pj_str_t pname, pvalue; int_parse_param( scanner, pool, &pname, &pvalue, 0); - if (!parser_stricmp(pname, pjsip_Q_STR) && pvalue.slen) { + if (!parser_stricmp(pname, pconst.pjsip_Q_STR) && pvalue.slen) { char *dot_pos = (char*) pj_memchr(pvalue.ptr, '.', pvalue.slen); if (!dot_pos) { hdr->q1000 = pj_strtoul(&pvalue); @@ -1643,7 +1629,7 @@ static void int_parse_contact_param( pjsip_contact_hdr *hdr, pvalue.ptr = dot_pos + 1; hdr->q1000 = pj_strtoul_mindigit(&pvalue, 3); } - } else if (!parser_stricmp(pname, pjsip_EXPIRES_STR) && pvalue.slen) { + } else if (!parser_stricmp(pname, pconst.pjsip_EXPIRES_STR) && pvalue.slen) { hdr->expires = pj_strtoul(&pvalue); } else { @@ -1700,7 +1686,7 @@ static pjsip_hdr* parse_hdr_content_len( pjsip_parse_ctx *ctx ) pjsip_clen_hdr *hdr; hdr = pjsip_clen_hdr_create(ctx->pool); - pj_scan_get(ctx->scanner, &pjsip_DIGIT_SPEC, &digit); + pj_scan_get(ctx->scanner, &pconst.pjsip_DIGIT_SPEC, &digit); hdr->len = pj_strtoul(&digit); parse_hdr_end(ctx->scanner); @@ -1719,9 +1705,9 @@ static pjsip_hdr* parse_hdr_content_type( pjsip_parse_ctx *ctx ) hdr = pjsip_ctype_hdr_create(ctx->pool); /* Parse media type and subtype. */ - pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &hdr->media.type); + pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->media.type); pj_scan_get_char(scanner); - pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &hdr->media.subtype); + pj_scan_get(scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->media.subtype); /* Parse media parameters */ while (*scanner->curptr == ';') { @@ -1745,10 +1731,10 @@ static pjsip_hdr* parse_hdr_cseq( pjsip_parse_ctx *ctx ) pjsip_cseq_hdr *hdr; hdr = pjsip_cseq_hdr_create(ctx->pool); - pj_scan_get( ctx->scanner, &pjsip_DIGIT_SPEC, &cseq); + pj_scan_get( ctx->scanner, &pconst.pjsip_DIGIT_SPEC, &cseq); hdr->cseq = pj_strtoul(&cseq); - pj_scan_get( ctx->scanner, &pjsip_TOKEN_SPEC, &method); + pj_scan_get( ctx->scanner, &pconst.pjsip_TOKEN_SPEC, &method); pjsip_method_init_np(&hdr->method, &method); parse_hdr_end( ctx->scanner ); @@ -1781,7 +1767,7 @@ static void parse_hdr_fromto( pj_scanner *scanner, int_parse_param( scanner, pool, &pname, &pvalue, 0); - if (!parser_stricmp(pname, pjsip_TAG_STR)) { + if (!parser_stricmp(pname, pconst.pjsip_TAG_STR)) { hdr->tag = pvalue; } else { @@ -1865,19 +1851,19 @@ static void int_parse_via_param( pjsip_via_hdr *hdr, pj_scanner *scanner, int_parse_param( scanner, pool, &pname, &pvalue, 0); - if (!parser_stricmp(pname, pjsip_BRANCH_STR) && pvalue.slen) { + if (!parser_stricmp(pname, pconst.pjsip_BRANCH_STR) && pvalue.slen) { hdr->branch_param = pvalue; - } else if (!parser_stricmp(pname, pjsip_TTL_STR) && pvalue.slen) { + } else if (!parser_stricmp(pname, pconst.pjsip_TTL_STR) && pvalue.slen) { hdr->ttl_param = pj_strtoul(&pvalue); - } else if (!parser_stricmp(pname, pjsip_MADDR_STR) && pvalue.slen) { + } else if (!parser_stricmp(pname, pconst.pjsip_MADDR_STR) && pvalue.slen) { hdr->maddr_param = pvalue; - } else if (!parser_stricmp(pname, pjsip_RECEIVED_STR) && pvalue.slen) { + } else if (!parser_stricmp(pname, pconst.pjsip_RECEIVED_STR) && pvalue.slen) { hdr->recvd_param = pvalue; - } else if (!parser_stricmp(pname, pjsip_RPORT_STR)) { + } else if (!parser_stricmp(pname, pconst.pjsip_RPORT_STR)) { if (pvalue.slen) hdr->rport_param = pj_strtoul(&pvalue); else @@ -2003,13 +1989,13 @@ static pjsip_hdr* parse_hdr_via( pjsip_parse_ctx *ctx ) pj_scan_advance_n( scanner, 8, 1); - pj_scan_get( scanner, &pjsip_TOKEN_SPEC, &hdr->transport); - pj_scan_get( scanner, &pjsip_HOST_SPEC, &hdr->sent_by.host); + pj_scan_get( scanner, &pconst.pjsip_TOKEN_SPEC, &hdr->transport); + pj_scan_get( scanner, &pconst.pjsip_HOST_SPEC, &hdr->sent_by.host); if (*scanner->curptr==':') { pj_str_t digit; pj_scan_get_char(scanner); - pj_scan_get(scanner, &pjsip_DIGIT_SPEC, &digit); + pj_scan_get(scanner, &pconst.pjsip_DIGIT_SPEC, &digit); hdr->sent_by.port = pj_strtoul(&digit); } diff --git a/pjsip/src/pjsip/sip_tel_uri.c b/pjsip/src/pjsip/sip_tel_uri.c index f55eba79..ea1435d9 100644 --- a/pjsip/src/pjsip/sip_tel_uri.c +++ b/pjsip/src/pjsip/sip_tel_uri.c @@ -105,7 +105,7 @@ PJ_DEF(pjsip_tel_uri*) pjsip_tel_uri_create(pj_pool_t *pool) static const pj_str_t *tel_uri_get_scheme( const pjsip_tel_uri *uri ) { PJ_UNUSED_ARG(uri); - return &pjsip_TEL_STR; + return &pjsip_parser_const()->pjsip_TEL_STR; } static void *tel_uri_get_uri( pjsip_tel_uri *uri ) @@ -182,11 +182,12 @@ static pj_ssize_t tel_uri_print( pjsip_uri_context_e context, int printed; char *startbuf = buf; char *endbuf = buf+size; + const pjsip_parser_const_t *pc = pjsip_parser_const(); PJ_UNUSED_ARG(context); /* Print scheme. */ - copy_advance(buf, pjsip_TEL_STR); + copy_advance(buf, pc->pjsip_TEL_STR); *buf++ = ':'; /* Print number. */ @@ -370,14 +371,15 @@ static void* tel_uri_parse( pj_scanner *scanner, pj_pool_t *pool, pjsip_tel_uri *uri; pj_str_t token; int skip_ws = scanner->skip_ws; + const pjsip_parser_const_t *pc = pjsip_parser_const(); scanner->skip_ws = 0; /* Parse scheme. */ - pj_scan_get(scanner, &pjsip_TOKEN_SPEC, &token); + pj_scan_get(scanner, &pc->pjsip_TOKEN_SPEC, &token); if (pj_scan_get_char(scanner) != ':') PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); - if (pj_stricmp_alnum(&token, &pjsip_TEL_STR) != 0) + if (pj_stricmp_alnum(&token, &pc->pjsip_TEL_STR) != 0) PJ_THROW(PJSIP_SYN_ERR_EXCEPTION); /* Create URI */ @@ -394,21 +396,22 @@ static void* tel_uri_parse( pj_scanner *scanner, pj_pool_t *pool, /* Get all parameters. */ if (parse_params && *scanner->curptr==';') { pj_str_t pname, pvalue; + const pjsip_parser_const_t *pc = pjsip_parser_const(); do { /* Eat the ';' separator. */ pj_scan_get_char(scanner); /* Get pname. */ - pj_scan_get(scanner, &pjsip_PARAM_CHAR_SPEC, &pname); + pj_scan_get(scanner, &pc->pjsip_PARAM_CHAR_SPEC, &pname); if (*scanner->curptr == '=') { pj_scan_get_char(scanner); # if defined(PJSIP_UNESCAPE_IN_PLACE) && PJSIP_UNESCAPE_IN_PLACE!=0 - pj_scan_get_unescape( scanner, - &pjsip_TEL_PARSING_PVALUE_SPEC_ESC, - &pvalue); + pj_scan_get_unescape(scanner, + &pjsip_TEL_PARSING_PVALUE_SPEC_ESC, + &pvalue); # else pj_scan_get(scanner, &pjsip_TEL_PARSING_PVALUE_SPEC, &pvalue); diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c index 8f5dabb1..5f6679aa 100644 --- a/pjsip/src/pjsip/sip_transport.c +++ b/pjsip/src/pjsip/sip_transport.c @@ -113,7 +113,7 @@ struct transport_names_t /* * Register new transport type to PJSIP. */ -PJ_DECL(pj_status_t) pjsip_transport_register_type(unsigned tp_flag, +PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag, const char *tp_name, int def_port, int *p_tp_type) @@ -149,8 +149,7 @@ PJ_DECL(pj_status_t) pjsip_transport_register_type(unsigned tp_flag, /* * Get transport type from name. */ -PJ_DEF(pjsip_transport_type_e) -pjsip_transport_get_type_from_name(const pj_str_t *name) +PJ_DEF(pjsip_transport_type_e) pjsip_transport_get_type_from_name(const pj_str_t *name) { unsigned i; @@ -178,8 +177,7 @@ pjsip_transport_get_type_from_name(const pj_str_t *name) /* * Get the transport type for the specified flags. */ -PJ_DEF(pjsip_transport_type_e) -pjsip_transport_get_type_from_flag(unsigned flag) +PJ_DEF(pjsip_transport_type_e) pjsip_transport_get_type_from_flag(unsigned flag) { unsigned i; @@ -200,8 +198,7 @@ pjsip_transport_get_type_from_flag(unsigned flag) return PJSIP_TRANSPORT_UNSPECIFIED; } -PJ_DEF(unsigned) -pjsip_transport_get_flag_from_type( pjsip_transport_type_e type ) +PJ_DEF(unsigned) pjsip_transport_get_flag_from_type(pjsip_transport_type_e type) { /* Sanity check. * Check that transport_names[] are indexed on transport type. @@ -219,8 +216,7 @@ pjsip_transport_get_flag_from_type( pjsip_transport_type_e type ) /* * Get the default SIP port number for the specified type. */ -PJ_DEF(int) -pjsip_transport_get_default_port_for_type(pjsip_transport_type_e type) +PJ_DEF(int) pjsip_transport_get_default_port_for_type(pjsip_transport_type_e type) { /* Sanity check. * Check that transport_names[] are indexed on transport type. diff --git a/pjsip/src/pjsip/sip_ua_layer.c b/pjsip/src/pjsip/sip_ua_layer.c index cff58133..c345b011 100644 --- a/pjsip/src/pjsip/sip_ua_layer.c +++ b/pjsip/src/pjsip/sip_ua_layer.c @@ -236,6 +236,7 @@ PJ_DEF(pj_status_t) pjsip_ua_destroy(void) /* * Create key to identify dialog set. */ +/* PJ_DEF(void) pjsip_ua_create_dlg_set_key( pj_pool_t *pool, pj_str_t *set_key, const pj_str_t *call_id, @@ -252,6 +253,7 @@ PJ_DEF(void) pjsip_ua_create_dlg_set_key( pj_pool_t *pool, pj_memcpy(set_key->ptr + call_id->slen + 1, local_tag->ptr, local_tag->slen); } +*/ /* * Acquire one dlg_set node to be put in the hash table. @@ -511,7 +513,7 @@ static struct dlg_set *find_dlg_set_for_msg( pjsip_rx_data *rdata ) role = PJSIP_ROLE_UAC; pjsip_tsx_create_key(rdata->tp_info.pool, &key, role, - &pjsip_invite_method, rdata); + pjsip_get_invite_method(), rdata); /* Lookup the INVITE transaction */ tsx = pjsip_tsx_layer_find_tsx(&key, PJ_TRUE); diff --git a/pjsip/src/pjsip/sip_uri.c b/pjsip/src/pjsip/sip_uri.c index c224090c..e22776ab 100644 --- a/pjsip/src/pjsip/sip_uri.c +++ b/pjsip/src/pjsip/sip_uri.c @@ -243,6 +243,7 @@ static pj_ssize_t pjsip_url_print( pjsip_uri_context_e context, char *startbuf = buf; char *endbuf = buf+size; const pj_str_t *scheme; + const pjsip_parser_const_t *pc = pjsip_parser_const(); *buf = '\0'; @@ -253,10 +254,10 @@ static pj_ssize_t pjsip_url_print( pjsip_uri_context_e context, /* Print "user:password@", if any. */ if (url->user.slen) { - copy_advance_escape(buf, url->user, pjsip_USER_SPEC); + copy_advance_escape(buf, url->user, pc->pjsip_USER_SPEC); if (url->passwd.slen) { *buf++ = ':'; - copy_advance_escape(buf, url->passwd, pjsip_PASSWD_SPEC); + copy_advance_escape(buf, url->passwd, pc->pjsip_PASSWD_SPEC); } *buf++ = '@'; @@ -289,13 +290,13 @@ static pj_ssize_t pjsip_url_print( pjsip_uri_context_e context, /* Method param is only allowed in external/other context. */ if (context == PJSIP_URI_IN_OTHER) { copy_advance_pair_escape(buf, ";method=", 8, url->method_param, - pjsip_PARAM_CHAR_SPEC); + pc->pjsip_PARAM_CHAR_SPEC); } /* Transport is not allowed in From/To header. */ if (context != PJSIP_URI_IN_FROMTO_HDR) { copy_advance_pair_escape(buf, ";transport=", 11, url->transport_param, - pjsip_PARAM_CHAR_SPEC); + pc->pjsip_PARAM_CHAR_SPEC); } /* TTL param is not allowed in From, To, Route, and Record-Route header. */ @@ -312,7 +313,7 @@ static pj_ssize_t pjsip_url_print( pjsip_uri_context_e context, /* maddr param is not allowed in From and To header. */ if (context != PJSIP_URI_IN_FROMTO_HDR) { copy_advance_pair_escape(buf, ";maddr=", 7, url->maddr_param, - pjsip_PARAM_CHAR_SPEC); + pc->pjsip_PARAM_CHAR_SPEC); } /* lr param is not allowed in From, To, and Contact header. */ @@ -327,8 +328,8 @@ static pj_ssize_t pjsip_url_print( pjsip_uri_context_e context, /* Other param. */ printed = pjsip_param_print_on(&url->other_param, buf, endbuf-buf, - &pjsip_PARAM_CHAR_SPEC, - &pjsip_PARAM_CHAR_SPEC, ';'); + &pc->pjsip_PARAM_CHAR_SPEC, + &pc->pjsip_PARAM_CHAR_SPEC, ';'); if (printed < 0) return -1; buf += printed; @@ -340,8 +341,8 @@ static pj_ssize_t pjsip_url_print( pjsip_uri_context_e context, */ if (context == PJSIP_URI_IN_CONTACT_HDR || context == PJSIP_URI_IN_OTHER) { printed = pjsip_param_print_on(&url->header_param, buf, endbuf-buf, - &pjsip_HDR_CHAR_SPEC, - &pjsip_HDR_CHAR_SPEC, '?'); + &pc->pjsip_HDR_CHAR_SPEC, + &pc->pjsip_HDR_CHAR_SPEC, '?'); if (printed < 0) return -1; buf += printed; diff --git a/pjsip/src/pjsip/sip_util.c b/pjsip/src/pjsip/sip_util.c index 6b74d0c5..c48ff865 100644 --- a/pjsip/src/pjsip/sip_util.c +++ b/pjsip/src/pjsip/sip_util.c @@ -261,8 +261,7 @@ on_error: return status; } -PJ_DEF(pj_status_t) -pjsip_endpt_create_request_from_hdr( pjsip_endpoint *endpt, +PJ_DEF(pj_status_t) pjsip_endpt_create_request_from_hdr( pjsip_endpoint *endpt, const pjsip_method *method, const pjsip_uri *param_target, const pjsip_from_hdr *param_from, @@ -484,7 +483,7 @@ PJ_DEF(pj_status_t) pjsip_endpt_create_ack( pjsip_endpoint *endpt, /* Create new request message from the headers. */ status = pjsip_endpt_create_request_from_hdr(endpt, - &pjsip_ack_method, + pjsip_get_ack_method(), tdata->msg->line.req.uri, from_hdr, to_hdr, NULL, cid_hdr, @@ -575,7 +574,7 @@ PJ_DEF(pj_status_t) pjsip_endpt_create_cancel( pjsip_endpoint *endpt, /* Create new request message from the headers. */ status = pjsip_endpt_create_request_from_hdr(endpt, - &pjsip_cancel_method, + pjsip_get_cancel_method(), req_tdata->msg->line.req.uri, from_hdr, to_hdr, NULL, cid_hdr, @@ -992,8 +991,7 @@ stateless_send_resolver_callback( pj_status_t status, * - establish transport (#pjsip_endpt_acquire_transport) * - send the message (#pjsip_transport_send) */ -PJ_DEF(pj_status_t) -pjsip_endpt_send_request_stateless(pjsip_endpoint *endpt, +PJ_DEF(pj_status_t) pjsip_endpt_send_request_stateless(pjsip_endpoint *endpt, pjsip_tx_data *tdata, void *token, pjsip_send_callback cb) diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index d1042da9..935eaf51 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -2771,7 +2771,7 @@ static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv, if (tsx->role==PJSIP_ROLE_UAS && tsx->state==PJSIP_TSX_STATE_TRYING && - pjsip_method_cmp(&tsx->method, &pjsip_refer_method)==0) + pjsip_method_cmp(&tsx->method, pjsip_get_refer_method())==0) { /* * Incoming REFER request. diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index f2d18dc3..61d49c39 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -54,6 +54,113 @@ static void init_data() } +PJ_DEF(void) pjsua_logging_config_default(pjsua_logging_config *cfg) +{ + pj_bzero(cfg, sizeof(*cfg)); + + cfg->msg_logging = PJ_TRUE; + cfg->level = 5; + cfg->console_level = 4; + cfg->decor = PJ_LOG_HAS_SENDER | PJ_LOG_HAS_TIME | + PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_NEWLINE; +} + +PJ_DEF(void) pjsua_logging_config_dup(pj_pool_t *pool, + pjsua_logging_config *dst, + const pjsua_logging_config *src) +{ + pj_memcpy(dst, src, sizeof(*src)); + pj_strdup_with_null(pool, &dst->log_filename, &src->log_filename); +} + +PJ_DEF(void) pjsua_config_default(pjsua_config *cfg) +{ + pj_bzero(cfg, sizeof(*cfg)); + + cfg->max_calls = 4; + cfg->thread_cnt = 1; +} + +PJ_DEF(void) pjsip_cred_dup( pj_pool_t *pool, + pjsip_cred_info *dst, + const pjsip_cred_info *src) +{ + pj_strdup_with_null(pool, &dst->realm, &src->realm); + pj_strdup_with_null(pool, &dst->scheme, &src->scheme); + pj_strdup_with_null(pool, &dst->username, &src->username); + pj_strdup_with_null(pool, &dst->data, &src->data); +} + +PJ_DEF(void) pjsua_config_dup(pj_pool_t *pool, + pjsua_config *dst, + const pjsua_config *src) +{ + unsigned i; + + pj_memcpy(dst, src, sizeof(*src)); + + for (i=0; i<src->outbound_proxy_cnt; ++i) { + pj_strdup_with_null(pool, &dst->outbound_proxy[i], + &src->outbound_proxy[i]); + } + + for (i=0; i<src->cred_count; ++i) { + pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]); + } + + pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent); + pj_strdup_with_null(pool, &dst->stun_domain, &src->stun_domain); + pj_strdup_with_null(pool, &dst->stun_host, &src->stun_host); + pj_strdup_with_null(pool, &dst->stun_relay_host, &src->stun_relay_host); +} + +PJ_DEF(void) pjsua_msg_data_init(pjsua_msg_data *msg_data) +{ + pj_bzero(msg_data, sizeof(*msg_data)); + pj_list_init(&msg_data->hdr_list); +} + +PJ_DEF(void) pjsua_transport_config_default(pjsua_transport_config *cfg) +{ + pj_bzero(cfg, sizeof(*cfg)); + pjsip_tls_setting_default(&cfg->tls_setting); +} + +PJ_DEF(void) pjsua_transport_config_dup(pj_pool_t *pool, + pjsua_transport_config *dst, + const pjsua_transport_config *src) +{ + PJ_UNUSED_ARG(pool); + pj_memcpy(dst, src, sizeof(*src)); +} + +PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg) +{ + pj_bzero(cfg, sizeof(*cfg)); + + cfg->reg_timeout = PJSUA_REG_INTERVAL; + cfg->transport_id = PJSUA_INVALID_ID; +} + +PJ_DEF(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg) +{ + pj_bzero(cfg, sizeof(*cfg)); +} + +PJ_DEF(void) pjsua_media_config_default(pjsua_media_config *cfg) +{ + pj_bzero(cfg, sizeof(*cfg)); + + cfg->clock_rate = PJSUA_DEFAULT_CLOCK_RATE; + cfg->max_media_ports = 32; + cfg->has_ioqueue = PJ_TRUE; + cfg->thread_cnt = 1; + cfg->quality = PJSUA_DEFAULT_CODEC_QUALITY; + cfg->ilbc_mode = PJSUA_DEFAULT_ILBC_MODE; + cfg->ec_tail_len = PJSUA_DEFAULT_EC_TAIL_LEN; + cfg->jb_init = cfg->jb_min_pre = cfg->jb_max_pre = cfg->jb_max = -1; +} + /***************************************************************************** * This is a very simple PJSIP module, whose sole purpose is to display @@ -148,7 +255,7 @@ static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata) /* Only want to handle OPTIONS requests */ if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, - &pjsip_options_method) != 0) + pjsip_get_options_method()) != 0) { return PJ_FALSE; } diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 6f646fb8..8700bd59 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -625,8 +625,8 @@ on_error: * Create UDP media transports for all the calls. This function creates * one UDP media transport for each call. */ -PJ_DEF(pj_status_t) -pjsua_media_transports_create(const pjsua_transport_config *app_cfg) +PJ_DEF(pj_status_t) pjsua_media_transports_create( + const pjsua_transport_config *app_cfg) { pjsua_transport_config cfg; unsigned i; @@ -1112,7 +1112,7 @@ static char* get_basename(const char *path, unsigned len) if (len==0) return p; - for (--p; p!=path && *p!='/' && *p!='\\'; --p); + for (--p; p!=path && *p!='/' && *p!='\\'; ) --p; return (p==path) ? p : p+1; } diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c index 5a90cb1d..963db29c 100644 --- a/pjsip/src/pjsua-lib/pjsua_pres.c +++ b/pjsip/src/pjsua-lib/pjsua_pres.c @@ -459,7 +459,7 @@ static pj_bool_t pres_on_rx_request(pjsip_rx_data *rdata) pjsip_evsub_state ev_state; pj_status_t status; - if (pjsip_method_cmp(req_method, &pjsip_subscribe_method) != 0) + if (pjsip_method_cmp(req_method, pjsip_get_subscribe_method()) != 0) return PJ_FALSE; /* Incoming SUBSCRIBE: */ @@ -926,7 +926,7 @@ static void pjsua_evsub_on_tsx_state(pjsip_evsub *sub, if (tsx->status_code/100 != 2 || tsx->role != PJSIP_UAC_ROLE || event->type != PJSIP_EVENT_RX_MSG || - pjsip_method_cmp(&tsx->method, &pjsip_subscribe_method)!=0) + pjsip_method_cmp(&tsx->method, pjsip_get_subscribe_method())!=0) { PJSUA_UNLOCK(); return; |