[asterisk-dev] RFC: chan_sip.c code cleanup for better NAT support (including stun)

Luigi Rizzo rizzo at icir.org
Wed Jul 18 05:52:34 CDT 2007


I would like to merge into trunk at least (and later, possibly
also into 1.4 if considered useful) some changes aimed at better
operation when asterisk is behind a NAT.

You can get an idea of the type of changes here:

http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=log

in particular
	http://svn.digium.com/view/asterisk?view=rev&revision=75160
	http://svn.digium.com/view/asterisk?view=rev&revision=75526
	http://svn.digium.com/view/asterisk?view=rev&revision=75527
	http://svn.digium.com/view/asterisk?view=rev&revision=75528
and so on.

Basically the changes are along these lines:

=== in terms of external configuration: ===
  + accept an optional :port in "externip", "externhost" to simplify
    configuration;
  + add documentation and more integrity checks on "externip",
    "externhost" and related options.
  + introduce the "stunaddr" option to talk to an STUN server for
    detecting the externally visible address/port for both sip and media
    sessions

=== in terms of internal changes: ===

  + document the usage of internal variables (bindaddr, externip, etc.) and
    remove/rename others (__ourip, ourport replaced by internip);
  + change the prototype and implementation of ast_sip_ouraddrfor()
    to remove some code duplications around it
  + make sure that the address part of externip/internip is used
    in a correct way for media sessions;
  + add the calls to the ast_stun_request() where appropriate (on SIP
    and media sockets), and a mechanism to refresh the STUN mapping
    for the main sip socket.

The functional changes should be completely backward compatible
(except possibly for bugs, but i am not aware of any).
However, since i don't know whether some incompatibilities could
come out, I prefer to do the work in trunk and merge into 1.4 only
when it is complete and we know that there are no surprises.

Let me know if you have objections.

	cheers
	luigi
-----------------------------------+-------------------------------------
  Luigi RIZZO, rizzo at iet.unipi.it  . Dip. di Ing. dell'Informazione
  http://www.iet.unipi.it/~luigi/  . Universita` di Pisa
  TEL/FAX: +39-050-2217.533/600    . via Diotisalvi 2, 56122 PISA (Italy)
  Mobile   +39-347-0373137
-----------------------------------+-------------------------------------



More information about the asterisk-dev mailing list