aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-21 17:31:28 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-21 17:31:28 +0000
commitf395a52a02593f8556bd3786addc671d3f4250e0 (patch)
tree9a03027276c525f44c08eb5dc4d7b9035fa697c9 /channels
parentc7eeabcdd20eb9b7fad38b03cd0784854c0813c9 (diff)
Merge a new implementation of ast_inet_ntoa, our thread safe replacement for
inet_ntoa, which uses thread specific data (aka thread local storage) instead of stack allocatted buffers to store the result. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@38042 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_iax2.c184
-rw-r--r--channels/chan_jingle.c2
-rw-r--r--channels/chan_mgcp.c42
-rw-r--r--channels/chan_sip.c256
-rw-r--r--channels/chan_skinny.c18
-rw-r--r--channels/iax2-parser.c10
-rw-r--r--channels/iax2-provision.c36
7 files changed, 226 insertions, 322 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 046cd7e6f..77c611f78 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1176,7 +1176,6 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
int res = 0;
int x;
struct timeval now;
- char iabuf[INET_ADDRSTRLEN];
char host[80];
if (new <= NEW_ALLOW) {
/* Look for an existing connection first */
@@ -1203,7 +1202,7 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
}
if ((res < 1) && (new >= NEW_ALLOW)) {
if (!iax2_getpeername(*sin, host, sizeof(host), lockpeer))
- snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
+ snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
gettimeofday(&now, NULL);
for (x=1;x<TRUNK_CALL_START;x++) {
/* Find first unused call number that hasn't been used in a while */
@@ -1575,7 +1574,7 @@ static int handle_error(void)
if (m.msg_controllen) {
sin = (struct sockaddr_in *)SO_EE_OFFENDER(&e);
if (sin)
- ast_log(LOG_WARNING, "Receive error from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_WARNING, "Receive error from %s\n", ast_inet_ntoa(sin->sin_addr));
else
ast_log(LOG_WARNING, "No address detected??\n");
} else {
@@ -1603,7 +1602,6 @@ static int transmit_trunk(struct iax_frame *f, struct sockaddr_in *sin, int sock
static int send_packet(struct iax_frame *f)
{
int res;
- char iabuf[INET_ADDRSTRLEN];
int callno = f->callno;
/* Don't send if there was an error, but return error instead */
@@ -1612,7 +1610,7 @@ static int send_packet(struct iax_frame *f)
/* Called with iaxsl held */
if (option_debug > 2 && iaxdebug)
- ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
+ ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
if (f->transfer) {
if (iaxdebug)
iax_showframe(f, NULL, 0, &iaxs[callno]->transfer, f->datalen - sizeof(struct ast_iax2_full_hdr));
@@ -1802,7 +1800,6 @@ static void __attempt_transmit(void *data)
struct iax_frame *f = data;
int freeme=0;
int callno = f->callno;
- char iabuf[INET_ADDRSTRLEN];
/* Make sure this call is still active */
if (callno)
ast_mutex_lock(&iaxsl[callno]);
@@ -1819,7 +1816,7 @@ static void __attempt_transmit(void *data)
iax2_destroy_nolock(callno);
} else {
if (iaxs[callno]->owner)
- ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno);
+ ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", ast_inet_ntoa(iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno);
iaxs[callno]->error = ETIMEDOUT;
if (iaxs[callno]->owner) {
struct ast_frame fr = { 0, };
@@ -1990,7 +1987,6 @@ static int iax2_show_peer(int fd, int argc, char *argv[])
{
char status[30];
char cbuf[256];
- char iabuf[INET_ADDRSTRLEN];
struct iax2_peer *peer;
char codec_buf[512];
int x = 0, codec = 0, load_realtime = 0;
@@ -2011,8 +2007,8 @@ static int iax2_show_peer(int fd, int argc, char *argv[])
ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "<unspecified>"));
ast_cli(fd, " Expire : %d\n", peer->expire);
ast_cli(fd, " ACL : %s\n", (peer->ha?"Yes":"No"));
- ast_cli(fd, " Addr->IP : %s Port %d\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)", ntohs(peer->addr.sin_port));
- ast_cli(fd, " Defaddr->IP : %s Port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port));
+ ast_cli(fd, " Addr->IP : %s Port %d\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)", ntohs(peer->addr.sin_port));
+ ast_cli(fd, " Defaddr->IP : %s Port %d\n", ast_inet_ntoa(peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port));
ast_cli(fd, " Username : %s\n", peer->username);
ast_cli(fd, " Codecs : ");
ast_getformatname_multiple(codec_buf, sizeof(codec_buf) -1, peer->capability);
@@ -2433,18 +2429,14 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
if (peername)
var = ast_load_realtime("iaxpeers", "name", peername, NULL);
else {
- char iabuf[INET_ADDRSTRLEN];
char porta[25];
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
sprintf(porta, "%d", ntohs(sin->sin_port));
- var = ast_load_realtime("iaxpeers", "ipaddr", iabuf, "port", porta, NULL);
+ var = ast_load_realtime("iaxpeers", "ipaddr", ast_inet_ntoa(sin->sin_addr), "port", porta, NULL);
if (var) {
/* We'll need the peer name in order to build the structure! */
- tmp = var;
- while(tmp) {
+ for (tmp = var; tmp; tmp = tmp->next) {
if (!strcasecmp(tmp->name, "name"))
peername = tmp->value;
- tmp = tmp->next;
}
}
}
@@ -2456,8 +2448,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
if (!peer)
return NULL;
- tmp = var;
- while(tmp) {
+ for (tmp = var; tmp; tmp = tmp->next) {
/* Make sure it's not a user only... */
if (!strcasecmp(tmp->name, "type")) {
if (strcasecmp(tmp->value, "friend") &&
@@ -2477,7 +2468,6 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
if (!strcasecmp(tmp->value, "dynamic"))
dynamic = 1;
}
- tmp = tmp->next;
}
if (!peer)
return NULL;
@@ -2561,15 +2551,15 @@ static struct iax2_user *realtime_user(const char *username)
static void realtime_update_peer(const char *peername, struct sockaddr_in *sin)
{
char port[10];
- char ipaddr[20];
char regseconds[20];
time_t nowtime;
time(&nowtime);
snprintf(regseconds, sizeof(regseconds), "%d", (int)nowtime);
- ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr);
snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
- ast_update_realtime("iaxpeers", "name", peername, "ipaddr", ipaddr, "port", port, "regseconds", regseconds, NULL);
+ ast_update_realtime("iaxpeers", "name", peername,
+ "ipaddr", ast_inet_ntoa(sin->sin_addr), "port", port,
+ "regseconds", regseconds, NULL);
}
struct create_addr_info {
@@ -3516,17 +3506,15 @@ static unsigned int calc_rxstamp(struct chan_iax2_pvt *p, unsigned int offset)
static struct iax2_trunk_peer *find_tpeer(struct sockaddr_in *sin, int fd)
{
struct iax2_trunk_peer *tpeer;
- char iabuf[INET_ADDRSTRLEN];
+
/* Finds and locks trunk peer */
ast_mutex_lock(&tpeerlock);
- tpeer = tpeers;
- while(tpeer) {
+ for (tpeer = tpeers; tpeer; tpeer = tpeer->next) {
/* We don't lock here because tpeer->addr *never* changes */
if (!inaddrcmp(&tpeer->addr, sin)) {
ast_mutex_lock(&tpeer->lock);
break;
}
- tpeer = tpeer->next;
}
if (!tpeer) {
if ((tpeer = ast_calloc(1, sizeof(*tpeer)))) {
@@ -3541,7 +3529,7 @@ static struct iax2_trunk_peer *find_tpeer(struct sockaddr_in *sin, int fd)
#ifdef SO_NO_CHECK
setsockopt(tpeer->sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums));
#endif
- ast_log(LOG_DEBUG, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
+ ast_log(LOG_DEBUG, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
}
}
ast_mutex_unlock(&tpeerlock);
@@ -3555,7 +3543,6 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
void *tmp, *ptr;
struct ast_iax2_meta_trunk_entry *met;
struct ast_iax2_meta_trunk_mini *mtm;
- char iabuf[INET_ADDRSTRLEN];
f = &fr->af;
tpeer = find_tpeer(&pvt->addr, pvt->sockfd);
@@ -3570,9 +3557,9 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
tpeer->trunkdataalloc += DEFAULT_TRUNKDATA;
tpeer->trunkdata = tmp;
- ast_log(LOG_DEBUG, "Expanded trunk '%s:%d' to %d bytes\n", ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
+ ast_log(LOG_DEBUG, "Expanded trunk '%s:%d' to %d bytes\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
} else {
- ast_log(LOG_WARNING, "Maximum trunk data space exceeded to %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
+ ast_log(LOG_WARNING, "Maximum trunk data space exceeded to %s:%d\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
ast_mutex_unlock(&tpeer->lock);
return -1;
}
@@ -4021,7 +4008,6 @@ static int __iax2_show_peers(int manager, int fd, struct mansession *s, int argc
struct iax2_peer *peer = NULL;
char name[256];
- char iabuf[INET_ADDRSTRLEN];
int registeredonly=0;
char *term = manager ? "\r\n" : "\n";
@@ -4089,10 +4075,10 @@ static int __iax2_show_peers(int manager, int fd, struct mansession *s, int argc
else
unmonitored_peers++;
- ast_copy_string(nm, ast_inet_ntoa(iabuf, sizeof(iabuf), peer->mask), sizeof(nm));
+ ast_copy_string(nm, ast_inet_ntoa(peer->mask), sizeof(nm));
snprintf(srch, sizeof(srch), FORMAT, name,
- peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
+ peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
nm,
ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ",
@@ -4100,14 +4086,14 @@ static int __iax2_show_peers(int manager, int fd, struct mansession *s, int argc
if (s)
astman_append(s, FORMAT, name,
- peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
+ peer->addr.sin_addr.s_addr ? ast_inet_ntoa( peer->addr.sin_addr) : "(Unspecified)",
ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
nm,
ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ",
peer->encmethods ? "(E)" : " ", status, term);
else
ast_cli(fd, FORMAT, name,
- peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
+ peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)",
nm,
ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ",
@@ -4268,15 +4254,14 @@ static int iax2_show_registry(int fd, int argc, char *argv[])
char host[80];
char perceived[80];
- char iabuf[INET_ADDRSTRLEN];
if (argc != 3)
return RESULT_SHOWUSAGE;
AST_LIST_LOCK(&peers);
ast_cli(fd, FORMAT2, "Host", "dnsmgr", "Username", "Perceived", "Refresh", "State");
for (reg = registrations;reg;reg = reg->next) {
- snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->addr.sin_addr), ntohs(reg->addr.sin_port));
+ snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
if (reg->us.sin_addr.s_addr)
- snprintf(perceived, sizeof(perceived), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->us.sin_addr), ntohs(reg->us.sin_port));
+ snprintf(perceived, sizeof(perceived), "%s:%d", ast_inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
else
ast_copy_string(perceived, "<Unregistered>", sizeof(perceived));
ast_cli(fd, FORMAT, host,
@@ -4296,7 +4281,6 @@ static int iax2_show_channels(int fd, int argc, char *argv[])
#define FORMATB "%-20.20s %-15.15s %-10.10s %5.5d/%5.5d %5.5d/%5.5d [Native Bridged to ID=%5.5d]\n"
int x;
int numchans = 0;
- char iabuf[INET_ADDRSTRLEN];
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -4318,7 +4302,7 @@ static int iax2_show_channels(int fd, int argc, char *argv[])
lag = iaxs[x]->remote_rr.delay;
ast_cli(fd, FORMAT,
iaxs[x]->owner ? iaxs[x]->owner->name : "(None)",
- ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[x]->addr.sin_addr),
+ ast_inet_ntoa(iaxs[x]->addr.sin_addr),
S_OR(iaxs[x]->username, "(None)"),
iaxs[x]->callno, iaxs[x]->peercallno,
iaxs[x]->oseqno, iaxs[x]->iseqno,
@@ -4574,7 +4558,6 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
struct iax2_user *user = NULL, *best = NULL;
int bestscore = 0;
int gotcapability = 0;
- char iabuf[INET_ADDRSTRLEN];
struct ast_variable *v = NULL, *tmpvar = NULL;
if (!iaxs[callno])
@@ -4626,7 +4609,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
iaxs[callno]->peercapability = iaxs[callno]->peerformat;
if (version > IAX_PROTO_VERSION) {
ast_log(LOG_WARNING, "Peer '%s' has too new a protocol version (%d) for me\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), version);
+ ast_inet_ntoa(sin->sin_addr), version);
return res;
}
/* Search the userlist for a compatible entry, and fill in the rest */
@@ -4770,7 +4753,6 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
static int raw_hangup(struct sockaddr_in *sin, unsigned short src, unsigned short dst, int sockfd)
{
struct ast_iax2_full_hdr fh;
- char iabuf[INET_ADDRSTRLEN];
fh.scallno = htons(src | IAX_FLAG_FULL);
fh.dcallno = htons(dst);
fh.ts = 0;
@@ -4784,7 +4766,7 @@ static int raw_hangup(struct sockaddr_in *sin, unsigned short src, unsigned shor
if (option_debug)
#endif
ast_log(LOG_DEBUG, "Raw Hangup %s:%d, src=%d, dst=%d\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), src, dst);
+ ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), src, dst);
return sendto(sockfd, &fh, sizeof(fh), 0, (struct sockaddr *)sin, sizeof(*sin));
}
@@ -4931,7 +4913,6 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
char md5secret[256] = "";
char rsasecret[256] = "";
char secret[256] = "";
- char iabuf[INET_ADDRSTRLEN];
struct iax2_peer *p;
struct ast_key *key;
char *keyn;
@@ -4952,7 +4933,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
expire = ies->refresh;
if (ast_strlen_zero(peer)) {
- ast_log(LOG_NOTICE, "Empty registration from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_NOTICE, "Empty registration from %s\n", ast_inet_ntoa(sin->sin_addr));
return -1;
}
/* We release the lock for the call to prevent a deadlock, but it's okay because
@@ -4969,13 +4950,13 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
}
if (!p) {
if (authdebug)
- ast_log(LOG_NOTICE, "No registration for peer '%s' (from %s)\n", peer, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_NOTICE, "No registration for peer '%s' (from %s)\n", peer, ast_inet_ntoa(sin->sin_addr));
return -1;
}
if (!ast_test_flag(p, IAX_DYNAMIC)) {
if (authdebug)
- ast_log(LOG_NOTICE, "Peer '%s' is not dynamic (from %s)\n", peer, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_NOTICE, "Peer '%s' is not dynamic (from %s)\n", peer, ast_inet_ntoa(sin->sin_addr));
if (ast_test_flag(p, IAX_TEMPONLY))
destroy_peer(p);
return -1;
@@ -4983,7 +4964,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
if (!ast_apply_ha(p->ha, sin)) {
if (authdebug)
- ast_log(LOG_NOTICE, "Host %s denied access to register peer '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), p->name);
+ ast_log(LOG_NOTICE, "Host %s denied access to register peer '%s'\n", ast_inet_ntoa(sin->sin_addr), p->name);
if (ast_test_flag(p, IAX_TEMPONLY))
destroy_peer(p);
return -1;
@@ -5044,7 +5025,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
ast_set_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED);
} else {
if (authdebug)
- ast_log(LOG_NOTICE, "Host %s failed MD5 authentication for '%s' (%s != %s)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), p->name, requeststr, md5secret);
+ ast_log(LOG_NOTICE, "Host %s failed MD5 authentication for '%s' (%s != %s)\n", ast_inet_ntoa(sin->sin_addr), p->name, requeststr, md5secret);
if (ast_test_flag(p, IAX_TEMPONLY))
destroy_peer(p);
return -1;
@@ -5053,7 +5034,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
/* They've provided a plain text password and we support that */
if (strcmp(secret, p->secret)) {
if (authdebug)
- ast_log(LOG_NOTICE, "Host %s did not provide proper plaintext password for '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), p->name);
+ ast_log(LOG_NOTICE, "Host %s did not provide proper plaintext password for '%s'\n", ast_inet_ntoa(sin->sin_addr), p->name);
if (ast_test_flag(p, IAX_TEMPONLY))
destroy_peer(p);
return -1;
@@ -5083,13 +5064,12 @@ static int authenticate(char *challenge, char *secret, char *keyn, int authmetho
{
int res = -1;
int x;
- char iabuf[INET_ADDRSTRLEN];
if (!ast_strlen_zero(keyn)) {
if (!(authmethods & IAX_AUTH_RSA)) {
if (ast_strlen_zero(secret))
- ast_log(LOG_NOTICE, "Asked to authenticate to %s with an RSA key, but they don't allow RSA authentication\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_NOTICE, "Asked to authenticate to %s with an RSA key, but they don't allow RSA authentication\n", ast_inet_ntoa(sin->sin_addr));
} else if (ast_strlen_zero(challenge)) {
- ast_log(LOG_NOTICE, "No challenge provided for RSA authentication to %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_NOTICE, "No challenge provided for RSA authentication to %s\n", ast_inet_ntoa(sin->sin_addr));
} else {
char sig[256];
struct ast_key *key;
@@ -5128,7 +5108,7 @@ static int authenticate(char *challenge, char *secret, char *keyn, int authmetho
iax_ie_append_str(ied, IAX_IE_PASSWORD, secret);
res = 0;
} else
- ast_log(LOG_NOTICE, "No way to send secret to peer '%s' (their methods: %d)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), authmethods);
+ ast_log(LOG_NOTICE, "No way to send secret to peer '%s' (their methods: %d)\n", ast_inet_ntoa(sin->sin_addr), authmethods);
}
return res;
}
@@ -5356,7 +5336,6 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c
char ourip[256] = "<Unspecified>";
struct sockaddr_in oldus;
struct sockaddr_in us;
- char iabuf[INET_ADDRSTRLEN];
int oldmsgs;
memset(&us, 0, sizeof(us));
@@ -5377,7 +5356,7 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c
memcpy(&oldus, &reg->us, sizeof(oldus));
oldmsgs = reg->messages;
if (inaddrcmp(&reg->addr, sin)) {
- ast_log(LOG_WARNING, "Received unsolicited registry ack from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_WARNING, "Received unsolicited registry ack from '%s'\n", ast_inet_ntoa(sin->sin_addr));
return -1;
}
memcpy(&reg->us, &us, sizeof(reg->us));
@@ -5400,10 +5379,10 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c
snprintf(msgstatus, sizeof(msgstatus), " with 1 new message waiting\n");
else
snprintf(msgstatus, sizeof(msgstatus), " with no messages waiting\n");
- snprintf(ourip, sizeof(ourip), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->us.sin_addr), ntohs(reg->us.sin_port));
- ast_verbose(VERBOSE_PREFIX_3 "Registered IAX2 to '%s', who sees us as %s%s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ourip, msgstatus);
+ snprintf(ourip, sizeof(ourip), "%s:%d", ast_inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
+ ast_verbose(VERBOSE_PREFIX_3 "Registered IAX2 to '%s', who sees us as %s%s\n", ast_inet_ntoa(sin->sin_addr), ourip, msgstatus);
}
- manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: IAX2\r\nDomain: %s\r\nStatus: Registered\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: IAX2\r\nDomain: %s\r\nStatus: Registered\r\n", ast_inet_ntoa(sin->sin_addr));
}
reg->regstate = REG_STATE_REGISTERED;
return 0;
@@ -5531,7 +5510,6 @@ static void reg_source_db(struct iax2_peer *p)
{
char data[80];
struct in_addr in;
- char iabuf[INET_ADDRSTRLEN];
char *c, *d;
if (!ast_test_flag(p, IAX_TEMPONLY) && (!ast_db_get("IAX/Registry", p->name, data, sizeof(data)))) {
c = strchr(data, ':');
@@ -5545,7 +5523,7 @@ static void reg_source_db(struct iax2_peer *p)
d++;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Seeding '%s' at %s:%d for %d\n", p->name,
- ast_inet_ntoa(iabuf, sizeof(iabuf), in), atoi(c), atoi(d));
+ ast_inet_ntoa(in), atoi(c), atoi(d));
iax2_poke_peer(p, 0);
p->expiry = atoi(d);
memset(&p->addr, 0, sizeof(p->addr));
@@ -5573,7 +5551,6 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
struct iax2_peer *p;
int msgcount;
char data[80];
- char iabuf[INET_ADDRSTRLEN];
int version;
memset(&ied, 0, sizeof(ied));
@@ -5591,12 +5568,12 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
iax2_regfunk(p->name, 1);
/* Stash the IP address from which they registered */
memcpy(&p->addr, sin, sizeof(p->addr));
- snprintf(data, sizeof(data), "%s:%d:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), p->expiry);
+ snprintf(data, sizeof(data), "%s:%d:%d", ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), p->expiry);
if (!ast_test_flag(p, IAX_TEMPONLY) && sin->sin_addr.s_addr) {
ast_db_put("IAX/Registry", p->name, data);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Registered IAX2 '%s' (%s) at %s:%d\n", p->name,
- ast_test_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED) ? "AUTHENTICATED" : "UNAUTHENTICATED", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
+ ast_test_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED) ? "AUTHENTICATED" : "UNAUTHENTICATED", ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Registered\r\n", p->name);
register_peer_exten(p, 1);
ast_device_state_changed("IAX2/%s", p->name); /* Activate notification */
@@ -5691,7 +5668,6 @@ static int registry_rerequest(struct iax_ies *ies, int callno, struct sockaddr_i
/* Start pessimistic */
struct iax_ie_data ied;
char peer[256] = "";
- char iabuf[INET_ADDRSTRLEN];
char challenge[256] = "";
int res;
int authmethods = 0;
@@ -5705,7 +5681,7 @@ static int registry_rerequest(struct iax_ies *ies, int callno, struct sockaddr_i
reg = iaxs[callno]->reg;
if (reg) {
if (inaddrcmp(&reg->addr, sin)) {
- ast_log(LOG_WARNING, "Received unsolicited registry authenticate request from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_WARNING, "Received unsolicited registry authenticate request from '%s'\n", ast_inet_ntoa(sin->sin_addr));
return -1;
}
if (ast_strlen_zero(reg->secret)) {
@@ -5903,7 +5879,7 @@ static int send_trunk(struct iax2_trunk_peer *tpeer, struct timeval *now)
res = transmit_trunk(fr, &tpeer->addr, tpeer->sockfd);
calls = tpeer->calls;
#if 0
- ast_log(LOG_DEBUG, "Trunking %d call chunks in %d bytes to %s:%d, ts=%d\n", calls, fr->datalen, ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), ntohl(mth->ts));
+ ast_log(LOG_DEBUG, "Trunking %d call chunks in %d bytes to %s:%d, ts=%d\n", calls, fr->datalen, ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), ntohl(mth->ts));
#endif
/* Reset transmit trunk side data */
tpeer->trunkdatalen = 0;
@@ -5926,7 +5902,6 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
{
char buf[1024];
int res;
- char iabuf[INET_ADDRSTRLEN];
struct iax2_trunk_peer *tpeer, *prev = NULL, *drop=NULL;
int processed = 0;
int totalcalls = 0;
@@ -5972,7 +5947,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
} else {
res = send_trunk(tpeer, &now);
if (iaxtrunkdebug)
- ast_verbose(" - Trunk peer (%s:%d) has %d call chunk%s in transit, %d bytes backloged and has hit a high water mark of %d bytes\n", ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), res, (res != 1) ? "s" : "", tpeer->trunkdatalen, tpeer->trunkdataalloc);
+ ast_verbose(" - Trunk peer (%s:%d) has %d call chunk%s in transit, %d bytes backloged and has hit a high water mark of %d bytes\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), res, (res != 1) ? "s" : "", tpeer->trunkdatalen, tpeer->trunkdataalloc);
}
totalcalls += res;
res = 0;
@@ -5985,7 +5960,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
ast_mutex_lock(&drop->lock);
/* Once we have this lock, we're sure nobody else is using it or could use it once we release it,
because by the time they could get tpeerlock, we've already grabbed it */
- ast_log(LOG_DEBUG, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), drop->addr.sin_addr), ntohs(drop->addr.sin_port));
+ ast_log(LOG_DEBUG, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
free(drop->trunkdata);
ast_mutex_unlock(&drop->lock);
ast_mutex_destroy(&drop->lock);
@@ -6246,7 +6221,6 @@ static int socket_process(struct iax2_thread *thread)
struct ast_iax2_meta_trunk_mini *mtm;
struct iax_frame *fr;
struct iax_frame *cur;
- char iabuf[INET_ADDRSTRLEN];
struct ast_frame f;
struct ast_channel *c;
struct iax2_dpcache *dp;
@@ -6282,7 +6256,7 @@ static int socket_process(struct iax2_thread *thread)
}
if ((vh->zeros == 0) && (ntohs(vh->callno) & 0x8000)) {
if (res < sizeof(*vh)) {
- ast_log(LOG_WARNING, "Rejecting packet from '%s.%d' that is flagged as a video frame but is too short\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_log(LOG_WARNING, "Rejecting packet from '%s.%d' that is flagged as a video frame but is too short\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
return 1;
}
@@ -6293,7 +6267,7 @@ static int socket_process(struct iax2_thread *thread)
unsigned char metatype;
if (res < sizeof(*meta)) {
- ast_log(LOG_WARNING, "Rejecting packet from '%s.%d' that is flagged as a meta frame but is too short\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_log(LOG_WARNING, "Rejecting packet from '%s.%d' that is flagged as a meta frame but is too short\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
return 1;
}
@@ -6312,7 +6286,7 @@ static int socket_process(struct iax2_thread *thread)
ptr = mth->data;
tpeer = find_tpeer(&sin, fd);
if (!tpeer) {
- ast_log(LOG_WARNING, "Unable to accept trunked packet from '%s:%d': No matching peer\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_log(LOG_WARNING, "Unable to accept trunked packet from '%s:%d': No matching peer\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
return 1;
}
tpeer->trunkact = ast_tvnow();
@@ -6339,7 +6313,7 @@ static int socket_process(struct iax2_thread *thread)
callno = ntohs(mte->callno);
trunked_ts = 0;
} else {
- ast_log(LOG_WARNING, "Unknown meta trunk cmd from '%s:%d': dropping\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_log(LOG_WARNING, "Unknown meta trunk cmd from '%s:%d': dropping\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
break;
}
/* Stop if we don't have enough data */
@@ -6413,7 +6387,7 @@ static int socket_process(struct iax2_thread *thread)
#endif
if (ntohs(mh->callno) & IAX_FLAG_FULL) {
if (res < sizeof(*fh)) {
- ast_log(LOG_WARNING, "Rejecting packet from '%s.%d' that is flagged as a full frame but is too short\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_log(LOG_WARNING, "Rejecting packet from '%s.%d' that is flagged as a full frame but is too short\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
return 1;
}
@@ -6616,7 +6590,7 @@ static int socket_process(struct iax2_thread *thread)
if (f.datalen) {
if (f.frametype == AST_FRAME_IAX) {
if (iax_parse_ies(&ies, thread->buf + sizeof(*fh), f.datalen)) {
- ast_log(LOG_WARNING, "Undecodable frame received from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
+ ast_log(LOG_WARNING, "Undecodable frame received from '%s'\n", ast_inet_ntoa(sin.sin_addr));
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
}
@@ -6761,7 +6735,7 @@ retryowner:
/* They're not allowed on */
auth_fail(fr->callno, IAX_COMMAND_REJECT);
if (authdebug)
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, who was trying to reach '%s@%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, who was trying to reach '%s@%s'\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
break;
}
/* This might re-enter the IAX code and need the lock */
@@ -6778,7 +6752,7 @@ retryowner:
iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_NO_ROUTE_DESTINATION);
send_command_final(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
if (authdebug)
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, request '%s@%s' does not exist\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, request '%s@%s' does not exist\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
} else {
/* Select an appropriate format */
@@ -6822,9 +6796,9 @@ retryowner:
send_command_final(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
if (authdebug) {
if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP))
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
else
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
}
} else {
/* Pick one... */
@@ -6862,7 +6836,7 @@ retryowner:
ast_log(LOG_ERROR, "No best format in 0x%x???\n", iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
send_command_final(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
if (authdebug)
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
ast_set_flag(iaxs[fr->callno], IAX_ALREADYGONE);
break;
}
@@ -6882,7 +6856,7 @@ retryowner:
"%sactual format = %s,\n"
"%shost prefs = %s,\n"
"%spriority = %s\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr),
+ ast_inet_ntoa(sin.sin_addr),
VERBOSE_PREFIX_4,
ast_getformatname(iaxs[fr->callno]->peerformat),
VERBOSE_PREFIX_4,
@@ -6900,7 +6874,7 @@ retryowner:
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD);
/* If this is a TBD call, we're ready but now what... */
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Accepted unauthenticated TBD call from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_3 "Accepted unauthenticated TBD call from %s\n", ast_inet_ntoa(sin.sin_addr));
}
}
}
@@ -6944,7 +6918,7 @@ retryowner:
if (!ast_test_flag(iaxs[fr->callno], IAX_PROVISION)) {
if (iaxs[fr->callno]->owner && authdebug)
ast_log(LOG_WARNING, "Call rejected by %s: %s\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr->callno]->addr.sin_addr),
+ ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr),
ies.cause ? ies.cause : "<Unknown>");
ast_log(LOG_DEBUG, "Immediately destroying %d, having received reject\n",
fr->callno);
@@ -6996,14 +6970,14 @@ retryowner:
iaxs[fr->callno]->peerformat = iaxs[fr->callno]->capability;
}
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Call accepted by %s (format %s)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr->callno]->addr.sin_addr), ast_getformatname(iaxs[fr->callno]->peerformat));
+ ast_verbose(VERBOSE_PREFIX_3 "Call accepted by %s (format %s)\n", ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr), ast_getformatname(iaxs[fr->callno]->peerformat));
if (!(iaxs[fr->callno]->peerformat & iaxs[fr->callno]->capability)) {
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_BEARERCAPABILITY_NOTAVAIL);
send_command_final(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
if (authdebug)
- ast_log(LOG_NOTICE, "Rejected call to %s, format 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected call to %s, format 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
} else {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
if (iaxs[fr->callno]->owner) {
@@ -7116,7 +7090,7 @@ retryowner2:
iaxs[fr->callno]->lag = ts - fr->ts;
if (option_debug && iaxdebug)
ast_log(LOG_DEBUG, "Peer %s lag measured as %dms\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr->callno]->addr.sin_addr), iaxs[fr->callno]->lag);
+ ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr), iaxs[fr->callno]->lag);
}
break;
case IAX_COMMAND_AUTHREQ:
@@ -7127,7 +7101,7 @@ retryowner2:
if (authenticate_reply(iaxs[fr->callno], &iaxs[fr->callno]->addr, &ies, iaxs[fr->callno]->secret, iaxs[fr->callno]->outkey)) {
ast_log(LOG_WARNING,
"I don't know how to authenticate %s to %s\n",
- ies.username ? ies.username : "<unknown>", ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr->callno]->addr.sin_addr));
+ ies.username ? ies.username : "<unknown>", ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr));
}
break;
case IAX_COMMAND_AUTHREP:
@@ -7141,7 +7115,7 @@ retryowner2:
}
if (authenticate_verify(iaxs[fr->callno], &ies)) {
if (authdebug)
- ast_log(LOG_NOTICE, "Host %s failed to authenticate as %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr->callno]->addr.sin_addr), iaxs[fr->callno]->username);
+ ast_log(LOG_NOTICE, "Host %s failed to authenticate as %s\n", ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr), iaxs[fr->callno]->username);
memset(&ied0, 0, sizeof(ied0));
auth_fail(fr->callno, IAX_COMMAND_REJECT);
break;
@@ -7153,7 +7127,7 @@ retryowner2:
exists = 0;
if (strcmp(iaxs[fr->callno]->exten, "TBD") && !exists) {
if (authdebug)
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, request '%s@%s' does not exist\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, request '%s@%s' does not exist\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "No such context/extension");
iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_NO_ROUTE_DESTINATION);
@@ -7196,9 +7170,9 @@ retryowner2:
if (!format) {
if (authdebug) {
if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP))
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
else
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
}
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
@@ -7236,9 +7210,9 @@ retryowner2:
ast_log(LOG_ERROR, "No best format in 0x%x???\n", iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability);
if (authdebug) {
if(ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP))
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested 0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->capability);
else
- ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
+ ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat, iaxs[fr->callno]->peercapability, iaxs[fr->callno]->capability);
}
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
@@ -7261,7 +7235,7 @@ retryowner2:
"%sactual format = %s,\n"
"%shost prefs = %s,\n"
"%spriority = %s\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr),
+ ast_inet_ntoa(sin.sin_addr),
VERBOSE_PREFIX_4,
ast_getformatname(iaxs[fr->callno]->peerformat),
VERBOSE_PREFIX_4,
@@ -7280,7 +7254,7 @@ retryowner2:
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_TBD);
/* If this is a TBD call, we're ready but now what... */
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Accepted AUTHENTICATED TBD call from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_3 "Accepted AUTHENTICATED TBD call from %s\n", ast_inet_ntoa(sin.sin_addr));
}
}
}
@@ -7291,7 +7265,7 @@ retryowner2:
ast_copy_string(iaxs[fr->callno]->exten, ies.called_number ? ies.called_number : "s", sizeof(iaxs[fr->callno]->exten));
if (!ast_exists_extension(NULL, iaxs[fr->callno]->context, iaxs[fr->callno]->exten, 1, iaxs[fr->callno]->cid_num)) {
if (authdebug)
- ast_log(LOG_NOTICE, "Rejected dial attempt from %s, request '%s@%s' does not exist\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
+ ast_log(LOG_NOTICE, "Rejected dial attempt from %s, request '%s@%s' does not exist\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->exten, iaxs[fr->callno]->context);
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "No such context/extension");
iax_ie_append_byte(&ied0, IAX_IE_CAUSECODE, AST_CAUSE_NO_ROUTE_DESTINATION);
@@ -7299,7 +7273,7 @@ retryowner2:
} else {
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Accepting DIAL from %s, formats = 0x%x\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr->callno]->peerformat);
+ ast_verbose(VERBOSE_PREFIX_3 "Accepting DIAL from %s, formats = 0x%x\n", ast_inet_ntoa(sin.sin_addr), iaxs[fr->callno]->peerformat);
ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
send_command(iaxs[fr->callno], AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, 0, NULL, 0, -1);
if(!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat)))
@@ -7351,7 +7325,7 @@ retryowner2:
case IAX_COMMAND_REGREJ:
if (iaxs[fr->callno]->reg) {
if (authdebug) {
- ast_log(LOG_NOTICE, "Registration of '%s' rejected: '%s' from: '%s'\n", iaxs[fr->callno]->reg->username, ies.cause ? ies.cause : "<unknown>", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
+ ast_log(LOG_NOTICE, "Registration of '%s' rejected: '%s' from: '%s'\n", iaxs[fr->callno]->reg->username, ies.cause ? ies.cause : "<unknown>", ast_inet_ntoa(sin.sin_addr));
manager_event(EVENT_FLAG_SYSTEM, "Registry", "Channel: IAX2\r\nUsername: %s\r\nStatus: Rejected\r\nCause: %s\r\n", iaxs[fr->callno]->reg->username, ies.cause ? ies.cause : "<unknown>");
}
iaxs[fr->callno]->reg->regstate = REG_STATE_REJECTED;
@@ -7797,7 +7771,6 @@ static int iax2_prov_app(struct ast_channel *chan, void *data)
char *opts;
int force =0;
unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
- char iabuf[INET_ADDRSTRLEN];
if (ast_strlen_zero(data))
data = "default";
sdata = ast_strdupa(data);
@@ -7816,7 +7789,7 @@ static int iax2_prov_app(struct ast_channel *chan, void *data)
res = iax2_provision(&iaxs[callno]->addr, iaxs[callno]->sockfd, NULL, sdata, force);
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Provisioned IAXY at '%s' with '%s'= %d\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[callno]->addr.sin_addr),
+ ast_inet_ntoa(iaxs[callno]->addr.sin_addr),
sdata, res);
return res;
}
@@ -9383,7 +9356,6 @@ static int function_iaxpeer(struct ast_channel *chan, char *cmd, char *data, cha
{
struct iax2_peer *peer;
char *peername, *colname;
- char iabuf[INET_ADDRSTRLEN];
if (!(peername = ast_strdupa(data)))
return -1;
@@ -9391,7 +9363,7 @@ static int function_iaxpeer(struct ast_channel *chan, char *cmd, char *data, cha
/* if our channel, return the IP address of the endpoint of current channel */
if (!strcmp(peername,"CURRENTCHANNEL")) {
unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
- ast_copy_string(buf, iaxs[callno]->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[callno]->addr.sin_addr) : "", len);
+ ast_copy_string(buf, iaxs[callno]->addr.sin_addr.s_addr ? ast_inet_ntoa(iaxs[callno]->addr.sin_addr) : "", len);
return 0;
}
@@ -9406,7 +9378,7 @@ static int function_iaxpeer(struct ast_channel *chan, char *cmd, char *data, cha
return -1;
if (!strcasecmp(colname, "ip")) {
- ast_copy_string(buf, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "", len);
+ ast_copy_string(buf, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "", len);
} else if (!strcasecmp(colname, "status")) {
peer_status(peer, buf, len);
} else if (!strcasecmp(colname, "mailbox")) {
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index 6ea1462ee..7ba3bc539 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -562,7 +562,7 @@ static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p,
snprintf(pass, sizeof(pass), "%08lx%08lx", ast_random(), ast_random());
ast_copy_string(ours1->username, user, sizeof(ours1->username));
ast_copy_string(ours1->password, pass, sizeof(ours1->password));
- ast_inet_ntoa(ours1->ip, sizeof(ours1->ip), us);
+ ast_copy_string(ours1->ip, ast_inet_ntoa(us), sizeof(ours1->ip));
ours1->protocol = AJI_PROTOCOL_UDP;
ours1->type = AJI_CONNECT_LOCAL;
ours1->generation = 0;
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 0d1a857a1..b70e17154 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -498,9 +498,8 @@ static int resend_response(struct mgcp_subchannel *sub, struct mgcp_response *re
{
struct mgcp_endpoint *p = sub->parent;
int res;
- char iabuf[INET_ADDRSTRLEN];
if (mgcpdebug) {
- ast_verbose("Retransmitting:\n%s\n to %s:%d\n", resp->buf, ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
+ ast_verbose("Retransmitting:\n%s\n to %s:%d\n", resp->buf, ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
}
res = __mgcp_xmit(p->parent, resp->buf, resp->len);
if (res > 0)
@@ -512,9 +511,8 @@ static int send_response(struct mgcp_subchannel *sub, struct mgcp_request *req)
{
struct mgcp_endpoint *p = sub->parent;
int res;
- char iabuf[INET_ADDRSTRLEN];
if (mgcpdebug) {
- ast_verbose("Transmitting:\n%s\n to %s:%d\n", req->data, ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
+ ast_verbose("Transmitting:\n%s\n to %s:%d\n", req->data, ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
}
res = __mgcp_xmit(p->parent, req->data, req->len);
if (res > 0)
@@ -736,7 +734,6 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
{
int res = 0;
struct mgcp_request **queue, *q, *r, *t;
- char iabuf[INET_ADDRSTRLEN];
ast_mutex_t *l;
ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence);
@@ -792,14 +789,14 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
if (!(*queue)) {
if (mgcpdebug) {
ast_verbose("Posting Request:\n%s to %s:%d\n", req->data,
- ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
+ ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
}
res = mgcp_postrequest(p, sub, req->data, req->len, seqno);
} else {
if (mgcpdebug) {
ast_verbose("Queueing Request:\n%s to %s:%d\n", req->data,
- ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
+ ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
}
}
@@ -1019,7 +1016,6 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
struct mgcp_gateway *g;
struct mgcp_endpoint *e;
int hasendpoints = 0;
- char iabuf[INET_ADDRSTRLEN];
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -1027,7 +1023,7 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
g = gateways;
while(g) {
e = g->endpoints;
- ast_cli(fd, "Gateway '%s' at %s (%s)\n", g->name, g->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), g->addr.sin_addr) : ast_inet_ntoa(iabuf, sizeof(iabuf), g->defaddr.sin_addr), g->dynamic ? "Dynamic" : "Static");
+ ast_cli(fd, "Gateway '%s' at %s (%s)\n", g->name, g->addr.sin_addr.s_addr ? ast_inet_ntoa(g->addr.sin_addr) : ast_inet_ntoa(g->defaddr.sin_addr), g->dynamic ? "Dynamic" : "Static");
while(e) {
/* Don't show wilcard endpoint */
if (strcmp(e->name, g->wcardep) !=0)
@@ -1536,7 +1532,6 @@ static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, s
struct mgcp_endpoint *p = NULL;
struct mgcp_subchannel *sub = NULL;
struct mgcp_gateway *g;
- char iabuf[INET_ADDRSTRLEN];
char tmp[256] = "";
char *at = NULL, *c;
int found = 0;
@@ -1568,7 +1563,7 @@ static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, s
if (ast_ouraddrfor(&g->addr.sin_addr, &g->ourip))
memcpy(&g->ourip, &__ourip, sizeof(g->ourip));
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Registered MGCP gateway '%s' at %s port %d\n", g->name, ast_inet_ntoa(iabuf, sizeof(iabuf), g->addr.sin_addr), ntohs(g->addr.sin_port));
+ ast_verbose(VERBOSE_PREFIX_3 "Registered MGCP gateway '%s' at %s port %d\n", g->name, ast_inet_ntoa(g->addr.sin_addr), ntohs(g->addr.sin_port));
}
}
/* not dynamic, check if the name matches */
@@ -1791,7 +1786,7 @@ static int process_sdp(struct mgcp_subchannel *sub, struct mgcp_request *req)
sin.sin_port = htons(portno);
ast_rtp_set_peer(sub->rtp, &sin);
#if 0
- printf("Peer RTP is at port %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ printf("Peer RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
#endif
/* Scan through the RTP payload types specified in a "m=" line: */
ast_rtp_pt_clear(sub->rtp);
@@ -1972,7 +1967,6 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
char t[256];
char m[256] = "";
char a[1024] = "";
- char iabuf[INET_ADDRSTRLEN];
int x;
struct sockaddr_in dest;
struct mgcp_endpoint *p = sub->parent;
@@ -1998,12 +1992,12 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
}
}
if (mgcpdebug) {
- ast_verbose("We're at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->ourip), ntohs(sin.sin_port));
+ ast_verbose("We're at %s port %d\n", ast_inet_ntoa(p->parent->ourip), ntohs(sin.sin_port));
}
snprintf(v, sizeof(v), "v=0\r\n");
- snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", getpid(), getpid(), ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
+ snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", getpid(), getpid(), ast_inet_ntoa(dest.sin_addr));
snprintf(s, sizeof(s), "s=session\r\n");
- snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
+ snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr));
snprintf(t, sizeof(t), "t=0 0\r\n");
snprintf(m, sizeof(m), "m=audio %d RTP/AVP", ntohs(dest.sin_port));
for (x = 1; x <= AST_FORMAT_MAX_AUDIO; x <<= 1) {
@@ -2334,7 +2328,6 @@ static struct mgcp_request *find_command(struct mgcp_endpoint *p, struct mgcp_su
struct mgcp_request **queue, ast_mutex_t *l, int ident)
{
struct mgcp_request *prev, *req;
- char iabuf[INET_ADDRSTRLEN];
ast_mutex_lock(l);
for (prev = NULL, req = *queue; req; prev = req, req = req->next) {
@@ -2349,7 +2342,7 @@ static struct mgcp_request *find_command(struct mgcp_endpoint *p, struct mgcp_su
if (*queue) {
if (mgcpdebug) {
ast_verbose("Posting Queued Request:\n%s to %s:%d\n", (*queue)->data,
- ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
+ ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
}
mgcp_postrequest(p, sub, (*queue)->data, (*queue)->len, (*queue)->trid);
@@ -2954,7 +2947,6 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
struct ast_frame f = { 0, };
struct mgcp_endpoint *p = sub->parent;
struct mgcp_gateway *g = NULL;
- char iabuf[INET_ADDRSTRLEN];
int res;
if (mgcpdebug) {
@@ -3204,7 +3196,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
ast_log(LOG_NOTICE, "Received unknown event '%s' from %s@%s\n", ev, p->name, p->parent->name);
}
} else {
- ast_log(LOG_WARNING, "Unknown verb '%s' received from %s\n", req->verb, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_WARNING, "Unknown verb '%s' received from %s\n", req->verb, ast_inet_ntoa(sin->sin_addr));
transmit_response(sub, "510", req, "Unknown verb");
}
return 0;
@@ -3251,7 +3243,6 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
socklen_t len;
int result;
int ident;
- char iabuf[INET_ADDRSTRLEN];
len = sizeof(sin);
memset(&req, 0, sizeof(req));
res = recvfrom(mgcpsock, req.data, sizeof(req.data) - 1, 0, (struct sockaddr *)&sin, &len);
@@ -3263,7 +3254,7 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
req.data[res] = '\0';
req.len = res;
if (mgcpdebug) {
- ast_verbose("MGCP read: \n%s\nfrom %s:%d\n", req.data, ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_verbose("MGCP read: \n%s\nfrom %s:%d\n", req.data, ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
}
parse(&req);
if (req.headers < 1) {
@@ -3271,7 +3262,7 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
return 1;
}
if (ast_strlen_zero(req.identifier)) {
- ast_log(LOG_NOTICE, "Message from %s missing identifier\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
+ ast_log(LOG_NOTICE, "Message from %s missing identifier\n", ast_inet_ntoa(sin.sin_addr));
return 1;
}
@@ -4049,7 +4040,6 @@ static int reload_config(void)
struct ast_variable *v;
struct mgcp_gateway *g;
struct mgcp_endpoint *e;
- char iabuf[INET_ADDRSTRLEN];
char *cat;
struct ast_hostent ahp;
struct hostent *hp;
@@ -4192,14 +4182,14 @@ static int reload_config(void)
} else {
if (bind(mgcpsock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) {
ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port),
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
strerror(errno));
close(mgcpsock);
mgcpsock = -1;
} else {
if (option_verbose > 1) {
ast_verbose(VERBOSE_PREFIX_2 "MGCP Listening on %s:%d\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port));
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos);
}
if (setsockopt(mgcpsock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index d621e7218..1c1022157 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1678,12 +1678,11 @@ static inline int sip_debug_test_pvt(struct sip_pvt *p)
static int __sip_xmit(struct sip_pvt *p, char *data, int len)
{
int res;
- char iabuf[INET_ADDRSTRLEN];
const struct sockaddr_in *dst = sip_real_dst(p);
res=sendto(sipsock, data, len, 0, (const struct sockaddr *)dst, sizeof(struct sockaddr_in));
if (res != len)
- ast_log(LOG_WARNING, "sip_xmit of %p (len %d) to %s:%d returned %d: %s\n", data, len, ast_inet_ntoa(iabuf, sizeof(iabuf), dst->sin_addr), ntohs(dst->sin_port), res, strerror(errno));
+ ast_log(LOG_WARNING, "sip_xmit of %p (len %d) to %s:%d returned %d: %s\n", data, len, ast_inet_ntoa(dst->sin_addr), ntohs(dst->sin_port), res, strerror(errno));
return res;
}
@@ -1691,13 +1690,12 @@ static int __sip_xmit(struct sip_pvt *p, char *data, int len)
/*! \brief Build a Via header for a request */
static void build_via(struct sip_pvt *p)
{
- char iabuf[INET_ADDRSTRLEN];
/* Work around buggy UNIDEN UIP200 firmware */
const char *rport = ast_test_flag(&p->flags[0], SIP_NAT) & SIP_NAT_RFC3581 ? ";rport" : "";
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
ast_string_field_build(p, via, "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x%s",
- ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch, rport);
+ ast_inet_ntoa(p->ourip), ourport, p->branch, rport);
}
/*! \brief NAT fix - decide which IP address to use for ASterisk server?
@@ -1730,9 +1728,8 @@ static enum sip_result ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *
}
*us = externip.sin_addr;
if (option_debug) {
- char iabuf[INET_ADDRSTRLEN];
- ast_inet_ntoa(iabuf, sizeof(iabuf), *(struct in_addr *)&them->s_addr);
- ast_log(LOG_DEBUG, "Target address %s is not local, substituting externip\n", iabuf);
+ ast_log(LOG_DEBUG, "Target address %s is not local, substituting externip\n",
+ ast_inet_ntoa(*(struct in_addr *)&them->s_addr));
}
} else if (bindaddr.sin_addr.s_addr)
*us = bindaddr.sin_addr;
@@ -1784,7 +1781,6 @@ static void append_history_full(struct sip_pvt *p, const char *fmt, ...)
static int retrans_pkt(void *data)
{
struct sip_pkt *pkt = data, *prev, *cur = NULL;
- char iabuf[INET_ADDRSTRLEN];
int reschedule = DEFAULT_RETRANS;
/* Lock channel PVT */
@@ -1820,7 +1816,7 @@ static int retrans_pkt(void *data)
const struct sockaddr_in *dst = sip_real_dst(pkt->owner);
ast_verbose("Retransmitting #%d (%s) to %s:%d:\n%s\n---\n",
pkt->retrans, sip_nat_mode(pkt->owner),
- ast_inet_ntoa(iabuf, sizeof(iabuf), dst->sin_addr),
+ ast_inet_ntoa(dst->sin_addr),
ntohs(dst->sin_port), pkt->data);
}
@@ -2080,12 +2076,11 @@ static int send_response(struct sip_pvt *p, struct sip_request *req, enum xmitty
add_blank(req);
if (sip_debug_test_pvt(p)) {
- char iabuf[INET_ADDRSTRLEN];
const struct sockaddr_in *dst = sip_real_dst(p);
ast_verbose("%sTransmitting (%s) to %s:%d:\n%s\n---\n",
reliable ? "Reliably " : "", sip_nat_mode(p),
- ast_inet_ntoa(iabuf, sizeof(iabuf), dst->sin_addr),
+ ast_inet_ntoa(dst->sin_addr),
ntohs(dst->sin_port), req->data);
}
if (recordhistory) {
@@ -2109,11 +2104,10 @@ static int send_request(struct sip_pvt *p, struct sip_request *req, enum xmittyp
add_blank(req);
if (sip_debug_test_pvt(p)) {
- char iabuf[INET_ADDRSTRLEN];
if (ast_test_flag(&p->flags[0], SIP_NAT_ROUTE))
- ast_verbose("%sTransmitting (NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port), req->data);
+ ast_verbose("%sTransmitting (NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port), req->data);
else
- ast_verbose("%sTransmitting (no NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port), req->data);
+ ast_verbose("%sTransmitting (no NAT) to %s:%d:\n%s\n---\n", reliable ? "Reliably " : "", ast_inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port), req->data);
}
if (recordhistory) {
struct sip_request tmp;
@@ -2196,7 +2190,7 @@ static int sip_sendtext(struct ast_channel *ast, const char *text)
static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey)
{
char port[10];
- char ipaddr[20];
+ char ipaddr[INET_ADDRSTRLEN];
char regseconds[20];
char *sysname = ast_config_AST_SYSTEM_NAME;
@@ -2206,7 +2200,7 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin,
const char *fc = fullcontact ? "fullcontact" : NULL;
snprintf(regseconds, sizeof(regseconds), "%d", (int)nowtime); /* Expiration time */
- ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr);
+ ast_copy_string(ipaddr, ast_inet_ntoa(sin->sin_addr), sizeof(ipaddr));
snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
if (ast_strlen_zero(sysname)) /* No system name, disable this */
@@ -2314,17 +2308,16 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
struct sip_peer *peer;
struct ast_variable *var = NULL;
struct ast_variable *tmp;
- char iabuf[80];
+ char ipaddr[INET_ADDRSTRLEN];
/* First check on peer name */
if (newpeername)
var = ast_load_realtime("sippeers", "name", newpeername, NULL);
else if (sin) { /* Then check on IP address for dynamic peers */
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
- var = ast_load_realtime("sippeers", "host", iabuf, NULL); /* First check for fixed IP hosts */
+ ast_copy_string(ipaddr, ast_inet_ntoa(sin->sin_addr), sizeof(ipaddr));
+ var = ast_load_realtime("sippeers", "host", ipaddr, NULL); /* First check for fixed IP hosts */
if (!var)
- var = ast_load_realtime("sippeers", "ipaddr", iabuf, NULL); /* Then check for registred hosts */
-
+ var = ast_load_realtime("sippeers", "ipaddr", ipaddr, NULL); /* Then check for registred hosts */
}
if (!var)
@@ -2342,7 +2335,7 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
}
if (!newpeername) { /* Did not find peer in realtime */
- ast_log(LOG_WARNING, "Cannot Determine peer name ip=%s\n", iabuf);
+ ast_log(LOG_WARNING, "Cannot Determine peer name ip=%s\n", ipaddr);
ast_variables_destroy(var);
return NULL;
}
@@ -2548,12 +2541,8 @@ static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer)
ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
}
}
- if (ast_strlen_zero(r->tohost)) {
- char iabuf[INET_ADDRSTRLEN];
-
- ast_inet_ntoa(iabuf, sizeof(iabuf), r->sa.sin_addr);
- ast_string_field_set(r, tohost, iabuf);
- }
+ if (ast_strlen_zero(r->tohost))
+ ast_string_field_set(r, tohost, ast_inet_ntoa(r->sa.sin_addr));
if (!ast_strlen_zero(peer->fromdomain))
ast_string_field_set(r, fromdomain, peer->fromdomain);
if (!ast_strlen_zero(peer->fromuser))
@@ -3964,10 +3953,9 @@ static char *generate_random_string(char *buf, size_t size)
/*! \brief Build SIP Call-ID value for a non-REGISTER transaction */
static void build_callid_pvt(struct sip_pvt *pvt)
{
- char iabuf[INET_ADDRSTRLEN];
char buf[33];
- const char *host = S_OR(pvt->fromdomain, ast_inet_ntoa(iabuf, sizeof(iabuf), pvt->ourip));
+ const char *host = S_OR(pvt->fromdomain, ast_inet_ntoa(pvt->ourip));
ast_string_field_build(pvt, callid, "%s@%s", generate_random_string(buf, sizeof(buf)), host);
@@ -3976,10 +3964,9 @@ static void build_callid_pvt(struct sip_pvt *pvt)
/*! \brief Build SIP Call-ID value for a REGISTER transaction */
static void build_callid_registry(struct sip_registry *reg, struct in_addr ourip, const char *fromdomain)
{
- char iabuf[INET_ADDRSTRLEN];
char buf[33];
- const char *host = S_OR(fromdomain, ast_inet_ntoa(iabuf, sizeof(iabuf), ourip));
+ const char *host = S_OR(fromdomain, ast_inet_ntoa(ourip));
ast_string_field_build(reg, callid, "%s@%s", generate_random_string(buf, sizeof(buf)), host);
}
@@ -4456,7 +4443,6 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
const char *c;
const char *a;
char host[258];
- char iabuf[INET_ADDRSTRLEN];
int len = -1;
int portno = -1; /*!< RTP Audio port number */
int vportno = -1; /*!< RTP Video port number */
@@ -4633,7 +4619,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
sin.sin_port = htons(portno);
ast_rtp_set_peer(p->rtp, &sin);
if (debug)
- ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(iabuf,sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
ast_rtp_stop(p->rtp);
if (debug)
@@ -4650,7 +4636,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
sin.sin_port = htons(udptlportno);
ast_udptl_set_peer(p->udptl, &sin);
if (debug)
- ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
ast_udptl_stop(p->udptl);
if (debug)
@@ -4898,14 +4884,14 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
if (p->rtp && sin.sin_port) {
ast_rtp_set_peer(p->rtp, &sin);
if (debug)
- ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(iabuf,sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
}
/* Setup video port number */
if (p->vrtp && vsin.sin_port) {
ast_rtp_set_peer(p->vrtp, &vsin);
if (debug)
- ast_verbose("Peer video RTP is at port %s:%d\n", ast_inet_ntoa(iabuf,sizeof(iabuf), vsin.sin_addr), ntohs(vsin.sin_port));
+ ast_verbose("Peer video RTP is at port %s:%d\n", ast_inet_ntoa(vsin.sin_addr), ntohs(vsin.sin_port));
}
/* Ok, we're going with this offer */
@@ -5105,7 +5091,6 @@ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, const st
break;
if (!copied) { /* Only check for empty rport in topmost via header */
- char iabuf[INET_ADDRSTRLEN];
char *rport;
/* Find ;rport; (empty request) */
@@ -5134,12 +5119,12 @@ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, const st
another RFC (RFC3581). I'll leave the original comments in for
posterity. */
snprintf(new, sizeof(new), "%s;received=%s;rport=%d",
- tmp, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr),
+ tmp, ast_inet_ntoa(p->recv.sin_addr),
ntohs(p->recv.sin_port));
} else {
/* We should *always* add a received to the topmost via */
snprintf(new, sizeof(new), "%s;received=%s",
- oh, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr));
+ oh, ast_inet_ntoa(p->recv.sin_addr));
}
oh = new; /* the header to copy */
} /* else add the following via headers untouched */
@@ -5185,7 +5170,6 @@ static void add_route(struct sip_request *req, struct sip_route *route)
static void set_destination(struct sip_pvt *p, char *uri)
{
char *h, *maddr, hostname[256];
- char iabuf[INET_ADDRSTRLEN];
int port, hn;
struct hostent *hp;
struct ast_hostent ahp;
@@ -5243,7 +5227,7 @@ static void set_destination(struct sip_pvt *p, char *uri)
memcpy(&p->sa.sin_addr, hp->h_addr, sizeof(p->sa.sin_addr));
p->sa.sin_port = htons(port);
if (debug)
- ast_verbose("set_destination: set destination to %s, port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), port);
+ ast_verbose("set_destination: set destination to %s, port %d\n", ast_inet_ntoa(p->sa.sin_addr), port);
}
/*! \brief Initialize SIP response, based on SIP request */
@@ -5643,7 +5627,6 @@ static int add_t38_sdp(struct sip_request *resp, struct sip_pvt *p)
size_t m_modem_left = sizeof(m_modem);
char *a_modem_next = a_modem;
size_t a_modem_left = sizeof(a_modem);
- char iabuf[INET_ADDRSTRLEN];
struct sockaddr_in udptldest = { 0, };
int debug;
@@ -5673,7 +5656,7 @@ static int add_t38_sdp(struct sip_request *resp, struct sip_pvt *p)
}
if (debug) {
- ast_log(LOG_DEBUG, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ntohs(udptlsin.sin_port));
+ ast_log(LOG_DEBUG, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(udptlsin.sin_port));
}
/* We break with the "recommendation" and send our IP, in order that our
@@ -5686,9 +5669,9 @@ static int add_t38_sdp(struct sip_request *resp, struct sip_pvt *p)
p->t38.jointcapability);
}
snprintf(v, sizeof(v), "v=0\r\n");
- snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(iabuf, sizeof(iabuf), udptldest.sin_addr));
+ snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(udptldest.sin_addr));
snprintf(s, sizeof(s), "s=session\r\n");
- snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), udptldest.sin_addr));
+ snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(udptldest.sin_addr));
snprintf(t, sizeof(t), "t=0 0\r\n");
ast_build_string(&m_modem_next, &m_modem_left, "m=image %d udptl t38\r\n", ntohs(udptldest.sin_port));
@@ -5779,7 +5762,6 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
size_t a_audio_left = sizeof(a_audio);
size_t a_video_left = sizeof(a_video);
- char iabuf[INET_ADDRSTRLEN];
int x;
int capability;
int needvideo = FALSE;
@@ -5858,7 +5840,7 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
if (p->maxcallbitrate)
snprintf(bandwidth, sizeof(bandwidth), "b=CT:%d\r\n", p->maxcallbitrate);
if (debug)
- ast_verbose("Video is at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ntohs(vsin.sin_port));
+ ast_verbose("Video is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(vsin.sin_port));
/* For video, we can't negotiate video offers. Let's compare the incoming call with what we got. */
if (p->prefcodec) {
@@ -5885,15 +5867,15 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
}
}
if (debug)
- ast_verbose("Audio is at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ntohs(sin.sin_port));
+ ast_verbose("Audio is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(sin.sin_port));
/* Start building generic SDP headers */
/* We break with the "recommendation" and send our IP, in order that our
peer doesn't have to ast_gethostbyname() us */
- snprintf(owner, sizeof(owner), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
- snprintf(connection, sizeof(connection), "c=IN IP4 %s\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
+ snprintf(owner, sizeof(owner), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(dest.sin_addr));
+ snprintf(connection, sizeof(connection), "c=IN IP4 %s\r\n", ast_inet_ntoa(dest.sin_addr));
ast_build_string(&m_audio_next, &m_audio_left, "m=audio %d RTP/AVP", ntohs(dest.sin_port));
if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD_ONEDIR))
@@ -6176,13 +6158,11 @@ static void extract_uri(struct sip_pvt *p, struct sip_request *req)
/*! \brief Build contact header - the contact header we send out */
static void build_contact(struct sip_pvt *p)
{
- char iabuf[INET_ADDRSTRLEN];
-
/* Construct Contact: header */
if (ourport != 5060) /* Needs to be 5060, according to the RFC */
- ast_string_field_build(p, our_contact, "<sip:%s%s%s:%d>", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport);
+ ast_string_field_build(p, our_contact, "<sip:%s%s%s:%d>", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(p->ourip), ourport);
else
- ast_string_field_build(p, our_contact, "<sip:%s%s%s>", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip));
+ ast_string_field_build(p, our_contact, "<sip:%s%s%s>", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(p->ourip));
}
/*! \brief Build the Remote Party-ID & From using callingpres options */
@@ -6194,7 +6174,6 @@ static void build_rpid(struct sip_pvt *p)
char buf[256];
const char *clid = default_callerid;
const char *clin = NULL;
- char iabuf[INET_ADDRSTRLEN];
const char *fromdomain;
if (!ast_strlen_zero(p->rpid) || !ast_strlen_zero(p->rpid_from))
@@ -6253,7 +6232,7 @@ static void build_rpid(struct sip_pvt *p)
break;
}
- fromdomain = S_OR(p->fromdomain, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip));
+ fromdomain = S_OR(p->fromdomain, ast_inet_ntoa(p->ourip));
snprintf(buf, sizeof(buf), "\"%s\" <sip:%s@%s>", clin, clid, fromdomain);
if (send_pres_tags)
@@ -6275,7 +6254,6 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
char to[256];
char tmp[BUFSIZ/2];
char tmp2[BUFSIZ/2];
- char iabuf[INET_ADDRSTRLEN];
const char *l = NULL, *n = NULL;
int x;
char urioptions[256]="";
@@ -6341,9 +6319,9 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
}
if ((ourport != 5060) && ast_strlen_zero(p->fromdomain)) /* Needs to be 5060 */
- snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=%s", n, l, S_OR(p->fromdomain, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip)), ourport, p->tag);
+ snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=%s", n, l, S_OR(p->fromdomain, ast_inet_ntoa(p->ourip)), ourport, p->tag);
else
- snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=%s", n, l, S_OR(p->fromdomain, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip)), p->tag);
+ snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=%s", n, l, S_OR(p->fromdomain, ast_inet_ntoa(p->ourip)), p->tag);
/* If we're calling a registered SIP peer, use the fullcontact to dial to the peer */
if (!ast_strlen_zero(p->fullcontact)) {
@@ -6679,7 +6657,6 @@ static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs,
char tmp[500];
char *t = tmp;
size_t maxbytes = sizeof(tmp);
- char iabuf[INET_ADDRSTRLEN];
initreqprep(&req, p, SIP_NOTIFY);
add_header(&req, "Event", "message-summary");
@@ -6687,7 +6664,7 @@ static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs,
ast_build_string(&t, &maxbytes, "Messages-Waiting: %s\r\n", newmsgs ? "yes" : "no");
ast_build_string(&t, &maxbytes, "Message-Account: sip:%s@%s\r\n",
- S_OR(vmexten, default_vmexten), S_OR(p->fromdomain, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip)));
+ S_OR(vmexten, default_vmexten), S_OR(p->fromdomain, ast_inet_ntoa(p->ourip)));
ast_build_string(&t, &maxbytes, "Voice-Message: %d/%d (0/0)\r\n", newmsgs, oldmsgs);
if (p->subscribed) {
if (p->expiry)
@@ -7225,7 +7202,6 @@ static int sip_poke_peer_s(void *data)
static void reg_source_db(struct sip_peer *peer)
{
char data[256];
- char iabuf[INET_ADDRSTRLEN];
struct in_addr in;
int expiry;
int port;
@@ -7263,7 +7239,7 @@ static void reg_source_db(struct sip_peer *peer)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
- peer->name, peer->username, ast_inet_ntoa(iabuf, sizeof(iabuf), in), port, expiry);
+ peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
memset(&peer->addr, 0, sizeof(peer->addr));
peer->addr.sin_family = AF_INET;
@@ -7370,7 +7346,6 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
{
char contact[BUFSIZ];
char data[BUFSIZ];
- char iabuf[INET_ADDRSTRLEN];
const char *expires = get_header(req, "Expires");
int expiry = atoi(expires);
char *curi, *n, *pt;
@@ -7491,7 +7466,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
peer->expire = ast_test_flag(&peer->flags[0], SIP_REALTIME) ? -1 :
ast_sched_add(sched, (expiry + 10) * 1000, expire_register, peer);
pvt->expiry = expiry;
- snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry, peer->username, peer->fullcontact);
+ snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry, peer->username, peer->fullcontact);
if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_RT_FROMCONTACT))
ast_db_put("SIP/Registry", peer->name, data);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Registered\r\n", peer->name);
@@ -7500,7 +7475,7 @@ static enum parse_register_result parse_register_contact(struct sip_pvt *pvt, st
if (inaddrcmp(&peer->addr, &oldsin)) {
sip_poke_peer(peer);
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s port %d expires %d\n", peer->name, ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry);
+ ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s port %d expires %d\n", peer->name, ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expiry);
register_peer_exten(peer, 1);
}
@@ -7853,7 +7828,6 @@ static enum check_auth_result register_verify(struct sip_pvt *p, struct sockaddr
enum check_auth_result res = AUTH_NOT_FOUND;
struct sip_peer *peer;
char tmp[256];
- char iabuf[INET_ADDRSTRLEN];
char *name, *c;
char *t;
char *domain;
@@ -7875,7 +7849,7 @@ static enum check_auth_result register_verify(struct sip_pvt *p, struct sockaddr
name = c + 4;
} else {
name = c;
- ast_log(LOG_NOTICE, "Invalid to address: '%s' from %s (missing sip:) trying to use anyway...\n", c, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
+ ast_log(LOG_NOTICE, "Invalid to address: '%s' from %s (missing sip:) trying to use anyway...\n", c, ast_inet_ntoa(sin->sin_addr));
}
/* Strip off the domain name */
@@ -8422,7 +8396,6 @@ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
static void check_via(struct sip_pvt *p, struct sip_request *req)
{
char via[256];
- char iabuf[INET_ADDRSTRLEN];
char *c, *pt;
struct hostent *hp;
struct ast_hostent ahp;
@@ -8461,7 +8434,7 @@ static void check_via(struct sip_pvt *p, struct sip_request *req)
if (sip_debug_test_pvt(p)) {
const struct sockaddr_in *dst = sip_real_dst(p);
- ast_verbose("Sending to %s : %d (%s)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), dst->sin_addr), ntohs(dst->sin_port), sip_nat_mode(p));
+ ast_verbose("Sending to %s : %d (%s)\n", ast_inet_ntoa(dst->sin_addr), ntohs(dst->sin_port), sip_nat_mode(p));
}
}
}
@@ -8556,7 +8529,6 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ
char *of;
char rpid_num[50];
const char *rpid;
- char iabuf[INET_ADDRSTRLEN];
enum check_auth_result res = AUTH_SUCCESSFUL;
char *t;
char calleridname[50];
@@ -8850,7 +8822,7 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ
ASTOBJ_UNREF(peer, sip_destroy_peer);
} else {
if (debug)
- ast_verbose("Found no matching peer or user for '%s:%d'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
+ ast_verbose("Found no matching peer or user for '%s:%d'\n", ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
/* do we allow guests? */
if (!global_allowguest) {
@@ -9131,7 +9103,6 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
#define FORMAT "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-8d %-10s %-10s\n"
char name[256];
- char iabuf[INET_ADDRSTRLEN];
int total_peers = 0;
int peers_online = 0;
int peers_offline = 0;
@@ -9199,7 +9170,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
}
snprintf(srch, sizeof(srch), FORMAT, name,
- iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iterator->addr.sin_addr) : "(Unspecified)",
+ iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iterator->addr.sin_addr) : "(Unspecified)",
ast_test_flag(&iterator->flags[1], SIP_PAGE2_DYNAMIC) ? " D " : " ", /* Dynamic or not? */
ast_test_flag(&iterator->flags[0], SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */
iterator->ha ? " A " : " ", /* permit/deny */
@@ -9208,7 +9179,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
if (!s) {/* Normal CLI list */
ast_cli(fd, FORMAT, name,
- iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iterator->addr.sin_addr) : "(Unspecified)",
+ iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iterator->addr.sin_addr) : "(Unspecified)",
ast_test_flag(&iterator->flags[1], SIP_PAGE2_DYNAMIC) ? " D " : " ", /* Dynamic or not? */
ast_test_flag(&iterator->flags[0], SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */
iterator->ha ? " A " : " ", /* permit/deny */
@@ -9232,7 +9203,7 @@ static int _sip_show_peers(int fd, int *total, struct mansession *s, struct mess
"RealtimeDevice: %s\r\n\r\n",
idtext,
iterator->name,
- iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iterator->addr.sin_addr) : "-none-",
+ iterator->addr.sin_addr.s_addr ? ast_inet_ntoa(iterator->addr.sin_addr) : "-none-",
ntohs(iterator->addr.sin_port),
ast_test_flag(&iterator->flags[1], SIP_PAGE2_DYNAMIC) ? "yes" : "no", /* Dynamic or not? */
ast_test_flag(&iterator->flags[0], SIP_NAT_ROUTE) ? "yes" : "no", /* NAT=yes? */
@@ -9582,7 +9553,6 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
{
char status[30] = "";
char cbuf[256];
- char iabuf[INET_ADDRSTRLEN];
struct sip_peer *peer;
char codec_buf[512];
struct ast_codec_pref *pref;
@@ -9662,8 +9632,8 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
ast_cli(fd, " DTMFmode : %s\n", dtmfmode2str(ast_test_flag(&peer->flags[0], SIP_DTMF)));
ast_cli(fd, " LastMsg : %d\n", peer->lastmsg);
ast_cli(fd, " ToHost : %s\n", peer->tohost);
- ast_cli(fd, " Addr->IP : %s Port %d\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)", ntohs(peer->addr.sin_port));
- ast_cli(fd, " Defaddr->IP : %s Port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port));
+ ast_cli(fd, " Addr->IP : %s Port %d\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)", ntohs(peer->addr.sin_port));
+ ast_cli(fd, " Defaddr->IP : %s Port %d\n", ast_inet_ntoa(peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port));
if (!ast_strlen_zero(global_regcontext))
ast_cli(fd, " Reg. exten : %s\n", peer->regexten);
ast_cli(fd, " Def. Username: %s\n", peer->username);
@@ -9742,8 +9712,8 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
astman_append(s, "SIP-DTMFmode: %s\r\n", dtmfmode2str(ast_test_flag(&peer->flags[0], SIP_DTMF)));
astman_append(s, "SIPLastMsg: %d\r\n", peer->lastmsg);
astman_append(s, "ToHost: %s\r\n", peer->tohost);
- astman_append(s, "Address-IP: %s\r\nAddress-Port: %d\r\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "", ntohs(peer->addr.sin_port));
- astman_append(s, "Default-addr-IP: %s\r\nDefault-addr-port: %d\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port));
+ astman_append(s, "Address-IP: %s\r\nAddress-Port: %d\r\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "", ntohs(peer->addr.sin_port));
+ astman_append(s, "Default-addr-IP: %s\r\nDefault-addr-port: %d\r\n", ast_inet_ntoa(peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port));
astman_append(s, "Default-Username: %s\r\n", peer->username);
if (!ast_strlen_zero(global_regcontext))
astman_append(s, "RegExtension: %s\r\n", peer->regexten);
@@ -9883,7 +9853,6 @@ static int sip_show_registry(int fd, int argc, char *argv[])
/*! \brief List global settings for the SIP channel */
static int sip_show_settings(int fd, int argc, char *argv[])
{
- char tmp[BUFSIZ];
int realtimepeers;
int realtimeusers;
@@ -9895,7 +9864,7 @@ static int sip_show_settings(int fd, int argc, char *argv[])
ast_cli(fd, "\n\nGlobal Settings:\n");
ast_cli(fd, "----------------\n");
ast_cli(fd, " SIP Port: %d\n", ntohs(bindaddr.sin_port));
- ast_cli(fd, " Bindaddress: %s\n", ast_inet_ntoa(tmp, sizeof(tmp), bindaddr.sin_addr));
+ ast_cli(fd, " Bindaddress: %s\n", ast_inet_ntoa(bindaddr.sin_addr));
ast_cli(fd, " Videosupport: %s\n", ast_test_flag(&global_flags[1], SIP_PAGE2_VIDEOSUPPORT) ? "Yes" : "No");
ast_cli(fd, " AutoCreatePeer: %s\n", autocreatepeer ? "Yes" : "No");
ast_cli(fd, " Allow unknown access: %s\n", global_allowguest ? "Yes" : "No");
@@ -10021,7 +9990,6 @@ static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions
#define FORMAT2 "%-15.15s %-10.10s %-11.11s %-11.11s %-4.4s %-7.7s %-15.15s\n"
#define FORMAT "%-15.15s %-10.10s %-11.11s %5.5d/%5.5d %-4.4s %-3.3s %-3.3s %-15.15s %-10.10s\n"
struct sip_pvt *cur;
- char iabuf[INET_ADDRSTRLEN];
int numchans = 0;
char *referstatus = NULL;
@@ -10039,7 +10007,7 @@ static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions
referstatus = referstatus2str(cur->refer->status);
}
if (cur->subscribed == NONE && !subscriptions) {
- ast_cli(fd, FORMAT, ast_inet_ntoa(iabuf, sizeof(iabuf), cur->sa.sin_addr),
+ ast_cli(fd, FORMAT, ast_inet_ntoa(cur->sa.sin_addr),
S_OR(cur->username, S_OR(cur->cid_num, "(None)")),
cur->callid,
cur->ocseq, cur->icseq,
@@ -10052,7 +10020,7 @@ static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions
numchans++;
}
if (cur->subscribed != NONE && subscriptions) {
- ast_cli(fd, FORMAT3, ast_inet_ntoa(iabuf, sizeof(iabuf), cur->sa.sin_addr),
+ ast_cli(fd, FORMAT3, ast_inet_ntoa(cur->sa.sin_addr),
S_OR(cur->username, S_OR(cur->cid_num, "(None)")),
cur->callid,
/* the 'complete' exten/context is hidden in the refer_to field for subscriptions */
@@ -10209,7 +10177,6 @@ static char *complete_sip_prune_realtime_user(const char *line, const char *word
static int sip_show_channel(int fd, int argc, char *argv[])
{
struct sip_pvt *cur;
- char iabuf[INET_ADDRSTRLEN];
size_t len;
int found = 0;
@@ -10234,11 +10201,11 @@ static int sip_show_channel(int fd, int argc, char *argv[])
ast_cli(fd, " Joint Codec Capability: %d\n", cur->jointcapability);
ast_cli(fd, " Format: %s\n", ast_getformatname_multiple(formatbuf, sizeof(formatbuf), cur->owner ? cur->owner->nativeformats : 0) );
ast_cli(fd, " MaxCallBR: %d kbps\n", cur->maxcallbitrate);
- ast_cli(fd, " Theoretical Address: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), cur->sa.sin_addr), ntohs(cur->sa.sin_port));
- ast_cli(fd, " Received Address: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), cur->recv.sin_addr), ntohs(cur->recv.sin_port));
+ ast_cli(fd, " Theoretical Address: %s:%d\n", ast_inet_ntoa(cur->sa.sin_addr), ntohs(cur->sa.sin_port));
+ ast_cli(fd, " Received Address: %s:%d\n", ast_inet_ntoa(cur->recv.sin_addr), ntohs(cur->recv.sin_port));
ast_cli(fd, " SIP Transfer mode: %s\n", transfermode2str(cur->allowtransfer));
ast_cli(fd, " NAT Support: %s\n", nat2str(ast_test_flag(&cur->flags[0], SIP_NAT)));
- ast_cli(fd, " Audio IP: %s %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), cur->redirip.sin_addr.s_addr ? cur->redirip.sin_addr : cur->ourip), cur->redirip.sin_addr.s_addr ? "(Outside bridge)" : "(local)" );
+ ast_cli(fd, " Audio IP: %s %s\n", ast_inet_ntoa(cur->redirip.sin_addr.s_addr ? cur->redirip.sin_addr : cur->ourip), cur->redirip.sin_addr.s_addr ? "(Outside bridge)" : "(local)" );
ast_cli(fd, " Our Tag: %s\n", cur->tag);
ast_cli(fd, " Their Tag: %s\n", cur->theirtag);
ast_cli(fd, " SIP User agent: %s\n", cur->useragent);
@@ -10430,7 +10397,6 @@ static int sip_do_debug_ip(int fd, int argc, char *argv[])
{
struct hostent *hp;
struct ast_hostent ahp;
- char iabuf[INET_ADDRSTRLEN];
int port = 0;
char *p, *arg;
@@ -10448,9 +10414,9 @@ static int sip_do_debug_ip(int fd, int argc, char *argv[])
memcpy(&debugaddr.sin_addr, hp->h_addr, sizeof(debugaddr.sin_addr));
debugaddr.sin_port = htons(port);
if (port == 0)
- ast_cli(fd, "SIP Debugging Enabled for IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr));
+ ast_cli(fd, "SIP Debugging Enabled for IP: %s\n", ast_inet_ntoa(debugaddr.sin_addr));
else
- ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), port);
+ ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(debugaddr.sin_addr), port);
ast_set_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE);
@@ -10461,7 +10427,6 @@ static int sip_do_debug_ip(int fd, int argc, char *argv[])
static int sip_do_debug_peer(int fd, int argc, char *argv[])
{
struct sip_peer *peer;
- char iabuf[INET_ADDRSTRLEN];
if (argc != 4)
return RESULT_SHOWUSAGE;
peer = find_peer(argv[3], NULL, 1);
@@ -10470,7 +10435,7 @@ static int sip_do_debug_peer(int fd, int argc, char *argv[])
debugaddr.sin_family = AF_INET;
debugaddr.sin_addr = peer->addr.sin_addr;
debugaddr.sin_port = peer->addr.sin_port;
- ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), ntohs(debugaddr.sin_port));
+ ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(debugaddr.sin_addr), ntohs(debugaddr.sin_port));
ast_set_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE);
} else
ast_cli(fd, "Unable to get IP address of peer '%s'\n", argv[3]);
@@ -10720,7 +10685,6 @@ static int build_reply_digest(struct sip_pvt *p, int method, char* digest, int d
char resp_hash[256];
char uri[256];
char cnonce[80];
- char iabuf[INET_ADDRSTRLEN];
const char *username;
const char *secret;
const char *md5secret;
@@ -10731,7 +10695,7 @@ static int build_reply_digest(struct sip_pvt *p, int method, char* digest, int d
else if (!ast_strlen_zero(p->uri))
ast_copy_string(uri, p->uri, sizeof(uri));
else
- snprintf(uri, sizeof(uri), "sip:%s@%s",p->username, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
+ snprintf(uri, sizeof(uri), "sip:%s@%s",p->username, ast_inet_ntoa(p->sa.sin_addr));
snprintf(cnonce, sizeof(cnonce), "%08lx", ast_random());
@@ -10949,7 +10913,6 @@ static int function_sippeer(struct ast_channel *chan, char *cmd, char *data, cha
{
struct sip_peer *peer;
char *colname;
- char iabuf[INET_ADDRSTRLEN];
if ((colname = strchr(data, ':'))) /*! \todo Will be deprecated after 1.4 */
*colname++ = '\0';
@@ -10962,7 +10925,7 @@ static int function_sippeer(struct ast_channel *chan, char *cmd, char *data, cha
return -1;
if (!strcasecmp(colname, "ip")) {
- ast_copy_string(buf, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "", len);
+ ast_copy_string(buf, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "", len);
} else if (!strcasecmp(colname, "status")) {
peer_status(peer, buf, len);
} else if (!strcasecmp(colname, "language")) {
@@ -11039,7 +11002,6 @@ struct ast_custom_function sippeer_function = {
static int function_sipchaninfo_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
{
struct sip_pvt *p;
- char iabuf[INET_ADDRSTRLEN];
*buf = 0;
@@ -11064,9 +11026,9 @@ static int function_sipchaninfo_read(struct ast_channel *chan, char *cmd, char *
}
if (!strcasecmp(data, "peerip")) {
- ast_copy_string(buf, p->sa.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr) : "", len);
+ ast_copy_string(buf, p->sa.sin_addr.s_addr ? ast_inet_ntoa(p->sa.sin_addr) : "", len);
} else if (!strcasecmp(data, "recvip")) {
- ast_copy_string(buf, p->recv.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr) : "", len);
+ ast_copy_string(buf, p->recv.sin_addr.s_addr ? ast_inet_ntoa(p->recv.sin_addr) : "", len);
} else if (!strcasecmp(data, "from")) {
ast_copy_string(buf, p->from, len);
} else if (!strcasecmp(data, "uri")) {
@@ -11399,7 +11361,6 @@ static void handle_response_refer(struct sip_pvt *p, int resp, char *rest, struc
{
char *auth = "Proxy-Authenticate";
char *auth2 = "Proxy-Authorization";
- char iabuf[INET_ADDRSTRLEN];
switch (resp) {
case 202: /* Transfer accepted */
@@ -11416,7 +11377,7 @@ static void handle_response_refer(struct sip_pvt *p, int resp, char *rest, struc
case 407: /* Proxy auth */
if (ast_strlen_zero(p->authname)) {
ast_log(LOG_WARNING, "Asked to authenticate REFER to %s:%d but we have no matching peer or realm auth!\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
+ ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
}
if (resp == 401) {
@@ -11623,7 +11584,6 @@ static int handle_response_peerpoke(struct sip_pvt *p, int resp, struct sip_requ
static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int ignore, int seqno)
{
struct ast_channel *owner;
- char iabuf[INET_ADDRSTRLEN];
int sipmethod;
int res = 1;
const char *c = get_header(req, "Cseq");
@@ -11740,7 +11700,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
else if (sipmethod == SIP_BYE) {
if (ast_strlen_zero(p->authname))
ast_log(LOG_WARNING, "Asked to authenticate %s, to %s:%d but we have no matching peer!\n",
- msg, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
+ msg, ast_inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
if ((p->authtries == MAX_AUTHTRIES) || do_proxy_auth(p, req, "Proxy-Authenticate", "Proxy-Authorization", sipmethod, 0)) {
ast_log(LOG_NOTICE, "Failed to authenticate on %s to '%s'\n", msg, get_header(&p->initreq, "From"));
@@ -11793,7 +11753,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
else if (sipmethod == SIP_REFER)
handle_response_refer(p, resp, rest, req, seqno);
else
- ast_log(LOG_WARNING, "Host '%s' does not implement '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), msg);
+ ast_log(LOG_WARNING, "Host '%s' does not implement '%s'\n", ast_inet_ntoa(p->sa.sin_addr), msg);
break;
case 603: /* Declined transfer */
if (sipmethod == SIP_REFER) {
@@ -11805,7 +11765,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
if ((resp >= 300) && (resp < 700)) {
/* Fatal response */
if ((option_verbose > 2) && (resp != 487))
- ast_verbose(VERBOSE_PREFIX_3 "Got SIP response %d \"%s\" back from %s\n", resp, rest, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_3 "Got SIP response %d \"%s\" back from %s\n", resp, rest, ast_inet_ntoa(p->sa.sin_addr));
ast_set_flag(&p->flags[0], SIP_ALREADYGONE);
if (p->rtp) {
/* Immediately stop RTP */
@@ -11886,7 +11846,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
}
}
} else
- ast_log(LOG_NOTICE, "Dont know how to handle a %d %s response from %s\n", resp, rest, p->owner ? p->owner->name : ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
+ ast_log(LOG_NOTICE, "Dont know how to handle a %d %s response from %s\n", resp, rest, p->owner ? p->owner->name : ast_inet_ntoa(p->sa.sin_addr));
}
} else {
/* Responses to OUTGOING SIP requests on INCOMING calls
@@ -11978,7 +11938,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
}
if ((resp >= 300) && (resp < 700)) {
if ((option_verbose > 2) && (resp != 487))
- ast_verbose(VERBOSE_PREFIX_3 "Incoming call: Got SIP response %d \"%s\" back from %s\n", resp, rest, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_3 "Incoming call: Got SIP response %d \"%s\" back from %s\n", resp, rest, ast_inet_ntoa(p->sa.sin_addr));
switch(resp) {
case 488: /* Not acceptable here - codec error */
case 603: /* Decline */
@@ -13559,7 +13519,6 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
struct ast_channel *c=NULL;
int res;
struct ast_channel *bridged_to;
- char iabuf[INET_ADDRSTRLEN];
char *audioqos = NULL, *videoqos = NULL;
if (p->pendinginvite && !ast_test_flag(&p->flags[0], SIP_OUTGOING) && !ast_test_flag(req, SIP_PKT_IGNORE))
@@ -13600,7 +13559,7 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
}
if (!ast_strlen_zero(get_header(req, "Also"))) {
ast_log(LOG_NOTICE, "Client '%s' using deprecated BYE/Also transfer method. Ask vendor to support REFER instead\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr));
+ ast_inet_ntoa(p->recv.sin_addr));
if (ast_strlen_zero(p->context))
ast_string_field_set(p, context, default_context);
res = get_also_info(p, req);
@@ -13616,7 +13575,7 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
ast_queue_hangup(p->owner);
}
} else {
- ast_log(LOG_WARNING, "Invalid transfer information from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr));
+ ast_log(LOG_WARNING, "Invalid transfer information from '%s'\n", ast_inet_ntoa(p->recv.sin_addr));
if (p->owner)
ast_queue_hangup(p->owner);
}
@@ -13831,9 +13790,8 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
}
} else {
if ((firststate = ast_extension_state(NULL, p->context, p->exten)) < 0) {
- char iabuf[INET_ADDRSTRLEN];
- ast_log(LOG_ERROR, "Got SUBSCRIBE for extension %s@%s from %s, but there is no hint for that extension\n", p->exten, p->context, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
+ ast_log(LOG_ERROR, "Got SUBSCRIBE for extension %s@%s from %s, but there is no hint for that extension\n", p->exten, p->context, ast_inet_ntoa(p->sa.sin_addr));
transmit_response(p, "404 Not found", req);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0;
@@ -13886,7 +13844,6 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
static int handle_request_register(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, char *e)
{
enum check_auth_result res;
- char iabuf[INET_ADDRSTRLEN];
/* Use this as the basis */
if (ast_test_flag(req, SIP_PKT_DEBUG))
@@ -13913,7 +13870,7 @@ static int handle_request_register(struct sip_pvt *p, struct sip_request *req, s
break;
}
ast_log(LOG_NOTICE, "Registration from '%s' failed for '%s' - %s\n",
- get_header(req, "To"), ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr),
+ get_header(req, "To"), ast_inet_ntoa(sin->sin_addr),
reason);
}
if (res < 1) {
@@ -13941,7 +13898,6 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
int ignore = FALSE;
int respid;
int res = 0;
- char iabuf[INET_ADDRSTRLEN];
int debug = sip_debug_test_pvt(p);
char *e;
int error = 0;
@@ -14125,7 +14081,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
default:
transmit_response_with_allow(p, "501 Method Not Implemented", req, 0);
ast_log(LOG_NOTICE, "Unknown SIP command '%s' from '%s'\n",
- cmd, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
+ cmd, ast_inet_ntoa(p->sa.sin_addr));
/* If this is some new method, and we don't have a call, destroy it now */
if (!p->initreq.headers)
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
@@ -14148,7 +14104,6 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
socklen_t len;
int nounlock;
int recount = 0;
- char iabuf[INET_ADDRSTRLEN];
unsigned int lockretry = 100;
len = sizeof(sin);
@@ -14175,7 +14130,7 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
if (pedanticsipchecking)
req.len = lws2sws(req.data, req.len); /* Fix multiline headers */
if (ast_test_flag(&req, SIP_PKT_DEBUG))
- ast_verbose("\n<-- SIP read from %s:%d: \n%s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), req.data);
+ ast_verbose("\n<-- SIP read from %s:%d: \n%s\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), req.data);
parse_request(&req);
req.method = find_sip_method(req.rlPart1);
@@ -14520,12 +14475,8 @@ static int sip_poke_peer(struct sip_peer *peer)
if (!ast_strlen_zero(peer->tohost))
ast_string_field_set(p, tohost, peer->tohost);
- else {
- char iabuf[INET_ADDRSTRLEN];
-
- ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr);
- ast_string_field_set(p, tohost, iabuf);
- }
+ else
+ ast_string_field_set(p, tohost, ast_inet_ntoa(peer->addr.sin_addr));
/* Recalculate our side, and recalculate Call ID */
if (ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip))
@@ -15450,7 +15401,6 @@ static int reload_config(enum channelreloadreason reason)
char newcontexts[AST_MAX_CONTEXT], oldcontexts[AST_MAX_CONTEXT];
struct hostent *hp;
int format;
- char iabuf[INET_ADDRSTRLEN];
struct ast_flags dummy[2];
int auto_sip_domains = FALSE;
struct sockaddr_in old_bindaddr = bindaddr;
@@ -15869,14 +15819,14 @@ static int reload_config(enum channelreloadreason reason)
if (bind(sipsock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) {
ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port),
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
strerror(errno));
close(sipsock);
sipsock = -1;
} else {
if (option_verbose > 1) {
ast_verbose(VERBOSE_PREFIX_2 "SIP Listening on %s:%d\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port));
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_verbose(VERBOSE_PREFIX_2 "Using SIP TOS: %s\n", ast_tos2str(global_tos_sip));
}
if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &global_tos_sip, sizeof(global_tos_sip)))
@@ -15894,18 +15844,14 @@ static int reload_config(enum channelreloadreason reason)
char temp[MAXHOSTNAMELEN];
/* First our default IP address */
- if (bindaddr.sin_addr.s_addr) {
- ast_inet_ntoa(temp, sizeof(temp), bindaddr.sin_addr);
- add_sip_domain(temp, SIP_DOMAIN_AUTO, NULL);
- } else {
+ if (bindaddr.sin_addr.s_addr)
+ add_sip_domain(ast_inet_ntoa(bindaddr.sin_addr), SIP_DOMAIN_AUTO, NULL);
+ else
ast_log(LOG_NOTICE, "Can't add wildcard IP address to domain list, please add IP address to domain manually.\n");
- }
/* Our extern IP address, if configured */
- if (externip.sin_addr.s_addr) {
- ast_inet_ntoa(temp, sizeof(temp), externip.sin_addr);
- add_sip_domain(temp, SIP_DOMAIN_AUTO, NULL);
- }
+ if (externip.sin_addr.s_addr)
+ add_sip_domain(ast_inet_ntoa(externip.sin_addr), SIP_DOMAIN_AUTO, NULL);
/* Extern host name (NAT traversal support) */
if (!ast_strlen_zero(externhost))
@@ -15961,14 +15907,12 @@ static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
if (option_debug > 2) {
- char iabuf[INET_ADDRSTRLEN];
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
+ ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
}
transmit_reinvite_with_t38_sdp(p);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
if (option_debug > 2) {
- char iabuf[INET_ADDRSTRLEN];
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf),udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
+ ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
}
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
@@ -16005,20 +15949,18 @@ static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
if (option_debug > 2) {
- char iabuf[INET_ADDRSTRLEN];
if (flag)
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
else
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip));
+ ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
}
transmit_reinvite_with_t38_sdp(p);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
if (option_debug > 2) {
- char iabuf[INET_ADDRSTRLEN];
if (flag)
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
else
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip));
+ ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
}
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
@@ -16035,11 +15977,10 @@ static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
}
if (option_debug > 2) {
- char iabuf[INET_ADDRSTRLEN];
if (flag)
- ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
else
- ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip));
+ ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
}
pvt->t38.state = T38_ENABLED;
p->t38.state = T38_ENABLED;
@@ -16124,21 +16065,18 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struc
}
if (changed && !ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (chan->_state != AST_STATE_UP) { /* We are in early state */
- char iabuf[INET_ADDRSTRLEN];
if (recordhistory)
append_history(p, "ExtInv", "Initial invite sent with remote bridge proposal.");
if (option_debug)
- ast_log(LOG_DEBUG, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp ? p->redirip.sin_addr : p->ourip));
+ ast_log(LOG_DEBUG, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
} else if (!p->pendinginvite) { /* We are up, and have no outstanding invite */
if (option_debug > 2) {
- char iabuf[INET_ADDRSTRLEN];
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp ? p->redirip.sin_addr : p->ourip));
+ ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
}
transmit_reinvite_with_sdp(p);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
if (option_debug > 2) {
- char iabuf[INET_ADDRSTRLEN];
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp ? p->redirip.sin_addr : p->ourip));
+ ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
}
/* We have a pending Invite. Send re-invite when we're done with the invite */
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index e925b2e3c..c5feda2da 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -1701,7 +1701,6 @@ static int skinny_show_devices(int fd, int argc, char *argv[])
struct skinny_device *d;
struct skinny_line *l;
int numlines = 0;
- char iabuf[INET_ADDRSTRLEN];
if (argc != 3) {
return RESULT_SHOWUSAGE;
@@ -1719,7 +1718,7 @@ static int skinny_show_devices(int fd, int argc, char *argv[])
ast_cli(fd, "%-20s %-16s %-15s %6X %c %2d\n",
d->name,
d->id,
- ast_inet_ntoa(iabuf, sizeof(iabuf), d->addr.sin_addr),
+ ast_inet_ntoa(d->addr.sin_addr),
d->type,
d->registered?'Y':'N',
numlines);
@@ -3296,7 +3295,6 @@ static int handle_open_receive_channel_ack_message(skinny_req *req, struct skinn
struct skinny_subchannel *sub;
struct sockaddr_in sin;
struct sockaddr_in us;
- char iabuf[INET_ADDRSTRLEN];
uint32_t addr;
int port;
int status;
@@ -3331,8 +3329,8 @@ static int handle_open_receive_channel_ack_message(skinny_req *req, struct skinn
}
if (skinnydebug) {
- ast_verbose("ipaddr = %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
- ast_verbose("ourip = %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), d->ourip), ntohs(us.sin_port));
+ ast_verbose("ipaddr = %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+ ast_verbose("ourip = %s:%d\n", ast_inet_ntoa(d->ourip), ntohs(us.sin_port));
}
if (!(req = req_alloc(sizeof(start_media_transmission_message), START_MEDIA_TRANSMISSION_MESSAGE)))
@@ -3897,10 +3895,9 @@ static void *skinny_session(void *data)
int res;
skinny_req *req;
struct skinnysession *s = data;
- char iabuf[INET_ADDRSTRLEN];
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Starting Skinny session from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
+ ast_verbose(VERBOSE_PREFIX_3 "Starting Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr));
for (;;) {
res = get_input(s);
@@ -4071,7 +4068,6 @@ static int reload_config(void)
struct ast_variable *v;
int format;
char *cat;
- char iabuf[INET_ADDRSTRLEN];
struct skinny_device *d;
int oldport = ntohs(bindaddr.sin_port);
@@ -4195,7 +4191,7 @@ static int reload_config(void)
} else {
if (bind(skinnysock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) {
ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port),
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
strerror(errno));
close(skinnysock);
skinnysock = -1;
@@ -4204,7 +4200,7 @@ static int reload_config(void)
}
if (listen(skinnysock,DEFAULT_SKINNY_BACKLOG)) {
ast_log(LOG_WARNING, "Failed to start listening to %s:%d: %s\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port),
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
strerror(errno));
close(skinnysock);
skinnysock = -1;
@@ -4213,7 +4209,7 @@ static int reload_config(void)
}
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Skinny listening on %s:%d\n",
- ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port));
+ ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
ast_pthread_create(&accept_t,NULL, accept_thread, NULL);
}
}
diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c
index b3d732657..b8d979cda 100644
--- a/channels/iax2-parser.c
+++ b/channels/iax2-parser.c
@@ -63,10 +63,9 @@ static void (*errorf)(const char *str) = internalerror;
static void dump_addr(char *output, int maxlen, void *value, int len)
{
struct sockaddr_in sin;
- char iabuf[INET_ADDRSTRLEN];
if (len == (int)sizeof(sin)) {
memcpy(&sin, value, len);
- snprintf(output, maxlen, "IPV4 %s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
+ snprintf(output, maxlen, "IPV4 %s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
snprintf(output, maxlen, "Invalid Address");
}
@@ -143,11 +142,9 @@ static void dump_datetime(char *output, int maxlen, void *value, int len)
static void dump_ipaddr(char *output, int maxlen, void *value, int len)
{
struct sockaddr_in sin;
- char iabuf[INET_ADDRSTRLEN];
if (len == (int)sizeof(unsigned int)) {
memcpy(&sin.sin_addr, value, len);
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr);
- snprintf(output, maxlen, "%s", iabuf);
+ snprintf(output, maxlen, "%s", ast_inet_ntoa(sin.sin_addr));
} else
ast_copy_string(output, "Invalid IPADDR", maxlen);
}
@@ -464,7 +461,6 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
const char *subclass;
char *dir;
char tmp[512];
- char iabuf[INET_ADDRSTRLEN];
switch(rx) {
case 0:
@@ -530,7 +526,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
" Timestamp: %05lums SCall: %5.5d DCall: %5.5d [%s:%d]\n",
(unsigned long)ntohl(fh->ts),
ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS,
- ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
+ ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
outputf(tmp);
if (fh->type == AST_FRAME_IAX)
dump_ies(fh->iedata, datalen);
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c
index a46972983..0b1fc3e33 100644
--- a/channels/iax2-provision.c
+++ b/channels/iax2-provision.c
@@ -91,20 +91,24 @@ static struct iax_flag {
char *iax_provflags2str(char *buf, int buflen, unsigned int flags)
{
int x;
- if (!buf || buflen < 1) {
- return(NULL);
- }
+
+ if (!buf || buflen < 1)
+ return NULL;
+
buf[0] = '\0';
- for (x=0;x<sizeof(iax_flags) / sizeof(iax_flags[0]); x++) {
+
+ for (x = 0; x < sizeof(iax_flags) / sizeof(iax_flags[0]); x++) {
if (flags & iax_flags[x].value){
strncat(buf, iax_flags[x].name, buflen - strlen(buf) - 1);
strncat(buf, ",", buflen - strlen(buf) - 1);
}
}
- if (strlen(buf))
+
+ if (!ast_strlen_zero(buf))
buf[strlen(buf) - 1] = '\0';
else
strncpy(buf, "none", buflen - 1);
+
return buf;
}
@@ -408,37 +412,45 @@ static const char *ifthere(const char *s)
return "<unspecified>";
}
-static const char *iax_server(char *a, int alen, unsigned int addr)
+static const char *iax_server(unsigned int addr)
{
struct in_addr ia;
+
if (!addr)
return "<unspecified>";
+
ia.s_addr = htonl(addr);
- return ast_inet_ntoa(a, alen, ia);
+
+ return ast_inet_ntoa(ia);
}
static int iax_show_provisioning(int fd, int argc, char *argv[])
{
struct iax_template *cur;
- char iabuf[80]; /* Has to be big enough for 'flags' too */
+ char server[INET_ADDRSTRLEN];
+ char alternate[INET_ADDRSTRLEN];
+ char flags[80]; /* Has to be big enough for 'flags' too */
int found = 0;
if ((argc != 3) && (argc != 4))
return RESULT_SHOWUSAGE;
ast_mutex_lock(&provlock);
for (cur = templates;cur;cur = cur->next) {
if ((argc == 3) || (!strcasecmp(argv[3], cur->name))) {
- if (found) ast_cli(fd, "\n");
+ if (found)
+ ast_cli(fd, "\n");
+ ast_copy_string(server, iax_server(cur->server), sizeof(server));
+ ast_copy_string(alternate, iax_server(cur->altserver), sizeof(alternate));
ast_cli(fd, "== %s ==\n", cur->name);
ast_cli(fd, "Base Templ: %s\n", strlen(cur->src) ? cur->src : "<none>");
ast_cli(fd, "Username: %s\n", ifthere(cur->user));
ast_cli(fd, "Secret: %s\n", ifthere(cur->pass));
ast_cli(fd, "Language: %s\n", ifthere(cur->lang));
ast_cli(fd, "Bind Port: %d\n", cur->port);
- ast_cli(fd, "Server: %s\n", iax_server(iabuf, sizeof(iabuf), cur->server));
+ ast_cli(fd, "Server: %s\n", server);
ast_cli(fd, "Server Port: %d\n", cur->serverport);
- ast_cli(fd, "Alternate: %s\n", iax_server(iabuf, sizeof(iabuf), cur->altserver));
- ast_cli(fd, "Flags: %s\n", iax_provflags2str(iabuf, sizeof(iabuf), cur->flags));
+ ast_cli(fd, "Alternate: %s\n", alternate);
+ ast_cli(fd, "Flags: %s\n", iax_provflags2str(flags, sizeof(flags), cur->flags));
ast_cli(fd, "Format: %s\n", ast_getformatname(cur->format));
ast_cli(fd, "TOS: 0x%x\n", cur->tos);
found++;