[svn-commits] twilson: trunk r264905 - /trunk/channels/chan_sip.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu May 20 20:00:46 CDT 2010
Author: twilson
Date: Thu May 20 20:00:44 2010
New Revision: 264905
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=264905
Log:
Take dup'd code for directmedia ACLs and make utility func
The same code was repeated in lots of different places, so I made a utility
fuction for it. This should make the merge in the v6-new branch easier.
Modified:
trunk/channels/chan_sip.c
Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=264905&r1=264904&r2=264905
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu May 20 20:00:44 2010
@@ -26414,6 +26414,22 @@
return 0;
}
+static int apply_directmedia_ha(struct sip_pvt *p, const char *op)
+{
+ struct sockaddr_in us, them;
+ int res;
+
+ ast_rtp_instance_get_remote_address(p->rtp, &them);
+ ast_rtp_instance_get_local_address(p->rtp, &us);
+
+ if (!(res = ast_apply_ha(p->directmediaha, &them))) {
+ ast_debug(3, "Reinvite %s to %s denied by directmedia ACL on %s\n",
+ op, ast_inet_ntoa(them.sin_addr), ast_inet_ntoa(us.sin_addr));
+ }
+
+ return res;
+}
+
static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
{
struct sip_pvt *p;
@@ -26425,14 +26441,7 @@
sip_pvt_lock(p);
if (p->udptl && ast_test_flag(&p->flags[0], SIP_DIRECT_MEDIA)) {
- struct sockaddr_in them;
- struct sockaddr_in us;
-
- ast_rtp_instance_get_remote_address(p->rtp, &them);
- ast_rtp_instance_get_local_address(p->rtp, &us);
- if (!ast_apply_ha(p->directmediaha, &them)) {
- ast_debug(3, "Reinvite UDPTL T.38 data to %s denied by directmedia ACL on %s\n", ast_inet_ntoa(them.sin_addr), ast_inet_ntoa(us.sin_addr));
- } else {
+ if (apply_directmedia_ha(p, "UDPTL T.38 data")) {
udptl = p->udptl;
}
}
@@ -26486,14 +26495,8 @@
*instance = p->rtp;
if (ast_test_flag(&p->flags[0], SIP_DIRECT_MEDIA)) {
- struct sockaddr_in them;
- struct sockaddr_in us;
-
res = AST_RTP_GLUE_RESULT_REMOTE;
- ast_rtp_instance_get_remote_address(p->rtp, &them);
- ast_rtp_instance_get_local_address(p->rtp, &us);
- if (!ast_apply_ha(p->directmediaha, &them)) {
- ast_debug(3, "Reinvite audio to %s denied by directmedia ACL on %s\n", ast_inet_ntoa(them.sin_addr), ast_inet_ntoa(us.sin_addr));
+ if (!apply_directmedia_ha(p, "audio")) {
res = AST_RTP_GLUE_RESULT_FORBID;
}
} else if (ast_test_flag(&p->flags[0], SIP_DIRECT_MEDIA_NAT)) {
@@ -26526,14 +26529,8 @@
*instance = p->vrtp;
if (ast_test_flag(&p->flags[0], SIP_DIRECT_MEDIA)) {
- struct sockaddr_in them;
- struct sockaddr_in us;
-
res = AST_RTP_GLUE_RESULT_REMOTE;
- ast_rtp_instance_get_remote_address(p->rtp, &them);
- ast_rtp_instance_get_local_address(p->rtp, &us);
- if (!ast_apply_ha(p->directmediaha, &them)) {
- ast_debug(3, "Reinvite video to %s denied by directmedia ACL on %s\n", ast_inet_ntoa(them.sin_addr), ast_inet_ntoa(us.sin_addr));
+ if (!apply_directmedia_ha(p, "video")) {
res = AST_RTP_GLUE_RESULT_FORBID;
}
}
@@ -26562,14 +26559,8 @@
*instance = p->trtp;
if (ast_test_flag(&p->flags[0], SIP_DIRECT_MEDIA)) {
- struct sockaddr_in them;
- struct sockaddr_in us;
-
res = AST_RTP_GLUE_RESULT_REMOTE;
- ast_rtp_instance_get_remote_address(p->rtp, &them);
- ast_rtp_instance_get_local_address(p->rtp, &us);
- if (!ast_apply_ha(p->directmediaha, &them)) {
- ast_debug(3, "Reinvite text to %s denied by directmedia ACL on %s\n", ast_inet_ntoa(them.sin_addr), ast_inet_ntoa(us.sin_addr));
+ if (!apply_directmedia_ha(p, "text")) {
res = AST_RTP_GLUE_RESULT_FORBID;
}
}
More information about the svn-commits
mailing list