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
This commit is contained in:
parent
c7eeabcdd2
commit
f395a52a02
7
acl.c
7
acl.c
|
@ -208,10 +208,9 @@ int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin)
|
|||
char iabuf[INET_ADDRSTRLEN];
|
||||
char iabuf2[INET_ADDRSTRLEN];
|
||||
/* DEBUG */
|
||||
ast_log(LOG_DEBUG,
|
||||
"##### Testing %s with %s\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr),
|
||||
ast_inet_ntoa(iabuf2, sizeof(iabuf2), ha->netaddr));
|
||||
ast_copy_string(iabuf, ast_inet_ntoa(sin->sin_addr), sizeof(iabuf));
|
||||
ast_copy_string(iabuf2, ast_inet_ntoa(ha->netaddr), sizeof(iabuf2));
|
||||
ast_log(LOG_DEBUG, "##### Testing %s with %s\n", iabuf, iabuf2);
|
||||
/* For each rule, if this address and the netmask = the net address
|
||||
apply the current rule */
|
||||
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == ha->netaddr.s_addr)
|
||||
|
|
|
@ -7505,7 +7505,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
|
|||
return -1;
|
||||
}
|
||||
memcpy(&ia,hp->h_addr,sizeof(in_addr_t));
|
||||
ast_inet_ntoa(nodeip,sizeof(nodeip) - 1,ia);
|
||||
ast_copy_string(nodeip, ast_inet_ntoa(ia), sizeof(nodeip));
|
||||
if (strcmp(hisip,nodeip))
|
||||
{
|
||||
char *s3 = strchr(s1,'@');
|
||||
|
@ -7519,7 +7519,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
|
|||
return -1;
|
||||
}
|
||||
memcpy(&ia,hp->h_addr,sizeof(in_addr_t));
|
||||
ast_inet_ntoa(nodeip,sizeof(nodeip) - 1,ia);
|
||||
ast_copy_string(nodeip, ast_inet_ntoa(ia), sizeof(nodeip));
|
||||
if (strcmp(hisip,nodeip))
|
||||
{
|
||||
ast_log(LOG_WARNING, "Node %s IP %s does not match link IP %s!!\n",b1,nodeip,hisip);
|
||||
|
|
|
@ -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, ®->us, sizeof(oldus));
|
||||
oldmsgs = reg->messages;
|
||||
if (inaddrcmp(®->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(®->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(®->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")) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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++;
|
||||
|
|
6
dnsmgr.c
6
dnsmgr.c
|
@ -172,10 +172,10 @@ static int dnsmgr_refresh(struct ast_dnsmgr_entry *entry, int verbose)
|
|||
/* check to see if it has changed, do callback if requested (where de callback is defined ????) */
|
||||
memcpy(&tmp, hp->h_addr, sizeof(tmp));
|
||||
if (tmp.s_addr != entry->last.s_addr) {
|
||||
ast_copy_string(iabuf, ast_inet_ntoa(entry->last), sizeof(iabuf));
|
||||
ast_copy_string(iabuf2, ast_inet_ntoa(tmp), sizeof(iabuf2));
|
||||
ast_log(LOG_NOTICE, "host '%s' changed from %s to %s\n",
|
||||
entry->name,
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), entry->last),
|
||||
ast_inet_ntoa(iabuf2, sizeof(iabuf2), tmp));
|
||||
entry->name, iabuf, iabuf2);
|
||||
memcpy(entry->result, hp->h_addr, sizeof(entry->result));
|
||||
memcpy(&entry->last, hp->h_addr, sizeof(entry->last));
|
||||
changed = entry->changed = 1;
|
||||
|
|
11
http.c
11
http.c
|
@ -174,7 +174,6 @@ static char *httpstatus_callback(struct sockaddr_in *req, const char *uri, struc
|
|||
size_t reslen = sizeof(result);
|
||||
char *c=result;
|
||||
struct ast_variable *v;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
ast_build_string(&c, &reslen,
|
||||
"\r\n"
|
||||
|
@ -185,7 +184,7 @@ static char *httpstatus_callback(struct sockaddr_in *req, const char *uri, struc
|
|||
|
||||
ast_build_string(&c, &reslen, "<tr><td><i>Prefix</i></td><td><b>%s</b></td></tr>\r\n", prefix);
|
||||
ast_build_string(&c, &reslen, "<tr><td><i>Bind Address</i></td><td><b>%s</b></td></tr>\r\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), oldsin.sin_addr));
|
||||
ast_inet_ntoa(oldsin.sin_addr));
|
||||
ast_build_string(&c, &reslen, "<tr><td><i>Bind Port</i></td><td><b>%d</b></td></tr>\r\n",
|
||||
ntohs(oldsin.sin_port));
|
||||
ast_build_string(&c, &reslen, "<tr><td colspan=\"2\"><hr></td></tr>\r\n");
|
||||
|
@ -513,7 +512,6 @@ char *ast_http_setcookie(const char *var, const char *val, int expires, char *bu
|
|||
|
||||
static void http_server_start(struct sockaddr_in *sin)
|
||||
{
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
int flags;
|
||||
int x = 1;
|
||||
|
||||
|
@ -549,7 +547,7 @@ static void http_server_start(struct sockaddr_in *sin)
|
|||
setsockopt(httpfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x));
|
||||
if (bind(httpfd, (struct sockaddr *)sin, sizeof(*sin))) {
|
||||
ast_log(LOG_NOTICE, "Unable to bind http server to %s:%d: %s\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port),
|
||||
ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port),
|
||||
strerror(errno));
|
||||
close(httpfd);
|
||||
httpfd = -1;
|
||||
|
@ -565,7 +563,7 @@ static void http_server_start(struct sockaddr_in *sin)
|
|||
fcntl(httpfd, F_SETFL, flags | O_NONBLOCK);
|
||||
if (ast_pthread_create(&master, NULL, http_root, NULL)) {
|
||||
ast_log(LOG_NOTICE, "Unable to launch http server on %s:%d: %s\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port),
|
||||
ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port),
|
||||
strerror(errno));
|
||||
close(httpfd);
|
||||
httpfd = -1;
|
||||
|
@ -628,7 +626,6 @@ static int __ast_http_load(int reload)
|
|||
|
||||
static int handle_show_http(int fd, int argc, char *argv[])
|
||||
{
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
struct ast_http_uri *urih;
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
|
@ -636,7 +633,7 @@ static int handle_show_http(int fd, int argc, char *argv[])
|
|||
ast_cli(fd, "Prefix: %s\n", prefix);
|
||||
if (oldsin.sin_family)
|
||||
ast_cli(fd, "Server Enabled and Bound to %s:%d\n\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), oldsin.sin_addr),
|
||||
ast_inet_ntoa(oldsin.sin_addr),
|
||||
ntohs(oldsin.sin_port));
|
||||
else
|
||||
ast_cli(fd, "Server Disabled\n\n");
|
||||
|
|
|
@ -216,7 +216,7 @@ static force_inline void ast_slinear_saturated_divide(short *input, short *value
|
|||
|
||||
int test_for_thread_safety(void);
|
||||
|
||||
const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia);
|
||||
const char *ast_inet_ntoa(struct in_addr ia);
|
||||
|
||||
#ifdef inet_ntoa
|
||||
#undef inet_ntoa
|
||||
|
|
39
manager.c
39
manager.c
|
@ -444,13 +444,12 @@ static int handle_showmancmds(int fd, int argc, char *argv[])
|
|||
static int handle_showmanconn(int fd, int argc, char *argv[])
|
||||
{
|
||||
struct mansession *s;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
char *format = " %-15.15s %-15.15s\n";
|
||||
ast_mutex_lock(&sessionlock);
|
||||
s = sessions;
|
||||
ast_cli(fd, format, "Username", "IP Address");
|
||||
while (s) {
|
||||
ast_cli(fd, format,s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_cli(fd, format,s->username, ast_inet_ntoa(s->sin.sin_addr));
|
||||
s = s->next;
|
||||
}
|
||||
|
||||
|
@ -750,7 +749,6 @@ static int set_eventmask(struct mansession *s, char *eventmask)
|
|||
static int authenticate(struct mansession *s, struct message *m)
|
||||
{
|
||||
struct ast_config *cfg;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
char *cat;
|
||||
char *user = astman_get_header(m, "Username");
|
||||
char *pass = astman_get_header(m, "Secret");
|
||||
|
@ -796,7 +794,7 @@ static int authenticate(struct mansession *s, struct message *m)
|
|||
v = v->next;
|
||||
}
|
||||
if (ha && !ast_apply_ha(ha, &(s->sin))) {
|
||||
ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
|
||||
ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", ast_inet_ntoa(s->sin.sin_addr), user);
|
||||
ast_free_ha(ha);
|
||||
ast_config_destroy(cfg);
|
||||
return -1;
|
||||
|
@ -825,7 +823,7 @@ static int authenticate(struct mansession *s, struct message *m)
|
|||
} else if (password && !strcmp(password, pass)) {
|
||||
break;
|
||||
} else {
|
||||
ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
|
||||
ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(s->sin.sin_addr), user);
|
||||
ast_config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
|
@ -842,7 +840,7 @@ static int authenticate(struct mansession *s, struct message *m)
|
|||
set_eventmask(s, events);
|
||||
return 0;
|
||||
}
|
||||
ast_log(LOG_NOTICE, "%s tried to authenticate with nonexistent user '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
|
||||
ast_log(LOG_NOTICE, "%s tried to authenticate with nonexistent user '%s'\n", ast_inet_ntoa(s->sin.sin_addr), user);
|
||||
ast_config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1800,7 +1798,6 @@ static int process_message(struct mansession *s, struct message *m)
|
|||
struct manager_action *tmp = first_action;
|
||||
char *id = astman_get_header(m,"ActionID");
|
||||
char idText[256] = "";
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
int ret = 0;
|
||||
|
||||
ast_copy_string(action, astman_get_header(m, "Action"), sizeof(action));
|
||||
|
@ -1840,10 +1837,10 @@ static int process_message(struct mansession *s, struct message *m)
|
|||
s->authenticated = 1;
|
||||
if (option_verbose > 1) {
|
||||
if (displayconnects) {
|
||||
ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
|
||||
}
|
||||
}
|
||||
ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
|
||||
astman_send_ack(s, m, "Authentication accepted");
|
||||
}
|
||||
} else if (!strcasecmp(action, "Logoff")) {
|
||||
|
@ -1881,7 +1878,6 @@ static int get_input(struct mansession *s, char *output)
|
|||
int res;
|
||||
int x;
|
||||
struct pollfd fds[1];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
for (x = 1; x < s->inlen; x++) {
|
||||
if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) {
|
||||
/* Copy output data up to and including \r\n */
|
||||
|
@ -1895,7 +1891,7 @@ static int get_input(struct mansession *s, char *output)
|
|||
}
|
||||
}
|
||||
if (s->inlen >= sizeof(s->inbuf) - 1) {
|
||||
ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), s->inbuf);
|
||||
ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", ast_inet_ntoa(s->sin.sin_addr), s->inbuf);
|
||||
s->inlen = 0;
|
||||
}
|
||||
fds[0].fd = s->fd;
|
||||
|
@ -1936,7 +1932,6 @@ static void *session_do(void *data)
|
|||
{
|
||||
struct mansession *s = data;
|
||||
struct message m;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
int res;
|
||||
|
||||
ast_mutex_lock(&s->__lock);
|
||||
|
@ -1966,15 +1961,15 @@ static void *session_do(void *data)
|
|||
if (s->authenticated) {
|
||||
if (option_verbose > 1) {
|
||||
if (displayconnects)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(s->sin.sin_addr));
|
||||
}
|
||||
ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(s->sin.sin_addr));
|
||||
} else {
|
||||
if (option_verbose > 1) {
|
||||
if (displayconnects)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(s->sin.sin_addr));
|
||||
}
|
||||
ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(s->sin.sin_addr));
|
||||
}
|
||||
destroy_session(s);
|
||||
return NULL;
|
||||
|
@ -1993,7 +1988,6 @@ static void *accept_thread(void *ignore)
|
|||
pthread_attr_t attr;
|
||||
time_t now;
|
||||
struct pollfd pfds[1];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
|
@ -2013,7 +2007,7 @@ static void *accept_thread(void *ignore)
|
|||
sessions = next;
|
||||
if (s->authenticated && (option_verbose > 1) && displayconnects) {
|
||||
ast_verbose(VERBOSE_PREFIX_2 "HTTP Manager '%s' timed out from %s\n",
|
||||
s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
s->username, ast_inet_ntoa(s->sin.sin_addr));
|
||||
}
|
||||
free_session(s);
|
||||
} else
|
||||
|
@ -2285,7 +2279,6 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
|
|||
unsigned long ident = 0;
|
||||
char workspace[512];
|
||||
char cookie[128];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
size_t len = sizeof(workspace);
|
||||
int blastaway = 0;
|
||||
char *c = workspace;
|
||||
|
@ -2359,15 +2352,15 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
|
|||
if (s->authenticated) {
|
||||
if (option_verbose > 1) {
|
||||
if (displayconnects)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "HTTP Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "HTTP Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(s->sin.sin_addr));
|
||||
}
|
||||
ast_log(LOG_EVENT, "HTTP Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "HTTP Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(s->sin.sin_addr));
|
||||
} else {
|
||||
if (option_verbose > 1) {
|
||||
if (displayconnects)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "HTTP Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "HTTP Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(s->sin.sin_addr));
|
||||
}
|
||||
ast_log(LOG_EVENT, "HTTP Failed attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "HTTP Failed attempt from %s\n", ast_inet_ntoa(s->sin.sin_addr));
|
||||
}
|
||||
s->needdestroy = 1;
|
||||
}
|
||||
|
|
|
@ -123,7 +123,6 @@ struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct i
|
|||
{
|
||||
int netsocket = -1;
|
||||
int *ioref;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
struct ast_netsock *ns;
|
||||
|
||||
|
@ -135,7 +134,7 @@ struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct i
|
|||
return NULL;
|
||||
}
|
||||
if (bind(netsocket,(struct sockaddr *)bindaddr, sizeof(struct sockaddr_in))) {
|
||||
ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr->sin_addr), ntohs(bindaddr->sin_port), strerror(errno));
|
||||
ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n", ast_inet_ntoa(bindaddr->sin_addr), ntohs(bindaddr->sin_port), strerror(errno));
|
||||
close(netsocket);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -474,7 +474,6 @@ void dundi_showframe(struct dundi_hdr *fhi, int rx, struct sockaddr_in *sin, int
|
|||
char *subclass;
|
||||
char tmp[256];
|
||||
char retries[20];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
if (ntohs(fhi->dtrans) & DUNDI_FLAG_RETRANS)
|
||||
strcpy(retries, "Yes");
|
||||
else
|
||||
|
@ -499,7 +498,7 @@ void dundi_showframe(struct dundi_hdr *fhi, int rx, struct sockaddr_in *sin, int
|
|||
snprintf(tmp, (int)sizeof(tmp),
|
||||
"%s Flags: %s STrans: %5.5d DTrans: %5.5d [%s:%d]%s\n", (rx > 1) ? " " : "",
|
||||
subclass, ntohs(fhi->strans) & ~DUNDI_FLAG_RESERVED, ntohs(fhi->dtrans) & ~DUNDI_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),
|
||||
fhi->cmdresp & 0x80 ? " (Final)" : "");
|
||||
outputf(tmp);
|
||||
dump_ies(fhi->ies, rx > 1, datalen);
|
||||
|
|
|
@ -1592,18 +1592,20 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
|
|||
hasauth = 1;
|
||||
if (hasauth) {
|
||||
int expire = default_expiration;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
char data[256];
|
||||
int needqual = 0;
|
||||
if (peer->registerexpire > -1)
|
||||
ast_sched_del(sched, peer->registerexpire);
|
||||
peer->registerexpire = ast_sched_add(sched, (expire + 10) * 1000, do_register_expire, peer);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), trans->addr.sin_addr);
|
||||
snprintf(data, sizeof(data), "%s:%d:%d", iabuf, ntohs(trans->addr.sin_port), expire);
|
||||
snprintf(data, sizeof(data), "%s:%d:%d", ast_inet_ntoa(trans->addr.sin_addr),
|
||||
ntohs(trans->addr.sin_port), expire);
|
||||
ast_db_put("dundi/dpeers", dundi_eid_to_str_short(eid_str, sizeof(eid_str), &peer->eid), data);
|
||||
if (inaddrcmp(&peer->addr, &trans->addr)) {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Registered DUNDi peer '%s' at '%s:%d'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid), iabuf, ntohs(trans->addr.sin_port));
|
||||
if (option_verbose > 2) {
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Registered DUNDi peer '%s' at '%s:%d'\n",
|
||||
dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid),
|
||||
ast_inet_ntoa(trans->addr.sin_addr), ntohs(trans->addr.sin_port));
|
||||
}
|
||||
needqual = 1;
|
||||
}
|
||||
|
||||
|
@ -1731,8 +1733,7 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
|
|||
ast_copy_string(trans->parent->dei->ipaddr, ies.q_ipaddr, sizeof(trans->parent->dei->ipaddr));
|
||||
if (!dundi_eid_cmp(&trans->them_eid, &trans->parent->query_eid)) {
|
||||
/* If it's them, update our address */
|
||||
ast_inet_ntoa(trans->parent->dei->ipaddr, sizeof(trans->parent->dei->ipaddr),
|
||||
trans->addr.sin_addr);
|
||||
ast_copy_string(trans->parent->dei->ipaddr, ast_inet_ntoa(trans->addr.sin_addr), sizeof(trans->parent->dei->ipaddr));
|
||||
}
|
||||
}
|
||||
if (ies.hint) {
|
||||
|
@ -2361,7 +2362,6 @@ static int dundi_show_peer(int fd, int argc, char *argv[])
|
|||
struct dundi_peer *peer;
|
||||
struct permission *p;
|
||||
char *order;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
char eid_str[20];
|
||||
int x, cnt;
|
||||
|
||||
|
@ -2391,7 +2391,7 @@ static int dundi_show_peer(int fd, int argc, char *argv[])
|
|||
}
|
||||
ast_cli(fd, "Peer: %s\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
|
||||
ast_cli(fd, "Model: %s\n", model2str(peer->model));
|
||||
ast_cli(fd, "Host: %s\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "<Unspecified>");
|
||||
ast_cli(fd, "Host: %s\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "<Unspecified>");
|
||||
ast_cli(fd, "Dynamic: %s\n", peer->dynamic ? "yes" : "no");
|
||||
ast_cli(fd, "Reg: %s\n", peer->registerid < 0 ? "No" : "Yes");
|
||||
ast_cli(fd, "In Key: %s\n", ast_strlen_zero(peer->inkey) ? "<None>" : peer->inkey);
|
||||
|
@ -2426,7 +2426,6 @@ static int dundi_show_peers(int fd, int argc, char *argv[])
|
|||
#define FORMAT2 "%-20.20s %-15.15s %-10.10s %-8.8s %-15.15s\n"
|
||||
#define FORMAT "%-20.20s %-15.15s %s %-10.10s %-8.8s %-15.15s\n"
|
||||
struct dundi_peer *peer;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
int registeredonly=0;
|
||||
char avgms[20];
|
||||
char eid_str[20];
|
||||
|
@ -2478,7 +2477,7 @@ static int dundi_show_peers(int fd, int argc, char *argv[])
|
|||
else
|
||||
strcpy(avgms, "Unavail");
|
||||
snprintf(srch, sizeof(srch), FORMAT, dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid),
|
||||
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)",
|
||||
peer->dynamic ? "(D)" : "(S)", model2str(peer->model), avgms, status);
|
||||
|
||||
if (argc == 5) {
|
||||
|
@ -2495,7 +2494,7 @@ static int dundi_show_peers(int fd, int argc, char *argv[])
|
|||
|
||||
if (print_line) {
|
||||
ast_cli(fd, FORMAT, dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid),
|
||||
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)",
|
||||
peer->dynamic ? "(D)" : "(S)", model2str(peer->model), avgms, status);
|
||||
}
|
||||
}
|
||||
|
@ -2511,13 +2510,12 @@ static int dundi_show_trans(int fd, int argc, char *argv[])
|
|||
#define FORMAT2 "%-22.22s %-5.5s %-5.5s %-3.3s %-3.3s %-3.3s\n"
|
||||
#define FORMAT "%-16.16s:%5d %-5.5d %-5.5d %-3.3d %-3.3d %-3.3d\n"
|
||||
struct dundi_transaction *trans;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
AST_LIST_LOCK(&peers);
|
||||
ast_cli(fd, FORMAT2, "Remote", "Src", "Dst", "Tx", "Rx", "Ack");
|
||||
AST_LIST_TRAVERSE(&alltrans, trans, all) {
|
||||
ast_cli(fd, FORMAT, ast_inet_ntoa(iabuf, sizeof(iabuf), trans->addr.sin_addr),
|
||||
ast_cli(fd, FORMAT, ast_inet_ntoa(trans->addr.sin_addr),
|
||||
ntohs(trans->addr.sin_port), trans->strans, trans->dtrans, trans->oseqno, trans->iseqno, trans->aseqno);
|
||||
}
|
||||
AST_LIST_UNLOCK(&peers);
|
||||
|
@ -2759,13 +2757,12 @@ static struct dundi_transaction *create_transaction(struct dundi_peer *p)
|
|||
static int dundi_xmit(struct dundi_packet *pack)
|
||||
{
|
||||
int res;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
if (dundidebug)
|
||||
dundi_showframe(pack->h, 0, &pack->parent->addr, pack->datalen - sizeof(struct dundi_hdr));
|
||||
res = sendto(netsocket, pack->data, pack->datalen, 0, (struct sockaddr *)&pack->parent->addr, sizeof(pack->parent->addr));
|
||||
if (res < 0) {
|
||||
ast_log(LOG_WARNING, "Failed to transmit to '%s:%d': %s\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), pack->parent->addr.sin_addr),
|
||||
ast_inet_ntoa(pack->parent->addr.sin_addr),
|
||||
ntohs(pack->parent->addr.sin_port), strerror(errno));
|
||||
}
|
||||
if (res > 0)
|
||||
|
@ -2871,7 +2868,6 @@ static void destroy_trans(struct dundi_transaction *trans, int fromtimeout)
|
|||
static int dundi_rexmit(void *data)
|
||||
{
|
||||
struct dundi_packet *pack;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
int res;
|
||||
AST_LIST_LOCK(&peers);
|
||||
pack = data;
|
||||
|
@ -2879,7 +2875,7 @@ static int dundi_rexmit(void *data)
|
|||
pack->retransid = -1;
|
||||
if (!ast_test_flag(pack->parent, FLAG_ISQUAL))
|
||||
ast_log(LOG_NOTICE, "Max retries exceeded to host '%s:%d' msg %d on call %d\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), pack->parent->addr.sin_addr),
|
||||
ast_inet_ntoa(pack->parent->addr.sin_addr),
|
||||
ntohs(pack->parent->addr.sin_port), pack->h->oseqno, ntohs(pack->h->strans));
|
||||
destroy_trans(pack->parent, 1);
|
||||
res = 0;
|
||||
|
@ -4315,7 +4311,7 @@ static int set_config(char *config_file, struct sockaddr_in* sin)
|
|||
hp = ast_gethostbyname(hn, &he);
|
||||
if (hp) {
|
||||
memcpy(&sin2.sin_addr, hp->h_addr, sizeof(sin2.sin_addr));
|
||||
ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin2.sin_addr);
|
||||
ast_copy_string(ipaddr, ast_inet_ntoa(sin2.sin_addr), sizeof(ipaddr));
|
||||
} else
|
||||
ast_log(LOG_WARNING, "Unable to look up host '%s'\n", hn);
|
||||
} else
|
||||
|
@ -4477,7 +4473,6 @@ static int load_module(void *mod)
|
|||
{
|
||||
int res = 0;
|
||||
struct sockaddr_in sin;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
__mod_desc = mod;
|
||||
dundi_set_output(dundi_debug_output);
|
||||
|
@ -4505,7 +4500,7 @@ static int load_module(void *mod)
|
|||
return -1;
|
||||
}
|
||||
if (bind(netsocket,(struct sockaddr *)&sin, sizeof(sin))) {
|
||||
ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), strerror(errno));
|
||||
ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -4523,7 +4518,7 @@ static int load_module(void *mod)
|
|||
}
|
||||
|
||||
if (option_verbose > 1)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "DUNDi Ready and Listening on %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "DUNDi Ready and Listening on %s port %d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
|
||||
ast_cli_register(&cli_debug);
|
||||
ast_cli_register(&cli_store_history);
|
||||
|
|
79
rtp.c
79
rtp.c
|
@ -528,17 +528,15 @@ void ast_rtp_setdtmf(struct ast_rtp *rtp, int dtmf)
|
|||
|
||||
static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
|
||||
{
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
if (ast_tvcmp(ast_tvnow(), rtp->dtmfmute) < 0) {
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
|
||||
ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(rtp->them.sin_addr));
|
||||
rtp->resp = 0;
|
||||
rtp->dtmfduration = 0;
|
||||
return &ast_null_frame;
|
||||
}
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
|
||||
ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(rtp->them.sin_addr));
|
||||
if (rtp->resp == 'X') {
|
||||
rtp->f.frametype = AST_FRAME_CONTROL;
|
||||
rtp->f.subclass = AST_CONTROL_FLASH;
|
||||
|
@ -688,10 +686,8 @@ static struct ast_frame *process_rfc3389(struct ast_rtp *rtp, unsigned char *dat
|
|||
ast_log(LOG_DEBUG, "- RTP 3389 Comfort noise event: Level %d (len = %d)\n", rtp->lastrxformat, len);
|
||||
|
||||
if (!(ast_test_flag(rtp, FLAG_3389_WARNING))) {
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
ast_log(LOG_NOTICE, "Comfort noise support incomplete in Asterisk (RFC 3389). Please turn off on client if possible. Client IP: %s\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
|
||||
ast_inet_ntoa(rtp->them.sin_addr));
|
||||
ast_set_flag(rtp, FLAG_3389_WARNING);
|
||||
}
|
||||
|
||||
|
@ -736,7 +732,6 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
|
|||
int res;
|
||||
struct sockaddr_in sin;
|
||||
unsigned int rtcpdata[8192 + AST_FRIENDLY_OFFSET];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
unsigned int *rtcpheader;
|
||||
int pt;
|
||||
struct timeval now;
|
||||
|
@ -776,7 +771,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
|
|||
(rtp->rtcp->them.sin_port != sin.sin_port)) {
|
||||
memcpy(&rtp->rtcp->them, &sin, sizeof(rtp->rtcp->them));
|
||||
if (option_debug || rtpdebug)
|
||||
ast_log(LOG_DEBUG, "RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
ast_log(LOG_DEBUG, "RTCP NAT: Got RTCP from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
}
|
||||
}
|
||||
if (option_debug)
|
||||
|
@ -797,7 +792,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
|
|||
}
|
||||
|
||||
if (rtcp_debug_test_addr(&sin)) {
|
||||
ast_verbose("\n\nGot RTCP from %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
|
||||
ast_verbose("\n\nGot RTCP from %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
ast_verbose("PT: %d(%s)\n", pt, (pt == 200) ? "Sender Report" : (pt == 201) ? "Receiver Report" : (pt == 192) ? "H.261 FUR" : "Unknown");
|
||||
ast_verbose("Reception reports: %d\n", rc);
|
||||
ast_verbose("SSRC of sender: %u\n", rtcpheader[i + 1]);
|
||||
|
@ -867,14 +862,14 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
|
|||
break;
|
||||
case RTCP_PT_SDES:
|
||||
if (rtcp_debug_test_addr(&sin))
|
||||
ast_verbose("Received an SDES from %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
ast_verbose("Received an SDES from %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
break;
|
||||
case RTCP_PT_BYE:
|
||||
if (rtcp_debug_test_addr(&sin))
|
||||
ast_verbose("Received a BYE from %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
ast_verbose("Received a BYE from %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
break;
|
||||
default:
|
||||
ast_log(LOG_NOTICE, "Unknown RTCP packet (pt=%d) received from %s:%d\n", pt, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
ast_log(LOG_NOTICE, "Unknown RTCP packet (pt=%d) received from %s:%d\n", pt, ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
break;
|
||||
}
|
||||
position += (length + 1);
|
||||
|
@ -944,7 +939,6 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
|
|||
int padding;
|
||||
int mark;
|
||||
int ext;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
unsigned int ssrc;
|
||||
unsigned int timestamp;
|
||||
unsigned int *rtpheader;
|
||||
|
@ -1002,7 +996,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
|
|||
rtp->rxseqno = 0;
|
||||
ast_set_flag(rtp, FLAG_NAT_ACTIVE);
|
||||
if (option_debug || rtpdebug)
|
||||
ast_log(LOG_DEBUG, "RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
ast_log(LOG_DEBUG, "RTP NAT: Got audio from other end. Now sending to address %s:%d\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1064,7 +1058,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
|
|||
|
||||
if (rtp_debug_test_addr(&sin))
|
||||
ast_verbose("Got RTP packet from %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp,res - hdrlen);
|
||||
ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp,res - hdrlen);
|
||||
|
||||
rtpPT = ast_rtp_lookup_pt(rtp, payloadtype);
|
||||
if (!rtpPT.isAstFormat) {
|
||||
|
@ -1086,7 +1080,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
|
|||
event_end >>= 24;
|
||||
duration = ntohl(*((unsigned int *)(data)));
|
||||
duration &= 0xFFFF;
|
||||
ast_verbose("Got RTP RFC2833 from %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u, mark %d, event %08x, end %d, duration %-5.5d) \n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp, res - hdrlen, (mark?1:0), event, ((event_end & 0x80)?1:0), duration);
|
||||
ast_verbose("Got RTP RFC2833 from %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u, mark %d, event %08x, end %d, duration %-5.5d) \n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp, res - hdrlen, (mark?1:0), event, ((event_end & 0x80)?1:0), duration);
|
||||
}
|
||||
if (rtp->lasteventseqn <= seqno || rtp->resp == 0 || (rtp->lasteventseqn >= 65530 && seqno <= 6)) {
|
||||
f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen, seqno);
|
||||
|
@ -1102,7 +1096,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
|
|||
/* Comfort Noise */
|
||||
f = process_rfc3389(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
|
||||
} else {
|
||||
ast_log(LOG_NOTICE, "Unknown RTP codec %d received from '%s'\n", payloadtype, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
|
||||
ast_log(LOG_NOTICE, "Unknown RTP codec %d received from '%s'\n", payloadtype, ast_inet_ntoa(rtp->them.sin_addr));
|
||||
}
|
||||
return f ? f : &ast_null_frame;
|
||||
}
|
||||
|
@ -1879,7 +1873,6 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
|
|||
int x;
|
||||
int payload;
|
||||
char data[256];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
if ((digit <= '9') && (digit >= '0'))
|
||||
digit -= '0';
|
||||
|
@ -1914,11 +1907,11 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
|
|||
res = sendto(rtp->s, (void *) rtpheader, hdrlen + 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
|
||||
if (res < 0)
|
||||
ast_log(LOG_ERROR, "RTP Transmission error to %s:%d: %s\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr),
|
||||
ast_inet_ntoa(rtp->them.sin_addr),
|
||||
ntohs(rtp->them.sin_port), strerror(errno));
|
||||
if (rtp_debug_test_addr(&rtp->them))
|
||||
ast_verbose("Sent RTP DTMF packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr),
|
||||
ast_inet_ntoa(rtp->them.sin_addr),
|
||||
ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
|
||||
}
|
||||
/* Sequence number of last two end packets does not get incremented */
|
||||
|
@ -1984,7 +1977,6 @@ static int ast_rtcp_write_sr(void *data)
|
|||
int fraction;
|
||||
struct timeval dlsr;
|
||||
char bdata[512];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
if (!rtp || !rtp->rtcp || (&rtp->rtcp->them.sin_addr == 0))
|
||||
return 0;
|
||||
|
@ -2049,7 +2041,7 @@ static int ast_rtcp_write_sr(void *data)
|
|||
|
||||
res = sendto(rtp->rtcp->s, (unsigned int *)rtcpheader, len, 0, (struct sockaddr *)&rtp->rtcp->them, sizeof(rtp->rtcp->them));
|
||||
if (res < 0) {
|
||||
ast_log(LOG_ERROR, "RTCP SR transmission error to %s:%d, rtcp halted %s\n",ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port), strerror(errno));
|
||||
ast_log(LOG_ERROR, "RTCP SR transmission error to %s:%d, rtcp halted %s\n",ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port), strerror(errno));
|
||||
if (rtp->rtcp->schedid > 0)
|
||||
ast_sched_del(rtp->sched, rtp->rtcp->schedid);
|
||||
rtp->rtcp->schedid = -1;
|
||||
|
@ -2063,7 +2055,7 @@ static int ast_rtcp_write_sr(void *data)
|
|||
rtp->rtcp->lastsrtxcount = rtp->txcount;
|
||||
|
||||
if (rtcp_debug_test_addr(&rtp->rtcp->them)) {
|
||||
ast_verbose("* Sent RTCP SR to %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
ast_verbose("* Sent RTCP SR to %s:%d\n", ast_inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
ast_verbose(" Our SSRC: %u\n", rtp->ssrc);
|
||||
ast_verbose(" Sent(NTP): %u.%010u\n", (unsigned int)now.tv_sec, (unsigned int)now.tv_usec*4096);
|
||||
ast_verbose(" Sent(RTP): %u\n", rtp->lastts);
|
||||
|
@ -2094,7 +2086,6 @@ static int ast_rtcp_write_rr(void *data)
|
|||
struct timeval now;
|
||||
unsigned int *rtcpheader;
|
||||
char bdata[1024];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
struct timeval dlsr;
|
||||
int fraction;
|
||||
|
||||
|
@ -2166,8 +2157,7 @@ static int ast_rtcp_write_rr(void *data)
|
|||
" IA jitter: %.4f\n"
|
||||
" Their last SR: %u\n"
|
||||
" DLSR: %4.4f (sec)\n\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf),
|
||||
rtp->rtcp->them.sin_addr),
|
||||
ast_inet_ntoa(rtp->rtcp->them.sin_addr),
|
||||
ntohs(rtp->rtcp->them.sin_port),
|
||||
rtp->ssrc, rtp->themssrc, fraction, lost,
|
||||
rtp->rxjitter,
|
||||
|
@ -2202,7 +2192,6 @@ int ast_rtp_sendcng(struct ast_rtp *rtp, int level)
|
|||
int res;
|
||||
int payload;
|
||||
char data[256];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
level = 127 - (level & 0x7f);
|
||||
payload = ast_rtp_lookup_code(rtp, 0, AST_RTP_CN);
|
||||
|
||||
|
@ -2221,10 +2210,10 @@ int ast_rtp_sendcng(struct ast_rtp *rtp, int level)
|
|||
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
|
||||
res = sendto(rtp->s, (void *)rtpheader, hdrlen + 1, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
|
||||
if (res <0)
|
||||
ast_log(LOG_ERROR, "RTP Comfort Noise Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||
ast_log(LOG_ERROR, "RTP Comfort Noise Transmission error to %s:%d: %s\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||
if (rtp_debug_test_addr(&rtp->them))
|
||||
ast_verbose("Sent Comfort Noise RTP packet to %s:%d (type %d, seq %d, ts %u, len %d)\n"
|
||||
, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastts,res - hdrlen);
|
||||
, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), payload, rtp->seqno, rtp->lastts,res - hdrlen);
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
@ -2233,7 +2222,6 @@ int ast_rtp_sendcng(struct ast_rtp *rtp, int level)
|
|||
static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec)
|
||||
{
|
||||
unsigned char *rtpheader;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
int hdrlen = 12;
|
||||
int res;
|
||||
unsigned int ms;
|
||||
|
@ -2295,11 +2283,11 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
|
|||
res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
|
||||
if (res <0) {
|
||||
if (!rtp->nat || (rtp->nat && (ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) {
|
||||
ast_log(LOG_DEBUG, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||
ast_log(LOG_DEBUG, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||
} else if ((ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) {
|
||||
/* Only give this error message once if we are not RTP debugging */
|
||||
if (option_debug || rtpdebug)
|
||||
ast_log(LOG_DEBUG, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
ast_log(LOG_DEBUG, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
ast_set_flag(rtp, FLAG_NAT_INACTIVE_NOWARN);
|
||||
}
|
||||
} else {
|
||||
|
@ -2312,7 +2300,7 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
|
|||
|
||||
if (rtp_debug_test_addr(&rtp->them))
|
||||
ast_verbose("Sent RTP packet to %s:%d (type %-2.2d, seq %-6.6u, ts %-6.6u, len %-6.6u)\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), codec, rtp->seqno, rtp->lastts,res - hdrlen);
|
||||
ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), codec, rtp->seqno, rtp->lastts,res - hdrlen);
|
||||
}
|
||||
|
||||
rtp->seqno++;
|
||||
|
@ -2508,7 +2496,6 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
|||
struct sockaddr_in vac0, vac1;
|
||||
struct sockaddr_in t0, t1;
|
||||
struct sockaddr_in vt0, vt1;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
void *pvt0, *pvt1;
|
||||
int codec0,codec1, oldcodec0, oldcodec1;
|
||||
|
@ -2652,13 +2639,13 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
|||
if (inaddrcmp(&t1, &ac1) || (vp1 && inaddrcmp(&vt1, &vac1)) || (codec1 != oldcodec1)) {
|
||||
if (option_debug > 1) {
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), t1.sin_addr), ntohs(t1.sin_port), codec1);
|
||||
c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), codec1);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' changed end vaddress to %s:%d (format %d)\n",
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vt1.sin_addr), ntohs(vt1.sin_port), codec1);
|
||||
c1->name, ast_inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), codec1);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
|
||||
c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
|
||||
c1->name, ast_inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
|
||||
}
|
||||
if (pr0->set_rtp_peer(c0, t1.sin_addr.s_addr ? p1 : NULL, vt1.sin_addr.s_addr ? vp1 : NULL, codec1, ast_test_flag(p1, FLAG_NAT_ACTIVE)))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name);
|
||||
|
@ -2669,9 +2656,9 @@ enum ast_bridge_result ast_rtp_bridge(struct ast_channel *c0, struct ast_channel
|
|||
if (inaddrcmp(&t0, &ac0) || (vp0 && inaddrcmp(&vt0, &vac0))) {
|
||||
if (option_debug) {
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
|
||||
c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), t0.sin_addr), ntohs(t0.sin_port), codec0);
|
||||
c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), codec0);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
|
||||
c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
|
||||
c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
|
||||
}
|
||||
if (pr1->set_rtp_peer(c1, t0.sin_addr.s_addr ? p0 : NULL, vt0.sin_addr.s_addr ? vp0 : NULL, codec0, ast_test_flag(p0, FLAG_NAT_ACTIVE)))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name);
|
||||
|
@ -2742,7 +2729,6 @@ static int rtp_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;
|
||||
|
||||
|
@ -2762,9 +2748,9 @@ static int rtp_do_debug_ip(int fd, int argc, char *argv[])
|
|||
memcpy(&rtpdebugaddr.sin_addr, hp->h_addr, sizeof(rtpdebugaddr.sin_addr));
|
||||
rtpdebugaddr.sin_port = htons(port);
|
||||
if (port == 0)
|
||||
ast_cli(fd, "RTP Debugging Enabled for IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtpdebugaddr.sin_addr));
|
||||
ast_cli(fd, "RTP Debugging Enabled for IP: %s\n", ast_inet_ntoa(rtpdebugaddr.sin_addr));
|
||||
else
|
||||
ast_cli(fd, "RTP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtpdebugaddr.sin_addr), port);
|
||||
ast_cli(fd, "RTP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(rtpdebugaddr.sin_addr), port);
|
||||
rtpdebug = 1;
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -2773,7 +2759,6 @@ static int rtcp_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;
|
||||
if (argc != 5)
|
||||
|
@ -2793,9 +2778,9 @@ static int rtcp_do_debug_ip(int fd, int argc, char *argv[])
|
|||
memcpy(&rtcpdebugaddr.sin_addr, hp->h_addr, sizeof(rtcpdebugaddr.sin_addr));
|
||||
rtcpdebugaddr.sin_port = htons(port);
|
||||
if (port == 0)
|
||||
ast_cli(fd, "RTCP Debugging Enabled for IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtcpdebugaddr.sin_addr));
|
||||
ast_cli(fd, "RTCP Debugging Enabled for IP: %s\n", ast_inet_ntoa(rtcpdebugaddr.sin_addr));
|
||||
else
|
||||
ast_cli(fd, "RTCP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtcpdebugaddr.sin_addr), port);
|
||||
ast_cli(fd, "RTCP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(rtcpdebugaddr.sin_addr), port);
|
||||
rtcpdebug = 1;
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
|
28
udptl.c
28
udptl.c
|
@ -644,7 +644,6 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl)
|
|||
struct sockaddr_in sin;
|
||||
socklen_t len;
|
||||
uint16_t seqno = 0;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
uint16_t *udptlheader;
|
||||
|
||||
len = sizeof(sin);
|
||||
|
@ -674,16 +673,16 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl)
|
|||
if ((udptl->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
|
||||
(udptl->them.sin_port != sin.sin_port)) {
|
||||
memcpy(&udptl->them, &sin, sizeof(udptl->them));
|
||||
ast_log(LOG_DEBUG, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), udptl->them.sin_addr), ntohs(udptl->them.sin_port));
|
||||
ast_log(LOG_DEBUG, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port));
|
||||
}
|
||||
}
|
||||
|
||||
if (udptl_debug_test_addr(&sin)) {
|
||||
ast_verbose("Got UDPTL packet from %s:%d (type %d, seq %d, len %d)\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res);
|
||||
ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res);
|
||||
}
|
||||
#if 0
|
||||
printf("Got UDPTL packet from %s:%d (seq %d, len = %d)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), seqno, res);
|
||||
printf("Got UDPTL packet from %s:%d (seq %d, len = %d)\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), seqno, res);
|
||||
#endif
|
||||
udptl_rx_packet(udptl, udptl->rawdata + AST_FRIENDLY_OFFSET, res);
|
||||
|
||||
|
@ -895,7 +894,6 @@ int ast_udptl_write(struct ast_udptl *s, struct ast_frame *f)
|
|||
int len;
|
||||
int res;
|
||||
uint8_t buf[LOCAL_FAX_MAX_DATAGRAM];
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
|
||||
/* If we have no peer, return immediately */
|
||||
if (s->them.sin_addr.s_addr == INADDR_ANY)
|
||||
|
@ -915,13 +913,13 @@ int ast_udptl_write(struct ast_udptl *s, struct ast_frame *f)
|
|||
|
||||
if (len > 0 && s->them.sin_port && s->them.sin_addr.s_addr) {
|
||||
if ((res = sendto(s->fd, buf, len, 0, (struct sockaddr *) &s->them, sizeof(s->them))) < 0)
|
||||
ast_log(LOG_NOTICE, "UDPTL Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->them.sin_addr), ntohs(s->them.sin_port), strerror(errno));
|
||||
ast_log(LOG_NOTICE, "UDPTL Transmission error to %s:%d: %s\n", ast_inet_ntoa(s->them.sin_addr), ntohs(s->them.sin_port), strerror(errno));
|
||||
#if 0
|
||||
printf("Sent %d bytes of UDPTL data to %s:%d\n", res, ast_inet_ntoa(iabuf, sizeof(iabuf), udptl->them.sin_addr), ntohs(udptl->them.sin_port));
|
||||
printf("Sent %d bytes of UDPTL data to %s:%d\n", res, ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port));
|
||||
#endif
|
||||
if (udptl_debug_test_addr(&s->them))
|
||||
ast_verbose("Sent UDPTL packet to %s:%d (type %d, seq %d, len %d)\n",
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), s->them.sin_addr),
|
||||
ast_inet_ntoa(s->them.sin_addr),
|
||||
ntohs(s->them.sin_port), 0, s->seqno, len);
|
||||
}
|
||||
|
||||
|
@ -991,7 +989,6 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
|
|||
struct sockaddr_in ac1;
|
||||
struct sockaddr_in t0;
|
||||
struct sockaddr_in t1;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
void *pvt0;
|
||||
void *pvt1;
|
||||
int to;
|
||||
|
@ -1056,16 +1053,16 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
|
|||
ast_udptl_get_peer(p0, &t0);
|
||||
if (inaddrcmp(&t1, &ac1)) {
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n",
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), t1.sin_addr), ntohs(t1.sin_port));
|
||||
c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port));
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n",
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac1.sin_addr), ntohs(ac1.sin_port));
|
||||
c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port));
|
||||
memcpy(&ac1, &t1, sizeof(ac1));
|
||||
}
|
||||
if (inaddrcmp(&t0, &ac0)) {
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n",
|
||||
c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), t0.sin_addr), ntohs(t0.sin_port));
|
||||
c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port));
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n",
|
||||
c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac0.sin_addr), ntohs(ac0.sin_port));
|
||||
c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port));
|
||||
memcpy(&ac0, &t0, sizeof(ac0));
|
||||
}
|
||||
who = ast_waitfor_n(cs, 2, &to);
|
||||
|
@ -1106,7 +1103,6 @@ static int udptl_do_debug_ip(int fd, int argc, char *argv[])
|
|||
{
|
||||
struct hostent *hp;
|
||||
struct ast_hostent ahp;
|
||||
char iabuf[INET_ADDRSTRLEN];
|
||||
int port;
|
||||
char *p;
|
||||
char *arg;
|
||||
|
@ -1128,9 +1124,9 @@ static int udptl_do_debug_ip(int fd, int argc, char *argv[])
|
|||
memcpy(&udptldebugaddr.sin_addr, hp->h_addr, sizeof(udptldebugaddr.sin_addr));
|
||||
udptldebugaddr.sin_port = htons(port);
|
||||
if (port == 0)
|
||||
ast_cli(fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), udptldebugaddr.sin_addr));
|
||||
ast_cli(fd, "UDPTL Debugging Enabled for IP: %s\n", ast_inet_ntoa(udptldebugaddr.sin_addr));
|
||||
else
|
||||
ast_cli(fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), udptldebugaddr.sin_addr), port);
|
||||
ast_cli(fd, "UDPTL Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(udptldebugaddr.sin_addr), port);
|
||||
udptldebug = 1;
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
|
23
utils.c
23
utils.c
|
@ -62,6 +62,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||
static char base64[64];
|
||||
static char b2a[256];
|
||||
|
||||
static pthread_key_t inet_ntoa_buf_key;
|
||||
static pthread_once_t inet_ntoa_buf_once = PTHREAD_ONCE_INIT;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__)
|
||||
|
||||
#define ERANGE 34 /*!< duh? ERANGE value copied from web... */
|
||||
|
@ -483,10 +486,24 @@ void ast_uri_decode(char *s)
|
|||
*o = '\0';
|
||||
}
|
||||
|
||||
/*! \brief ast_inet_ntoa: Recursive thread safe replacement of inet_ntoa */
|
||||
const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia)
|
||||
static void inet_ntoa_buf_key_create(void)
|
||||
{
|
||||
return inet_ntop(AF_INET, &ia, buf, bufsiz);
|
||||
pthread_key_create(&inet_ntoa_buf_key, free);
|
||||
}
|
||||
|
||||
/*! \brief ast_inet_ntoa: Recursive thread safe replacement of inet_ntoa */
|
||||
const char *ast_inet_ntoa(struct in_addr ia)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
pthread_once(&inet_ntoa_buf_once, inet_ntoa_buf_key_create);
|
||||
if (!(buf = pthread_getspecific(inet_ntoa_buf_key))) {
|
||||
if (!(buf = ast_calloc(1, INET_ADDRSTRLEN)))
|
||||
return NULL;
|
||||
pthread_setspecific(inet_ntoa_buf_key, buf);
|
||||
}
|
||||
|
||||
return inet_ntop(AF_INET, &ia, buf, INET_ADDRSTRLEN);
|
||||
}
|
||||
|
||||
int ast_utils_init(void)
|
||||
|
|
Reference in New Issue