[Asterisk-cvs] asterisk acl.c,1.29,1.30
markster at lists.digium.com
markster at lists.digium.com
Fri Dec 3 18:36:25 CST 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv24469
Modified Files:
acl.c
Log Message:
Add *preliminary* per-peer outbound proxy (bug #2859, new patch though)
Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- acl.c 23 Oct 2004 14:15:59 -0000 1.29
+++ acl.c 3 Dec 2004 23:34:44 -0000 1.30
@@ -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 @@
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 @@
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;
More information about the svn-commits
mailing list