📄 nua_params.c
字号:
static int nua_handle_tags_filter(tagi_t const *f, tagi_t const *t){ tag_type_t tag; if (!t || !t->t_tag) return 0; tag = t->t_tag; if (tag == tag_filter) return 0; /* Accept @From or @To only when they are followed by TAG_FILTER(nua_handle_tags_filter) */ if (tag == siptag_from || tag == siptag_to) { t = tl_next(t); return t && t->t_tag == tag_filter && t->t_value == (tag_value_t)nua_handle_tags_filter; } if (tag == nutag_identity) return 0; if (tag == siptag_from_str) return 0; if (tag == siptag_to_str) return 0; /** Ignore @CSeq, @RSeq, @RAck, @Timestamp, and @ContentLength */ if (tag == siptag_cseq || tag == siptag_cseq_str) return 0; if (tag == siptag_rseq || tag == siptag_rseq_str) return 0; if (tag == siptag_rack || tag == siptag_rack_str) return 0; if (tag == siptag_timestamp || tag == siptag_timestamp_str) return 0; if (tag == siptag_content_length || tag == siptag_content_length_str) return 0; return ! nua_handle_param_filter(f, t);}staticint nua_stack_set_smime_params(nua_t *nua, tagi_t const *tags){#if HAVE_SOFIA_SMIME int smime_enable = nua->sm->sm_enable; int smime_opt = nua->sm->sm_opt; int smime_protection_mode = nua->sm->sm_protection_mode; char const *smime_message_digest = NONE; char const *smime_signature = NONE; char const *smime_key_encryption = NONE; char const *smime_message_encryption = NONE; char const *smime_path = NONE; int n; n = tl_gets(tags, NUTAG_SMIME_ENABLE_REF(smime_enable), NUTAG_SMIME_OPT_REF(smime_opt), NUTAG_SMIME_PROTECTION_MODE_REF(smime_protection_mode), NUTAG_SMIME_MESSAGE_DIGEST_REF(smime_message_digest), NUTAG_SMIME_SIGNATURE_REF(smime_signature), NUTAG_SMIME_KEY_ENCRYPTION_REF(smime_key_encryption), NUTAG_SMIME_MESSAGE_ENCRYPTION_REF(smime_message_encryption), NUTAG_CERTIFICATE_DIR_REF(smime_path), TAG_NULL()); if (n <= 0) return n; /* XXX - all other S/MIME parameters? */ return sm_set_params(nua->sm, smime_enable, smime_opt, smime_protection_mode, smime_path);#endif return 0;}/**@fn void nua_get_params(nua_t *nua, tag_type_t tag, tag_value_t value, ...) * * Get NUA parameters matching with the given filter. * The values of NUA parameters is returned in #nua_r_get_params event. * * @param nua Pointer to NUA stack object * @param tag, value, ... List of tagged parameters * * @return * nothing * * @par Related tags: * TAG_ANY() \n * otherwise same tags as nua_set_params() * * @par Events: * #nua_r_get_params * * @par Examples * Find out default values of all parameters: * @code * nua_get_params(nua, TAG_ANY(), TAG_END()); * @endcode *//**@fn void nua_get_hparams(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...) * * Get values of handle-specific parameters in #nua_r_get_params event. * * Application will specify either expilicit list of tags it is interested * in, or a filter (at the moment, TAG_ANY()). The values are returned as a * list of tags in the #nua_r_get_params event. * * @param nh Pointer to operation handle * @param tag, value, ... List of tagged parameters * * The handle-specific parameters will contain only the parameters actually * modified by application, either by nua_set_hparams() or some other * handle-specific call. Currently, no NTA parameters are returned. They are * returned only when application asks for user-agent-level parameters using * either nua_get_params() or using default handle, eg. * @code * nua_get_hparams(nua_default(nua), TAG_ANY()) * @endcode * * @return * nothing * * @par Related tags: * #TAG_ANY \n * othervise same tags as nua_set_hparams() * * @par Events: * #nua_r_get_params *//** @NUA_EVENT nua_r_get_params * * Answer to nua_get_params() or nua_get_hparams(). * * @param status 200 when succesful, error code otherwise * @param phrase a short textual description of @a status code * @param nh NULL when responding to nua_get_params(), * operation handle when responding to nua_get_hparams() * @param hmagic NULL when responding to nua_get_params(), * application contact associated with the operation handle * when responding to nua_get_hparams() * @param sip NULL * @param tags * NUTAG_APPL_METHOD() \n * NUTAG_AUTH_CACHE() \n * NUTAG_AUTOACK() \n * NUTAG_AUTOALERT() \n * NUTAG_AUTOANSWER() \n * NUTAG_CALLEE_CAPS() \n * NUTAG_DETECT_NETWORK_UPDATES() \n * NUTAG_EARLY_ANSWER() \n * NUTAG_EARLY_MEDIA() \n * NUTAG_ENABLEINVITE() \n * NUTAG_ENABLEMESSAGE() \n * NUTAG_ENABLEMESSENGER() \n * NUTAG_INITIAL_ROUTE() \n * NUTAG_INITIAL_ROUTE_STR() \n * NUTAG_INSTANCE() \n * NUTAG_INVITE_TIMER() \n * NUTAG_KEEPALIVE() \n * NUTAG_KEEPALIVE_STREAM() \n * NUTAG_MAX_SUBSCRIPTIONS() \n * NUTAG_MEDIA_ENABLE() \n * NUTAG_MEDIA_FEATURES() \n * NUTAG_MIN_SE() \n * NUTAG_M_DISPLAY() \n * NUTAG_M_FEATURES() \n * NUTAG_M_PARAMS() \n * NUTAG_M_USERNAME() \n * NUTAG_ONLY183_100REL() \n * NUTAG_OUTBOUND() \n * NUTAG_PATH_ENABLE() \n * NUTAG_REFER_EXPIRES() \n * NUTAG_REFER_WITH_ID() \n * NUTAG_REGISTRAR() \n * NUTAG_RETRY_COUNT() \n * NUTAG_SERVICE_ROUTE_ENABLE() \n * NUTAG_SESSION_REFRESHER() \n * NUTAG_SESSION_TIMER() \n * NUTAG_SMIME_ENABLE() \n * NUTAG_SMIME_KEY_ENCRYPTION() \n * NUTAG_SMIME_MESSAGE_DIGEST() \n * NUTAG_SMIME_MESSAGE_ENCRYPTION() \n * NUTAG_SMIME_OPT() \n * NUTAG_SMIME_PROTECTION_MODE() \n * NUTAG_SMIME_SIGNATURE() \n * NUTAG_SOA_NAME() \n * NUTAG_SUBSTATE() \n * NUTAG_SUB_EXPIRES() \n * NUTAG_UPDATE_REFRESH() \n * NUTAG_USER_AGENT() \n * SIPTAG_ALLOW() \n * SIPTAG_ALLOW_STR() \n * SIPTAG_ALLOW_EVENTS() \n * SIPTAG_ALLOW_EVENTS_STR() \n * SIPTAG_FROM() \n * SIPTAG_FROM_STR() \n * SIPTAG_ORGANIZATION() \n * SIPTAG_ORGANIZATION_STR() \n * SIPTAG_SUPPORTED() \n * SIPTAG_SUPPORTED_STR() \n * SIPTAG_USER_AGENT() \n * SIPTAG_USER_AGENT_STR() \n * * @sa nua_get_params(), nua_get_hparams(), * nua_set_params(), nua_set_hparams(), #nua_r_set_params * * @END_NUA_EVENT *//**@internal * Send a list of NUA parameters to the application. * * This function gets invoked when application calls either nua_get_params() * or nua_get_hparams(). * * The parameter tag list will initially contain all the relevant parameter * tags, and it will be filtered down to parameters asked by application. * * The handle-specific parameters will contain only the parameters actually * modified by application, either by nua_set_hparams() or some other * handle-specific call. NTA parameters are returned only when application * asks for user-agent-level parameters using nua_get_params(). * */int nua_stack_get_params(nua_t *nua, nua_handle_t *nh, nua_event_t e, tagi_t const *tags){ nua_handle_t *dnh = nua->nua_dhandle; nua_global_preferences_t const *ngp = nua->nua_prefs; nua_handle_preferences_t const *nhp = nh->nh_prefs; nua_handle_preferences_t const nhp_zero[1] = {{ 0 }}; tagi_t *lst; int has_from; sip_from_t from[1]; sip_contact_t const *m; /* nta */ unsigned udp_mtu = 0; usize_t max_proceeding = 0; unsigned sip_t1 = 0, sip_t2 = 0, sip_t4 = 0, sip_t1x64 = 0; unsigned debug_drop_prob = 0; url_string_t const *proxy = NULL; sip_contact_t const *aliases = NULL; unsigned flags = 0; /* soa */ tagi_t *media_params = NULL; su_home_t tmphome[SU_HOME_AUTO_SIZE(16536)]; enter; if (nh == dnh) nta_agent_get_params(nua->nua_nta, NTATAG_UDP_MTU_REF(udp_mtu), NTATAG_MAX_PROCEEDING_REF(max_proceeding), NTATAG_SIP_T1_REF(sip_t1), NTATAG_SIP_T2_REF(sip_t2), NTATAG_SIP_T4_REF(sip_t4), NTATAG_SIP_T1X64_REF(sip_t1x64), NTATAG_DEBUG_DROP_PROB_REF(debug_drop_prob), NTATAG_DEFAULT_PROXY_REF(proxy), NTATAG_ALIASES_REF(aliases), NTATAG_SIPFLAGS_REF(flags), TAG_END()); if (nh->nh_ds->ds_local) has_from = 1, *from = *nh->nh_ds->ds_local, from->a_params = NULL; else /* if (nua->nua_from_is_set) */ has_from = 1, *from = *nua->nua_from; media_params = soa_get_paramlist(nh->nh_soa, TAG_END()); m = nua_stack_get_contact(nua->nua_registrations); /* Include tag in the list returned to user * if it has been earlier set (by user) */#define TIF(TAG, pref) \ TAG_IF(nhp->nhp_set.nhb_##pref, TAG(nhp->nhp_##pref)) /* Include tag in the list returned to user * if it has been earlier set (by user) * but always include in the default parameters */#define TIFD(TAG, pref) \ TAG_IF(nh == dnh || nhp->nhp_set.nhb_##pref, TAG(nhp->nhp_##pref)) /* Include string tag made out of SIP header * if it has been earlier set (by user) */#define TIF_STR(TAG, pref) \ TAG_IF(nhp->nhp_set.nhb_##pref, \ TAG(nhp->nhp_set.nhb_##pref && nhp->nhp_##pref \ ? sip_header_as_string(tmphome, (void *)nhp->nhp_##pref) : NULL)) /* Include header tag made out of string * if it has been earlier set (by user) */#define TIF_SIP(TAG, pref) \ TAG_IF(nhp->nhp_set.nhb_##pref, \ TAG(nhp->nhp_set.nhb_##pref && nhp->nhp_##pref \ ? sip_##pref##_make(tmphome, (char *)nhp->nhp_##pref) \ : NULL)) if (nh != dnh && nhp == dnh->nh_prefs) nhp = nhp_zero; su_home_auto(tmphome, sizeof(tmphome)); lst = tl_filtered_tlist (tmphome, tags, TAG_IF(has_from, SIPTAG_FROM(from)), TAG_IF(has_from, SIPTAG_FROM_STR(has_from ? sip_header_as_string(tmphome, (void *)from) : NULL)), TIF(NUTAG_RETRY_COUNT, retry_count), TIF(NUTAG_MAX_SUBSCRIPTIONS, max_subscriptions), TIF(NUTAG_SOA_NAME, soa_name), TIF(NUTAG_MEDIA_ENABLE, media_enable), TIF(NUTAG_ENABLEINVITE, invite_enable), TIF(NUTAG_AUTOALERT, auto_alert), TIF(NUTAG_EARLY_ANSWER, early_answer), TIF(NUTAG_EARLY_MEDIA, early_media), TIF(NUTAG_ONLY183_100REL, only183_100rel), TIF(NUTAG_AUTOANSWER, auto_answer), TIF(NUTAG_AUTOACK, auto_ack), TIF(NUTAG_INVITE_TIMER, invite_timeout), TIFD(NUTAG_SESSION_TIMER, session_timer), TIF(NUTAG_MIN_SE, min_se), TIFD(NUTAG_SESSION_REFRESHER, refresher), TIF(NUTAG_UPDATE_REFRESH, update_refresh), TIF(NUTAG_ENABLEMESSAGE, message_enable), TIF(NUTAG_ENABLEMESSENGER, win_messenger_enable), /* TIF(NUTAG_AUTORESPOND, autorespond), */ TIF(NUTAG_CALLEE_CAPS, callee_caps), TIF(NUTAG_MEDIA_FEATURES, media_features), TIF(NUTAG_SERVICE_ROUTE_ENABLE, service_route_enable), TIF(NUTAG_PATH_ENABLE, path_enable), TIF(NUTAG_AUTH_CACHE, auth_cache), TIF(NUTAG_REFER_EXPIRES, refer_expires), TIF(NUTAG_REFER_WITH_ID, refer_with_id), TIF(NUTAG_SUBSTATE, substate), TIF(NUTAG_SUB_EXPIRES, sub_expires), TIF(SIPTAG_SUPPORTED, supported), TIF_STR(SIPTAG_SUPPORTED_STR, supported), TIF(SIPTAG_ALLOW, allow), TIF_STR(SIPTAG_ALLOW_STR, allow), TIF_STR(NUTAG_APPL_METHOD, appl_method), TIF(SIPTAG_ALLOW_EVENTS, allow_events), TIF_STR(SIPTAG_ALLOW_EVENTS_STR, allow_events), TIF_SIP(SIPTAG_USER_AGENT, user_agent), TIF(SIPTAG_USER_AGENT_STR, user_agent), TIF(NUTAG_USER_AGENT, user_agent), TIF_SIP(SIPTAG_ORGANIZATION, organization), TIF(SIPTAG_ORGANIZATION_STR, organization), TIF(NUTAG_INITIAL_ROUTE, initial_route), TIF_STR(NUTAG_INITIAL_ROUTE_STR, initial_route), TIF(NUTAG_REGISTRAR, registrar), TIF(NUTAG_KEEPALIVE, keepalive), TIF(NUTAG_KEEPALIVE_STREAM, keepalive_stream), TIF(NUTAG_INSTANCE, instance), TIF(NUTAG_M_DISPLAY, m_display), TIF(NUTAG_M_USERNAME, m_username), TIF(NUTAG_M_PARAMS, m_params), TIF(NUTAG_M_FEATURES, m_features), TIF(NUTAG_OUTBOUND, outbound), /* Handle-specific proxy */ TAG_IF(nh != dnh && nhp->nhp_set.nhb_proxy, NUTAG_PROXY(nhp->nhp_proxy)), /* Skip user-agent-level parameters if parameters are for handle only */ TAG_IF(nh != dnh, TAG_NEXT(media_params)), /* Include tag in the list returned to user * if it has been earlier set (by user) */#define GIF(TAG, pref) \ TAG_IF(ngp->ngp_set.ngp_##pref, TAG(ngp->ngp_##pref)) GIF(NUTAG_DETECT_NETWORK_UPDATES, detect_network_updates), GIF(NUTAG_SHUTDOWN_EVENTS, shutdown_events), NTATAG_CONTACT(m),#if HAVE_SOFIA_SMIME NUTAG_SMIME_ENABLE(nua->sm->sm_enable), NUTAG_SMIME_OPT(nua->sm->sm_opt), NUTAG_SMIME_PROTECTION_MODE(nua->sm->sm_protection_mode), NUTAG_SMIME_MESSAGE_DIGEST(nua->sm->sm_message_digest), NUTAG_SMIME_SIGNATURE(nua->sm->sm_signature), NUTAG_SMIME_KEY_ENCRYPTION(nua->sm->sm_key_encryption), NUTAG_SMIME_MESSAGE_ENCRYPTION(nua->sm->sm_message_encryption),#endif NTATAG_UDP_MTU(udp_mtu), NTATAG_MAX_PROCEEDING(max_proceeding), NTATAG_SIP_T1(sip_t1), NTATAG_SIP_T2(sip_t2), NTATAG_SIP_T4(sip_t4), NTATAG_SIP_T1X64(sip_t1x64), NTATAG_DEBUG_DROP_PROB(debug_drop_prob), /* Stack-wide proxy */ NTATAG_DEFAULT_PROXY(proxy), NTATAG_ALIASES(aliases), NTATAG_SIPFLAGS(flags), TAG_NEXT(media_params)); nua_stack_event(nua, nh, NULL, nua_r_get_params, SIP_200_OK, lst); su_home_deinit(tmphome); tl_vfree(media_params); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -