++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;
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;
}
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;
}
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;
if (name)
*name = '\0';
- if (!strncmp(c, "sip:", 4)) {
+ if (!strncasecmp(c, "sip:", 4)) {
name = c + 4;
} else {
name = c;
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);
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);
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;
}
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;
}
}
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;
}
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;
}
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, '@');
}
/* 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;
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 */
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));