diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index aef3c68dfa..27633db4ad 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -2311,10 +2311,17 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame) if ( !frame->samples ) { chan_misdn_log(4, ch->bc->port, "misdn_write: zero write\n"); - if (ch->state == MISDN_WAITING4DIGS) { - chan_misdn_log(4, ch->bc->port, "misdn_write: WAIT4DIGS ..\n"); + + if (!strcmp(frame->src,"ast_prod")) { + chan_misdn_log(1, ch->bc->port, "misdn_write: state (%s) prodded.\n", misdn_get_ch_state(ch)); + + if (ch->ts) { + chan_misdn_log(4,ch->bc->port,"Starting Playtones\n"); + misdn_lib_tone_generator_start(ch->bc); + } return 0; } + return -1; } @@ -2499,9 +2506,8 @@ static int dialtone_indicate(struct chan_list *cl) if (ts) { cl->notxtone=0; cl->norxtone=0; + /* This prods us in misdn_write */ ast_playtones_start(ast,0, ts->data, 0); - chan_misdn_log(4,cl->bc->port,"Starting Playtones\n"); - misdn_lib_tone_generator_start(cl->bc); } return 0; @@ -3181,11 +3187,6 @@ static void do_immediate_setup(struct misdn_bchannel *bc,struct chan_list *ch , ch->state = MISDN_INCOMING_SETUP; } - if ( !bc->nt && (ch->orginator==ORG_MISDN) && !ch->incoming_early_audio ) - chan_misdn_log(1,bc->port, " --> incoming_early_audio off\n"); - else - dialtone_indicate(ch); - chan_misdn_log(1, bc->port, "* Starting Ast ctx:%s dad:%s oad:%s with 's' extension\n", ast->context, ast->exten, AST_CID_P(ast)); strncpy(ast->exten,"s", 2); @@ -3801,7 +3802,8 @@ cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data) if ( (!ast_strlen_zero(bc->dad)) && stop_tone ) stop_indicate(ch); else { - dialtone_indicate(ch); + if (bc->nt) + dialtone_indicate(ch); } } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 0c93c78fc6..76e3df56e2 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -4104,9 +4104,9 @@ static void set_destination(struct sip_pvt *p, char *uri) ++h; else { h = uri; - if (strncmp(h, "sip:", 4) == 0) + if (strncasecmp(h, "sip:", 4) == 0) h += 4; - else if (strncmp(h, "sips:", 5) == 0) + else if (strncasecmp(h, "sips:", 5) == 0) h += 5; } hn = strcspn(h, ":;>") + 1; @@ -5330,7 +5330,7 @@ static int transmit_state_notify(struct sip_pvt *p, int state, int full, int sub ast_copy_string(from, get_header(&p->initreq, "From"), sizeof(from)); c = get_in_brackets(from); - if (strncmp(c, "sip:", 4)) { + if (strncasecmp(c, "sip:", 4)) { ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", c); return -1; } @@ -5340,7 +5340,7 @@ static int transmit_state_notify(struct sip_pvt *p, int state, int full, int sub ast_copy_string(to, get_header(&p->initreq, "To"), sizeof(to)); c = get_in_brackets(to); - if (strncmp(c, "sip:", 4)) { + if (strncasecmp(c, "sip:", 4)) { ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", c); return -1; } @@ -5838,7 +5838,7 @@ static int transmit_refer(struct sip_pvt *p, const char *dest) ast_copy_string(from, of, sizeof(from)); of = get_in_brackets(from); ast_copy_string(p->from,of,sizeof(p->from)); - if (strncmp(of, "sip:", 4)) { + if (strncasecmp(of, "sip:", 4)) { ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n"); } else of += 4; @@ -6700,7 +6700,7 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si if (name) *name = '\0'; - if (!strncmp(c, "sip:", 4)) { + if (!strncasecmp(c, "sip:", 4)) { name = c + 4; } else { name = c; @@ -6729,10 +6729,12 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si if (peer) ASTOBJ_UNREF(peer,sip_destroy_peer); peer = NULL; + res = -4; } if (peer) { if (!ast_test_flag(&peer->flags_page2, SIP_PAGE2_DYNAMIC)) { ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name); + res = -5; } else { ast_copy_flags(p, peer, SIP_NAT); transmit_response(p, "100 Trying", req); @@ -6806,22 +6808,20 @@ static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct si proper authentication by digest auth name */ transmit_response(p, "403 Authentication user name does not match account name", &p->initreq); break; - case -3: + case -3: /* Unknown domain */ + case -4: /* ACL error */ + case -5: /* Peer is not supposed to register with us at all */ if (global_alwaysauthreject) { transmit_fake_auth_response(p, &p->initreq, p->randdata, sizeof(p->randdata), 1); } else { /* URI not found */ - transmit_response(p, "404 Not found", &p->initreq); + if (res == -5) + transmit_response(p, "403 Forbidden", &p->initreq); + else + transmit_response(p, "404 Not found", &p->initreq); } - /* Set res back to -2 because we don't want to return an invalid domain message. That check already happened up above. */ - res = -2; break; } - if (option_debug > 1) { - ast_log(LOG_DEBUG, "SIP REGISTER attempt failed for %s : %s\n", - peer->name, - (res == -1) ? "Bad password" : ((res == -2 ) ? "Bad digest user" : "Peer not found")); - } } if (peer) ASTOBJ_UNREF(peer,sip_destroy_peer); @@ -6842,7 +6842,7 @@ static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq) if (ast_strlen_zero(tmp)) return 0; c = get_in_brackets(tmp); - if (strncmp(c, "sip:", 4)) { + if (strncasecmp(c, "sip:", 4)) { ast_log(LOG_WARNING, "Huh? Not an RDNIS SIP header (%s)?\n", c); return -1; } @@ -6876,13 +6876,13 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq) from = get_in_brackets(tmpf); - if (strncmp(uri, "sip:", 4)) { + if (strncasecmp(uri, "sip:", 4)) { ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", uri); return -1; } uri += 4; if (!ast_strlen_zero(from)) { - if (strncmp(from, "sip:", 4)) { + if (strncasecmp(from, "sip:", 4)) { ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", from); return -1; } @@ -7024,12 +7024,12 @@ static int get_refer_info(struct sip_pvt *sip_pvt, struct sip_request *outgoing_ } h_contact = get_header(req, "Contact"); - if (strncmp(refer_to, "sip:", 4)) { + if (strncasecmp(refer_to, "sip:", 4)) { ast_log(LOG_WARNING, "Refer-to: Huh? Not a SIP header (%s)?\n", refer_to); return -1; } - if (strncmp(referred_by, "sip:", 4)) { + if (strncasecmp(referred_by, "sip:", 4)) { ast_log(LOG_WARNING, "Referred-by: Huh? Not a SIP header (%s) Ignoring?\n", referred_by); referred_by = NULL; } @@ -7145,7 +7145,7 @@ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq) c = get_in_brackets(tmp); - if (strncmp(c, "sip:", 4)) { + if (strncasecmp(c, "sip:", 4)) { ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", c); return -1; } @@ -7336,7 +7336,7 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme of = get_in_brackets(from); if (ast_strlen_zero(p->exten)) { t = uri2; - if (!strncmp(t, "sip:", 4)) + if (!strncasecmp(t, "sip:", 4)) t+= 4; ast_copy_string(p->exten, t, sizeof(p->exten)); t = strchr(p->exten, '@'); @@ -7347,7 +7347,7 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme } /* save the URI part of the From header */ ast_copy_string(p->from, of, sizeof(p->from)); - if (strncmp(of, "sip:", 4)) { + if (strncasecmp(of, "sip:", 4)) { ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n"); } else of += 4; @@ -11354,8 +11354,24 @@ static int handle_request_register(struct sip_pvt *p, struct sip_request *req, i ast_verbose("Using latest REGISTER request as basis request\n"); 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' - %s\n", get_header(req, "To"), ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), (res == -1) ? "Wrong password" : (res == -2 ? "Username/auth name mismatch" : "Not a local SIP domain")); + if ((res = register_verify(p, sin, req, e, ignore)) < 0) { + const char *error; + switch (res) { + case -1: error = "Wrong password"; + break; + case -2: error = "Username/auth name mismatch"; + break; + case -3: error = "Not a local SIP domain"; + break; + case -4: error = "ACL error (permit/deny)"; + break; + case -5: error = "Peer is not supposed to register"; + break; + default: error = "Unknown error"; + break; + } + ast_log(LOG_NOTICE, "Registration from '%s' failed for '%s' - %s\n", get_header(req, "To"), ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), error); + } if (res < 1) { /* Destroy the session, but keep us around for just a bit in case they don't get our 200 OK */ @@ -13497,7 +13513,7 @@ static int sip_sipredirect(struct sip_pvt *p, const char *dest) ast_log(LOG_ERROR, "Cannot retrieve the 'To' header from the original SIP request!\n"); return 0; } - if ((localtmp = strstr(tmp, "sip:")) && (localtmp = strchr(localtmp, '@'))) { + if ((localtmp = strcasestr(tmp, "sip:")) && (localtmp = strchr(localtmp, '@'))) { char lhost[80], lport[80]; memset(lhost, 0, sizeof(lhost)); memset(lport, 0, sizeof(lport));