< Previous by Date | Date Index | Next by Date > |
< Previous in Thread | Thread Index | Next in Thread > |
A quick note: storing/accessing pointers
to transports outside of the stack thread is not a good idea. Especially since
there are some changes on the table to allow transports to be added/removed at
runtime. I haven’t really though much about alternatives though –
perhaps queuing some messages to the stack to start a stun test???? From:
resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx
[mailto:resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of Matthias Moetje - TERASENS
GmbH Hi, in my efforts to implement client support for STUN I found
that it is necessary to modify the UDP transport to
implement this functionality (as Dmytrow already mentioned in a
previous post). I think this functionality might be of interest for
others, too, so here's a proposal for adding stun client support. Why this is necessary: The STUN functions in stun.cxx work fine for RTP ports but they can't be used directly for the
SIP UDP ports because the stack is already bound to these
ports. Even when binding with SO_REUSEPORT, the response is
received by the stack and not by the stun function (at least on
Windows), so it is necessary to do the STUN communication in the
UdpTransport class itself. This class already implements a stun server,
so I see no reason why the client should be
implemented elsewhere. I think the application should have control over the use
of the discovered public IP address and port (a more automatic
and integrated solution could be added later), therefore the
application would need to get a pointer to the UdpTransport class.
This could be done by turning void addTransport( TransportType protocol, int port=0,
IpVersion version=V4, StunSetting stun=StunDisabled,...); into Transport addTransport( TransportType protocol, int
port=0, IpVersion version=V4, StunSetting stun=StunDisabled,...); The StunSetting enumeration could be extended to typedef enum StunClient, //Client only StunClientServer //Client and Server This would be 100% compatible and require no changes to
existing code nor would it change any existing behaviour. UdpTransport would receive two public methods: //returns true if message was sent successfully bool StunTest(StunAddress4& dest, int testNum); //returns true and discovered address if last StunTest was
successful bool StunResult(StunAddress4* srcAddr); Would there be any resons against implementing it this way? Any suggestions? Best
regards, Matthias
Moetje
|