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: http://svn.digium.com/svn/asterisk/trunk@264905 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
0e1abeca6b
commit
ed87841315
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue