Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • voice/asterisk
1 result
Show changes
Commits on Source (3)
...@@ -246,7 +246,7 @@ struct ast_sip_session { ...@@ -246,7 +246,7 @@ struct ast_sip_session {
int ring_cw; int ring_cw;
int early_media; int early_media;
/*! The working transport of the session */ /*! The working transport of the session */
enum ast_transport transport_type; struct ast_sip_transport_state *transport_state;
}; };
typedef int (*ast_sip_session_request_creation_cb)(struct ast_sip_session *session, pjsip_tx_data *tdata); typedef int (*ast_sip_session_request_creation_cb)(struct ast_sip_session *session, pjsip_tx_data *tdata);
......
...@@ -1137,4 +1137,6 @@ int ast_check_command_in_path(const char *cmd); ...@@ -1137,4 +1137,6 @@ int ast_check_command_in_path(const char *cmd);
*/ */
void ast_ubus_free_context(struct ubus_context *ctx); void ast_ubus_free_context(struct ubus_context *ctx);
void ast_send_network_info_ubus_event(int enabled, char* protocol, char* addr_buf, int port);
#endif /* _ASTERISK_UTILS_H */ #endif /* _ASTERISK_UTILS_H */
...@@ -81,6 +81,7 @@ static char base64[64]; ...@@ -81,6 +81,7 @@ static char base64[64];
static char base64url[64]; static char base64url[64];
static char b2a[256]; static char b2a[256];
static char b2a_url[256]; static char b2a_url[256];
static const char broadcast_path[] = "voice.sip.data";
AST_THREADSTORAGE(inet_ntoa_buf); AST_THREADSTORAGE(inet_ntoa_buf);
...@@ -3266,3 +3267,33 @@ void ast_ubus_free_context(struct ubus_context *ctx) ...@@ -3266,3 +3267,33 @@ void ast_ubus_free_context(struct ubus_context *ctx)
free(ctx->msgbuf.data); free(ctx->msgbuf.data);
free(ctx); free(ctx);
} }
void ast_send_network_info_ubus_event(int enabled, char* protocol, char* addr_buf, int port)
{
struct blob_buf blob;
struct ubus_context *ubusContext = NULL;
ubusContext = ubus_connect(NULL);
if(!ubusContext){
return;
}
memset(&blob, 0, sizeof(blob));
if(blob_buf_init(&blob, 0)) {
ast_ubus_free_context(ubusContext);
return;
}
blobmsg_add_u8(&blob, "enabled", enabled);
blobmsg_add_string(&blob, "protocol", protocol);
blobmsg_add_string(&blob, "ip", addr_buf);
blobmsg_add_u32(&blob, "port", port);
if(ubus_send_event(ubusContext, broadcast_path, blob.head) != UBUS_STATUS_OK)
ast_log(LOG_ERROR,"Error sending ubus message\n");
ast_ubus_free_context(ubusContext);
blob_buf_free(&blob);
return;
}
...@@ -851,7 +851,7 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj) ...@@ -851,7 +851,7 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
if (!transport->enable) { if (!transport->enable) {
ast_log(LOG_WARNING, "TCP transport is disabled\n"); ast_log(LOG_WARNING, "TCP transport is disabled\n");
} else } else {
res = pjsip_tcp_transport_start3(ast_sip_get_pjsip_endpoint(), &cfg, res = pjsip_tcp_transport_start3(ast_sip_get_pjsip_endpoint(), &cfg,
&temp_state->state->factory); &temp_state->state->factory);
} }
......
...@@ -327,6 +327,12 @@ static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata) ...@@ -327,6 +327,12 @@ static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata)
(int) (tdata->buf.end - tdata->buf.start), tdata->buf.start); (int) (tdata->buf.end - tdata->buf.start), tdata->buf.start);
} }
if (tdata->msg->type == PJSIP_REQUEST_MSG) {
char addr_buf[AST_SOCKADDR_BUFLEN] = {'\0'};
pj_sockaddr_print(&tdata->tp_info.dst_addr, addr_buf, sizeof(addr_buf), 0);
ast_send_network_info_ubus_event(1, "sip", addr_buf, tdata->tp_info.dst_port);
}
if (default_logger->log_to_pcap) { if (default_logger->log_to_pcap) {
pjsip_logger_write_to_pcap(default_logger, tdata->buf.start, (int) (tdata->buf.cur - tdata->buf.start), pjsip_logger_write_to_pcap(default_logger, tdata->buf.start, (int) (tdata->buf.cur - tdata->buf.start),
NULL, &tdata->tp_info.dst_addr); NULL, &tdata->tp_info.dst_addr);
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "asterisk/threadstorage.h" #include "asterisk/threadstorage.h"
#include "asterisk/threadpool.h" #include "asterisk/threadpool.h"
#include "asterisk/statsd.h" #include "asterisk/statsd.h"
#include "res_pjsip/include/res_pjsip_private.h"
#include "asterisk/vector.h" #include "asterisk/vector.h"
#include "asterisk/pbx.h" #include "asterisk/pbx.h"
...@@ -1185,6 +1184,8 @@ static int sip_outbound_registration_send_ubus_event(char *ev_name, int time, ch ...@@ -1185,6 +1184,8 @@ static int sip_outbound_registration_send_ubus_event(char *ev_name, int time, ch
static void schedule_retry(struct registration_response *response, unsigned int interval, static void schedule_retry(struct registration_response *response, unsigned int interval,
const char *server_uri, const char *client_uri, const char *client_num) const char *server_uri, const char *client_uri, const char *client_num)
{ {
char addr_buf[AST_SOCKADDR_BUFLEN] = {'\0'};
update_client_state_status(response->client_state, SIP_REGISTRATION_REJECTED_TEMPORARY); update_client_state_status(response->client_state, SIP_REGISTRATION_REJECTED_TEMPORARY);
schedule_registration(response->client_state, interval); schedule_registration(response->client_state, interval);
...@@ -1200,6 +1201,8 @@ static void schedule_retry(struct registration_response *response, unsigned int ...@@ -1200,6 +1201,8 @@ static void schedule_retry(struct registration_response *response, unsigned int
ast_log_dt(LOG_EVENT_CODE_V002, client_num, "No response received"); ast_log_dt(LOG_EVENT_CODE_V002, client_num, "No response received");
} }
sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri); sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri);
pj_sockaddr_print(&response->rdata->pkt_info.src_addr, addr_buf, sizeof(addr_buf), 0);
ast_send_network_info_ubus_event(0, "sip", addr_buf, response->rdata->pkt_info.src_port);
} }
static int reregister_immediately_cb(void *obj) static int reregister_immediately_cb(void *obj)
...@@ -1541,6 +1544,7 @@ static int handle_registration_response(void *data) ...@@ -1541,6 +1544,7 @@ static int handle_registration_response(void *data)
char c_uri[PJSIP_MAX_URL_SIZE]; char c_uri[PJSIP_MAX_URL_SIZE];
char *client_num = NULL; char *client_num = NULL;
char * saveptr = NULL; char * saveptr = NULL;
char addr_buf[AST_SOCKADDR_BUFLEN] = {'\0'};
if (client_state->status == SIP_REGISTRATION_STOPPED) { if (client_state->status == SIP_REGISTRATION_STOPPED) {
ao2_ref(response, -1); ao2_ref(response, -1);
...@@ -1628,6 +1632,8 @@ static int handle_registration_response(void *data) ...@@ -1628,6 +1632,8 @@ static int handle_registration_response(void *data)
ast_log_dt(LOG_EVENT_CODE_V002, client_num, "Bad response received"); ast_log_dt(LOG_EVENT_CODE_V002, client_num, "Bad response received");
update_client_state_status(client_state, SIP_REGISTRATION_REJECTED_TEMPORARY); update_client_state_status(client_state, SIP_REGISTRATION_REJECTED_TEMPORARY);
sip_outbound_registration_send_ubus_event("UNREGISTERED", response->expiration, client_uri); sip_outbound_registration_send_ubus_event("UNREGISTERED", response->expiration, client_uri);
pj_sockaddr_print(&response->rdata->pkt_info.src_addr, addr_buf, sizeof(addr_buf), 0);
ast_send_network_info_ubus_event(0, "sip", addr_buf, response->rdata->pkt_info.src_port);
client_state->registration_resend_timer_id = ast_sched_add(sched, waiting_time * 1000, registration_resend, response); client_state->registration_resend_timer_id = ast_sched_add(sched, waiting_time * 1000, registration_resend, response);
return 0; return 0;
...@@ -1749,6 +1755,8 @@ static int handle_registration_response(void *data) ...@@ -1749,6 +1755,8 @@ static int handle_registration_response(void *data)
client_state->is494=0; client_state->is494=0;
update_client_state_status(client_state, SIP_REGISTRATION_UNREGISTERED); update_client_state_status(client_state, SIP_REGISTRATION_UNREGISTERED);
sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri); sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri);
pj_sockaddr_print(&response->rdata->pkt_info.src_addr, addr_buf, sizeof(addr_buf), 0);
ast_send_network_info_ubus_event(0, "sip", addr_buf, response->rdata->pkt_info.src_port);
if (PJSIP_TRANSPORT_IS_RELIABLE(response->rdata->tp_info.transport)) { if (PJSIP_TRANSPORT_IS_RELIABLE(response->rdata->tp_info.transport)) {
ast_sip_transport_monitor_unregister_key(response->transport_key, ast_sip_transport_monitor_unregister_key(response->transport_key,
registration_transport_shutdown_cb, client_state->registration_name, registration_transport_shutdown_cb, client_state->registration_name,
...@@ -1769,6 +1777,8 @@ static int handle_registration_response(void *data) ...@@ -1769,6 +1777,8 @@ static int handle_registration_response(void *data)
/* 494 loop detected! This is fatal! */ /* 494 loop detected! This is fatal! */
update_client_state_status(client_state, SIP_REGISTRATION_REJECTED_PERMANENT); update_client_state_status(client_state, SIP_REGISTRATION_REJECTED_PERMANENT);
sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri); sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri);
pj_sockaddr_print(&response->rdata->pkt_info.src_addr, addr_buf, sizeof(addr_buf), 0);
ast_send_network_info_ubus_event(0, "sip", addr_buf, response->rdata->pkt_info.src_port);
/* reset is494 */ /* reset is494 */
client_state->is494=0; client_state->is494=0;
} else { } else {
...@@ -1788,6 +1798,8 @@ static int handle_registration_response(void *data) ...@@ -1788,6 +1798,8 @@ static int handle_registration_response(void *data)
client_state->failover_retries >= client_state->failover_max_retries) { client_state->failover_retries >= client_state->failover_max_retries) {
update_client_state_status(client_state, SIP_REGISTRATION_REJECTED_PERMANENT); update_client_state_status(client_state, SIP_REGISTRATION_REJECTED_PERMANENT);
sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri); sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri);
pj_sockaddr_print(&response->rdata->pkt_info.src_addr, addr_buf, sizeof(addr_buf), 0);
ast_send_network_info_ubus_event(0, "sip", addr_buf, response->rdata->pkt_info.src_port);
ast_log(LOG_WARNING, "Maximum failover retries reached when attempting outbound registration to '%s' with client '%s', stopping registration attempt\n", ast_log(LOG_WARNING, "Maximum failover retries reached when attempting outbound registration to '%s' with client '%s', stopping registration attempt\n",
server_uri, client_uri); server_uri, client_uri);
ast_log_dt(LOG_EVENT_CODE_V002, client_num, "Maximum failover retries reached"); ast_log_dt(LOG_EVENT_CODE_V002, client_num, "Maximum failover retries reached");
...@@ -1809,6 +1821,8 @@ static int handle_registration_response(void *data) ...@@ -1809,6 +1821,8 @@ static int handle_registration_response(void *data)
/* If we received enough temporal responses to exceed our maximum give up permanently */ /* If we received enough temporal responses to exceed our maximum give up permanently */
update_client_state_status(client_state, SIP_REGISTRATION_REJECTED_PERMANENT); update_client_state_status(client_state, SIP_REGISTRATION_REJECTED_PERMANENT);
sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri); sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri);
pj_sockaddr_print(&response->rdata->pkt_info.src_addr, addr_buf, sizeof(addr_buf), 0);
ast_send_network_info_ubus_event(0, "sip", addr_buf, response->rdata->pkt_info.src_port);
ast_log(LOG_WARNING, "Maximum retries reached when attempting outbound registration to '%s' with client '%s', stopping registration attempt\n", ast_log(LOG_WARNING, "Maximum retries reached when attempting outbound registration to '%s' with client '%s', stopping registration attempt\n",
server_uri, client_uri); server_uri, client_uri);
ast_log_dt(LOG_EVENT_CODE_V002, client_num, "Maximum retries reached"); ast_log_dt(LOG_EVENT_CODE_V002, client_num, "Maximum retries reached");
...@@ -1869,6 +1883,8 @@ static int handle_registration_response(void *data) ...@@ -1869,6 +1883,8 @@ static int handle_registration_response(void *data)
ast_log(LOG_WARNING, "Fatal registration attempt to '%s', stopping outbound registration\n", client_uri); ast_log(LOG_WARNING, "Fatal registration attempt to '%s', stopping outbound registration\n", client_uri);
} }
} }
pj_sockaddr_print(&response->rdata->pkt_info.src_addr, addr_buf, sizeof(addr_buf), 0);
ast_send_network_info_ubus_event(0, "sip", addr_buf, response->rdata->pkt_info.src_port);
ast_log_dt(LOG_EVENT_CODE_V002, client_num, "Fatal response received"); ast_log_dt(LOG_EVENT_CODE_V002, client_num, "Fatal response received");
} }
......
...@@ -998,7 +998,7 @@ static enum ast_sip_session_media_encryption check_endpoint_media_transport( ...@@ -998,7 +998,7 @@ static enum ast_sip_session_media_encryption check_endpoint_media_transport(
return AST_SIP_MEDIA_TRANSPORT_INVALID; return AST_SIP_MEDIA_TRANSPORT_INVALID;
} }
if (session->transport_type == AST_TRANSPORT_TLS || session->transport_type == AST_TRANSPORT_WSS) if (session->transport_state->type == AST_TRANSPORT_TLS || session->transport_state->type == AST_TRANSPORT_WSS)
local_encryption = endpoint->media.rtp.encryption; local_encryption = endpoint->media.rtp.encryption;
incoming_encryption = get_media_encryption_type(stream->desc.transport, stream, &optimistic); incoming_encryption = get_media_encryption_type(stream->desc.transport, stream, &optimistic);
...@@ -1178,8 +1178,8 @@ static int setup_media_encryption(struct ast_sip_session *session, ...@@ -1178,8 +1178,8 @@ static int setup_media_encryption(struct ast_sip_session *session,
const struct pjmedia_sdp_media *stream) const struct pjmedia_sdp_media *stream)
{ {
// Only enable media encryption for TLS/WSS transport // Only enable media encryption for TLS/WSS transport
if (session->transport_type != AST_TRANSPORT_TLS && if (session->transport_state->type != AST_TRANSPORT_TLS &&
session->transport_type != AST_TRANSPORT_WSS) session->transport_state->type != AST_TRANSPORT_WSS)
return 0; return 0;
switch (session_media->encryption) { switch (session_media->encryption) {
...@@ -1632,8 +1632,8 @@ static int add_crypto_to_stream(struct ast_sip_session *session, ...@@ -1632,8 +1632,8 @@ static int add_crypto_to_stream(struct ast_sip_session *session,
static const pj_str_t STR_MEDSECREQ = { "requested", 9 }; static const pj_str_t STR_MEDSECREQ = { "requested", 9 };
enum ast_rtp_dtls_setup setup; enum ast_rtp_dtls_setup setup;
if (session->transport_type != AST_TRANSPORT_TLS && if (session->transport_state->type != AST_TRANSPORT_TLS &&
session->transport_type != AST_TRANSPORT_WSS) session->transport_state->type != AST_TRANSPORT_WSS)
return 0; return 0;
switch (session_media->encryption) { switch (session_media->encryption) {
...@@ -1856,8 +1856,8 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as ...@@ -1856,8 +1856,8 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
} else { } else {
media->desc.transport = pj_str(ast_sdp_get_rtp_profile( media->desc.transport = pj_str(ast_sdp_get_rtp_profile(
/* Optimistic encryption places crypto in the normal RTP/AVP profile */ /* Optimistic encryption places crypto in the normal RTP/AVP profile */
(session->transport_type == AST_TRANSPORT_TLS || (session->transport_state->type == AST_TRANSPORT_TLS ||
session->transport_type == AST_TRANSPORT_WSS) && session->transport_state->type == AST_TRANSPORT_WSS) &&
!session->endpoint->media.rtp.encryption_optimistic && !session->endpoint->media.rtp.encryption_optimistic &&
(session_media->encryption == AST_SIP_MEDIA_ENCRYPT_SDES), (session_media->encryption == AST_SIP_MEDIA_ENCRYPT_SDES),
session_media->rtp, session->endpoint->media.rtp.use_avpf, session_media->rtp, session->endpoint->media.rtp.use_avpf,
......
...@@ -2514,7 +2514,7 @@ static int sip_session_refresh(struct ast_sip_session *session, ...@@ -2514,7 +2514,7 @@ static int sip_session_refresh(struct ast_sip_session *session,
} }
} }
if ((session->transport_type == AST_TRANSPORT_TLS || session->transport_type == AST_TRANSPORT_WSS) && if ((session->transport_state->type == AST_TRANSPORT_TLS || session->transport_state->type == AST_TRANSPORT_WSS) &&
session->endpoint->mediasec && session->endpoint->media.rtp.encryption == AST_SIP_MEDIA_ENCRYPT_SDES) { session->endpoint->mediasec && session->endpoint->media.rtp.encryption == AST_SIP_MEDIA_ENCRYPT_SDES) {
ast_debug(3, "Session Refresh: Adding MEDIASEC headers\n"); ast_debug(3, "Session Refresh: Adding MEDIASEC headers\n");
...@@ -2941,7 +2941,7 @@ int ast_sip_session_create_invite(struct ast_sip_session *session, pjsip_tx_data ...@@ -2941,7 +2941,7 @@ int ast_sip_session_create_invite(struct ast_sip_session *session, pjsip_tx_data
SCOPE_EXIT_RTN_VALUE(-1, "pjsip_inv_invite failed\n"); SCOPE_EXIT_RTN_VALUE(-1, "pjsip_inv_invite failed\n");
} }
if ((session->transport_type == AST_TRANSPORT_TLS || session->transport_type == AST_TRANSPORT_WSS) && if ((session->transport_state->type == AST_TRANSPORT_TLS || session->transport_state->type == AST_TRANSPORT_WSS) &&
session->endpoint->mediasec && session->endpoint->media.rtp.encryption == AST_SIP_MEDIA_ENCRYPT_SDES) { session->endpoint->mediasec && session->endpoint->media.rtp.encryption == AST_SIP_MEDIA_ENCRYPT_SDES) {
ast_debug(3, "INVITE: Adding MEDIASEC headers\n"); ast_debug(3, "INVITE: Adding MEDIASEC headers\n");
...@@ -3527,7 +3527,7 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint ...@@ -3527,7 +3527,7 @@ struct ast_sip_session *ast_sip_session_create_outgoing(struct ast_sip_endpoint
pjsip_inv_terminate(inv_session, 500, PJ_FALSE); pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
return NULL; return NULL;
} }
session->transport_type = transport_state->type; session->transport_state = transport_state;
ast_party_id_copy(&session->id, &endpoint->id.self); ast_party_id_copy(&session->id, &endpoint->id.self);
...@@ -4403,7 +4403,7 @@ static void handle_new_invite_request(pjsip_rx_data *rdata) ...@@ -4403,7 +4403,7 @@ static void handle_new_invite_request(pjsip_rx_data *rdata)
SCOPE_EXIT_RTN("Couldn't create session\n"); SCOPE_EXIT_RTN("Couldn't create session\n");
} }
session->call_direction = AST_SIP_SESSION_INCOMING_CALL; session->call_direction = AST_SIP_SESSION_INCOMING_CALL;
session->transport_type = transport_state->type; session->transport_state = transport_state;
/* /*
* The current thread is supposed be the session serializer to prevent * The current thread is supposed be the session serializer to prevent
...@@ -4970,6 +4970,32 @@ static int session_end_completion(void *vsession) ...@@ -4970,6 +4970,32 @@ static int session_end_completion(void *vsession)
return 0; return 0;
} }
static struct ast_sip_transport_state* get_udp_transport_state()
{
struct ao2_container *transport_states = ast_sip_get_transport_states();
struct ast_sip_transport_state *state;
struct ao2_iterator it;
if (!transport_states)
return NULL;
it = ao2_iterator_init(transport_states, 0);
while (state = ao2_iterator_next(&it)) {
if (!state->flow && state->type == AST_TRANSPORT_UDP) {
ast_debug(3, "found UDP transport '%s'\n", state->id);
ao2_ref(state, -1);
break;
}
ao2_ref(state, -1);
}
ao2_iterator_destroy(&it);
ao2_ref(transport_states, -1);
return state;
}
static int sip_inv_transport2(pjsip_inv_session *inv, pjsip_event *e) static int sip_inv_transport2(pjsip_inv_session *inv, pjsip_event *e)
{ {
struct ast_sip_session *session = inv->mod_data[session_module.id]; struct ast_sip_session *session = inv->mod_data[session_module.id];
...@@ -4985,20 +5011,44 @@ static int sip_inv_transport2(pjsip_inv_session *inv, pjsip_event *e) ...@@ -4985,20 +5011,44 @@ static int sip_inv_transport2(pjsip_inv_session *inv, pjsip_event *e)
msg->line.req.method.id != PJSIP_INVITE_METHOD) msg->line.req.method.id != PJSIP_INVITE_METHOD)
return 0; return 0;
if (!endpoint || !endpoint->transport2) if (endpoint && endpoint->transport2) {
return 0; transport2 = ast_sip_get_transport_state(endpoint->transport2);
}
if (!transport2) {
// for emergency ongoing call, try UDP further, if transport2 is not available
if (session->channel && ast_channel_emergency_ongoing_get(session->channel)) {
ast_log(LOG_NOTICE, "Try UDP transport for emergency ongoing call\n");
transport2 = ast_sip_get_transport_state(endpoint->transport2); transport2 = get_udp_transport_state();
if (!transport2 || transport2->type == session->transport_type)
if (!transport2) {
ast_log(LOG_NOTICE, "No UDP transport available\n");
return 0;
}
} else {
if (endpoint->transport2) {
ast_log(LOG_ERROR, "transport2 %s is not available\n", endpoint->transport2);
} else {
ast_debug(3, "no transport2 available\n");
}
return 0;
}
}
if (transport2 == session->transport_state) {
ast_debug(3, "Tried transport2 '%s'. No help!\n", transport2->id);
return 0; return 0;
}
if (ast_sip_set_tpselector_from_transport_name(endpoint->transport2, &selector)) if (ast_sip_set_tpselector_from_transport_name(endpoint->transport2, &selector))
return 0; return 0;
pjsip_dlg_set_transport(inv->dlg, &selector); pjsip_dlg_set_transport(inv->dlg, &selector);
session->transport_type = transport2->type; session->transport_state = transport2;
ast_log(LOG_NOTICE, "Sending SIP INVITE with transport2 (%s)\n", endpoint->transport2); ast_log(LOG_NOTICE, "Sending SIP INVITE with transport (%s)\n", transport2->id);
pjsip_inv_uac_restart(inv, PJ_FALSE); pjsip_inv_uac_restart(inv, PJ_FALSE);
pjmedia_sdp_neg_cancel_offer(inv->neg); pjmedia_sdp_neg_cancel_offer(inv->neg);
...@@ -5019,6 +5069,8 @@ static int check_request_status(pjsip_inv_session *inv, pjsip_event *e) ...@@ -5019,6 +5069,8 @@ static int check_request_status(pjsip_inv_session *inv, pjsip_event *e)
struct ast_sip_session *session = inv->mod_data[session_module.id]; struct ast_sip_session *session = inv->mod_data[session_module.id];
pjsip_transaction *tsx = e->body.tsx_state.tsx; pjsip_transaction *tsx = e->body.tsx_state.tsx;
ast_debug(3, "%s: Received response '%d'\n", ast_sip_session_get_name(session), tsx->status_code);
if (tsx->status_code != 503 && tsx->status_code != 408 && tsx->status_code != 500) { if (tsx->status_code != 503 && tsx->status_code != 408 && tsx->status_code != 500) {
// DNS resolve: stick to the server address // DNS resolve: stick to the server address
ast_sip_resolve_track_cur_addr(tsx->last_tx); ast_sip_resolve_track_cur_addr(tsx->last_tx);
...@@ -5026,6 +5078,8 @@ static int check_request_status(pjsip_inv_session *inv, pjsip_event *e) ...@@ -5026,6 +5078,8 @@ static int check_request_status(pjsip_inv_session *inv, pjsip_event *e)
} }
if (!ast_sip_failover_request(tsx->last_tx)) { if (!ast_sip_failover_request(tsx->last_tx)) {
ast_log(LOG_NOTICE, "Failed to send SIP INVITE with transport '%s'\n", session->transport_state->id);
// Try if the endpoint has transport2 // Try if the endpoint has transport2
return sip_inv_transport2(inv, e); return sip_inv_transport2(inv, e);
} }
......
...@@ -2636,6 +2636,29 @@ static void dtls_perform_setup(struct dtls_details *dtls) ...@@ -2636,6 +2636,29 @@ static void dtls_perform_setup(struct dtls_details *dtls)
} }
#endif #endif
static void ast_rtp_network_info_notify(struct ast_rtp_instance *instance, struct ast_sockaddr *addr)
{
struct ast_sockaddr prev_address;
char *addr_str, *addr_str_tmp;
if (ast_sockaddr_isnull(addr)) {
ast_rtp_instance_get_remote_address(instance, &prev_address);
addr_str = ast_sockaddr_stringify(&prev_address);
addr_str_tmp = strstr(addr_str, ":");
if (addr_str_tmp)
*addr_str_tmp = '\0';
ast_send_network_info_ubus_event(0, "rtp", addr_str, ast_sockaddr_port(&prev_address));
}
else {
addr_str = ast_sockaddr_stringify(addr);
addr_str_tmp = strstr(addr_str, ":");
if (addr_str_tmp)
*addr_str_tmp = '\0';
ast_send_network_info_ubus_event(1, "rtp", addr_str, ast_sockaddr_port(addr));
}
ast_rtp_instance_set_remote_address(instance, addr);
}
#ifdef HAVE_PJPROJECT #ifdef HAVE_PJPROJECT
static void rtp_learning_start(struct ast_rtp *rtp); static void rtp_learning_start(struct ast_rtp *rtp);
...@@ -2656,7 +2679,7 @@ static void ast_rtp_ice_start_media(pj_ice_sess *ice, pj_status_t status) ...@@ -2656,7 +2679,7 @@ static void ast_rtp_ice_start_media(pj_ice_sess *ice, pj_status_t status)
/* Symmetric RTP must be disabled for the remote address to not get overwritten */ /* Symmetric RTP must be disabled for the remote address to not get overwritten */
ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 0); ast_rtp_instance_set_prop(instance, AST_RTP_PROPERTY_NAT, 0);
ast_rtp_instance_set_remote_address(instance, &remote_address); ast_rtp_network_info_notify(instance, &remote_address);
} }
if (rtp->rtcp) { if (rtp->rtcp) {
...@@ -3281,7 +3304,7 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s ...@@ -3281,7 +3304,7 @@ static int __rtp_recvfrom(struct ast_rtp_instance *instance, void *buf, size_t s
if (rtcp) { if (rtcp) {
ast_sockaddr_copy(&rtp->rtcp->them, sa); ast_sockaddr_copy(&rtp->rtcp->them, sa);
} else { } else {
ast_rtp_instance_set_remote_address(instance, sa); ast_rtp_network_info_notify(instance, sa);
} }
} }
return 0; return 0;
...@@ -8185,7 +8208,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc ...@@ -8185,7 +8208,7 @@ static struct ast_frame *ast_rtp_read(struct ast_rtp_instance *instance, int rtc
if ((ast_stun_handle_packet(rtp->s, &addr_tmp, read_area, res, NULL, NULL) == AST_STUN_ACCEPT) && if ((ast_stun_handle_packet(rtp->s, &addr_tmp, read_area, res, NULL, NULL) == AST_STUN_ACCEPT) &&
ast_sockaddr_isnull(&remote_address)) { ast_sockaddr_isnull(&remote_address)) {
ast_sockaddr_from_sin(&addr, &addr_tmp); ast_sockaddr_from_sin(&addr, &addr_tmp);
ast_rtp_instance_set_remote_address(instance, &addr); ast_rtp_network_info_notify(instance, &addr);
} }
return &ast_null_frame; return &ast_null_frame;
} }
...@@ -9000,7 +9023,17 @@ static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct ...@@ -9000,7 +9023,17 @@ static void ast_rtp_remote_address_set(struct ast_rtp_instance *instance, struct
for (index = 0; index < AST_VECTOR_SIZE(&rtp->ssrc_mapping); ++index) { for (index = 0; index < AST_VECTOR_SIZE(&rtp->ssrc_mapping); ++index) {
struct rtp_ssrc_mapping *mapping = AST_VECTOR_GET_ADDR(&rtp->ssrc_mapping, index); struct rtp_ssrc_mapping *mapping = AST_VECTOR_GET_ADDR(&rtp->ssrc_mapping, index);
ast_rtp_instance_set_remote_address(mapping->instance, addr); ast_rtp_network_info_notify(mapping->instance, addr);
}
if (!ast_sockaddr_isnull(addr)) {
char *addr_str, *addr_str_tmp;
addr_str = ast_sockaddr_stringify(addr);
addr_str_tmp = strstr(addr_str, ":");
if (addr_str_tmp)
*addr_str_tmp = '\0';
ast_send_network_info_ubus_event(1, "rtp", addr_str, ast_sockaddr_port(addr));
} }
/* Need to reset the DTMF last sequence number and the timestamp of the last END packet */ /* Need to reset the DTMF last sequence number and the timestamp of the last END packet */
...@@ -9279,7 +9312,7 @@ static void ast_rtp_stop(struct ast_rtp_instance *instance) ...@@ -9279,7 +9312,7 @@ static void ast_rtp_stop(struct ast_rtp_instance *instance)
rtp->red = NULL; rtp->red = NULL;
} }
ast_rtp_instance_set_remote_address(instance, &addr); ast_rtp_network_info_notify(instance, &addr);
ast_set_flag(rtp, FLAG_NEED_MARKER_BIT); ast_set_flag(rtp, FLAG_NEED_MARKER_BIT);
} }
...@@ -9495,7 +9528,7 @@ static int ast_rtp_bundle(struct ast_rtp_instance *child, struct ast_rtp_instanc ...@@ -9495,7 +9528,7 @@ static int ast_rtp_bundle(struct ast_rtp_instance *child, struct ast_rtp_instanc
ao2_lock(child); ao2_lock(child);
ast_rtp_instance_set_remote_address(child, &them); ast_rtp_network_info_notify(child, &them);
return 0; return 0;
} }
......