anchor.diff:      case via_indicates_loop(LoopCookie, {ViaHostname, ViaPort},
       			    sipheader:via(keylist:fetch("Via", Header))) of
   	true ->
  -	    throw({sipparseerror, Header, 482, "Loop Detected"});
  +	    throw({sipparseerror, request, Header, 482, "Loop Detected"});
   	_ ->
   	    true
       end.
  
positive.code: url2str(URL) ->
      sipurl:print(URL).
  
  sanity_check_contact(Name, Header) ->
      case keylist:fetch(Name, Header) of
  	[Str] ->
  	    case sipheader:from([Str]) of
  		{_, URI} ->
  		    sanity_check_uri(Name ++ ":", URI, Header);
  		_ ->
  		    throw({sipparseerror, Header, 400, "Invalid " ++ Name ++ ": header"})
  	    end;
  	_ ->
  	    throw({sipparseerror, Header, 400, "Missing " ++ Name ++ ": header"})
      end.
  
  sanity_check_uri(Desc, {none, _, _, _, _, _}, Header) ->
      throw({sipparseerror, Header, 400, "No user part in " ++ Desc ++ " URL"});
  sanity_check_uri(Desc, {_, _, none, _, _}, Header) ->
      throw({sipparseerror, Header, 400, "No host part in " ++ Desc ++ " URL"});
  sanity_check_uri(_, URI, _) ->
      URI.
  
  check_supported_uri_scheme({unparseable, URIstr}, Header) ->
      case string:chr(URIstr, $:) of
  	0 ->
  	    throw({sipparseerror, Header, 416, "Unsupported URI Scheme"});
  	Index ->
  	    Scheme = string:substr(URIstr, 1, Index),
  	    throw({sipparseerror, Header, 416, "Unsupported URI Scheme (" ++ Scheme ++ ")"})
      end;
  check_supported_uri_scheme(URI, _) ->
      true.
  
negative.code: 
  check_packet({request, Method, URI, Header, Body}, Origin) ->
      check_supported_uri_scheme(URI, Header),
      sanity_check_contact(request, "From", Header),
      sanity_check_contact(request, "To", Header),
      case sipheader:cseq(keylist:fetch("CSeq", Header)) of
  	{unparseable, CSeqStr} ->
  	    logger:log(error, "INVALID CSeq ~p in packet from ~s", [CSeqStr, origin2str(Origin, "unknown")]),
  	    throw({sipparseerror, request, Header, 400, "Invalid CSeq"});
  	{CSeqNum, CSeqMethod} ->
  	    case util:isnumeric(CSeqNum) of
  		false ->
  		    throw({sipparseerror, request, Header, 400, "CSeq number " ++ CSeqNum ++ " is not an integer"});	
  		_ -> true
  	    end,
  	    if
  		CSeqMethod /= Method ->
  		    throw({sipparseerror, request, Header, 400, "CSeq Method " ++ CSeqMethod ++ " does not match request Method " ++ Method});
  		true -> true
  	    end
      end,
  