anchor.diff:  -module(sippacket).
  --export([parse/2, parse_packet/1, parse_packet/2, parseheader/1, parserequest/1]).
  -
  +%%-compile(export_all).
  +
  +%%--------------------------------------------------------------------
  +%% External exports
  +%%--------------------------------------------------------------------
  +-export([
  +	 parse/2,
  +	 parse_packet/1,
  +	 parse_packet/2,
  +	 parseheader/1,
  +	 test/0
  +	]).
  +
  +%%--------------------------------------------------------------------
  +%% Internal exports
  +%%--------------------------------------------------------------------
  +
  +%%--------------------------------------------------------------------
  +%% Include files
  +%%--------------------------------------------------------------------
   -include("sipsocket.hrl").
   -include("siprecords.hrl").
   
  +%%--------------------------------------------------------------------
  +%% Records
  +%%--------------------------------------------------------------------
  +
  +%%--------------------------------------------------------------------
  +%% Macros
  +%%--------------------------------------------------------------------
  +
  +%%====================================================================
  +%% External functions
  +%%====================================================================
  +
  +%%--------------------------------------------------------------------
  +%% Function: parse(Packet, Origin)
  +%% Descrip.: Parse a packet received from the network into either a
  +%%           request or a response record()
  +%% Returns : {request, Request}   |
  +%%           {response, Response} |
  +%%           {siperror, Status, Reason}
  +%%           Request  = request record()
  +%%           Response = response record()
  +%%           Status   = integer(), SIP status code
  +%%           Reason   = string(), SIP reason phrase
  +%%--------------------------------------------------------------------
  +parse(Packet, Origin) ->
  +    case parse_packet(Packet, Origin) of
  +	keepalive ->
  +	    keepalive;
  +	{HeaderStr, BodyStr} ->
  +	    {FirstLine, Headerkeylist} = parseheader(HeaderStr),
  +	    case parse_firstline(FirstLine) of
  +		{request, Parsed} ->
  +		    %% XXX move data from SIP URI:s such as
  +		    %%   sips:alice@atlanta.com?subject=project%20x&priority=urgent
  +		    %% into Headerkeylist and strip them from the URI. See
  +		    %% RFC 3261 19.1.5 Forming Requests from a URI
  +		    request(Parsed, Headerkeylist, BodyStr);
  +		{response, Parsed} ->
  +		    response(Parsed, Headerkeylist, BodyStr);
  +		none ->
  +		    {siperror, 400, "Completely unparseable request/response"}
  +	    end
  +    end.
  +
  +%%--------------------------------------------------------------------
  +%% Function: parse_packet(Packet, Origin) ->
  +%%           parse_packet(Packet)
  +%%           Packet = string()
  +%%           Origin = siporigin record() | none
  +%% Descrip.: 'Fix' line breaks in Packet and then find the header-
  +%%           body separator.
  +%% Returns : {HeaderStr, BodyStr} |
  +%%           {keepalive}
  +%%           HeaderStr = string()
  +%%           BodyStr   = string()
  +%%--------------------------------------------------------------------
   parse_packet(Packet) ->
       parse_packet(Packet, none).
   
  
positive.code: 	    none;
  	Method ->
  	    Index2 = string:rchr(Rest, 32),
  	    URI = string:substr(Rest, 1, Index2 - 1),
  	    "SIP/2.0" = string:strip(string:substr(Rest, Index2 + 1),
  				     left),
  	    {request, {Method, URI}}
      end.
  
  request({Method, URI}, Header, Body) ->
  %    io:format("Request:~p~n", [{Method, URI}]),
      URL = sipurl:parse(URI),
      #request{method=Method, uri=URL, header=Header, body=Body}.
  
  response({Status, Reason}, Header, Body) ->
  %    io:format("Response:~p~n", [Status]),
      #response{status=list_to_integer(Status), reason=Reason, header=Header, body=Body}.
  
negative.code: 	S ->
  	    logger:log(debug, "Keep-alive packet from ~s", [S])
      end,
      keepalive;
  parse_packet(Packet, Origin) ->
      case sipserver:origin2str(Origin, none) of
  	none -> true;
  