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;
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;
}
}
*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)) {
*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;
}
}
*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;
}
}