[Asterisk-cvs] asterisk acl.c,1.24,1.25 manager.c,1.59,1.60 rtp.c,1.73,1.74 utils.c,1.13,1.14
markster at lists.digium.com
markster at lists.digium.com
Tue Jun 29 09:10:59 CDT 2004
- Previous message: [Asterisk-cvs] asterisk/channels Makefile,1.54,1.55 chan_h323.c,1.62,1.63 chan_iax.c,1.61,1.62 chan_iax2.c,1.162,1.163 chan_mgcp.c,1.56,1.57 chan_sip.c,1.430,1.431 chan_skinny.c,1.48,1.49 iax2-parser.c,1.22,1.23
- Next message: [Asterisk-cvs] asterisk/redhat asterisk.spec,1.4,1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv16770
Modified Files:
acl.c manager.c rtp.c utils.c
Log Message:
Create reentrant ast_inet_ntoa and replace all inet_ntoa's with ast_inet_ntoa's (but #1944)
Index: acl.c
===================================================================
RCS file: /usr/cvsroot/asterisk/acl.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- acl.c 22 Jun 2004 20:11:15 -0000 1.24
+++ acl.c 29 Jun 2004 12:56:46 -0000 1.25
@@ -170,8 +170,10 @@
/* Start optimistic */
int res = AST_SENSE_ALLOW;
while(ha) {
+ char tmp[80];
+ char tmp2[80];
/* DEBUG */
- ast_log(LOG_DEBUG, "##### Testing %s with %s\n",inet_ntoa(sin->sin_addr), inet_ntoa(ha->netaddr) );
+ ast_log(LOG_DEBUG, "##### Testing %s with %s\n",ast_inet_ntoa(tmp, sizeof(tmp), sin->sin_addr), ast_inet_ntoa(tmp2, sizeof(tmp2), ha->netaddr));
/* For each rule, if this address and the netmask = the net address
apply the current rule */
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == (ha->netaddr.s_addr))
@@ -226,11 +228,13 @@
struct rt_msghdr m_rtm;
char m_space[512];
} m_rtmsg;
- char *cp, *p = ast_strdupa(inet_ntoa(*them));
+ char tmp[80];
+ char *cp, *p;
int i, l, s, seq, flags;
pid_t pid = getpid();
static int routeseq; /* Protected by "routeseq_lock" mutex */
+ p = ast_strdupa(ast_inet_ntoa(tmp, sizeof(tmp), *them))
memset(us, 0, sizeof(struct in_addr));
memset(&m_rtmsg, 0, sizeof(m_rtmsg));
@@ -293,7 +297,7 @@
if (i == RTA_IFA && sa->sa_family == AF_INET) {
sin = (struct sockaddr_in *)sa;
*us = sin->sin_addr;
- ast_log(LOG_DEBUG, "Found route to %s, output from our address %s.\n", p, inet_ntoa(*us));
+ ast_log(LOG_DEBUG, "Found route to %s, output from our address %s.\n", p, ast_inet_ntoa(tmp, sizeof(tmp), *us));
return 0;
}
cp += sa->sa_len > 0 ?
@@ -350,7 +354,8 @@
sscanf(fields[2],"%x",&gateway);
sscanf(fields[7],"%x",&mask);
#if 0
- printf("Addr: %s %08x Dest: %08x Mask: %08x\n", inet_ntoa(*them), remote_ip, dest, mask);
+ { char tmp[80];
+ printf("Addr: %s %08x Dest: %08x Mask: %08x\n", ast_inet_ntoa(tmp, sizeof(tmp), *them), remote_ip, dest, mask); }
#endif
/* Looks simple, but here is the magic */
if (((remote_ip & mask) ^ dest) == 0) {
Index: manager.c
===================================================================
RCS file: /usr/cvsroot/asterisk/manager.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- manager.c 29 Jun 2004 05:04:48 -0000 1.59
+++ manager.c 29 Jun 2004 12:56:46 -0000 1.60
@@ -163,12 +163,13 @@
static int handle_showmanconn(int fd, int argc, char *argv[])
{
struct mansession *s;
+ char iabuf[80];
char *format = " %-15.15s %-15.15s\n";
ast_mutex_lock(&sessionlock);
s = sessions;
ast_cli(fd, format, "Username", "IP Address");
while (s) {
- ast_cli(fd, format,s->username, inet_ntoa(s->sin.sin_addr));
+ ast_cli(fd, format,s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
s = s->next;
}
@@ -311,6 +312,7 @@
static int authenticate(struct mansession *s, struct message *m)
{
struct ast_config *cfg;
+ char iabuf[80];
char *cat;
char *user = astman_get_header(m, "Username");
char *pass = astman_get_header(m, "Secret");
@@ -340,7 +342,7 @@
v = v->next;
}
if (ha && !ast_apply_ha(ha, &(s->sin))) {
- ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", inet_ntoa(s->sin.sin_addr), user);
+ ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_free_ha(ha);
ast_destroy(cfg);
return -1;
@@ -369,7 +371,7 @@
} else if (password && !strcasecmp(password, pass)) {
break;
} else {
- ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", inet_ntoa(s->sin.sin_addr), user);
+ ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_destroy(cfg);
return -1;
}
@@ -386,7 +388,7 @@
set_eventmask(s, events);
return 0;
}
- ast_log(LOG_NOTICE, "%s tried to authenticate with non-existant user '%s'\n", inet_ntoa(s->sin.sin_addr), user);
+ ast_log(LOG_NOTICE, "%s tried to authenticate with non-existant user '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
ast_destroy(cfg);
return -1;
}
@@ -938,6 +940,7 @@
struct manager_action *tmp = first_action;
char *id = astman_get_header(m,"ActionID");
char idText[256] = "";
+ char iabuf[80];
strncpy(action, astman_get_header(m, "Action"), sizeof(action));
ast_log( LOG_DEBUG, "Manager received command '%s'\n", action );
@@ -976,8 +979,8 @@
} else {
s->authenticated = 1;
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged on from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
- ast_log(LOG_EVENT, "Manager '%s' logged on from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged on from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
+ ast_log(LOG_EVENT, "Manager '%s' logged on from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
astman_send_ack(s, m, "Authentication accepted");
}
} else if (!strcasecmp(action, "Logoff")) {
@@ -1009,6 +1012,7 @@
int res;
int x;
struct pollfd fds[1];
+ char iabuf[80];
for (x=1;x<s->inlen;x++) {
if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) {
/* Copy output data up to and including \r\n */
@@ -1022,7 +1026,7 @@
}
}
if (s->inlen >= sizeof(s->inbuf) - 1) {
- ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", inet_ntoa(s->sin.sin_addr), s->inbuf);
+ ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), s->inbuf);
s->inlen = 0;
}
fds[0].fd = s->fd;
@@ -1046,6 +1050,7 @@
{
struct mansession *s = data;
struct message m;
+ char iabuf[80];
int res;
ast_mutex_lock(&s->lock);
@@ -1070,12 +1075,12 @@
}
if (s->authenticated) {
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
- ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
+ ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
} else {
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", inet_ntoa(s->sin.sin_addr));
- ast_log(LOG_EVENT, "Failed attempt from %s\n", inet_ntoa(s->sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
+ ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
}
destroy_session(s);
return NULL;
Index: rtp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/rtp.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- rtp.c 22 Jun 2004 18:48:59 -0000 1.73
+++ rtp.c 29 Jun 2004 12:56:46 -0000 1.74
@@ -34,6 +34,7 @@
#include <asterisk/channel_pvt.h>
#include <asterisk/config.h>
#include <asterisk/lock.h>
+#include <asterisk/utils.h>
#define RTP_MTU 1200
@@ -170,15 +171,16 @@
{
struct timeval tv;
static struct ast_frame null_frame = { AST_FRAME_NULL, };
+ char iabuf[80];
gettimeofday(&tv, NULL);
if ((tv.tv_sec < rtp->dtmfmute.tv_sec) ||
((tv.tv_sec == rtp->dtmfmute.tv_sec) && (tv.tv_usec < rtp->dtmfmute.tv_usec))) {
- ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", inet_ntoa(rtp->them.sin_addr));
+ ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
rtp->resp = 0;
rtp->dtmfduration = 0;
return &null_frame;
}
- ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, inet_ntoa(rtp->them.sin_addr));
+ ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
rtp->f.frametype = AST_FRAME_DTMF;
rtp->f.subclass = rtp->resp;
rtp->f.datalen = 0;
@@ -333,6 +335,7 @@
int res;
struct sockaddr_in sin;
unsigned int rtcpdata[1024];
+ char iabuf[80];
if (!rtp->rtcp)
return &null_frame;
@@ -359,7 +362,7 @@
if ((rtp->rtcp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
(rtp->rtcp->them.sin_port != sin.sin_port)) {
memcpy(&rtp->them, &sin, sizeof(rtp->them));
- ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
+ ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
}
}
if (option_debug)
@@ -397,6 +400,7 @@
int payloadtype;
int hdrlen = 12;
int mark;
+ char iabuf[80];
unsigned int timestamp;
unsigned int *rtpheader;
static struct ast_frame *f, null_frame = { AST_FRAME_NULL, };
@@ -434,7 +438,7 @@
if ((rtp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
(rtp->them.sin_port != sin.sin_port)) {
memcpy(&rtp->them, &sin, sizeof(rtp->them));
- ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
+ ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
}
}
@@ -446,7 +450,7 @@
timestamp = ntohl(rtpheader[1]);
#if 0
- printf("Got RTP packet from %s:%d (type %d, seq %d, ts %d, len = %d)\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp,res - hdrlen);
+ printf("Got RTP packet from %s:%d (type %d, seq %d, ts %d, len = %d)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp,res - hdrlen);
#endif
rtpPT = ast_rtp_lookup_pt(rtp, payloadtype);
if (!rtpPT.isAstFormat) {
@@ -937,6 +941,7 @@
int ms;
int x;
char data[256];
+ char iabuf[80];
if ((digit <= '9') && (digit >= '0'))
digit -= '0';
@@ -979,9 +984,9 @@
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
res = sendto(rtp->s, (void *)rtpheader, hdrlen + 4, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
if (res <0)
- ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
+ ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
#if 0
- printf("Sent %d bytes of RTP data to %s:%d\n", res, inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
+ printf("Sent %d bytes of RTP data to %s:%d\n", res, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
#endif
}
if (x ==0) {
@@ -999,6 +1004,7 @@
static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec)
{
unsigned int *rtpheader;
+ char iabuf[80];
int hdrlen = 12;
int res;
int ms;
@@ -1078,9 +1084,9 @@
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
if (res <0)
- ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
+ ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
#if 0
- printf("Sent %d bytes of RTP data to %s:%d\n", res, inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
+ printf("Sent %d bytes of RTP data to %s:%d\n", res, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
#endif
}
return 0;
@@ -1273,6 +1279,7 @@
struct sockaddr_in vac0, vac1;
struct sockaddr_in t0, t1;
struct sockaddr_in vt0, vt1;
+ char iabuf[80];
void *pvt0, *pvt1;
int to;
@@ -1389,13 +1396,13 @@
ast_rtp_get_peer(vp0, &vt0);
if (inaddrcmp(&t1, &ac1) || (vp1 && inaddrcmp(&vt1, &vac1)) || (codec1 != oldcodec1)) {
ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
- c1->name, inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), codec1);
+ c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), t1.sin_addr), ntohs(t1.sin_port), codec1);
ast_log(LOG_DEBUG, "Oooh, '%s' changed end vaddress to %s:%d (format %d)\n",
- c1->name, inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), codec1);
+ c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vt1.sin_addr), ntohs(vt1.sin_port), codec1);
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
- c1->name, inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
+ c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
ast_log(LOG_DEBUG, "Oooh, '%s' wasv %s:%d/(format %d)\n",
- c1->name, inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
+ c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
if (pr0->set_rtp_peer(c0, t1.sin_addr.s_addr ? p1 : NULL, vt1.sin_addr.s_addr ? vp1 : NULL, codec1))
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name);
memcpy(&ac1, &t1, sizeof(ac1));
@@ -1404,9 +1411,9 @@
}
if (inaddrcmp(&t0, &ac0) || (vp0 && inaddrcmp(&vt0, &vac0))) {
ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
- c0->name, inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), codec0);
+ c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), t0.sin_addr), ntohs(t0.sin_port), codec0);
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
- c0->name, inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
+ c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
if (pr1->set_rtp_peer(c1, t0.sin_addr.s_addr ? p0 : NULL, vt0.sin_addr.s_addr ? vp0 : NULL, codec0))
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name);
memcpy(&ac0, &t0, sizeof(ac0));
Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- utils.c 28 Jun 2004 20:10:27 -0000 1.13
+++ utils.c 29 Jun 2004 12:56:46 -0000 1.14
@@ -12,6 +12,9 @@
#include <ctype.h>
#include <string.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
#include <asterisk/lock.h>
#include <asterisk/utils.h>
@@ -325,6 +328,10 @@
#endif
}
+const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia)
+{
+ return inet_ntop(AF_INET, &ia, buf, bufsiz);
+}
int ast_utils_init(void)
{
- Previous message: [Asterisk-cvs] asterisk/channels Makefile,1.54,1.55 chan_h323.c,1.62,1.63 chan_iax.c,1.61,1.62 chan_iax2.c,1.162,1.163 chan_mgcp.c,1.56,1.57 chan_sip.c,1.430,1.431 chan_skinny.c,1.48,1.49 iax2-parser.c,1.22,1.23
- Next message: [Asterisk-cvs] asterisk/redhat asterisk.spec,1.4,1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list