anchor.diff:  parse_all_headers(Msg) when is_record(Msg, sip_request); is_record(Msg, sip_response) ->
       Headers = [{Name, sip_headers:parse(Name, Value)} || {Name, Value} <- headers(Msg)],
       set_headers(Msg, Headers).
  +
  +
  +%% @doc Validate that request contains all required headers
  +%% A valid SIP request formulated by a UAC MUST, at a minimum, contain
  +%% the following header fields: To, From, CSeq, Call-ID, Max-Forwards,
  +%% and Via; all of these header fields are mandatory in all SIP
  +%% requests.
  +%% FIXME: UAC should validate generated request according to 12.1.2
  +%% @end
  +-spec validate_request(#sip_request{}) -> ok | {error, Reason :: term()}.
  +validate_request(#sip_request{method = Method} = Msg) ->
  +    do([error_m ||
  +        check(count(to, Msg) =:= 1, {invalid, to}),
  +        check(count(from, Msg) =:= 1, {invalid, from}),
  +        check(count(cseq, Msg) =:= 1, {invalid, cseq}),
  +        check(count('call-id', Msg) =:= 1, {invalid, 'call-id'}),
  +        check(count('max-forwards', Msg) =:= 1, {invalid, 'max-forwards'}),
  +        check(count(via, Msg) >= 1, {invalid, via}),
  +        check(Method =/= 'INVITE' orelse is_single_contact(Msg), {invalid, contact}), % 8.1.1.8
  +        check(is_contact_secure(Msg), {invalid, contact_must_be_sips})]).
  +
  +%% @doc Validate that response contains all required headers
  +%% A valid SIP response formulated by a UAS MUST, at a minimum, contain
  +%% the following header fields: To, From, CSeq, Call-ID and Via;
  +%% all of these header fields are mandatory in all SIP responses.
  +%%
  +%% FIXME: UAS should validate generated response according to 12.1.1
  +%% @end
  +-spec validate_response(#sip_response{}) -> ok | {error, Reason :: term()}.
  +validate_response(#sip_response{} = Msg) ->
  +    do([error_m ||
  +        check(count(to, Msg) =:= 1, {invalid, to}),
  +        check(count(from, Msg) =:= 1, {invalid, from}),
  +        check(count(cseq, Msg) =:= 1, {invalid, cseq}),
  +        check(count('call-id', Msg) =:= 1, {invalid, 'call-id'}),
  +        check(count(via, Msg) >= 1, {invalid, via})]).
   
   %%-----------------------------------------------------------------
   %% Internal functions
  
positive.code: %%-----------------------------------------------------------------
  %% Exports
  %%-----------------------------------------------------------------
  -export([is_dialog_establishing/1, method/1]).
  -export([parse_stream/2, parse_datagram/1, parse_all_headers/1, to_binary/1]).
  -export([create_ack/2, create_response/2, create_response/3]).
  -export([validate_request/1, validate_response/1]).
  -export([update_top_header/3, replace_top_header/3, append_header/3]).
  -export([header_values/2, header_top_value/2, has_header/2]).
  -export([with_branch/2, foldl_headers/4]).
  
negative.code: -spec create_response(sip_message(), integer()) -> #sip_response{}.
  create_response(Request, Status) ->
      create_response(Request, Status, default_reason(Status)).
  
  %% @doc
  %% Parses the datagram for SIP packet. The headers of the returned message are
  