mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
Create reentrant ast_inet_ntoa and replace all inet_ntoa's with ast_inet_ntoa's (but #1944)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3345 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
13
acl.c
13
acl.c
@@ -170,8 +170,10 @@ int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin)
|
||||
/* Start optimistic */
|
||||
int res = AST_SENSE_ALLOW;
|
||||
while(ha) {
|
||||
char tmp[80];
|
||||
char tmp2[80];
|
||||
/* DEBUG */
|
||||
ast_log(LOG_DEBUG, "##### Testing %s with %s\n",inet_ntoa(sin->sin_addr), inet_ntoa(ha->netaddr) );
|
||||
ast_log(LOG_DEBUG, "##### Testing %s with %s\n",ast_inet_ntoa(tmp, sizeof(tmp), sin->sin_addr), ast_inet_ntoa(tmp2, sizeof(tmp2), ha->netaddr));
|
||||
/* For each rule, if this address and the netmask = the net address
|
||||
apply the current rule */
|
||||
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == (ha->netaddr.s_addr))
|
||||
@@ -226,11 +228,13 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
||||
struct rt_msghdr m_rtm;
|
||||
char m_space[512];
|
||||
} m_rtmsg;
|
||||
char *cp, *p = ast_strdupa(inet_ntoa(*them));
|
||||
char tmp[80];
|
||||
char *cp, *p;
|
||||
int i, l, s, seq, flags;
|
||||
pid_t pid = getpid();
|
||||
static int routeseq; /* Protected by "routeseq_lock" mutex */
|
||||
|
||||
p = ast_strdupa(ast_inet_ntoa(tmp, sizeof(tmp), *them))
|
||||
memset(us, 0, sizeof(struct in_addr));
|
||||
|
||||
memset(&m_rtmsg, 0, sizeof(m_rtmsg));
|
||||
@@ -293,7 +297,7 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
||||
if (i == RTA_IFA && sa->sa_family == AF_INET) {
|
||||
sin = (struct sockaddr_in *)sa;
|
||||
*us = sin->sin_addr;
|
||||
ast_log(LOG_DEBUG, "Found route to %s, output from our address %s.\n", p, inet_ntoa(*us));
|
||||
ast_log(LOG_DEBUG, "Found route to %s, output from our address %s.\n", p, ast_inet_ntoa(tmp, sizeof(tmp), *us));
|
||||
return 0;
|
||||
}
|
||||
cp += sa->sa_len > 0 ?
|
||||
@@ -350,7 +354,8 @@ int ast_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
||||
sscanf(fields[2],"%x",&gateway);
|
||||
sscanf(fields[7],"%x",&mask);
|
||||
#if 0
|
||||
printf("Addr: %s %08x Dest: %08x Mask: %08x\n", inet_ntoa(*them), remote_ip, dest, mask);
|
||||
{ char tmp[80];
|
||||
printf("Addr: %s %08x Dest: %08x Mask: %08x\n", ast_inet_ntoa(tmp, sizeof(tmp), *them), remote_ip, dest, mask); }
|
||||
#endif
|
||||
/* Looks simple, but here is the magic */
|
||||
if (((remote_ip & mask) ^ dest) == 0) {
|
||||
|
@@ -26,7 +26,7 @@ CHANNEL_LIBS=chan_modem.so chan_sip.so \
|
||||
# If you really want IAX1 uncomment the following, but it is
|
||||
# unmaintained
|
||||
#
|
||||
#CHANNEL_LIBS+=chan_iax.so
|
||||
CHANNEL_LIBS+=chan_iax.so
|
||||
|
||||
#
|
||||
# If you really want VoFR you can have it :-P
|
||||
|
@@ -918,7 +918,7 @@ struct oh323_alias *find_alias(const char *source_aliases)
|
||||
struct oh323_user *find_user(const call_details_t cd)
|
||||
{
|
||||
struct oh323_user *u;
|
||||
|
||||
char iabuf[80];
|
||||
u = userl.users;
|
||||
if(userbyalias == 1){
|
||||
while(u) {
|
||||
@@ -930,7 +930,7 @@ struct oh323_user *find_user(const call_details_t cd)
|
||||
|
||||
} else {
|
||||
while(u) {
|
||||
if (!strcasecmp(cd.sourceIp, inet_ntoa(u->addr.sin_addr))) {
|
||||
if (!strcasecmp(cd.sourceIp, ast_inet_ntoa(iabuf, sizeof(iabuf), u->addr.sin_addr))) {
|
||||
break;
|
||||
}
|
||||
u = u->next;
|
||||
@@ -998,6 +998,12 @@ struct rtp_info *create_connection(unsigned call_reference)
|
||||
struct sockaddr_in us;
|
||||
struct sockaddr_in them;
|
||||
struct rtp_info *info;
|
||||
char iabuf[80];
|
||||
/* XXX This is sooooo bugus. inet_ntoa is not reentrant
|
||||
but this function wants to return a static variable so
|
||||
the only way to do this will be to declare iabuf within
|
||||
the oh323_pvt structure XXX */
|
||||
static char iabuf[80];
|
||||
|
||||
info = (struct rtp_info *) malloc(sizeof(struct rtp_info));
|
||||
|
||||
@@ -1012,7 +1018,7 @@ struct rtp_info *create_connection(unsigned call_reference)
|
||||
ast_rtp_get_us(p->rtp, &us);
|
||||
ast_rtp_get_peer(p->rtp, &them);
|
||||
|
||||
info->addr = inet_ntoa(us.sin_addr);
|
||||
info->addr = ast_inet_ntoa(iabuf, sizeof(iabuf), us.sin_addr);
|
||||
info->port = ntohs(us.sin_port);
|
||||
|
||||
return info;
|
||||
@@ -1031,6 +1037,7 @@ int setup_incoming_call(call_details_t cd)
|
||||
/* struct ast_channel *c = NULL; */
|
||||
struct oh323_user *user = NULL;
|
||||
struct oh323_alias *alias = NULL;
|
||||
char iabuf[80];
|
||||
|
||||
/* allocate the call*/
|
||||
p = oh323_alloc(cd.call_reference);
|
||||
@@ -1094,7 +1101,7 @@ int setup_incoming_call(call_details_t cd)
|
||||
ast_log(LOG_DEBUG, "Sending %s to context [%s]\n", cd.call_source_aliases, p->context);
|
||||
} else {
|
||||
if (user->host) {
|
||||
if (strcasecmp(cd.sourceIp, inet_ntoa(user->addr.sin_addr))){
|
||||
if (strcasecmp(cd.sourceIp, ast_inet_ntoa(iabuf, sizeof(iabuf), user->addr.sin_addr))){
|
||||
if (ast_strlen_zero(user->context)) {
|
||||
if (ast_strlen_zero(default_context)) {
|
||||
ast_log(LOG_ERROR, "Call from '%s' rejected due to non-matching IP address (%s) and no default context\n", user->name, cd.sourceIp);
|
||||
@@ -1833,6 +1840,7 @@ static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, str
|
||||
struct sockaddr_in them;
|
||||
struct sockaddr_in us;
|
||||
char *mode;
|
||||
char iabuf[80];
|
||||
|
||||
mode = convertcap(chan->writeformat);
|
||||
|
||||
@@ -1849,7 +1857,7 @@ static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, str
|
||||
ast_rtp_get_peer(rtp, &them);
|
||||
ast_rtp_get_us(rtp, &us);
|
||||
|
||||
h323_native_bridge(p->cd.call_token, inet_ntoa(them.sin_addr), mode);
|
||||
h323_native_bridge(p->cd.call_token, ast_inet_ntoa(iabuf, sizeof(iabuf), them.sin_addr), mode);
|
||||
|
||||
return 0;
|
||||
|
||||
|
@@ -509,6 +509,7 @@ static void showframe(struct ast_iax_frame *f, struct ast_iax_full_hdr *fhi, int
|
||||
char subclass2[20];
|
||||
char *class;
|
||||
char *subclass;
|
||||
char iabuf[80];
|
||||
if (f) {
|
||||
fh = f->data;
|
||||
snprintf(retries, sizeof(retries), "%03d", f->retries);
|
||||
@@ -555,7 +556,7 @@ static void showframe(struct ast_iax_frame *f, struct ast_iax_full_hdr *fhi, int
|
||||
" Timestamp: %05ldms Callno: %5.5d DCall: %5.5d [%s:%d]\n",
|
||||
(long)ntohl(fh->ts),
|
||||
(short)(ntohs(fh->callno) & ~AST_FLAG_FULL), (short) ntohs(fh->dcallno),
|
||||
inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -819,8 +820,8 @@ static int find_callno(short callno, short dcallno ,struct sockaddr_in *sin, int
|
||||
iaxs[x]->callno = x;
|
||||
iaxs[x]->pingtime = DEFAULT_RETRY_TIME;
|
||||
iaxs[x]->expirey = expirey;
|
||||
iaxs[x]->pingid = ast_sched_add(sched, ping_time * 1000, send_ping, (void *)x);
|
||||
iaxs[x]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)x);
|
||||
iaxs[x]->pingid = ast_sched_add(sched, ping_time * 1000, send_ping, (void *)(long)x);
|
||||
iaxs[x]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
|
||||
iaxs[x]->amaflags = amaflags;
|
||||
strncpy(iaxs[x]->accountcode, accountcode, sizeof(iaxs[x]->accountcode)-1);
|
||||
} else {
|
||||
@@ -925,7 +926,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", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_WARNING, "Receive error from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
else
|
||||
ast_log(LOG_WARNING, "No address detected??\n");
|
||||
} else {
|
||||
@@ -939,9 +940,10 @@ static int handle_error(void)
|
||||
static int send_packet(struct ast_iax_frame *f)
|
||||
{
|
||||
int res;
|
||||
char iabuf[80];
|
||||
/* Called with iaxsl held */
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, f->callno, iaxs[f->callno]->peercallno, inet_ntoa(iaxs[f->callno]->addr.sin_addr), ntohs(iaxs[f->callno]->addr.sin_port));
|
||||
ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, f->callno, iaxs[f->callno]->peercallno, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[f->callno]->addr.sin_addr), ntohs(iaxs[f->callno]->addr.sin_port));
|
||||
/* Don't send if there was an error, but return error instead */
|
||||
if (f->callno < 0) {
|
||||
ast_log(LOG_WARNING, "Call number = %d\n", f->callno);
|
||||
@@ -1108,6 +1110,7 @@ static int attempt_transmit(void *data)
|
||||
struct ast_iax_frame *f = data;
|
||||
int freeme=0;
|
||||
int callno = f->callno;
|
||||
char iabuf[80];
|
||||
/* Make sure this call is still active */
|
||||
if (callno > -1)
|
||||
ast_mutex_lock(&iaxsl[callno]);
|
||||
@@ -1124,7 +1127,7 @@ static int attempt_transmit(void *data)
|
||||
iax_destroy_nolock(f->callno);
|
||||
} else {
|
||||
if (iaxs[f->callno]->owner)
|
||||
ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", inet_ntoa(iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->f->frametype, f->f->subclass, f->ts, f->seqno);
|
||||
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->f->frametype, f->f->subclass, f->ts, f->seqno);
|
||||
iaxs[f->callno]->error = ETIMEDOUT;
|
||||
if (iaxs[f->callno]->owner) {
|
||||
struct ast_frame fr = { 0, };
|
||||
@@ -1531,7 +1534,7 @@ static void mysql_update_peer(char *peer, struct sockaddr_in *sin)
|
||||
time(&nowtime);
|
||||
mysql_real_escape_string(mysql, name, peer, strlen(peer));
|
||||
snprintf(query, sizeof(query), "UPDATE iax1friends SET ipaddr=\"%s\", port=\"%d\", regseconds=\"%ld\" WHERE name=\"%s\"",
|
||||
inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), nowtime, name);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), nowtime, name);
|
||||
ast_mutex_lock(&mysqllock);
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
ast_log(LOG_WARNING, "Unable to update database\n");
|
||||
@@ -1838,7 +1841,7 @@ static int iax_call(struct ast_channel *c, char *dest, int timeout)
|
||||
if (p->maxtime) {
|
||||
/* Initialize pingtime and auto-congest time */
|
||||
p->pingtime = p->maxtime / 2;
|
||||
p->initid = ast_sched_add(sched, p->maxtime * 2, auto_congest, (void *)p->callno);
|
||||
p->initid = ast_sched_add(sched, p->maxtime * 2, auto_congest, (void *)(long)p->callno);
|
||||
}
|
||||
send_command(p, AST_FRAME_IAX,
|
||||
AST_IAX_COMMAND_NEW, 0, requeststr, strlen(requeststr) + 1, -1);
|
||||
@@ -1902,10 +1905,11 @@ static int iax_start_transfer(struct ast_channel *c0, struct ast_channel *c1)
|
||||
int res;
|
||||
char req0[256];
|
||||
char req1[256];
|
||||
char iabuf[80];
|
||||
struct chan_iax_pvt *p0 = c0->pvt->pvt;
|
||||
struct chan_iax_pvt *p1 = c1->pvt->pvt;
|
||||
snprintf(req0, sizeof(req0), "remip=%s;remport=%d;remcall=%d;", inet_ntoa(p1->addr.sin_addr), ntohs(p1->addr.sin_port), p1->peercallno);
|
||||
snprintf(req1, sizeof(req1), "remip=%s;remport=%d;remcall=%d;", inet_ntoa(p0->addr.sin_addr), ntohs(p0->addr.sin_port), p0->peercallno);
|
||||
snprintf(req0, sizeof(req0), "remip=%s;remport=%d;remcall=%d;", ast_inet_ntoa(iabuf, sizeof(iabuf), p1->addr.sin_addr), ntohs(p1->addr.sin_port), p1->peercallno);
|
||||
snprintf(req1, sizeof(req1), "remip=%s;remport=%d;remcall=%d;", ast_inet_ntoa(iabuf, sizeof(iabuf), p0->addr.sin_addr), ntohs(p0->addr.sin_port), p0->peercallno);
|
||||
res = send_command(p0, AST_FRAME_IAX, AST_IAX_COMMAND_TXREQ, 0, req0, strlen(req0) + 1, -1);
|
||||
if (res)
|
||||
return -1;
|
||||
@@ -2079,10 +2083,11 @@ static struct ast_channel *ast_iax_new(struct chan_iax_pvt *i, int state, int ca
|
||||
{
|
||||
char host[256];
|
||||
struct ast_channel *tmp;
|
||||
char iabuf[80];
|
||||
tmp = ast_channel_alloc(1);
|
||||
if (tmp) {
|
||||
if (!iax_getpeername(i->addr, host, sizeof(host)))
|
||||
snprintf(host, sizeof(host), "%s:%d", inet_ntoa(i->addr.sin_addr), ntohs(i->addr.sin_port));
|
||||
snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), i->addr.sin_addr), ntohs(i->addr.sin_port));
|
||||
if (strlen(i->username))
|
||||
snprintf(tmp->name, sizeof(tmp->name), "IAX[%s@%s]/%d", i->username, host, i->callno);
|
||||
else
|
||||
@@ -2334,6 +2339,7 @@ static int iax_show_peers(int fd, int argc, char *argv[])
|
||||
#define FORMAT "%-15.15s %-15.15s %s %-15.15s %-8d %-10s\n"
|
||||
struct iax_peer *peer;
|
||||
char name[256] = "";
|
||||
char iabuf[80];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_mutex_lock(&peerl.lock);
|
||||
@@ -2356,9 +2362,9 @@ static int iax_show_peers(int fd, int argc, char *argv[])
|
||||
strcpy(status, "UNKNOWN");
|
||||
} else
|
||||
strcpy(status, "Unmonitored");
|
||||
strncpy(nm, inet_ntoa(peer->mask), sizeof(nm)-1);
|
||||
strncpy(nm, ast_inet_ntoa(iabuf, sizeof(iabuf), peer->mask), sizeof(nm)-1);
|
||||
ast_cli(fd, FORMAT, name,
|
||||
peer->addr.sin_addr.s_addr ? inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->dynamic ? "(D)" : "(S)",
|
||||
nm,
|
||||
ntohs(peer->addr.sin_port), status);
|
||||
@@ -2408,14 +2414,15 @@ static int iax_show_registry(int fd, int argc, char *argv[])
|
||||
struct iax_registry *reg;
|
||||
char host[80];
|
||||
char perceived[80];
|
||||
char iabuf[80];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_mutex_lock(&peerl.lock);
|
||||
ast_cli(fd, FORMAT2, "Host", "Username", "Perceived", "Refresh", "State");
|
||||
for (reg = registrations;reg;reg = reg->next) {
|
||||
snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
|
||||
snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->addr.sin_addr), ntohs(reg->addr.sin_port));
|
||||
if (reg->us.sin_addr.s_addr)
|
||||
snprintf(perceived, sizeof(perceived), "%s:%d", inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
|
||||
snprintf(perceived, sizeof(perceived), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->us.sin_addr), ntohs(reg->us.sin_port));
|
||||
else
|
||||
strcpy(perceived, "<Unregistered>");
|
||||
ast_cli(fd, FORMAT, host,
|
||||
@@ -2433,13 +2440,14 @@ static int iax_show_channels(int fd, int argc, char *argv[])
|
||||
#define FORMAT "%-15.15s %-10.10s %5.5d/%5.5d %5.5d/%5.5d %-5.5dms %-4.4dms %-6.6s\n"
|
||||
int x;
|
||||
int numchans = 0;
|
||||
char iabuf[80];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_cli(fd, FORMAT2, "Peer", "Username", "ID (Lo/Rem)", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
|
||||
for (x=0;x<AST_IAX_MAX_CALLS;x++) {
|
||||
ast_mutex_lock(&iaxsl[x]);
|
||||
if (iaxs[x]) {
|
||||
ast_cli(fd, FORMAT, inet_ntoa(iaxs[x]->addr.sin_addr),
|
||||
ast_cli(fd, FORMAT, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[x]->addr.sin_addr),
|
||||
strlen(iaxs[x]->username) ? iaxs[x]->username : "(None)",
|
||||
iaxs[x]->callno, iaxs[x]->peercallno,
|
||||
iaxs[x]->oseqno, iaxs[x]->iseqno,
|
||||
@@ -2626,6 +2634,7 @@ static int check_access(int callno, struct sockaddr_in *sin, char *orequest, int
|
||||
char *var, *value;
|
||||
struct iax_user *user;
|
||||
char request[256];
|
||||
char iabuf[80];
|
||||
int gotcapability=0;
|
||||
char *stringp=NULL;
|
||||
strncpy(request, orequest, sizeof(request)-1);
|
||||
@@ -2670,7 +2679,7 @@ static int check_access(int callno, struct sockaddr_in *sin, char *orequest, int
|
||||
iaxs[callno]->peercapability = iaxs[callno]->peerformat;
|
||||
if (version > AST_IAX_PROTO_VERSION) {
|
||||
ast_log(LOG_WARNING, "Peer '%s' has too new a protocol version (%d) for me\n",
|
||||
inet_ntoa(sin->sin_addr), version);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), version);
|
||||
return res;
|
||||
}
|
||||
ast_mutex_lock(&userl.lock);
|
||||
@@ -2736,6 +2745,7 @@ static int check_access(int callno, struct sockaddr_in *sin, char *orequest, int
|
||||
static int raw_hangup(struct sockaddr_in *sin, short src, short dst)
|
||||
{
|
||||
struct ast_iax_full_hdr fh;
|
||||
char iabuf[80];
|
||||
fh.callno = htons(src | AST_FLAG_FULL);
|
||||
fh.dcallno = htons(dst);
|
||||
fh.ts = 0;
|
||||
@@ -2746,7 +2756,7 @@ static int raw_hangup(struct sockaddr_in *sin, short src, short dst)
|
||||
if (option_debug)
|
||||
#endif
|
||||
ast_log(LOG_DEBUG, "Raw Hangup %s:%d, src=%d, dst=%d\n",
|
||||
inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), src, dst);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), src, dst);
|
||||
return sendto(netsocket, &fh, sizeof(fh), 0, (struct sockaddr *)sin, sizeof(*sin));
|
||||
}
|
||||
|
||||
@@ -2841,6 +2851,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, char *orequest)
|
||||
char md5secret[256] = "";
|
||||
char rsasecret[256] = "";
|
||||
char secret[256] = "";
|
||||
char iabuf[80];
|
||||
struct iax_peer *p;
|
||||
struct ast_key *key;
|
||||
char *var;
|
||||
@@ -2879,7 +2890,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, char *orequest)
|
||||
}
|
||||
|
||||
if (!strlen(peer)) {
|
||||
ast_log(LOG_NOTICE, "Empty registration from %s\n", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "Empty registration from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2892,19 +2903,19 @@ static int register_verify(int callno, struct sockaddr_in *sin, char *orequest)
|
||||
p = mysql_peer(peer);
|
||||
#endif
|
||||
if (!p) {
|
||||
ast_log(LOG_NOTICE, "No registration for peer '%s' (from %s)\n", peer, inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "No registration for peer '%s' (from %s)\n", peer, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!p->dynamic) {
|
||||
ast_log(LOG_NOTICE, "Peer '%s' is not dynamic (from %s)\n", peer, inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "Peer '%s' is not dynamic (from %s)\n", peer, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
if (p->delme)
|
||||
free(p);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ast_apply_ha(p->ha, sin)) {
|
||||
ast_log(LOG_NOTICE, "Host %s denied access to register peer '%s'\n", inet_ntoa(sin->sin_addr), p->name);
|
||||
ast_log(LOG_NOTICE, "Host %s denied access to register peer '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), p->name);
|
||||
if (p->delme)
|
||||
free(p);
|
||||
return -1;
|
||||
@@ -2943,7 +2954,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, char *orequest)
|
||||
} else if (strlen(secret) && strstr(p->methods, "plaintext")) {
|
||||
/* They've provided a plain text password and we support that */
|
||||
if (strcmp(secret, p->secret)) {
|
||||
ast_log(LOG_NOTICE, "Host %s did not provide proper plaintext password for '%s'\n", inet_ntoa(sin->sin_addr), p->name);
|
||||
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);
|
||||
if (p->delme)
|
||||
free(p);
|
||||
return -1;
|
||||
@@ -2959,7 +2970,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, char *orequest)
|
||||
for (x=0;x<16;x++)
|
||||
MYSNPRINTF "%2.2x", digest[x]);
|
||||
if (strcasecmp(requeststr, md5secret)) {
|
||||
ast_log(LOG_NOTICE, "Host %s failed MD5 authentication for '%s' (%s != %s)\n", inet_ntoa(sin->sin_addr), p->name, requeststr, md5secret);
|
||||
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);
|
||||
if (p->delme)
|
||||
free(p);
|
||||
return -1;
|
||||
@@ -2985,12 +2996,13 @@ static int authenticate(char *challenge, char *secret, char *keyn, char *methods
|
||||
{
|
||||
int res = -1;
|
||||
int x;
|
||||
char iabuf[80];
|
||||
if (keyn && strlen(keyn)) {
|
||||
if (!strstr(methods, "rsa")) {
|
||||
if (!secret || !strlen(secret))
|
||||
ast_log(LOG_NOTICE, "Asked to authenticate to %s with an RSA key, but they don't allow RSA authentication\n", inet_ntoa(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(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
} else if (!strlen(challenge)) {
|
||||
ast_log(LOG_NOTICE, "No challenge provided for RSA authentication to %s\n", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "No challenge provided for RSA authentication to %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
} else {
|
||||
char sig[256];
|
||||
struct ast_key *key;
|
||||
@@ -3027,7 +3039,7 @@ static int authenticate(char *challenge, char *secret, char *keyn, char *methods
|
||||
MYSNPRINTF2 "secret=%s;", secret);
|
||||
res = 0;
|
||||
} else
|
||||
ast_log(LOG_NOTICE, "No way to send secret to peer '%s' (their methods: %s)\n", inet_ntoa(sin->sin_addr), methods);
|
||||
ast_log(LOG_NOTICE, "No way to send secret to peer '%s' (their methods: %s)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), methods);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -3292,6 +3304,7 @@ static int iax_ack_registry(char *orequest, struct sockaddr_in *sin, int callno)
|
||||
int ourport = 0;
|
||||
int refresh = 0;
|
||||
char ourip[256] = "<Unspecified>";
|
||||
char iabuf[80];
|
||||
struct sockaddr_in oldus;
|
||||
char *var, *value;
|
||||
char *stringp=NULL;
|
||||
@@ -3325,11 +3338,11 @@ static int iax_ack_registry(char *orequest, struct sockaddr_in *sin, int callno)
|
||||
reg = iaxs[callno]->reg;
|
||||
memcpy(&oldus, ®->us, sizeof(oldus));
|
||||
if (memcmp(®->addr, sin, sizeof(®->addr))) {
|
||||
ast_log(LOG_WARNING, "Received unsolicited registry ack from '%s'\n", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_WARNING, "Received unsolicited registry ack from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return -1;
|
||||
}
|
||||
if (!inet_aton(ourip, ®->us.sin_addr)) {
|
||||
ast_log(LOG_WARNING, "Registry ack from '%s' contains invalid IP '%s'\n", inet_ntoa(sin->sin_addr), ourip);
|
||||
ast_log(LOG_WARNING, "Registry ack from '%s' contains invalid IP '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ourip);
|
||||
return -1;
|
||||
}
|
||||
reg->us.sin_port = htons(ourport);
|
||||
@@ -3341,8 +3354,8 @@ static int iax_ack_registry(char *orequest, struct sockaddr_in *sin, int callno)
|
||||
reg->expire = ast_sched_add(sched, (5 * reg->refresh / 6) * 1000, iax_do_register_s, reg);
|
||||
}
|
||||
if (memcmp(&oldus, ®->us, sizeof(oldus)) && (option_verbose > 2)) {
|
||||
snprintf(ourip, sizeof(ourip), "%s:%d", inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Registered to '%s', who sees us as %s\n", inet_ntoa(sin->sin_addr), ourip);
|
||||
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 to '%s', who sees us as %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ourip);
|
||||
}
|
||||
reg->regstate = REG_STATE_REGISTERED;
|
||||
return 0;
|
||||
@@ -3429,6 +3442,7 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno)
|
||||
/* Called from IAX thread only, with proper iaxsl lock */
|
||||
char requeststr[256] = "";
|
||||
struct iax_peer *p;
|
||||
char iabuf[80];
|
||||
for (p = peerl.peers;p;p = p->next) {
|
||||
if (!strcasecmp(name, p->name)) {
|
||||
break;
|
||||
@@ -3448,7 +3462,7 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno)
|
||||
iax_regfunk(p->name, 1);
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Registered '%s' (%s) at %s:%d\n", p->name,
|
||||
iaxs[callno]->state & IAX_STATE_AUTHENTICATED ? "AUTHENTICATED" : "UNAUTHENTICATED", inet_ntoa(sin->sin_addr), htons(sin->sin_port));
|
||||
iaxs[callno]->state & IAX_STATE_AUTHENTICATED ? "AUTHENTICATED" : "UNAUTHENTICATED", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), htons(sin->sin_port));
|
||||
iax_poke_peer(p);
|
||||
}
|
||||
/* Update the host */
|
||||
@@ -3459,7 +3473,7 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno)
|
||||
if (p->expirey)
|
||||
p->expire = ast_sched_add(sched, p->expirey * 1000, expire_registry, (void *)p);
|
||||
MYSNPRINTF "peer=%s;yourip=%s;yourport=%d;refresh=%d;",
|
||||
p->name, inet_ntoa(p->addr.sin_addr), ntohs(p->addr.sin_port), p->expirey);
|
||||
p->name, ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), p->expirey);
|
||||
if (p->hascallerid)
|
||||
MYSNPRINTF "callerid=%s;", p->callerid);
|
||||
requeststr[strlen(requeststr)-1] = '\0';
|
||||
@@ -3510,6 +3524,7 @@ static int registry_rerequest(char *orequest, int callno, struct sockaddr_in *si
|
||||
char peer[256] = "";
|
||||
char methods[256] = "";
|
||||
char challenge[256] = "";
|
||||
char iabuf[80];
|
||||
char *var, *value;
|
||||
int res;
|
||||
char *stringp=NULL;
|
||||
@@ -3538,7 +3553,7 @@ static int registry_rerequest(char *orequest, int callno, struct sockaddr_in *si
|
||||
}
|
||||
reg = iaxs[callno]->reg;
|
||||
if (memcmp(®->addr, sin, sizeof(®->addr))) {
|
||||
ast_log(LOG_WARNING, "Received unsolicited registry authenticate request from '%s'\n", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_WARNING, "Received unsolicited registry authenticate request from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return -1;
|
||||
}
|
||||
if (!strlen(reg->secret)) {
|
||||
@@ -3598,7 +3613,7 @@ static void iax_dprequest(struct iax_dpcache *dp, int callno)
|
||||
/* Auto-hangup with 30 seconds of inactivity */
|
||||
if (iaxs[callno]->autoid > -1)
|
||||
ast_sched_del(sched, iaxs[callno]->autoid);
|
||||
iaxs[callno]->autoid = ast_sched_add(sched, 30000, auto_hangup, (void *)callno);
|
||||
iaxs[callno]->autoid = ast_sched_add(sched, 30000, auto_hangup, (void *)(long)callno);
|
||||
send_command(iaxs[callno], AST_FRAME_IAX, AST_IAX_COMMAND_DPREQ, 0, dp->exten, strlen(dp->exten) + 1, -1);
|
||||
dp->flags |= CACHE_FLAG_TRANSMITTED;
|
||||
}
|
||||
@@ -3651,6 +3666,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
|
||||
int format;
|
||||
int exists;
|
||||
int mm;
|
||||
char iabuf[80];
|
||||
char rel0[256];
|
||||
char rel1[255];
|
||||
char empty[32]=""; /* Safety measure */
|
||||
@@ -3662,7 +3678,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
|
||||
return 1;
|
||||
}
|
||||
if (res < sizeof(struct ast_iax_mini_hdr)) {
|
||||
ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, sizeof(struct ast_iax_mini_hdr));
|
||||
ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, (int)sizeof(struct ast_iax_mini_hdr));
|
||||
return 1;
|
||||
}
|
||||
#ifdef DEBUG_SUPPORT
|
||||
@@ -3761,7 +3777,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
|
||||
}
|
||||
/* A full frame */
|
||||
if (res < sizeof(struct ast_iax_full_hdr)) {
|
||||
ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, sizeof(struct ast_iax_full_hdr));
|
||||
ast_log(LOG_WARNING, "midget packet received (%d of %d min)\n", res, (int)sizeof(struct ast_iax_full_hdr));
|
||||
ast_mutex_unlock(&iaxsl[fr.callno]);
|
||||
return 1;
|
||||
}
|
||||
@@ -3862,7 +3878,7 @@ retryowner:
|
||||
if (check_access(fr.callno, &sin, f.data, f.datalen)) {
|
||||
/* They're not allowed on */
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "No authority found", strlen("No authority found"), -1);
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, request '%s'\n", inet_ntoa(sin.sin_addr), (char *)f.data);
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, request '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), (char *)f.data);
|
||||
break;
|
||||
}
|
||||
/* This might re-enter the IAX code and need the lock */
|
||||
@@ -3870,7 +3886,7 @@ retryowner:
|
||||
if (!strlen(iaxs[fr.callno]->secret) && !strlen(iaxs[fr.callno]->inkeys)) {
|
||||
if (strcmp(iaxs[fr.callno]->exten, "TBD") && !exists) {
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "No such context/extension", strlen("No such context/extension"), -1);
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, request '%s@%s' does not exist\n", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->exten, iaxs[fr.callno]->context);
|
||||
} else {
|
||||
/* Select an appropriate format */
|
||||
format = iaxs[fr.callno]->peerformat & iax_capability;
|
||||
@@ -3878,14 +3894,14 @@ retryowner:
|
||||
format = iaxs[fr.callno]->peercapability & iax_capability;
|
||||
if (!format) {
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "Unable to negotiate codec", strlen("Unable to negotiate codec"), -1);
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_capability);
|
||||
} else {
|
||||
/* Pick one... */
|
||||
format = ast_best_codec(iaxs[fr.callno]->peercapability & iax_capability);
|
||||
if (!format) {
|
||||
ast_log(LOG_ERROR, "No best format in 0x%x???\n", iaxs[fr.callno]->peercapability & iax_capability);
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "Unable to negotiate codec", strlen("Unable to negotiate codec"), -1);
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_capability);
|
||||
iaxs[fr.callno]->alreadygone = 1;
|
||||
break;
|
||||
}
|
||||
@@ -3899,14 +3915,14 @@ retryowner:
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepting unauthenticated call from %s, requested format = %d, actual format = %d\n",
|
||||
inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat,format);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat,format);
|
||||
if(!(c = ast_iax_new(iaxs[fr.callno], AST_STATE_RING, format)))
|
||||
iax_destroy_nolock(fr.callno);
|
||||
} else {
|
||||
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", inet_ntoa(sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepted unauthenticated TBD call from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3945,7 +3961,7 @@ retryowner:
|
||||
if (f.data)
|
||||
((char *)f.data)[f.datalen] = '\0';
|
||||
if (iaxs[fr.callno]->owner)
|
||||
ast_log(LOG_WARNING, "Call rejected by %s: %s\n", inet_ntoa(iaxs[fr.callno]->addr.sin_addr), (char *)f.data);
|
||||
ast_log(LOG_WARNING, "Call rejected by %s: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr.callno]->addr.sin_addr), (char *)f.data);
|
||||
iaxs[fr.callno]->error = EPERM;
|
||||
ast_log(LOG_DEBUG, "Immediately destroying %d, having received reject\n", fr.callno);
|
||||
iax_destroy_nolock(fr.callno);
|
||||
@@ -3964,10 +3980,10 @@ retryowner:
|
||||
iaxs[fr.callno]->peerformat = iax_capability;
|
||||
}
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Call accepted by %s (format %s)\n", inet_ntoa(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(iabuf, sizeof(iabuf), iaxs[fr.callno]->addr.sin_addr), ast_getformatname(iaxs[fr.callno]->peerformat));
|
||||
if (!(iaxs[fr.callno]->peerformat & iaxs[fr.callno]->capability)) {
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "Unable to negotiate codec", strlen("Unable to negotiate codec"), -1);
|
||||
ast_log(LOG_NOTICE, "Rejected call to %s, format 0x%x incompatible with our capability 0x%x.\n", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->capability);
|
||||
} else {
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if (iaxs[fr.callno]->owner) {
|
||||
@@ -4054,7 +4070,7 @@ retryowner:
|
||||
/* A little strange -- We have to actually go through the motions of
|
||||
delivering the packet. In the very last step, it will be properly
|
||||
handled by do_deliver */
|
||||
snprintf(src, sizeof(src), "LAGRQ-IAX/%s/%d", inet_ntoa(sin.sin_addr),fr.callno);
|
||||
snprintf(src, sizeof(src), "LAGRQ-IAX/%s/%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr),fr.callno);
|
||||
f.src = src;
|
||||
f.mallocd = 0;
|
||||
f.offset = 0;
|
||||
@@ -4074,7 +4090,7 @@ retryowner:
|
||||
if (authenticate_reply(iaxs[fr.callno], &iaxs[fr.callno]->addr, (char *)f.data, iaxs[fr.callno]->secret, iaxs[fr.callno]->outkey)) {
|
||||
ast_log(LOG_WARNING,
|
||||
"I don't know how to authenticate %s to %s\n",
|
||||
(char *)f.data, inet_ntoa(iaxs[fr.callno]->addr.sin_addr));
|
||||
(char *)f.data, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr.callno]->addr.sin_addr));
|
||||
}
|
||||
break;
|
||||
case AST_IAX_COMMAND_AUTHREP:
|
||||
@@ -4085,14 +4101,14 @@ retryowner:
|
||||
}
|
||||
((char *)f.data)[f.datalen] = '\0';
|
||||
if (authenticate_verify(iaxs[fr.callno], (char *)f.data)) {
|
||||
ast_log(LOG_NOTICE, "Host %s failed to authenticate as %s\n", inet_ntoa(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(iabuf, sizeof(iabuf), iaxs[fr.callno]->addr.sin_addr), iaxs[fr.callno]->username);
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "No authority found", strlen("No authority found"), -1);
|
||||
break;
|
||||
}
|
||||
/* This might re-enter the IAX code and need the lock */
|
||||
exists = ast_exists_extension(NULL, iaxs[fr.callno]->context, iaxs[fr.callno]->exten, 1, iaxs[fr.callno]->callerid);
|
||||
if (strcmp(iaxs[fr.callno]->exten, "TBD") && !exists) {
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, request '%s@%s' does not exist\n", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->exten, iaxs[fr.callno]->context);
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "No such context/extension", strlen("No such context/extension"), -1);
|
||||
} else {
|
||||
/* Select an appropriate format */
|
||||
@@ -4101,14 +4117,14 @@ retryowner:
|
||||
ast_log(LOG_DEBUG, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr.callno]->peerformat), iaxs[fr.callno]->peercapability);
|
||||
format = iaxs[fr.callno]->peercapability & iax_capability;
|
||||
if (!format) {
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_capability);
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "Unable to negotiate codec", strlen("Unable to negotiate codec"), -1);
|
||||
} else {
|
||||
/* Pick one... */
|
||||
format = ast_best_codec(iaxs[fr.callno]->peercapability & iax_capability);
|
||||
if (!format) {
|
||||
ast_log(LOG_ERROR, "No best format in 0x%x???\n", iaxs[fr.callno]->peercapability & iax_capability);
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iax_capability);
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "Unable to negotiate codec", strlen("Unable to negotiate codec"), -1);
|
||||
}
|
||||
}
|
||||
@@ -4121,7 +4137,7 @@ retryowner:
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepting AUTHENTICATED call from %s, requested format = %d, actual format = %d\n",
|
||||
inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat,format);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat,format);
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if(!(c = ast_iax_new(iaxs[fr.callno], AST_STATE_RING, format)))
|
||||
iax_destroy_nolock(fr.callno);
|
||||
@@ -4129,7 +4145,7 @@ retryowner:
|
||||
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", inet_ntoa(sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepted AUTHENTICATED TBD call from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4140,12 +4156,12 @@ retryowner:
|
||||
iaxs[fr.callno]->state &= ~IAX_STATE_TBD;
|
||||
strncpy(iaxs[fr.callno]->exten, (char *)f.data, sizeof(iaxs[fr.callno]->exten)-1);
|
||||
if (!ast_exists_extension(NULL, iaxs[fr.callno]->context, iaxs[fr.callno]->exten, 1, iaxs[fr.callno]->callerid)) {
|
||||
ast_log(LOG_NOTICE, "Rejected dial attempt from %s, request '%s@%s' does not exist\n", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->exten, iaxs[fr.callno]->context);
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, AST_IAX_COMMAND_REJECT, 0, "No such context/extension", strlen("No such context/extension"), -1);
|
||||
} else {
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepting DIAL from %s, formats = 0x%x\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat);
|
||||
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);
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if(!(c = ast_iax_new(iaxs[fr.callno], AST_STATE_RING, iaxs[fr.callno]->peerformat)))
|
||||
iax_destroy_nolock(fr.callno);
|
||||
@@ -4299,7 +4315,7 @@ retryowner:
|
||||
return 1;
|
||||
}
|
||||
/* Common things */
|
||||
snprintf(src, sizeof(src), "IAX/%s/%d", inet_ntoa(sin.sin_addr),fr.callno); f.src = src;
|
||||
snprintf(src, sizeof(src), "IAX/%s/%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr),fr.callno); f.src = src;
|
||||
f.mallocd = 0;
|
||||
f.offset = 0;
|
||||
fr.f = &f;
|
||||
@@ -5384,6 +5400,7 @@ int load_module(void)
|
||||
int x;
|
||||
struct iax_registry *reg;
|
||||
struct iax_peer *peer;
|
||||
char iabuf[80];
|
||||
|
||||
struct sockaddr_in sin;
|
||||
|
||||
@@ -5434,7 +5451,7 @@ int load_module(void)
|
||||
return -1;
|
||||
}
|
||||
if (bind(netsocket,(struct sockaddr *)&sin, sizeof(sin))) {
|
||||
ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), strerror(errno));
|
||||
close(netsocket);
|
||||
netsocket = -1;
|
||||
return -1;
|
||||
@@ -5464,7 +5481,7 @@ int load_module(void)
|
||||
if (!res) {
|
||||
res = start_network_thread();
|
||||
if (option_verbose > 1)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "IAX Ready and Listening on %s port %d\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "IAX Ready and Listening on %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
|
||||
} else {
|
||||
ast_log(LOG_ERROR, "Unable to start network thread\n");
|
||||
close(netsocket);
|
||||
|
@@ -627,6 +627,7 @@ static int iax2_getpeername(struct sockaddr_in sin, char *host, int len, int loc
|
||||
static struct chan_iax2_pvt *new_iax(struct sockaddr_in *sin, int lockpeer)
|
||||
{
|
||||
struct chan_iax2_pvt *tmp;
|
||||
char iabuf[80];
|
||||
tmp = malloc(sizeof(struct chan_iax2_pvt));
|
||||
if (tmp) {
|
||||
memset(tmp, 0, sizeof(struct chan_iax2_pvt));
|
||||
@@ -642,7 +643,7 @@ static struct chan_iax2_pvt *new_iax(struct sockaddr_in *sin, int lockpeer)
|
||||
/* strncpy(tmp->context, context, sizeof(tmp->context)-1); */
|
||||
strncpy(tmp->exten, "s", sizeof(tmp->exten)-1);
|
||||
if (!iax2_getpeername(*sin, tmp->host, sizeof(tmp->host), lockpeer))
|
||||
snprintf(tmp->host, sizeof(tmp->host), "%s:%d", inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
|
||||
snprintf(tmp->host, sizeof(tmp->host), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
@@ -1164,7 +1165,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", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_WARNING, "Receive error from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
else
|
||||
ast_log(LOG_WARNING, "No address detected??\n");
|
||||
} else {
|
||||
@@ -1192,9 +1193,10 @@ static int transmit_trunk(struct iax_frame *f, struct sockaddr_in *sin)
|
||||
static int send_packet(struct iax_frame *f)
|
||||
{
|
||||
int res;
|
||||
char iabuf[80];
|
||||
/* Called with iaxsl held */
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, f->callno, iaxs[f->callno]->peercallno, inet_ntoa(iaxs[f->callno]->addr.sin_addr), ntohs(iaxs[f->callno]->addr.sin_port));
|
||||
ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, f->callno, iaxs[f->callno]->peercallno, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[f->callno]->addr.sin_addr), ntohs(iaxs[f->callno]->addr.sin_port));
|
||||
/* Don't send if there was an error, but return error instead */
|
||||
if (!f->callno) {
|
||||
ast_log(LOG_WARNING, "Call number = %d\n", f->callno);
|
||||
@@ -1382,6 +1384,7 @@ static int attempt_transmit(void *data)
|
||||
struct iax_frame *f = data;
|
||||
int freeme=0;
|
||||
int callno = f->callno;
|
||||
char iabuf[80];
|
||||
/* Make sure this call is still active */
|
||||
if (callno)
|
||||
ast_mutex_lock(&iaxsl[callno]);
|
||||
@@ -1398,7 +1401,7 @@ static int attempt_transmit(void *data)
|
||||
iax2_destroy_nolock(f->callno);
|
||||
} else {
|
||||
if (iaxs[f->callno]->owner)
|
||||
ast_log(LOG_WARNING, "Max retries exceeded to host %s on %s (type = %d, subclass = %d, ts=%d, seqno=%d)\n", inet_ntoa(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(iabuf, sizeof(iabuf), iaxs[f->callno]->addr.sin_addr),iaxs[f->callno]->owner->name , f->af.frametype, f->af.subclass, f->ts, f->oseqno);
|
||||
iaxs[f->callno]->error = ETIMEDOUT;
|
||||
if (iaxs[f->callno]->owner) {
|
||||
struct ast_frame fr = { 0, };
|
||||
@@ -1827,7 +1830,7 @@ static void mysql_update_peer(char *peer, struct sockaddr_in *sin)
|
||||
time(&nowtime);
|
||||
mysql_real_escape_string(mysql, name, peer, strlen(peer));
|
||||
snprintf(query, sizeof(query), "UPDATE iaxfriends SET ipaddr=\"%s\", port=\"%d\", regseconds=\"%ld\" WHERE name=\"%s\"",
|
||||
inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), nowtime, name);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), nowtime, name);
|
||||
ast_mutex_lock(&mysqllock);
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
ast_log(LOG_WARNING, "Unable to update database\n");
|
||||
@@ -2743,6 +2746,7 @@ static unsigned int calc_rxstamp(struct chan_iax2_pvt *p)
|
||||
static struct iax2_trunk_peer *find_tpeer(struct sockaddr_in *sin)
|
||||
{
|
||||
struct iax2_trunk_peer *tpeer;
|
||||
char iabuf[80];
|
||||
/* Finds and locks trunk peer */
|
||||
ast_mutex_lock(&tpeerlock);
|
||||
tpeer = tpeers;
|
||||
@@ -2765,7 +2769,7 @@ static struct iax2_trunk_peer *find_tpeer(struct sockaddr_in *sin)
|
||||
ast_mutex_lock(&tpeer->lock);
|
||||
tpeer->next = tpeers;
|
||||
tpeers = tpeer;
|
||||
ast_log(LOG_DEBUG, "Created trunk peer for '%s:%d'\n", inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
|
||||
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_mutex_unlock(&tpeerlock);
|
||||
@@ -2777,6 +2781,7 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct ast_frame *f)
|
||||
struct iax2_trunk_peer *tpeer;
|
||||
void *tmp, *ptr;
|
||||
struct ast_iax2_meta_trunk_entry *met;
|
||||
char iabuf[80];
|
||||
tpeer = find_tpeer(&pvt->addr);
|
||||
if (tpeer) {
|
||||
if (tpeer->trunkdatalen + f->datalen + 4 >= tpeer->trunkdataalloc) {
|
||||
@@ -2786,14 +2791,14 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct ast_frame *f)
|
||||
if (tmp) {
|
||||
tpeer->trunkdataalloc += DEFAULT_TRUNKDATA;
|
||||
tpeer->trunkdata = tmp;
|
||||
ast_log(LOG_DEBUG, "Expanded trunk '%s:%d' to %d bytes\n", inet_ntoa(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(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Insufficient memory to expand trunk data to %s:%d\n", inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
|
||||
ast_log(LOG_WARNING, "Insufficient memory to expand trunk data to %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
|
||||
ast_mutex_unlock(&tpeer->lock);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Maximum trunk data space exceeded to %s:%d\n", inet_ntoa(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(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
|
||||
ast_mutex_unlock(&tpeer->lock);
|
||||
return -1;
|
||||
}
|
||||
@@ -2994,6 +2999,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
|
||||
#define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %-10s\n"
|
||||
struct iax2_peer *peer;
|
||||
char name[256] = "";
|
||||
char iabuf[80];
|
||||
int registeredonly=0;
|
||||
if ((argc != 3) && (argc != 4) && (argc != 5))
|
||||
return RESULT_SHOWUSAGE;
|
||||
@@ -3027,10 +3033,10 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
|
||||
strcpy(status, "UNKNOWN");
|
||||
} else
|
||||
strcpy(status, "Unmonitored");
|
||||
strncpy(nm, inet_ntoa(peer->mask), sizeof(nm)-1);
|
||||
strncpy(nm, ast_inet_ntoa(iabuf, sizeof(iabuf), peer->mask), sizeof(nm)-1);
|
||||
|
||||
sprintf(srch, FORMAT, name,
|
||||
peer->addr.sin_addr.s_addr ? inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->dynamic ? "(D)" : "(S)",
|
||||
nm,
|
||||
ntohs(peer->addr.sin_port), peer->trunk ? "(T)" : " ", status);
|
||||
@@ -3049,7 +3055,7 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
|
||||
|
||||
if (print_line) {
|
||||
ast_cli(fd, FORMAT, name,
|
||||
peer->addr.sin_addr.s_addr ? inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->dynamic ? "(D)" : "(S)",
|
||||
nm,
|
||||
ntohs(peer->addr.sin_port), peer->trunk ? "(T)" : " ", status);
|
||||
@@ -3121,14 +3127,15 @@ static int iax2_show_registry(int fd, int argc, char *argv[])
|
||||
struct iax2_registry *reg;
|
||||
char host[80];
|
||||
char perceived[80];
|
||||
char iabuf[80];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_mutex_lock(&peerl.lock);
|
||||
ast_cli(fd, FORMAT2, "Host", "Username", "Perceived", "Refresh", "State");
|
||||
for (reg = registrations;reg;reg = reg->next) {
|
||||
snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
|
||||
snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->addr.sin_addr), ntohs(reg->addr.sin_port));
|
||||
if (reg->us.sin_addr.s_addr)
|
||||
snprintf(perceived, sizeof(perceived), "%s:%d", inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
|
||||
snprintf(perceived, sizeof(perceived), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->us.sin_addr), ntohs(reg->us.sin_port));
|
||||
else
|
||||
strcpy(perceived, "<Unregistered>");
|
||||
ast_cli(fd, FORMAT, host,
|
||||
@@ -3146,13 +3153,14 @@ static int iax2_show_channels(int fd, int argc, char *argv[])
|
||||
#define FORMAT "%-15.15s %-10.10s %5.5d/%5.5d %5.5d/%5.5d %-5.5dms %-4.4dms %-6.6s\n"
|
||||
int x;
|
||||
int numchans = 0;
|
||||
char iabuf[80];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_cli(fd, FORMAT2, "Peer", "Username", "ID (Lo/Rem)", "Seq (Tx/Rx)", "Lag", "Jitter", "Format");
|
||||
for (x=0;x<IAX_MAX_CALLS;x++) {
|
||||
ast_mutex_lock(&iaxsl[x]);
|
||||
if (iaxs[x]) {
|
||||
ast_cli(fd, FORMAT, inet_ntoa(iaxs[x]->addr.sin_addr),
|
||||
ast_cli(fd, FORMAT, ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[x]->addr.sin_addr),
|
||||
!ast_strlen_zero(iaxs[x]->username) ? iaxs[x]->username : "(None)",
|
||||
iaxs[x]->callno, iaxs[x]->peercallno,
|
||||
iaxs[x]->oseqno, iaxs[x]->iseqno,
|
||||
@@ -3354,6 +3362,8 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
|
||||
struct iax2_user *user, *best = NULL;
|
||||
int bestscore = 0;
|
||||
int gotcapability=0;
|
||||
char iabuf[80];
|
||||
|
||||
if (!iaxs[callno])
|
||||
return res;
|
||||
if (ies->called_number)
|
||||
@@ -3389,7 +3399,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",
|
||||
inet_ntoa(sin->sin_addr), version);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), version);
|
||||
return res;
|
||||
}
|
||||
ast_mutex_lock(&userl.lock);
|
||||
@@ -3496,6 +3506,7 @@ 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)
|
||||
{
|
||||
struct ast_iax2_full_hdr fh;
|
||||
char iabuf[80];
|
||||
fh.scallno = htons(src | IAX_FLAG_FULL);
|
||||
fh.dcallno = htons(dst);
|
||||
fh.ts = 0;
|
||||
@@ -3507,7 +3518,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",
|
||||
inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), src, dst);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), src, dst);
|
||||
return sendto(netsocket, &fh, sizeof(fh), 0, (struct sockaddr *)sin, sizeof(*sin));
|
||||
}
|
||||
|
||||
@@ -3584,6 +3595,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
|
||||
char md5secret[256] = "";
|
||||
char rsasecret[256] = "";
|
||||
char secret[256] = "";
|
||||
char iabuf[80];
|
||||
struct iax2_peer *p;
|
||||
struct ast_key *key;
|
||||
char *keyn;
|
||||
@@ -3604,7 +3616,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", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "Empty registration from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -3620,13 +3632,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, inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "No registration for peer '%s' (from %s)\n", peer, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!p->dynamic) {
|
||||
if (authdebug)
|
||||
ast_log(LOG_NOTICE, "Peer '%s' is not dynamic (from %s)\n", peer, inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "Peer '%s' is not dynamic (from %s)\n", peer, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
if (p->temponly)
|
||||
free(p);
|
||||
return -1;
|
||||
@@ -3634,7 +3646,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", inet_ntoa(sin->sin_addr), p->name);
|
||||
ast_log(LOG_NOTICE, "Host %s denied access to register peer '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), p->name);
|
||||
if (p->temponly)
|
||||
free(p);
|
||||
return -1;
|
||||
@@ -3676,7 +3688,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", inet_ntoa(sin->sin_addr), p->name);
|
||||
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);
|
||||
if (p->temponly)
|
||||
free(p);
|
||||
return -1;
|
||||
@@ -3693,7 +3705,7 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
|
||||
sprintf(requeststr + (x << 1), "%2.2x", digest[x]);
|
||||
if (strcasecmp(requeststr, md5secret)) {
|
||||
if (authdebug)
|
||||
ast_log(LOG_NOTICE, "Host %s failed MD5 authentication for '%s' (%s != %s)\n", inet_ntoa(sin->sin_addr), p->name, requeststr, md5secret);
|
||||
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);
|
||||
if (p->temponly)
|
||||
free(p);
|
||||
return -1;
|
||||
@@ -3720,12 +3732,13 @@ static int authenticate(char *challenge, char *secret, char *keyn, int authmetho
|
||||
{
|
||||
int res = -1;
|
||||
int x;
|
||||
char iabuf[80];
|
||||
if (keyn && !ast_strlen_zero(keyn)) {
|
||||
if (!(authmethods & IAX_AUTH_RSA)) {
|
||||
if (!secret || 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", inet_ntoa(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(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
} else if (ast_strlen_zero(challenge)) {
|
||||
ast_log(LOG_NOTICE, "No challenge provided for RSA authentication to %s\n", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "No challenge provided for RSA authentication to %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
} else {
|
||||
char sig[256];
|
||||
struct ast_key *key;
|
||||
@@ -3762,7 +3775,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", inet_ntoa(sin->sin_addr), authmethods);
|
||||
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);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -3966,6 +3979,7 @@ 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[80];
|
||||
int oldmsgs;
|
||||
|
||||
memset(&us, 0, sizeof(us));
|
||||
@@ -3986,7 +4000,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", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_WARNING, "Received unsolicited registry ack from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return -1;
|
||||
}
|
||||
memcpy(®->us, &us, sizeof(reg->us));
|
||||
@@ -4007,8 +4021,8 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c
|
||||
snprintf(msgstatus, sizeof(msgstatus), " with 1 message waiting\n");
|
||||
else if (reg->messages > -1)
|
||||
snprintf(msgstatus, sizeof(msgstatus), " with no messages waiting\n");
|
||||
snprintf(ourip, sizeof(ourip), "%s:%d", inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Registered to '%s', who sees us as %s%s\n", inet_ntoa(sin->sin_addr), ourip, msgstatus);
|
||||
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 to '%s', who sees us as %s%s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ourip, msgstatus);
|
||||
}
|
||||
reg->regstate = REG_STATE_REGISTERED;
|
||||
return 0;
|
||||
@@ -4092,6 +4106,7 @@ static void reg_source_db(struct iax2_peer *p)
|
||||
{
|
||||
char data[80];
|
||||
struct in_addr in;
|
||||
char iabuf[80];
|
||||
char *c, *d;
|
||||
if (!ast_db_get("IAX/Registry", p->name, data, sizeof(data))) {
|
||||
c = strchr(data, ':');
|
||||
@@ -4105,7 +4120,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,
|
||||
inet_ntoa(in), atoi(c), atoi(d));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), in), atoi(c), atoi(d));
|
||||
iax2_poke_peer(p, 0);
|
||||
p->expirey = atoi(d);
|
||||
memset(&p->addr, 0, sizeof(p->addr));
|
||||
@@ -4131,6 +4146,7 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
|
||||
struct iax2_peer *p;
|
||||
int msgcount;
|
||||
char data[80];
|
||||
char iabuf[80];
|
||||
int version;
|
||||
memset(&ied, 0, sizeof(ied));
|
||||
for (p = peerl.peers;p;p = p->next) {
|
||||
@@ -4150,12 +4166,12 @@ static int update_registry(char *name, struct sockaddr_in *sin, int callno, char
|
||||
if (inaddrcmp(&p->addr, sin)) {
|
||||
if (iax2_regfunk)
|
||||
iax2_regfunk(p->name, 1);
|
||||
snprintf(data, sizeof(data), "%s:%d:%d", inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), p->expirey);
|
||||
snprintf(data, sizeof(data), "%s:%d:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), p->expirey);
|
||||
ast_db_put("IAX/Registry", p->name, data);
|
||||
if (sin->sin_addr.s_addr) {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Registered '%s' (%s) at %s:%d\n", p->name,
|
||||
iaxs[callno]->state & IAX_STATE_AUTHENTICATED ? "AUTHENTICATED" : "UNAUTHENTICATED", inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
|
||||
iaxs[callno]->state & IAX_STATE_AUTHENTICATED ? "AUTHENTICATED" : "UNAUTHENTICATED", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
|
||||
} else {
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Unregistered '%s' (%s)\n", p->name,
|
||||
@@ -4244,6 +4260,7 @@ 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[80];
|
||||
char challenge[256] = "";
|
||||
int res;
|
||||
int authmethods = 0;
|
||||
@@ -4256,7 +4273,7 @@ static int registry_rerequest(struct iax_ies *ies, int callno, struct sockaddr_i
|
||||
memset(&ied, 0, sizeof(ied));
|
||||
reg = iaxs[callno]->reg;
|
||||
if (inaddrcmp(®->addr, sin)) {
|
||||
ast_log(LOG_WARNING, "Received unsolicited registry authenticate request from '%s'\n", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_WARNING, "Received unsolicited registry authenticate request from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return -1;
|
||||
}
|
||||
if (ast_strlen_zero(reg->secret)) {
|
||||
@@ -4450,6 +4467,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
|
||||
{
|
||||
char buf[1024];
|
||||
int res;
|
||||
char iabuf[80];
|
||||
struct iax2_trunk_peer *tpeer, *prev = NULL, *drop=NULL;
|
||||
int processed = 0;
|
||||
int totalcalls = 0;
|
||||
@@ -4496,7 +4514,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
|
||||
} else {
|
||||
res = send_trunk(tpeer, &now);
|
||||
if (iaxtrunkdebug)
|
||||
ast_verbose("Processed trunk peer (%s:%d) with %d call(s)\n", inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), res);
|
||||
ast_verbose("Processed trunk peer (%s:%d) with %d call(s)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), res);
|
||||
}
|
||||
totalcalls += res;
|
||||
res = 0;
|
||||
@@ -4509,7 +4527,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", inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
|
||||
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));
|
||||
free(drop->trunkdata);
|
||||
ast_mutex_unlock(&drop->lock);
|
||||
ast_mutex_destroy(&drop->lock);
|
||||
@@ -4688,6 +4706,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
|
||||
char dblbuf[4096]; /* Declaration of dblbuf must immediately *preceed* fr on the stack */
|
||||
struct iax_frame fr;
|
||||
struct iax_frame *cur;
|
||||
char iabuf[80];
|
||||
struct ast_frame f;
|
||||
struct ast_channel *c;
|
||||
struct iax2_dpcache *dp;
|
||||
@@ -4734,7 +4753,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
|
||||
ptr = mth->data;
|
||||
tpeer = find_tpeer(&sin);
|
||||
if (!tpeer) {
|
||||
ast_log(LOG_WARNING, "Unable to accept trunked packet from '%s:%d': No matching peer\n", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
|
||||
return 1;
|
||||
}
|
||||
if (!ts || (!tpeer->rxtrunktime.tv_sec && !tpeer->rxtrunktime.tv_usec)) {
|
||||
@@ -4974,7 +4993,7 @@ static int socket_read(int *id, int fd, short events, void *cbdata)
|
||||
if (f.datalen) {
|
||||
if (f.frametype == AST_FRAME_IAX) {
|
||||
if (iax_parse_ies(&ies, buf + sizeof(struct ast_iax2_full_hdr), f.datalen)) {
|
||||
ast_log(LOG_WARNING, "Undecodable frame received from '%s'\n", inet_ntoa(sin.sin_addr));
|
||||
ast_log(LOG_WARNING, "Undecodable frame received from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
|
||||
ast_mutex_unlock(&iaxsl[fr.callno]);
|
||||
return 1;
|
||||
}
|
||||
@@ -5084,7 +5103,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\n", inet_ntoa(sin.sin_addr));
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
|
||||
break;
|
||||
}
|
||||
/* If we're in trunk mode, do it now, and update the trunk number in our frame before continuing */
|
||||
@@ -5104,7 +5123,7 @@ retryowner:
|
||||
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "No such context/extension");
|
||||
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", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->exten, iaxs[fr.callno]->context);
|
||||
} else {
|
||||
/* Select an appropriate format */
|
||||
format = iaxs[fr.callno]->peerformat & iaxs[fr.callno]->capability;
|
||||
@@ -5115,7 +5134,7 @@ retryowner:
|
||||
iax_ie_append_str(&ied0, IAX_IE_CAUSE, "Unable to negotiate codec");
|
||||
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", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iaxs[fr.callno]->capability);
|
||||
} else {
|
||||
/* Pick one... */
|
||||
format = ast_best_codec(iaxs[fr.callno]->peercapability & iaxs[fr.callno]->capability);
|
||||
@@ -5125,7 +5144,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", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->peercapability, iaxs[fr.callno]->capability);
|
||||
iaxs[fr.callno]->alreadygone = 1;
|
||||
break;
|
||||
}
|
||||
@@ -5140,14 +5159,14 @@ retryowner:
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepting unauthenticated call from %s, requested format = %d, actual format = %d\n",
|
||||
inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat,format);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat,format);
|
||||
if(!(c = ast_iax2_new(fr.callno, AST_STATE_RING, format)))
|
||||
iax2_destroy_nolock(fr.callno);
|
||||
} else {
|
||||
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", inet_ntoa(sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepted unauthenticated TBD call from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5179,7 +5198,7 @@ retryowner:
|
||||
case IAX_COMMAND_REJECT:
|
||||
if (iaxs[fr.callno]->owner) {
|
||||
if (authdebug)
|
||||
ast_log(LOG_WARNING, "Call rejected by %s: %s\n", inet_ntoa(iaxs[fr.callno]->addr.sin_addr), ies.cause ? ies.cause : "<Unknown>");
|
||||
ast_log(LOG_WARNING, "Call rejected by %s: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr.callno]->addr.sin_addr), ies.cause ? ies.cause : "<Unknown>");
|
||||
}
|
||||
ast_log(LOG_DEBUG, "Immediately destroying %d, having received reject\n", fr.callno);
|
||||
/* Send ack immediately, before we destroy */
|
||||
@@ -5218,13 +5237,13 @@ 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", inet_ntoa(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(iabuf, sizeof(iabuf), 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");
|
||||
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", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat, iaxs[fr.callno]->capability);
|
||||
} else {
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if (iaxs[fr.callno]->owner) {
|
||||
@@ -5337,7 +5356,7 @@ retryowner2:
|
||||
iaxs[fr.callno]->lag = ts - fr.ts;
|
||||
if (option_debug)
|
||||
ast_log(LOG_DEBUG, "Peer %s lag measured as %dms\n",
|
||||
inet_ntoa(iaxs[fr.callno]->addr.sin_addr), iaxs[fr.callno]->lag);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr.callno]->addr.sin_addr), iaxs[fr.callno]->lag);
|
||||
}
|
||||
#ifdef BRIDGE_OPTIMIZATION
|
||||
}
|
||||
@@ -5351,7 +5370,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>", inet_ntoa(iaxs[fr.callno]->addr.sin_addr));
|
||||
ies.username ? ies.username : "<unknown>", ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[fr.callno]->addr.sin_addr));
|
||||
}
|
||||
break;
|
||||
case IAX_COMMAND_AUTHREP:
|
||||
@@ -5365,7 +5384,7 @@ retryowner2:
|
||||
}
|
||||
if (authenticate_verify(iaxs[fr.callno], &ies)) {
|
||||
if (authdebug)
|
||||
ast_log(LOG_NOTICE, "Host %s failed to authenticate as %s\n", inet_ntoa(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(iabuf, sizeof(iabuf), iaxs[fr.callno]->addr.sin_addr), iaxs[fr.callno]->username);
|
||||
memset(&ied0, 0, sizeof(ied0));
|
||||
auth_fail(fr.callno, IAX_COMMAND_REJECT);
|
||||
break;
|
||||
@@ -5377,7 +5396,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", inet_ntoa(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(iabuf, sizeof(iabuf), 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");
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
|
||||
@@ -5389,7 +5408,7 @@ retryowner2:
|
||||
format = iaxs[fr.callno]->peercapability & iaxs[fr.callno]->capability;
|
||||
if (!format) {
|
||||
if (authdebug)
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", inet_ntoa(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(iabuf, sizeof(iabuf), 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");
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
|
||||
@@ -5399,7 +5418,7 @@ retryowner2:
|
||||
if (!format) {
|
||||
ast_log(LOG_ERROR, "No best format in 0x%x???\n", iaxs[fr.callno]->peercapability & iaxs[fr.callno]->capability);
|
||||
if (authdebug)
|
||||
ast_log(LOG_NOTICE, "Rejected connect attempt from %s, requested/capability 0x%x/0x%x incompatible with our capability 0x%x.\n", inet_ntoa(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(iabuf, sizeof(iabuf), 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");
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
|
||||
@@ -5415,7 +5434,7 @@ retryowner2:
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepting AUTHENTICATED call from %s, requested format = %d, actual format = %d\n",
|
||||
inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat,format);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), iaxs[fr.callno]->peerformat,format);
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if(!(c = ast_iax2_new(fr.callno, AST_STATE_RING, format)))
|
||||
iax2_destroy_nolock(fr.callno);
|
||||
@@ -5423,7 +5442,7 @@ retryowner2:
|
||||
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", inet_ntoa(sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepted AUTHENTICATED TBD call from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5434,14 +5453,14 @@ retryowner2:
|
||||
strncpy(iaxs[fr.callno]->exten, ies.called_number ? ies.called_number : "s", sizeof(iaxs[fr.callno]->exten)-1);
|
||||
if (!ast_exists_extension(NULL, iaxs[fr.callno]->context, iaxs[fr.callno]->exten, 1, iaxs[fr.callno]->callerid)) {
|
||||
if (authdebug)
|
||||
ast_log(LOG_NOTICE, "Rejected dial attempt from %s, request '%s@%s' does not exist\n", inet_ntoa(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(iabuf, sizeof(iabuf), 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");
|
||||
send_command_final(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_REJECT, 0, ied0.buf, ied0.pos, -1);
|
||||
} else {
|
||||
iaxs[fr.callno]->state |= IAX_STATE_STARTED;
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Accepting DIAL from %s, formats = 0x%x\n", inet_ntoa(sin.sin_addr), iaxs[fr.callno]->peerformat);
|
||||
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);
|
||||
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)))
|
||||
@@ -6929,6 +6948,7 @@ int load_module(void)
|
||||
char *config = "iax.conf";
|
||||
int res = 0;
|
||||
int x;
|
||||
char iabuf[80];
|
||||
struct iax2_registry *reg;
|
||||
struct iax2_peer *peer;
|
||||
|
||||
@@ -7006,7 +7026,7 @@ int load_module(void)
|
||||
return -1;
|
||||
}
|
||||
if (bind(netsocket,(struct sockaddr *)&sin, sizeof(sin))) {
|
||||
ast_log(LOG_ERROR, "Unable to bind to %s port %d: %s\n", inet_ntoa(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(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -7019,7 +7039,7 @@ int load_module(void)
|
||||
if (!res) {
|
||||
res = start_network_thread();
|
||||
if (option_verbose > 1)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "IAX Ready and Listening on %s port %d\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "IAX Ready and Listening on %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
|
||||
} else {
|
||||
ast_log(LOG_ERROR, "Unable to start network thread\n");
|
||||
close(netsocket);
|
||||
|
@@ -491,8 +491,9 @@ static int resend_response(struct mgcp_subchannel *sub, struct mgcp_response *re
|
||||
{
|
||||
struct mgcp_endpoint *p = sub->parent;
|
||||
int res;
|
||||
char iabuf[80];
|
||||
if (mgcpdebug) {
|
||||
ast_verbose("Retransmitting:\n%s\n to %s:%d\n", resp->buf, inet_ntoa(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(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
|
||||
}
|
||||
res = __mgcp_xmit(p->parent, resp->buf, resp->len);
|
||||
if (res > 0)
|
||||
@@ -504,8 +505,9 @@ static int send_response(struct mgcp_subchannel *sub, struct mgcp_request *req)
|
||||
{
|
||||
struct mgcp_endpoint *p = sub->parent;
|
||||
int res;
|
||||
char iabuf[80];
|
||||
if (mgcpdebug) {
|
||||
ast_verbose("Transmitting:\n%s\n to %s:%d\n", req->data, inet_ntoa(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(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
|
||||
}
|
||||
res = __mgcp_xmit(p->parent, req->data, req->len);
|
||||
if (res > 0)
|
||||
@@ -698,6 +700,7 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
|
||||
{
|
||||
int res = 0;
|
||||
struct mgcp_request **queue, *q, *r, *t;
|
||||
char iabuf[80];
|
||||
ast_mutex_t *l;
|
||||
|
||||
switch (req->cmd) {
|
||||
@@ -746,7 +749,7 @@ 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,
|
||||
inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
|
||||
}
|
||||
|
||||
res = mgcp_postrequest(p, sub, req->data, req->len, seqno);
|
||||
@@ -754,7 +757,7 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
|
||||
else {
|
||||
if (mgcpdebug) {
|
||||
ast_verbose("Queueing Request:\n%s to %s:%d\n", req->data,
|
||||
inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -934,13 +937,14 @@ static int mgcp_show_endpoints(int fd, int argc, char *argv[])
|
||||
struct mgcp_gateway *g;
|
||||
struct mgcp_endpoint *e;
|
||||
int hasendpoints = 0;
|
||||
char iabuf[80];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_mutex_lock(&gatelock);
|
||||
g = gateways;
|
||||
while(g) {
|
||||
e = g->endpoints;
|
||||
ast_cli(fd, "Gateway '%s' at %s (%s)\n", g->name, g->addr.sin_addr.s_addr ? inet_ntoa(g->addr.sin_addr) : inet_ntoa(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(iabuf, sizeof(iabuf), g->addr.sin_addr) : ast_inet_ntoa(iabuf, sizeof(iabuf), g->defaddr.sin_addr), g->dynamic ? "Dynamic" : "Static");
|
||||
while(e) {
|
||||
// JS: Don't show wilcard endpoint
|
||||
if (strcmp(e->name, g->wcardep) !=0)
|
||||
@@ -1358,43 +1362,12 @@ static char *get_csv(char *c, int *len, char **next)
|
||||
return s;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int rtpready(struct ast_rtp *rtp, struct ast_frame *f, void *data)
|
||||
{
|
||||
/* Just deliver the audio directly */
|
||||
struct mgcp_endpoint *p = data;
|
||||
ast_mutex_lock(&p->lock);
|
||||
if (p->owner) {
|
||||
/* Generally, you lock in the order channel lock, followed by private
|
||||
lock. Since here we are doing the reverse, there is the possibility
|
||||
of deadlock. As a result, in the case of a deadlock, we simply fail out
|
||||
here. */
|
||||
if (!ast_mutex_trylock(&p->owner->lock)) {
|
||||
if (f->frametype == AST_FRAME_VOICE) {
|
||||
if (f->subclass != p->owner->nativeformats) {
|
||||
ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
|
||||
p->owner->nativeformats = f->subclass;
|
||||
ast_set_read_format(p->owner, p->owner->readformat);
|
||||
ast_set_write_format(p->owner, p->owner->writeformat);
|
||||
}
|
||||
if (p->dtmfinband) {
|
||||
f = ast_dsp_process(p->owner,p->dsp,f);
|
||||
}
|
||||
}
|
||||
ast_queue_frame(p->owner, f);
|
||||
ast_mutex_unlock(&p->owner->lock);
|
||||
}
|
||||
}
|
||||
ast_mutex_unlock(&p->lock);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct mgcp_subchannel *find_subchannel(char *name, int msgid, struct sockaddr_in *sin)
|
||||
{
|
||||
struct mgcp_endpoint *p = NULL;
|
||||
struct mgcp_subchannel *sub = NULL;
|
||||
struct mgcp_gateway *g;
|
||||
char iabuf[80];
|
||||
char tmp[256] = "";
|
||||
char *at = NULL, *c;
|
||||
int found = 0;
|
||||
@@ -1427,7 +1400,7 @@ static struct mgcp_subchannel *find_subchannel(char *name, int msgid, struct soc
|
||||
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, inet_ntoa(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(iabuf, sizeof(iabuf), g->addr.sin_addr), ntohs(g->addr.sin_port));
|
||||
}
|
||||
}
|
||||
/* SC: not dynamic, check if the name matches */
|
||||
@@ -1648,7 +1621,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", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
printf("Peer RTP is at port %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), 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);
|
||||
@@ -1827,6 +1800,7 @@ static int add_sdp(struct mgcp_request *resp, struct mgcp_subchannel *sub, struc
|
||||
char t[256];
|
||||
char m[256];
|
||||
char a[1024] = "";
|
||||
char iabuf[80];
|
||||
int x;
|
||||
struct sockaddr_in dest;
|
||||
struct mgcp_endpoint *p = sub->parent;
|
||||
@@ -1852,12 +1826,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", inet_ntoa(p->parent->ourip), ntohs(sin.sin_port));
|
||||
ast_verbose("We're at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), 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(), inet_ntoa(dest.sin_addr));
|
||||
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(s, sizeof(s), "s=session\r\n");
|
||||
snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", inet_ntoa(dest.sin_addr));
|
||||
snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), 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) {
|
||||
@@ -2195,6 +2169,7 @@ 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[80];
|
||||
|
||||
ast_mutex_lock(l);
|
||||
for (prev = NULL, req = *queue; req; prev = req, req = req->next) {
|
||||
@@ -2209,7 +2184,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,
|
||||
inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
|
||||
}
|
||||
|
||||
mgcp_postrequest(p, sub, (*queue)->data, (*queue)->len, (*queue)->trid);
|
||||
@@ -2823,6 +2798,7 @@ 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[80];
|
||||
int res;
|
||||
if (mgcpdebug) {
|
||||
ast_verbose("Handling request '%s' on %s@%s\n", req->verb, p->name, p->parent->name);
|
||||
@@ -3069,7 +3045,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, inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_WARNING, "Unknown verb '%s' received from %s\n", req->verb, ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
transmit_response(sub, "510", req, "Unknown verb");
|
||||
}
|
||||
return 0;
|
||||
@@ -3116,6 +3092,7 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
|
||||
int len;
|
||||
int result;
|
||||
int ident;
|
||||
char iabuf[80];
|
||||
len = sizeof(sin);
|
||||
memset(&req, 0, sizeof(req));
|
||||
res = recvfrom(mgcpsock, req.data, sizeof(req.data) - 1, 0, (struct sockaddr *)&sin, &len);
|
||||
@@ -3127,7 +3104,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", req.data, inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
ast_verbose("MGCP read: \n%s\nfrom %s:%d", req.data, ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
|
||||
}
|
||||
parse(&req);
|
||||
if (req.headers < 1) {
|
||||
@@ -3135,7 +3112,7 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
|
||||
return 1;
|
||||
}
|
||||
if (!req.identifier || !strlen(req.identifier)) {
|
||||
ast_log(LOG_NOTICE, "Message from %s missing identifier\n", inet_ntoa(sin.sin_addr));
|
||||
ast_log(LOG_NOTICE, "Message from %s missing identifier\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -3884,6 +3861,7 @@ static int reload_config(void)
|
||||
struct ast_variable *v;
|
||||
struct mgcp_gateway *g;
|
||||
struct mgcp_endpoint *e;
|
||||
char iabuf[80];
|
||||
char *cat;
|
||||
struct ast_hostent ahp; struct hostent *hp;
|
||||
int format;
|
||||
@@ -4014,14 +3992,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",
|
||||
inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), 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",
|
||||
inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), 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)))
|
||||
|
@@ -581,12 +581,13 @@ 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[80];
|
||||
if (p->nat == SIP_NAT_ALWAYS)
|
||||
res=sendto(sipsock, data, len, 0, (struct sockaddr *)&p->recv, sizeof(struct sockaddr_in));
|
||||
else
|
||||
res=sendto(sipsock, data, len, 0, (struct sockaddr *)&p->sa, sizeof(struct sockaddr_in));
|
||||
if (res != len) {
|
||||
ast_log(LOG_WARNING, "sip_xmit of %p (len %d) to %s returned %d: %s\n", data, len, inet_ntoa(p->sa.sin_addr), res, strerror(errno));
|
||||
ast_log(LOG_WARNING, "sip_xmit of %p (len %d) to %s returned %d: %s\n", data, len, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), res, strerror(errno));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -607,8 +608,9 @@ static int ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *us)
|
||||
if (localaddr && externip.sin_addr.s_addr &&
|
||||
ast_apply_ha(localaddr, &theirs)) {
|
||||
char t[256];
|
||||
char iabuf[80];
|
||||
memcpy(us, &externip.sin_addr, sizeof(struct in_addr));
|
||||
strcpy(t, inet_ntoa(*(struct in_addr *)&them->s_addr));
|
||||
strcpy(t, 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", t);
|
||||
}
|
||||
else if (bindaddr.sin_addr.s_addr)
|
||||
@@ -655,14 +657,15 @@ static int retrans_pkt(void *data)
|
||||
{
|
||||
struct sip_pkt *pkt=data, *prev, *cur;
|
||||
int res = 0;
|
||||
char iabuf[80];
|
||||
ast_mutex_lock(&pkt->owner->lock);
|
||||
if (pkt->retrans < MAX_RETRANS) {
|
||||
pkt->retrans++;
|
||||
if (sip_debug_test_pvt(pkt->owner)) {
|
||||
if (pkt->owner->nat == SIP_NAT_ALWAYS)
|
||||
ast_verbose("Retransmitting #%d (NAT):\n%s\n to %s:%d\n", pkt->retrans, pkt->data, inet_ntoa(pkt->owner->recv.sin_addr), ntohs(pkt->owner->recv.sin_port));
|
||||
ast_verbose("Retransmitting #%d (NAT):\n%s\n to %s:%d\n", pkt->retrans, pkt->data, ast_inet_ntoa(iabuf, sizeof(iabuf), pkt->owner->recv.sin_addr), ntohs(pkt->owner->recv.sin_port));
|
||||
else
|
||||
ast_verbose("Retransmitting #%d (no NAT):\n%s\n to %s:%d\n", pkt->retrans, pkt->data, inet_ntoa(pkt->owner->sa.sin_addr), ntohs(pkt->owner->sa.sin_port));
|
||||
ast_verbose("Retransmitting #%d (no NAT):\n%s\n to %s:%d\n", pkt->retrans, pkt->data, ast_inet_ntoa(iabuf, sizeof(iabuf), pkt->owner->sa.sin_addr), ntohs(pkt->owner->sa.sin_port));
|
||||
}
|
||||
append_history(pkt->owner, "ReTx", pkt->data);
|
||||
__sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
|
||||
@@ -837,11 +840,12 @@ static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp)
|
||||
static int send_response(struct sip_pvt *p, struct sip_request *req, int reliable, int seqno)
|
||||
{
|
||||
int res;
|
||||
char iabuf[80];
|
||||
if (sip_debug_test_pvt(p)) {
|
||||
if (p->nat == SIP_NAT_ALWAYS)
|
||||
ast_verbose("%sTransmitting (NAT):\n%s\n to %s:%d\n", reliable ? "Reliably " : "", req->data, inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
ast_verbose("%sTransmitting (NAT):\n%s\n to %s:%d\n", reliable ? "Reliably " : "", req->data, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
else
|
||||
ast_verbose("%sTransmitting (no NAT):\n%s\n to %s:%d\n", reliable ? "Reliably " : "", req->data, inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port));
|
||||
ast_verbose("%sTransmitting (no NAT):\n%s\n to %s:%d\n", reliable ? "Reliably " : "", req->data, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port));
|
||||
}
|
||||
if (reliable) {
|
||||
append_history(p, "TxRespRel", req->data);
|
||||
@@ -859,11 +863,12 @@ static int send_response(struct sip_pvt *p, struct sip_request *req, int reliabl
|
||||
static int send_request(struct sip_pvt *p, struct sip_request *req, int reliable, int seqno)
|
||||
{
|
||||
int res;
|
||||
char iabuf[80];
|
||||
if (sip_debug_test_pvt(p)) {
|
||||
if (p->nat == SIP_NAT_ALWAYS)
|
||||
ast_verbose("%sTransmitting:\n%s (NAT) to %s:%d\n", reliable ? "Reliably " : "", req->data, inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
ast_verbose("%sTransmitting:\n%s (NAT) to %s:%d\n", reliable ? "Reliably " : "", req->data, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
else
|
||||
ast_verbose("%sTransmitting:\n%s (no NAT) to %s:%d\n", reliable ? "Reliably " : "", req->data, inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port));
|
||||
ast_verbose("%sTransmitting:\n%s (no NAT) to %s:%d\n", reliable ? "Reliably " : "", req->data, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port));
|
||||
}
|
||||
if (reliable) {
|
||||
append_history(p, "TxReqRel", req->data);
|
||||
@@ -1033,7 +1038,7 @@ static void mysql_update_peer(char *peer, struct sockaddr_in *sin, char *usernam
|
||||
mysql_real_escape_string(mysql, name, peer, strlen(peer));
|
||||
mysql_real_escape_string(mysql, uname, username, strlen(username));
|
||||
snprintf(query, sizeof(query), "UPDATE sipfriends SET ipaddr=\"%s\", port=\"%d\", regseconds=\"%ld\", username=\"%s\" WHERE name=\"%s\"",
|
||||
inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), nowtime + expiry, uname, name);
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port), nowtime + expiry, uname, name);
|
||||
ast_mutex_lock(&mysqllock);
|
||||
if (mysql_real_query(mysql, query, strlen(query)))
|
||||
ast_log(LOG_WARNING, "Unable to update database\n");
|
||||
@@ -1064,7 +1069,7 @@ static struct sip_peer *mysql_peer(char *peer, struct sockaddr_in *sin)
|
||||
mysql_real_escape_string(mysql, name, peer, strlen(peer));
|
||||
}
|
||||
if (sin)
|
||||
snprintf(query, sizeof(query), "SELECT name, secret, context, username, ipaddr, port, regseconds FROM sipfriends WHERE ipaddr=\"%s\" AND port=\"%d\"", inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
|
||||
snprintf(query, sizeof(query), "SELECT name, secret, context, username, ipaddr, port, regseconds FROM sipfriends WHERE ipaddr=\"%s\" AND port=\"%d\"", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
|
||||
else
|
||||
snprintf(query, sizeof(query), "SELECT name, secret, context, username, ipaddr, port, regseconds FROM sipfriends WHERE name=\"%s\"", name);
|
||||
ast_mutex_lock(&mysqllock);
|
||||
@@ -1201,6 +1206,7 @@ static int create_addr(struct sip_pvt *r, char *peer)
|
||||
int found=0;
|
||||
char *port;
|
||||
int portno;
|
||||
char iabuf[80];
|
||||
char host[256], *hostn;
|
||||
|
||||
r->sa.sin_family = AF_INET;
|
||||
@@ -1227,9 +1233,9 @@ static int create_addr(struct sip_pvt *r, char *peer)
|
||||
strncpy(r->tohost, p->tohost, sizeof(r->tohost)-1);
|
||||
if (ast_strlen_zero(r->tohost)) {
|
||||
if (p->addr.sin_addr.s_addr)
|
||||
snprintf(r->tohost, sizeof(r->tohost), inet_ntoa(p->addr.sin_addr));
|
||||
snprintf(r->tohost, sizeof(r->tohost), ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr));
|
||||
else
|
||||
snprintf(r->tohost, sizeof(r->tohost), inet_ntoa(p->defaddr.sin_addr));
|
||||
snprintf(r->tohost, sizeof(r->tohost), ast_inet_ntoa(iabuf, sizeof(iabuf), p->defaddr.sin_addr));
|
||||
}
|
||||
if (!ast_strlen_zero(p->fromdomain))
|
||||
strncpy(r->fromdomain, p->fromdomain, sizeof(r->fromdomain)-1);
|
||||
@@ -2188,6 +2194,7 @@ static void build_callid(char *callid, int len, struct in_addr ourip)
|
||||
int res;
|
||||
int val;
|
||||
int x;
|
||||
char iabuf[80];
|
||||
for (x=0;x<4;x++) {
|
||||
val = rand();
|
||||
res = snprintf(callid, len, "%08x", val);
|
||||
@@ -2195,13 +2202,14 @@ static void build_callid(char *callid, int len, struct in_addr ourip)
|
||||
callid += res;
|
||||
}
|
||||
/* It's not important that we really use our right IP here... */
|
||||
snprintf(callid, len, "@%s", inet_ntoa(ourip));
|
||||
snprintf(callid, len, "@%s", ast_inet_ntoa(iabuf, sizeof(iabuf), ourip));
|
||||
}
|
||||
|
||||
/*--- sip_alloc: Allocate SIP_PVT structure and set defaults ---*/
|
||||
static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useglobalnat)
|
||||
{
|
||||
struct sip_pvt *p;
|
||||
char iabuf[80];
|
||||
|
||||
p = malloc(sizeof(struct sip_pvt));
|
||||
if (!p)
|
||||
@@ -2250,9 +2258,9 @@ static struct sip_pvt *sip_alloc(char *callid, struct sockaddr_in *sin, int useg
|
||||
}
|
||||
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
|
||||
if (p->nat != SIP_NAT_NEVER)
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
else
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
if (!callid)
|
||||
build_callid(p->callid, sizeof(p->callid), p->ourip);
|
||||
else
|
||||
@@ -2292,6 +2300,7 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
|
||||
struct sip_pvt *p;
|
||||
char *callid;
|
||||
char tmp[256] = "";
|
||||
char iabuf[80];
|
||||
char *cmd;
|
||||
char *tag = "", *c;
|
||||
int themisfrom;
|
||||
@@ -2331,7 +2340,7 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
|
||||
}
|
||||
|
||||
if (ast_strlen_zero(callid)) {
|
||||
ast_log(LOG_WARNING, "Call missing call ID from '%s'\n", inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_WARNING, "Call missing call ID from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
return NULL;
|
||||
}
|
||||
ast_mutex_lock(&iflock);
|
||||
@@ -2557,6 +2566,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
|
||||
char *c;
|
||||
char *a;
|
||||
char host[258];
|
||||
char iabuf[80];
|
||||
int len = -1;
|
||||
int portno=0;
|
||||
int vportno=0;
|
||||
@@ -2651,7 +2661,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
|
||||
ast_rtp_set_peer(p->vrtp, &sin);
|
||||
|
||||
if (sipdebug)
|
||||
ast_verbose("Peer RTP is at port %s:%d\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
ast_verbose("Peer RTP is at port %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
|
||||
|
||||
/* Next, scan through each "a=rtpmap:" line, noting each
|
||||
* specified RTP payload type (with corresponding MIME subtype):
|
||||
@@ -2835,6 +2845,7 @@ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, struct s
|
||||
int start = 0;
|
||||
int copied = 0;
|
||||
char new[256];
|
||||
char iabuf[80];
|
||||
for (;;) {
|
||||
tmp = __get_header(orig, field, &start);
|
||||
if (!ast_strlen_zero(tmp)) {
|
||||
@@ -2842,7 +2853,7 @@ static int copy_via_headers(struct sip_pvt *p, struct sip_request *req, struct s
|
||||
/* Whoo hoo! Now we can indicate port address translation too! Just
|
||||
another RFC (RFC3581). I'll leave the original comments in for
|
||||
posterity. */
|
||||
snprintf(new, sizeof(new), "%s;received=%s;rport=%d", tmp, inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
snprintf(new, sizeof(new), "%s;received=%s;rport=%d", tmp, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
add_header(req, field, new);
|
||||
} else {
|
||||
/* Add what we're responding to */
|
||||
@@ -2889,6 +2900,7 @@ 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[80];
|
||||
int port, hn;
|
||||
struct hostent *hp;
|
||||
struct ast_hostent ahp;
|
||||
@@ -2943,7 +2955,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", inet_ntoa(p->sa.sin_addr), port);
|
||||
ast_verbose("set_destination: set destination to %s, port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), port);
|
||||
}
|
||||
|
||||
/*--- init_resp: Initialize SIP response, based on SIP request ---*/
|
||||
@@ -3029,6 +3041,7 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, char *msg, int se
|
||||
char stripped[80] ="";
|
||||
char tmp[80];
|
||||
char newto[256];
|
||||
char iabuf[80];
|
||||
char *c, *n;
|
||||
char *ot, *of;
|
||||
|
||||
@@ -3044,9 +3057,9 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, char *msg, int se
|
||||
if (newbranch) {
|
||||
p->branch ^= rand();
|
||||
if (p->nat != SIP_NAT_NEVER)
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
else /* Some implementations (e.g. Uniden UIP200) can't handle rport being in the message!! */
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
}
|
||||
|
||||
if (!ast_strlen_zero(p->uri)) {
|
||||
@@ -3237,6 +3250,7 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
|
||||
char m2[256] = "";
|
||||
char a[1024] = "";
|
||||
char a2[1024] = "";
|
||||
char iabuf[80];
|
||||
int x;
|
||||
int capability;
|
||||
struct sockaddr_in dest;
|
||||
@@ -3282,14 +3296,14 @@ static int add_sdp(struct sip_request *resp, struct sip_pvt *p)
|
||||
}
|
||||
}
|
||||
if (debug){
|
||||
ast_verbose("We're at %s port %d\n", inet_ntoa(p->ourip), ntohs(sin.sin_port));
|
||||
ast_verbose("We're at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ntohs(sin.sin_port));
|
||||
if (p->vrtp)
|
||||
ast_verbose("Video is at %s port %d\n", inet_ntoa(p->ourip), ntohs(vsin.sin_port));
|
||||
ast_verbose("Video is at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ntohs(vsin.sin_port));
|
||||
}
|
||||
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, inet_ntoa(dest.sin_addr));
|
||||
snprintf(o, sizeof(o), "o=root %d %d IN IP4 %s\r\n", p->sessionid, p->sessionversion, ast_inet_ntoa(iabuf, sizeof(iabuf), dest.sin_addr));
|
||||
snprintf(s, sizeof(s), "s=session\r\n");
|
||||
snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", inet_ntoa(dest.sin_addr));
|
||||
snprintf(c, sizeof(c), "c=IN IP4 %s\r\n", ast_inet_ntoa(iabuf, sizeof(iabuf), 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));
|
||||
snprintf(m2, sizeof(m2), "m=video %d RTP/AVP", ntohs(vdest.sin_port));
|
||||
@@ -3539,11 +3553,12 @@ static void extract_uri(struct sip_pvt *p, struct sip_request *req)
|
||||
/*--- build_contact: Build contact header - the contact header we send out ---*/
|
||||
static void build_contact(struct sip_pvt *p)
|
||||
{
|
||||
char iabuf[80];
|
||||
/* Construct Contact: header */
|
||||
if (ourport != 5060)
|
||||
snprintf(p->our_contact, sizeof(p->our_contact), "<sip:%s@%s:%d>", p->exten, inet_ntoa(p->ourip), ourport);
|
||||
snprintf(p->our_contact, sizeof(p->our_contact), "<sip:%s@%s:%d>", p->exten, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport);
|
||||
else
|
||||
snprintf(p->our_contact, sizeof(p->our_contact), "<sip:%s@%s>", p->exten, inet_ntoa(p->ourip));
|
||||
snprintf(p->our_contact, sizeof(p->our_contact), "<sip:%s@%s>", p->exten, ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip));
|
||||
}
|
||||
|
||||
/*--- initreqprep: Initiate SIP request to peer/user ---*/
|
||||
@@ -3553,6 +3568,7 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, char *cmd, c
|
||||
char from[256];
|
||||
char to[256];
|
||||
char tmp[80];
|
||||
char iabuf[80];
|
||||
char cid[256];
|
||||
char *l = callerid, *n=NULL;
|
||||
|
||||
@@ -3578,9 +3594,9 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, char *cmd, c
|
||||
l = p->fromuser;
|
||||
|
||||
if ((ourport != 5060) && ast_strlen_zero(p->fromdomain))
|
||||
snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? inet_ntoa(p->ourip) : p->fromdomain, ourport, p->tag);
|
||||
snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, ourport, p->tag);
|
||||
else
|
||||
snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? inet_ntoa(p->ourip) : p->fromdomain, p->tag);
|
||||
snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, p->tag);
|
||||
|
||||
if (!ast_strlen_zero(p->username)) {
|
||||
if (ntohs(p->sa.sin_port) != DEFAULT_SIP_PORT) {
|
||||
@@ -3625,14 +3641,15 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, char *cmd, c
|
||||
static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, char *authheader, char *vxml_url, char *distinctive_ring, char *osptoken, int init)
|
||||
{
|
||||
struct sip_request req;
|
||||
char iabuf[80];
|
||||
|
||||
if (init) {
|
||||
/* Bump branch even on initial requests */
|
||||
p->branch ^= rand();
|
||||
if (p->nat != SIP_NAT_NEVER)
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
else /* Work around buggy UNIDEN UIP200 firmware */
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
initreqprep(&req, p, cmd, vxml_url);
|
||||
} else
|
||||
reqprep(&req, p, cmd, 0, 1);
|
||||
@@ -3827,9 +3844,10 @@ static int sip_reg_timeout(void *data)
|
||||
/* if we are here, our registration timed out, so we'll just do it over */
|
||||
struct sip_registry *r=data;
|
||||
struct sip_pvt *p;
|
||||
char iabuf[80];
|
||||
int res;
|
||||
ast_mutex_lock(®l.lock);
|
||||
ast_log(LOG_NOTICE, "Registration for '%s@%s' timed out, trying again\n", r->username, inet_ntoa(r->addr.sin_addr));
|
||||
ast_log(LOG_NOTICE, "Registration for '%s@%s' timed out, trying again\n", r->username, ast_inet_ntoa(iabuf, sizeof(iabuf), r->addr.sin_addr));
|
||||
if (r->call) {
|
||||
/* Unlink us, destroy old call. Locking is not relevent here because all this happens
|
||||
in the single SIP manager thread. */
|
||||
@@ -3854,6 +3872,7 @@ static int transmit_register(struct sip_registry *r, char *cmd, char *auth, char
|
||||
char tmp[80];
|
||||
char via[80];
|
||||
char addr[80];
|
||||
char iabuf[80];
|
||||
struct sip_pvt *p;
|
||||
struct ast_hostent ahp;
|
||||
struct hostent *hp;
|
||||
@@ -3938,9 +3957,9 @@ static int transmit_register(struct sip_registry *r, char *cmd, char *auth, char
|
||||
|
||||
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
|
||||
if (p->nat != SIP_NAT_NEVER)
|
||||
snprintf(via, sizeof(via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(via, sizeof(via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
else /* Work around buggy UNIDEN UIP200 firmware */
|
||||
snprintf(via, sizeof(via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(via, sizeof(via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
add_header(&req, "Via", via);
|
||||
add_header(&req, "From", from);
|
||||
add_header(&req, "To", to);
|
||||
@@ -4074,6 +4093,7 @@ static int sip_poke_peer(struct sip_peer *peer);
|
||||
static void reg_source_db(struct sip_peer *p)
|
||||
{
|
||||
char data[80];
|
||||
char iabuf[80];
|
||||
struct in_addr in;
|
||||
char *c, *d, *u;
|
||||
int expiry;
|
||||
@@ -4094,7 +4114,7 @@ static void reg_source_db(struct sip_peer *p)
|
||||
strncpy(p->username, u, sizeof(p->username));
|
||||
}
|
||||
ast_verbose(VERBOSE_PREFIX_3 "SIP Seeding '%s' at %s@%s:%d for %d\n", p->name,
|
||||
p->username, inet_ntoa(in), atoi(c), atoi(d));
|
||||
p->username, ast_inet_ntoa(iabuf, sizeof(iabuf), in), atoi(c), atoi(d));
|
||||
sip_poke_peer(p);
|
||||
expiry = atoi(d);
|
||||
memset(&p->addr, 0, sizeof(p->addr));
|
||||
@@ -4116,6 +4136,7 @@ static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_req
|
||||
{
|
||||
char contact[80]= "";
|
||||
char data[256];
|
||||
char iabuf[80];
|
||||
char *expires = get_header(req, "Expires");
|
||||
int expiry = atoi(expires);
|
||||
char *c, *n, *pt;
|
||||
@@ -4210,12 +4231,12 @@ static int parse_contact(struct sip_pvt *pvt, struct sip_peer *p, struct sip_req
|
||||
if (!p->temponly)
|
||||
p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p);
|
||||
pvt->expiry = expiry;
|
||||
snprintf(data, sizeof(data), "%s:%d:%d:%s", inet_ntoa(p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username);
|
||||
snprintf(data, sizeof(data), "%s:%d:%d:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username);
|
||||
ast_db_put("SIP/Registry", p->name, data);
|
||||
if (inaddrcmp(&p->addr, &oldsin)) {
|
||||
sip_poke_peer(p);
|
||||
if (option_verbose > 2)
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s port %d expires %d\n", p->name, inet_ntoa(p->addr.sin_addr), ntohs(p->addr.sin_port), expiry);
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Registered SIP '%s' at %s port %d expires %d\n", p->name, ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry);
|
||||
}
|
||||
|
||||
/* Save User agent */
|
||||
@@ -4528,6 +4549,7 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si
|
||||
int res = -1;
|
||||
struct sip_peer *peer;
|
||||
char tmp[256] = "";
|
||||
char iabuf[80];
|
||||
char *name, *c;
|
||||
char *t;
|
||||
/* Terminate URI */
|
||||
@@ -4547,7 +4569,7 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si
|
||||
name = c + 4;
|
||||
} else {
|
||||
name = c;
|
||||
ast_log(LOG_NOTICE, "Invalid to address: '%s' from %s (missing sip:) trying to use anyway...\n", c, inet_ntoa(sin->sin_addr));
|
||||
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));
|
||||
}
|
||||
c = strchr(name, '@');
|
||||
if (c)
|
||||
@@ -4897,6 +4919,7 @@ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
|
||||
static int check_via(struct sip_pvt *p, struct sip_request *req)
|
||||
{
|
||||
char via[256] = "";
|
||||
char iabuf[80];
|
||||
char *c, *pt;
|
||||
struct hostent *hp;
|
||||
struct ast_hostent ahp;
|
||||
@@ -4935,9 +4958,9 @@ static int check_via(struct sip_pvt *p, struct sip_request *req)
|
||||
p->nat = SIP_NAT_ALWAYS;
|
||||
if (sip_debug_test_pvt(p)) {
|
||||
if (p->nat == SIP_NAT_ALWAYS)
|
||||
ast_verbose("Sending to %s : %d (NAT)\n", inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port));
|
||||
ast_verbose("Sending to %s : %d (NAT)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port));
|
||||
else
|
||||
ast_verbose("Sending to %s : %d (non-NAT)\n", inet_ntoa(p->sa.sin_addr), ntohs(p->sa.sin_port));
|
||||
ast_verbose("Sending to %s : %d (non-NAT)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), ntohs(p->sa.sin_port));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -5010,6 +5033,7 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, char *cmd
|
||||
struct sip_peer *peer;
|
||||
char *of, from[256] = "", *c;
|
||||
char *rpid,rpid_num[50];
|
||||
char iabuf[80];
|
||||
int res = 0;
|
||||
char *t;
|
||||
char calleridname[50];
|
||||
@@ -5197,7 +5221,7 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, char *cmd
|
||||
}
|
||||
} else
|
||||
if (debug)
|
||||
ast_verbose("Found no matching peer or user for '%s:%d'\n", inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
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_mutex_unlock(&peerl.lock);
|
||||
|
||||
}
|
||||
@@ -5315,6 +5339,7 @@ static int sip_show_peers(int fd, int argc, char *argv[])
|
||||
#define FORMAT "%-15.15s %-15.15s %s %s %s %-15.15s %-8d %-10s\n"
|
||||
struct sip_peer *peer;
|
||||
char name[256] = "";
|
||||
char iabuf[80];
|
||||
if (argc != 3 && argc != 5)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_mutex_lock(&peerl.lock);
|
||||
@@ -5324,7 +5349,7 @@ static int sip_show_peers(int fd, int argc, char *argv[])
|
||||
char status[20];
|
||||
int print_line = -1;
|
||||
char srch[2000];
|
||||
strncpy(nm, inet_ntoa(peer->mask), sizeof(nm)-1);
|
||||
strncpy(nm, ast_inet_ntoa(iabuf, sizeof(iabuf), peer->mask), sizeof(nm)-1);
|
||||
if (!ast_strlen_zero(peer->username))
|
||||
snprintf(name, sizeof(name), "%s/%s", peer->name, peer->username);
|
||||
else
|
||||
@@ -5341,7 +5366,7 @@ static int sip_show_peers(int fd, int argc, char *argv[])
|
||||
} else
|
||||
strcpy(status, "Unmonitored");
|
||||
sprintf(srch, FORMAT, name,
|
||||
peer->addr.sin_addr.s_addr ? inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->dynamic ? " D " : " ", /* Dynamic or not? */
|
||||
(peer->nat == SIP_NAT_ALWAYS) ? " N " : " ", /* NAT=yes? */
|
||||
peer->ha ? " A " : " ", /* permit/deny */
|
||||
@@ -5362,7 +5387,7 @@ static int sip_show_peers(int fd, int argc, char *argv[])
|
||||
|
||||
if (print_line) {
|
||||
ast_cli(fd, FORMAT, name,
|
||||
peer->addr.sin_addr.s_addr ? inet_ntoa(peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "(Unspecified)",
|
||||
peer->dynamic ? " D " : " ", /* Dynamic or not? */
|
||||
(peer->nat == SIP_NAT_ALWAYS) ? " N " : " ", /* NAT=yes? */
|
||||
peer->ha ? " A " : " ", /* permit/deny */
|
||||
@@ -5421,6 +5446,7 @@ static void print_group(int fd, unsigned int group)
|
||||
static int sip_show_peer(int fd, int argc, char *argv[])
|
||||
{
|
||||
char status[30];
|
||||
char iabuf[80];
|
||||
struct sip_peer *peer;
|
||||
|
||||
if (argc != 4)
|
||||
@@ -5462,8 +5488,8 @@ static int sip_show_peer(int fd, int argc, char *argv[])
|
||||
ast_cli(fd, "\n" );
|
||||
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 ? inet_ntoa(peer->addr.sin_addr) : "(Unspecified)", ntohs(peer->addr.sin_port));
|
||||
ast_cli(fd, " Defaddr->IP : %s Port %d\n", inet_ntoa(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(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, " Codecs : ");
|
||||
/* This should really be a function in frame.c */
|
||||
if (peer->capability & AST_FORMAT_G723_1)
|
||||
@@ -5525,12 +5551,13 @@ static int sip_show_registry(int fd, int argc, char *argv[])
|
||||
#define FORMAT "%-20.20s %-12.12s %8d %-20.20s\n"
|
||||
struct sip_registry *reg;
|
||||
char host[80];
|
||||
char iabuf[80];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_mutex_lock(®l.lock);
|
||||
ast_cli(fd, FORMAT2, "Host", "Username", "Refresh", "State");
|
||||
for (reg = regl.registrations;reg;reg = reg->next) {
|
||||
snprintf(host, sizeof(host), "%s:%d", inet_ntoa(reg->addr.sin_addr), ntohs(reg->addr.sin_port));
|
||||
snprintf(host, sizeof(host), "%s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), reg->addr.sin_addr), ntohs(reg->addr.sin_port));
|
||||
ast_cli(fd, FORMAT, host,
|
||||
reg->username, reg->refresh, regstate2str(reg->regstate));
|
||||
}
|
||||
@@ -5561,6 +5588,7 @@ static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions
|
||||
#define FORMAT2 "%-15.15s %-10.10s %-11.11s %-11.11s %s\n"
|
||||
#define FORMAT "%-15.15s %-10.10s %-11.11s %5.5d/%5.5d %-6.6s%s\n"
|
||||
struct sip_pvt *cur;
|
||||
char iabuf[80];
|
||||
int numchans = 0;
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
@@ -5572,7 +5600,7 @@ static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions
|
||||
ast_cli(fd, FORMAT3, "Peer", "User", "Call ID", "URI");
|
||||
while (cur) {
|
||||
if (!cur->subscribed && !subscriptions) {
|
||||
ast_cli(fd, FORMAT, inet_ntoa(cur->sa.sin_addr),
|
||||
ast_cli(fd, FORMAT, ast_inet_ntoa(iabuf, sizeof(iabuf), cur->sa.sin_addr),
|
||||
ast_strlen_zero(cur->username) ? ( ast_strlen_zero(cur->callerid) ? "(None)" : cur->callerid ) : cur->username,
|
||||
cur->callid,
|
||||
cur->ocseq, cur->icseq,
|
||||
@@ -5580,7 +5608,7 @@ static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions
|
||||
numchans++;
|
||||
}
|
||||
if (cur->subscribed && subscriptions) {
|
||||
ast_cli(fd, FORMAT3, inet_ntoa(cur->sa.sin_addr),
|
||||
ast_cli(fd, FORMAT3, ast_inet_ntoa(iabuf, sizeof(iabuf), cur->sa.sin_addr),
|
||||
ast_strlen_zero(cur->username) ? ( ast_strlen_zero(cur->callerid) ? "(None)" : cur->callerid ) : cur->username,
|
||||
cur->callid, cur->uri);
|
||||
|
||||
@@ -5624,6 +5652,7 @@ static int sip_show_channel(int fd, int argc, char *argv[])
|
||||
{
|
||||
struct sip_pvt *cur;
|
||||
char tmp[256];
|
||||
char iabuf[80];
|
||||
size_t len;
|
||||
int found = 0;
|
||||
if (argc != 4)
|
||||
@@ -5644,8 +5673,8 @@ static int sip_show_channel(int fd, int argc, char *argv[])
|
||||
ast_cli(fd, " Non-Codec Capability: %d\n", cur->noncodeccapability);
|
||||
ast_cli(fd, " Joint Codec Capability: %d\n", cur->jointcapability);
|
||||
ast_cli(fd, " Format %s\n", ast_getformatname(cur->owner ? cur->owner->nativeformats : 0) );
|
||||
ast_cli(fd, " Theoretical Address: %s:%d\n", inet_ntoa(cur->sa.sin_addr), ntohs(cur->sa.sin_port));
|
||||
ast_cli(fd, " Received Address: %s:%d\n", inet_ntoa(cur->recv.sin_addr), ntohs(cur->recv.sin_port));
|
||||
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, " NAT Support: %s\n", cur->nat ? ((cur->nat == SIP_NAT_ALWAYS) ? "Yes" : "RFC3581"): "No");
|
||||
ast_cli(fd, " Our Tag: %08d\n", cur->tag);
|
||||
ast_cli(fd, " Their Tag: %s\n", cur->theirtag);
|
||||
@@ -5793,6 +5822,7 @@ static int sip_do_debug_ip(int fd, int argc, char *argv[])
|
||||
{
|
||||
struct hostent *hp;
|
||||
struct ast_hostent ahp;
|
||||
char iabuf[80];
|
||||
int port = 0;
|
||||
char *p, *arg;
|
||||
if (argc != 4)
|
||||
@@ -5812,9 +5842,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", inet_ntoa(debugaddr.sin_addr));
|
||||
ast_cli(fd, "SIP Debugging Enabled for IP: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr));
|
||||
else
|
||||
ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", inet_ntoa(debugaddr.sin_addr), port);
|
||||
ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), debugaddr.sin_addr), port);
|
||||
sipdebug = 1;
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
@@ -5822,6 +5852,7 @@ 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[80];
|
||||
if (argc != 4)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_mutex_lock(&peerl.lock);
|
||||
@@ -5838,7 +5869,7 @@ static int sip_do_debug_peer(int fd, int argc, char *argv[])
|
||||
debugaddr.sin_family = AF_INET;
|
||||
memcpy(&debugaddr.sin_addr, &peer->addr.sin_addr, sizeof(debugaddr.sin_addr));
|
||||
debugaddr.sin_port = peer->addr.sin_port;
|
||||
ast_cli(fd, "SIP Debugging Enabled for IP: %s:%d\n", inet_ntoa(debugaddr.sin_addr), ntohs(debugaddr.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));
|
||||
sipdebug = 1;
|
||||
} else
|
||||
ast_cli(fd, "Unable to get IP address of peer '%s'\n", argv[3]);
|
||||
@@ -6032,13 +6063,14 @@ static int build_reply_digest(struct sip_pvt *p, char* orig_header, char* digest
|
||||
char resp_hash[256];
|
||||
char uri[256] = "";
|
||||
char cnonce[80];
|
||||
char iabuf[80];
|
||||
|
||||
if (!ast_strlen_zero(p->domain))
|
||||
strncpy(uri, p->domain, sizeof(uri) - 1);
|
||||
else if (!ast_strlen_zero(p->uri))
|
||||
strncpy(uri, p->uri, sizeof(uri) - 1);
|
||||
else
|
||||
snprintf(uri, sizeof(uri), "sip:%s@%s",p->username, inet_ntoa(p->sa.sin_addr));
|
||||
snprintf(uri, sizeof(uri), "sip:%s@%s",p->username, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
|
||||
|
||||
snprintf(cnonce, sizeof(cnonce), "%08x", rand());
|
||||
|
||||
@@ -6232,6 +6264,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
|
||||
int pingtime;
|
||||
struct timeval tv;
|
||||
int seqno=0;
|
||||
char iabuf[80];
|
||||
c = get_header(req, "Cseq");
|
||||
if (sscanf(c, "%d ", &seqno) != 1) {
|
||||
ast_log(LOG_WARNING, "Unable to determine sequence number\n");
|
||||
@@ -6453,7 +6486,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
|
||||
} else if (!strcasecmp(msg, "BYE") || !strcasecmp(msg, "REFER")) {
|
||||
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, inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
msg, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
if ((p->authtries > 1) || do_proxy_auth(p, req, "Proxy-Authenticate", "Proxy-Authorization", msg, 0)) {
|
||||
ast_log(LOG_NOTICE, "Failed to authenticate on %s to '%s'\n", msg, get_header(&p->initreq, "From"));
|
||||
p->needdestroy = 1;
|
||||
@@ -6471,12 +6504,12 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
|
||||
if (!strcasecmp(msg, "INVITE"))
|
||||
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
|
||||
else
|
||||
ast_log(LOG_WARNING, "Host '%s' does not implement '%s'\n", inet_ntoa(p->sa.sin_addr), msg);
|
||||
ast_log(LOG_WARNING, "Host '%s' does not implement '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr), msg);
|
||||
break;
|
||||
default:
|
||||
if ((resp >= 300) && (resp < 700)) {
|
||||
if ((option_verbose > 2) && (resp != 487))
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Got SIP response %d \"%s\" back from %s\n", resp, rest, inet_ntoa(p->sa.sin_addr));
|
||||
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));
|
||||
p->alreadygone = 1;
|
||||
if (p->rtp) {
|
||||
/* Immediately stop RTP */
|
||||
@@ -6531,7 +6564,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
|
||||
if (!p->owner)
|
||||
p->needdestroy = 1;
|
||||
} else
|
||||
ast_log(LOG_NOTICE, "Dunno anything about a %d %s response from %s\n", resp, rest, p->owner ? p->owner->name : inet_ntoa(p->sa.sin_addr));
|
||||
ast_log(LOG_NOTICE, "Dunno anything about a %d %s response from %s\n", resp, rest, p->owner ? p->owner->name : ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
|
||||
}
|
||||
} else {
|
||||
if (sip_debug_test_pvt(p))
|
||||
@@ -6546,7 +6579,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
|
||||
if (!strcasecmp(msg, "BYE") || !strcasecmp(msg, "REFER")) {
|
||||
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, inet_ntoa(p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
msg, ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr), ntohs(p->recv.sin_port));
|
||||
if ((p->authtries > 1) || do_proxy_auth(p, req, "Proxy-Authenticate", "Proxy-Authorization", msg, 0)) {
|
||||
ast_log(LOG_NOTICE, "Failed to authenticate on %s to '%s'\n", msg, get_header(&p->initreq, "From"));
|
||||
p->needdestroy = 1;
|
||||
@@ -6613,6 +6646,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
|
||||
int respid;
|
||||
int res;
|
||||
int gotdest;
|
||||
char iabuf[80];
|
||||
struct ast_frame af = { AST_FRAME_NULL, };
|
||||
int debug = sip_debug_test_pvt(p);
|
||||
|
||||
@@ -6944,7 +6978,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
|
||||
}
|
||||
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",
|
||||
inet_ntoa(p->recv.sin_addr));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr));
|
||||
if (ast_strlen_zero(p->context))
|
||||
strncpy(p->context, context, sizeof(p->context) - 1);
|
||||
res = get_also_info(p, req);
|
||||
@@ -6960,7 +6994,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
|
||||
ast_queue_hangup(p->owner);
|
||||
}
|
||||
} else {
|
||||
ast_log(LOG_WARNING, "Invalid transfer information from '%s'\n", inet_ntoa(p->recv.sin_addr));
|
||||
ast_log(LOG_WARNING, "Invalid transfer information from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), p->recv.sin_addr));
|
||||
ast_queue_hangup(p->owner);
|
||||
}
|
||||
} else if (p->owner)
|
||||
@@ -7080,7 +7114,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
|
||||
copy_request(&p->initreq, req);
|
||||
check_via(p, req);
|
||||
if ((res = register_verify(p, sin, req, e, ignore)) < 0)
|
||||
ast_log(LOG_NOTICE, "Registration from '%s' failed for '%s'\n", get_header(req, "To"), inet_ntoa(sin->sin_addr));
|
||||
ast_log(LOG_NOTICE, "Registration from '%s' failed for '%s'\n", get_header(req, "To"), ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr));
|
||||
if (res < 1) {
|
||||
/* Destroy the session, but keep us around for just a bit in case they don't
|
||||
get our 200 OK */
|
||||
@@ -7110,7 +7144,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
|
||||
} else {
|
||||
transmit_response_with_allow(p, "405 Method Not Allowed", req, 0);
|
||||
ast_log(LOG_NOTICE, "Unknown SIP command '%s' from '%s'\n",
|
||||
cmd, inet_ntoa(p->sa.sin_addr));
|
||||
cmd, ast_inet_ntoa(iabuf, sizeof(iabuf), p->sa.sin_addr));
|
||||
/* If this is some new method, and we don't have a call, destroy it now */
|
||||
if (!p->initreq.headers)
|
||||
p->needdestroy = 1;
|
||||
@@ -7185,6 +7219,7 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer)
|
||||
/* Called with peerl lock, but releases it */
|
||||
struct sip_pvt *p;
|
||||
char name[256] = "";
|
||||
char iabuf[80];
|
||||
int newmsgs, oldmsgs;
|
||||
/* Check for messages */
|
||||
ast_app_messagecount(peer->mailbox, &newmsgs, &oldmsgs);
|
||||
@@ -7216,9 +7251,9 @@ static int sip_send_mwi_to_peer(struct sip_peer *peer)
|
||||
memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
|
||||
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
|
||||
if (p->nat != SIP_NAT_NEVER)
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
else /* UNIDEN UIP200 bug */
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
build_callid(p->callid, sizeof(p->callid), p->ourip);
|
||||
/* Send MWI */
|
||||
p->outgoing = 1;
|
||||
@@ -7402,6 +7437,7 @@ static int sip_poke_noanswer(void *data)
|
||||
static int sip_poke_peer(struct sip_peer *peer)
|
||||
{
|
||||
struct sip_pvt *p;
|
||||
char iabuf[80];
|
||||
if (!peer->maxms || !peer->addr.sin_addr.s_addr) {
|
||||
/* IF we have no IP, or this isn't to be monitored, return
|
||||
imeediately after clearing things out */
|
||||
@@ -7424,16 +7460,16 @@ static int sip_poke_peer(struct sip_peer *peer)
|
||||
if (!ast_strlen_zero(p->tohost))
|
||||
strncpy(p->tohost, peer->tohost, sizeof(p->tohost) - 1);
|
||||
else
|
||||
snprintf(p->tohost, sizeof(p->tohost), "%s", inet_ntoa(peer->addr.sin_addr));
|
||||
snprintf(p->tohost, sizeof(p->tohost), "%s", ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr));
|
||||
|
||||
/* Recalculate our side, and recalculate Call ID */
|
||||
if (ast_sip_ouraddrfor(&p->sa.sin_addr,&p->ourip))
|
||||
memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
|
||||
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
|
||||
if (p->nat != SIP_NAT_NEVER)
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
else
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
build_callid(p->callid, sizeof(p->callid), p->ourip);
|
||||
|
||||
if (peer->pokeexpire > -1)
|
||||
@@ -7506,6 +7542,7 @@ static struct ast_channel *sip_request(char *type, int format, void *data)
|
||||
struct ast_channel *tmpc = NULL;
|
||||
char *ext, *host;
|
||||
char tmp[256] = "";
|
||||
char iabuf[80];
|
||||
char *dest = data;
|
||||
|
||||
oldformat = format;
|
||||
@@ -7552,9 +7589,9 @@ static struct ast_channel *sip_request(char *type, int format, void *data)
|
||||
memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
|
||||
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
|
||||
if (p->nat != SIP_NAT_NEVER)
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
else /* UNIDEN bug */
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", inet_ntoa(p->ourip), ourport, p->branch);
|
||||
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
|
||||
build_callid(p->callid, sizeof(p->callid), p->ourip);
|
||||
if (ext)
|
||||
strncpy(p->username, ext, sizeof(p->username) - 1);
|
||||
@@ -7969,6 +8006,7 @@ static int reload_config(void)
|
||||
struct hostent *hp;
|
||||
int format;
|
||||
int oldport = ntohs(bindaddr.sin_port);
|
||||
char iabuf[80];
|
||||
|
||||
globaldtmfmode = SIP_DTMF_RFC2833;
|
||||
globalpromiscredir = 0;
|
||||
@@ -8230,14 +8268,14 @@ static int reload_config(void)
|
||||
|
||||
if (bind(sipsock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) {
|
||||
ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
|
||||
inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), 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",
|
||||
inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Using TOS bits %d\n", tos);
|
||||
}
|
||||
if (setsockopt(sipsock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
|
||||
|
@@ -988,13 +988,14 @@ static int skinny_show_lines(int fd, int argc, char *argv[])
|
||||
struct skinny_device *d;
|
||||
struct skinny_line *l;
|
||||
int haslines = 0;
|
||||
char iabuf[80];
|
||||
if (argc != 3)
|
||||
return RESULT_SHOWUSAGE;
|
||||
ast_mutex_lock(&devicelock);
|
||||
d = devices;
|
||||
while(d) {
|
||||
l = d->lines;
|
||||
ast_cli(fd, "Device '%s' at %s\n", d->name, inet_ntoa(d->addr.sin_addr));
|
||||
ast_cli(fd, "Device '%s' at %s\n", d->name, ast_inet_ntoa(iabuf, sizeof(iabuf), d->addr.sin_addr));
|
||||
while(l) {
|
||||
ast_cli(fd, " -- '%s@%s in '%s' is %s\n", l->name, d->name, l->context, l->sub->owner ? "active" : "idle");
|
||||
haslines = 1;
|
||||
@@ -2326,8 +2327,9 @@ static void *skinny_session(void *data)
|
||||
int res;
|
||||
skinny_req *req;
|
||||
struct skinnysession *s = data;
|
||||
char iabuf[80];
|
||||
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Starting Skinny session from %s\n", inet_ntoa(s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Starting Skinny session from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
|
||||
for (;;) {
|
||||
res = 0;
|
||||
@@ -2506,6 +2508,7 @@ static int reload_config(void)
|
||||
struct ast_variable *v;
|
||||
int format;
|
||||
char *cat;
|
||||
char iabuf[80];
|
||||
struct skinny_device *d;
|
||||
int oldport = ntohs(bindaddr.sin_port);
|
||||
|
||||
@@ -2612,7 +2615,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",
|
||||
inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port),
|
||||
strerror(errno));
|
||||
close(skinnysock);
|
||||
skinnysock = -1;
|
||||
@@ -2622,7 +2625,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",
|
||||
inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port),
|
||||
strerror(errno));
|
||||
close(skinnysock);
|
||||
skinnysock = -1;
|
||||
@@ -2632,7 +2635,7 @@ static int reload_config(void)
|
||||
|
||||
if (option_verbose > 1)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Skinny listening on %s:%d\n",
|
||||
inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), bindaddr.sin_addr), ntohs(bindaddr.sin_port));
|
||||
|
||||
pthread_create(&accept_t,NULL, accept_thread, NULL);
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
#include <asterisk/frame.h>
|
||||
#include <asterisk/utils.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@@ -44,9 +45,10 @@ 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[80];
|
||||
if (len == (int)sizeof(sin)) {
|
||||
memcpy(&sin, value, len);
|
||||
snprintf(output, maxlen, "IPV4 %s:%d", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
snprintf(output, maxlen, "IPV4 %s:%d", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
|
||||
} else {
|
||||
snprintf(output, maxlen, "Invalid Address");
|
||||
}
|
||||
@@ -252,6 +254,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
||||
char *class;
|
||||
char *subclass;
|
||||
char tmp[256];
|
||||
char iabuf[80];
|
||||
if (f) {
|
||||
fh = f->data;
|
||||
snprintf(retries, (int)sizeof(retries), "%03d", f->retries);
|
||||
@@ -302,7 +305,7 @@ snprintf(tmp, (int)sizeof(tmp),
|
||||
" 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,
|
||||
inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), ntohs(sin->sin_port));
|
||||
outputf(tmp);
|
||||
if (fh->type == AST_FRAME_IAX)
|
||||
dump_ies(fh->iedata, datalen);
|
||||
|
@@ -29,6 +29,9 @@ extern int ast_base64encode(char *dst, unsigned char *src, int srclen, int max);
|
||||
extern int ast_base64decode(unsigned char *dst, char *src, int max);
|
||||
|
||||
extern int test_for_thread_safety(void);
|
||||
extern const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia);
|
||||
extern int ast_utils_init(void);
|
||||
|
||||
#define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__
|
||||
|
||||
#endif
|
||||
|
27
manager.c
27
manager.c
@@ -163,12 +163,13 @@ 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[80];
|
||||
char *format = " %-15.15s %-15.15s\n";
|
||||
ast_mutex_lock(&sessionlock);
|
||||
s = sessions;
|
||||
ast_cli(fd, format, "Username", "IP Address");
|
||||
while (s) {
|
||||
ast_cli(fd, format,s->username, inet_ntoa(s->sin.sin_addr));
|
||||
ast_cli(fd, format,s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
s = s->next;
|
||||
}
|
||||
|
||||
@@ -311,6 +312,7 @@ static int set_eventmask(struct mansession *s, char *eventmask)
|
||||
static int authenticate(struct mansession *s, struct message *m)
|
||||
{
|
||||
struct ast_config *cfg;
|
||||
char iabuf[80];
|
||||
char *cat;
|
||||
char *user = astman_get_header(m, "Username");
|
||||
char *pass = astman_get_header(m, "Secret");
|
||||
@@ -340,7 +342,7 @@ 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", inet_ntoa(s->sin.sin_addr), user);
|
||||
ast_log(LOG_NOTICE, "%s failed to pass IP ACL as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
|
||||
ast_free_ha(ha);
|
||||
ast_destroy(cfg);
|
||||
return -1;
|
||||
@@ -369,7 +371,7 @@ static int authenticate(struct mansession *s, struct message *m)
|
||||
} else if (password && !strcasecmp(password, pass)) {
|
||||
break;
|
||||
} else {
|
||||
ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", inet_ntoa(s->sin.sin_addr), user);
|
||||
ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
|
||||
ast_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
@@ -386,7 +388,7 @@ static int authenticate(struct mansession *s, struct message *m)
|
||||
set_eventmask(s, events);
|
||||
return 0;
|
||||
}
|
||||
ast_log(LOG_NOTICE, "%s tried to authenticate with non-existant user '%s'\n", inet_ntoa(s->sin.sin_addr), user);
|
||||
ast_log(LOG_NOTICE, "%s tried to authenticate with non-existant user '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), user);
|
||||
ast_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
@@ -938,6 +940,7 @@ 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[80];
|
||||
|
||||
strncpy(action, astman_get_header(m, "Action"), sizeof(action));
|
||||
ast_log( LOG_DEBUG, "Manager received command '%s'\n", action );
|
||||
@@ -976,8 +979,8 @@ static int process_message(struct mansession *s, struct message *m)
|
||||
} else {
|
||||
s->authenticated = 1;
|
||||
if (option_verbose > 1)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged on from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "Manager '%s' logged on from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged on from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "Manager '%s' logged on from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
astman_send_ack(s, m, "Authentication accepted");
|
||||
}
|
||||
} else if (!strcasecmp(action, "Logoff")) {
|
||||
@@ -1009,6 +1012,7 @@ static int get_input(struct mansession *s, char *output)
|
||||
int res;
|
||||
int x;
|
||||
struct pollfd fds[1];
|
||||
char iabuf[80];
|
||||
for (x=1;x<s->inlen;x++) {
|
||||
if ((s->inbuf[x] == '\n') && (s->inbuf[x-1] == '\r')) {
|
||||
/* Copy output data up to and including \r\n */
|
||||
@@ -1022,7 +1026,7 @@ 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", inet_ntoa(s->sin.sin_addr), s->inbuf);
|
||||
ast_log(LOG_WARNING, "Dumping long line with no return from %s: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr), s->inbuf);
|
||||
s->inlen = 0;
|
||||
}
|
||||
fds[0].fd = s->fd;
|
||||
@@ -1046,6 +1050,7 @@ static void *session_do(void *data)
|
||||
{
|
||||
struct mansession *s = data;
|
||||
struct message m;
|
||||
char iabuf[80];
|
||||
int res;
|
||||
|
||||
ast_mutex_lock(&s->lock);
|
||||
@@ -1070,12 +1075,12 @@ static void *session_do(void *data)
|
||||
}
|
||||
if (s->authenticated) {
|
||||
if (option_verbose > 1)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, inet_ntoa(s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "Manager '%s' logged off from %s\n", s->username, ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
} else {
|
||||
if (option_verbose > 1)
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", inet_ntoa(s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "Failed attempt from %s\n", inet_ntoa(s->sin.sin_addr));
|
||||
ast_verbose(VERBOSE_PREFIX_2 "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), s->sin.sin_addr));
|
||||
}
|
||||
destroy_session(s);
|
||||
return NULL;
|
||||
|
@@ -452,7 +452,7 @@ int ast_osp_validate(char *provider, char *token, int *handle, unsigned int *tim
|
||||
}
|
||||
callerid = l;
|
||||
ast_mutex_lock(&osplock);
|
||||
strcpy(ip, inet_ntoa(addr));
|
||||
ast_inet_ntoa(ip, sizeof(ip), addr));
|
||||
osp = providers;
|
||||
while(osp) {
|
||||
if (!strcasecmp(osp->name, provider)) {
|
||||
|
37
rtp.c
37
rtp.c
@@ -34,6 +34,7 @@
|
||||
#include <asterisk/channel_pvt.h>
|
||||
#include <asterisk/config.h>
|
||||
#include <asterisk/lock.h>
|
||||
#include <asterisk/utils.h>
|
||||
|
||||
#define RTP_MTU 1200
|
||||
|
||||
@@ -170,15 +171,16 @@ static struct ast_frame *send_dtmf(struct ast_rtp *rtp)
|
||||
{
|
||||
struct timeval tv;
|
||||
static struct ast_frame null_frame = { AST_FRAME_NULL, };
|
||||
char iabuf[80];
|
||||
gettimeofday(&tv, NULL);
|
||||
if ((tv.tv_sec < rtp->dtmfmute.tv_sec) ||
|
||||
((tv.tv_sec == rtp->dtmfmute.tv_sec) && (tv.tv_usec < rtp->dtmfmute.tv_usec))) {
|
||||
ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", inet_ntoa(rtp->them.sin_addr));
|
||||
ast_log(LOG_DEBUG, "Ignore potential DTMF echo from '%s'\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
|
||||
rtp->resp = 0;
|
||||
rtp->dtmfduration = 0;
|
||||
return &null_frame;
|
||||
}
|
||||
ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, inet_ntoa(rtp->them.sin_addr));
|
||||
ast_log(LOG_DEBUG, "Sending dtmf: %d (%c), at %s\n", rtp->resp, rtp->resp, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr));
|
||||
rtp->f.frametype = AST_FRAME_DTMF;
|
||||
rtp->f.subclass = rtp->resp;
|
||||
rtp->f.datalen = 0;
|
||||
@@ -333,6 +335,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
|
||||
int res;
|
||||
struct sockaddr_in sin;
|
||||
unsigned int rtcpdata[1024];
|
||||
char iabuf[80];
|
||||
|
||||
if (!rtp->rtcp)
|
||||
return &null_frame;
|
||||
@@ -359,7 +362,7 @@ struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp)
|
||||
if ((rtp->rtcp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
|
||||
(rtp->rtcp->them.sin_port != sin.sin_port)) {
|
||||
memcpy(&rtp->them, &sin, sizeof(rtp->them));
|
||||
ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", inet_ntoa(rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->rtcp->them.sin_addr), ntohs(rtp->rtcp->them.sin_port));
|
||||
}
|
||||
}
|
||||
if (option_debug)
|
||||
@@ -397,6 +400,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
|
||||
int payloadtype;
|
||||
int hdrlen = 12;
|
||||
int mark;
|
||||
char iabuf[80];
|
||||
unsigned int timestamp;
|
||||
unsigned int *rtpheader;
|
||||
static struct ast_frame *f, null_frame = { AST_FRAME_NULL, };
|
||||
@@ -434,7 +438,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
|
||||
if ((rtp->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
|
||||
(rtp->them.sin_port != sin.sin_port)) {
|
||||
memcpy(&rtp->them, &sin, sizeof(rtp->them));
|
||||
ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
ast_log(LOG_DEBUG, "RTP NAT: Using address %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,7 +450,7 @@ struct ast_frame *ast_rtp_read(struct ast_rtp *rtp)
|
||||
timestamp = ntohl(rtpheader[1]);
|
||||
|
||||
#if 0
|
||||
printf("Got RTP packet from %s:%d (type %d, seq %d, ts %d, len = %d)\n", inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp,res - hdrlen);
|
||||
printf("Got RTP packet from %s:%d (type %d, seq %d, ts %d, len = %d)\n", ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port), payloadtype, seqno, timestamp,res - hdrlen);
|
||||
#endif
|
||||
rtpPT = ast_rtp_lookup_pt(rtp, payloadtype);
|
||||
if (!rtpPT.isAstFormat) {
|
||||
@@ -937,6 +941,7 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
|
||||
int ms;
|
||||
int x;
|
||||
char data[256];
|
||||
char iabuf[80];
|
||||
|
||||
if ((digit <= '9') && (digit >= '0'))
|
||||
digit -= '0';
|
||||
@@ -979,9 +984,9 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
|
||||
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
|
||||
res = sendto(rtp->s, (void *)rtpheader, hdrlen + 4, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
|
||||
if (res <0)
|
||||
ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||
ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||
#if 0
|
||||
printf("Sent %d bytes of RTP data to %s:%d\n", res, inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
printf("Sent %d bytes of RTP data to %s:%d\n", res, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
#endif
|
||||
}
|
||||
if (x ==0) {
|
||||
@@ -999,6 +1004,7 @@ int ast_rtp_senddigit(struct ast_rtp *rtp, char digit)
|
||||
static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec)
|
||||
{
|
||||
unsigned int *rtpheader;
|
||||
char iabuf[80];
|
||||
int hdrlen = 12;
|
||||
int res;
|
||||
int ms;
|
||||
@@ -1078,9 +1084,9 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
|
||||
if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
|
||||
res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
|
||||
if (res <0)
|
||||
ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||
ast_log(LOG_NOTICE, "RTP Transmission error to %s:%d: %s\n", ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
|
||||
#if 0
|
||||
printf("Sent %d bytes of RTP data to %s:%d\n", res, inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
printf("Sent %d bytes of RTP data to %s:%d\n", res, ast_inet_ntoa(iabuf, sizeof(iabuf), rtp->them.sin_addr), ntohs(rtp->them.sin_port));
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
@@ -1273,6 +1279,7 @@ int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, st
|
||||
struct sockaddr_in vac0, vac1;
|
||||
struct sockaddr_in t0, t1;
|
||||
struct sockaddr_in vt0, vt1;
|
||||
char iabuf[80];
|
||||
|
||||
void *pvt0, *pvt1;
|
||||
int to;
|
||||
@@ -1389,13 +1396,13 @@ int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, st
|
||||
ast_rtp_get_peer(vp0, &vt0);
|
||||
if (inaddrcmp(&t1, &ac1) || (vp1 && inaddrcmp(&vt1, &vac1)) || (codec1 != oldcodec1)) {
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
|
||||
c1->name, inet_ntoa(t1.sin_addr), ntohs(t1.sin_port), codec1);
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), t1.sin_addr), ntohs(t1.sin_port), codec1);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' changed end vaddress to %s:%d (format %d)\n",
|
||||
c1->name, inet_ntoa(vt1.sin_addr), ntohs(vt1.sin_port), codec1);
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vt1.sin_addr), ntohs(vt1.sin_port), codec1);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
|
||||
c1->name, inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac1.sin_addr), ntohs(ac1.sin_port), oldcodec1);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' wasv %s:%d/(format %d)\n",
|
||||
c1->name, inet_ntoa(vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
|
||||
c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1);
|
||||
if (pr0->set_rtp_peer(c0, t1.sin_addr.s_addr ? p1 : NULL, vt1.sin_addr.s_addr ? vp1 : NULL, codec1))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name);
|
||||
memcpy(&ac1, &t1, sizeof(ac1));
|
||||
@@ -1404,9 +1411,9 @@ int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, st
|
||||
}
|
||||
if (inaddrcmp(&t0, &ac0) || (vp0 && inaddrcmp(&vt0, &vac0))) {
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d (format %d)\n",
|
||||
c0->name, inet_ntoa(t0.sin_addr), ntohs(t0.sin_port), codec0);
|
||||
c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), t0.sin_addr), ntohs(t0.sin_port), codec0);
|
||||
ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n",
|
||||
c0->name, inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
|
||||
c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0);
|
||||
if (pr1->set_rtp_peer(c1, t0.sin_addr.s_addr ? p0 : NULL, vt0.sin_addr.s_addr ? vp0 : NULL, codec0))
|
||||
ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name);
|
||||
memcpy(&ac0, &t0, sizeof(ac0));
|
||||
|
7
utils.c
7
utils.c
@@ -12,6 +12,9 @@
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <asterisk/lock.h>
|
||||
#include <asterisk/utils.h>
|
||||
|
||||
@@ -325,6 +328,10 @@ static void base64_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia)
|
||||
{
|
||||
return inet_ntop(AF_INET, &ia, buf, bufsiz);
|
||||
}
|
||||
|
||||
int ast_utils_init(void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user