[Asterisk-cvs] asterisk/channels chan_h323.c,1.31.2.2,1.31.2.3 chan_iax.c,1.49.2.2,1.49.2.3 chan_iax2.c,1.91.2.11,1.91.2.12 chan_mgcp.c,1.34.2.2,1.34.2.3 chan_sip.c,1.292.2.26,1.292.2.27 chan_skinny.c,1.27.2.2,1.27.2.3
markster at lists.digium.com
markster at lists.digium.com
Wed Apr 21 20:45:30 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv20221/channels
Modified Files:
Tag: v1-0_stable
chan_h323.c chan_iax.c chan_iax2.c chan_mgcp.c chan_sip.c
chan_skinny.c
Log Message:
Backport gethostbyname_r conversion
Index: chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v
retrieving revision 1.31.2.2
retrieving revision 1.31.2.3
diff -u -d -r1.31.2.2 -r1.31.2.3
--- chan_h323.c 15 Mar 2004 09:14:36 -0000 1.31.2.2
+++ chan_h323.c 22 Apr 2004 00:50:10 -0000 1.31.2.3
@@ -1432,7 +1432,7 @@
struct oh323_peer *peer = NULL;
struct oh323_user *user = NULL;
struct oh323_alias *alias = NULL;
- struct hostent *hp;
+ struct ast_hostent ahp; struct hostent *hp;
char *cat;
char *utype;
@@ -1459,7 +1459,7 @@
if (!strcasecmp(v->name, "port")) {
port = (int)strtol(v->value, NULL, 10);
} else if (!strcasecmp(v->name, "bindaddr")) {
- if (!(hp = gethostbyname(v->value))) {
+ if (!(hp = ast_gethostbyname(v->value, &ahp))) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
} else {
memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
Index: chan_iax.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax.c,v
retrieving revision 1.49.2.2
retrieving revision 1.49.2.3
diff -u -d -r1.49.2.2 -r1.49.2.3
--- chan_iax.c 21 Mar 2004 11:23:25 -0000 1.49.2.2
+++ chan_iax.c 22 Apr 2004 00:50:10 -0000 1.49.2.3
@@ -1666,7 +1666,7 @@
static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, int *maxtime, char *peer, char *context)
{
- struct hostent *hp;
+ struct ast_hostent ahp; struct hostent *hp;
struct iax_peer *p;
int found=0;
if (sendani)
@@ -1713,7 +1713,7 @@
}
ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
- hp = gethostbyname(peer);
+ hp = ast_gethostbyname(peer, &ahp);
if (hp) {
memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
sin->sin_port = htons(AST_DEFAULT_IAX_PORTNO);
@@ -3361,7 +3361,7 @@
char *porta;
char *stringp=NULL;
- struct hostent *hp;
+ struct ast_hostent ahp; struct hostent *hp;
if (!value)
return -1;
strncpy(copy, value, sizeof(copy)-1);
@@ -3383,7 +3383,7 @@
ast_log(LOG_WARNING, "%s is not a valid port number at line %d\n", porta, lineno);
return -1;
}
- hp = gethostbyname(hostname);
+ hp = ast_gethostbyname(hostname, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Host '%s' not found at line %d\n", hostname, lineno);
return -1;
Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.91.2.11
retrieving revision 1.91.2.12
diff -u -d -r1.91.2.11 -r1.91.2.12
--- chan_iax2.c 24 Mar 2004 21:24:33 -0000 1.91.2.11
+++ chan_iax2.c 22 Apr 2004 00:50:10 -0000 1.91.2.12
@@ -1682,7 +1682,7 @@
static int create_addr(struct sockaddr_in *sin, int *capability, int *sendani, int *maxtime, char *peer, char *context, int *trunk, int *notransfer, char *secret, int seclen)
{
- struct hostent *hp;
+ struct ast_hostent ahp; struct hostent *hp;
struct iax2_peer *p;
int found=0;
if (sendani)
@@ -1737,7 +1737,7 @@
}
}
if (!p && !found) {
- hp = gethostbyname(peer);
+ hp = ast_gethostbyname(peer, &ahp);
if (hp) {
memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
sin->sin_port = htons(IAX_DEFAULT_PORTNO);
@@ -3507,7 +3507,7 @@
char *porta;
char *stringp=NULL;
- struct hostent *hp;
+ struct ast_hostent ahp; struct hostent *hp;
if (!value)
return -1;
strncpy(copy, value, sizeof(copy)-1);
@@ -3529,7 +3529,7 @@
ast_log(LOG_WARNING, "%s is not a valid port number at line %d\n", porta, lineno);
return -1;
}
- hp = gethostbyname(hostname);
+ hp = ast_gethostbyname(hostname, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Host '%s' not found at line %d\n", hostname, lineno);
return -1;
Index: chan_mgcp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v
retrieving revision 1.34.2.2
retrieving revision 1.34.2.3
diff -u -d -r1.34.2.2 -r1.34.2.3
--- chan_mgcp.c 15 Mar 2004 09:14:36 -0000 1.34.2.2
+++ chan_mgcp.c 22 Apr 2004 00:50:10 -0000 1.34.2.3
@@ -1220,7 +1220,7 @@
int peercapability, peerNonCodecCapability;
struct sockaddr_in sin;
char *codecs;
- struct hostent *hp;
+ struct ast_hostent ahp; struct hostent *hp;
int codec;
int iterator;
struct mgcp_endpoint *p = sub->parent;
@@ -1237,7 +1237,7 @@
return -1;
}
/* XXX This could block for a long time, and block the main thread! XXX */
- hp = gethostbyname(host);
+ hp = ast_gethostbyname(host, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Unable to lookup host in c= line, '%s'\n", c);
return -1;
@@ -1415,7 +1415,7 @@
struct sockaddr_in dest;
struct mgcp_endpoint *p = sub->parent;
/* XXX We break with the "recommendation" and send our IP, in order that our
- peer doesn't have to gethostbyname() us XXX */
+ peer doesn't have to ast_gethostbyname() us XXX */
len = 0;
if (!sub->rtp) {
ast_log(LOG_WARNING, "No way to add SDP without an RTP structure\n");
@@ -2885,7 +2885,7 @@
struct mgcp_gateway *g;
struct mgcp_endpoint *e;
char *cat;
- struct hostent *hp;
+ struct ast_hostent ahp; struct hostent *hp;
int format;
if (gethostname(ourhost, sizeof(ourhost))) {
@@ -2904,7 +2904,7 @@
while(v) {
/* Create the interface list */
if (!strcasecmp(v->name, "bindaddr")) {
- if (!(hp = gethostbyname(v->value))) {
+ if (!(hp = ast_gethostbyname(v->value, &ahp))) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
} else {
memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
@@ -2966,7 +2966,7 @@
if (ntohl(bindaddr.sin_addr.s_addr)) {
memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip));
} else {
- hp = gethostbyname(ourhost);
+ hp = ast_gethostbyname(ourhost, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Unable to get our IP address, MGCP disabled\n");
return 0;
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.292.2.26
retrieving revision 1.292.2.27
diff -u -d -r1.292.2.26 -r1.292.2.27
--- chan_sip.c 1 Apr 2004 06:35:17 -0000 1.292.2.26
+++ chan_sip.c 22 Apr 2004 00:50:10 -0000 1.292.2.27
@@ -793,6 +793,7 @@
static int create_addr(struct sip_pvt *r, char *peer)
{
struct hostent *hp;
+ struct ast_hostent ahp;
struct sip_peer *p;
int found=0;
char *port;
@@ -890,7 +891,7 @@
portno = tportno;
}
}
- hp = gethostbyname(hostn);
+ hp = ast_gethostbyname(hostn, &ahp);
if (hp) {
strncpy(r->tohost, peer, sizeof(r->tohost) - 1);
memcpy(&r->sa.sin_addr, hp->h_addr, sizeof(r->sa.sin_addr));
@@ -1841,6 +1842,7 @@
char *stringp=NULL;
struct hostent *hp;
+ struct ast_hostent ahp;
if (!value)
return -1;
strncpy(copy, value, sizeof(copy)-1);
@@ -1876,7 +1878,7 @@
ast_log(LOG_WARNING, "%s is not a valid port number at line %d\n", porta, lineno);
return -1;
}
- hp = gethostbyname(hostname);
+ hp = ast_gethostbyname(hostname, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Host '%s' not found at line %d\n", hostname, lineno);
return -1;
@@ -1994,6 +1996,7 @@
struct sockaddr_in sin;
char *codecs;
struct hostent *hp;
+ struct ast_hostent ahp;
int codec;
int iterator;
int sendonly = 0;
@@ -2015,7 +2018,7 @@
return -1;
}
/* XXX This could block for a long time, and block the main thread! XXX */
- hp = gethostbyname(host);
+ hp = ast_gethostbyname(host, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Unable to lookup host in c= line, '%s'\n", c);
return -1;
@@ -2296,6 +2299,7 @@
char *h, *maddr, hostname[256];
int port, hn;
struct hostent *hp;
+ struct ast_hostent ahp;
/* Parse uri to h (host) and port - uri is already just the part inside the <> */
/* general form we are expecting is sip[s]:username[:password]@host[:port][;...] */
@@ -2337,7 +2341,7 @@
strncpy(hostname, maddr, hn); hostname[hn] = '\0';
}
- hp = gethostbyname(hostname);
+ hp = ast_gethostbyname(hostname, &ahp);
if (hp == NULL) {
ast_log(LOG_WARNING, "Can't find address for host '%s'\n", hostname);
return;
@@ -2622,7 +2626,7 @@
struct sockaddr_in dest;
struct sockaddr_in vdest = { 0, };
/* XXX We break with the "recommendation" and send our IP, in order that our
- peer doesn't have to gethostbyname() us XXX */
+ peer doesn't have to ast_gethostbyname() us XXX */
len = 0;
if (!p->rtp) {
ast_log(LOG_WARNING, "No way to add SDP without an RTP structure\n");
@@ -3177,6 +3181,7 @@
char via[80];
char addr[80];
struct sip_pvt *p;
+ struct ast_hostent ahp;
struct hostent *hp;
/* exit if we are already in process with this registrar ?*/
@@ -3218,7 +3223,7 @@
based on whether the remote host is on the external or
internal network so we can register through nat
*/
- if ((hp = gethostbyname(r->hostname))) {
+ if ((hp = ast_gethostbyname(r->hostname, &ahp))) {
if (ast_sip_ouraddrfor((struct in_addr *)hp->h_addr, &p->ourip))
memcpy(&p->ourip, &bindaddr.sin_addr, sizeof(p->ourip));
}
@@ -3423,6 +3428,7 @@
char *c, *n, *pt;
int port;
struct hostent *hp;
+ struct ast_hostent ahp;
struct sockaddr_in oldsin;
if (!strlen(expires)) {
expires = strstr(get_header(req, "Contact"), "expires=");
@@ -3484,7 +3490,7 @@
memcpy(&oldsin, &p->addr, sizeof(oldsin));
if (!p->nat) {
/* XXX This could block for a long time XXX */
- hp = gethostbyname(n);
+ hp = ast_gethostbyname(n, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Invalid host '%s'\n", n);
return -1;
@@ -4116,6 +4122,7 @@
char via[256] = "";
char *c, *pt;
struct hostent *hp;
+ struct ast_hostent ahp;
memset(via, 0, sizeof(via));
strncpy(via, get_header(req, "Via"), sizeof(via) - 1);
@@ -4137,7 +4144,7 @@
*pt = '\0';
pt++;
}
- hp = gethostbyname(c);
+ hp = ast_gethostbyname(c, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "'%s' is not a valid host\n", c);
return -1;
@@ -5945,6 +5952,7 @@
char *dest = data;
struct hostent *hp;
+ struct ast_hostent ahp;
struct sip_peer *p;
int found = 0;
@@ -5978,7 +5986,7 @@
}
ast_mutex_unlock(&peerl.lock);
if (!p && !found) {
- hp = gethostbyname(host);
+ hp = ast_gethostbyname(host, &ahp);
if (hp)
res = AST_DEVICE_UNKNOWN;
}
@@ -6358,6 +6366,7 @@
struct ast_variable *v;
struct sip_peer *peer;
struct sip_user *user;
+ struct ast_hostent ahp;
char *cat;
char *utype;
struct hostent *hp;
@@ -6442,23 +6451,23 @@
if (default_expiry < 1)
default_expiry = DEFAULT_DEFAULT_EXPIRY;
} else if (!strcasecmp(v->name, "bindaddr")) {
- if (!(hp = gethostbyname(v->value))) {
+ if (!(hp = ast_gethostbyname(v->value, &ahp))) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
} else {
memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
}
} else if (!strcasecmp(v->name, "localnet")) {
- if (!(hp = gethostbyname(v->value)))
+ if (!(hp = ast_gethostbyname(v->value, &ahp)))
ast_log(LOG_WARNING, "Invalid localnet keyword: %s\n", v->value);
else
memcpy(&localnet.sin_addr, hp->h_addr, sizeof(localnet.sin_addr));
} else if (!strcasecmp(v->name, "localmask")) {
- if (!(hp = gethostbyname(v->value)))
+ if (!(hp = ast_gethostbyname(v->value, &ahp)))
ast_log(LOG_WARNING, "Invalid localmask keyword: %s\n", v->value);
else
memcpy(&localmask.sin_addr, hp->h_addr, sizeof(localmask.sin_addr));
} else if (!strcasecmp(v->name, "externip")) {
- if (!(hp = gethostbyname(v->value)))
+ if (!(hp = ast_gethostbyname(v->value, &ahp)))
ast_log(LOG_WARNING, "Invalid address for externip keyword: %s\n", v->value);
else
memcpy(&externip.sin_addr, hp->h_addr, sizeof(externip.sin_addr));
@@ -6550,7 +6559,7 @@
if (ntohl(bindaddr.sin_addr.s_addr)) {
memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip));
} else {
- hp = gethostbyname(ourhost);
+ hp = ast_gethostbyname(ourhost, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Unable to get IP address for %s, SIP disabled\n", ourhost);
return 0;
Index: chan_skinny.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_skinny.c,v
retrieving revision 1.27.2.2
retrieving revision 1.27.2.3
diff -u -d -r1.27.2.2 -r1.27.2.3
--- chan_skinny.c 15 Mar 2004 09:14:36 -0000 1.27.2.2
+++ chan_skinny.c 22 Apr 2004 00:50:11 -0000 1.27.2.3
@@ -482,7 +482,7 @@
static char ourhost[256];
static int ourport;
static struct in_addr __ourip;
-struct hostent *hp;
+struct ast_hostent ahp; struct hostent *hp;
static int skinnysock = -1;
static pthread_t tcp_thread;
static pthread_t accept_t;
@@ -2521,7 +2521,7 @@
while(v) {
/* Create the interface list */
if (!strcasecmp(v->name, "bindaddr")) {
- if (!(hp = gethostbyname(v->value))) {
+ if (!(hp = ast_gethostbyname(v->value, &ahp))) {
ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
} else {
memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
@@ -2555,7 +2555,7 @@
if (ntohl(bindaddr.sin_addr.s_addr)) {
memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip));
} else {
- hp = gethostbyname(ourhost);
+ hp = ast_gethostbyname(ourhost, &ahp);
if (!hp) {
ast_log(LOG_WARNING, "Unable to get our IP address, Skinny disabled\n");
return 0;
More information about the svn-commits
mailing list