diff options
author | Mark Spencer <markster@digium.com> | 2004-12-03 23:34:45 +0000 |
---|---|---|
committer | Mark Spencer <markster@digium.com> | 2004-12-03 23:34:45 +0000 |
commit | 4820c2bb973de13a52ce584045f4a20be381e5b0 (patch) | |
tree | 1b2c1c2831fe11e5f38a4cbc4c94c490b1b425b3 /acl.c | |
parent | 41306646ade6c8f333f8f8df1da8064e7f047f58 (diff) |
Add *preliminary* per-peer outbound proxy (bug #2859, new patch though)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4383 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'acl.c')
-rwxr-xr-x | acl.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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; |