[asterisk-commits] rizzo: branch rizzo/astobj2 r75160 - /team/rizzo/astobj2/channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jul 15 12:13:31 CDT 2007
Author: rizzo
Date: Sun Jul 15 12:13:30 2007
New Revision: 75160
URL: http://svn.digium.com/view/asterisk?view=rev&rev=75160
Log:
make use of the newly introduced (in trunk) stun support.
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=75160&r1=75159&r2=75160
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Sun Jul 15 12:13:30 2007
@@ -1387,6 +1387,7 @@
*/
static volatile int sipsock = -1; /*!< Main socket for SIP network communication */
+static struct sockaddr_in stunaddr = { 0, }; /*!< stun server address */
static struct sockaddr_in bindaddr = { 0, }; /*!< The address we bind to */
static struct sockaddr_in externip; /*!< External IP address if we are behind NAT */
static char externhost[MAXHOSTNAMELEN]; /*!< External host name (possibly with dynamic DNS and DHCP */
@@ -17872,6 +17873,14 @@
M_BOOL("recordhistory", recordhistory)
M_INT_GE("registertimeout", global_reg_timeout, 1, DEFAULT_REGISTRATION_TIMEOUT)
M_F("registerattempts", global_regattempts_max = atoi(v->value);) /* XXX */
+ M_F("stunaddr", {
+ if (!(hp = ast_gethostbyname(v->value, &ahp))) {
+ ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
+ } else {
+ memcpy(&stunaddr.sin_addr, hp->h_addr, sizeof(stunaddr.sin_addr));
+ stunaddr.sin_family = AF_INET;
+ stunaddr.sin_port = htons(3478);
+ } } )
M_F("bindaddr", {
if (!(hp = ast_gethostbyname(v->value, &ahp))) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
@@ -18113,6 +18122,14 @@
ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_netsock_set_qos(my_socket, global_tos_sip, global_tos_sip);
sipsock = my_socket;
+ if (stunaddr.sin_addr.s_addr != 0) {
+ ast_log(LOG_WARNING, "stun to %s:%d\n",
+ ast_inet_ntoa(stunaddr.sin_addr) , ntohs(stunaddr.sin_port));
+ ast_stun_request(sipsock, &stunaddr,
+ NULL, &externip);
+ ast_log(LOG_WARNING, "stun sees us at %s:%d\n",
+ ast_inet_ntoa(externip.sin_addr) , ntohs(externip.sin_port));
+ }
sipsock_read_id = ast_io_add(io, sipsock, sipsock_read, AST_IO_IN, NULL);
}
}
More information about the asterisk-commits
mailing list