mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
contrib: add dtls transport type to pjsip
A DTLS type is needed for our DHT account. This type of transport is based on UDP + TLS. This kind of transport behaviour don't exist on current PJSIP v2.5.5 release. This patch adds this transport type, both for IPv4 and IPv6. Our PJSIP bridge class is modifier to support this new type for DHT account. Change-Id: I247fcb7c89fe23c99c580705c5f4a1d172b9c917 Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
This commit is contained in:

committed by
gerrit2

parent
60222051f6
commit
88be4bd9c7
63
contrib/src/pjproject/add_dtls_transport.patch
Normal file
63
contrib/src/pjproject/add_dtls_transport.patch
Normal file
@ -0,0 +1,63 @@
|
||||
--- a/pjsip/src/pjsip/sip_transport.c
|
||||
+++ b/pjsip/src/pjsip/sip_transport.c
|
||||
@@ -183,6 +183,13 @@
|
||||
PJSIP_TRANSPORT_RELIABLE | PJSIP_TRANSPORT_SECURE
|
||||
},
|
||||
{
|
||||
+ PJSIP_TRANSPORT_DTLS,
|
||||
+ 5061,
|
||||
+ {"DTLS", 4},
|
||||
+ "DTLS transport",
|
||||
+ PJSIP_TRANSPORT_SECURE
|
||||
+ },
|
||||
+ {
|
||||
PJSIP_TRANSPORT_SCTP,
|
||||
5060,
|
||||
{"SCTP", 4},
|
||||
@@ -224,6 +231,13 @@
|
||||
"TLS IPv6 transport",
|
||||
PJSIP_TRANSPORT_RELIABLE | PJSIP_TRANSPORT_SECURE
|
||||
},
|
||||
+ {
|
||||
+ PJSIP_TRANSPORT_DTLS6,
|
||||
+ 5061,
|
||||
+ {"DTLS", 4},
|
||||
+ "DTLS IPv6 transport",
|
||||
+ PJSIP_TRANSPORT_SECURE
|
||||
+ },
|
||||
};
|
||||
|
||||
static void tp_state_callback(pjsip_transport *tp,
|
||||
@@ -249,7 +263,7 @@
|
||||
*/
|
||||
PJ_DEF(pj_status_t) pjsip_transport_register_type( unsigned tp_flag,
|
||||
const char *tp_name,
|
||||
- int def_port,
|
||||
+ int def_port,
|
||||
int *p_tp_type)
|
||||
{
|
||||
unsigned i;
|
||||
--- a/pjsip/include/pjsip/sip_types.h
|
||||
+++ b/pjsip/include/pjsip/sip_types.h
|
||||
@@ -73,6 +73,9 @@
|
||||
/** TLS. */
|
||||
PJSIP_TRANSPORT_TLS,
|
||||
|
||||
+ /** DTLS. */
|
||||
+ PJSIP_TRANSPORT_DTLS,
|
||||
+
|
||||
/** SCTP. */
|
||||
PJSIP_TRANSPORT_SCTP,
|
||||
|
||||
@@ -95,7 +98,10 @@
|
||||
PJSIP_TRANSPORT_TCP6 = PJSIP_TRANSPORT_TCP + PJSIP_TRANSPORT_IPV6,
|
||||
|
||||
/** TLS over IPv6 */
|
||||
- PJSIP_TRANSPORT_TLS6 = PJSIP_TRANSPORT_TLS + PJSIP_TRANSPORT_IPV6
|
||||
+ PJSIP_TRANSPORT_TLS6 = PJSIP_TRANSPORT_TLS + PJSIP_TRANSPORT_IPV6,
|
||||
+
|
||||
+ /** DTLS over IPv6 */
|
||||
+ PJSIP_TRANSPORT_DTLS6 = PJSIP_TRANSPORT_DTLS + PJSIP_TRANSPORT_IPV6
|
||||
|
||||
} pjsip_transport_type_e;
|
||||
|
@ -77,6 +77,7 @@ endif
|
||||
$(APPLY) $(SRC)/pjproject/pj_ice_sess.patch
|
||||
$(APPLY) $(SRC)/pjproject/fix_turn_fallback.patch
|
||||
$(APPLY) $(SRC)/pjproject/fix_ioqueue_ipv6_sendto.patch
|
||||
$(APPLY) $(SRC)/pjproject/add_dtls_transport.patch
|
||||
$(UPDATE_AUTOCONFIG)
|
||||
$(MOVE)
|
||||
|
||||
|
@ -173,9 +173,9 @@ SipsIceTransport::SipsIceTransport(pjsip_endpoint* endpt,
|
||||
remote_ = ice->getRemoteAddress(comp_id);
|
||||
pj_sockaddr_cp(&base.key.rem_addr, remote_.pjPtr());
|
||||
base.key.type = tp_type;
|
||||
auto raw_tp_type = static_cast<pjsip_transport_type_e>(base.key.type);
|
||||
base.type_name = const_cast<char*>(pjsip_transport_get_type_name(raw_tp_type));
|
||||
base.flag = pjsip_transport_get_flag_from_type(raw_tp_type);
|
||||
auto reg_type = static_cast<pjsip_transport_type_e>(tp_type);
|
||||
base.type_name = const_cast<char*>(pjsip_transport_get_type_name(reg_type));
|
||||
base.flag = pjsip_transport_get_flag_from_type(reg_type);
|
||||
base.info = static_cast<char*>(pj_pool_alloc(pool_.get(), TRANSPORT_INFO_LENGTH));
|
||||
|
||||
auto remote_addr = remote_.toString();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "siptransport.h"
|
||||
#include "sip_utils.h"
|
||||
#include "ip_utils.h"
|
||||
#include "ice_transport.h"
|
||||
|
||||
#include "ringdht/sip_transport_ice.h"
|
||||
#include "ringdht/sips_transport_ice.h"
|
||||
@ -181,9 +182,6 @@ cp_(cp), pool_(pool), endpt_(endpt)
|
||||
pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP),
|
||||
&ice_pj_transport_type_);
|
||||
*/
|
||||
pjsip_transport_register_type(PJSIP_TRANSPORT_SECURE, "DTLS",
|
||||
pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_TLS),
|
||||
&dtls_pj_transport_type_);
|
||||
RING_DBG("SipTransportBroker@%p", this);
|
||||
}
|
||||
|
||||
@ -443,8 +441,10 @@ SipTransportBroker::getTlsIceTransport(const std::shared_ptr<ring::IceTransport>
|
||||
unsigned comp_id,
|
||||
const tls::TlsParams& params)
|
||||
{
|
||||
auto ipv6 = ice->getLocalAddress(comp_id).isIpv6();
|
||||
auto type = ipv6 ? PJSIP_TRANSPORT_DTLS6 : PJSIP_TRANSPORT_DTLS;
|
||||
auto sip_ice_tr = std::unique_ptr<tls::SipsIceTransport>(
|
||||
new tls::SipsIceTransport(endpt_, dtls_pj_transport_type_, params, ice, comp_id));
|
||||
new tls::SipsIceTransport(endpt_, type, params, ice, comp_id));
|
||||
auto tr = sip_ice_tr->getTransportBase();
|
||||
auto sip_tr = std::make_shared<SipTransport>(tr);
|
||||
sip_ice_tr.release(); // managed by PJSIP now
|
||||
|
@ -219,11 +219,6 @@ private:
|
||||
*/
|
||||
int ice_pj_transport_type_ {PJSIP_TRANSPORT_START_OTHER};
|
||||
|
||||
/**
|
||||
* Storage for SIP/DTLS transport instances.
|
||||
*/
|
||||
int dtls_pj_transport_type_ {PJSIP_TRANSPORT_START_OTHER};
|
||||
|
||||
pj_caching_pool& cp_;
|
||||
pj_pool_t& pool_;
|
||||
pjsip_endpoint *endpt_;
|
||||
|
Reference in New Issue
Block a user