int video = FALSE;
int image = FALSE;
int text = FALSE;
+ int processed_crypto = FALSE;
char protocol[5] = {0,};
int x;
case 'a':
/* Audio specific scanning */
if (audio) {
- if (process_sdp_a_sendonly(value, &sendonly))
+ if (process_sdp_a_sendonly(value, &sendonly)) {
processed = TRUE;
- else if (process_crypto(p, p->rtp, &p->srtp, value))
+ } else if (!processed_crypto && process_crypto(p, p->rtp, &p->srtp, value)) {
+ processed_crypto = TRUE;
processed = TRUE;
- else if (process_sdp_a_audio(value, p, &newaudiortp, &last_rtpmap_codec))
+ } else if (process_sdp_a_audio(value, p, &newaudiortp, &last_rtpmap_codec)) {
processed = TRUE;
+ }
}
/* Video specific scanning */
else if (video) {
- if (process_sdp_a_sendonly(value, &vsendonly))
+ if (process_sdp_a_sendonly(value, &vsendonly)) {
processed = TRUE;
- else if (process_crypto(p, p->vrtp, &p->vsrtp, value))
+ } else if (!processed_crypto && process_crypto(p, p->vrtp, &p->vsrtp, value)) {
+ processed_crypto = TRUE;
processed = TRUE;
- else if (process_sdp_a_video(value, p, &newvideortp, &last_rtpmap_codec))
+ } else if (process_sdp_a_video(value, p, &newvideortp, &last_rtpmap_codec)) {
processed = TRUE;
+ }
}
/* Text (T.140) specific scanning */
else if (text) {
- if (process_sdp_a_text(value, p, &newtextrtp, red_fmtp, &red_num_gen, red_data_pt, &last_rtpmap_codec))
+ if (process_sdp_a_text(value, p, &newtextrtp, red_fmtp, &red_num_gen, red_data_pt, &last_rtpmap_codec)) {
processed = TRUE;
- else if (process_crypto(p, p->trtp, &p->tsrtp, value))
+ } else if (!processed_crypto && process_crypto(p, p->trtp, &p->tsrtp, value)) {
+ processed_crypto = TRUE;
processed = TRUE;
+ }
}
/* Image (T.38 FAX) specific scanning */
else if (image) {
}
if (!ast_strlen_zero(peer->cid_name))
ast_string_field_set(p, cid_name, peer->cid_name);
- if (!ast_strlen_zero(peer->cid_tag))
- ast_string_field_set(p, cid_tag, peer->cid_tag);
if (peer->callingpres)
p->callingpres = peer->callingpres;
}
+ if (!ast_strlen_zero(peer->cid_tag)) {
+ ast_string_field_set(p, cid_tag, peer->cid_tag);
+ }
ast_string_field_set(p, fullcontact, peer->fullcontact);
if (!ast_strlen_zero(peer->context)) {
} else if (!strcasecmp(word, "nonat")) {
ast_set_flag(&flags[0], SIP_DIRECT_MEDIA);
ast_clear_flag(&flags[0], SIP_DIRECT_MEDIA_NAT);
+ } else if (!strcasecmp(word, "outgoing")) {
+ ast_set_flag(&flags[0], SIP_DIRECT_MEDIA);
+ ast_set_flag(&mask[2], SIP_PAGE3_DIRECT_MEDIA_OUTGOING);
+ ast_set_flag(&flags[2], SIP_PAGE3_DIRECT_MEDIA_OUTGOING);
} else {
ast_log(LOG_WARNING, "Unknown directmedia mode '%s' on line %d\n", v->value, v->lineno);
}
p->redircodecs = codecs;
changed = 1;
}
+
+ if (ast_test_flag(&p->flags[2], SIP_PAGE3_DIRECT_MEDIA_OUTGOING) && !p->outgoing_call) {
+ /* We only wish to withhold sending the initial direct media reinvite on the incoming dialog.
+ * Further direct media reinvites beyond the initial should be sent. In order to allow further
+ * direct media reinvites to be sent, we clear this flag.
+ */
+ ast_clear_flag(&p->flags[2], SIP_PAGE3_DIRECT_MEDIA_OUTGOING);
+ sip_pvt_unlock(p);
+ ast_channel_unlock(chan);
+ return 0;
+ }
+
if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER) && !ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
if (chan->_state != AST_STATE_UP) { /* We are in early state */
if (p->do_history)
}
}
- /* For now, when we receive an INVITE just take the first successful crypto line */
- if ((*srtp)->crypto && !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
- ast_debug(3, "We've already processed a crypto attribute, skipping '%s'\n", a);
- return FALSE;
- }
-
if (!(*srtp)->crypto && !((*srtp)->crypto = sdp_crypto_setup())) {
return FALSE;
}
}
}
+/* Note that no 'chan_fixup' function is provided for this datastore type,
+ * because the channels that will use it will never be involved in masquerades.
+ */
+static const struct ast_datastore_info fabricated_channel_datastore = {
+ .type = "CEL fabricated channel",
+ .destroy = ast_free_ptr,
+};
+
struct ast_channel *ast_cel_fabricate_channel_from_event(const struct ast_event *event)
{
struct varshead *headp;
struct ast_cel_event_record record = {
.version = AST_CEL_EVENT_RECORD_VERSION,
};
+ struct ast_datastore *datastore;
+ char *app_data;
/* do not call ast_channel_alloc because this is not really a real channel */
if (!(tchan = ast_dummy_channel_alloc())) {
AST_LIST_INSERT_HEAD(headp, newvariable, entries);
}
- tchan->appl = ast_strdup(record.application_name);
- tchan->data = ast_strdup(record.application_data);
tchan->amaflags = record.amaflag;
+ /* We need to store an 'application name' and 'application
+ * data' on the channel for logging purposes, but the channel
+ * structure only provides a place to store pointers, and it
+ * expects these pointers to be pointing to data that does not
+ * need to be freed. This means that the channel's destructor
+ * does not attempt to free any storage that these pointers
+ * point to. However, we can't provide data in that form directly for
+ * these structure members. In order to ensure that these data
+ * elements have a lifetime that matches the channel's
+ * lifetime, we'll put them in a datastore attached to the
+ * channel, and set's the channel's pointers to point into the
+ * datastore. The datastore will then be automatically destroyed
+ * when the channel is destroyed.
+ */
+
+ if (!(datastore = ast_datastore_alloc(&fabricated_channel_datastore, NULL))) {
+ ast_channel_unref(tchan);
+ return NULL;
+ }
+
+ if (!(app_data = ast_malloc(strlen(record.application_name) + strlen(record.application_data) + 2))) {
+ ast_datastore_free(datastore);
+ ast_channel_unref(tchan);
+ return NULL;
+ }
+
+ tchan->appl = app_data;
+ tchan->data = app_data + strlen(record.application_name) + 1;
+
+ strcpy((char *) tchan->appl, record.application_name);
+ strcpy((char *) tchan->data, record.application_data);
+ datastore->data = app_data;
+ ast_channel_datastore_add(tchan, datastore);
+
return tchan;
}