While at it, also added better logging and handling of peers that are not supposed to register.
My patch, stole the issue report from Russell. My apologies, Russell :-)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@64514 65c4cc65-6c06-0410-ace0-fbb531ad65f3
/* 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);
@ -11244,8 +11244,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){
constchar*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