diff options
Diffstat (limited to 'res')
-rw-r--r-- | res/ari/resource_channels.h | 4 | ||||
-rw-r--r-- | res/res_ari_applications.c | 19 | ||||
-rw-r--r-- | res/res_ari_asterisk.c | 19 | ||||
-rw-r--r-- | res/res_ari_bridges.c | 19 | ||||
-rw-r--r-- | res/res_ari_channels.c | 19 | ||||
-rw-r--r-- | res/res_ari_device_states.c | 19 | ||||
-rw-r--r-- | res/res_ari_endpoints.c | 19 | ||||
-rw-r--r-- | res/res_ari_events.c | 1 | ||||
-rw-r--r-- | res/res_ari_mailboxes.c | 19 | ||||
-rw-r--r-- | res/res_ari_playbacks.c | 19 | ||||
-rw-r--r-- | res/res_ari_recordings.c | 19 | ||||
-rw-r--r-- | res/res_ari_sounds.c | 19 | ||||
-rw-r--r-- | res/res_hep.c | 34 | ||||
-rw-r--r-- | res/res_pjsip_sdp_rtp.c | 18 | ||||
-rw-r--r-- | res/res_pjsip_session.c | 137 | ||||
-rw-r--r-- | res/res_stun_monitor.c | 12 |
16 files changed, 244 insertions, 152 deletions
diff --git a/res/ari/resource_channels.h b/res/ari/resource_channels.h index f68db2f5b..b071d08ba 100644 --- a/res/ari/resource_channels.h +++ b/res/ari/resource_channels.h @@ -78,7 +78,7 @@ struct ast_ari_channels_originate_args { const char *other_channel_id; /*! The unique id of the channel which is originating this one. */ const char *originator; - /*! The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names an be found with "core show codecs". */ + /*! The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". */ const char *formats; }; /*! @@ -179,7 +179,7 @@ struct ast_ari_channels_originate_with_id_args { const char *other_channel_id; /*! The unique id of the channel which is originating this one. */ const char *originator; - /*! The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names an be found with "core show codecs". */ + /*! The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs". */ const char *formats; }; /*! diff --git a/res/res_ari_applications.c b/res/res_ari_applications.c index 951ee85b7..21d9f56eb 100644 --- a/res/res_ari_applications.c +++ b/res/res_ari_applications.c @@ -490,19 +490,24 @@ static struct stasis_rest_handlers applications = { .children = { &applications_applicationName, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&applications); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&applications); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&applications); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Stasis application resources", diff --git a/res/res_ari_asterisk.c b/res/res_ari_asterisk.c index 1dbd850bb..89517ccae 100644 --- a/res/res_ari_asterisk.c +++ b/res/res_ari_asterisk.c @@ -1211,19 +1211,24 @@ static struct stasis_rest_handlers asterisk = { .children = { &asterisk_config,&asterisk_info,&asterisk_modules,&asterisk_logging,&asterisk_variable, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&asterisk); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&asterisk); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&asterisk); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Asterisk resources", diff --git a/res/res_ari_bridges.c b/res/res_ari_bridges.c index e61865e31..5402c2b99 100644 --- a/res/res_ari_bridges.c +++ b/res/res_ari_bridges.c @@ -1537,19 +1537,24 @@ static struct stasis_rest_handlers bridges = { .children = { &bridges_bridgeId, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&bridges); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&bridges); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&bridges); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Bridge resources", diff --git a/res/res_ari_channels.c b/res/res_ari_channels.c index 739eb0135..9d218e2be 100644 --- a/res/res_ari_channels.c +++ b/res/res_ari_channels.c @@ -2841,19 +2841,24 @@ static struct stasis_rest_handlers channels = { .children = { &channels_create,&channels_channelId, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&channels); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&channels); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&channels); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Channel resources", diff --git a/res/res_ari_device_states.c b/res/res_ari_device_states.c index b2aea525e..d6de5dff8 100644 --- a/res/res_ari_device_states.c +++ b/res/res_ari_device_states.c @@ -321,19 +321,24 @@ static struct stasis_rest_handlers deviceStates = { .children = { &deviceStates_deviceName, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&deviceStates); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&deviceStates); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&deviceStates); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Device state resources", diff --git a/res/res_ari_endpoints.c b/res/res_ari_endpoints.c index 944146fcb..d96de0877 100644 --- a/res/res_ari_endpoints.c +++ b/res/res_ari_endpoints.c @@ -445,19 +445,24 @@ static struct stasis_rest_handlers endpoints = { .children = { &endpoints_sendMessage,&endpoints_tech, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&endpoints); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&endpoints); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&endpoints); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Endpoint resources", diff --git a/res/res_ari_events.c b/res/res_ari_events.c index 76b791719..3f5b89a44 100644 --- a/res/res_ari_events.c +++ b/res/res_ari_events.c @@ -454,7 +454,6 @@ static int load_module(void) res |= ast_websocket_server_add_protocol2(events.ws_server, protocol); stasis_app_ref(); res |= ast_ari_add_handler(&events); - if (res) { unload_module(); return AST_MODULE_LOAD_DECLINE; diff --git a/res/res_ari_mailboxes.c b/res/res_ari_mailboxes.c index 2eac60987..12c33cd88 100644 --- a/res/res_ari_mailboxes.c +++ b/res/res_ari_mailboxes.c @@ -327,19 +327,24 @@ static struct stasis_rest_handlers mailboxes = { .children = { &mailboxes_mailboxName, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&mailboxes); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&mailboxes); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&mailboxes); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Mailboxes resources", diff --git a/res/res_ari_playbacks.c b/res/res_ari_playbacks.c index 8267a91b5..e2c432db0 100644 --- a/res/res_ari_playbacks.c +++ b/res/res_ari_playbacks.c @@ -279,19 +279,24 @@ static struct stasis_rest_handlers playbacks = { .children = { &playbacks_playbackId, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&playbacks); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&playbacks); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&playbacks); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Playback control resources", diff --git a/res/res_ari_recordings.c b/res/res_ari_recordings.c index e82605c7b..57d80f2e0 100644 --- a/res/res_ari_recordings.c +++ b/res/res_ari_recordings.c @@ -863,19 +863,24 @@ static struct stasis_rest_handlers recordings = { .children = { &recordings_stored,&recordings_live, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&recordings); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&recordings); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&recordings); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Recording resources", diff --git a/res/res_ari_sounds.c b/res/res_ari_sounds.c index fe0692f16..fded7fbce 100644 --- a/res/res_ari_sounds.c +++ b/res/res_ari_sounds.c @@ -209,19 +209,24 @@ static struct stasis_rest_handlers sounds = { .children = { &sounds_soundId, } }; +static int unload_module(void) +{ + ast_ari_remove_handler(&sounds); + stasis_app_unref(); + return 0; +} + static int load_module(void) { int res = 0; stasis_app_ref(); res |= ast_ari_add_handler(&sounds); - return res; -} + if (res) { + unload_module(); + return AST_MODULE_LOAD_DECLINE; + } -static int unload_module(void) -{ - ast_ari_remove_handler(&sounds); - stasis_app_unref(); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "RESTful API module - Sound resources", diff --git a/res/res_hep.c b/res/res_hep.c index 41a558141..25b4d13b1 100644 --- a/res/res_hep.c +++ b/res/res_hep.c @@ -69,7 +69,7 @@ </enumlist> </description> </configOption> - <configOption name="capture_address" default="192.168.1.1:9061"> + <configOption name="capture_address"> <synopsis>The address and port of the Homer server to send packets to.</synopsis> </configOption> <configOption name="capture_password"> @@ -96,8 +96,6 @@ #include <netinet/udp.h> #include <netinet/ip6.h> -#define DEFAULT_HEP_SERVER "" - /*! Generic vendor ID. Used for HEPv3 standard packets */ #define GENERIC_VENDOR_ID 0x0000 @@ -280,11 +278,13 @@ static AO2_GLOBAL_OBJ_STATIC(global_data); static struct ast_taskprocessor *hep_queue_tp; static void *module_config_alloc(void); +static int hepv3_config_pre_apply(void); static void hepv3_config_post_apply(void); /*! \brief Register information about the configs being processed by this module */ CONFIG_INFO_STANDARD(cfg_info, global_config, module_config_alloc, .files = ACO_FILES(&hepv3_conf), + .pre_apply_config = hepv3_config_pre_apply, .post_apply_config = hepv3_config_post_apply, ); @@ -377,6 +377,8 @@ static struct hepv3_runtime_data *hepv3_data_alloc(struct hepv3_global_config *c return NULL; } + data->sockfd = -1; + if (!ast_sockaddr_parse(&data->remote_addr, config->capture_address, PARSE_PORT_REQUIRE)) { ast_log(AST_LOG_WARNING, "Failed to create address from %s\n", config->capture_address); ao2_ref(data, -1); @@ -594,11 +596,33 @@ int hepv3_send_packet(struct hepv3_capture_info *capture_info) } /*! + * \brief Pre-apply callback for the config framework. + * + * This validates that required fields exist and are populated. + */ +static int hepv3_config_pre_apply(void) +{ + struct module_config *config = aco_pending_config(&cfg_info); + + if (!config->general->enabled) { + /* If we're not enabled, we don't care about anything else */ + return 0; + } + + if (ast_strlen_zero(config->general->capture_address)) { + ast_log(AST_LOG_ERROR, "Missing required configuration option 'capture_address'\n"); + return -1; + } + + return 0; +} + +/*! * \brief Post-apply callback for the config framework. * * This will create the run-time information from the supplied * configuration. -*/ + */ static void hepv3_config_post_apply(void) { RAII_VAR(struct module_config *, mod_cfg, ao2_global_obj_ref(global_config), ao2_cleanup); @@ -653,7 +677,7 @@ static int load_module(void) } aco_option_register(&cfg_info, "enabled", ACO_EXACT, global_options, "yes", OPT_BOOL_T, 1, FLDSET(struct hepv3_global_config, enabled)); - aco_option_register(&cfg_info, "capture_address", ACO_EXACT, global_options, DEFAULT_HEP_SERVER, OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_address)); + aco_option_register(&cfg_info, "capture_address", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 1, STRFLDSET(struct hepv3_global_config, capture_address)); aco_option_register(&cfg_info, "capture_password", ACO_EXACT, global_options, "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct hepv3_global_config, capture_password)); aco_option_register(&cfg_info, "capture_id", ACO_EXACT, global_options, "0", OPT_UINT_T, 0, STRFLDSET(struct hepv3_global_config, capture_id)); aco_option_register_custom(&cfg_info, "uuid_type", ACO_EXACT, global_options, "call-id", uuid_type_handler, 0); diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index dfa6957c7..97e365c10 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -453,6 +453,7 @@ static int set_caps(struct ast_sip_session *session, static pjmedia_sdp_attr* generate_rtpmap_attr(struct ast_sip_session *session, pjmedia_sdp_media *media, pj_pool_t *pool, int rtp_code, int asterisk_format, struct ast_format *format, int code) { + extern pj_bool_t pjsip_use_compact_form; pjmedia_sdp_rtpmap rtpmap; pjmedia_sdp_attr *attr = NULL; char tmp[64]; @@ -461,6 +462,11 @@ static pjmedia_sdp_attr* generate_rtpmap_attr(struct ast_sip_session *session, p snprintf(tmp, sizeof(tmp), "%d", rtp_code); pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++], tmp); + + if (rtp_code <= AST_RTP_PT_LAST_STATIC && pjsip_use_compact_form) { + return NULL; + } + rtpmap.pt = media->desc.fmt[media->desc.fmt_count - 1]; rtpmap.clock_rate = ast_rtp_lookup_sample_rate2(asterisk_format, format, code); pj_strdup2(pool, &rtpmap.enc_name, ast_rtp_lookup_mime_subtype2(asterisk_format, format, code, options)); @@ -1260,11 +1266,9 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as continue; } - if (!(attr = generate_rtpmap_attr(session, media, pool, rtp_code, 1, format, 0))) { - ao2_ref(format, -1); - continue; + if ((attr = generate_rtpmap_attr(session, media, pool, rtp_code, 1, format, 0))) { + media->attr[media->attr_count++] = attr; } - media->attr[media->attr_count++] = attr; if ((attr = generate_fmtp_attr(pool, format, rtp_code))) { media->attr[media->attr_count++] = attr; @@ -1293,12 +1297,10 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as continue; } - if (!(attr = generate_rtpmap_attr(session, media, pool, rtp_code, 0, NULL, index))) { - continue; + if ((attr = generate_rtpmap_attr(session, media, pool, rtp_code, 0, NULL, index))) { + media->attr[media->attr_count++] = attr; } - media->attr[media->attr_count++] = attr; - if (index == AST_RTP_DTMF) { snprintf(tmp, sizeof(tmp), "%d 0-16", rtp_code); attr = pjmedia_sdp_attr_create(pool, "fmtp", pj_cstr(&stmp, tmp)); diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 560b3903d..3034652a5 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -1328,9 +1328,7 @@ static void session_destructor(void *obj) ao2_cleanup(session->req_caps); ao2_cleanup(session->direct_media_cap); - if (session->dsp) { - ast_dsp_free(session->dsp); - } + ast_dsp_free(session->dsp); if (session->inv_session) { pjsip_dlg_dec_session(session->inv_session->dlg, &session_module); @@ -1400,6 +1398,7 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, pjsip_inv_session *inv_session, pjsip_rx_data *rdata) { RAII_VAR(struct ast_sip_session *, session, NULL, ao2_cleanup); + struct ast_sip_session *ret_session; struct ast_sip_session_supplement *iter; int dsp_features = 0; @@ -1407,12 +1406,39 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, if (!session) { return NULL; } + AST_LIST_HEAD_INIT(&session->supplements); + AST_LIST_HEAD_INIT_NOLOCK(&session->delayed_requests); + ast_party_id_init(&session->id); + + session->direct_media_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); + if (!session->direct_media_cap) { + return NULL; + } + session->req_caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); + if (!session->req_caps) { + return NULL; + } session->datastores = ao2_container_alloc(DATASTORE_BUCKETS, datastore_hash, datastore_cmp); if (!session->datastores) { return NULL; } + if (endpoint->dtmf == AST_SIP_DTMF_INBAND || endpoint->dtmf == AST_SIP_DTMF_AUTO) { + dsp_features |= DSP_FEATURE_DIGIT_DETECT; + } + if (endpoint->faxdetect) { + dsp_features |= DSP_FEATURE_FAX_DETECT; + } + if (dsp_features) { + session->dsp = ast_dsp_new(); + if (!session->dsp) { + return NULL; + } + + ast_dsp_set_features(session->dsp, dsp_features); + } + session->endpoint = ao2_bump(endpoint); session->media = ao2_container_alloc(MEDIA_BUCKETS, session_media_hash, session_media_cmp); @@ -1449,30 +1475,6 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, inv_session->mod_data[session_module.id] = ao2_bump(session); session->contact = ao2_bump(contact); session->inv_session = inv_session; - session->req_caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); - if (!session->req_caps) { - /* Release the ref held by session->inv_session */ - ao2_ref(session, -1); - return NULL; - } - - if ((endpoint->dtmf == AST_SIP_DTMF_INBAND) || (endpoint->dtmf == AST_SIP_DTMF_AUTO)) { - dsp_features |= DSP_FEATURE_DIGIT_DETECT; - } - - if (endpoint->faxdetect) { - dsp_features |= DSP_FEATURE_FAX_DETECT; - } - - if (dsp_features) { - if (!(session->dsp = ast_dsp_new())) { - /* Release the ref held by session->inv_session */ - ao2_ref(session, -1); - return NULL; - } - - ast_dsp_set_features(session->dsp, dsp_features); - } if (add_supplements(session)) { /* Release the ref held by session->inv_session */ @@ -1484,11 +1486,11 @@ struct ast_sip_session *ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, iter->session_begin(session); } } - session->direct_media_cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); - AST_LIST_HEAD_INIT_NOLOCK(&session->delayed_requests); - ast_party_id_init(&session->id); - ao2_ref(session, +1); - return session; + + /* Avoid unnecessary ref manipulation to return a session */ + ret_session = session; + session = NULL; + return ret_session; } /*! \brief struct controlling the suspension of the session's serializer. */ @@ -1704,6 +1706,7 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint pjsip_dialog *dlg; struct pjsip_inv_session *inv_session; RAII_VAR(struct ast_sip_session *, session, NULL, ao2_cleanup); + struct ast_sip_session *ret_session; /* If no location has been provided use the AOR list from the endpoint itself */ if (location || !contact) { @@ -1760,14 +1763,17 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint if (ast_format_cap_count(req_caps)) { /* get joint caps between req_caps and endpoint caps */ struct ast_format_cap *joint_caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); - ast_format_cap_get_compatible(req_caps, session->endpoint->media.codecs, joint_caps); + + ast_format_cap_get_compatible(req_caps, endpoint->media.codecs, joint_caps); /* if joint caps */ if (ast_format_cap_count(joint_caps)) { /* copy endpoint caps into session->req_caps */ - ast_format_cap_append_from_cap(session->req_caps, session->endpoint->media.codecs, AST_MEDIA_TYPE_UNKNOWN); + ast_format_cap_append_from_cap(session->req_caps, + endpoint->media.codecs, AST_MEDIA_TYPE_UNKNOWN); /* replace instances of joint caps equivalents in session->req_caps */ - ast_format_cap_replace_from_cap(session->req_caps, joint_caps, AST_MEDIA_TYPE_UNKNOWN); + ast_format_cap_replace_from_cap(session->req_caps, joint_caps, + AST_MEDIA_TYPE_UNKNOWN); } ao2_cleanup(joint_caps); } @@ -1781,8 +1787,10 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint return NULL; } - ao2_ref(session, +1); - return session; + /* Avoid unnecessary ref manipulation to return a session */ + ret_session = session; + session = NULL; + return ret_session; } void ast_sip_session_terminate(struct ast_sip_session *session, int response) @@ -2142,12 +2150,29 @@ static int new_invite(void *data) goto end; }; - if ((sdp_info = pjsip_rdata_get_sdp_info(invite->rdata)) && (sdp_info->sdp_err == PJ_SUCCESS) && sdp_info->sdp) { + pjsip_timer_setting_default(&timer); + timer.min_se = invite->session->endpoint->extensions.timer.min_se; + timer.sess_expires = invite->session->endpoint->extensions.timer.sess_expires; + pjsip_timer_init_session(invite->session->inv_session, &timer); + + /* + * At this point, we've verified what we can that won't take awhile, + * so let's go ahead and send a 100 Trying out to stop any + * retransmissions. + */ + if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 100, NULL, NULL, &tdata) != PJ_SUCCESS) { + pjsip_inv_terminate(invite->session->inv_session, 500, PJ_TRUE); + goto end; + } + ast_sip_session_send_response(invite->session, tdata); + + sdp_info = pjsip_rdata_get_sdp_info(invite->rdata); + if (sdp_info && (sdp_info->sdp_err == PJ_SUCCESS) && sdp_info->sdp) { if (handle_incoming_sdp(invite->session, sdp_info->sdp)) { - if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 488, NULL, NULL, &tdata) == PJ_SUCCESS) { + tdata = NULL; + if (pjsip_inv_end_session(invite->session->inv_session, 488, NULL, &tdata) == PJ_SUCCESS + && tdata) { ast_sip_session_send_response(invite->session, tdata); - } else { - pjsip_inv_terminate(invite->session->inv_session, 488, PJ_TRUE); } goto end; } @@ -2160,33 +2185,21 @@ static int new_invite(void *data) /* If we were unable to create a local SDP terminate the session early, it won't go anywhere */ if (!local) { - if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 500, NULL, NULL, &tdata) == PJ_SUCCESS) { + tdata = NULL; + if (pjsip_inv_end_session(invite->session->inv_session, 500, NULL, &tdata) == PJ_SUCCESS + && tdata) { ast_sip_session_send_response(invite->session, tdata); - } else { - pjsip_inv_terminate(invite->session->inv_session, 500, PJ_TRUE); } goto end; - } else { - pjsip_inv_set_local_sdp(invite->session->inv_session, local); - pjmedia_sdp_neg_set_prefer_remote_codec_order(invite->session->inv_session->neg, PJ_FALSE); -#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS - if (!invite->session->endpoint->preferred_codec_only) { - pjmedia_sdp_neg_set_answer_multiple_codecs(invite->session->inv_session->neg, PJ_TRUE); - } -#endif } - pjsip_timer_setting_default(&timer); - timer.min_se = invite->session->endpoint->extensions.timer.min_se; - timer.sess_expires = invite->session->endpoint->extensions.timer.sess_expires; - pjsip_timer_init_session(invite->session->inv_session, &timer); - - /* At this point, we've verified what we can, so let's go ahead and send a 100 Trying out */ - if (pjsip_inv_initial_answer(invite->session->inv_session, invite->rdata, 100, NULL, NULL, &tdata) != PJ_SUCCESS) { - pjsip_inv_terminate(invite->session->inv_session, 500, PJ_TRUE); - goto end; + pjsip_inv_set_local_sdp(invite->session->inv_session, local); + pjmedia_sdp_neg_set_prefer_remote_codec_order(invite->session->inv_session->neg, PJ_FALSE); +#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS + if (!invite->session->endpoint->preferred_codec_only) { + pjmedia_sdp_neg_set_answer_multiple_codecs(invite->session->inv_session->neg, PJ_TRUE); } - ast_sip_session_send_response(invite->session, tdata); +#endif handle_incoming_request(invite->session, invite->rdata); diff --git a/res/res_stun_monitor.c b/res/res_stun_monitor.c index 46deaff75..08d1d6615 100644 --- a/res/res_stun_monitor.c +++ b/res/res_stun_monitor.c @@ -269,7 +269,7 @@ static int stun_start_monitor(void) * \retval 0 on success. * \retval -1 on error. */ -static int setup_stunaddr(const char *value) +static int setup_stunaddr(const char *value, int reload) { char *val; char *host_str; @@ -305,8 +305,12 @@ static int setup_stunaddr(const char *value) stun_addr.ss.ss_family = AF_INET; if (ast_get_ip(&stun_addr, host_str)) { ast_log(LOG_WARNING, "Unable to lookup STUN server '%s'\n", host_str); - ast_free(host_str); - return -1; + + /* Only treat this as fatal if we are reloading */ + if (reload) { + ast_free(host_str); + return -1; + } } /* Save STUN server information. */ @@ -348,7 +352,7 @@ static int load_config(int startup) for (v = ast_variable_browse(cfg, "general"); v; v = v->next) { if (!strcasecmp(v->name, "stunaddr")) { - if (setup_stunaddr(v->value)) { + if (setup_stunaddr(v->value, !startup)) { ast_log(LOG_WARNING, "Invalid STUN server address: %s at line %d\n", v->value, v->lineno); } |