diff options
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index de2c80e55..29b92a51c 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -3188,7 +3188,7 @@ static int method_match(enum sipmethod id, const char *name) int len = strlen(sip_methods[id].text); int l_name = name ? strlen(name) : 0; /* true if the string is long enough, and ends with whitespace, and matches */ - return (l_name >= len && name[len] < 33 && + return (l_name >= len && name && name[len] < 33 && !strncasecmp(sip_methods[id].text, name, len)); } @@ -3492,7 +3492,7 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka } ast_debug(1, "Target address %s is not local, substituting externaddr\n", ast_sockaddr_stringify(them)); - } else if (p) { + } else { /* no remapping, but we bind to a specific address, so use it. */ switch (p->socket.type) { case SIP_TRANSPORT_TCP: @@ -3523,8 +3523,6 @@ static void ast_sip_ouraddrfor(const struct ast_sockaddr *them, struct ast_socka ast_sockaddr_set_port(us, ast_sockaddr_port(&bindaddr)); } } - } else if (!ast_sockaddr_is_any(&bindaddr)) { - ast_sockaddr_copy(us, &bindaddr); } ast_debug(3, "Setting SIP_TRANSPORT_%s with address %s\n", sip_get_transport(p->socket.type), ast_sockaddr_stringify(us)); } @@ -3667,7 +3665,7 @@ static int retrans_pkt(const void *data) pkt->retransid = -1; /* Kill this scheduler item */ - if (pkt->owner && pkt->method != SIP_OPTIONS && xmitres == 0) { + if (pkt->method != SIP_OPTIONS && xmitres == 0) { if (pkt->is_fatal || sipdebug) { /* Tell us if it's critical or if we're debugging */ ast_log(LOG_WARNING, "Retransmission timeout reached on transmission %s for seqno %u (%s %s) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions\n" "Packet timed out after %dms with no response\n", @@ -7224,6 +7222,8 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit if (i->rtp) { ast_channel_set_fd(tmp, 0, ast_rtp_instance_fd(i->rtp, 0)); ast_channel_set_fd(tmp, 1, ast_rtp_instance_fd(i->rtp, 1)); + ast_rtp_instance_set_write_format(i->rtp, &fmt); + ast_rtp_instance_set_read_format(i->rtp, &fmt); } if (needvideo && i->vrtp) { ast_channel_set_fd(tmp, 2, ast_rtp_instance_fd(i->vrtp, 0)); @@ -7243,11 +7243,9 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit ast_format_copy(ast_channel_writeformat(tmp), &fmt); ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt); - ast_rtp_instance_set_write_format(i->rtp, &fmt); ast_format_copy(ast_channel_readformat(tmp), &fmt); ast_format_copy(ast_channel_rawreadformat(tmp), &fmt); - ast_rtp_instance_set_read_format(i->rtp, &fmt); ast_channel_tech_pvt_set(tmp, dialog_ref(i, "sip_new: set chan->tech_pvt to i")); @@ -8511,7 +8509,7 @@ static int sip_subscribe_mwi(const char *value, int lineno) int portnum = 0; enum sip_transport transport = SIP_TRANSPORT_UDP; char buf[256] = ""; - char *username = NULL, *hostname = NULL, *secret = NULL, *authuser = NULL, *porta = NULL, *mailbox = NULL, *at = NULL; + char *username = NULL, *hostname = NULL, *secret = NULL, *authuser = NULL, *porta = NULL, *mailbox = NULL; if (!value) { return -1; @@ -8519,13 +8517,12 @@ static int sip_subscribe_mwi(const char *value, int lineno) ast_copy_string(buf, value, sizeof(buf)); - if (!(at = strstr(buf, "@"))) { - return -1; - } + username = buf; if ((hostname = strrchr(buf, '@'))) { *hostname++ = '\0'; - username = buf; + } else { + return -1; } if ((secret = strchr(username, ':'))) { @@ -27283,8 +27280,12 @@ enum st_refresher st_get_refresher(struct sip_pvt *p) */ enum st_mode st_get_mode(struct sip_pvt *p, int no_cached) { - if (!p->stimer) + if (!p->stimer) { sip_st_alloc(p); + if (!p->stimer) { + return SESSION_TIMER_MODE_INVALID; + } + } if (!no_cached && p->stimer->st_cached_mode != SESSION_TIMER_MODE_INVALID) return p->stimer->st_cached_mode; |