Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 45305) +++ channels/chan_sip.c (working copy) @@ -468,6 +468,7 @@ #define DEFAULT_ALLOWGUEST TRUE #define DEFAULT_SRVLOOKUP FALSE /*!< Recommended setting is ON */ #define DEFAULT_COMPACTHEADERS FALSE +#define DEFAULT_RTPIP "auto" #define DEFAULT_TOS_SIP 0 /*!< Call signalling packets should be marked as DSCP CS3, but the default is 0 to be compatible with previous versions. */ #define DEFAULT_TOS_AUDIO 0 /*!< Audio packets should be marked as DSCP EF (Expedited Forwarding), but the default is 0 to be compatible with previous versions. */ #define DEFAULT_TOS_VIDEO 0 /*!< Video packets should be marked as DSCP AF41, but the default is 0 to be compatible with previous versions. */ @@ -526,6 +527,7 @@ static char global_realm[MAXHOSTNAMELEN]; /*!< Default realm */ static char global_regcontext[AST_MAX_CONTEXT]; /*!< Context for auto-extensions */ static char global_useragent[AST_MAX_EXTENSION]; /*!< Useragent for the SIP channel */ +static char global_rtpip[AST_MAX_EXTENSION]; /*!< Specify IP endpoint for RTP SDP message */ static int allow_external_domains; /*!< Accept calls to external SIP domains? */ static int global_callevents; /*!< Whether we send manager events or not */ static int global_t1min; /*!< T1 roundtrip time minimum */ @@ -5771,11 +5773,21 @@ p->t38.peercapability, p->t38.jointcapability); } - snprintf(v, sizeof(v), "v=0\r\n"); - snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(udptldest.sin_addr)); - snprintf(s, sizeof(s), "s=session\r\n"); - snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(udptldest.sin_addr)); - snprintf(t, sizeof(t), "t=0 0\r\n"); + + /* Replace RTP IP address, if rtpip!=auto */ + if (!strcasestr(global_rtpip, "auto")) { + snprintf(v, sizeof(v), "v=0\r\n"); + snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, global_rtpip); + snprintf(s, sizeof(s), "s=session\r\n"); + snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", global_rtpip); + snprintf(t, sizeof(t), "t=0 0\r\n"); + } else { + snprintf(v, sizeof(v), "v=0\r\n"); + snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(udptldest.sin_addr)); + snprintf(s, sizeof(s), "s=session\r\n"); + snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(udptldest.sin_addr)); + snprintf(t, sizeof(t), "t=0 0\r\n"); + } ast_build_string(&m_modem_next, &m_modem_left, "m=image %d udptl t38\r\n", ntohs(udptldest.sin_port)); if ((p->t38.jointcapability & T38FAX_VERSION) == T38FAX_VERSION_0) @@ -5979,8 +5991,15 @@ /* We break with the "recommendation" and send our IP, in order that our peer doesn't have to ast_gethostbyname() us */ - snprintf(owner, sizeof(owner), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(dest.sin_addr)); - snprintf(connection, sizeof(connection), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr)); + /* Replace RTP IP address, if rtpip!=auto */ + if (!strcasestr(global_rtpip, "auto")) { + snprintf(owner, sizeof(owner), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, global_rtpip); + snprintf(connection, sizeof(connection), "c=IN IP4 %s\r\n", global_rtpip); + } else { + snprintf(owner, sizeof(owner), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(dest.sin_addr)); + snprintf(connection, sizeof(connection), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr)); + } + ast_build_string(&m_audio_next, &m_audio_left, "m=audio %d RTP/AVP", ntohs(dest.sin_port)); if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_ONEDIR)) @@ -15637,6 +15656,7 @@ global_notifyringing = DEFAULT_NOTIFYRINGING; global_alwaysauthreject = 0; global_allowsubscribe = FALSE; + ast_copy_string(global_rtpip, DEFAULT_RTPIP, sizeof(global_rtpip)); ast_copy_string(global_useragent, DEFAULT_USERAGENT, sizeof(global_useragent)); ast_copy_string(default_notifymime, DEFAULT_NOTIFYMIME, sizeof(default_notifymime)); if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) @@ -15752,6 +15772,8 @@ ast_log(LOG_WARNING, "'%s' is not a valid RTP keepalive time at line %d. Using default.\n", v->value, v->lineno); global_rtpkeepalive = 0; } + } else if (!strcasecmp(v->name, "rtpip")) { + ast_copy_string(global_rtpip, v->value, sizeof(global_rtpip)); } else if (!strcasecmp(v->name, "compactheaders")) { compactheaders = ast_true(v->value); } else if (!strcasecmp(v->name, "notifymimetype")) {