summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2010-05-21 01:00:44 +0000
committerTerry Wilson <twilson@digium.com>2010-05-21 01:00:44 +0000
commitfe9c31517149e54c3dbc9bc082fbe385ea092f23 (patch)
treea30a72fe88226a3b6573585f6dbd7f37b16e9ca2
parent43991ce806f1cb587d8893afe035519efd7977d4 (diff)
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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@264905 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--channels/chan_sip.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index f7cd05e5a..9642f3de1 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -26414,6 +26414,22 @@ static int reload_config(enum channelreloadreason reason)
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 @@ static struct ast_udptl *sip_get_udptl_peer(struct ast_channel *chan)
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 @@ static enum ast_rtp_glue_result sip_get_rtp_peer(struct ast_channel *chan, struc
*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 @@ static enum ast_rtp_glue_result sip_get_vrtp_peer(struct ast_channel *chan, stru
*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 @@ static enum ast_rtp_glue_result sip_get_trtp_peer(struct ast_channel *chan, stru
*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;
}
}