From ecf198bf85af7b17727fea89e238fc74d70caa69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= Date: Tue, 9 Apr 2019 10:07:42 -0400 Subject: [PATCH] upnp: add TCP port mapping P2P file transfer should support UPnP as a NAT traversal technique. Change-Id: I62f9990fd646c874f611d3dba7277bef54caeb46 Gitlab: #86 --- src/ice_transport.cpp | 116 ++++++++++++++++++++++---------------- src/upnp/upnp_context.cpp | 2 +- 2 files changed, 67 insertions(+), 51 deletions(-) diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp index 4038c6ac6..6ca1480e8 100644 --- a/src/ice_transport.cpp +++ b/src/ice_transport.cpp @@ -236,13 +236,19 @@ public: /** * Returns the IP of each candidate for a given component in the ICE session */ - std::vector getLocalCandidatesAddr(unsigned comp_id) const; + struct LocalCandidate { + IpAddr addr; + pj_ice_cand_transport transport; + }; + std::vector getLocalICECandidates(unsigned comp_id) const; /** * Adds a reflective candidate to ICE session * Must be called before negotiation */ - void addReflectiveCandidate(int comp_id, const IpAddr& base, const IpAddr& addr); + void addReflectiveCandidate(int comp_id, const IpAddr &base, + const IpAddr &addr, + const pj_ice_cand_transport& transport); /** * Creates UPnP port mappings and adds ICE candidates based on those mappings @@ -708,10 +714,10 @@ IceTransport::Impl::createIceSession(pj_ice_sess_role role) return true; } -std::vector -IceTransport::Impl::getLocalCandidatesAddr(unsigned comp_id) const +std::vector +IceTransport::Impl::getLocalICECandidates(unsigned comp_id) const { - std::vector cand_addrs; + std::vector cand_addrs; pj_ice_sess_cand cand[PJ_ARRAY_SIZE(cand_)]; unsigned cand_cnt = PJ_ARRAY_SIZE(cand); @@ -720,25 +726,27 @@ IceTransport::Impl::getLocalCandidatesAddr(unsigned comp_id) const return cand_addrs; } - for (unsigned i=0; i