< Previous by Date | Date Index | Next by Date > |
< Previous in Thread | Thread Index | Next in Thread > |
Best regards,
Matthias Moetje
From: resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx [mailto:resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of Matthias Moetje - TERASENS GmbH
Sent: Thursday, April 06, 2006 9:45 PM
To: resiprocate-devel@xxxxxxxxxxxxxxxxxxx
Subject: [reSIProcate] STUN Client supportHi,I just finished the implementation of STUN client support.It was much easier than I had expected and it worksquite well. (I haven't solved the via problem yet, though)This is what I've done:SipStack::AddTransport now returns a pointer of type "Transport"to the internally created transport. This pointer can be castedback to a UdpTransport interface (for STUN client usage).I added the following new member variables:mutable resip::Mutex myMutex;
Tuple mStunMappedAddress; // the discovered mapped address
bool mStunSuccess; // received a successful response to last STUN testand these two public functions:bool stunSendTest(const Tuple& dest);
bool stunResult(Tuple& mappedAddress);The first one lets you initiate a STUN test to the STUNserver specified by "dest". It constructs a STUN messageand adds it to the "mTxFifo".The latter function just returns the discovered mapped addressand port in case the last STUN test was successful.I added some code to the process function in order to processthe STUN response. It checks the first two bytes (verysimilar to the existing implementation of STUN server):if (buffer[0] == 1 && buffer[1] == 1 && ipVersion() == V4)I changed the STUN server message detection fromif (buffer[0] == 0 || buffer[0] == 1 && ipVersion() == V4)(which was obviously wrong) toif (buffer[0] == 0 && buffer[1] == 1 && ipVersion() == V4)Finally I added a Lock to the two STUN functions and to the processfunction for thread safety.If nobody has some serious reasons against this implementationI would check it in soon, I don't think this will affect existingapplications in any way because the mutex is the only realeffective change for someone who doesn't use STUN clientor server functionality.Best regards,
Matthias Moetje
TERASENS GmbH
Augustenstraße 24
80333 Munich
GERMANY
Phone:
Fax:
e-mail:
Web:+49.89.143370-0
+49.89.143370-22
info@xxxxxxxxxxxx
www.terasens.com