mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-27 06:31:54 +00:00
res_pjsip_t38: bind UDPTL sessions like RTP
In res_pjsip_sdp_rtp, the bind_rtp_to_media_address option and the fallback use of the transport's bind address solve problems sending media on systems that cannot send ipv4 packets on ipv6 sockets, and certain other situations. This change extends both of these behaviors to UDPTL sessions as well in res_pjsip_t38, to fix fax-specific problems on these systems, introducing a new option endpoint/t38_bind_udptl_to_media_address. ASTERISK-29402 Change-Id: I87220c0e9cdd2fe9d156846cb906debe08c63557
This commit is contained in:
@@ -255,11 +255,52 @@ static struct t38_state *t38_state_get_or_alloc(struct ast_sip_session *session)
|
||||
/*! \brief Initializes UDPTL support on a session, only done when actually needed */
|
||||
static int t38_initialize_session(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
|
||||
{
|
||||
struct ast_sockaddr temp_media_address;
|
||||
struct ast_sockaddr *media_address = &address;
|
||||
|
||||
if (session_media->udptl) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(session_media->udptl = ast_udptl_new_with_bindaddr(NULL, NULL, 0, &address))) {
|
||||
if (session->endpoint->media.t38.bind_udptl_to_media_address && !ast_strlen_zero(session->endpoint->media.address)) {
|
||||
if (ast_sockaddr_parse(&temp_media_address, session->endpoint->media.address, 0)) {
|
||||
ast_debug(5, "Endpoint %s: Binding UDPTL media to %s\n",
|
||||
ast_sorcery_object_get_id(session->endpoint),
|
||||
session->endpoint->media.address);
|
||||
media_address = &temp_media_address;
|
||||
} else {
|
||||
ast_debug(5, "Endpoint %s: UDPTL media address invalid: %s\n",
|
||||
ast_sorcery_object_get_id(session->endpoint),
|
||||
session->endpoint->media.address);
|
||||
}
|
||||
} else {
|
||||
struct ast_sip_transport *transport;
|
||||
|
||||
transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",
|
||||
session->endpoint->transport);
|
||||
if (transport) {
|
||||
struct ast_sip_transport_state *trans_state;
|
||||
|
||||
trans_state = ast_sip_get_transport_state(ast_sorcery_object_get_id(transport));
|
||||
if (trans_state) {
|
||||
char hoststr[PJ_INET6_ADDRSTRLEN];
|
||||
|
||||
pj_sockaddr_print(&trans_state->host, hoststr, sizeof(hoststr), 0);
|
||||
if (ast_sockaddr_parse(&temp_media_address, hoststr, 0)) {
|
||||
ast_debug(5, "Transport %s bound to %s: Using it for UDPTL media.\n",
|
||||
session->endpoint->transport, hoststr);
|
||||
media_address = &temp_media_address;
|
||||
} else {
|
||||
ast_debug(5, "Transport %s bound to %s: Invalid for UDPTL media.\n",
|
||||
session->endpoint->transport, hoststr);
|
||||
}
|
||||
ao2_ref(trans_state, -1);
|
||||
}
|
||||
ao2_ref(transport, -1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(session_media->udptl = ast_udptl_new_with_bindaddr(NULL, NULL, 0, media_address))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user