aboutsummaryrefslogtreecommitdiffstats
path: root/acl.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-12-03 23:34:45 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-12-03 23:34:45 +0000
commit6e02cf8b96c03ec5f79bc77d76e56193c87a5670 (patch)
tree1b2c1c2831fe11e5f38a4cbc4c94c490b1b425b3 /acl.c
parent79a741f2616cc17440b66842899bd142fc9341c6 (diff)
Add *preliminary* per-peer outbound proxy (bug #2859, new patch though)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4383 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'acl.c')
-rwxr-xr-xacl.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/acl.c b/acl.c
index 935ec808d..c7eb34270 100755
--- a/acl.c
+++ b/acl.c
@@ -23,6 +23,7 @@
#include <asterisk/channel.h>
#include <asterisk/utils.h>
#include <asterisk/lock.h>
+#include <asterisk/srv.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
@@ -186,10 +187,20 @@ int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin)
return res;
}
-int ast_get_ip(struct sockaddr_in *sin, char *value)
+int ast_get_ip_or_srv(struct sockaddr_in *sin, const char *value, const char *service)
{
struct hostent *hp;
struct ast_hostent ahp;
+ char srv[256];
+ char host[256];
+ int tportno = ntohs(sin->sin_port);
+ if (service) {
+ snprintf(srv, sizeof(srv), "%s.%s", service, value);
+ if (ast_get_srv(NULL, host, sizeof(host), &tportno, srv) > 0) {
+ sin->sin_port = htons(tportno);
+ value = host;
+ }
+ }
hp = ast_gethostbyname(value, &ahp);
if (hp) {
memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
@@ -200,6 +211,11 @@ int ast_get_ip(struct sockaddr_in *sin, char *value)
return 0;
}
+int ast_get_ip(struct sockaddr_in *sin, const char *value)
+{
+ return ast_get_ip_or_srv(sin, value, NULL);
+}
+
/* iface is the interface (e.g. eth0); address is the return value */
int ast_lookup_iface(char *iface, struct in_addr *address) {
int mysock, res = 0;